PERFORCE change 123333 for review
Ivan Voras
ivoras at FreeBSD.org
Wed Jul 11 17:32:46 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123333
Change 123333 by ivoras at ivoras_finstall on 2007/07/11 17:32:25
Make /usr tree in a compressed UFS-formatted disk image,
introduce a (hopefully, temporary) ugly kludge for the
"current date is negative" problem, discussed (without
much progress) on mailing lists.
Affected files ...
.. //depot/projects/soc2007/ivoras_finstall/makeimage/bundles/livecd#3 edit
.. //depot/projects/soc2007/ivoras_finstall/makeimage/makeimage.py#8 edit
Differences ...
==== //depot/projects/soc2007/ivoras_finstall/makeimage/bundles/livecd#3 (text+ko) ====
@@ -1,10 +1,30 @@
+#!/bin/sh
# $dest_file$ generated by finstall makeimage.py on $date$ $time$
# BEFORE: hostid
# REQUIRE: root
# KEYWORD: nojail
-#
-/sbin/mount_mfs -s 32m -S -m 3 -f 512 -b 4096 md /tmp
-/bin/mkdir /tmp/etc /tmp/var /tmp/root
+
+# This is hack of tremendeous bogosity, but currently there's no way
+# out of it. A normal FreeBSD kernel, once CD-booted, reports a date in
+# 1937 (at least in VMWare Server).
+# What I'm doing here is detecting if the date (in unix time_t format)
+# is negative, and set the positive value as the current date. It doesn't
+# work since the "wrong" date isn't simply a negative of the current one
+# but at least it's in the current epoch.
+t=`/bin/date +%s`
+if [ $t -lt 0 ]
+then
+ t=`/bin/expr -- $t \* -1`
+ /bin/date -f %s $t
+fi
+
+/sbin/mount_mfs -s 128m -S -m 3 -f 512 -b 4096 md /tmp
+/bin/mkdir /tmp/etc /tmp/var /tmp/root /tmp/install
/sbin/mount_unionfs -o copymode=transparent /tmp/etc /etc
/sbin/mount_unionfs -o copymode=transparent /tmp/var /var
/sbin/mount_unionfs -o copymode=transparent /tmp/root /root
+/sbin/mount_unionfs -o copymode=transparent /tmp/install /install
+
+/sbin/mdconfig -a -t vnode -f /usr/usr.img.uzip -u 60
+/sbin/mount -o ro /dev/md60.uzip /usr
+
==== //depot/projects/soc2007/ivoras_finstall/makeimage/makeimage.py#8 (text+ko) ====
@@ -73,7 +73,7 @@
ISO = None
STARTDIR = os.path.realpath(".")
-opts, args = getopt(sys.argv[1:], "d:s:i:p:bch")
+opts, args = getopt(sys.argv[1:], "d:s:i:p:k:bch")
for o,a in opts:
if o == "-d":
WORKDIR = a
@@ -113,6 +113,8 @@
DESTDIR = "%s/livecd" % WORKDIR
initutils()
+
+
if DoMakeRoot:
if os.path.exists(DESTDIR):
if not os.path.exists("%s/COPYRIGHT" % DESTDIR):
@@ -127,6 +129,23 @@
os.makedirs(DESTDIR)
+
+os.chdir(WORKDIR)
+if DoMakeRoot:
+ execute("touch usr.img")
+ execute("truncate -s 600m usr.img")
+if not os.path.exists("%s/usr.img" % WORKDIR):
+ print "No usr.img"
+ sys.exit(1)
+execute("mdconfig -a -t vnode -f usr.img -u 60")
+execute("newfs -m 2 /dev/md60")
+if not os.path.exists("%s/usr" % DESTDIR):
+ os.mkdir("%s/usr" % DESTDIR)
+execute("mount /dev/md60 %s/usr" % DESTDIR)
+os.chdir(STARTDIR)
+
+
+if DoMakeRoot:
printmsg("Using '%s' as source directory" % SRCDIR)
printmsg("Using '%s' as working directory (root on '%s')" % (WORKDIR, DESTDIR))
printmsg("Using '%s' kernel" % KERNEL)
@@ -135,9 +154,9 @@
if DoBuild:
execute("make buildworld")
execute("make installworld DESTDIR=%s" % DESTDIR)
+ execute("make installkernel KERNCONF=%s DESTDIR=%s" % (KERNEL, DESTDIR))
execute("make distribution DESTDIR=%s" % DESTDIR)
- execute("make installkernel KERNCONF=%s DESTDIR=%s" % (KERNEL, DESTDIR))
- execute("rm %s/boot/kernel/*.symbols" % DESTDIR)
+# execute("rm %s/boot/kernel/*.symbols" % DESTDIR)
os.chdir(DESTDIR)
execute("mtree -c > livecd.mtree")
os.chdir(STARTDIR)
@@ -146,6 +165,9 @@
print "%s doesn't look like existing livecd root" % DESTDIR
sys.exit(1)
+
+# Prepare /usr image
+
str_time = strftime("%H:%M")
str_date = strftime("%Y-%m-%d")
@@ -238,9 +260,40 @@
else:
printmsg("WARNING: Not bundling any config files")
+### finstall-specific part ###
+# Everything done until now has been for a generic LiveCD. Now, do some magic
+# (configuration mostly) for finstall.
+
+# Create an alternative root user named "install" and make it run startx when
+# logged in.
+install_found = False
+f = file("%s/etc/passwd" % DESTDIR, "r")
+for line in f.readlines():
+ if line.startswith("install:"):
+ install_found = True
+f.close()
+if not install_found:
+ f = file("%s/tmp/userinst.sh" % DESTDIR, "w")
+ f.write("pw useradd -n install -o -u 0 -d /install -m -s /bin/tcsh -w none -c Installer")
+ f.close()
+ execute("chroot %s /bin/sh /tmp/userinst.sh" % DESTDIR)
+ os.unlink("%s/tmp/userinst.sh" % DESTDIR)
+skel_cshrc = file("%s/usr/share/skel/dot.cshrc" % DESTDIR, "r").read()
+f = file("%s/install/.cshrc" % DESTDIR, "w")
+f.write(skel_cshrc)
+f.write("startx\n")
+f.close()
+
+
+# finish usr image
os.chdir(WORKDIR)
+execute("umount %s/usr" % DESTDIR)
+execute("mdconfig -d -u 60")
+execute("mkuzip -v -o %s/usr/usr.img.uzip -s 16384 usr.img" % DESTDIR)
+
+os.chdir(WORKDIR)
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))
+execute("mkisofs -l -nobak -V %s -T -J -R -ldots -b boot/cdboot -no-emul-boot -o %s %s" % (LABEL, ISO, DESTDIR))
os.chdir(STARTDIR)
More information about the p4-projects
mailing list