summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmake-boot-image.sh53
1 files changed, 39 insertions, 14 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index ccba121..30b4462 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -7,14 +7,13 @@ WORKDIR=./work
DLDIR=./downloads
OUTDIR=./out
#OUTUSB=/dev/sdb1
-KERNEL_TOOLS=y
-RUN_QEMU=y
+DEVEL_MODE=y
ROOTCMD=sudo
WGET="wget" #"wget --no-check-certificate"
KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.6.tar.xz
KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/7eace27993ad3aa1d6911866d9c60a11f32d36d9/kconfiglib.py
KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/7eace27993ad3aa1d6911866d9c60a11f32d36d9/makefile.patch
-NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/nic-firmware_1.157_all.udeb
+NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/nic-firmware_1.162_all.udeb
UFTP_TARBALL_URL=http://downloads.sourceforge.net/project/uftp-multicast/source-tar/uftp-4.9.2.tar.gz
BUSYBOX_BIN_URL=https://busybox.net/downloads/binaries/busybox-x86_64
PCI_IDS_URL=https://pci-ids.ucw.cz/v2.2/pci.ids
@@ -76,10 +75,10 @@ then $ROOTCMD apt-get update
# Dependencies for kernel building
$ROOTCMD apt-get build-dep linux-source
# Dependancies for kernel tools
- [ "x$KERNEL_TOOLS" == "xy" ] && $ROOTCMD apt-get install libelf-dev libunwind-dev \
+ [ "x$DEVEL_MODE" == "xy" ] && $ROOTCMD apt-get install libelf-dev libunwind-dev \
libdw-dev libaudit-dev libssl-dev libslang2-dev libiberty-dev
# Optionnally qemu to run the result for santity checking
- [ "x$RUN_QEMU" = "xy" ] && $ROOTCMD apt-get install qemu-system-x86
+ [ "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
$ROOTCMD apt-get install partclone udpcast gdisk efibootmgr tcpdump
@@ -122,6 +121,7 @@ def sset(sym, value=None):
sym.set_user_value(value)
return True
+debug = '--debug' in sys.argv;
conf = kconfiglib.Config(sys.argv[1])
conf.load_config('.config')
support_xz = conf['KERNEL_XZ'] is not None
@@ -134,23 +134,33 @@ while more_work and i < 10:
for sym in conf.get_symbols():
name = sym.get_name()
+
+ # Default hostname is (none) and could make FreeBSD's dhcpd complain because unallowed '()'
if name in ['DEFAULT_HOSTNAME']:
- # default is (none) and could make FreeBSD's dhcpd complain because unallowed '()'
more_work = sset(sym, 'eficast') or more_work
+ # Embed initrd in the EFI bootable kernel
if name in ['INITRAMFS_SOURCE']:
- # embed initrd in the EFI bootable kernel
more_work = sset(sym, '../initrd/') or more_work
+ # Make kernel directly loadable by EFI, add USB3, Dell flash
if name in ['EFI_STUB', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']:
- # Make kernel directly loadable by EFI, add USB3, Dell flash...
more_work = sset(sym) or more_work
+ # Support soft RAID (linux) and hard RAID (some cards)
+ if name in ['DM_RAID', 'SCSI_LOWLEVEL', 'MEGARAID_SAS', 'MEGARAID_NEWGEN']:
+ more_work = sset(sym) or more_work
+
+ # If --debug passed as arg, make kernel aware of virtual drivers (used for testing eficast on qemu/kvm)
+ if debug and name in ['VIRTIO_PCI', 'VIRTIO_MMIO', 'VIRTIO_NET', 'VIRTIO_BLK', 'SCSI_LOWLEVEL', 'SCSI_VIRTIO']:
+ more_work = sset(sym) or more_work
+
+ # Disable thing that are unneeded or annoying for the purpose of disk cloning
if name in ['LOGO', 'SUSPEND', 'HIBERNATION', 'CPU_FREQ', 'PCCARD', 'HAMRADIO', 'WIRELESS', 'RFKILL', 'WLAN', 'SOUND', 'NETWORK_FILESYSTEMS', 'KEYS', 'SECURITY', 'VIRTUALIZATION']:
more_work = sset(sym, 'n') or more_work
+ # Compress everything with XZ if available (slower, smaller)
if support_xz:
- # Compress everything with XZ if available (slower, smaller)
if name in ['KERNEL_XZ']:
more_work = sset(sym, 'y') or more_work
if name in ['RD_GZIP', 'RD_BZIP2', 'RD_LZMA', 'RD_LZO', 'RD_LZ4']:
@@ -182,12 +192,16 @@ chmod +x "$WORKDIR/kernel/scripts/Kconfiglib/customize.py"
cd "$WORKDIR/kernel"
if [ ! -f .config ]
then make defconfig
- make scriptconfig SCRIPT=scripts/Kconfiglib/customize.py
+ if [ "x$DEVEL_MODE" == "xy" ]
+ then extra="SCRIPT_ARG=--debug"
+ else extra=""
+ fi
+ make scriptconfig SCRIPT=scripts/Kconfiglib/customize.py $extra
fi
)
p="$WORKDIR/kernel/tools/perf/perf"
-if [ "x$KERNEL_TOOLS" == "xy" -a ! -f "$p" ]
+if [ "x$DEVEL_MODE" == "xy" -a ! -f "$p" ]
then (
cd "$WORKDIR/kernel"
make tools/perf
@@ -236,7 +250,7 @@ fi
if [ ! -f "$WORKDIR/initrd/partclone-restore" ]
then (
set +x
- PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+ PATH="$WORKDIR/kernel/tools/perf:/usr/sbin:/usr/bin:/sbin:/bin"
# Diagnostic tools
mkchroot "$WORKDIR/initrd" dmidecode iftop iostat lshw lspci lsusb mpstat tcpdump
# Manpage display
@@ -248,6 +262,15 @@ then (
)
fi
+if [ "x$DEVEL_MODE" == "xy" ]
+then (
+ p="$WORKDIR/kernel/tools/perf/perf"
+ cp -a "$p" "$WORKDIR/initrd/sbin/"
+ set +x
+ mkchroot "$WORKDIR/initrd" $(ldd "$p" | egrep -o '/.* ')
+ )
+fi
+
if [ ! -d "$WORKDIR/initrd/usr/man" ]
then mkdir -p "$WORKDIR"/initrd/usr/man/man{1,8} "$WORKDIR"/initrd/usr/share/groff/1.22.2/font "$WORKDIR/initrd/etc/groff/"
cp /usr/share/man/man1/{iostat,mpstat,strace,udp-receiver}* "$WORKDIR/initrd/usr/man/man1/"
@@ -490,7 +513,9 @@ chmod +x "$WORKDIR/initrd/bin/sinkdo"
cd "$WORKDIR/kernel"
# Workaround : some kernel version forget to update embed initramfs in certain cases
[ -f usr/initramfs_data.cpio.gz ] && rm usr/initramfs_data.cpio.gz
- make -j $(($(nproc)+1))
+ nproc=$(nproc --all)
+ nproc=${nproc:-4}
+ make -j $((nproc+1))
)
# Copy / run result EFI file #
@@ -506,5 +531,5 @@ then [ -d "$WORKDIR/mountpoint" ] || mkdir "$WORKDIR/mountpoint"
$ROOTCMD umount "$WORKDIR/mountpoint"
fi
-[ "x$RUN_QEMU" == "xy" ] && qemu-system-x86_64 -M q35 -m 256 -kernel "$OUTDIR/BOOTX64.EFI"
+[ "x$DEVEL_MODE" == "xy" ] && qemu-system-x86_64 -M q35 -m 256 -kernel "$OUTDIR/BOOTX64.EFI"