diff options
Diffstat (limited to 'abs/core-testing/linhes-live/lib')
11 files changed, 513 insertions, 0 deletions
diff --git a/abs/core-testing/linhes-live/lib/initcpio/gen_larch_init b/abs/core-testing/linhes-live/lib/initcpio/gen_larch_init new file mode 100755 index 0000000..d834e8f --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/gen_larch_init @@ -0,0 +1,12 @@ +#! /bin/bash + +# gen_larch_init +# +# Author: Michael Towers <gradgrind[at]online[dot]de> + +# Create an initramfs for a larch live system +# $1 - kernel version + +# The cpio.gz image is generated in larch.img + +/sbin/mkinitcpio -c /lib/initcpio/mkinitcpio.conf -k $1 -g larch.img diff --git a/abs/core-testing/linhes-live/lib/initcpio/hooks/larch1 b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch1 new file mode 100644 index 0000000..e1a3753 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch1 @@ -0,0 +1,120 @@ +# vim: set ft=sh: + +# larch1 - live 'hook' for mkinitcpio: set up tmpfs and find boot device + +# Author: Michael Towers (gradgrind) <mt.42@web.de> +# +# This file is part of the larch project. +# +# larch 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 2 of the License, or +# (at your option) any later version. +# +# larch 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 larch; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#---------------------------------------------------------------------------- +#2008.02.11 + +# Replacement for msg which includes leading and trailing spaces +msg_ () { [ "${quiet}" != "y" ] && echo "$@"; } + +# Try to mount a disk, partition or cdrom and look for the file +# 'larchboot' in the /larch directory. +# If LiveCD system found in the device, return 0, else return 1 +# and leave the device mounted. +# $1 = device name (e.g. "/dev/hda2") +# $2 = directory where devices will be mounted +# +test_live_data_dir () +{ + /bin/mount -r -t iso9660 "$1" $2 >/dev/null 2>/dev/null || \ + /bin/mount -r -t vfat -o noatime,nodiratime "$1" $2 >/dev/null 2>/dev/null || \ + /bin/mount -r -t ext2 -o noatime,nodiratime "$1" $2 >/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + if [ -f "$2/larch/larchboot" ]; then + LDEV="$1" + msg_ " ... found at $1" + return 0 + else + /bin/umount $2 2>/dev/null + msg_ " ... $1 mounted, but no 'larch/larchboot' found" + fi + else + msg_ " ... not $1" + fi + return 1 +} + +run_hook () +{ + msg_ ":: Creating writeable filesystem (tmpfs)" + /bin/mkdir "/tfs" + # Boot option copy-to-ram (c2r) + if [ "${c2r}" = "y" ]; then + TFSSIZE="90%" + else + TFSSIZE="60%" + fi + /bin/mount -t tmpfs -o "size=${TFSSIZE}" tmpfs "/tfs" + + # Directory for test mounts (and then for live CD) + cdmount="/livecd" + /bin/mkdir "${cdmount}" + + # look for livecd data directory, first try ${root} + LDEV="${root}" + if [ "x${LDEV}" != "x" ]; then + /bin/mount -r -t iso9660 "${LDEV}" "${cdmount}" >/dev/null 2>/dev/null || \ + /bin/mount -r -t vfat -o noatime,nodiratime "${LDEV}" "${cdmount}" >/dev/null 2>/dev/null || \ + /bin/mount -r -t ext2 -o noatime,nodiratime "${LDEV}" "${cdmount}" >/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + if [ -d "${cdmount}/larch" ]; then + msg_ ":: larch system at ${LDEV}" + else + /bin/umount "${cdmount}" 2>/dev/null + echo "!! No larch system at ${LDEV}" + LDEV="" + fi + else + echo "!! Couldn't mount ${LDEV}" + LDEV="" + fi + fi + + # then try cdroms + if [ "x${LDEV}" = "x" ]; then + msg_ ":: Looking for boot device" + cdroms=$( /bin/cat /proc/sys/dev/cdrom/info | { while read a b c; do + if [ "${a}" = "drive" -a "${b}" = "name:" ]; then + echo "${c}" + break + fi + done + } ) + for i in ${cdroms}; do + test_live_data_dir "/dev/${i}" "${cdmount}" + if [ $? -eq 0 ]; then break; fi + done + fi + + # test USB devices (and disks) repeatedly until timed out + if [ "x${LDEV}" = "x" ]; then + msg_ ":: Searching for usb (and disk) devices .." + for i in 1 2 3 4 5; do + msg_ " :wait ${i} :::" + /bin/sleep ${i} + for d in /dev/sd[a-z][0-9]*; do + test_live_data_dir "${d}" "${cdmount}" + if [ $? -eq 0 ]; then break 2; fi + done + done + fi +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2 b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2 new file mode 100644 index 0000000..74b4e64 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2 @@ -0,0 +1,33 @@ +# larch2 - live 'hook' for mkinitcpio: unionfs specific + +# Author: Michael Towers (gradgrind) <mt.42@web.de> +# +# This file is part of the larch project. +# +# larch 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 2 of the License, or +# (at your option) any later version. +# +# larch 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 larch; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#---------------------------------------------------------------------------- +#2007.12.13 + +run_hook () +{ + #!!! --- unionfs specific + # Need unionfs module + /bin/modprobe unionfs + ovlmnt="ro" + bropt="dirs=" + sqfmnt="ro" + utype="unionfs" +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2_aufs b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2_aufs new file mode 100644 index 0000000..ac8e40b --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch2_aufs @@ -0,0 +1,33 @@ +# larch2_aufs - live 'hook' for mkinitcpio: aufs specific + +# Author: Michael Towers (gradgrind) <mt.42@web.de> +# +# This file is part of the larch project. +# +# larch 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 2 of the License, or +# (at your option) any later version. +# +# larch 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 larch; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#---------------------------------------------------------------------------- +# 2008.02.29 + +run_hook () +{ + #!!! --- aufs specific + # Need aufs module + /bin/modprobe aufs + ovlmnt="rr+wh" + sqfmnt="rr" + bropt="br:" + utype="aufs" +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/hooks/larch3 b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch3 new file mode 100644 index 0000000..47be81a --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/hooks/larch3 @@ -0,0 +1,192 @@ +# larch3 - live 'hook' for mkinitcpio: +# deal with c2r, +# mount base system, +# load overlay, +# set up unioned root filesystem. +# Also manages overlay merging. + +# Author: Michael Towers <gradgrind[at]online[dot]de> +# +# This file is part of the larch project. +# +# larch 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 2 of the License, or +# (at your option) any later version. +# +# larch 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 larch; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#---------------------------------------------------------------------------- +# 2008.04.04 + +run_hook () +{ + if [ "x${LDEV}" = "x" ]; then + err "Sorry, couldn't find boot medium ..." + break="y" + return + fi + + /sbin/modprobe loop + + # Path to compressed base system + sysSqf=${cdmount}/system.sqf + + ovlpath=${cdmount} + + # A possibility to use alternative files: + if [ -f ${cdmount}/larch/boot-init ]; then + . ${cdmount}/larch/boot-init + fi + + # Path to compressed 'modifications' archive + modsSqf=${ovlpath}/mods.sqf + # Default overlay file and directory + overlay=${ovlpath}/overlay.ovl + + # Make union root + /bin/mkdir /union + + # Deal with new archives + if [ -f ${overlay}_ ]; then + /bin/mount -o remount,rw ${LDEV} ${cdmount} + /bin/mv ${overlay} ${overlay}~ + /bin/mv ${overlay}_ ${overlay} + + if [ -f ${modsSqf}_ ]; then + /bin/mv ${modsSqf} ${modsSqf}~ + /bin/mv ${modsSqf}_ ${modsSqf} + fi + /bin/mount -o remount,ro ${LDEV} ${cdmount} + fi + + # Boot option copy-to-ram (c2r) + if [ "${c2r}" = "y" ]; then + msg_ ":: Copying base system to RAM, this will take a while ..." + /bin/cat ${sysSqf} > /tfs/system.sqf + if [ $? -ne 0 ]; then + err "Sorry, not enough RAM" + break="y" + return + fi + sysSqf=/tfs/system.sqf + + msg_ ":: Copying mods archive to RAM, this might take a while ..." + /bin/cat ${modsSqf} > /tfs/mods.sqf + if [ $? -ne 0 ]; then + err "Sorry, not enough RAM" + break="y" + return + fi + modsSqf=/tfs/mods.sqf + + # force use of swap (if available) + :> /tfs/swapon + + elif [ "${swap}" = "y" ]; then + :> /tfs/swapon + fi + + msg_ ":: Mounting squashed images" + /bin/mkdir /tfs/system + # The klibc mount command doesn't support '-o loop' + /bin/losetup /dev/loop0 ${sysSqf} + /bin/mount -r -t squashfs /dev/loop0 /tfs/system + + # Make stuff in 'system' available by providing the loader and + # library path + ldli=$( cd /tfs/system; echo lib/ld-linux*.so.2 ) + /bin/ln -s /tfs/system/${ldli} /${ldli} + export LD_LIBRARY_PATH=/tfs/system/lib:/tfs/system/usr/lib + + /bin/mkdir /tfs/mods + # The klibc mount command doesn't support '-o loop' + /bin/losetup /dev/loop1 ${modsSqf} + /bin/mount -r -t squashfs /dev/loop1 /tfs/mods + + # Unpack the overlay + msg_ ":: Initializing writable layer for union (overlay)" + /tfs/system/usr/bin/lzop -d < ${overlay} | \ + /tfs/system/bin/tar -C /tfs -xf - + + # Copy the installation tidy-up script (for removing custom live-only stuff), + # and any other files in 'larch/copy' directory + if [ -d ${ovlpath}/larch/copy ]; then + cd ${ovlpath}/larch/copy + for f in *; do + cat ${f} >/tfs/${f} + done + fi + + msg_ ":: Setting up union file system" + + layers="/tfs/overlay=rw:/tfs/mods=${ovlmnt}:/tfs/system=${sqfmnt}" + /bin/mount -t ${utype} -o ${bropt}${layers} ${utype} /union + + echo "${utype}" > /tfs/utype + + # Minimal device nodes needed before udev does its work + /bin/mkdir /union/dev + /bin/mknod /union/dev/console c 5 1 + /bin/mknod /union/dev/null c 1 3 + /bin/mknod /union/dev/zero c 1 5 + + # Make special directories + /bin/mkdir -m 1777 /union/tmp + /bin/mkdir /union/media + /bin/mkdir /union/sys + /bin/mkdir /union/proc + + # Make the tmpfs stuff accessible within the union + /bin/mkdir /union/.livesys + /bin/mount -o bind /tfs /union/.livesys + + /bin/mkdir /union/.livesys/medium + + /bin/mount -o bind /tfs/system /union/.livesys/system + /bin/mount -o bind /tfs/overlay /union/.livesys/overlay + /bin/mount -o bind ${cdmount} /union/.livesys/medium + + if [ "x${modsSqf}" != "x" ]; then + /bin/mount -o move /tfs/mods /union/.livesys/mods + fi + + # Remember the boot device + echo "${LDEV}" > /tfs/bootdevice + + if [ "${c2r}" = "y" ]; then + # Set flag to inform system of copy-to-ram + :> /tfs/c2r + + # Unmount boot device + /bin/umount ${cdmount} + fi + + msg_ ":: End of live system set-up" + + # Now some tweaks to alter 'init' actions from non-larch hooks, etc. + # Override rootdelay from usb hook + if [ "x${larchdelay}" = "x" ]; then + # To avoid spurious udevd pid numbers + export rootdelay=1 + else + # Allow adjustment via boot option + export rootdelay=${larchdelay} + fi + # root must be set to something or other, even though larch doesn't + # need it ... + export root="/dev/loop0" +} + +####### +# The actual root switch occurs later, when 'init' execs 'kinit'. +# I handle this by overwriting the 'kinit' binary with my own script. +# This will unmount dev, sys and proc and then exec run-init. +####### diff --git a/abs/core-testing/linhes-live/lib/initcpio/install/larch1 b/abs/core-testing/linhes-live/lib/initcpio/install/larch1 new file mode 100644 index 0000000..56baf48 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/install/larch1 @@ -0,0 +1,15 @@ +install () +{ + MODULES="vfat isofs ext2 ext3 nls_cp437" + BINARIES="" + FILES="" + SCRIPT="larch1" +} + +help () +{ +cat<<HELPEOF + This hook deals with booting a larch live CD. It is the first larch hook, +creating a tmpfs and seeking the boot medium. +HELPEOF +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/install/larch2 b/abs/core-testing/linhes-live/lib/initcpio/install/larch2 new file mode 100644 index 0000000..a906227 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/install/larch2 @@ -0,0 +1,15 @@ +install () +{ + MODULES="unionfs" + BINARIES="" + FILES="" + SCRIPT="larch2" +} + +help () +{ +cat<<HELPEOF + This hook deals with booting a larch live CD. It handles selection of the +desired unioning file system, here unionfs. +HELPEOF +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/install/larch2_aufs b/abs/core-testing/linhes-live/lib/initcpio/install/larch2_aufs new file mode 100644 index 0000000..0e19de9 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/install/larch2_aufs @@ -0,0 +1,15 @@ +install () +{ + MODULES="aufs" + BINARIES="" + FILES="" + SCRIPT="larch2_aufs" +} + +help () +{ +cat<<HELPEOF + This hook deals with booting a larch live CD. It handles selection of the +desired unioning file system, here aufs. +HELPEOF +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/install/larch3 b/abs/core-testing/linhes-live/lib/initcpio/install/larch3 new file mode 100644 index 0000000..7dad03c --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/install/larch3 @@ -0,0 +1,18 @@ +install () +{ + MODULES="squashfs loop reiserfs" + BINARIES="" + FILES="" + SCRIPT="larch3" +# add_file "/lib/initcpio/kinit" "/bin/kinit" ##### This doesn't work, so: + sed -i 's|.*/usr/lib/klibc/bin/kinit\.shared.*||' "${FILELIST}" + sed -i 's|/usr/lib/klibc/bin/kinit|/lib/initcpio/kinit|' "${FILELIST}" +} + +help () +{ +cat<<HELPEOF + This hook deals with booting a larch live CD. It is the last larch hook, +setting up the tmpfs root file system. +HELPEOF +} diff --git a/abs/core-testing/linhes-live/lib/initcpio/kinit b/abs/core-testing/linhes-live/lib/initcpio/kinit new file mode 100755 index 0000000..7c86f4b --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/kinit @@ -0,0 +1,6 @@ +#! /bin/sh + +umount /sys +umount /proc +umount /dev +exec run-init -c /dev/console /union /sbin/init ${CMDLINE} diff --git a/abs/core-testing/linhes-live/lib/initcpio/mkinitcpio.conf b/abs/core-testing/linhes-live/lib/initcpio/mkinitcpio.conf new file mode 100644 index 0000000..79cca21 --- /dev/null +++ b/abs/core-testing/linhes-live/lib/initcpio/mkinitcpio.conf @@ -0,0 +1,54 @@ +# vim:set ft=sh +# MODULES +# The following modules are loaded before any boot hooks are +# run. Advanced users may wish to specify all system modules +# in this array. For instance: +# MODULES="piix ide_disk reiserfs" +MODULES="" + +# BINARIES +# This setting includes, into the CPIO image, and additional +# binaries a given user may wish. This is run first, so may +# be used to override the actual binaries used in a given hook. +# (Existing files are NOT overwritten is already added) +# BINARIES are dependancy parsed, so you may safely ignore libraries +#BINARIES="" + +# FILES +# This setting is similar to BINARIES above, however, files are added +# as-is and are not parsed in anyway. This is useful for config files. +# Some users may wish to include modprobe.conf for custom module options, +# like so: +# FILES="/etc/modprobe.conf" +FILES="" + +# HOOKS +# This is the most important setting in this file. The HOOKS control the +# modules and scripts added to the image, and what happens at boot time. +# Order is important, and it is recommended that you do not change the +# order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for +# help on a given hook. +# 'base' is _required_ unless you know precisely what you are doing. +# 'udev' is _required_ in order to automatically load modules +# 'modload' may be used in place of 'udev', but is not recommended +# 'filesystems' is _required_ unless you specify your fs modules in MODULES +# Examples: +# This setup specifies all modules in the MODULES setting above. +# No raid, lvm, or encrypted root is needed. +# HOOKS="base" +# +# This setup will autodetect all modules for your system and should +# work as a sane default +# HOOKS="base udev autodetect ide scsi sata filesystems" +# +# This setup will generate a 'full' image which supports most systems. +# No autodetection is done. +# HOOKS="base udev ide scsi sata usb filesystems" +# +# This setup assembles an ide raid array with an encrypted root FS. +# Note: See 'mkinitcpio -H raid' for more information on raid devices. +# HOOKS="base udev ide filesystems raid encrypt" +# +# This setup loads an LVM volume group on a usb device. +# HOOKS="base udev usb filesystems lvm" +HOOKS="base udev pata scsi sata usb larch1 larch2___aufs___ larch3" |