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

Commit

Permalink
Prelim support for migrating from legacy base packages to newer
Browse files Browse the repository at this point in the history
ports base
  • Loading branch information
kmoore134 committed Feb 10, 2019
1 parent 96cd670 commit 42d36f5
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions doupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,61 @@ func cleanup_zol_port() {
logtofile("Finished ZFS port cleanup stage 1\n-----------------------")
}

func checkbaseswitch() {

// Does the new pkg repo have os/userland port origin
cmd := exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "rquery", "-U", "%v", "os/userland")
err := cmd.Run()
if ( err != nil ) {
return
}

// We have os/userland remote, lets see if we are using it already locally
cmd = exec.Command(PKGBIN, "query", "-U", "%v", "os/userland")
err = cmd.Run()
if ( err == nil ) {
return
}

// 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()
if ( cmderr != nil ) {
log.Fatal("Failed getting base package list")
}

barr := strings.Split(string(output), "\n")
for i, _ := range barr {
// Unset vital flag
sendinfomsg("Removing: " + barr[i])
logtofile("Removing: " + barr[i])
cmd := exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "set", "-v", "0", barr[i])
err := cmd.Run()
if ( err != nil ) {
log.Fatal("Failed unsetting vital")
}
// Remove the package now
cmd = exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "delete", "-y", barr[i])
err = cmd.Run()
if ( err != nil ) {
log.Fatal("Failed removing")
}
}

// Load new userland / kernel and friends
pkgcmd := exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "install", "-U", "-y", "os/userland", "os/kernel", "os/docs", "os/userland-lib32")
fullout, err := pkgcmd.CombinedOutput()
sendinfomsg(string(fullout))
logtofile(string(fullout))
}

func updateincremental(force bool) {
sendinfomsg("Starting package update")
logtofile("PackageUpdate\n-----------------------")

// Check if we are moving from legacy pkg base to ports-base
checkbaseswitch()

pkgcmd := exec.Command(PKGBIN, "-c", STAGEDIR, "-C", localpkgconf, "upgrade", "-U", "-y", "-f", "ports-mgmt/pkg")
fullout, err := pkgcmd.CombinedOutput()
sendinfomsg(string(fullout))
Expand Down

0 comments on commit 42d36f5

Please sign in to comment.