summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2019-08-18 21:59:07 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2019-08-18 21:59:07 +0200
commit14190fa8b5f6c29f1b21878541a8001bbda775ce (patch)
tree7f72d01af031fba1e640730f9249410215f9dfcf
parenta38a399f3b3958897326c9ccd590f825f504ea10 (diff)
downloadeficast-14190fa8b5f6c29f1b21878541a8001bbda775ce.tar.gz
eficast-14190fa8b5f6c29f1b21878541a8001bbda775ce.tar.bz2
eficast-14190fa8b5f6c29f1b21878541a8001bbda775ce.zip
More polishing
-rwxr-xr-xmake-boot-image.sh81
1 files changed, 41 insertions, 40 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index b3ec8df..1d07478 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -20,15 +20,14 @@ WGET="wget" # "wget --no-check-certificate" could help but is a security concer
NFS_MOUNT_CMDLINE="mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs"
# You probably need to tweak version numbers in following URLs if you have an HTTP 404 - Not found error
-#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.9.tar.xz # no modules, kernel 5.x seems to not support /sbin/hotplug
-KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.xz # ok in qemu
+#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.9.tar.xz # ok in qemu, seems sane on real hardware
+KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.xz # ok in qemu, seems sane on real hardware
#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.140.tar.xz # ok in qemu
#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.12.74.tar.xz # reset loop in qemu
-
# old kernels 2.6, 3.x before year 2017 don't cope with recent distro/gcc defaults options (-fPIE)
# https://unix.stackexchange.com/questions/436071/compile-old-kernel-with-new-gcc
# https://lore.kernel.org/patchwork/patch/731680/
-#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.11.9.tar.xz # Kconfiglib v12.13.0 can't cope with it, and gcc probably to recent
+#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.11.9.tar.xz # Kconfiglib v12.13.0 can't cope with it, and gcc probably too recent
#KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.xz
# KConfigLib allows to create kernel .config in a programmatic manner, in a somewhat portable way
@@ -43,7 +42,7 @@ USB_IDS_URL=https://usb-ids.gowdy.us/usb.ids
# Free space checking to not let everything go wrong
ROOT_MIN_AVAIL_MIO=256
-WORKDIR_MIN_AVAIL_MIO=2048
+WORKDIR_MIN_AVAIL_MIO=2560
DLDIR_MIN_AVAIL_MIO=512
OUTDIR_MIN_AVAIL_MIO=64
@@ -119,9 +118,9 @@ fi
umask 0022 # Needed for embeding initrd without "sudo make" in kernel dir
-[ -d "$WORKDIR" ] || mkdir -p "$WORKDIR" && check_free_space $WORKDIR_MIN_AVAIL_MIO "$WORKDIR"
-[ -d "$DLDIR" ] || mkdir -p "$DLDIR" && check_free_space $DLDIR_MIN_AVAIL_MIO "$DLDIR"
-[ -d "$OUTDIR" ] || mkdir -p "$OUTDIR" && check_free_space $OUTDIR_MIN_AVAIL_MIO "$OUTDIR"
+[ -d "$WORKDIR" ] || ( mkdir -p "$WORKDIR" && check_free_space $WORKDIR_MIN_AVAIL_MIO "$WORKDIR" )
+[ -d "$DLDIR" ] || ( mkdir -p "$DLDIR" && check_free_space $DLDIR_MIN_AVAIL_MIO "$DLDIR" )
+[ -d "$OUTDIR" ] || ( mkdir -p "$OUTDIR" && check_free_space $OUTDIR_MIN_AVAIL_MIO "$OUTDIR" )
# When using sudo with password auth, ask and cache pass first
@@ -236,6 +235,13 @@ while more_work and i < passes:
if sym.name == 'INITRAMFS_SOURCE':
more_work = sset(sym, '../initrd/') or more_work
+ # Support dumb hotplug via /sbin/hotplug script (disabled by default on 5.x kernels, may be some 4.x also)
+ # We don't ship mdev/udev/systemd or any netlink listener to load appropriate modules for now
+ if sym.name == 'UEVENT_HELPER':
+ more_work = sset(sym) or more_work
+ if sym.name == 'UEVENT_HELPER_PATH':
+ more_work = sset(sym, '/sbin/hotplug') or more_work
+
# Make kernel directly loadable by EFI, add USB3, Dell flash
if sym.name in ['EFI_STUB', 'EARLY_PRINTK_EFI']:
more_work = sset(sym) or more_work
@@ -286,8 +292,8 @@ while more_work and i < passes:
if sym.name == 'INITRAMFS_COMPRESSION':
sset(sym, '.xz')
- # Enable .config to be readable from /proc/config.gz (convinent for all-in-one image)
- if sym.name in ['IKCONFIG','IKCONFIG_PROC']:
+ # Enable beeps (pcspkr) and .config to be readable from /proc/config.gz
+ if sym.name in ['IKCONFIG','IKCONFIG_PROC', 'INPUT_PCSPKR']:
sset(sym)
# Try to get rid of some useless features in EFIcast context
@@ -442,17 +448,17 @@ echo $VERSION > "$WORKDIR/initrd/etc/eficast_version"
cat > "$WORKDIR/initrd/etc/rc.d/funcs" <<"EOF"
# echo_color <foreground_color> <background_color> [prefix_string] <message>
echo_color() {
- setterm --foreground "$1" --background "$2"
+ setterm --foreground "$1" --background "$2" --bold on
echo -n "$3"
- setterm --foreground white --background black
+ setterm --foreground white --background black --bold off
[ "x$4" == "xversion" ] && echo " (eficast v"$(cat /etc/eficast_version)")" || echo
}
# no args, print colored message, wait 10 sec and reboot
eficast_end() {
echo -e "\e]2;eficast_end\007" # Term title (tmux), intentionnal carriage return
- echo_color white green "----- EFICAST end of execution ------"
( sfx_success ; touch /run/nosound ) &
+ message success
[ -r /run/eficast_end ] && action=$(cat /run/eficast_end)
case $action in
poweroff) read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time for poweroff...'
@@ -470,9 +476,10 @@ eficast_end() {
# note : rcS rescue_shell is slighly different because most of the env is not ready in rcS
rescue_shell() {
echo -e "\e]2;rescue_shell\007" # Term title (tmux), intentionnal carriage return
+ message rescue
echo_color white red "Something went wrong. Dropping to a shell." version
( sfx_failure ; touch /run/nosound ) &
- PS1='\h:\w# ' HOME='/root/' /bin/busybox sh
+ PS1='\h:\w# ' HOME='/root/' busybox sh
}
machine_info() {
@@ -581,18 +588,17 @@ export TERM=linux # busybox on qemu set vt102, then tmux segfaults
EOF
add_initrd_script etc/rc.d/rcS <<"EOF"
-echo -e '\e[37;42m'----- EFICAST start of execution ------'\e[0m'
echo -e '\e[32m/etc/rc.d/rcS script will run on /dev/console now\e[0m'
-echo -e '\e[37;43m'----- rcS script started -----'\e[0m' # Hint for user about boot steps if its hangs
+echo -e '\e[37;43m\e[1m'----- rcS script started -----'\e[0m' # Hint for user about boot steps if its hangs
# Declare some funcs to have a tidy output with trace mode
# note : rc.d/funcs has a rescue_shell() that is slighly different (the environment is not fully intialized here)
rescue_shell() {
- busybox echo -e '\e[37;41m'Something went wrong. Dropping to a shell.'\e[0m'
- busybox beep
+ /bin/busybox echo -e '\e[37;41m\e[1m'Something went wrong. Dropping to a shell.'\e[0m'
+ /bin/busybox beep
PS1='\h:\w# ' busybox setsid busybox cttyhack busybox sh
- busybox sync; busybox umount /dev/pts /dev /sys /proc
- busybox reboot -f
+ /bin/busybox sync; busybox umount /dev/pts /dev /sys /proc
+ /bin/busybox reboot -f
}
mount_pseudofilesystems() {
@@ -606,9 +612,7 @@ mount_pseudofilesystems() {
return 0
}
-# FIXME : mod loading does not work on kernel 5.x /sbin/hotplug is not called. /proc entry has vanished.
-# First try with busybox mdev -d was a failure.
-# See https://github.com/slashbeast/mdev-like-a-boss/blob/master/mdev.init ?
+# TODO Kernel 5.x disable UEVENT_HELPER by default, it may need some clean alternative
coldplugging() {
echo 4 > /proc/sys/kernel/printk
for d in /sys/bus/*/devices/*
@@ -627,11 +631,10 @@ klogd; syslogd # Start logging in /var/log/messages
mount -o remount -o size=80% / # Allow using most of RAM for rootfs
coldplugging # Load modules for cold-plugged peripherials
loadkmap < /etc/keys.bmap # Load keyboard layout
-sleep 5 # Wait for physical link detection + STP + IPv6 DAD & Autoconf
set +v
# Hint users about boot steps to help them if it hangs
echo -e '\e[32m/etc/rc.d/rc2-or-rescue script will run on /dev/tty1 now\e[0m'
-echo -e '\e[37;43m----- rcS script ended -----\e[0m'
+echo -e '\e[37;43m\e[1m----- rcS script ended -----\e[0m'
EOF
add_initrd_script etc/rc.d/rc2-or-rescue <<"EOF"
. /etc/rc.d/funcs # Load helper functions
@@ -645,24 +648,22 @@ else touch /run/rescue
fi
EOF
add_initrd_script etc/rc.d/rc2 <<"EOF"
-echo -e '\e[37;43m'----- rc2 script started -----'\e[0m' # Hint for user about boot steps if its hangs
. /etc/rc.d/funcs # Load helper functions
+echo_color white yellow '----- rc2 script started -----'
+message boot-ok
setterm -blank 60 # screen sleep mode after 60 minutes
set -v # Trace execution
network_up
network_conf
network_show
machine_info
-/etc/rc.d/initrd-autorun.sh && eficast_end
-set +v
-echo -e '\e[37;43m'----- rc2 script ended -----'\e[0m' # Hint for user about boot steps if its hangs
+/etc/rc.d/initrd-autorun && eficast_end
EOF
-add_initrd_script etc/rc.d/initrd-autorun.sh <<"EOF"
+add_initrd_script etc/rc.d/initrd-autorun <<"EOF"
echo -ne "\e]2;$0\007" # Term title (tmux)
. /etc/rc.d/funcs # Load helper functions
-read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
-echo
-mount | grep -q /mnt/nfs && umount /mnt/nfs
+echo_color white yellow '----- initrd-autorun script started -----'
+echo -e '\e[32m/etc/rc.d/nfs-mount script will run now\e[0m'
busybox sh -v /etc/rc.d/nfs-mount
if [ $? -ne 0 ]
then echo_color white red "----- NFS server : not mounted ------"
@@ -677,15 +678,15 @@ then echo_color white red "----- NFS server : missing script ------"
exit 2
fi
echo_color white green "----- NFS server ready ------"
-message nfs autorun
+read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
+message nfs-ok
echo -ne "\e]2;nfs-autorun.sh\007" # Term title (tmux)
cd /mnt/nfs
# don't use source here, exit in inner script will skip cleanup routine (and rescue_shell)
./nfs-autorun.sh
-echo -e '\e[37;43m'----- initrd-autorun.sh script ended -----'\e[0m' # Hint for user about boot steps if its hangs
-}
EOF
add_initrd_script etc/rc.d/nfs-mount <<EOF
+mount | grep -q /mnt/nfs && umount /mnt/nfs
$NFS_MOUNT_CMDLINE
EOF
add_initrd_script sbin/hotplug <<"EOF"
@@ -695,13 +696,13 @@ add_initrd_script sbin/hotplug <<"EOF"
if [ "x$ACTION" = "xadd" ]
then if [ -n "$PCI_ID" ]
then if [ -n "$MODALIAS" ]
- then echo "$0: PCI_ID==$PCI_ID, starting 'modprobe $MODALIAS'"
- else echo -e "\e[37;43m$0: PCI_ID==$PCI_ID, no MODALIAS found\e[0m"
+ then /bin/busybox modprobe -v $MODALIAS 2>&1 | /bin/busybox awk -vT="$0: DEVPATH=$DEVPATH PCI_ID==$PCI_ID " '{ print T $0 }' | /bin/busybox tee -a /var/log/hotplug-pci.log
+ else echo -e '\e[37;43m\e[1m'$0: PCI_ID==$PCI_ID, no MODALIAS found'\e[0m'
+ echo $0: PCI_ID==$PCI_ID, no MODALIAS found >> /var/log/hotplug-pci.log
fi
- /sbin/modprobe -v $MODALIAS 2>&1 | /bin/busybox awk -vT="$0: DEVPATH=$DEVPATH PCI_ID==$PCI_ID " '{ print T $0 }' | /bin/busybox tee -a /var/log/hotplug-pci.log
else if [ -n "$MODALIAS" ]
- then /sbin/modprobe -v $MODALIAS 2>&1 | /bin/busybox awk -vT="$0: DEVPATH=$DEVPATH MODALIAS==$MODALIAS " '{ print T $0 }' >> /var/log/hotplug-non-pci.log
+ then /bin/busybox modprobe -v $MODALIAS 2>&1 | /bin/busybox awk -vT="$0: DEVPATH=$DEVPATH MODALIAS==$MODALIAS " '{ print T $0 }' >> /var/log/hotplug-non-pci.log
else echo "$0: DEVPATH=$DEVPATH no MODALIAS found" >> /var/log/hotplug-non-pci.log
fi
fi