Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add apx support #795

Merged
merged 7 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,15 @@ checkcoverage:
lint:
@if ! $(gopath)/bin/golangci-lint --version &>/dev/null; then \
echo "Installing linters..."; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(gopath)/bin v1.22.2; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(gopath)/bin v1.55.2; \
fi
@$(gopath)/bin/golangci-lint run --deadline=10m --tests --disable-all \
--enable=misspell \
--enable=vet \
--enable=ineffassign \
--enable=gofmt \
$${CYCLO_MAX:+--enable=gocyclo --cyclo-over=$${CYCLO_MAX}} \
--enable=golint \
--enable=deadcode \
--enable=varcheck \
--enable=structcheck \
--enable=revive \
--enable=unused \
--enable=vetshadow \
--enable=errcheck \
Expand Down
21 changes: 10 additions & 11 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (b *Builder) InitMix(upstreamVer string, mixVer string, allLocal bool, allU

// Clean up the upstream bundles folder and its contents
if err := os.RemoveAll(upstreamBundlesBaseDir); err != nil {
return errors.Wrap(err, "Failed to delete upstream-bundles dir.")
return errors.Wrap(err, "Failed to delete upstream-bundles dir")
}

if err := b.AddBundles(bundles, allLocal, allUpstream, false); err != nil {
Expand Down Expand Up @@ -440,7 +440,7 @@ func (b *Builder) BuildImage(format string, configFile string) error {
// The previous ister.py configuration file exist,
// we need to migrate it to clr-installer YAML
log.Warning(log.Mixer, "Previous generation image config %s found", migrationFile)
if err = b.migrateConfigFile(migrationFile, configFile); err != nil {
if err = b.migrateConfigFile(migrationFile); err != nil {
return err
}
}
Expand All @@ -450,16 +450,15 @@ func (b *Builder) BuildImage(format string, configFile string) error {

// If the legacy JSON file exists, rename the old file to prevent migration
// each time we build and discourage the user from using the old JSON file.
if _, err := os.Stat(migrationFile); os.IsNotExist(err) {
} else if err != nil {
if _, err := os.Stat(migrationFile); err != nil && !os.IsNotExist(err) {
return err
} else {
renameFile := migrationFile + "-EOL"
log.Info(log.Mixer, " Renaming previous generation config %s to %s", migrationFile, renameFile)
if mvErr := os.Rename(migrationFile, renameFile); mvErr != nil {
log.Warning(log.Mixer, "Failed to rename %s: %v", migrationFile, mvErr)
}
}
renameFile := migrationFile + "-EOL"
log.Info(log.Mixer, " Renaming previous generation config %s to %s", migrationFile, renameFile)
if mvErr := os.Rename(migrationFile, renameFile); mvErr != nil {
log.Warning(log.Mixer, "Failed to rename %s: %v", migrationFile, mvErr)
}

} else {
if !strings.HasSuffix(configFile, "yaml") {
return fmt.Errorf("build configuration file '%s' must end in .yaml", configFile)
Expand Down Expand Up @@ -489,7 +488,7 @@ func (b *Builder) BuildImage(format string, configFile string) error {
// migrateConfigFile will generate a clr-install YAML file based on the existing
// ister JSON file. We will also rename the existing ister JSON to prevent it
// from being migrated a second time.
func (b *Builder) migrateConfigFile(migrationFile, configFile string) error {
func (b *Builder) migrateConfigFile(migrationFile string) error {
log.Info(log.Mixer, "Migrating image config from %s to %s", migrationConfig, buildConfig)

convertCmd := exec.Command("clr-installer", "--json-yaml", migrationFile, "--iso", "--keep-image")
Expand Down
2 changes: 1 addition & 1 deletion builder/bundle_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (b *Builder) getUpstreamBundles() error {

// Make the folder to store upstream bundles if does not exist
if err := os.MkdirAll(upstreamBundlesBaseDir, 0777); err != nil {
return errors.Wrap(err, "Failed to create upstream-bundles dir.")
return errors.Wrap(err, "Failed to create upstream-bundles dir")
}

// Download the upstream bundles
Expand Down
4 changes: 2 additions & 2 deletions builder/bundle_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestSetPackagesList(t *testing.T) {
}
}

func mustCreateTempBundleDirs(t *testing.T, b *Builder, d string) {
func mustCreateTempBundleDirs(t *testing.T, b *Builder) {
t.Helper()

var err error
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestGetBundlePath(t *testing.T) {
b.UpstreamVer = "10"
b.Config = config.MixConfig{}
b.Config.LoadDefaultsForPath(d)
mustCreateTempBundleDirs(t, b, d)
mustCreateTempBundleDirs(t, b)

testCases := []struct {
name string
Expand Down
22 changes: 15 additions & 7 deletions builder/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,19 @@ func resolveFilesForBundle(bundle *bundle, repoPkgs repoPkgMap, packagerCmd []st
// Last metadata expiration check: 0:00:00 ago on Wed 07 Mar 2018 04:05:44 PM PS
// Dependencies resolved.
// =============================================================================
// Package Arch Version
//
// Package Arch Version
//
// =============================================================================
// Installing:
// systemd-boot x86_64 234-166
//
// systemd-boot x86_64 234-166
//
// Installing dependencies:
// Linux-PAM x86_64 1.2.1-33
// <more packages>
// zlib-lib x86_64 1.2.8.jtkv4-43
//
// Linux-PAM x86_64 1.2.1-33
// <more packages>
// zlib-lib x86_64 1.2.8.jtkv4-43
//
// Transaction Summary
// =============================================================================
Expand All @@ -224,10 +229,13 @@ func resolveFilesForBundle(bundle *bundle, repoPkgs repoPkgMap, packagerCmd []st
// Last metadata expiration check: 0:00:00 ago on Wed 07 Mar 2018 04:33:18 PM PS
// Dependencies resolved.
// =============================================================================
// Package Arch Version
//
// Package Arch Version
//
// =============================================================================
// Installing:
// shim x86_64 12-10
//
// shim x86_64 12-10
//
// Transaction Summary
// =============================================================================
Expand Down
6 changes: 3 additions & 3 deletions builder/bundleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type bundleSet map[string]*bundle
// validateAndFillBundleSet will validate a bundleSet and fill in the Allpackage
// fields in each bundle. Specifically, it will validate that a bundleSet meets
// the following constraints:
// 1) Completeness. For each bundle in the set, every bundle included by that
// bundle is also in the set.
// 2) Cycle-Free. The set contains no bundle include cycles.
// 1. Completeness. For each bundle in the set, every bundle included by that
// bundle is also in the set.
// 2. Cycle-Free. The set contains no bundle include cycles.
func validateAndFillBundleSet(bundles bundleSet) error {
// Sort the bundles so that all includes and optional (also-add) includes appear
// before a bundle, then calculate AllPackages for each bundle.
Expand Down
4 changes: 2 additions & 2 deletions builder/repo_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (b *Builder) RemoveRepo(name string) error {
_, err = DNFConf.GetSection(name)
if err != nil {
log.Debug(log.Mixer, err.Error())
return errors.Errorf("unable to remove repo %s, does not exist.", name)
return errors.Errorf("unable to remove repo %s, does not exist", name)
}

DNFConf.DeleteSection(name)
Expand Down Expand Up @@ -411,7 +411,7 @@ func (b *Builder) AddRPMList(rpms []string) error {
if strings.HasSuffix(rpm, ".src.rpm") {
log.Info(log.Mixer, "Removing %s because source RPMs are not supported in mixes.", rpm)
if err := os.RemoveAll(filepath.Join(b.Config.Mixer.LocalRPMDir, rpm)); err != nil {
return errors.Wrapf(err, "Failed to remove %s, your mix will not generate properly with source RPMs included.", rpm)
return errors.Wrapf(err, "Failed to remove %s, your mix will not generate properly with source RPMs included", rpm)
}
}
log.Info(log.Mixer, "Hardlinking %s to repodir", rpm)
Expand Down
2 changes: 1 addition & 1 deletion builder/stopwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (sw *stopWatch) Stop() {
e.d = time.Since(sw.t)
}

func (sw *stopWatch) WriteSummary(w io.Writer) {
func (sw *stopWatch) WriteSummary(_ io.Writer) {
if len(sw.entries) == 0 {
return
}
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (config *MixConfig) expandEnv() error {

for _, s := range matches {
if _, ok := os.LookupEnv(s[1]); !ok {
return errors.Errorf("buildconf contains an undefined environment variable: %s\n", s[1])
return errors.Errorf("buildconf contains an undefined environment variable: %s", s[1])
}
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ module github.com/clearlinux/mixer-tools
go 1.18

require (
github.com/BurntSushi/toml v1.3.0
github.com/BurntSushi/toml v1.3.2
github.com/go-ini/ini v1.67.0
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA=
github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -20,8 +20,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
Expand Down
4 changes: 2 additions & 2 deletions mixer/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ var buildDeltaManifestsFlags struct {
to uint32
}

func runBuildDeltaPacks(cmd *cobra.Command, args []string) error {
func runBuildDeltaPacks(cmd *cobra.Command, _ []string) error {
if err := checkRoot(); err != nil {
fail(err)
}
Expand All @@ -708,7 +708,7 @@ func runBuildDeltaPacks(cmd *cobra.Command, args []string) error {
return nil
}

func runBuildDeltaManifests(cmd *cobra.Command, args []string) error {
func runBuildDeltaManifests(cmd *cobra.Command, _ []string) error {
if err := checkRoot(); err != nil {
fail(err)
}
Expand Down
14 changes: 7 additions & 7 deletions mixer/cmd/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func init() {
addRepoCmd.Flags().Uint32Var(&repoAddFlags.priority, "priority", 1, "Repo priority between 1 and 99, where 1 is highest")
}

func runExcludesRepo(cmd *cobra.Command, args []string) {
func runExcludesRepo(_ *cobra.Command, args []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -125,7 +125,7 @@ func runExcludesRepo(cmd *cobra.Command, args []string) {
log.Info(log.Mixer, "Excluded packages from repo %s:\n%s", args[0], strings.Join(args[1:], "\n"))
}

func runPriorityRepo(cmd *cobra.Command, args []string) {
func runPriorityRepo(_ *cobra.Command, args []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -145,7 +145,7 @@ type repoAddCmdFlags struct {

var repoAddFlags repoAddCmdFlags

func runAddRepo(cmd *cobra.Command, args []string) {
func runAddRepo(_ *cobra.Command, args []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -169,7 +169,7 @@ func runAddRepo(cmd *cobra.Command, args []string) {
log.Info(log.Mixer, "Adding repo %s with url %s and priority %d", args[0], u.String(), repoAddFlags.priority)
}

func runRemoveRepo(cmd *cobra.Command, args []string) {
func runRemoveRepo(_ *cobra.Command, args []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -181,7 +181,7 @@ func runRemoveRepo(cmd *cobra.Command, args []string) {
}
}

func runListRepos(cmd *cobra.Command, args []string) {
func runListRepos(_ *cobra.Command, _ []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -193,7 +193,7 @@ func runListRepos(cmd *cobra.Command, args []string) {
}
}

func runInitRepo(cmd *cobra.Command, args []string) {
func runInitRepo(_ *cobra.Command, _ []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -205,7 +205,7 @@ func runInitRepo(cmd *cobra.Command, args []string) {
}
}

func runSetURLRepo(cmd *cobra.Command, args []string) {
func runSetURLRepo(_ *cobra.Command, args []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand Down
2 changes: 1 addition & 1 deletion mixer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func hasMarker(cmd *cobra.Command, marker string) bool {

func checkRoot() error {
if uid := os.Geteuid(); uid != 0 {
return errors.Errorf("This command requires root (uid=%d)\n", uid)
return errors.Errorf("This command requires root (uid=%d)", uid)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion mixer/cmd/rpms.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
}
}

func runAddRPM(cmd *cobra.Command, args []string) {
func runAddRPM(_ *cobra.Command, _ []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand Down
4 changes: 2 additions & 2 deletions mixer/cmd/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func init() {
versionsUpdateCmd.Flags().BoolVar(&versionsUpdateFlags.skipFormatCheck, "skip-format-check", false, "Skip format bump check")
}

func runVersions(cmd *cobra.Command, args []string) {
func runVersions(_ *cobra.Command, _ []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand All @@ -82,7 +82,7 @@ func runVersions(cmd *cobra.Command, args []string) {
}
}

func runVersionsUpdate(cmd *cobra.Command, args []string) {
func runVersionsUpdate(_ *cobra.Command, _ []string) {
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
Expand Down
23 changes: 11 additions & 12 deletions swupd/create_manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,23 @@ func initBundles(ui UpdateInfo, c config, numWorkers int) ([]*Manifest, error) {
tmpManifests = append(tmpManifests, bundle)
mux.Unlock()
continue
} else {
log.Info(log.Mixer, "- %s", bundleName)
biPath := filepath.Join(c.imageBase, fmt.Sprint(ui.version), bundle.Name+"-info")
if _, err = os.Stat(biPath); os.IsNotExist(err) {
err = syncToFull(ui.version, bundle.Name, c.imageBase)
if err != nil {
errorChan <- err
return
}
}

err = bundle.GetBundleInfo(c.stateDir, biPath)
}
log.Info(log.Mixer, "- %s", bundleName)
biPath := filepath.Join(c.imageBase, fmt.Sprint(ui.version), bundle.Name+"-info")
if _, err = os.Stat(biPath); os.IsNotExist(err) {
err = syncToFull(ui.version, bundle.Name, c.imageBase)
if err != nil {
errorChan <- err
return
}
}

err = bundle.GetBundleInfo(c.stateDir, biPath)
if err != nil {
errorChan <- err
return
}

mux.Lock()
tmpManifests = append(tmpManifests, bundle)
mux.Unlock()
Expand Down
Loading
Loading