diff --git a/cmd/pkg.go b/cmd/pkg.go index f1fcb739..dfe94746 100644 --- a/cmd/pkg.go +++ b/cmd/pkg.go @@ -23,11 +23,11 @@ import ( "github.com/vanilla-os/orchid/cmdr" ) -var validPkgArgs = []string{"add", "remove", "list"} +var validPkgArgs = []string{"add", "remove", "list", "apply"} func NewPkgCommand() *cmdr.Command { cmd := cmdr.NewCommand( - "pkg add|remove|list", + "pkg add|remove|list|apply", abroot.Trans("pkg.long"), abroot.Trans("pkg.short"), pkg, @@ -88,6 +88,18 @@ func pkg(cmd *cobra.Command, args []string) error { cmdr.Info.Printf(abroot.Trans("pkg.listMsg"), added, removed) return nil + case "apply": + aBsys, err := core.NewABSystem() + if err != nil { + cmdr.Error.Println(err) + return err + } + + err = aBsys.RunOperation(core.APPLY) + if err != nil { + cmdr.Info.Println(abroot.Trans("pkg.applyFailed")) + return err + } } return nil diff --git a/cmd/upgrade.go b/cmd/upgrade.go index c194b491..e370b332 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -81,7 +81,14 @@ func upgrade(cmd *cobra.Command, args []string) error { return err } - err = aBsys.Upgrade(force) + var operation core.ABSystemOperation + if force { + operation = core.FOCE_UPGRADE + } else { + operation = core.UPGRADE + } + + err = aBsys.RunOperation(operation) if err != nil { if err == core.NoUpdateError { cmdr.Info.Println(abroot.Trans("upgrade.noUpdateAvailable")) diff --git a/core/oci.go b/core/oci.go index e9dc5eeb..016b7cdf 100644 --- a/core/oci.go +++ b/core/oci.go @@ -14,15 +14,17 @@ package core */ import ( + "context" "errors" "os" "path/filepath" + "github.com/containers/buildah" "github.com/vanilla-os/abroot/settings" "github.com/vanilla-os/prometheus" ) -// GenerateRootfs generates a rootfs from a image recipe file +// OciExportRootFs generates a rootfs from a image recipe file func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error { PrintVerbose("OciExportRootFs: running...") @@ -105,3 +107,81 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s return nil } + +// FindImageWithLabel returns the name of the first image containinig the provided key-value pair +// or an empty string if none was found +func FindImageWithLabel(key, value string) (string, error) { + PrintVerbose("FindImageWithLabel: running...") + + pt, err := prometheus.NewPrometheus( + "/var/lib/abroot/storage", + "overlay", + settings.Cnf.MaxParallelDownloads, + ) + if err != nil { + PrintVerbose("FindImageWithLabel:err: %s", err) + return "", err + } + + images, err := pt.Store.Images() + if err != nil { + PrintVerbose("FindImageWithLabel:err(2): %s", err) + return "", err + } + + for _, img := range images { + // This is the only way I could find to get the labels form an image + builder, err := buildah.ImportBuilderFromImage(context.Background(), pt.Store, buildah.ImportFromImageOptions{Image: img.ID}) + if err != nil { + PrintVerbose("FindImageWithLabel:err(3): %s", err) + return "", err + } + + val, ok := builder.Labels()[key] + if ok && val == value { + return img.Names[0], nil + } + } + + return "", nil +} + +// DeleteImageForRoot retrieves the image created for the provided root ("vos-a"|"vos-b") +func RetrieveImageForRoot(root string) (string, error) { + PrintVerbose("ApplyInImageForRoot: running...") + + image, err := FindImageWithLabel("ABRoot.root", root) + if err != nil { + PrintVerbose("ApplyInImageForRoot:err: %s", err) + return "", err + } + + return image, nil +} + +// DeleteImageForRoot deletes the image created for the provided root ("vos-a"|"vos-b") +func DeleteImageForRoot(root string) error { + image, err := RetrieveImageForRoot(root) + if err != nil { + PrintVerbose("DeleteImageForRoot:err: %s", err) + return err + } + + pt, err := prometheus.NewPrometheus( + "/var/lib/abroot/storage", + "overlay", + settings.Cnf.MaxParallelDownloads, + ) + if err != nil { + PrintVerbose("DeleteImageForRoot:err(2): %s", err) + return err + } + + _, err = pt.Store.DeleteImage(image, true) + if err != nil { + PrintVerbose("DeleteImageForRoot:err(3): %s", err) + return err + } + + return nil +} diff --git a/core/packages.go b/core/packages.go index 7a9575cb..6e474775 100644 --- a/core/packages.go +++ b/core/packages.go @@ -27,22 +27,32 @@ import ( type PackageManager struct{} const ( - PackagesBaseDir = "/etc/abroot" - PackagesAddFile = "packages.add" - PackagesRemoveFile = "packages.remove" + PackagesBaseDir = "/etc/abroot" + PackagesAddFile = "packages.add" + PackagesRemoveFile = "packages.remove" + PackagesUnstagedFile = "packages.unstaged" ) +const ( + ADD = "+" + REMOVE = "-" +) + +// An unstaged package is a package that is waiting to be applied +// to the next root. +// +// Every time a `pkg apply` or `upgrade` operation +// is executed, all unstaged packages are consumed and added/removed +// in the next root. +type UnstagedPackage struct { + Name, Status string +} + // NewPackageManager returns a new PackageManager struct func NewPackageManager() *PackageManager { PrintVerbose("PackageManager.NewPackageManager: running...") - err := os.MkdirAll(PackagesAddFile, 0755) - if err != nil { - PrintVerbose("PackageManager.NewPackageManager:err: " + err.Error()) - panic(err) - } - - err = os.MkdirAll(PackagesRemoveFile, 0755) + err := os.MkdirAll(PackagesBaseDir, 0755) if err != nil { PrintVerbose("PackageManager.NewPackageManager:err: " + err.Error()) panic(err) @@ -81,11 +91,25 @@ func NewPackageManager() *PackageManager { func (p *PackageManager) Add(pkg string) error { PrintVerbose("PackageManager.Add: running...") - pkgs, err := p.GetAddPackages() + // Add to unstaged packages first + upkgs, err := p.GetUnstagedPackages() if err != nil { PrintVerbose("PackageManager.Add:err: " + err.Error()) return err } + upkgs = append(upkgs, UnstagedPackage{pkg, ADD}) + err = p.writeUnstagedPackages(upkgs) + if err != nil { + PrintVerbose("PackageManager.Add:err(2): " + err.Error()) + return err + } + + // Modify added packages list + pkgs, err := p.GetAddPackages() + if err != nil { + PrintVerbose("PackageManager.Add:err(3): " + err.Error()) + return err + } for _, p := range pkgs { if p == pkg { @@ -104,19 +128,35 @@ func (p *PackageManager) Add(pkg string) error { func (p *PackageManager) Remove(pkg string) error { PrintVerbose("PackageManager.Remove: running...") - apkgs, err := p.GetAddPackages() + // Add to unstaged packages first + upkgs, err := p.GetUnstagedPackages() + if err != nil { + PrintVerbose("PackageManager.Add:err: " + err.Error()) + return err + } + upkgs = append(upkgs, UnstagedPackage{pkg, REMOVE}) + err = p.writeUnstagedPackages(upkgs) if err != nil { - PrintVerbose("PackageManager.Remove:err: " + err.Error()) + PrintVerbose("PackageManager.Remove:err(2): " + err.Error()) return err } - for i, apkg := range apkgs { - if apkg == pkg { - apkgs = append(apkgs[:i], apkgs[i+1:]...) - return p.writeAddPackages(apkgs) + // If package was added by the user, simply remove it from packages.add + // Unstaged will take care of the rest + pkgs, err := p.GetAddPackages() + if err != nil { + PrintVerbose("PackageManager.Remove:err(3): " + err.Error()) + return err + } + for i, ap := range pkgs { + if ap == pkg { + pkgs = append(pkgs[:i], pkgs[i+1:]...) + PrintVerbose("PackageManager.Remove: removing manually added package") + return p.writeAddPackages(pkgs) } } + // Otherwise, add package to packages.remove PrintVerbose("PackageManager.Remove: writing packages.remove") return p.writeRemovePackages(pkg) } @@ -133,6 +173,34 @@ func (p *PackageManager) GetRemovePackages() ([]string, error) { return p.getPackages(PackagesRemoveFile) } +// GetUnstagedPackages returns the package changes that are yet to be applied +func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error) { + PrintVerbose("PackageManager.GetUnstagedPackages: running...") + pkgs, err := p.getPackages(PackagesUnstagedFile) + if err != nil { + PrintVerbose("PackageManager.GetUnstagedPackages:err: ", err.Error()) + return nil, err + } + + unstagedList := []UnstagedPackage{} + for _, line := range pkgs { + if line == "" || line == "\n" { + continue + } + + splits := strings.SplitN(line, " ", 2) + unstagedList = append(unstagedList, UnstagedPackage{splits[1], splits[0]}) + } + + return unstagedList, nil +} + +// ClearUnstagedPackages removes all packages from the unstaged list +func (p *PackageManager) ClearUnstagedPackages() error { + PrintVerbose("PackageManager.ClearUnstagedPackages: running...") + return p.writeUnstagedPackages([]UnstagedPackage{}) +} + // GetAddPackages returns the packages in the packages.add file as string func (p *PackageManager) GetAddPackagesString(sep string) (string, error) { PrintVerbose("PackageManager.GetAddPackagesString: running...") @@ -209,6 +277,17 @@ func (p *PackageManager) writeRemovePackages(pkg string) error { return p.writePackages(PackagesRemoveFile, pkgs) } +func (p *PackageManager) writeUnstagedPackages(pkgs []UnstagedPackage) error { + PrintVerbose("PackageManager.writeUnstagedPackages: running...") + + pkgFmt := []string{} + for _, pkg := range pkgs { + pkgFmt = append(pkgFmt, fmt.Sprintf("%s %s", pkg.Status, pkg.Name)) + } + + return p.writePackages(PackagesUnstagedFile, pkgFmt) +} + func (p *PackageManager) writePackages(file string, pkgs []string) error { PrintVerbose("PackageManager.writePackages: running...") @@ -235,24 +314,52 @@ func (p *PackageManager) writePackages(file string, pkgs []string) error { return nil } -func (p *PackageManager) GetFinalCmd() string { - PrintVerbose("PackageManager.GetFinalCmd: running...") +func (p *PackageManager) processApplyPackages() (string, string) { + PrintVerbose("PackageManager.processApplyPackages: running...") + + unstaged, err := p.GetUnstagedPackages() + if err != nil { + PrintVerbose("PackageManager.processApplyPackages:err: %s", err.Error()) + } + + var addPkgs, removePkgs []string + for _, pkg := range unstaged { + if pkg.Status == ADD { + addPkgs = append(addPkgs, pkg.Name) + } else if pkg.Status == REMOVE { + removePkgs = append(removePkgs, pkg.Name) + } + } + finalAddPkgs := "" + if len(addPkgs) > 0 { + finalAddPkgs = fmt.Sprintf("%s %s", settings.Cnf.IPkgMngAdd, strings.Join(addPkgs, " ")) + } + + finalRemovePkgs := "" + if len(removePkgs) > 0 { + finalRemovePkgs = fmt.Sprintf("%s %s", settings.Cnf.IPkgMngRm, strings.Join(removePkgs, " ")) + } + + return finalAddPkgs, finalRemovePkgs +} + +func (p *PackageManager) processUpgradePackages() (string, string) { addPkgs, err := p.GetAddPackagesString(" ") if err != nil { PrintVerbose("PackageManager.GetFinalCmd:err: " + err.Error()) - return "" + return "", "" } removePkgs, err := p.GetRemovePackagesString(" ") if err != nil { PrintVerbose("PackageManager.GetFinalCmd:err(2): " + err.Error()) - return "" + return "", "" } if len(addPkgs) == 0 && len(removePkgs) == 0 { PrintVerbose("PackageManager.GetFinalCmd: no packages to install or remove") - return "true" + return "", "" } finalAddPkgs := "" @@ -265,6 +372,24 @@ func (p *PackageManager) GetFinalCmd() string { finalRemovePkgs = fmt.Sprintf("%s %s", settings.Cnf.IPkgMngRm, removePkgs) } + return finalAddPkgs, finalRemovePkgs +} + +func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string { + PrintVerbose("PackageManager.GetFinalCmd: running...") + + var finalAddPkgs, finalRemovePkgs string + if operation == APPLY { + finalAddPkgs, finalRemovePkgs = p.processApplyPackages() + } else { + err := p.ClearUnstagedPackages() + if err != nil { + PrintVerbose("PackageManager.GetFinalCmd:err: %s", err.Error()) + panic(err) + } + finalAddPkgs, finalRemovePkgs = p.processUpgradePackages() + } + cmd := "" if finalAddPkgs != "" && finalRemovePkgs != "" { cmd = fmt.Sprintf("%s && %s", finalAddPkgs, finalRemovePkgs) diff --git a/core/system.go b/core/system.go index ae8f11c4..8368839a 100644 --- a/core/system.go +++ b/core/system.go @@ -39,6 +39,14 @@ type QueuedFunction struct { Priority int } +const ( + UPGRADE = "upgrade" + FOCE_UPGRADE = "force-upgrade" + APPLY = "package-apply" +) + +type ABSystemOperation string + var ( queue []QueuedFunction lockFile string = filepath.Join("/tmp", "ABSystem.Upgrade.lock") @@ -304,25 +312,29 @@ exec /lib/systemd/systemd return nil } -// Upgrade upgrades the system to the latest available image -func (s *ABSystem) Upgrade(force bool) error { - PrintVerbose("ABSystem.Upgrade: starting upgrade") +// RunOperation executes a root-switching operation from the options below: +// +// UPGRADE: Upgrades to a new image, if available, +// FORCE_UPGRADE: Forces the upgrade operation, even if no new image is available, +// APPLY: Applies package changes, but doesn't update the system. +func (s *ABSystem) RunOperation(operation ABSystemOperation) error { + PrintVerbose("ABSystem.RunOperation: starting %s", operation) s.ResetQueue() // Stage 0: Check if upgrade is possible // ------------------------------------- - PrintVerbose("[Stage 0] -------- ABSystemUpgrade") + PrintVerbose("[Stage 0] -------- ABSystemRunOperation") if s.UpgradeLockExists() { err := errors.New("upgrades are locked, another is running or need a reboot") - PrintVerbose("ABSystemUpgrade:err(0): %s", err) + PrintVerbose("ABSystemRunOperation:err(0): %s", err) return err } err := s.LockUpgrade() if err != nil { - PrintVerbose("ABSystemUpgrade:err(0.1): %s", err) + PrintVerbose("ABSystemRunOperation:err(0.1): %s", err) return err } @@ -330,23 +342,28 @@ func (s *ABSystem) Upgrade(force bool) error { // Stage 1: Check if there is an update available // ------------------------------------------------ - PrintVerbose("[Stage 1] -------- ABSystemUpgrade") + PrintVerbose("[Stage 1] -------- ABSystemRunOperation") if s.UserLockRequested() { err := errors.New("upgrade locked per user request") - PrintVerbose("ABSystemUpgrade:err(1): %s", err) + PrintVerbose("ABSystemRunOperation:err(1): %s", err) return err } - newDigest, res := s.CheckUpdate() - if !res { - if force { - PrintVerbose("ABSystemUpgrade: No update available but --force is set. Proceeding...") - } else { - PrintVerbose("ABSystemUpgrade:err(1.1): %s", err) - s.RunCleanUpQueue("") - return NoUpdateError + var imageDigest string + if operation != APPLY { + var res bool + imageDigest, res = s.CheckUpdate() + if !res { + if operation != FOCE_UPGRADE { + PrintVerbose("ABSystemRunOperation:err(1.1): %s", err) + s.RunCleanUpQueue("") + return NoUpdateError + } + PrintVerbose("ABSystemRunOperation: No update available but --force is set. Proceeding...") } + } else { + imageDigest = s.CurImage.Digest } // Stage 2: Get the future root and boot partitions, @@ -356,23 +373,23 @@ func (s *ABSystem) Upgrade(force bool) error { // before the clean up was done). Finally run // the IntegrityCheck on the future root. // ------------------------------------------------ - PrintVerbose("[Stage 2] -------- ABSystemUpgrade") + PrintVerbose("[Stage 2] -------- ABSystemRunOperation") if s.UserLockRequested() { err := errors.New("upgrade locked per user request") - PrintVerbose("ABSystemUpgrade:err(2): %s", err) + PrintVerbose("ABSystemRunOperation:err(2): %s", err) return err } partFuture, err := s.RootM.GetFuture() if err != nil { - PrintVerbose("ABSystem.Upgrade:err(2.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(2.1): %s", err) return err } partBoot, err := s.RootM.GetBoot() if err != nil { - PrintVerbose("ABSystem.Upgrade:err(2.2): %s", err) + PrintVerbose("ABSystem.RunOperation:err(2.2): %s", err) return err } @@ -381,7 +398,7 @@ func (s *ABSystem) Upgrade(force bool) error { err = partFuture.Partition.Mount("/part-future/") if err != nil { - PrintVerbose("ABSystem.Upgrade:err(2.3: %s", err) + PrintVerbose("ABSystem.RunOperation:err(2.3: %s", err) return err } @@ -392,30 +409,64 @@ func (s *ABSystem) Upgrade(force bool) error { _, err = NewIntegrityCheck(partFuture, settings.Cnf.AutoRepair) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(2.4): %s", err) + PrintVerbose("ABSystem.RunOperation:err(2.4): %s", err) return err } // Stage 3: Make a imageRecipe with user packages // ------------------------------------------------ - PrintVerbose("[Stage 3] -------- ABSystemUpgrade") + PrintVerbose("[Stage 3] -------- ABSystemRunOperation") if s.UserLockRequested() { err := errors.New("upgrade locked per user request") - PrintVerbose("ABSystemUpgrade:err(3): %s", err) + PrintVerbose("ABSystemRunOperation:err(3): %s", err) return err } - labels := map[string]string{"maintainer": "'Generated by ABRoot'"} + futurePartition, err := s.RootM.GetFuture() + if err != nil { + PrintVerbose("ABSystemRunOperation:err(3.1): %s", err) + return err + } + + labels := map[string]string{ + "maintainer": "'Generated by ABRoot'", + "ABRoot.root": futurePartition.Label, + } args := map[string]string{} pkgM := NewPackageManager() - pkgsFinal := pkgM.GetFinalCmd() + pkgsFinal := pkgM.GetFinalCmd(operation) if pkgsFinal == "" { pkgsFinal = "true" } content := `RUN ` + pkgsFinal + + var imageName string + if operation == APPLY { + presentPartition, err := s.RootM.GetPresent() + if err != nil { + PrintVerbose("ABSystemRunOperation:err(3.2): %s", err) + return err + } + imageName, err = RetrieveImageForRoot(presentPartition.Label) + if err != nil { + PrintVerbose("ABSystemRunOperation:err(3.3): %s", err) + return err + } + } else { + imageName = strings.Split(settings.Cnf.FullImageName, ":")[0] + "@" + imageDigest + labels["ABRoot.BaseImageDigest"] = s.CurImage.Digest + } + + // Delete old image + err = DeleteImageForRoot(futurePartition.Label) + if err != nil { + PrintVerbose("ABSystemRunOperation:err(3.4): %s", err) + return err + } + imageRecipe := NewImageRecipe( - settings.Cnf.FullImageName, + imageName, labels, args, content, @@ -423,11 +474,11 @@ func (s *ABSystem) Upgrade(force bool) error { // Stage 4: Extract the rootfs // ------------------------------------------------ - PrintVerbose("[Stage 4] -------- ABSystemUpgrade") + PrintVerbose("[Stage 4] -------- ABSystemRunOperation") if s.UserLockRequested() { err := errors.New("upgrade locked per user request") - PrintVerbose("ABSystemUpgrade:err(4): %s", err) + PrintVerbose("ABSystemRunOperation:err(4): %s", err) return err } @@ -441,46 +492,46 @@ func (s *ABSystem) Upgrade(force bool) error { systemNew, ) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(4.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(4.1): %s", err) return err } // Stage 5: Write abimage.abr.new to future/ // ------------------------------------------------ - PrintVerbose("[Stage 5] ABSystemUpgrade") + PrintVerbose("[Stage 5] ABSystemRunOperation") if s.UserLockRequested() { err := errors.New("upgrade locked per user request") - PrintVerbose("ABSystemUpgrade:err(5): %s", err) + PrintVerbose("ABSystemRunOperation:err(5): %s", err) return err } - abimage := NewABImage(newDigest, settings.Cnf.FullImageName) + abimage := NewABImage(imageDigest, settings.Cnf.FullImageName) err = abimage.WriteTo(partFuture.Partition.MountPoint, "new") if err != nil { - PrintVerbose("ABSystem.Upgrade:err(5.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(5.1): %s", err) return err } // Stage 6: Generate /etc/fstab and /usr/sbin/init // ------------------------------------------------ - PrintVerbose("[Stage 6] -------- ABSystemUpgrade") + PrintVerbose("[Stage 6] -------- ABSystemRunOperation") err = s.GenerateFstab(systemNew, partFuture) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(6): %s", err) + PrintVerbose("ABSystem.RunOperation:err(6): %s", err) return err } err = s.GenerateSbinInit(systemNew, partFuture) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(6.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(6.1): %s", err) return err } // Stage 7: Update the bootloader // ------------------------------------------------ - PrintVerbose("[Stage 7] -------- ABSystemUpgrade") + PrintVerbose("[Stage 7] -------- ABSystemRunOperation") chroot, err := NewChroot( systemNew, @@ -488,7 +539,7 @@ func (s *ABSystem) Upgrade(force bool) error { partFuture.Partition.Device, ) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(7): %s", err) + PrintVerbose("ABSystem.RunOperation:err(7): %s", err) return err } @@ -501,7 +552,7 @@ func (s *ABSystem) Upgrade(force bool) error { }, ) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(7.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(7.1): %s", err) return err } @@ -513,36 +564,36 @@ func (s *ABSystem) Upgrade(force bool) error { partFuture.Partition.Uuid, ) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(7.2): %s", err) + PrintVerbose("ABSystem.RunOperation:err(7.2): %s", err) return err } // Stage 8: Sync /etc // ------------------------------------------------ - PrintVerbose("[Stage 8] -------- ABSystemUpgrade") + PrintVerbose("[Stage 8] -------- ABSystemRunOperation") newEtc := filepath.Join(systemNew, "/etc") err = s.SyncEtc(newEtc) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(8): %s", err) + PrintVerbose("ABSystem.RunOperation:err(8): %s", err) return err } // Stage 9: Mount boot partition // ------------------------------------------------ - PrintVerbose("[Stage 9] -------- ABSystemUpgrade") + PrintVerbose("[Stage 9] -------- ABSystemRunOperation") uuid := uuid.New().String() tmpBootMount := filepath.Join("/tmp", uuid) err = os.Mkdir(tmpBootMount, 0755) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(9): %s", err) + PrintVerbose("ABSystem.RunOperation:err(9): %s", err) return err } err = partBoot.Mount(tmpBootMount) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(9.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(9.1): %s", err) return err } @@ -550,11 +601,11 @@ func (s *ABSystem) Upgrade(force bool) error { // Stage 10: Atomic swap the rootfs and abimage.abr // ------------------------------------------------ - PrintVerbose("[Stage 10] -------- ABSystemUpgrade") + PrintVerbose("[Stage 10] -------- ABSystemRunOperation") err = AtomicSwap(systemOld, systemNew) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(10): %s", err) + PrintVerbose("ABSystem.RunOperation:err(10): %s", err) return err } @@ -566,13 +617,13 @@ func (s *ABSystem) Upgrade(force bool) error { // PartFuture may not have /abimage.abr if it got corrupted or was wiped. // In these cases, create a dummy file for the atomic swap. if _, err = os.Stat(oldABImage); os.IsNotExist(err) { - PrintVerbose("ABSystem.Upgrade: Creating dummy /part-future/abimage.abr") + PrintVerbose("ABSystem.RunOperation: Creating dummy /part-future/abimage.abr") os.Create(oldABImage) } err = AtomicSwap(oldABImage, newABImage) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(10.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(10.1): %s", err) return err } @@ -580,11 +631,11 @@ func (s *ABSystem) Upgrade(force bool) error { // Stage 11: Atomic swap the bootloader // ------------------------------------------------ - PrintVerbose("[Stage 11] -------- ABSystemUpgrade") + PrintVerbose("[Stage 11] -------- ABSystemRunOperation") grub, err := NewGrub(partBoot) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(11): %s", err) + PrintVerbose("ABSystem.RunOperation:err(11): %s", err) return err } @@ -594,11 +645,11 @@ func (s *ABSystem) Upgrade(force bool) error { // Just like in Stage 10, tmpBootMount/grub/grub.cfg.future may not exist. if _, err = os.Stat(grubCfgFuture); os.IsNotExist(err) { - PrintVerbose("ABSystem.Upgrade: Creating grub.cfg.future") + PrintVerbose("ABSystem.RunOperation: Creating grub.cfg.future") grubCfgContents, err := os.ReadFile(grubCfgCurrent) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(11.1): %s", err) + PrintVerbose("ABSystem.RunOperation:err(11.1): %s", err) } var replacerPairs []string @@ -622,12 +673,12 @@ func (s *ABSystem) Upgrade(force bool) error { err = AtomicSwap(grubCfgCurrent, grubCfgFuture) if err != nil { - PrintVerbose("ABSystem.Upgrade:err(11.2): %s", err) + PrintVerbose("ABSystem.RunOperation:err(11.2): %s", err) return err } } - PrintVerbose("ABSystem.Upgrade: upgrade completed") + PrintVerbose("ABSystem.RunOperation: upgrade completed") s.RunCleanUpQueue("") return nil } diff --git a/go.mod b/go.mod index 22aa9435..37ec3da5 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/containers/storage v1.46.1 github.com/spf13/cobra v1.7.0 github.com/vanilla-os/orchid v0.4.0 - github.com/vanilla-os/prometheus v0.1.5 + github.com/vanilla-os/prometheus v0.1.6 golang.org/x/sys v0.8.0 ) diff --git a/go.sum b/go.sum index e22b9c14..22324670 100644 --- a/go.sum +++ b/go.sum @@ -544,6 +544,8 @@ github.com/vanilla-os/orchid v0.4.0 h1:Phx+WSdcvXAV48rCLbAVMr5ePaJyqG1263ybHxOUv github.com/vanilla-os/orchid v0.4.0/go.mod h1:dNPvHxofO4hEXodEKXp0nLQDZhoHh8evCUXc6X1xLao= github.com/vanilla-os/prometheus v0.1.5 h1:cAv0XaFtE9dZYxYpluc/wcq9Wkg2FytwMzh67F8dV+s= github.com/vanilla-os/prometheus v0.1.5/go.mod h1:ChWuR5stilaf0KkHa+aNIj4ZtnfLJO1UOBtb4FiputY= +github.com/vanilla-os/prometheus v0.1.6 h1:FU+Ts+Hxwz6C0uflD05s836CxKytclTD56ZHzgxpp70= +github.com/vanilla-os/prometheus v0.1.6/go.mod h1:A65eiUB5ZJa1PLJeEW7gLuNJKKXJBFIvXnSEa5rbMQE= github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/vbauerster/mpb/v8 v8.3.0 h1:xw2eMJ6v5NP8Rd7yOVzU6OqnRPrS1yWAoLTrWe7W4Nc= diff --git a/vendor/github.com/vanilla-os/prometheus/client.go b/vendor/github.com/vanilla-os/prometheus/client.go index 7a71f93a..a5acc49b 100644 --- a/vendor/github.com/vanilla-os/prometheus/client.go +++ b/vendor/github.com/vanilla-os/prometheus/client.go @@ -184,7 +184,9 @@ func (p *Prometheus) BuildContainerFile(dockerfilePath string, imageName string) id, _, err := imagebuildah.BuildDockerfiles( context.Background(), p.Store, - define.BuildOptions{}, + define.BuildOptions{ + Output: imageName, + }, dockerfilePath, ) if err != nil { diff --git a/vendor/github.com/vanilla-os/prometheus/main.go b/vendor/github.com/vanilla-os/prometheus/main.go index 9238bf1c..66ad669b 100644 --- a/vendor/github.com/vanilla-os/prometheus/main.go +++ b/vendor/github.com/vanilla-os/prometheus/main.go @@ -1,5 +1,5 @@ package prometheus -var version = "0.1.5" +var version = "0.1.6" func main() {} diff --git a/vendor/modules.txt b/vendor/modules.txt index f3ac51f7..f4515952 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -689,7 +689,7 @@ github.com/vanilla-os/orchid github.com/vanilla-os/orchid/cmdr github.com/vanilla-os/orchid/log github.com/vanilla-os/orchid/roff -# github.com/vanilla-os/prometheus v0.1.5 +# github.com/vanilla-os/prometheus v0.1.6 ## explicit; go 1.19 github.com/vanilla-os/prometheus # github.com/vbatts/tar-split v0.11.3