def install_disc_post(mia, operid, dev, fstype, bootiso_relpath, reldir): global dev_hd # the harddisk device where save packages. global dev_iso # the iso where save pkgs. dolog('instpkg_disc_post(%s, %s, %s, %s)\n' % \ (dev, fstype, reldir, bootiso_relpath)) ################################ Umount Start ##################################### if dev != dev_hd.get_dev(): msg = 'Error: previous use device %s, this time umount device %s, both should be equal, the install operate can not continue!!!' % (dev_hd.get_dev(), dev) logger.e(msg) return msg if dev_iso: if not dev_iso.do_umount(): msg = 'Umount previous iso %s Failed, install operate can not continue!!!' % dev_iso.get_dev() logger.e(msg) return msg dev_iso = None if dev_hd: if not dev_hd.do_umount(): msg = 'Umount previous iso %s Failed, install operate can not continue!!!' % dev_hd.get_dev() logger.e(msg) return msg if dev_hd.get_fstype() == 'iso9660': # Eject the cdrom after used. try: cdfd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK) isys.ejectcdrom(cdfd) # TODO: ejectcdrom use other method os.close(cdfd) except Exception, errmsg: logger.e('Eject(%s) failed: %s' % \ (dev, str(errmsg))) return str(errmsg) dev_hd = None
def instpkg_disc_post(mia, operid, dev, fstype, reldir, bootiso_relpath, first_pkg): global dev_hd # the harddisk device where save packages. global dev_iso # the iso where save pkgs. if installmode == 'copyinstallmode': # determine the rpmdb.tar.bz2 and etc.tar.bz2. If exist copy it to tmp_config_dir in target system. rpmpkgdir = os.path.dirname(first_pkg) rpmdb_abs = os.path.join(rpmpkgdir, rpmdb) etctar_abs = os.path.join(rpmpkgdir, etctar) tgt_tmp_config_dir = os.path.join(CONF_TGTSYS_ROOT, tmp_config_dir) if not os.path.exists(tgt_tmp_config_dir): os.makedirs(tgt_tmp_config_dir) if os.path.exists(rpmdb_abs): ret = os.system('cp %s %s' % (rpmdb_abs, os.path.join(tgt_tmp_config_dir, rpmdb))) if ret != 0: dolog('copy %s to target system failed.\n' % rpmdb) else: dolog('copy %s to target system successfully.\n' % rpmdb) if os.path.exists(etctar_abs): ret = os.system('cp %s %s' % (etctar_abs, os.path.join(tgt_tmp_config_dir, etctar))) if ret != 0: dolog('copy %s to target system failed.\n' % rpmdb) else: dolog('copy %s to target system successfully.\n' % rpmdb) dolog('instpkg_disc_post(%s, %s, %s, %s, %s)\n' % \ (dev, fstype, reldir, bootiso_relpath, first_pkg)) # We don't know which package start the minilogd but it # will lock the disk, so it must be killed. if os.system('/usr/bin/killall minilogd') == 0: time.sleep(2) ################################ Umount Start ##################################### if dev != dev_hd.get_dev(): msg = 'Error: previous use device %s, this time umount device %s, both should be equal, the install operate can not continue!!!' % (dev_hd.get_dev(), dev) Log.e(msg) return msg if dev_iso: if not dev_iso.do_umount(): msg = 'Umount previous iso %s Failed, install operate can not continue!!!' % dev_iso.get_dev() Log.e(msg) return msg dev_iso = None if dev_hd: if not dev_hd.do_umount(): msg = 'Umount previous iso %s Failed, install operate can not continue!!!' % dev_hd.get_dev() Log.e(msg) return msg if dev_hd.get_fstype() == 'iso9660': # Eject the cdrom after used. try: cdfd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK) isys.ejectcdrom(cdfd) os.close(cdfd) except Exception, errmsg: syslog.syslog(syslog.LOG_ERR, 'Eject(%s) failed: %s' % \ (dev, str(errmsg))) return str(errmsg) dev_hd = None
mntpoint = "/tmpfs/mnt/%s" % key umount_dev(mntpoint) if case == "2": # Test umount iso function. dev_path = "/mnt/sda12/MagicLinux-2.5-1.iso" mntpoint = "/media/loop1" ret, msg = umount_dev(mntpoint) if case == "5": # Test ejectcdrom function. print "eject cdrom" iso_dev = "/dev/loop1" f_cd = os.open(iso_dev, os.O_RDONLY | os.O_NONBLOCK) try: isys.ejectcdrom(f_cd) except SystemError, e: # like (22, 'Invalid argument') # (5, 'Input/output error') # and so on print e if f_cd: os.close(f_cd) if case == "6": isys.sync() if case == "7": my_swap = "/dev/sda7" isys.swapon(my_swap) if case == "8": my_swap = "/dev/sda7"
mntpoint = "/tmpfs/mnt/%s" % key umount_dev(mntpoint) if case == '2': # Test umount iso function. dev_path = "/mnt/sda12/MagicLinux-2.5-1.iso" mntpoint = "/media/loop1" ret, msg = umount_dev(mntpoint) if case == '5': # Test ejectcdrom function. print "eject cdrom" iso_dev = "/dev/loop1" f_cd = os.open(iso_dev, os.O_RDONLY | os.O_NONBLOCK) try: isys.ejectcdrom(f_cd) except SystemError, e: # like (22, 'Invalid argument') # (5, 'Input/output error') # and so on print e if f_cd: os.close(f_cd) if case == '6': isys.sync() if case == '7': my_swap = "/dev/sda7" isys.swapon(my_swap) if case == '8': my_swap = "/dev/sda7"