From 1d7b500a94d6ead34853b2da7132a688c1c67036 Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Mon, 10 Jun 2019 16:25:48 -0400 Subject: [PATCH] Handle incoming changes to rename "zol" OS flavor to "nozfs" and the change from sysutils/zol -> sysutils/openzfs --- go.mod | 2 +- go.sum | 2 + update/update.go | 100 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 85 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 6880f98..ed6852d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/client9/misspell v0.3.4 // indirect github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835 // indirect - github.com/gordonklaus/ineffassign v0.0.0-20190531140324-8863c8f9d746 // indirect + github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 // indirect github.com/gorilla/websocket v1.4.0 github.com/magefile/mage v1.8.0 golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284 // indirect diff --git a/go.sum b/go.sum index 4757cc7..18ca14f 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc h1:cJlkeAx github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gordonklaus/ineffassign v0.0.0-20190531140324-8863c8f9d746 h1:RlrReUDDybSbREJYQEFtzr/0vkgKTL3Y2LVUmVsYGHE= github.com/gordonklaus/ineffassign v0.0.0-20190531140324-8863c8f9d746/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 h1:ehVe1P3MbhHjeN/Rn66N2fGLrP85XXO1uxpLhv0jtX8= +github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/magefile/mage v1.8.0 h1:mzL+xIopvPURVBwHG9A50JcjBO+xV3b5iZ7khFRI+5E= diff --git a/update/update.go b/update/update.go index 15a2129..a57c2ab 100644 --- a/update/update.go +++ b/update/update.go @@ -80,6 +80,9 @@ func DoUpdate(message []byte) { // Check if we are moving from pre-flavor pkg base to flavors checkFlavorSwitch() + // Check if moving from zol -> nozfs flavor + checkZoLSwitch() + // Start downloading our files if we aren't doing stand-alone upgrade if defines.UpdateFileFlag == "" { logger.LogToFile("Fetching file updates") @@ -404,19 +407,19 @@ func sanitize_zfs() { // removing _, err := os.Stat(defines.STAGEDIR + "/boot/modules/zfs.ko") if err != nil { - cleanup_zol_port() + cleanup_openzfs_port() } } -func cleanup_zol_port() { +func cleanup_openzfs_port() { ws.SendMsg("Cleaning ZFS Port") logger.LogToFile("ZFS Port cleanup stage 1\n-----------------------") - // Update the sysutils/zol port + // Update the sysutils/openzfs port cmd := exec.Command( defines.PKGBIN, "-c", defines.STAGEDIR, "-C", defines.PkgConf, - "delete", "-U", "-y", "sysutils/zol-kmod", + "delete", "-U", "-y", "sysutils/openzfs-kmod", ) logger.LogToFile( "Cleaning up ZFS port with: " + strings.Join(cmd.Args, " "), @@ -456,6 +459,67 @@ func cleanup_zol_port() { ) } +func checkZoLSwitch() { + // Does the new pkg repo have os-nozfs-userland flavorized package + cmd := exec.Command( + defines.PKGBIN, "-C", defines.PkgConf, + "rquery", "-U", "%v", "os-nozfs-userland", + ) + if err := cmd.Run(); err != nil { + return + } + + // We have flavorized package, lets see if we are still using the + // old non-flavor version still + cmd = exec.Command(defines.PKGBIN, "query", "%v", "os-zol-userland") + if err := cmd.Run(); err != nil { + // We are not using the old, we can safely return now + return + } + + var pkgSlice []string + pkgArgs := []string{ + defines.PKGBIN, "-C", defines.PkgConf, "set", "--change-name", + } + + // Update the old style base packages to their flavor versions + if _, err := os.Stat( + "/boot/kernel/zfs.ko", + ); os.IsNotExist(err) { + // Switch to a nozfs base flavor + ws.SendMsg("Switching to nozfs base flavor") + pkgSlice = append( + pkgSlice, + "os-zol-userland:os-nozfs-userland", + "os-zol-userland-base:os-nozfs-userland-base", + "os-zol-userland-debug:os-nozfs-userland-debug", + "os-zol-userland-docs:os-nozfs-userland-docs", + "os-zol-userland-lib32:os-nozfs-userland-lib32", + "os-zol-userland-tests:os-nozfs-userland-tests", + "os-zol-kernel:os-nozfs-kernel", + "os-zol-kernel-debug:os-nozfs-kernel-debug", + "os-zol-kernel-debug-symbols:os-nozfs-kernel-debug-symbols", + "os-zol-kernel-symbols:os-nozfs-kernel-symbols", + "os-zol-buildkernel:os-nozfs-buildkernel", + "os-zol-buildworld:os-nozfs-buildworld", + ) + + } + + for _, pkg := range pkgSlice { + args := append(pkgArgs, pkg, "-y") + + if out, err := exec.Command( + args[0], args[1:]..., + ).CombinedOutput(); err != nil { + ws.SendMsg( + pkg+" failed to install! Error:\n"+string(out), "fatal", + ) + log.Fatal(out) + } + } +} + func checkFlavorSwitch() { // Does the new pkg repo have os-generic-userland flavorized package cmd := exec.Command( @@ -483,22 +547,22 @@ func checkFlavorSwitch() { if _, err := os.Stat( "/boot/kernel/zfs.ko", ); os.IsNotExist(err) { - // Switch to a ZOL base flavor - ws.SendMsg("Switching to ZOL base flavor") + // Switch to a nozfs base flavor + ws.SendMsg("Switching to nozfs base flavor") pkgSlice = append( pkgSlice, - "userland:os-zol-userland", - "userland-base:os-zol-userland-base", - "userland-debug:os-zol-userland-debug", - "userland-docs:os-zol-userland-docs", - "userland-lib32:os-zol-userland-lib32", - "userland-tests:os-zol-userland-tests", - "kernel:os-zol-kernel", - "kernel-debug:os-zol-kernel-debug", - "kernel-debug-symbols:os-zol-kernel-debug-symbols", - "kernel-symbols:os-zol-kernel-symbols", - "buildkernel:os-zol-buildkernel", - "buildworld:os-zol-buildworld", + "userland:os-nozfs-userland", + "userland-base:os-nozfs-userland-base", + "userland-debug:os-nozfs-userland-debug", + "userland-docs:os-nozfs-userland-docs", + "userland-lib32:os-nozfs-userland-lib32", + "userland-tests:os-nozfs-userland-tests", + "kernel:os-nozfs-kernel", + "kernel-debug:os-nozfs-kernel-debug", + "kernel-debug-symbols:os-nozfs-kernel-debug-symbols", + "kernel-symbols:os-nozfs-kernel-symbols", + "buildkernel:os-nozfs-buildkernel", + "buildworld:os-nozfs-buildworld", ) } else {