Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"os"
"path/filepath"
"slices"

"github.com/BurntSushi/toml"
)
Expand Down Expand Up @@ -58,8 +59,8 @@ func NewConfig() (*Config, error) {
}

// Reverse because /etc takes precedence in stateless
for i := len(ConfigPaths) - 1; i >= 0; i-- {
globPat := filepath.Join(ConfigPaths[i], fmt.Sprintf("*%s", ConfigSuffix))
for _, path := range slices.Backward(ConfigPaths) {
globPat := filepath.Join(path, fmt.Sprintf("*%s", ConfigSuffix))

configs, _ := filepath.Glob(globPat)

Expand Down
17 changes: 7 additions & 10 deletions builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
)

// DisableColors controls whether or not to use colours in the display.
Expand Down Expand Up @@ -54,9 +55,11 @@ const (
// CacheDirectory is where packages' build cache are stored.
CacheDirectory = "/var/lib/solbuild/cache"

// Obsolete cache directories. These are only still specified so that the
// `delete-cache -a` subcommand will remove them. In the future they will
// be removed.
/* Obsolete cache directories. These are only still specified so that the
* `delete-cache -a` subcommand will remove them. In the future they will
* be removed.
*/

ObsoleteCcacheDirectory = "/var/lib/solbuild/ccache/ypkg"
ObsoleteLegacyCcacheDirectory = "/var/lib/solbuild/ccache/legacy"
ObsoleteSccacheDirectory = "/var/lib/solbuild/sccache/ypkg"
Expand Down Expand Up @@ -100,13 +103,7 @@ func PathExists(path string) bool {

// IsValidImage will check if the specified profile is a valid one.
func IsValidImage(profile string) bool {
for _, p := range ValidImages {
if p == profile {
return true
}
}

return false
return slices.Contains(ValidImages, profile)
}

// EmitImageError emits the stock response to requesting an invalid image.
Expand Down
6 changes: 2 additions & 4 deletions builder/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,8 @@ func ValidMemSize(s string) bool {
lastChar := s[len(s)-1:]
validLastChars := []string{"G", "T", "P", "E"}

for _, v := range validLastChars {
if v == lastChar {
return true
}
if slices.Contains(validLastChars, lastChar) {
return true
}

slog.Error(fmt.Sprintf("Invalid Memory Size: %s doesn't end in a valid memory unit, e.g. G\n", s))
Expand Down