PERFORCE change 122233 for review
Ivan Voras
ivoras at FreeBSD.org
Sun Jun 24 16:37:51 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122233
Change 122233 by ivoras at ivoras_finstall on 2007/06/24 16:37:17
Silence most of the warnings on the LiveCD
Affected files ...
.. //depot/projects/soc2007/ivoras_finstall/makeimage/makeimage.py#3 edit
Differences ...
==== //depot/projects/soc2007/ivoras_finstall/makeimage/makeimage.py#3 (text+ko) ====
@@ -37,7 +37,7 @@
raise MakeImageException("This utility requires mkisofs(8) (install ports/sysutils/cdrtools)")
def usage():
- print "usage: %s -d WORKDIR [-s SRCDIR] [-k KERNEL]" % sys.argv[0]
+ print "usage: %s -d WORKDIR [-s SRCDIR] [-k KERNEL] [-b] [-c] [-i ISOFILE]" % sys.argv[0]
sys.exit(1)
WORKDIR = None # Working directory. Will create DESTDIR inside it.
@@ -45,9 +45,11 @@
SRCDIR = "/usr/src"
KERNEL = "GENERIC"
DoBuild = False
+DoMakeRoot = True # Create / install livecd tree
LABEL = "FreeBSD7"
+ISO = None
-opts, args = getopt(sys.argv[1:], "d:s:bh")
+opts, args = getopt(sys.argv[1:], "d:s:i:bch")
for o,a in opts:
if o == "-d":
WORKDIR = a
@@ -63,6 +65,10 @@
KERNEL = a
elif o == "-b":
DoBuild = True
+ elif o == "-c":
+ DoMakeRoot = False
+ elif o == "-i":
+ ISO = a
elif o == "-h":
usage()
@@ -74,39 +80,67 @@
os.makedirs(WORKDIR)
DESTDIR = "%s/livecd" % WORKDIR
-if os.path.exists(DESTDIR):
- if not os.path.exists("%s/COPYRIGHT" % DESTDIR):
- print "--> %s doesn't look like a FreeBSD root" % DESTDIR
- resp = raw_input("Delete it anyway? (y/N) ").upper()
- if resp != "Y":
- print "Canceling"
- sys.exit(1)
- else:
- print "Wiping out %s" % DESTDIR
- nukedir(DESTDIR)
+
+if DoMakeRoot:
+ if os.path.exists(DESTDIR):
+ if not os.path.exists("%s/COPYRIGHT" % DESTDIR):
+ print "--> %s doesn't look like a FreeBSD root" % DESTDIR
+ resp = raw_input("Delete it anyway? (y/N) ").upper()
+ if resp != "Y":
+ print "Canceling"
+ sys.exit(1)
+ else:
+ print "Wiping out %s" % DESTDIR
+ nukedir(DESTDIR)
+
+ os.makedirs(DESTDIR)
-os.makedirs(DESTDIR)
+ initutils()
-initutils()
+ printmsg("Using '%s' as source directory" % SRCDIR)
+ printmsg("Using '%s' as working directory (root on '%s')" % (WORKDIR, DESTDIR))
+ printmsg("Using '%s' kernel" % KERNEL)
-printmsg("Using '%s' as source directory" % SRCDIR)
-printmsg("Using '%s' as working directory (root on '%s')" % (WORKDIR, DESTDIR))
-printmsg("Using '%s' kernel" % KERNEL)
-printmsg("Random message to test scrolling")
+ os.chdir(SRCDIR)
+ if DoBuild:
+ execute("make buildworld")
+ execute("make installworld DESTDIR=%s" % DESTDIR)
+ execute("make distribution DESTDIR=%s" % DESTDIR)
+ execute("make installkernel KERNCONF=%s DESTDIR=%s" % (KERNEL, DESTDIR))
+else:
+ if not os.path.exists(DESTDIR) or not os.path.exists("%s/COPYRIGHT" % DESTDIR):
+ print "%s doesn't look like existing livecd root" % DESTDIR
+ sys.exit(1)
-os.chdir(SRCDIR)
-if DoBuild:
- execute("make buildworld")
-execute("make installworld DESTDIR=%s" % DESTDIR)
-execute("make distribution DESTDIR=%s" % DESTDIR)
-execute("make installkernel KERNCONF=%s DESTDIR=%s" % (KERNEL, DESTDIR))
+str_time = strftime("%Y-%m-%d %H:%M")
+printmsg("Creating config files")
+# Edit loader.conf
lc = file("%s/boot/loader.conf" % DESTDIR, "w+")
-lc.write("# /boot/loader.conf generated by finstall makeimage.py on %s\n" % strftime("%Y-%m-%d %H:%M"))
+lc.write("# /boot/loader.conf generated by finstall makeimage.py on %s\n" % str_time)
lc.write('rootdev="iso9660/%s"\n' % LABEL)
lc.write('boot_cdrom="1"\n')
lc.close()
+# Edit fstab
+f = file("%s/etc/fstab" % DESTDIR, "w+")
+f.write("# /etc/fstab generated by finstall makeimage.py on %s\n" % str_time)
+f.write("/dev/iso9660/%s / cd9660 ro 0 0\n" % LABEL)
+f.write("md /tmp mfs rw,-S,-s32m 0 0\n")
+f.write("/tmp /etc unionfs rw,copymode=transparent 0 0\n")
+f.close()
+
+# Edit rc.conf
+f = file("%s/etc/rc.conf" % DESTDIR, "w+")
+f.write("# /etc/rc.conf generated by finstall makeimage.py on %s\n" % str_time)
+f.write('rc_debug="NO"\n')
+f.write('hostname="finstall"\n')
+f.write('background_fsck="NO"\n')
+f.write('syslogd_flags="-C"\n')
+f.close()
+
os.chdir(WORKDIR)
-execute("mkisofs -l -nobak -V %s -T -J -r -ldots -b boot/cdboot -no-emul-boot -o %s/image.iso %s" % (LABEL, WORKDIR, DESTDIR))
+if ISO == None:
+ ISO = "%s/image.iso" % WORKDIR
+execute("mkisofs -l -nobak -V %s -T -J -r -ldots -b boot/cdboot -no-emul-boot -o %s %s" % (LABEL, ISO, DESTDIR))
More information about the p4-projects
mailing list