From c6464e932f63546c66637096f591c045f5d5ca78 Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Mon, 11 Feb 2019 15:57:36 +0000 Subject: [PATCH] Finish the legacy base pkg migration to ports base migration. Remove the Appliance mode options, we're not going to need it after all. --- config.go | 2 -- defines.go | 4 --- doupdate.go | 79 ++++++++++++----------------------------------------- 3 files changed, 17 insertions(+), 68 deletions(-) diff --git a/config.go b/config.go index 117cb29..fbcb415 100644 --- a/config.go +++ b/config.go @@ -21,7 +21,6 @@ func loadconfig() bool { // Set some defaults for values that may not be in the config file s := ConfigFile{ - Appliance: false, Bootstrap: false, BootstrapFatal: false, TrainsPubKey: "", @@ -31,7 +30,6 @@ func loadconfig() bool { } // Set our gloabls now - appliancemode = s.Appliance bootstrap = s.Bootstrap bootstrapfatal = s.BootstrapFatal trainsurl = s.TrainsURL diff --git a/defines.go b/defines.go index b615bbf..fe6e154 100644 --- a/defines.go +++ b/defines.go @@ -36,9 +36,6 @@ var bootstrapfatal = false // Default pubkey used for trains var trainpubkey = "/usr/local/share/" + toolname + "/trains.pub" -// Are we running in appliance mode? -var appliancemode = false - // Package defaults //---------------------------------------------------- var PKGBIN = "pkg-static" @@ -109,7 +106,6 @@ type DelPkg struct { // Local configuration file type ConfigFile struct { - Appliance bool `json:"appliance"` Bootstrap bool `json:"bootstrap"` BootstrapFatal bool `json:"bootstrapfatal"` Cachedir string `json:"cachedir"` diff --git a/doupdate.go b/doupdate.go index 6f2b82a..f1cb22d 100644 --- a/doupdate.go +++ b/doupdate.go @@ -414,6 +414,11 @@ func checkbaseswitch() { return } + output, cmderr := exec.Command("tar", "czf", STAGEDIR + "/.etcbackup.tgz", "-C", STAGEDIR + "/etc", ".").Output() + if ( cmderr != nil ) { + sendinfomsg(string(output)) + sendfatalmsg("Failed saving /etc configuration") + } // Make sure pkg is fetched sendinfomsg("Fetching new base") logtofile("Fetching new base") @@ -425,9 +430,9 @@ func checkbaseswitch() { // Get list of packages we need to nuke shellcmd := PKGBIN + " query '%o %n-%v' | grep '^base ' | awk '{print $2}'" - output, cmderr := exec.Command("/bin/sh", "-c", shellcmd).Output() + output, cmderr = exec.Command("/bin/sh", "-c", shellcmd).Output() if ( cmderr != nil ) { - log.Fatal("Failed getting base package list") + sendfatalmsg("Failed getting base package list") } basepkgs := strings.TrimSpace(string(output)) @@ -464,6 +469,15 @@ func checkbaseswitch() { fullout, err := pkgcmd.CombinedOutput() sendinfomsg(string(fullout)) logtofile(string(fullout)) + + // Copy back the /etc changes + output, cmderr = exec.Command("tar", "xf", STAGEDIR + "/.etcbackup.tgz", "-C", STAGEDIR + "/etc").Output() + if ( cmderr != nil ) { + sendinfomsg(string(output)) + sendfatalmsg("Failed updating /etc configuration") + } + exec.Command("rm", STAGEDIR + "/.etcbackup.tgz").Run() + } func updateincremental(force bool) { @@ -532,61 +546,6 @@ func updateincremental(force bool) { } -func updatefresh() { - sendinfomsg("Starting appliance update") - logtofile("ApplianceUpdate\n-----------------------") - - // Start by removing everything from this new BE - pkgcmd := exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "delete", "-y") - fullout, err := pkgcmd.CombinedOutput() - sendinfomsg(string(fullout)) - logtofile(string(fullout)) - - // Setup our main process to install the entire pkg repo - cmd := exec.Command(PKGBIN) - cmd.Args = append(cmd.Args, "-c") - cmd.Args = append(cmd.Args, STAGEDIR) - cmd.Args = append(cmd.Args, "-C") - cmd.Args = append(cmd.Args, localpkgconf) - cmd.Args = append(cmd.Args, "install") - cmd.Args = append(cmd.Args, "-U") - cmd.Args = append(cmd.Args, "-I") - cmd.Args = append(cmd.Args, "-y") - cmd.Args = append(cmd.Args, "-g") - cmd.Args = append(cmd.Args, "*") - - logtofile("Starting appliance upgrade with: " + strings.Join(cmd.Args, " ")) - stdout, err := cmd.StdoutPipe() - if err != nil { - destroymddev() - logtofile("Failed starting pkg install stdout!") - sendfatalmsg("Failed starting pkg install stdout!") - } - if err := cmd.Start(); err != nil { - destroymddev() - logtofile("Failed starting pkg install!") - sendfatalmsg("Failed starting pkg install!") - } - buff := bufio.NewScanner(stdout) - - // Iterate over buff and append content to the slice - var allText []string - for buff.Scan() { - line := buff.Text() - sendinfomsg(line) - logtofile("pkg: " + line) - allText = append(allText, line+"\n") - } - // Pkg returns 0 on sucess - if err := cmd.Wait(); err != nil { - destroymddev() - logtofile("Failed pkg install!") - sendfatalmsg("Failed pkg install!") - } - sendinfomsg("Finished stage appliance install") - logtofile("FinishedApplianceUpdate\n-----------------------") -} - func startupgrade() { cleanupbe() @@ -596,11 +555,7 @@ func startupgrade() { // If we are using standalone update need to nullfs mount the pkgs doupdatefilemnt() - if ( appliancemode ) { - updatefresh() - } else { - updateincremental(fullupdateflag) - } + updateincremental(fullupdateflag) // Check if we need to do any ZFS automagic sanitize_zfs()