Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Finish the legacy base pkg migration to ports base migration.
Browse files Browse the repository at this point in the history
Remove the Appliance mode options, we're not going to need it
after all.
  • Loading branch information
kmoore134 committed Feb 11, 2019
1 parent 143c901 commit c6464e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 68 deletions.
2 changes: 0 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand All @@ -31,7 +30,6 @@ func loadconfig() bool {
}

// Set our gloabls now
appliancemode = s.Appliance
bootstrap = s.Bootstrap
bootstrapfatal = s.BootstrapFatal
trainsurl = s.TrainsURL
Expand Down
4 changes: 0 additions & 4 deletions defines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
Expand Down
79 changes: 17 additions & 62 deletions doupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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))
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit c6464e9

Please sign in to comment.