reguire gnupg1 on f>=31; sense the system to use gpg1 when installed
[bootmanager.git] / source / steps / InstallBootstrapFS.py
index 7449b2c..bea2afd 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
 #
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
@@ -85,15 +85,12 @@ def Run(vars, upgrade, log):
         log.write("Upgrade mode init : Scanning for devices\n")
         systeminfo.get_block_devices_dict(vars, log)
         utils.sysexec_noerr("vgscan --mknodes", log)
+        utils.sysexec_noerr("vgchange -ay", log)
 
     # debugging info - show in either mode
-    log.write("In InstallBootstrapFS : DEVICES status BEG\n")
-    utils.sysexec_noerr("vgdisplay", log)
-    utils.sysexec_noerr("pvdisplay", log)
-    for name, path in PARTITIONS.items():
-        log.write("PARTITIONS[{}]={}\n".format(name,path))
-        utils.sysexec_noerr("ls -l {}".format(path), log)
-    log.write("In InstallBootstrapFS : DEVICES status END\n")
+    utils.display_disks_status(PARTITIONS, "In InstallBootstrapFS", log)
+
+    utils.breakpoint("we need to make /dev/mapper/* appear")
 
     log.write("turning on swap space\n")
     utils.sysexec("swapon {}".format(PARTITIONS["swap"]), log)
@@ -114,11 +111,11 @@ def Run(vars, upgrade, log):
         utils.sysexec("mount -t {} {} {}/vservers"\
                       .format(fstype, PARTITIONS["vservers"], SYSIMG_PATH), log)
 
-        if vars['virt']=='lxc':
+        #if vars['virt']=='lxc':
             # NOTE: btrfs quota is supported from version: >= btrfs-progs-0.20 (f18+)
             #       older versions will not recongize the 'quota' command.
-            log.write("Enabling btrfs quota on {}/vservers\n".format(SYSIMG_PATH))
-            utils.sysexec_noerr("btrfs quota enable {}/vservers".format(SYSIMG_PATH))
+            #log.write("Enabling btrfs quota on {}/vservers\n".format(SYSIMG_PATH))
+            #utils.sysexec_noerr("btrfs quota enable {}/vservers".format(SYSIMG_PATH))
 
     vars['ROOT_MOUNTED'] = 1
 
@@ -235,9 +232,13 @@ def Run(vars, upgrade, log):
     if (vars['ONE_PARTITION'] != '1'):
         # Import the GPG key into the RPM database so that RPMS can be verified
         utils.makedirs(SYSIMG_PATH + "/etc/pki/rpm-gpg")
-        utils.sysexec("gpg --homedir=/root --export --armor"
-                      " --no-default-keyring --keyring {}/usr/boot/pubring.gpg"
-                      " > {}/etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab".format(SYSIMG_PATH, SYSIMG_PATH), log)
+        # see also myplc/plc.d/gpg
+        utils.sysexec(
+            "type -p gpg1 >& /dev/null && GPG=gpg1 || GPG=gpg; "
+            "$GPG --homedir=/root --export --armor"
+            " --no-default-keyring --keyring {}/usr/boot/pubring.gpg"
+            " > {}/etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab"
+            .format(SYSIMG_PATH, SYSIMG_PATH), log, shell=True)
         utils.sysexec_chroot(SYSIMG_PATH, "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab", log)
 
     # keep a log on the installed hdd
@@ -280,13 +281,17 @@ def CleanupSysimgBeforeUpgrade(sysimg, target_nodefamily, log):
         with open("{}/etc/planetlab/virt".format(sysimg)) as infile:
             installed_virt = infile.read().strip()
     except Exception as e:
-        print_exc()
+        traceback.print_exc()
         raise BootManagerException("Could not retrieve data about previous installation - cannot upgrade")
 
     # moving from vservers to lxc also means another filesystem
     # so plain reinstall is the only option
     if installed_virt != 'lxc':
-        raise BootManagerException("Can only upgrade nodes running lxc containers (vservers not supported)")
+        message = """Can only upgrade nodes already running lxc containers
+a node running vservers has its /vservers/ partition formatted as ext3 
+and we need btrfs to move to containers
+your only option here is reinstall"""
+        raise BootManagerException(message)
 
     # changing arch is not reasonable either
     if target_arch != installed_arch: