diff options
author | James Meyer <james.meyer@operamail.com> | 2008-11-23 03:47:32 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2008-11-23 03:47:32 (GMT) |
commit | a73aa26202d19da424722bcf1285b566dbfd9d8d (patch) | |
tree | cc24843c13127ef3b5d8207aa7c82be0b1f00d37 /abs/mv-core/mythvantage-live/lib/initcpio/hooks | |
parent | a1219610c24fc89e2e4c1b81194fe25e40933cf5 (diff) | |
download | linhes_pkgbuild-a73aa26202d19da424722bcf1285b566dbfd9d8d.zip linhes_pkgbuild-a73aa26202d19da424722bcf1285b566dbfd9d8d.tar.gz linhes_pkgbuild-a73aa26202d19da424722bcf1285b566dbfd9d8d.tar.bz2 |
add mythvantage specific packages.
Diffstat (limited to 'abs/mv-core/mythvantage-live/lib/initcpio/hooks')
4 files changed, 383 insertions, 0 deletions
diff --git a/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch1 b/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch1 new file mode 100644 index 0000000..88ccc3e --- /dev/null +++ b/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch1 @@ -0,0 +1,125 @@ +# 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 + msg_ ":: Searching for usb cdroms .." + for d in /dev/sr[0-9]*; do + test_live_data_dir "${d}" "${cdmount}" + if [ $? -eq 0 ]; then break 2; fi + done + done + fi +} diff --git a/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch2 b/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch2 new file mode 100644 index 0000000..74b4e64 --- /dev/null +++ b/abs/mv-core/mythvantage-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/mv-core/mythvantage-live/lib/initcpio/hooks/larch2_aufs b/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch2_aufs new file mode 100644 index 0000000..ac8e40b --- /dev/null +++ b/abs/mv-core/mythvantage-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/mv-core/mythvantage-live/lib/initcpio/hooks/larch3 b/abs/mv-core/mythvantage-live/lib/initcpio/hooks/larch3 new file mode 100644 index 0000000..47be81a --- /dev/null +++ b/abs/mv-core/mythvantage-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. +####### |