use build/build.common functions
authorMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 31 Aug 2007 02:29:35 +0000 (02:29 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 31 Aug 2007 02:29:35 +0000 (02:29 +0000)
build.sh

index f1433f5..be62285 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -5,7 +5,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2004-2006 The Trustees of Princeton University
 #
-# $Id: build.sh,v 1.17 2007/08/13 18:02:33 faiyaza Exp $
+# $Id: build.sh,v 1.18.2.1 2007/08/30 16:39:09 mef Exp $
 #
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -23,10 +23,14 @@ fi
 
 export PATH
 
-# Release and architecture to install
-releasever=4
-basearch=i386
+# build.common comes from the build module
+. build.common
 
+pl_process_fedora_options $@
+shiftcount=$?
+shift $shiftcount
+
+# XXX this should be coming from some configuration file
 # Packages to install
 packagelist=(
 bash
@@ -58,28 +62,9 @@ tar
 findutils
 )
 
-usage()
-{
-    echo "Usage: build.sh [OPTION]..."
-    echo "     -r release      Fedora release number (default: $releasever)"
-    echo "     -a arch         Fedora architecture (default: $basearch)"
-    echo "     -h              This message"
-    exit 1
-}
-
-# Get options
-while getopts "r:a:h" opt ; do
-    case $opt in
-       r)
-           releasever=$OPTARG
-           ;;
-       a)
-           basearch=$OPTARG
-           ;;
-       h|*)
-           usage
-           ;;
-    esac
+# vserver-reference packages used for reference image
+for package in "${packagelist[@]}" ; do
+    packages="$packages -p $package"
 done
 
 # Do not tolerate errors
@@ -89,38 +74,10 @@ set -e
 vroot=$PWD/vservers/.vref/default
 install -d -m 755 $vroot
 
-# Install default reference image
-for package in "${packagelist[@]}" ; do
-    packages="$packages -p $package"
-done
-mkfedora -v -r $releasever -a $basearch -k $packages $vroot
-
-# Clean /dev
-rm -rf $vroot/dev
-mkdir -p $vroot/dev
-mknod -m 666 $vroot/dev/null c 1 3
-mknod -m 666 $vroot/dev/zero c 1 5
-mknod -m 666 $vroot/dev/full c 1 7
-mknod -m 644 $vroot/dev/random c 1 8
-mknod -m 644 $vroot/dev/urandom c 1 9
-mknod -m 666 $vroot/dev/tty c 5 0
-mknod -m 666 $vroot/dev/ptmx c 5 2
-# For bash command substitution
-ln -nsf ../proc/self/fd $vroot/dev/fd
-# For df and linuxconf
-touch $vroot/dev/hdv1
-# For TUN/TAP
-mkdir -p $vroot/dev/net
-mknod -m 600 $vroot/dev/net/tun c 10 200
-# For pseudo ttys
-mkdir -p $vroot/dev/pts
-
-# Disable all services in reference image
-chroot $vroot sh -c "/sbin/chkconfig --list | awk '{ print \$1 }' | xargs -i /sbin/chkconfig {} off"
+# Populate a minimal /dev in the reference image
+pl_makedevs $vroot
 
-# This tells the Boot Manager that it is okay to update
-# /etc/resolv.conf and /etc/hosts whenever the network configuration
-# changes. Users are free to delete this file.
-touch $vroot/etc/AUTO_UPDATE_NET_FILES
+# Populate image with vserver-reference packages
+pl_setup_chroot $vroot $packages
 
 exit 0