From cd83917a95a3d675537d7c073cb4c91e1d230335 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 12 Oct 2009 18:46:43 +0200 Subject: [PATCH] xbps-casper: update to 0.3, multiple improvements. * Remove unionfs-fuse support, it won't be used. * Added two scripts for casper-bottom: 11keymap and 30policykit. * It's possible now to specify the keymap and locale through the bootloader. * Use the 15autologin script from now on. --HG-- extra : convert_revision : a66369cf25a9d07369f3c8d6723b3735f4a21944 --- templates/xbps-casper/files/hooks/casper | 5 - templates/xbps-casper/files/scripts/casper | 132 ++++++------------ .../files/scripts/casper-bottom/05mountpoints | 2 +- .../files/scripts/casper-bottom/10adduser | 10 +- .../files/scripts/casper-bottom/11keymap | 43 ++++++ .../files/scripts/casper-bottom/12fstab | 4 +- .../files/scripts/casper-bottom/13swap | 9 +- .../files/scripts/casper-bottom/14locales | 4 +- .../files/scripts/casper-bottom/15autologin | 6 +- .../files/scripts/casper-bottom/18hostname | 4 +- .../files/scripts/casper-bottom/30policykit | 46 ++++++ templates/xbps-casper/template | 2 +- 12 files changed, 155 insertions(+), 112 deletions(-) create mode 100755 templates/xbps-casper/files/scripts/casper-bottom/11keymap create mode 100755 templates/xbps-casper/files/scripts/casper-bottom/30policykit diff --git a/templates/xbps-casper/files/hooks/casper b/templates/xbps-casper/files/hooks/casper index 14ae7db9924..66fdbc772ec 100755 --- a/templates/xbps-casper/files/hooks/casper +++ b/templates/xbps-casper/files/hooks/casper @@ -21,11 +21,6 @@ esac manual_add_modules unionfs manual_add_modules aufs -# unionfs-fuse, if available -if [ -x /usr/bin/unionfs-fuse ]; then - copy_exec /usr/bin/unionfs-fuse /bin -fi - # We need losetup copy_exec /sbin/losetup /sbin diff --git a/templates/xbps-casper/files/scripts/casper b/templates/xbps-casper/files/scripts/casper index 3a6265f8940..dd2ed79bd59 100644 --- a/templates/xbps-casper/files/scripts/casper +++ b/templates/xbps-casper/files/scripts/casper @@ -52,20 +52,24 @@ parse_cmdline() { live-media-path=*) LIVE_MEDIA_PATH="${x#live-media-path=}" export LIVE_MEDIA_PATH - echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;; + echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" \ + >> /etc/casper.conf ;; esac done if [ "${UNIONFS}" = "" ]; then - export UNIONFS="aufs" + export UNIONFS="unionfs" fi } is_casper_path() { path=$1 if [ -d "$path/$LIVE_MEDIA_PATH" ]; then - if [ "$(echo $path/$LIVE_MEDIA_PATH/*.squashfs)" != "$path/$LIVE_MEDIA_PATH/*.squashfs" ] || - [ "$(echo $path/$LIVE_MEDIA_PATH/*.ext2)" != "$path/$LIVE_MEDIA_PATH/*.ext2" ] || - [ "$(echo $path/$LIVE_MEDIA_PATH/*.dir)" != "$path/$LIVE_MEDIA_PATH/*.dir" ]; then + if [ "$(echo $path/$LIVE_MEDIA_PATH/*.squashfs)" != \ + "$path/$LIVE_MEDIA_PATH/*.squashfs" ] || + [ "$(echo $path/$LIVE_MEDIA_PATH/*.ext2)" != \ + "$path/$LIVE_MEDIA_PATH/*.ext2" ] || + [ "$(echo $path/$LIVE_MEDIA_PATH/*.dir)" != \ + "$path/$LIVE_MEDIA_PATH/*.dir" ]; then return 0 fi fi @@ -154,7 +158,8 @@ copy_live_to() { fstype=$(get_fstype "${dev}") freespace=$(fs_size "${dev}") else - [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device." + [ "$quiet" != "y" ] && \ + log_warning_msg "${copytodev} is not a block device." return 1 fi fi @@ -167,7 +172,8 @@ copy_live_to() { mkdir "${copyto}" echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" - cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files + # "cp -a" from busybox also copies hidden files + cp -a ${copyfrom}/* ${copyto} umount ${copyfrom} mount -r -o move ${copyto} ${copyfrom} rmdir ${copyto} @@ -209,11 +215,13 @@ do_nfsmount() { NFSOPTS="" fi - [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" + [ "$quiet" != "y" ] && \ + log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" # FIXME: This while loop is an ugly HACK round an nfs bug i=0 while [ "$i" -lt 60 ]; do - nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break + nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" \ + "${mountpoint}" && rc=0 && break sleep 1 i="$(($i + 1))" done @@ -229,7 +237,8 @@ do_cifsmount() { CIFSOPTS="${NFSOPTS}" fi - [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" + [ "$quiet" != "y" ] && \ + log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" modprobe "${MP_QUIET}" cifs if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then @@ -278,7 +287,8 @@ do_snap_copy () return 0 else return 1 - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" + [ "$quiet" != "y" ] && \ + log_warning_msg "Unable to find the snapshot ${snap_type} medium" fi } @@ -356,10 +366,6 @@ setup_unionfs() { case ${UNIONFS} in aufs|unionfs) modprobe "${MP_QUIET}" -b ${UNIONFS} || true - if ! cut -f2 /proc/filesystems | grep -q "^${UNIONFS}\$" && \ - [ -x /bin/unionfs-fuse ]; then - UNIONFS="unionfs-fuse" - fi ;; esac @@ -377,8 +383,6 @@ setup_unionfs() { roopt="nfsro" # work around a bug in nfs-unionfs locking elif [ "${UNIONFS}" = "aufs" ]; then roopt="rr" - elif [ "${UNIONFS}" = "unionfs-fuse" ]; then - roopt="RO" else roopt="ro" fi @@ -417,22 +421,15 @@ setup_unionfs() { cow_fstype=$(get_fstype "${cowprobe}") cow_mountopt="rw,noatime" else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" + [ "$quiet" != "y" ] && \ + log_warning_msg "Unable to find the persistent medium" fi fi - mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || panic "Can not mount $cowdevice on /cow" - - case ${UNIONFS} in - unionfs-fuse) - (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:$rofsstring "$rootmnt" || panic "${UNIONFS} mount failed") - mkdir -p /dev/.initramfs/varrun - pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true - ;; - *) - mount -t ${UNIONFS} -o noatime,dirs=/cow=rw:$rofsstring ${UNIONFS} "$rootmnt" || panic "${UNIONFS} mount failed" - ;; - esac + mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} \ + /cow || panic "Can not mount $cowdevice on /cow" + mount -t ${UNIONFS} -o noatime,dirs=/cow=rw:$rofsstring \ + ${UNIONFS} "$rootmnt" || panic "${UNIONFS} mount failed" # Adding other custom mounts if [ -n "${PERSISTENT}" ]; then @@ -440,10 +437,13 @@ setup_unionfs() { # FIXME: add a custom mounts configurable system homecow=$(find_cow_device "${home_persistence}" ) if [ -b "${homecow}" ]; then - mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home" - export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() + mount -t $(get_fstype "${homecow}") -o rw,noatime \ + "${homecow}" "${rootmnt}/home" + # Used to proper calculate free space in do_snap_copy() + export HOMEMOUNTED=1 else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" + [ "$quiet" != "y" ] && \ + log_warning_msg "Unable to find the persistent home medium" fi # Look for other snapshots to copy in try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" @@ -454,14 +454,12 @@ setup_unionfs() { for d in ${rofslist}; do mkdir -p "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}" case d in - *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}" + *.dir) + # do nothing ;; *) - if [ "${UNIONFS}" = unionfs-fuse ]; then - mount -o bind "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}" - else - mount -o move "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}" - fi + mount -o move "${d}" \ + "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}" ;; esac done @@ -473,11 +471,7 @@ setup_unionfs() { # XXX: hardcode the image name for now (xtraeme). # move the first mount. mkdir -p "${rootmnt}/rofs" - if [ "${UNIONFS}" = unionfs-fuse ]; then - mount -o bind /filesystem.squashfs "${rootmnt}/rofs" - else - mount -o move /filesystem.squashfs "${rootmnt}/rofs" - fi + mount -o move /filesystem.squashfs "${rootmnt}/rofs" } check_dev () @@ -537,7 +531,8 @@ find_livefs() { fi fi # or do the scan of block devices - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|fd)"); do + for sysblock in \ + $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|fd)"); do devname=$(sys2dev "${sysblock}") fstype=$(get_fstype "${devname}") if /lib/udev/cdrom_id ${devname} > /dev/null; then @@ -565,34 +560,15 @@ find_livefs() { return 1 } -set_usplash_timeout() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "TIMEOUT 120" - fi -} - mountroot() { - exec 6>&1 - exec 7>&2 - exec > casper.log - exec 2>&1 - tail -f casper.log >&7 & - tailpid="$!" - parse_cmdline - wait_for_udev 10 - set_usplash_timeout + maybe_break casper-premount [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount" run_scripts /scripts/casper-premount [ "$quiet" != "y" ] && log_end_msg - # Needed here too because some things (*cough* udev *cough*) - # changes the timeout - - set_usplash_timeout - if [ ! -z "${NETBOOT}" ]; then if do_netmount ; then livefs_root="${mountpoint}" @@ -622,36 +598,16 @@ mountroot() { live_dest="${TODISK}" fi if [ "${live_dest}" ]; then - log_begin_msg "Copying live_media to ${live_dest}" + [ "$quiet" != "y" ] && \ + log_begin_msg "Copying live_media to ${live_dest}" copy_live_to "${livefs_root}" "${live_dest}" - log_end_msg + [ "$quiet" != "y" ] && log_end_msg fi mount_images_in_directory "${livefs_root}" "${rootmnt}" - log_end_msg - - # unionfs-fuse needs /dev to be bind-mounted for the duration of - # casper-bottom; udev's init script will take care of things after that - if [ "${UNIONFS}" = unionfs-fuse ]; then - mount -n -o bind /dev "${rootmnt}/dev" - fi - maybe_break casper-bottom [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom" - run_scripts /scripts/casper-bottom [ "$quiet" != "y" ] && log_end_msg - - if [ "${UNIONFS}" = unionfs-fuse ]; then - umount "${rootmnt}/dev" - fi - - exec 1>&6 6>&- - exec 2>&7 7>&- - kill "$tailpid" - cp casper.log "${rootmnt}/var/log/" - if [ -f /etc/casper.conf ]; then - cp /etc/casper.conf "${rootmnt}/etc/" - fi } diff --git a/templates/xbps-casper/files/scripts/casper-bottom/05mountpoints b/templates/xbps-casper/files/scripts/casper-bottom/05mountpoints index 7c61de33ff6..ca5ee5eb678 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/05mountpoints +++ b/templates/xbps-casper/files/scripts/casper-bottom/05mountpoints @@ -1,7 +1,7 @@ #!/bin/sh PREREQ="" -DESCRIPTION="Moving mount points..." +DESCRIPTION="Setting up /cdrom mountpoint" . /scripts/casper-functions diff --git a/templates/xbps-casper/files/scripts/casper-bottom/10adduser b/templates/xbps-casper/files/scripts/casper-bottom/10adduser index 1bd8658e636..264167b16a6 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/10adduser +++ b/templates/xbps-casper/files/scripts/casper-bottom/10adduser @@ -1,7 +1,7 @@ #!/bin/sh PREREQ="" -DESCRIPTION="Adding live session user..." +DESCRIPTION="Setting up live session user '$USERNAME'" . /scripts/casper-functions @@ -21,10 +21,10 @@ esac log_begin_msg "$DESCRIPTION" # U6aMy0wojraho is just a blank password -chroot /root useradd -c "$USERFULLNAME" -m $USERNAME -p U6aMy0wojraho - -if [ -f /root/etc/sudoers ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers +chroot ${rootmnt} useradd -c "$USERFULLNAME" -m $USERNAME \ + -G audio -p U6aMy0wojraho +if [ -f ${rootmnt}/etc/sudoers ]; then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${rootmnt}/etc/sudoers fi log_end_msg diff --git a/templates/xbps-casper/files/scripts/casper-bottom/11keymap b/templates/xbps-casper/files/scripts/casper-bottom/11keymap new file mode 100755 index 00000000000..2cb0eb55f0d --- /dev/null +++ b/templates/xbps-casper/files/scripts/casper-bottom/11keymap @@ -0,0 +1,43 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Setting up system keymap" + +. /scripts/casper-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# commandline +for x in $(cat /proc/cmdline); do + case $x in + keymap=*) + keymap=${x#keymap=} + set_keymap="true" + ;; + esac +done + +if [ "${set_keymap}" ]; then + sed -i -e "s|qwerty/us|qwerty/${keymap}|" \ + "${rootmnt}/etc/conf.d/keymaps" +fi + +if [ -f "${rootmnt}/etc/hal/fdi/policy/10-keymap.fdi" ]; then + sed -i -e "s|>us<|>${keymap}<|" \ + ${rootmnt}/etc/hal/fdi/policy/10-keymap.fdi +fi + +log_end_msg diff --git a/templates/xbps-casper/files/scripts/casper-bottom/12fstab b/templates/xbps-casper/files/scripts/casper-bottom/12fstab index 10414d7dcdc..6fdf5032ed4 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/12fstab +++ b/templates/xbps-casper/files/scripts/casper-bottom/12fstab @@ -1,8 +1,8 @@ #!/bin/sh PREREQ="" -DESCRIPTION="Configuring fstab..." -FSTAB=/root/etc/fstab +DESCRIPTION="Setting up /etc/fstab" +FSTAB=${rootmnt}/etc/fstab . /scripts/casper-functions diff --git a/templates/xbps-casper/files/scripts/casper-bottom/13swap b/templates/xbps-casper/files/scripts/casper-bottom/13swap index 8a8d0c72b62..8f75989bf4f 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/13swap +++ b/templates/xbps-casper/files/scripts/casper-bottom/13swap @@ -1,8 +1,8 @@ #!/bin/sh PREREQ="" -DESCRIPTION="Setting up swap..." -FSTAB=/root/etc/fstab +DESCRIPTION="Setting up swap" +FSTAB=${rootmnt}/etc/fstab . /scripts/casper-functions @@ -27,14 +27,15 @@ for device in /dev/[hs]d[a-z][0-9]*; do continue fi - /sbin/blkid -o udev -p ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue + /sbin/blkid -o udev -p ${device%%[0-9]*} | \ + grep -q "^ID_FS_USAGE=raid" && continue magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then # log "Found $device" devices="$devices $device" - fi + fi done for device in $devices; do diff --git a/templates/xbps-casper/files/scripts/casper-bottom/14locales b/templates/xbps-casper/files/scripts/casper-bottom/14locales index 77fbb9d2c07..da1a7dd5417 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/14locales +++ b/templates/xbps-casper/files/scripts/casper-bottom/14locales @@ -1,7 +1,7 @@ #! /bin/sh PREREQ="" -DESCRIPTION="Setting up locales..." +DESCRIPTION="Setting up system locale" . /scripts/casper-functions @@ -31,7 +31,7 @@ for x in $(cat /proc/cmdline); do done if [ "${set_locale}" ]; then - echo "LOCALE=$locale" > /root/etc/conf.d/locale + echo "system_locale=\"$locale\"" > ${rootmnt}/etc/conf.d/locale fi log_end_msg diff --git a/templates/xbps-casper/files/scripts/casper-bottom/15autologin b/templates/xbps-casper/files/scripts/casper-bottom/15autologin index bc2d94ec11d..ac094bccbe9 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/15autologin +++ b/templates/xbps-casper/files/scripts/casper-bottom/15autologin @@ -1,7 +1,7 @@ #!/bin/sh PREREQ="" -DESCRIPTION="Setting up automatic login..." +DESCRIPTION="Setting up automatic login" . /scripts/casper-functions @@ -19,5 +19,7 @@ prereqs) esac log_begin_msg "$DESCRIPTION" - +if [ -f "${rootmnt}/etc/inittab" ]; then + sed -i -e "s|agetty|casper-getty|g" "${rootmnt}/etc/inittab" +fi log_end_msg diff --git a/templates/xbps-casper/files/scripts/casper-bottom/18hostname b/templates/xbps-casper/files/scripts/casper-bottom/18hostname index e97513569f2..311a4b068b2 100755 --- a/templates/xbps-casper/files/scripts/casper-bottom/18hostname +++ b/templates/xbps-casper/files/scripts/casper-bottom/18hostname @@ -1,7 +1,7 @@ #! /bin/sh PREREQ="" -DESCRIPTION="Setting hostname..." +DESCRIPTION="Setting up hostname" . /scripts/casper-functions @@ -20,7 +20,7 @@ esac log_begin_msg "$DESCRIPTION" -echo "hostname=$HOST" > /root/etc/conf.d/hostname +echo "hostname=$HOST" > "${rootmnt}/etc/conf.d/hostname" cat > /root/etc/hosts <> ${conf_file} <<_EOF + + + + + + + + + + + + + +_EOF + +log_end_msg diff --git a/templates/xbps-casper/template b/templates/xbps-casper/template index cf7834f29df..ac17d9fb422 100644 --- a/templates/xbps-casper/template +++ b/templates/xbps-casper/template @@ -1,6 +1,6 @@ # Template file for 'xbps-casper' pkgname=xbps-casper -version=0.2 +version=0.3 build_style=custom-install short_desc="Run a live preinstalled system from read-only media" maintainer="Juan RP "