kadischi/livecd_generator kadischi.py,1.41,1.42

Jasper O'neal Hartline (autopsy) fedora-extras-commits at redhat.com
Fri Sep 1 18:46:40 UTC 2006


Author: autopsy

Update of /cvs/devel/kadischi/livecd_generator
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26909/kadischi/livecd_generator

Modified Files:
	kadischi.py 
Log Message:
Start prototype for LiveCD-to-system installer using Anaconda


Index: kadischi.py
===================================================================
RCS file: /cvs/devel/kadischi/livecd_generator/kadischi.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- kadischi.py	19 Aug 2006 16:52:33 -0000	1.41
+++ kadischi.py	1 Sep 2006 18:46:38 -0000	1.42
@@ -46,10 +46,16 @@
     print "[kadischi]: Starting kadischi with root access..."
 
     # Parsing command line arguments
+    # Make case for running from LiveCD
     (options, args) = parse_args ()
-    if len(args) != 2:
-        print >> sys.stderr, "[kadischi]: Invalid arguments!"
-        return 1
+    if os.access("/.livecd", os.R_OK):
+        if len(args) != 1:
+            print >> sys.stderr, "[kadischi]: Invalid arguments!"
+            return 1
+    else:
+        if len(args) != 2:
+            print >> sys.stderr, "[kadischi]: Invalid arguments!"
+            return 1
 
     force = options.force
     anaconda_args = ["/usr/sbin/anaconda"]
@@ -95,153 +101,174 @@
     # validating the repository
     print "[kadischi]: Trying to validate your repository"
     method = args [0]
-    isoimage = os.path.normpath (args [1])
+    if os.access("/.livecd", os.R_OK):
+        pass
+    else:
+        isoimage = os.path.normpath (args [1])
+
     method = method_check(method)
     if method is None:
         return 2
 
     # checking if everything is OK with destination (iso image) file
-    if os.path.isfile(isoimage) and not options.force:
-        print >> sys.stderr, "[kadischi]: Trying to overwrite existing image %s without --force.  Exiting" % (isoimage,)
-        return 3
+    if os.access("/.livecd", os.R_OK):
+        pass
+    else:
+        if os.path.isfile(isoimage) and not options.force:
+            print >> sys.stderr, "[kadischi]: Trying to overwrite existing image %s without --force.  Exiting" % (isoimage,)
+            return 3
 
     # prepare dirs
-    sysdir = normalize_path([builddir, 'system'])
-    csysdir = normalize_path([builddir, 'compressed'])
-    os.makedirs (sysdir)
+    if os.access("/.livecd", os.R_OK):
+        pass
+    else:
+        sysdir = normalize_path([builddir, 'system'])
+        csysdir = normalize_path([builddir, 'compressed'])
+        os.makedirs (sysdir)
 
     # loading productPath from buildstamp for anaconda
     print "[kadischi]: Using buildstamp file %s. " % buildstamp
     buildstamping(builddir)
 
     # run anaconda
-    print "\n[kadischi] : running anaconda    \n"
-    anaconda_args.append("--rootpath=%s" % sysdir)
-    anaconda_args.append("--method=%s" % method)
-    execute(anaconda_args)
-    print "\n[kadischi] :  anaconda has finished its job \n"
+    # Make case for running from LiveCD
+    if os.access("/.livecd", os.R_OK):
+        print "\n[kadischi] : running anaconda    \n"
+        anaconda_args.append("--method=%s" % method)
+        execute(anaconda_args)
+        print "\n[kadischi] :  anaconda has finished its job \n"
+    else:
+        print "\n[kadischi] : running anaconda    \n"
+        anaconda_args.append("--rootpath=%s" % sysdir)
+        anaconda_args.append("--method=%s" % method)
+        execute(anaconda_args)
+        print "\n[kadischi] :  anaconda has finished its job \n"
 
     # run post_install_scripts
-    print "[kadischi]: running post installation scripts"
-    run_scripts(sysdir, bindir, anaconda_args)
+    if os.access("/.livecd", os.R_OK):
+        print "\n[kadischi] :  Please reboot your system to start Fedora Core\n"
+        sys.exit(0)
+    else:
+        print "[kadischi]: running post installation scripts"
+        run_scripts(sysdir, bindir, anaconda_args)
 
-    ### Calculate size of result ISO image by known ratios for SquashFS
-    size = 0
-    stepsize = 0
+        ### Calculate size of result ISO image by known ratios for SquashFS
+        size = 0
+        stepsize = 0
+
+        ts = rpm.TransactionSet(sysdir)
+        mi = ts.dbMatch()
+        for hdr in mi:
+            size = (hdr['size'])
+            stepsize = (size + stepsize)
+
+        totalsize = stepsize
+        if (totalsize > 1600000000):
+            estimate0 = (totalsize / 2.3) ## Observed ratio for SquashFS
+            estimate1 = (totalsize / 2.5) ## Observed ratio for SquashFS
+        else:
+            estimate0 = (totalsize / 2.4) ## Observed ratio for SquashFS
+            estimate1 = (totalsize / 2.6) ## Observed ratio for SquashFS
 
-    ts = rpm.TransactionSet(sysdir)
-    mi = ts.dbMatch()
-    for hdr in mi:
-        size = (hdr['size'])
-        stepsize = (size + stepsize)
-
-    totalsize = stepsize
-    if (totalsize > 1600000000):
-        estimate0 = (totalsize / 2.3) ## Observed ratio for SquashFS
-        estimate1 = (totalsize / 2.5) ## Observed ratio for SquashFS
-    else:
-        estimate0 = (totalsize / 2.4) ## Observed ratio for SquashFS
-        estimate1 = (totalsize / 2.6) ## Observed ratio for SquashFS
-
-    print ("[kadischi]: estimated %s size is between %s and %s bytes" % (isoimage, estimate1, estimate0))
-
-    # make initrd image and pickup kernel version cause when we move files arround, it will be late
-    print ("[kadischi]: making initrd image")
-    make_initrds(sysdir, bindir)
-
-    # move files
-    print "[kadischi]: moving files that should be on tmpfs"
-    move = normalize_path([bindir, 'movefiles.py'])
-    args = [move, sysdir]
-    execute (args)
-
-    # compress the tree
-    print "[kadischi]: compressing the tree (order a pizza 'cause this will take a while)"
-    # kadischi.sqsh is a file that we mount loopback. So we need to create supporting
-    # files and directories outside of the compressed tree.
-    os.makedirs (os.path.join(csysdir, 'boot/isolinux'))
-    touch = file(normalize_path([csysdir, '.livecd']), 'w')
-    touch.close()
-
-    # Make the SquashFS image
-    ctree = normalize_path([csysdir, 'kadischi.sqsh'])
-    args = ["/sbin/mksquashfs", sysdir, ctree, "-no-fragments"]
-    execute (args)
-
-    # install boot
-    print "[kadischi]: installing boot & config files in compressed tree"
-    boot = normalize_path([bindir, 'install-boot.sh'])
-    args = [boot, sysdir, csysdir, kernel]
-    if kernel != None and kernel_smp == None:
-        args = [boot, sysdir, csysdir, kernel]
-    elif kernel != None and kernel_smp != None:
+        print ("[kadischi]: estimated %s size is between %s and %s bytes" % (isoimage, estimate1, estimate0))
+
+        # make initrd image and pickup kernel version cause when we move files arround, it will be late
+        print ("[kadischi]: making initrd image")
+        make_initrds(sysdir, bindir)
+
+        # move files
+        print "[kadischi]: moving files that should be on tmpfs"
+        move = normalize_path([bindir, 'movefiles.py'])
+        args = [move, sysdir]
+        execute (args)
+
+        # compress the tree
+        print "[kadischi]: compressing the tree (order a pizza 'cause this will take a while)"
+        # kadischi.sqsh is a file that we mount loopback. So we need to create supporting
+        # files and directories outside of the compressed tree.
+        os.makedirs (os.path.join(csysdir, 'boot/isolinux'))
+        touch = file(normalize_path([csysdir, '.livecd']), 'w')
+        touch.close()
+
+        # Make the SquashFS image
+        ctree = normalize_path([csysdir, 'kadischi.sqsh'])
+        args = ["/sbin/mksquashfs", sysdir, ctree, "-no-fragments"]
+        execute (args)
+
+        # install boot
+        print "[kadischi]: installing boot & config files in compressed tree"
+        boot = normalize_path([bindir, 'install-boot.sh'])
         args = [boot, sysdir, csysdir, kernel]
-    else:
-        args = [boot, sysdir, csysdir, kernel_smp]
-    execute(args)
+        if kernel != None and kernel_smp == None:
+            args = [boot, sysdir, csysdir, kernel]
+        elif kernel != None and kernel_smp != None:
+            args = [boot, sysdir, csysdir, kernel]
+        else:
+            args = [boot, sysdir, csysdir, kernel_smp]
+        execute(args)
 
-    # delete sysdir - we don`t need it anymore
-    print "[kadischi]: removing uncompressed tree"
-    cleanup(sysdir)
-
-    # create iso image
-    print "[kadischi]: creating iso image %s" % isoimage
-    args = ["/usr/bin/mkisofs", "-quiet", "-R",
-        "-V", dist,
-        "-b", "boot/isolinux/isolinux.bin",
-        "-c", "boot/isolinux/boot.cat",
-        "-p", myname,
-        "-x", "lost+found",
-        "-no-emul-boot", "-boot-load-size", "4", "-boot-info-table",
-        "-o", isoimage,
-        csysdir]
-    execute (args)
-
-    # delete builddir
-    print "[kadischi]: removing builddir."
-    cleanup (builddir)
-
-    # Done!
-    # print "[kadischi]: Finished successfully."
-    # return 0
-
-    ### Burn the CD
-    using_kickstart = False
-    using_cmdline = False
-    for args in anaconda_args:
-        if re.search("--kickstart=", args) != None:
-            using_kickstart = True
-        if re.search("--cmdline", args) != None:
-            using_cmdline = True
-	if using_kickstart == True or using_cmdline == True:
-            print "[kadischi]: Finished successfully"
-            return 0
+        # delete sysdir - we don`t need it anymore
+        print "[kadischi]: removing uncompressed tree"
+        cleanup(sysdir)
+
+        # create iso image
+        print "[kadischi]: creating iso image %s" % isoimage
+        args = ["/usr/bin/mkisofs", "-quiet", "-R",
+            "-V", dist,
+            "-b", "boot/isolinux/isolinux.bin",
+            "-c", "boot/isolinux/boot.cat",
+            "-p", myname,
+            "-x", "lost+found",
+            "-no-emul-boot", "-boot-load-size", "4", "-boot-info-table",
+            "-o", isoimage,
+            csysdir]
+        execute (args)
+
+        # delete builddir
+        print "[kadischi]: removing builddir."
+        cleanup (builddir)
+
+        # Done!
+        # print "[kadischi]: Finished successfully."
+        # return 0
+
+        ### Burn the CD
+        using_kickstart = False
+        using_cmdline = False
+        for args in anaconda_args:
+            if re.search("--kickstart=", args) != None:
+                using_kickstart = True
+            if re.search("--cmdline", args) != None:
+                using_cmdline = True
+	    if using_kickstart == True or using_cmdline == True:
+                print "[kadischi]: Finished successfully"
+                return 0
  
-    choice = ""
-    device = ""
-    print "[kadischi]: Kadischi is finished building the Live ISO image.."
-    choice = raw_input("[kadischi]: Would you like to burn the CD image now? [yes/no]: ")
-    if choice == "yes":
-        device = raw_input("[kadischi]: What device is your CDROM or DVDROM? [/dev/cdrom]: ")
-        if device == None:
-            device = "dev=/dev/cdrom"
+        choice = ""
+        device = ""
+        print "[kadischi]: Kadischi is finished building the Live ISO image.."
+        choice = raw_input("[kadischi]: Would you like to burn the CD image now? [yes/no]: ")
+        if choice == "yes":
+            device = raw_input("[kadischi]: What device is your CDROM or DVDROM? [/dev/cdrom]: ")
+            if device == None:
+                device = "dev=/dev/cdrom"
+            else:
+                device = string.join(["dev=", device], "")
+            burn_cd(device)
+            burned = True
         else:
-            device = string.join(["dev=", device], "")
-        burn_cd(device)
-        burned = True
-    else:
-        print "[kadischi]: Finished successfully."
-        return 0
+            print "[kadischi]: Finished successfully."
+            return 0
 
-    ### Verify the CD
-    choice = raw_input("[kadischi]: Would you like to verify the CD or DVD burned? [yes/no]: ")
-    if choice == "yes":
-        dev = device[4:]
-        device = string.join(["if=", dev], "")
-        verify_cd(device)
-    else:
-        print "[kadischi]: Finished successfully."
-        return 0
+        ### Verify the CD
+        choice = raw_input("[kadischi]: Would you like to verify the CD or DVD burned? [yes/no]: ")
+        if choice == "yes":
+            dev = device[4:]
+            device = string.join(["if=", dev], "")
+            verify_cd(device)
+        else:
+            print "[kadischi]: Finished successfully."
+            return 0
 
 def requirements():
     """ Searches which Requires has not yet installed """




More information about the scm-commits mailing list