Sync with Debian git, incorporating 09_use_udevadm_info.dpatch v1.157.1-1grml.02
authorMichael Prokop <mika@grml.org>
Mon, 6 Apr 2009 20:26:45 +0000 (22:26 +0200)
committerMichael Prokop <mika@grml.org>
Wed, 8 Apr 2009 23:11:14 +0000 (01:11 +0200)
debian/bug/live-initramfs.script [new file with mode: 0644]
debian/changelog
debian/copyright
debian/live-initramfs.init [new file with mode: 0644]
hooks/live
scripts/live-bottom/12fstab
scripts/live-bottom/13swap
scripts/live-bottom/14locales
scripts/live-bottom/15autologin
scripts/live-bottom/16umountfs [new file with mode: 0755]
scripts/live-helpers

diff --git a/debian/bug/live-initramfs.script b/debian/bug/live-initramfs.script
new file mode 100644 (file)
index 0000000..d56b035
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Checking depends
+dpkg -l busybox file initramfs-tools sudo udev user-setup
+
+# Checking recommends
+dpkg -l eject uuid-runtime wget
+
+# Checking suggests
+dpkg -l loop-aes-utils curlftpfs genext2fs httpfs2 squashfs-tools mtd-tools
+
+# Checking other packages
+dpkg -l cryptsetup splashy usplash
index 6af347f..5ab1b4c 100644 (file)
@@ -1,3 +1,11 @@
+live-initramfs (1.157.1-1grml.02) unstable; urgency=low
+
+  * Updating to Debian's git version 03f7e0ea30d52158973ff47bcdebd9932501d143.
+    providing my patch for a smooth udev upgrade path (from 0.125 to 0.140
+    where 'udevadm info' replaces 'udevinfo').
+
+ -- Michael Prokop <mika@grml.org>  Thu, 09 Apr 2009 01:08:30 +0200
+
 live-initramfs (1.157.1-1grml.01) unstable; urgency=low
 
   * Resync with Debian's 1.157.1-1 (mentioning just the relevant changes):
index ca3db4d..e703900 100644 (file)
@@ -1,28 +1,29 @@
 Author: Daniel Baumann <daniel@debian.org>
 Download: http://debian-live.alioth.debian.org/
 
-live-initramfs is a fork of casper <http://packages.ubuntu.com/casper/>. casper
-was originally written by Tollef Fog Heen <tfheen@canonical.com> and Matt
-Zimmerman <mdz@canonical.com>.
+live-initramfs is a fork of casper <http://packages.ubuntu.com/casper/>.
+casper was originally written by Tollef Fog Heen <tfheen@canonical.com>
+and Matt Zimmerman <mdz@canonical.com>.
 
 Files: *
 Copyright:
- (C) 2007-2008 Daniel Baumann <daniel@debian.org>
+ (C) 2007-2009 Daniel Baumann <daniel@debian.org>
  (C) 2005-2008 Canonical Ltd. <http://www.cannonical.com/>
  (C) 2006-2007 Marco Amadori <marco.amadori@gmail.com>
  (C) 2008 Dell Inc. <http://www.dell.com/>
 License: GPL-3+
- This program is free software: you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
- version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
  .
- This program is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
  .
- You should have received a copy of the GNU General Public License along with
- this program. If not, see <http://www.gnu.org/licenses/>.
-
-On Debian systems, the complete text of the GNU General Public License
-can be found in /usr/share/common-licenses/GPL-3 file.
+ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ can be found in /usr/share/common-licenses/GPL-3 file.
diff --git a/debian/live-initramfs.init b/debian/live-initramfs.init
new file mode 100644 (file)
index 0000000..2082a2b
--- /dev/null
@@ -0,0 +1,202 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:            live-initramfs
+# Required-Start:      $syslog
+# Required-Stop:       $syslog
+# Should-Start:                $local_fs
+# Should-Stop:         $local_fs
+# Default-Start:       1 2 3 4 5
+# Default-Stop:                0 6
+# Short-Description:   live-initramfs init script
+# Description:         Resyncs snapshots, evantually caches files in order to
+#                      let remove the media.
+### END INIT INFO
+
+# Authors: Tollef Fog Heen <tfheen@canonical.com>
+#         Marco Amadori <marco.amadori@gmail.com>
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+NAME=live-initramfs
+SCRIPTNAME=/etc/init.d/${NAME}
+DO_SNAPSHOT=/sbin/live-snapshot
+
+# Exit if system was not booted by live-initramfs
+grep -qs boot=live /proc/cmdline || exit 0
+
+# Exit if the system was booted from an ISO image rather than a physical CD
+grep -qs find_iso= /proc/cmdline && exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/live.conf ] && . /etc/live.conf
+
+# Load the VERBOSE setting and other rcS variables
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+# Try to cache everything we're likely to need after ejecting.  This
+# is fragile and simple-minded, but our options are limited.
+cache_path()
+{
+       path="${1}"
+
+       if [ -d "${path}" ]
+       then
+               find "${path}" -type f | xargs cat > /dev/null 2>&1
+       elif [ -f "${path}" ]
+       then
+               if [ -x "${path}" ]
+               then
+                       if file "${path}" | grep -q 'dynamically linked'
+                       then
+                               for lib in $(ldd "${path}" | awk '{ print $3 }')
+                               do
+                                       cache_path "${lib}"
+                               done
+                       fi
+               fi
+
+               cat "${path}" >/dev/null 2>&1
+       fi
+}
+
+get_boot_device()
+{
+       # search in /proc/mounts for the device that is mounted at /live/image
+       while read DEVICE MOUNT REST
+       do
+               if [ "${MOUNT}" = "/live/image" ]
+               then
+                       echo "${DEVICE}"
+                       exit 0
+               fi
+       done < /proc/mounts
+}
+
+device_is_USB_flash_drive()
+{
+       # remove leading "/dev/" and all trailing numbers from input
+       DEVICE=$(expr substr ${1} 6 3)
+
+       # check that device starts with "sd"
+       [ "$(expr substr ${DEVICE} 1 2)" != "sd" ] && return 1
+
+       # check that the device is an USB device
+       if readlink /sys/block/${DEVICE}/device | grep -q usb
+       then
+               return 0
+       fi
+
+       return 1
+}
+
+do_stop ()
+{
+       if ! grep -qs nopersistent /proc/cmdline && grep -qs persistent /proc/cmdline
+       then
+               if [ ! -z "${ROOTSNAP}" ]
+               then
+                       ${DO_SNAPSHOT} --resync-string="${ROOTSNAP}"
+               fi
+
+               if [ ! -z "${HOMESNAP}" ]
+               then
+                       ${DO_SNAPSHOT} --resync-string="${HOMESNAP}"
+               fi
+       else
+               return 0
+       fi
+
+       # check for netboot
+       if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline  || grep -qsi root=/dev/cifs /proc/cmdline
+       then
+               return 0
+       fi
+
+       prompt=1
+       if grep -qs noprompt /proc/cmdline
+       then
+               prompt=
+       fi
+
+       for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default $(which stty)
+       do
+               cache_path "${path}"
+       done
+
+       for x in $(cat /proc/cmdline)
+       do
+               case ${x} in
+                       quickreboot)
+                               QUICKREBOOT="Yes"
+                               ;;
+               esac
+       done
+
+       if [ -z ${QUICKREBOOT} ]
+       then
+               # TODO: i18n
+               BOOT_DEVICE="$(get_boot_device)"
+
+               if device_is_USB_flash_drive ${BOOT_DEVICE}
+               then
+                       # do NOT eject USB flash drives!
+                       # otherwise rebooting with most USB flash drives
+                       # failes because they actually remember the
+                       # "ejected" state even after reboot
+                       MESSAGE="Please remove the USB flash drive"
+               else
+                       # ejecting is a very good idea here
+                       MESSAGE="Please remove the disc, close the the tray (if any)"
+
+                       if [ -x /usr/bin/eject ]
+                       then
+                               eject -p -m /live/image >/dev/null 2>&1
+                       fi
+
+                       [ "$prompt" ] || return 0
+               fi
+
+               stty sane < /dev/console
+
+               echo -n -e "\n\n${MESSAGE} and press ENTER to continue:" > /dev/console
+
+               if [ -x /sbin/usplash_write ]
+               then
+                       /sbin/usplash_write "TIMEOUT 86400"
+                       /sbin/usplash_write "TEXT-URGENT ${MESSAGE}"
+                       /sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
+               fi
+
+               read x < /dev/console
+       fi
+}
+
+case "${1}" in
+       start|restart|reload|force-reload|status)
+               [ "${VERBOSE}" != no ] && log_end_msg 0
+               ;;
+
+       stop)
+               log_begin_msg "${NAME} is resyncing snapshots and caching reboot files..."
+               do_stop
+
+               case "${?}" in
+                       0|1)
+                               [ "${VERBOSE}" != no ] && log_end_msg 0
+                               ;;
+
+                       2)
+                               [ "${VERBOSE}" != no ] && log_end_msg 1
+                               ;;
+               esac
+               ;;
+
+       *)
+               log_success_msg "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload}" >&2
+               exit 3
+               ;;
+esac
index 32adfb6..4e29226 100755 (executable)
@@ -148,7 +148,10 @@ else
        copy_exec /sbin/udevtrigger /sbin
        copy_exec /sbin/udevsettle /sbin
 fi
-copy_exec /usr/bin/udevinfo /bin
+if [ -x /usr/bin/udevinfo ]
+then
+       copy_exec /usr/bin/udevinfo /bin
+fi
 
 # Program: wget
 if [ -x /usr/bin/wget ]
index f38eee7..d246a59 100755 (executable)
@@ -32,17 +32,27 @@ log_begin_msg "Configuring fstab"
 
 # live-initramfs script
 
-# Create a fake fstab only if it is not already there
+# Create a fake fstab only if it doesn't exist or if its the debootstrap template
 if [ ! -f "${FSTAB}" ] || grep -qs 'UNCONFIGURED FSTAB FOR BASE SYSTEM' "${FSTAB}"
 then
-       cat >> ${FSTAB} << EOF
+
+cat > ${FSTAB} << EOF
 # /etc/fstab: static file system information.
 #
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 
-${UNIONTYPE} / ${UNIONTYPE} rw 0 0
-tmpfs /tmp tmpfs nosuid,nodev 0 0
 EOF
+
+fi
+
+if ! grep -qs  "^${UNIONTYPE}" "${FSTAB}"
+then
+       echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${FSTAB}"
+fi
+
+if ! grep -qs "^tmpfs /tmp" "${FSTAB}"
+then
+       echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${FSTAB}"
 fi
 
 # disabled for now
index 8fc718c..448c90a 100755 (executable)
@@ -55,9 +55,10 @@ done
 for device in ${devices}
 do
 
-cat >> ${FSTAB} << EOF
-${device} swap swap defaults 0 0
-EOF
+if ! grep -qs  "^${device} swap" "${FSTAB}"
+then
+       echo "${device} swap swap defaults 0 0" >> "${FSTAB}"
+fi
 
 done
 
index 6348338..022a605 100755 (executable)
@@ -104,7 +104,10 @@ then
 
        if [ -d /root/etc/default/kdm.d/ ]
        then
-               printf 'LANGUAGE=%s\n' "${LANG}" >> /root/etc/default/kdm.d/live-autologin
+               if ! grep -qs "^LANGUAGE" "${LANG}"
+               then
+                       printf 'LANGUAGE=%s\n' "${LANG}" >> /root/etc/default/kdm.d/live-autologin
+               fi
        elif [ -f /root/etc/kde3/kdm/kdmrc ]
        then
                sed -i -r -e "s/#Language=.*/Language=${language}/" \
@@ -113,8 +116,8 @@ then
 
        really_export LANG
 
-       printf 'LANG="%s"\n' "${LANG}" >> /root/etc/default/locale
-       printf 'LANG="%s"\n' "${LANG}" >> /root/etc/environment
+       printf 'LANG="%s"\n' "${LANG}" > /root/etc/default/locale
+       printf 'LANG="%s"\n' "${LANG}" > /root/etc/environment
        printf '%s %s\n' "${LANG}" "${codepage}" > /root/etc/locale.gen
 
        if [ -z "${SILENT}" ]
index 7fb2b13..38c3a8f 100755 (executable)
@@ -59,6 +59,8 @@ fi
 
 if [ -d /root/etc/default/kdm.d/ ]
 then
+       if ! grep -qs "^AUTOLOGIN" /root/etc/default/kdm.d/live-autologin
+       then
 
 cat >> /root/etc/default/kdm.d/live-autologin << EOF
 AUTOLOGINUSER=${USERNAME}
@@ -66,6 +68,8 @@ AUTOLOGINAGAIN=true
 AUTOLOGINDELAY=0
 EOF
 
+       fi
+
 elif [ -f /root/etc/kde3/kdm/kdmrc ]
 then
        # Configure KDM autologin
diff --git a/scripts/live-bottom/16umountfs b/scripts/live-bottom/16umountfs
new file mode 100755 (executable)
index 0000000..64ad99d
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+       echo "${PREREQ}"
+}
+
+case "${1}" in
+       prereqs)
+               prereqs
+               exit 0
+               ;;
+esac
+
+# live-initramfs header
+
+. /live.vars
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling umountfs for live specific filesystems"
+
+# live-initramfs script
+
+if [ -e /root/etc/init.d/umountfs ]
+then
+       sed -i  -e 's#pioodl $TMPFS_MTPTS)#pioodl $TMPFS_MTPTS | sed -e "s@\\ @\\n@" | grep -v ^/live)#' \
+               -e 's#pioodl $REG_MTPTS)#pioodl $REG_MTPTS | sed -e "s@\\ @\\n@" | grep -v ^/live | grep -v ^/filesystem) /#' \
+       /root/etc/init.d/umountfs
+fi
+
+log_end_msg
index 70897d6..59bdb4f 100644 (file)
@@ -6,10 +6,19 @@ then
        export PATH="${PATH}:/usr/lib/klibc/bin"
 fi
 
+# handle upgrade path from old udev (using udevinfo) to
+# recent versions of udev (using udevadm info)
+if [ -x /sbin/udevadm ]
+then
+       udevinfo='/sbin/udevadm info'
+else
+       udevinfo='udevinfo'
+fi
+
 sys2dev ()
 {
        sysdev=${1#/sys}
-       echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})"
+       echo "/dev/$($udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})"
 }
 
 subdevices ()