diff options
Diffstat (limited to 'abs/core/LinHES-config/mv_install.py')
-rwxr-xr-x | abs/core/LinHES-config/mv_install.py | 222 |
1 files changed, 197 insertions, 25 deletions
diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py index 2e60ab7..c7a002d3 100755 --- a/abs/core/LinHES-config/mv_install.py +++ b/abs/core/LinHES-config/mv_install.py @@ -129,7 +129,7 @@ def mdadm_assemble_all(): def copy_updates(): try: - MVROOT = os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"].strip() except: logging.debug("MVROOT was not defined, using the default value") MVROOT = "/usr/MythVantage" @@ -475,20 +475,118 @@ def create_squashlist(): logging.debug(i) f.close() +def mount_for_copy_it(): + + image_mount='/image_mount/root' + try: + os.makedirs(image_mount) + except: + pass + image_mount='/image_mount/root' + + image_mount='/image_mount/usr/share' + try: + os.makedirs(image_mount) + except: + pass + + image_mount='/image_mount/lib/modules' + try: + os.makedirs(image_mount) + except: + pass + + image_mount='/image_mount/var/cache/pacman' + try: + os.makedirs(image_mount) + except: + pass + + image_mount='/image_mount/var/lib/pacman' + try: + os.makedirs(image_mount) + except: + pass + + fsimage='root-image' + cmd = 'mount /run/archiso/sfs/%s/%s.fs /image_mount/root' %(fsimage,fsimage) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Mount image root") + + fsimage='lib-modules' + cmd = 'mount /run/archiso/sfs/%s/%s.fs /image_mount/lib/modules' %(fsimage,fsimage) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Mount image lib-modules") + + fsimage='usr-share' + cmd = 'mount /run/archiso/sfs/%s/%s.fs /image_mount/usr/share' %(fsimage,fsimage) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Mount image usr share") + + fsimage='var-lib-pacman' + cmd = 'mount /run/archiso/sfs/%s/%s.fs /image_mount/var/lib/pacman' %(fsimage,fsimage) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Mount image var-lib-pacman") + + fsimage='var-cache-pacman' + cmd = 'mount /run/archiso/sfs/%s/%s.fs /image_mount/var/cache/pacman' %(fsimage,fsimage) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Mount image var-cahce-pacman") + + +def umount_for_copy_it(): + cmd='umount %s' %('/image_mount/lib/modules') + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("unMount image lib_modules") + + cmd='umount %s' %('/image_mount/usr/share') + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("unMount image usr_share") + + cmd='umount %s' %('/image_mount/root') + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("unMount image /") + + cmd='umount %s' %('/image_mount/var/cache/pacman') + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("unMount image var-cache-pacman") + + cmd='umount %s' %('/image_mount/var/lib/pacman') + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("unMount image var-lib-pacman") + + def copy_it(install_type): logging.info("______Transferring to disk______") + mount_for_copy_it() logging.debug( install_type) if ( install_type == "install"): logging.info("Transferring system") - cmd = " unsquashfs -f -d %s /.livesys/medium/larch/system.sqf" %(data_config.MOUNTPOINT) - #runcmd(cmd) - rc = runcmd(cmd)[0] - if rc != 0 : - error_out("Running unsquashfs") + cmdlist = ['rsync -avrp /image_mount/root/* /new_boot', + 'rsync -arvp /image_mount/lib/* /new_boot/lib/', + 'rsync -arvp /image_mount/usr /new_boot', + 'rsync -arvp /image_mount/var /new_boot'] + + #'rsync -arvp /image_mount/lib /new_boot', + + for cmd in cmdlist: + #runcmd(cmd) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Running %s" %cmd) + - #logging.debug(cmd) - #cmdout=commands.getoutput(cmd) if ( install_type == "upgrade"): logging.info("Upgrading system") @@ -533,12 +631,10 @@ def copy_it(install_type): runcmd(cmd) cmd = "chmod +s %s/bin/mount" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd = "rm %s/etc/*.larch*" %(data_config.MOUNTPOINT) - runcmd(cmd) - cmd = "rm %s/etc/mkinitcpio.d/larch*" %(data_config.MOUNTPOINT) - runcmd(cmd) - cmd = "rm %s/etc/rc.d/functions.d/*larch*" %(data_config.MOUNTPOINT) - runcmd(cmd) + apply_pristine() + post_process() + + umount_for_copy_it() logging.debug("__End of copy_it__") def create_fstab(extralines): @@ -636,6 +732,7 @@ def fstab_it(install_type): elif os.path.exists("/tmp/etc/fstab"): logging.debug(" Upgrade and not Knoppmyth, using old fstab") cp_and_log("/tmp/etc/fstab", fstabfile) + # Catch all for creating new fstab if not os.path.exists(data_config.MOUNTPOINT+"/etc"): os.makedirs(data_config.MOUNTPOINT+"/etc") @@ -735,11 +832,31 @@ def fstab_it(install_type): def grub_it(): logging.info("______Start of grub install______") + cmd = "chroot %s grub-install --target=i386-pc --recheck --debug /dev/%s" %(data_config.MOUNTPOINT,hostoptions["rootdisk"]) + logging.info("Running grub-install") + runcmd(cmd) + + cmd = " mkinitcpio -g %s/boot/initramfs-linux.img" %(data_config.MOUNTPOINT) + logging.info("Running mkinitcpio") + runcmd(cmd) + + + cmd="chroot %s grub-mkconfig -o /boot/grub/grub.cfg" %data_config.MOUNTPOINT + runcmd(cmd) + #rootuuid = find_uuid(hostoptions["rootpartition"]) + #cmd = " mkinitcpio -b %s -g %s/boot/kernel26.img" %(data_config.MOUNTPOINT, data_config.MOUNTPOINT) + #cmd = " mkinitcpio -g %s/boot/initramfs-linux.img" %(data_config.MOUNTPOINT) + #logging.info("Running mkinitcpio") + #runcmd(cmd) + +def grub_it1(): + logging.info("______Start of grub install______") cmd = " grub-install --recheck --no-floppy --root-directory=%s \"(hd0)\" " % data_config.MOUNTPOINT logging.info("Running grub-install") runcmd(cmd) rootuuid = find_uuid(hostoptions["rootpartition"]) cmd = " mkinitcpio -b %s -g %s/boot/kernel26.img" %(data_config.MOUNTPOINT, data_config.MOUNTPOINT) + cmd = " mkinitcpio -g %s/boot/initramfs-linux.img" %(data_config.MOUNTPOINT) logging.info("Running mkinitcpio") runcmd(cmd) logging.info("Adding root uuid to grub menu") @@ -755,6 +872,20 @@ def grub_it(): logging.debug(" Found kernel Root grubline:") logging.debug( templine) templine[2] = "root=/dev/disk/by-uuid/%s" %(rootuuid) + templine[1] = "/boot/vmlinuz-linux" + newline = '' + for i in templine: + newline+=i + newline+=" " + newline+="\n" + logging.debug(" New grub menu.lst line:") + logging.debug( newline) + newgrub.append(newline) + elif line.startswith("initrd"): + templine = line.split() + logging.debug(" Found initrd grubline:") + logging.debug( templine) + templine[1] = "/boot/initramfs-linux.img" newline = '' for i in templine: newline+=i @@ -823,7 +954,7 @@ def apply_new_auth(): logging.info("_____Applying Password updates_______") passfile = "/root/myth_user_call.out" try: - MVROOT = os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"].strip() except: logging.debug("MVROOT was not defined, using the default value") MVROOT = "/usr/MythVantage" @@ -1030,10 +1161,48 @@ def restore_default_settings(): copy_updates() fix_permissions() +def apply_pristine(): + logging.info("_____Applying Pristine files_______") + if data_config.NOOPDEBUG == "FALSE": + cmd = "chroot " + data_config.MOUNTPOINT + " " + "tar -xvf /pristine.tar" + else: + cmd = "echo chroot " + data_config.MOUNTPOINT + " " + "tar -xvf /pristine.tar" + try: +# Using os.system because runcmd fails + logging.debug(cmd) + os.system(cmd) + except: + logging.debug("Applying pristine files failed %s", passfile) + logging.debug + + try: + removefile="%s/pristine.tar" %(data_config.MOUNTPOINT) + os.remove(removefile) + except OSError: + logging.debug(" Couldn't remove pristine.tar") + pass + +def post_process(): + logging.info("_____Post processing_______") + if data_config.NOOPDEBUG == "FALSE": + cmd = "chroot " + data_config.MOUNTPOINT + " " + "/root/.post_process/go.sh" + else: + cmd = "echo chroot " + data_config.MOUNTPOINT + " " + "/root/.post_process/go.sh" + try: +# Using os.system because runcmd fails + logging.debug(cmd) + os.system(cmd) + except: + logging.debug("Applying post_process_failed %s", passfile) + logging.debug + + + + def full_install(hostoptions): logging.info("______Start of full install______") try: - MVROOT = os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"].strip() except: logging.debug(" MVROOT was not defined, using the default value") MVROOT = "/usr/MythVantage" @@ -1088,7 +1257,10 @@ def full_install(hostoptions): msg = "Configuring system" update_status(msg) progress(98) + mount_bind_chroot() grub_it() + umount_bind_chroot() + genlocale() special_hardware_check() # Configuring the system @@ -1118,7 +1290,7 @@ def full_install(hostoptions): logging.info("______Installing Database in CHROOT________") mysqldb("stop", '') mount_bind_chroot() - cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) logging.info("Running systemconfig in chroot") #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT) @@ -1135,7 +1307,7 @@ def full_install(hostoptions): else: logging.info("______No database required, continuing configuration________") mount_bind_chroot() - cmd = " chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) # Need to check for to touch /tmp/.dbsysfailed #cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) @@ -1282,7 +1454,7 @@ def upgrade_mount_search(): def upgrade(hostoptions): try: - MVROOT = os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"].strip() except: logging.debug("MVROOT was not defined, using the default value") MVROOT = "/usr/MythVantage" @@ -1385,23 +1557,23 @@ def upgrade(hostoptions): if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ): if clean_upgrade() or not backup_sql_check(): logging.info("Installing new database") - cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) else: logging.info("Restoring database") - cmd = " chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT, hostoptions["backupfile"]) + cmd = "chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT, hostoptions["backupfile"]) runcmd(cmd) if os.path.exists("/tmp/etc/KnoppMyth-version"): - cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) logging.debug("Correcting permissions because of km->linhes upgrade") - cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) + cmd = "chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) runcmd(cmd) - cmd = " chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup") + cmd = "chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup") runcmd(cmd) else: - cmd = " chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) + cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) runcmd(cmd) logging.info("Running systemconfig in chroot 2nd time") |