kadischi/livecd_generator kadischi.py, 1.1.1.1, 1.2 livecd-mkinitrd.sh, 1.1.1.1, 1.2
Darko Ilic (darko)
fedora-extras-commits at redhat.com
Sun Aug 28 10:20:19 UTC 2005
Author: darko
Update of /cvs/devel/kadischi/livecd_generator
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18342/livecd_generator
Modified Files:
kadischi.py livecd-mkinitrd.sh
Log Message:
repository verification, buildstamp manipulation, UI mode selection, minor bugfixes
Index: kadischi.py
===================================================================
RCS file: /cvs/devel/kadischi/livecd_generator/kadischi.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- kadischi.py 21 Aug 2005 17:09:00 -0000 1.1.1.1
+++ kadischi.py 28 Aug 2005 10:20:17 -0000 1.2
@@ -3,6 +3,7 @@
import os
import sys
import optparse
+import shutil
from shvar import shvarFile
from functions import *
@@ -16,6 +17,8 @@
force = False
method = ''
anaconda_args = ''
+buildstamp = ''
+product_path = ''
kernel_version = ''
# OK, we`re starting
@@ -29,27 +32,48 @@
# process command line options
-usage = 'usage: %prog [options] <path-to-the-repository> <destination-iso-image-file>\n\npath-to-the-repository can be a path on the local file system, but can also be a path\nto a http, ftp or some other type of repository. For details, read about installation\nmethods in anaconda documentation.'
+usage = 'usage: %prog [options] <path-to-the-repository> <destination-iso-image-file>\n\npath-to-the-repository can be a path on the local file system (without any prefixes)\nbut can also be a path to a http, ftp or some other type of repository.\nFor details, consult the documentation at http://fedoraproject.org/wiki/KadischiDoc'
version = '%prog ' + version
parser = optparse.OptionParser (usage=usage, version=version)
-parser.add_option ("-f", "--force", dest="force", action="store_true", default=False, help="Overwrite destination iso image file, if such exists.")
+parser.add_option ("-f", "--force", dest="force", action="store_true", default=False, help="overwrite destination iso image file, if such exists.")
-parser.add_option ("", "--kickstart", dest="ksfile", help="Supply anaconda with kickstart file")
+parser.add_option ("-C", "--cmdline", dest="cmdline", action="store_true", default=False, help="run anaconda in command line mode (runs without interface, but requires complete kickstart file)")
-parser.add_option ("-C", "--cmdline", dest="cmdline", action="store_true", default=False, help="Run anaconda in command line mode (runs without interface, but requires complete kickstart file)")
+parser.add_option ("-T", "--text", dest="text", action="store_true", default=False, help="run anaconda in TUI mode")
+
+parser.add_option ("", "--graphical", dest="graphical", action="store_true", default=False, help="run anaconda in GUI mode")
+
+parser.add_option ("", "--kickstart", dest="ksfile", help="supply anaconda with kickstart file")
+
+parser.add_option ("", "--buildstamp", dest="buildstamp", help="buildstamp file (if not set, using the default buildstamp from the config directory)")
flc_log ('Parsing command line arguments')
(options, args) = parser.parse_args ()
force = options.force
-if options.cmdline:
- anaconda_args = anaconda_args + ' -C'
-
if options.ksfile != None:
anaconda_args = anaconda_args + ' --kickstart=' + options.ksfile
+if options.buildstamp != None:
+ buildstamp = options.buildstamp
+else:
+ buildstamp = normalize_path ([confdir, 'buildstamp'])
+
+# set display mode
+
+display_mode = ''
+
+if options.graphical:
+ display_mode = ' --graphical'
+if options.text:
+ display_mode = ' -T'
+if options.cmdline:
+ display_mode = ' -C'
+
+anaconda_args = display_mode + anaconda_args
+
### check if everything looks OK
# checking arguments
@@ -65,11 +89,57 @@
method = args [0]
isoimage = normalize_path ([args [1]])
-# format method string the way anaconda likes it
+# checking UID - must be root
+
+flc_log ('Checking UID')
+
+if os.getuid () != 0:
+ flc_log ('You have to be root to run this application. Please restart with root permissions.\n')
+ sys.exit (1)
+
+# check if we can open buildstamp file
+
+if not os.access(buildstamp, os.R_OK):
+ flc_log ('Can`t open buildstamp file %s. ' % buildstamp)
+ sys.exit (1)
+
+# loading productPath from buildstamp
+
+flc_log ('Using buildstamp file %s. ' % buildstamp)
+
+f = open(buildstamp, "r")
+lines = f.readlines()
+if len(lines) >= 4:
+ product_path = lines[3][:-1]
+ flc_log ('Product path set to %s. ' % product_path)
+else:
+ flc_log ('Product path can`t be found in buildstamp file %s (Product path should be on the 4th line of the file)' % buildstamp)
+ sys.exit (1)
+
+# validating the repository
+
+flc_log ('Now we are going to try to validate your repository (for now, only http, ftp and local repositories can be checked)')
+
+valid = True
if method.find (':') == -1:
- method = 'nfs:/' + normalize_path ([method])
+ method = normalize_path ([method])
+ valid = path_exists (method) and path_exists (method + '/' + product_path) and path_exists (method + '/' + product_path + '/' + 'base') and path_exists (method + '/' + product_path + '/' + 'RPMS')
+elif method.find ('http') == 0 or method.find ('ftp') == 0:
+ method = method.rstrip('/')
+ valid = url_exists (method) and url_exists (method + '/' + product_path) and url_exists (method + '/' + product_path + '/' + 'base') and url_exists (method + '/' + product_path + '/' + 'RPMS')
+
+if valid:
+ flc_log ('Repository seems to be OK.')
+else:
+ flc_log ('Repository validation failed. Aborting execution.')
+ sys.exit (1)
+
+# format method string the way anaconda likes it
+if method.find (':') == -1:
+ method = 'nfs:/' + method
+
# checking if everything is OK with destination (iso image) file
if os.path.isfile (isoimage):
@@ -82,14 +152,6 @@
elif not os.path.isdir (os.path.dirname (isoimage)):
os.makedirs (os.path.dirname (isoimage))
-# checking UID - must be root
-
-flc_log ('Checking UID')
-
-if os.getuid () != 0:
- flc_log ('You have to be root to run this application. Please restart with root permissions.\n')
- sys.exit (1)
-
# check for installed rpms
flc_log ('Checking required packages')
@@ -129,6 +191,7 @@
sys.exit(1)
# prepare dirs
+
buildsubdir = 'livecd-build_no' + buildnum
builddir = normalize_path ([builddir, buildsubdir])
@@ -140,6 +203,20 @@
# we shouldn`t create csysdir because mkzftree wants to create it by it self
# os.makedirs (csysdir)
+# Moving the buildstamp file to /tmp/product/.buildstamp so anaconda can find it
+
+if not os.path.exists ('/tmp/product'):
+ os.makedirs ('/tmp/product')
+elif not os.path.isdir ('/tmp/product'):
+ flc_log ('Path /tmp/product is not a directory, temporarly moving to %s' % normalize_path([builddir, 'product']))
+ shutil.move ('/tmp/product', normalize_path([builddir, 'product']))
+ os.makedirs ('/tmp/product')
+elif os.path.exists ('/tmp/product/.buildstamp'):
+ flc_log ('Path /tmp/product/.buildstamp already exists, temporarly moving to %s' % normalize_path([builddir, '.buildstamp']))
+ shutil.move ('/tmp/product/.buildstamp', normalize_path([builddir, '.buildstamp']))
+
+shutil.copy2 (buildstamp, '/tmp/product/.buildstamp')
+
# run anaconda
flc_log ('\n *** running anaconda *** \n')
@@ -208,17 +285,11 @@
run ("%s %s %s" % (normalize_path([bindir, 'create-iso.sh']), csysdir, isoimage), builddir)
-# delete csysdir
-
-flc_log ('removing compressed tree')
-
-clean_directory (csysdir)
-
# delete builddir
flc_log ('removing builddir')
-clean_directory (builddir)
+cleanup (builddir)
flc_log ('Finished.')
sys.exit (0)
\ No newline at end of file
Index: livecd-mkinitrd.sh
===================================================================
RCS file: /cvs/devel/kadischi/livecd_generator/livecd-mkinitrd.sh,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- livecd-mkinitrd.sh 21 Aug 2005 17:09:00 -0000 1.1.1.1
+++ livecd-mkinitrd.sh 28 Aug 2005 10:20:17 -0000 1.2
@@ -54,8 +54,8 @@
mkdir -p $dir
fi
- if [ -x $rootdir/usr/bin/strip ]; then
- $rootdir/usr/bin/strip -g $verbose $src -o $dest
+ if [ -x /usr/bin/strip ]; then
+ /usr/bin/strip -g $verbose $src -o $dest
else
[ -n "$verbose" ] && echo "$src -> $dest"
cp -a $src $dest
More information about the fedora-extras-commits
mailing list