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
This commit is contained in:
Juan RP 2009-10-12 18:46:43 +02:00
parent a8b0553147
commit cd83917a95
12 changed files with 155 additions and 112 deletions

View file

@ -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

View file

@ -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
}

View file

@ -1,7 +1,7 @@
#!/bin/sh
PREREQ=""
DESCRIPTION="Moving mount points..."
DESCRIPTION="Setting up /cdrom mountpoint"
. /scripts/casper-functions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <<EOF
127.0.0.1 localhost
127.0.1.1 $HOST

View file

@ -0,0 +1,46 @@
#!/bin/sh
PREREQ=""
DESCRIPTION="Setting up PolicyKit actions for user '${USERNAME}'"
. /scripts/casper-functions
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
conf_file=${rootmnt}/etc/PolicyKit/PolicyKit.conf
if [ ! -f ${conf_file} ]; then
exit 0
fi
log_begin_msg "$DESCRIPTION"
rm -f ${conf_file}
cat >> ${conf_file} <<_EOF
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">
<!-- See the manual page PolicyKit.conf(5) for file format -->
<config version="0.1">
<match action="org.freedesktop.hal.*">
<match user="${USERNAME}">
<return result="yes"/>
</match>
</match>
</config>
_EOF
log_end_msg

View file

@ -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 <xtraeme@gmail.com>"