summaryrefslogtreecommitdiff
path: root/make-boot-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'make-boot-image.sh')
-rwxr-xr-xmake-boot-image.sh79
1 files changed, 39 insertions, 40 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index 51c8bc8..2980e3a 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -1,6 +1,6 @@
#!/bin/bash -xe
PS4='+ ($LINENO) ' # To ease debugging
-VERSION="1.0rc2"
+VERSION="1.1-emac"
# Config #
##########
@@ -8,12 +8,13 @@ WORKDIR=./work # Must not be with "nodev" mount option
# sudo rm -r this folder if you want to re-run everything
DLDIR=./downloads
OUTDIR=./out
-OUTUSB=/dev/sdb # Will wreck everything here !
+#OUTUSB=/dev/sdb # If enabled, it could wreck everything there !
LEGACY=y # make USB bootable key compatible with non UEFI-BIOS
-DEVEL_MODE=n # Adds debugging tools in the generated image
+DEVEL_MODE=y # Adds debugging tools in the generated image
INCLUDE_TCPDUMP=y # tcpdump costs few Mb with libcrypto
ROOTCMD=sudo
WGET="wget" # "wget --no-check-certificate" could help but is a security concern
+# You probably need to tweak version numbers if you have an HTTP 404 - Not found error
KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.17.tar.xz
KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/v10.36.0/kconfiglib.py
KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch
@@ -61,15 +62,18 @@ function mkchroot
# Environement and dependencies #
#################################
+which lsb_release || $ROOTCMD apt install lsb-release
codename=$(lsb_release -sc || true)
-if [ "x$codename" != "xstretch" ]
+if [ "x$codename" != "xbuster" ]
then cat >&2 <<EOT
-This script is tested only on Debian 9 (aka stretch).
+This script is tested only on GNU/Linux Debian 10 amd64 (aka Buster).
The fastest way to have the right environment is :
- * download debian live http://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-9.6.0-amd64-gnome.iso
- * burn it or copy it on a USB stick (as raw, with "cp XX.iso /dev/sdX"), alternatively launch a VM with it
- * download and run this script from there
- * grab the generated out/BOOTX64.EFI file
+ * download Debian 10 amd64 live
+ * here : http://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/
+ * or here : http://cdimage.debian.org/mirror/cdimage/archive/
+ * burn it or copy it on a USB stick (as raw, with "sudo cp XX.iso /dev/sdX")
+ * alternatively launch a VM with it
+ * run this script from there
EOT
exit 1
fi
@@ -77,41 +81,37 @@ fi
mkdir -p "$WORKDIR" "$DLDIR" "$OUTDIR"
umask 0022 # Needed for embeding initrd without "sudo make" in kernel dir
+# When using sudo with password auth, ask and cache pass first
+$ROOTCMD true
+
if [ ! -e "$DLDIR/apt-update-done" ]
-then
- if ! ls /var/lib/apt/lists/*_jessie-backports_* >/dev/null
- then echo 'deb http://ftp.debian.org/debian jessie-backports main' \
- | $ROOTCMD tee /etc/apt/sources.list.d/backports.list
- fi
- $ROOTCMD apt-get update
+then $ROOTCMD apt-get update
> "$DLDIR/apt-update-done"
fi
-if [ ! -e "$WORKDIR/apt-done" ]
-then
- # Dependencies of this script (assuming default debian install or live)
+if [ ! -e "$WORKDIR/apt-install-done" ]
+then # Dependencies of this script (assuming default debian install or live)
$ROOTCMD apt-get install wget libncurses5-dev coreutils
[ "x$LEGACY" == "xy" ] && $ROOTCMD apt-get install mbr syslinux
# Dependencies for kernel building
- $ROOTCMD apt-get build-dep linux-source
- $ROOTCMD apt-get install libelf-dev libssl-dev
+ $ROOTCMD apt-get install build-essential flex bison
+
# Dependencies for kernel tools
- [ "x$DEVEL_MODE" == "xy" ] && $ROOTCMD apt-get install libunwind-dev \
- libdw-dev libaudit-dev libslang2-dev libiberty-dev flex bison
+ [ "x$DEVEL_MODE" == "xy" ] && $ROOTCMD apt-get install libelf-dev libunwind-dev \
+ libdw-dev libaudit-dev libssl-dev libslang2-dev libnuma-dev \
+ systemtap-sdt-dev python-dev binutils-dev libiberty-dev libbabeltrace-ctf-dev
# Optionnally qemu to run the result for santity checking
[ "x$DEVEL_MODE" = "xy" ] && $ROOTCMD apt-get install qemu-system-x86
# Dependencies to put into the initrd
- $ROOTCMD apt-get install dmidecode pciutils usbutils lshw sysstat iftop strace \
- ntfs-3g e2fsprogs partclone util-linux udpcast gdisk efibootmgr pigz \
- pv bc figlet toilet-fonts ncurses-bin beep net-tools ethtool
- # Optionnal dependencies to put into the initrd
- [ "x$INCLUDE_TCPDUMP" == "xy" ] && $ROOTCMD apt-get install tcpdump
-
# util-linux : fdisk, sfdisk, lsblk, setterm
# net-tools : mii-tool
# ncurses-bin : tput
- $ROOTCMD apt-get -t jessie-backports install tmux
- > "$WORKDIR/apt-done"
+ $ROOTCMD apt-get install dmidecode pciutils usbutils lshw sysstat iftop strace rsync \
+ ntfs-3g e2fsprogs dosfstools exfat-utils partclone util-linux gdisk efibootmgr \
+ pv bc figlet toilet-fonts ncurses-bin beep net-tools ethtool pigz tmux
+ # Optionnal dependencies to put into the initrd
+ [ "x$INCLUDE_TCPDUMP" == "xy" ] && $ROOTCMD apt-get install tcpdump
+ > "$WORKDIR/apt-install-done"
fi
# Kernel build setup #
@@ -206,7 +206,7 @@ while more_work and i < passes:
# Disable thing that are unneeded or annoying for the purpose of disk cloning
# FIXME Need NFS v3 client
- if sym.name in [ 'HAMRADIO', 'HIBERNATION', 'KEYS', 'LOGO', 'NETFILTER', 'NETWORK_FILESYSTEMS',
+ if sym.name in [ 'HAMRADIO', 'HIBERNATION', 'LOGO', 'NETFILTER', # 'KEYS', 'NETWORK_FILESYSTEMS',
'PCCARD', 'RFKILL', 'SECURITY', 'SOUND', 'SUSPEND', 'VIRTUALIZATION', 'WIRELESS', 'WLAN']:
more_work = sset(sym, 0) or more_work
@@ -290,15 +290,13 @@ then ln -s /bin/busybox "$WORKDIR/initrd/init"
fi
if [ ! -s "$WORKDIR/initrd/etc/keys.bmap" ]
-then # When using sudo with password auth, ask and cache pass first
- $ROOTCMD true
- # The following compound command will suck at asking pass
- # FIXME fails on Debian 9
+then
+ # FIXME fails on Debian 9 and 10
#$ROOTCMD dumpkeys | $ROOTCMD loadkeys -b > "$WORKDIR/initrd/etc/keys.bmap"
cp -a /etc/localtime "$WORKDIR/initrd/etc/"
fi
-if [ ! -s "$WORKDIR/initrd/usr/sbin/partclone.restore" ]
+if [ ! -s "$WORKDIR/initrd/usr/share/figlet/standard" ]
then (
set +x
PATH="$WORKDIR/kernel/tools/perf:/usr/sbin:/usr/bin:/sbin:/bin"
@@ -315,9 +313,9 @@ then (
# Disk tools
mkchroot "$WORKDIR/initrd" fdisk gdisk sfdisk sgdisk
# Cloning tools
- mkchroot "$WORKDIR/initrd" /usr/sbin/partclone* efibootmgr pigz udp-receiver scp rsync
+ mkchroot "$WORKDIR/initrd" /usr/sbin/partclone* efibootmgr pigz scp rsync
# Some dyn-loaded libraries (ldd will not display them)
- mkchroot "$WORKDIR/initrd" /lib/x86_64-linux-gnu/libusb-1.0.so.0
+ mkchroot "$WORKDIR/initrd" /lib/x86_64-linux-gnu/libusb-1.0.so.0 /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
if [ "x$INCLUDE_TCPDUMP" == "xy" ]
then # tcpdump costs few Mb with libcrypto
@@ -346,7 +344,7 @@ if [ ! -f "$WORKDIR/initrd/usr/share/groff/current/man.local" ]
then mkdir -p "$WORKDIR"/initrd/usr/man/man{1,6,8} "$WORKDIR"/initrd/usr/share/groff/current/font
mkdir -p "$WORKDIR"/initrd/etc/groff/
- cp -a /usr/share/man/man1/{beep,iostat,lshw,mpstat,setterm,bc,pv,strace,tmux,pigz,udp-receiver}* "$WORKDIR"/initrd/usr/man/man1/
+ cp -a /usr/share/man/man1/{beep,iostat,lshw,mpstat,setterm,bc,pv,strace,tmux,pigz}* "$WORKDIR"/initrd/usr/man/man1/
cp -a /usr/share/man/man6/figlet* "$WORKDIR"/initrd/usr/man/man6/
cp -a /usr/share/man/man8/{dmidecode,iftop,lspci,lsblk,lsusb,partclone,efibootmgr,mkfs}* "$WORKDIR"/initrd/usr/man/man8/
cp -a /usr/share/man/man8/{ntfs,mkntfs,mkexfatfs,mount.ntfs,mount.fuse,mount.exfat-fuse}* "$WORKDIR"/initrd/usr/man/man8/
@@ -396,7 +394,7 @@ 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 ) &
- [ -r touch /run/eficast_end ] && action=$(cat /run/eficast_end)
+ [ -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...'
poweroff
@@ -690,6 +688,7 @@ fi > /dev/console 2>&1
EOF
add_initrd_script "/bin/nfs-mount" <<"EOF"
echo -ne "\e]2;$0\007" # Term title (tmux)
+mount | grep -q /mnt/nfs && umount /mnt/nfs
set -v # Trace execution
mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs
EOF