]> git.donarmstrong.com Git - neurodebian.git/commitdiff
ENH: tune up Tiziano's changes so we could process options from cmdline
authorYaroslav Halchenko <debian@onerussian.com>
Fri, 7 Dec 2012 03:46:17 +0000 (22:46 -0500)
committerYaroslav Halchenko <debian@onerussian.com>
Fri, 7 Dec 2012 03:46:17 +0000 (22:46 -0500)
templating/options handling could be greatly improved ;)

vm/d-i/wheezy/initial_setup
vm/d-i/wheezy/preseed.cfg.in
vm/tools/nd_createappliance

index bbeb0fd4b23723e8c67a06a2911ae72fd3664d40..63532b4e26241649e99c291ababd4e58288cf630 100755 (executable)
@@ -88,7 +88,7 @@ apt-get install -y linux-headers-$cdarch
 
 # to get all the rest stuff in recommends
 apt-get install -y dkms
-# TODO: neurodebian-guest-additions
+# TODO: neurodebian-guest-additions  -- pulls in gdm3 ATM
 
 if [ "$darch" != "$cdarch" ] ; then
     # Because DKMS builds for currently running kernel, which during
@@ -131,6 +131,7 @@ apt-get install --no-install-recommends -y \
 # resolve their destiny ;-)   a;though it might be pooling too much, eg exim4
 
 # TODO: autologin for lightdm (autologin-user=brain in /etc/lightdm/lightdm.conf), default panel (with chromium) for xfce
+# TODO: pre-configure the panel "Welcome to the first start of the panel", "Use default config"?
 
 # Clean-up installed development files which got pulled in for
 # VM guest additions (to build kernel modules via DKMS)
@@ -163,8 +164,8 @@ sed -i -e 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=1/g' /etc/default/grub
 update-grub
 
 # finally configure geomirror for APT and disable deb-src lists
-#sed -i -e "s/10.0.0.1:9999/$(dpkg --print-architecture)-geomirror.debian.net/" \
-#    -e "s/^deb-src/#deb-src/" /etc/apt/sources.list
+sed -i -e "s,\(deb\(\|-src\) http://\)[^/]*/,\1$(dpkg --print-architecture)-geomirror.debian.net/,g" \
+    -e "s/^deb-src/#deb-src/" /etc/apt/sources.list
 
 etckeeper commit "Initial VM setup done"
 
index 9ec5f33b62780f89c21134faa8d4203fef2254db..5024aa7d0d1ff29113cd6cffcc42799bc2769b4f 100644 (file)
@@ -78,7 +78,7 @@ d-i netcfg/invalid_hostname string neurodebian
 # If you select ftp, the mirror/country string does not need to be set.
 #d-i mirror/protocol string ftp
 d-i mirror/country string manual
-d-i mirror/http/hostname string ftp.debian.de
+d-i mirror/http/hostname string %(MIRROR_HTTP_HOSTNAME)s
 d-i mirror/http/directory string /debian
 #d-i mirror/http/proxy string
 
@@ -93,7 +93,7 @@ d-i clock-setup/utc boolean true
 
 # You may set this to any valid setting for $TZ; see the contents of
 # /usr/share/zoneinfo/ for valid values.
-d-i time/zone string Europe/Berlin
+d-i time/zone string %(TIME_ZONE)s
 
 # Controls whether to use NTP to set the clock during the install
 d-i clock-setup/ntp boolean true
@@ -331,7 +331,7 @@ d-i debian-installer/exit/poweroff boolean true
 # packages and run commands in the target system.
 #d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
 #d-i preseed/late_command string wget -O/target/tmp/initial_setup http://git.debian.org/?p=pkg-exppsy/neurodebian.git;a=blob_plain;f=vm/d-i/tools/initial_setup;hb=HEAD; \
-d-i preseed/late_command string wget -O/target/tmp/initial_setup http://10.0.2.2:10100/initial_setup ; \
+d-i preseed/late_command string wget -O/target/tmp/initial_setup http://%(DI_HTTP_HOSTNAME)s/initial_setup ; \
         in-target /bin/bash /tmp/initial_setup
 
 # XXX here get/call nd_setupguestos ?
index ef2e32989eb93d53c16cc0d025f1da988fd3517a..593c315695340ba5a59367c2c18393f9f075d607 100755 (executable)
@@ -5,59 +5,77 @@
 # fail early
 set -eu
 
+build_dir=$PWD/build
+dist_dir=$PWD/dist
+vendor="NeuroDebian"
+vm_version="6.999.b4.20121206"
+vm_ostype=Debian
+vendor_url="http://neuro.debian.net"
+product_url="${vendor_url}/vm.html"
+di_port=10100                   # port to start webserver on
+
+# Generic definitions
+eula="This virtual appliance contains Free and Open Source Software (FOSS) released under licenses compliant with the Debian Free Software Guidelines (DFSG, see http://www.debian.org/social_contract), such as, GPL, BSD, MIT, etc.  Such software is free to be used or customized for any purpose.
+
+However, by default this virtual machine is also enabled to install additional software from Debian and NeuroDebian repositories that is distributed under more restrictive licenses (e.g. closed-source, non-commercial, research-only). It is the user's responsibility to adhere to the terms and conditions of any particular software that is installed and used in this virtual machine. Copyright and license details for any installed PACKAGE are available in /usr/share/doc/PACKAGE/copyright inside the virtual machine."
+
+# The defaults to be modified from cmdline
+di_cd=
+# look here for more details about the default IP of the host:
+# # http://www.virtualbox.org/manual/ch09.html#changenat
+mirror_host=10.0.0.1:9999
+di_tz='US/Eastern'
+di_preseed_in=
 
 function usage {
-echo "Usage: $0 [-p PRESEED -i ISO -m MIRROR -t TZ]
+echo "Usage: $0 [OPTIONS]
 
 Create ND VirtualBox appliance.
 
-Options: 
-  -p PRESEED   path to preesed file for d-i
-  -i ISO       path to debian installation iso file
-  -m MIRROR    debian mirror to use for installation
-  -t TZ        time zone of virtual machine
-  -h           Show this help and exit
+Options:
+  -p PRESEED_IN path to preesed.cfg.in file for d-i
+  -i ISO        path to debian installation iso file
+  -m MIRROR     debian mirror to use for installation
+  -t TIME_ZONE  time zone of virtual machine
+  -h            Show this help and exit
 "
 }
 
-while getopts "p:" OPTION
+# Process cmdline
+while getopts "p:i:" OPTION
 do
   case $OPTION in
-    "f")  $OPTARG;;
-    \?) exit 1;;
+      "p") di_preseed_in="$OPTARG";;
+      "i") di_cd="$OPTARG";;
+      "m") mirror_host="$OPTARG";;
+      "t") di_tz="$OPTARG";;
+      "h") exit 1;;
   esac
 done
 
+if [ -z "$di_cd" ] ; then
+    echo "You must specify the iso image (-i)" >&2
+    exit 1
+fi
 
-# TODO: arguments later on to become cmdline args
-#iso=debian-squeeze-di-beta1-amd64-businesscard.iso
-#iso=debian-6.0.3-${ARCH:=amd64}-businesscard.iso
-#iso=debian-wheezy-DI-a1-${ARCH:=amd64}-businesscard.iso
-
-di_cd=/backup/isos/debian-wheezy-DI-b1-amd64-netinst.iso
-# look here for more details about the default IP of the host:
-# # http://www.virtualbox.org/manual/ch09.html#changenat
-di_host=10.0.2.2              # where to look for di preseed
-di_port=10100
-di_preseed=/home/tiziano/git/neurodebian/vm/d-i/wheezy/preseed.cfg
-
-
-build_dir=$PWD/build
-dist_dir=$PWD/dist
-vendor="NeuroDebian"
-vm_version="6.999.20120827"
-vm_ostype=Debian
-vendor_url="http://neuro.debian.net"
-product_url="${vendor_url}/vm.html"
-
-# Generic definitions
-eula="This virtual appliance contains Free and Open Source Software (FOSS) released under licenses compliant with the Debian Free Software Guidelines (DFSG, see http://www.debian.org/social_contract), such as, GPL, BSD, MIT, etc.  Such software is free to be used or customized for any purpose.
-
-However, by default this virtual machine is also enabled to install additional software from Debian and NeuroDebian repositories that is distributed under more restrictive licenses (e.g. closed-source, non-commercial, research-only). It is the user's responsibility to adhere to the terms and conditions of any particular software that is installed and used in this virtual machine. Copyright and license details for any installed PACKAGE are available in /usr/share/doc/PACKAGE/copyright inside the virtual machine."
+if [ -z "$di_preseed_in" ]; then
+    # deduce release and use corresponding directory here
+    release=$(basename "$di_cd" | cut -d- -f2)
+    di_preseed_in=$(dirname $0)/../d-i/$release/preseed.cfg.in
+    if [ ! -e "$di_preseed_in" ]; then
+        echo "$di_preseed_in is not found. Specify one with -p" >&2
+        exit 2
+    fi
+fi
 
+# Figure out our IP address for VM to reach webserver
+eth=`route | awk '/default/{print $8;}'`
+di_host=`ip addr show dev $eth | sed -ne '/inet /s, *inet \([0-9.]*\)/.*,\1,gp'`
 
-# Computed settings
-#vm_basepath=
+# Generate preseed file
+# yoh could not escape Python here
+di_preseed=${di_preseed_in%.in}
+python -c "open('$di_preseed', 'w').write(open('$di_preseed_in').read() % {'DI_HTTP_HOSTNAME': '$di_host:$di_port', 'MIRROR_HTTP_HOSTNAME': '$mirror_host', 'TIME_ZONE': '$di_tz'})"
 
 # By default 32bit unless installer image has amd64
 # TODO: might need to make more robust?
@@ -165,7 +183,12 @@ _info "Run Debian Installer"
 # press Enter"
 
 # start local web server to serve preseed file
-cd $(dirname ${di_preseed}) && python -m SimpleHTTPServer ${di_port} >&/dev/null &
+builtin cd $(dirname ${di_preseed})
+python -m SimpleHTTPServer ${di_port} >&/dev/null &
+di_pid=$!
+builtin cd -
+
+
 
 VBoxManage startvm "${vm_name}"
 
@@ -184,7 +207,7 @@ while VBoxManage showvminfo "${vm_name}" | grep -q running; do
 done
 
 # kill the web server
-#kill ${webserver_pid}
+kill ${di_pid} || echo "Could not kill the webserver"
 
 _info Compacting VDI
 sudo ./nd_compactvdi "${vm_disk}"