diff options
author | Colin Guthrie <colin@mageia.org> | 2013-10-19 19:36:27 +0100 |
---|---|---|
committer | Jybz <j.biernacki@free.fr> | 2024-04-20 18:13:16 +0200 |
commit | 4fdad650c2fd165735aaa55b9859c64c010c56ea (patch) | |
tree | ff29288bf8d33d40e1aee030de274a9b0d248d2f | |
download | mageia-dracut-conf-4fdad650c2fd165735aaa55b9859c64c010c56ea.tar mageia-dracut-conf-4fdad650c2fd165735aaa55b9859c64c010c56ea.tar.gz mageia-dracut-conf-4fdad650c2fd165735aaa55b9859c64c010c56ea.tar.bz2 mageia-dracut-conf-4fdad650c2fd165735aaa55b9859c64c010c56ea.tar.xz mageia-dracut-conf-4fdad650c2fd165735aaa55b9859c64c010c56ea.zip |
mgainstaller: Add a module used to generate the Mageia Installer
v2: Add modules.description
v3: Add modules to go into modules.alias but then get rm'ed before
actual build. This is needed for stage2 device probe
overlayfs is renamed to overlay from 3.19
Signed-off-by: Thomas Backlund <tmb@mageia.org>
-rw-r--r-- | modules.d/90mgainstaller/mgainstaller-mount-stage2.sh | 57 | ||||
-rwxr-xr-x | modules.d/90mgainstaller/module-setup.sh | 73 | ||||
-rwxr-xr-x | modules.d/90mgainstaller/parse-mgainstaller.sh | 6 |
3 files changed, 136 insertions, 0 deletions
diff --git a/modules.d/90mgainstaller/mgainstaller-mount-stage2.sh b/modules.d/90mgainstaller/mgainstaller-mount-stage2.sh new file mode 100644 index 0000000..aa7200a --- /dev/null +++ b/modules.d/90mgainstaller/mgainstaller-mount-stage2.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +if [[ "$root" = "mgainstaller" ]]; then + mkdir -p /run/drakx + + # Turn off kernel messages while we run stage1 (it messes up curses control) + stage1printk= + if [[ -f /proc/sys/kernel/printk ]]; then + stage1printk=$(cat /proc/sys/kernel/printk) + echo '0 0 0 0' >/proc/sys/kernel/printk + fi + + # Run stage1 This ensures that stage2 is available and mounted on /tmp/stage2 + # Note: We could run this later but it makes sense to do it at the "correct" + # time in the dracut init stage. + stage1rv="53" # 0x35 + while [[ "$stage1rv" = "53" ]]; do + stage1 + stage1rv=$? + if [[ "$stage1rv" = "66" ]]; then + # exit code 66 is "proceed" aka, run /sbin/init after doing some + # symlinking/bind mounts + >/run/drakx/run-init + fi + done + + # Restore kernel messages + if [[ -n "$stage1printk" ]]; then + echo "$stage1printk" >/proc/sys/kernel/printk + fi + + # Create a fake sysroot to please dracut and allow it to continue + # Our stage2 reuses the root environment provided by the initrd. + # We do not actually switch to a new root. Hence we hack over the switch_root + # command to allow dracut to continue as normal (shutting down udev etc.) + # before we take over again later. As there are no hook points at later + # stages, this is the cleanest way without modifying dracut itself + + # /sysroot has to be a mountpoint + mount -t tmpfs -o mode=755,nodev,nosuid none /sysroot + + # Fool usable_root() + mkdir -p /sysroot/dev + mkdir -p /sysroot/proc + mkdir -p /sysroot/sys + + # Create a fake init (it will never be run) + mkdir -p /sysroot/sbin + >/sysroot/sbin/init + chmod a+x /sysroot/sbin/init + + # Inject our fake switch_root to run stage2 + mv /usr/sbin/switch_root /usr/sbin/switch_root.real + ln -sf stage2-fake-switch_root /usr/sbin/switch_root +fi diff --git a/modules.d/90mgainstaller/module-setup.sh b/modules.d/90mgainstaller/module-setup.sh new file mode 100755 index 0000000..987adde --- /dev/null +++ b/modules.d/90mgainstaller/module-setup.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +check() { + # an installer host-only image doesn't really make a lot of sense + [[ $hostonly ]] && return 1 + return 255 +} + +depends() { + return 0 +} + +installkernel() { + instmods squashfs loop overlay + + # This bit is a bit hacky. We need to install kernel modules we don't actually + # want. We will keep them until depmod is run, then rm them again. + if [[ "$DRAKX_FAKE_MODULES" && -f "$srcmods/modules.dep" ]]; then + fakemoddir="${initdir}/lib/modules/${kernel}/kernel/mageia-fake-modules" + mkdir -p "${fakemoddir}" + regexp="/("$(echo $DRAKX_FAKE_MODULES | sed 's/^[[:space:]]*\(.*[^ ]\)[[:space:]]*$/\1/' | sed 's/ /|/g')")\.ko" + modfiles=$(cut -d':' -f1 $srcmods/modules.dep | grep -E "$regexp" | xargs) + ( cd $srcmods/; cp -f $modfiles "${fakemoddir}/" ) + fi + return 0 +} + +install() { + local _arch _libdir + _arch=$(uname -m) + _libdir=lib + if [ "x86_64" = "$_arch" ]; then + _libdir=lib64 + fi + + inst_simple "$srcmods/modules.description" "/lib/modules/$kernel/modules.description" + inst /usr/share/terminfo/l/linux /usr/share/terminfo/l/linux + inst /usr/share/ldetect-lst/pcitable.gz /usr/share/ldetect-lst/pcitable.gz + inst /usr/share/ldetect-lst/usbtable.gz /usr/share/ldetect-lst/usbtable.gz + inst /usr/share/pci.ids /usr/share/pci.ids + inst /usr/share/ldetect-lst/dkms-modules.alias /usr/share/ldetect-lst/dkms-modules.alias + inst /usr/share/ldetect-lst/fallback-modules.alias /usr/share/ldetect-lst/fallback-modules.alias + inst_libdir_file "libnss_dns.so*" + # below has /usr added... + inst /usr/lib/module-init-tools/ldetect-lst-modules.alias /usr/lib/module-init-tools/ldetect-lst-modules.alias + + # To allow for debug build of stage1 + if [ -n "$DRAKX_STAGE1_BINARY" -a -x "$DRAKX_STAGE1_BINARY" ]; then + inst "$DRAKX_STAGE1_BINARY" /usr/sbin/stage1 + else + inst /usr/${_libdir}/drakx-installer-binaries/stage1 /usr/sbin/stage1 + fi + + if [ -n "$DRAKX_INIT_BINARY" -a -x "$DRAKX_INIT_BINARY" ]; then + inst "$DRAKX_INIT_BINARY" /usr/sbin/stage2-fake-switch_root + else + inst /usr/${_libdir}/drakx-installer-binaries/init /usr/sbin/stage2-fake-switch_root + fi + + inst /usr/sbin/pppd-diet /usr/sbin/pppd + inst /usr/sbin/pppoe-diet /usr/sbin/pppoe + + if [ "$_arch" != "ppc" -a "$_arch" != "ia64" ]; then + inst /etc/pcmcia/config.opts /etc/pcmcia/config.opts + fi + + inst_hook cmdline 29 "$moddir/parse-mgainstaller.sh" + inst_hook mount 99 "$moddir/mgainstaller-mount-stage2.sh" + + inst_multiple chmod mkdir ln +} diff --git a/modules.d/90mgainstaller/parse-mgainstaller.sh b/modules.d/90mgainstaller/parse-mgainstaller.sh new file mode 100755 index 0000000..e074df9 --- /dev/null +++ b/modules.d/90mgainstaller/parse-mgainstaller.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +root="mgainstaller" # quiet complaints from init +rootok=1 |