From f454e1250e7deec95166035de0d1b303b99b3a0f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 23 Sep 2007 14:46:28 +0200 Subject: [PATCH] Adding casper 1.77+debian-6. --- bin/casper-snapshot | 2 +- debian/changelog | 9 +++++++++ debian/manpage/casper.7 | 9 ++++++--- scripts/casper | 14 +++++++++++++- scripts/casper-bottom/23networking | 26 ++++++++++++++++++++++++-- scripts/casper-helpers | 7 ++++++- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/bin/casper-snapshot b/bin/casper-snapshot index 33dede4..c0c8662 100644 --- a/bin/casper-snapshot +++ b/bin/casper-snapshot @@ -208,7 +208,7 @@ Mount_device () mkdir -p "${MOUNTP}" fi - if [ -n "${dev}" ]; then + if [ -z "${dev}" ]; then # create a temp mount -t tmpfs -o rw tmpfs "${MOUNTP}" if [ ! -L /home/$USERNAME/Desktop/casper-snapshot ]; then diff --git a/debian/changelog b/debian/changelog index 4b85a68..83768c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +casper (1.77+debian-6) unstable; urgency=medium + + * Improved snapshots features (even still experimental). + * Added "live-media-offset=BYTES" boot param, to enable "hiding" + feature, thanks to Sebastien Raveau . + * Now it creates /etc/resolv.conf if netbooted. + + -- Marco Amadori Fri, 1 Dec 2006 17:43:30 +0100 + casper (1.77+debian-5) unstable; urgency=low * Fixed preseeding locale and keyboard's variant and options. diff --git a/debian/manpage/casper.7 b/debian/manpage/casper.7 index aac3eca..c195d9f 100644 --- a/debian/manpage/casper.7 +++ b/debian/manpage/casper.7 @@ -30,12 +30,15 @@ Let you specify the name(s) and the options of the interface(s) that should be c .BR ip[= frommedia ] If this variable is set, dhcp and static configuration are just skipped and the system will use the (must be) media-preconfigured /etc/network/interfaces instead. .TP -.BI "locale=" LOCALE " | debian-installer/locale=" LOCALE -Configure the running locale as specified, if not present the live-media rootfs configured locale will be used and if also this one misses casper behave as "locale=en_US.UTF-8" was specified. If only 2 lowercase letter are specified (like "it"), the "maybe wanted" locale is generated (like it:IT.UTF-8), in this case if also "keyb=" is unspecified is set with those 2 lowercase letters (keyb=it). -.TP .BI "{live-media|bootfrom}=" DEVICE If you specify one of this two equivalent forms, casper will first try to find this device for the "/casper" directory where the read-only root filesystem should reside. If it did not find something usable, the normal scan for block devices is performed. .TP +.BI "live-media-offset=" BYTES +This way you could tell casper that your image starts at offset BYTES in the above specified or autodiscovered device, this could be useful to hide the debian-live iso or image inside another iso or image, to create "clean" images. +.TP +.BI "locale=" LOCALE " | debian-installer/locale=" LOCALE +Configure the running locale as specified, if not present the live-media rootfs configured locale will be used and if also this one misses casper behave as "locale=en_US.UTF-8" was specified. If only 2 lowercase letter are specified (like "it"), the "maybe wanted" locale is generated (like it:IT.UTF-8), in this case if also "keyb=" is unspecified is set with those 2 lowercase letters (keyb=it). +.TP .BR "netboot[=" nfs "|" cifs ] This tells casper to perform a network mount. The parameter "nfsroot=" (with optional "nfsopts="), should specify where is the location of the root filesystem. With no args, will try cifs first, and if it fails nfs. .TP diff --git a/scripts/casper b/scripts/casper index 8cfc0df..7358f85 100644 --- a/scripts/casper +++ b/scripts/casper @@ -73,6 +73,8 @@ parse_cmdline () export LIVEMEDIA=${x#*=} ;; live-media-timeout=*) export LIVEMEDIA_TIMEOUT=${x#live-media-timeout=} ;; + live-media-offset=*) + export LIVEMEDIA_OFFSET=${x#live-media-offset=} ;; locale=*|debian-installer/locale=*) export LOCALE=${x#*=} ;; keyb=*|kbd-chooser/method=*) @@ -224,7 +226,7 @@ do_netmount() { modprobe "${MP_QUIET}" af_packet # For DHCP - ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf + ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config if [ "${NFSROOT}" = "auto" ]; then NFSROOT=${ROOTSERVER}:${ROOTPATH} @@ -482,6 +484,12 @@ check_dev () if [ -z "${devname}" ]; then devname=$(sys2dev "${sysdev}") fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}") + devname="${loopdevname}" + fi + fstype=$(get_fstype "${devname}") if is_supported_fs ${fstype}; then mount -t ${fstype} -o ro "${devname}" $mountpoint || continue @@ -492,6 +500,10 @@ check_dev () umount $mountpoint fi fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + losetup -d "${loopdevname}" + fi return 1 } diff --git a/scripts/casper-bottom/23networking b/scripts/casper-bottom/23networking index 2bdf9b0..129ca35 100755 --- a/scripts/casper-bottom/23networking +++ b/scripts/casper-bottom/23networking @@ -21,7 +21,7 @@ esac log_begin_msg "$DESCRIPTION" -if [ "${STATICIP}" == "frommedia" ] && [ -e "$IFFILE" ] ; then +if [ "${STATICIP}" == "frommedia" -a -e "$IFFILE" ] ; then # will use existent /etc/network/interfaces log_end_msg exit 0 @@ -35,7 +35,7 @@ EOF udevtrigger -if [ -z "${NETBOOT}" -a -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]; then +if [ -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]; then parsed=$(echo "${STATICIP}" | sed -e 's/:/ /g') for ifline in ${parsed}; do ifname="$(echo ${ifline} | cut -f1 -d ',')" @@ -71,6 +71,28 @@ iface ${i} inet ${method} EOF done + if [ ! -f /root/etc/resolv.conf -a -f /netboot.config ] ; then + # create a resolv.conf if it is not present + cp /netboot.config /root/var/log/netboot.config + rc_search=$(cat netboot.config | awk '/domain/{print $3}') + rc_server0=$(cat netboot.config | awk '/dns0/{print $5}') + rc_server1=$(cat netboot.config | awk '/dns0/{print $8}') + rc_server0="nameserver ${rc_server0}" + if [ "${rc_server1}" = "0.0.0.0" ]; then + rc_server1="" + else + rc_server1="nameserver ${rc_server1}" + fi + cat > /root/etc/resolv.conf <> /root/var/log/netboot.config + fi fi log_end_msg diff --git a/scripts/casper-helpers b/scripts/casper-helpers index cfbc3c6..f8bd206 100644 --- a/scripts/casper-helpers +++ b/scripts/casper-helpers @@ -110,6 +110,7 @@ setup_loop() { local fspath=$1 local module=$2 local pattern=$3 + local offset=$4 modprobe "${MP_QUIET}" -b "$module" udevsettle @@ -117,7 +118,11 @@ setup_loop() { for loopdev in $pattern; do if [ "$(cat $loopdev/size)" -eq 0 ]; then dev=$(sys2dev "${loopdev}") - losetup "$dev" "$fspath" + if [ -n "$offset" ]; then + losetup -o "$offset" "$dev" "$fspath" + else + losetup "$dev" "$fspath" + fi echo "$dev" return 0 fi -- 2.1.4