diff --git a/README.md b/README.md index aadc3e9..7318217 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,9 @@ Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands --- #### Advanced system features: +##### `ENABLE_SYSTEMDSWAP`=false +Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled. + ##### `ENABLE_MINBASE`=false Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB. @@ -234,6 +237,12 @@ Install and enable the [ARM side libraries for interfacing to Raspberry Pi GPU]( ##### `VIDEOCORESRC_DIR`="" Path to a directory (`userland`) of [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot. +##### `ENABLE_NEXMON`=false +Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git). + +##### `NEXMONSRC_DIR`="" +Path to a directory (`nexmon`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot. + ##### `ENABLE_IPTABLES`=false Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service. @@ -345,6 +354,23 @@ With this parameter set to true the script expects the existing kernel sources d ##### `RPI_FIRMWARE_DIR`="" The directory (`firmware`) containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project. +##### `KERNEL_DEFAULT_GOV`="ONDEMAND" +Set the default cpu governor at kernel compilation. Supported values are: PERFORMANCE POWERSAVE USERSPACE ONDEMAND CONSERVATIVE SCHEDUTIL + +##### `KERNEL_NF`=false +Enable Netfilter modules as kernel modules + +##### `KERNEL_VIRT`=false +Enable Kernel KVM support (/dev/kvm) + +##### `KERNEL_ZSWAP`=false +Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases + +##### `KERNEL_BPF`=true +Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd compilations about it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls] + +##### `KERNEL_SECURITY`=false +Enables Apparmor, integrity subsystem, auditing --- #### Reduce disk usage: diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index a662049..c29a977 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -5,6 +5,14 @@ # Load utility functions . ./functions.sh +# Need to use kali kernel src if nexmon is enabled +if [ "$ENABLE_NEXMON" = true ] ; then + KERNEL_URL="${KALI_KERNEL_URL}" + # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel + KERNEL_BRANCH="" + KERNELSRC_DIR="" +fi + # Fetch and build latest raspberry kernel if [ "$BUILD_KERNEL" = true ] ; then # Setup source directory @@ -87,6 +95,283 @@ if [ "$BUILD_KERNEL" = true ] ; then # Load default raspberry kernel configuration make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" + #Switch to KERNELSRC_DIR so we can use set_kernel_config + cd "${KERNEL_DIR}" || exit + + # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap + if [ "$KERNEL_ZSWAP" = true ] ; then + set_kernel_config CONFIG_ZPOOL y + set_kernel_config CONFIG_ZSWAP y + set_kernel_config CONFIG_ZBUD y + set_kernel_config CONFIG_Z3FOLD y + set_kernel_config CONFIG_ZSMALLOC y + set_kernel_config CONFIG_PGTABLE_MAPPING y + set_kernel_config CONFIG_LZO_COMPRESS y + fi + + # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 + if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then + set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y + set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y + set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y + set_kernel_config CONFIG_HAVE_KVM_EVENTFD y + set_kernel_config CONFIG_HAVE_KVM_IRQFD y + set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y + set_kernel_config CONFIG_HAVE_KVM_MSI y + set_kernel_config CONFIG_KVM y + set_kernel_config CONFIG_KVM_ARM_HOST y + set_kernel_config CONFIG_KVM_ARM_PMU y + set_kernel_config CONFIG_KVM_COMPAT y + set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y + set_kernel_config CONFIG_KVM_MMIO y + set_kernel_config CONFIG_KVM_VFIO y + set_kernel_config CONFIG_VHOST m + set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y + set_kernel_config CONFIG_VHOST_NET m + set_kernel_config CONFIG_VIRTUALIZATION y + + set_kernel_config CONFIG_MMU_NOTIFIER y + + # erratum + set_kernel_config ARM64_ERRATUM_834220 y + + # https://sourceforge.net/p/kvm/mailman/message/18440797/ + set_kernel_config CONFIG_PREEMPT_NOTIFIERS y + fi + + # enable apparmor,integrity audit, + if [ "$KERNEL_SECURITY" = true ] ; then + + # security filesystem, security models and audit + set_kernel_config CONFIG_SECURITYFS y + set_kernel_config CONFIG_SECURITY y + set_kernel_config CONFIG_AUDIT y + + # harden strcpy and memcpy + set_kernel_config CONFIG_HARDENED_USERCOPY=y + set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y + set_kernel_config CONFIG_FORTIFY_SOURCE=y + + # integrity sub-system + set_kernel_config CONFIG_INTEGRITY=y + set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y + set_kernel_config CONFIG_INTEGRITY_AUDIT=y + set_kernel_config CONFIG_INTEGRITY_SIGNATURE=y + set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING=y + + # This option provides support for retaining authentication tokens and access keys in the kernel. + set_kernel_config CONFIG_KEYS=y + set_kernel_config CONFIG_KEYS_COMPAT=y + + # Apparmor + set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0 + set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y + set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y + set_kernel_config CONFIG_SECURITY_APPARMOR y + set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y + set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor" + + # restrictions on unprivileged users reading the kernel + set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT=y + + # network security hooks + set_kernel_config CONFIG_SECURITY_NETWORK y + set_kernel_config CONFIG_SECURITY_NETWORK_XFRM=y + set_kernel_config CONFIG_SECURITY_PATH=y + set_kernel_config CONFIG_SECURITY_YAMA=y + + # New Options + if [ "$KERNEL_NF" = true ] ; then + set_kernel_config CONFIG_IP_NF_SECURITY m + set_kernel_config CONFIG_NETLABEL y + set_kernel_config CONFIG_IP6_NF_SECURITY m + fi + set_kernel_config CONFIG_SECURITY_SELINUX n + set_kernel_config CONFIG_SECURITY_SMACK n + set_kernel_config CONFIG_SECURITY_TOMOYO n + set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n + set_kernel_config CONFIG_SECURITY_LOADPIN n + set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n + set_kernel_config CONFIG_IMA n + set_kernel_config CONFIG_EVM n + set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y + set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y + set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y + set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y + set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y + set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y + set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y + set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n + set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m + set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096 + + set_kernel_config CONFIG_ARM64_CRYPTO y + set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m + set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m + set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m + set_kernel_config CRYPTO_GHASH_ARM64_CE m + set_kernel_config CRYPTO_SHA2_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_AES_ARM64 m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y + set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m + set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m + set_kernel_config SYSTEM_TRUSTED_KEYS + fi + + # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 + if [ "$KERNEL_NF" = true ] ; then + set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m + set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m + set_kernel_config CONFIG_NFT_FIB_INET m + set_kernel_config CONFIG_NFT_FIB_IPV4 m + set_kernel_config CONFIG_NFT_FIB_IPV6 m + set_kernel_config CONFIG_NFT_FIB_NETDEV m + set_kernel_config CONFIG_NFT_OBJREF m + set_kernel_config CONFIG_NFT_RT m + set_kernel_config CONFIG_NFT_SET_BITMAP m + set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y + set_kernel_config CONFIG_NF_LOG_ARP m + set_kernel_config CONFIG_NF_SOCKET_IPV4 m + set_kernel_config CONFIG_NF_SOCKET_IPV6 m + set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m + set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m + set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m + set_kernel_config CONFIG_IP6_NF_IPTABLES m + set_kernel_config CONFIG_IP6_NF_MATCH_AH m + set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m + set_kernel_config CONFIG_IP6_NF_NAT m + set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m + set_kernel_config CONFIG_IP6_NF_TARGET_NPT m + set_kernel_config CONFIG_IP_NF_SECURITY m + set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m + set_kernel_config CONFIG_IP_SET_BITMAP_PORT m + set_kernel_config CONFIG_IP_SET_HASH_IP m + set_kernel_config CONFIG_IP_SET_HASH_IPMARK m + set_kernel_config CONFIG_IP_SET_HASH_IPPORT m + set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m + set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m + set_kernel_config CONFIG_IP_SET_HASH_MAC m + set_kernel_config CONFIG_IP_SET_HASH_NET m + set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m + set_kernel_config CONFIG_IP_SET_HASH_NETNET m + set_kernel_config CONFIG_IP_SET_HASH_NETPORT m + set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m + set_kernel_config CONFIG_IP_SET_LIST_SET m + set_kernel_config CONFIG_NETFILTER_XTABLES m + set_kernel_config CONFIG_NETFILTER_XTABLES m + set_kernel_config CONFIG_NFT_BRIDGE_META m + set_kernel_config CONFIG_NFT_BRIDGE_REJECT m + set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m + set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m + set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m + set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m + set_kernel_config CONFIG_NFT_COMPAT m + set_kernel_config CONFIG_NFT_COUNTER m + set_kernel_config CONFIG_NFT_CT m + set_kernel_config CONFIG_NFT_DUP_IPV4 m + set_kernel_config CONFIG_NFT_DUP_IPV6 m + set_kernel_config CONFIG_NFT_DUP_NETDEV m + set_kernel_config CONFIG_NFT_EXTHDR m + set_kernel_config CONFIG_NFT_FWD_NETDEV m + set_kernel_config CONFIG_NFT_HASH m + set_kernel_config CONFIG_NFT_LIMIT m + set_kernel_config CONFIG_NFT_LOG m + set_kernel_config CONFIG_NFT_MASQ m + set_kernel_config CONFIG_NFT_MASQ_IPV4 m + set_kernel_config CONFIG_NFT_MASQ_IPV6 m + set_kernel_config CONFIG_NFT_META m + set_kernel_config CONFIG_NFT_NAT m + set_kernel_config CONFIG_NFT_NUMGEN m + set_kernel_config CONFIG_NFT_QUEUE m + set_kernel_config CONFIG_NFT_QUOTA m + set_kernel_config CONFIG_NFT_REDIR m + set_kernel_config CONFIG_NFT_REDIR_IPV4 m + set_kernel_config CONFIG_NFT_REDIR_IPV6 m + set_kernel_config CONFIG_NFT_REJECT m + set_kernel_config CONFIG_NFT_REJECT_INET m + set_kernel_config CONFIG_NFT_REJECT_IPV4 m + set_kernel_config CONFIG_NFT_REJECT_IPV6 m + set_kernel_config CONFIG_NFT_SET_HASH m + set_kernel_config CONFIG_NFT_SET_RBTREE m + set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m + set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m + set_kernel_config CONFIG_NF_DEFRAG_IPV4 m + set_kernel_config CONFIG_NF_DEFRAG_IPV6 m + set_kernel_config CONFIG_NF_DUP_IPV4 m + set_kernel_config CONFIG_NF_DUP_IPV6 m + set_kernel_config CONFIG_NF_DUP_NETDEV m + set_kernel_config CONFIG_NF_LOG_BRIDGE m + set_kernel_config CONFIG_NF_LOG_IPV4 m + set_kernel_config CONFIG_NF_LOG_IPV6 m + set_kernel_config CONFIG_NF_NAT_IPV4 m + set_kernel_config CONFIG_NF_NAT_IPV6 m + set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m + set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m + set_kernel_config CONFIG_NF_NAT_PPTP m + set_kernel_config CONFIG_NF_NAT_PROTO_GRE m + set_kernel_config CONFIG_NF_NAT_REDIRECT m + set_kernel_config CONFIG_NF_NAT_SIP m + set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m + set_kernel_config CONFIG_NF_NAT_TFTP m + set_kernel_config CONFIG_NF_REJECT_IPV4 m + set_kernel_config CONFIG_NF_REJECT_IPV6 m + set_kernel_config CONFIG_NF_TABLES m + set_kernel_config CONFIG_NF_TABLES_ARP m + set_kernel_config CONFIG_NF_TABLES_BRIDGE m + set_kernel_config CONFIG_NF_TABLES_INET m + set_kernel_config CONFIG_NF_TABLES_IPV4 m + set_kernel_config CONFIG_NF_TABLES_IPV6 m + set_kernel_config CONFIG_NF_TABLES_NETDEV m + fi + + # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA + if [ "$KERNEL_BPF" = true ] ; then + set_kernel_config CONFIG_BPF_SYSCALL y + set_kernel_config CONFIG_BPF_EVENTS y + set_kernel_config CONFIG_BPF_STREAM_PARSER y + set_kernel_config CONFIG_CGROUP_BPF y + fi + + # KERNEL_DEFAULT_GOV was set by user + if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then + + case "$KERNEL_DEFAULT_GOV" in + performance) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y + ;; + userspace) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y + ;; + ondemand) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y + ;; + conservative) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y + ;; + shedutil) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y + ;; + *) + echo "error: unsupported default cpu governor" + exit 1 + ;; + esac + + # unset previous default governor + unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE + fi + + #Revert to previous directory + cd "${WORKDIR}" || exit + # Set kernel configuration parameters to enable qemu emulation if [ "$ENABLE_QEMU" = true ] ; then echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config @@ -126,6 +411,7 @@ if [ "$BUILD_KERNEL" = true ] ; then if [ "$KERNEL_MENUCONFIG" = true ] ; then make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig fi + # end if "$KERNELSRC_CONFIG" = true fi # Use ccache to cross compile the kernel @@ -142,6 +428,7 @@ if [ "$BUILD_KERNEL" = true ] ; then if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules fi + # end if "$KERNELSRC_PREBUILT" = false fi # Check if kernel compilation was successful @@ -237,19 +524,79 @@ if [ "$BUILD_KERNEL" = true ] ; then fi else # BUILD_KERNEL=false - # Kernel installation - chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel + if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then + + # Use Sakakis modified kernel if ZSWAP is active + if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then + RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}" + fi + + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel dl + as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" + + #extract download + tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}" + + #move extracted kernel to /boot/firmware + mkdir "${R}/boot/firmware" + cp "${temp_dir}"/boot/* "${R}"/boot/firmware/ + cp -r "${temp_dir}"/lib/* "${R}"/lib/ + + # Remove temporary directory for kernel sources + rm -fr "${temp_dir}" + + # Set permissions of the kernel sources + chown -R root:root "${R}/boot/firmware" + chown -R root:root "${R}/lib/modules" + fi + + # Install Kernel from hypriot comptabile with all Raspberry PI + if [ "$SET_ARCH" = 32 ] ; then + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel + as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL" - # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot - chroot_exec apt-get -qq -y install flash-kernel + # Copy downloaded U-Boot sources + mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb + + # Set permissions + chown -R root:root "${R}"/tmp/kernel.deb + + # Install kernel + chroot_exec dpkg -i /tmp/kernel.deb + + # move /boot to /boot/firmware to fit script env. + #mkdir "${BOOT_DIR}" + mkdir "${temp_dir}"/firmware + mv "${R}"/boot/* "${temp_dir}"/firmware/ + mv "${temp_dir}"/firmware "${R}"/boot/ + + #same for kernel headers + if [ "$KERNEL_HEADERS" = true ] ; then + # Fetch kernel header + as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL" + mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb + chown -R root:root "${R}"/tmp/kernel-header.deb + # Install kernel header + chroot_exec dpkg -i /tmp/kernel-header.deb + rm -f "${R}"/tmp/kernel-header.deb + fi + + # Remove temporary directory and files + rm -fr "${temp_dir}" + rm -f "${R}"/tmp/kernel.deb + fi # Check if kernel installation was successful - VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)" - if [ -z "$VMLINUZ" ] ; then - echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" + KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)" + if [ -z "$KERNEL" ] ; then + echo "error: kernel installation failed! (/boot/kernel* not found)" cleanup exit 1 fi - # Copy vmlinuz kernel to the boot directory - install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}" fi diff --git a/bootstrap.d/14-fstab.sh b/bootstrap.d/14-fstab.sh index 149dcb3..4ecba25 100644 --- a/bootstrap.d/14-fstab.sh +++ b/bootstrap.d/14-fstab.sh @@ -8,6 +8,11 @@ # Install and setup fstab install_readonly files/mount/fstab "${ETC_DIR}/fstab" +if [ "$ENABLE_UBOOTUSB" = true ] ; then + sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab" + sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab" +fi + # Add usb/sda disk root partition to fstab if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab" diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 611f1a5..d7d0239 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -5,39 +5,37 @@ # Load utility functions . ./functions.sh -if [ "$BUILD_KERNEL" = true ] ; then - if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then - # Install boot binaries from local directory - cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin - cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat - cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat - cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat - cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf - cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf - cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf - else - # Create temporary directory for boot binaries - temp_dir=$(as_nobody mktemp -d) - - # Install latest boot binaries from raspberry/firmware github - as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" - as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" - as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" - as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" - as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" - as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" - as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" - - # Move downloaded boot binaries - mv "${temp_dir}/"* "${BOOT_DIR}/" - - # Remove temporary directory for boot binaries - rm -fr "${temp_dir}" - - # Set permissions of the boot binaries - chown -R root:root "${BOOT_DIR}" - chmod -R 600 "${BOOT_DIR}" - fi +if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then + # Install boot binaries from local directory + cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin + cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat + cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf +else + # Create temporary directory for boot binaries + temp_dir=$(as_nobody mktemp -d) + + # Install latest boot binaries from raspberry/firmware github + as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" + as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" + as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" + as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" + as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" + as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" + as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" + + # Move downloaded boot binaries + mv "${temp_dir}/"* "${BOOT_DIR}/" + + # Remove temporary directory for boot binaries + rm -fr "${temp_dir}" + + # Set permissions of the boot binaries + chown -R root:root "${BOOT_DIR}" + chmod -R 600 "${BOOT_DIR}" fi # Setup firmware boot cmdline @@ -159,6 +157,50 @@ if [ "$ENABLE_CONSOLE" = true ] ; then chroot_exec systemctl enable serial-getty\@serial0.service else echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" + + # disable serial console systemd style + chroot_exec systemctl disable serial-getty\@"$SET_SERIAL".service +fi + +if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then + # Create temporary directory for systemd-swap sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch systemd-swap sources + as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}" + + # Copy downloaded systemd-swap sources + mv "${temp_dir}/systemd-swap" "${R}/tmp/" + + # Set permissions of the systemd-swap sources + chown -R root:root "${R}/tmp/systemd-swap" + + # Remove temporary directory for systemd-swap sources + rm -fr "${temp_dir}" + + # Change into downloaded src dir + cd "${R}/tmp/systemd-swap" || exit + + # Build package + . ./package.sh debian + + # Install package + chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb + + # Enable service + chroot_exec systemctl enable systemd-swap + + # Change back into script root dir + cd "${WORKDIR}" || exit +else + # Enable ZSWAP in cmdline if systemd-swap is not used + if [ "$KERNEL_ZSWAP" = true ] ; then + CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" + fi +fi + +if [ "$KERNEL_SECURITY" = true ] ; then + CMDLINE="${CMDLINE} apparmor=1 security=apparmor" fi # Install firmware boot cmdline diff --git a/bootstrap.d/21-firewall.sh b/bootstrap.d/21-firewall.sh index 1688be9..91b6e26 100644 --- a/bootstrap.d/21-firewall.sh +++ b/bootstrap.d/21-firewall.sh @@ -9,9 +9,10 @@ if [ "$ENABLE_IPTABLES" = true ] ; then # Create iptables configuration directory mkdir -p "${ETC_DIR}/iptables" - # make sure iptables-legacy is the used alternatives - #iptables-save and -restore are slaves of iptables and thus are set accordingly - chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy + if [ "$KERNEL_NF" = false ] ; then + #iptables-save and -restore are slaves of iptables and thus are set accordingly + chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy + fi # Install iptables systemd service install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service" @@ -27,9 +28,11 @@ if [ "$ENABLE_IPTABLES" = true ] ; then chroot_exec systemctl enable iptables.service if [ "$ENABLE_IPV6" = true ] ; then - # make sure ip6tables-legacy is the used alternatives - chroot_exec update-alternatives --verbose --set ip6tables /usr/sbin/ip6tables-legacy - + if [ "$KERNEL_NF" = false ] ; then + #iptables-save and -restore are slaves of iptables and thus are set accordingly + chroot_exec update-alternatives --verbose --set ip6tables /usr/sbin/ip6tables-legacy + fi + # Install ip6tables systemd service install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service" diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh index dded27d..e81dcd9 100644 --- a/bootstrap.d/41-uboot.sh +++ b/bootstrap.d/41-uboot.sh @@ -77,6 +77,11 @@ if [ "$ENABLE_UBOOT" = true ] ; then #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)] sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" fi + + # instead of sd, boot from usb device + if [ "$ENABLE_UBOOTUSB" = true ] ; then + sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" + fi # Set mkfile to use the correct dtb file sed -i "s|bcm2709-rpi-2-b.dtb|${DTB_FILE}|" "${BOOT_DIR}/uboot.mkimage" diff --git a/bootstrap.d/44-nexmon_monitor_patch.sh b/bootstrap.d/44-nexmon_monitor_patch.sh new file mode 100644 index 0000000..5a260a2 --- /dev/null +++ b/bootstrap.d/44-nexmon_monitor_patch.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# +# Build and Setup nexmon with monitor mode patch +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then + # Copy existing nexmon sources into chroot directory + if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then + # Copy local U-Boot sources + cp -r "${NEXMONSRC_DIR}" "${R}/tmp" + else + # Create temporary directory for nexmon sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch nexmon sources + as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" + + # Copy downloaded nexmon sources + mv "${temp_dir}/nexmon" "${R}"/tmp/ + + # Set permissions of the nexmon sources + chown -R root:root "${R}"/tmp/nexmon + + # Remove temporary directory for nexmon sources + rm -fr "${temp_dir}" + fi + + # Set script Root + export NEXMON_ROOT="${R}"/tmp/nexmon + + # Build nexmon firmware outside the build system, if we can. + cd "${NEXMON_ROOT}" || exit + + # Make ancient isl build + cd buildtools/isl-0.10 || exit + ./configure + make + cd ../.. || exit + + # Disable statistics + touch DISABLE_STATISTICS + + # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh + export KERNEL="${KERNEL_IMAGE}" + export ARCH=arm + export SUBARCH=arm + export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + export CC="${CC}"gcc + export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so + export ZLIBFLATE="zlib-flate -compress" + export Q=@ + export NEXMON_SETUP_ENV=1 + export HOSTUNAME=$(uname -s) + export PLATFORMUNAME=$(uname -m) + + # Make nexmon + make + + # build patches + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then + cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit + sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile + make clean + + # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. + LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + + # copy RPi0W & RPi3 firmware + mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin + cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin + cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin + fi + + if [ "$RPI_MODEL" = 3P ] ; then + cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit + sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile + make clean + + # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. + LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + + # RPi3B+ firmware + mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin + cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin + cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin + fi + +#Revert to previous directory +cd "${WORKDIR}" || exit + +# Remove nexmon sources +rm -fr "${NEXMON_ROOT}" + +fi diff --git a/functions.sh b/functions.sh index c73cbaf..4733375 100644 --- a/functions.sh +++ b/functions.sh @@ -3,6 +3,17 @@ cleanup (){ set +x set +e + + # Remove exports from nexmon + unset KERNEL + unset ARCH + unset SUBARCH + unset CCPLUGIN + unset ZLIBFLATE + unset Q + unset NEXMON_SETUP_ENV + unset HOSTUNAME + unset PLATFORMUNAME # Identify and kill all processes still using files echo "killing processes using mount point ..." @@ -83,4 +94,23 @@ cdr2mask () set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 [ $1 -gt 1 ] && shift $1 || shift echo ${1-0}.${2-0}.${3-0}.${4-0} +} + +# GPL v2.0 - #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh +set_kernel_config() { + # flag as $1, value to set as $2, config must exist at "./.config" + TGT="CONFIG_${1#CONFIG_}" + REP="${2}" + if grep -q "^${TGT}[^_]" .config; then + sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config + else + echo "${TGT}"="${2}" >> .config + fi +} + +# unset kernel config parameter +unset_kernel_config() { + # unsets flag with the value of $1, config must exist at "./.config" + TGT="CONFIG_${1#CONFIG_}" + sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config } \ No newline at end of file diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index e0f8872..2ea5bcb 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -57,6 +57,20 @@ FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} +NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} +SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} + +# Kernel deb packages for 32bit kernel +RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb} +RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb} +# Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used +RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} +# Default precompiled 64bit kernel +RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} +# Generic +RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL} +# Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul) +KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git} # Build directories WORKDIR=$(pwd) @@ -138,14 +152,18 @@ SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} # Advanced settings +ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false} ENABLE_MINBASE=${ENABLE_MINBASE:=false} ENABLE_REDUCE=${ENABLE_REDUCE:=false} ENABLE_UBOOT=${ENABLE_UBOOT:=false} UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} +ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} +ENABLE_NEXMON=${ENABLE_NEXMON:=false} VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} +NEXMONSRC_DIR=${NEXMONSRC_DIR:=""} ENABLE_HARDNET=${ENABLE_HARDNET:=false} ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} @@ -162,6 +180,12 @@ KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} KERNEL_CCACHE=${KERNEL_CCACHE:=false} +KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} +KERNEL_VIRT=${KERNEL_VIRT:=false} +KERNEL_BPF=${KERNEL_BPF:=false} +KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=powersave} +KERNEL_SECURITY=${KERNEL_SECURITY:=false} +KERNEL_NF=${KERNEL_NF:=false} # Kernel compilation from source directory settings KERNELSRC_DIR=${KERNELSRC_DIR:=""} @@ -297,6 +321,17 @@ case "$RPI_MODEL" in ;; esac +if [ "$ENABLE_UBOOTUSB" = true ] ; then + if [ "$ENABLE_UBOOT" = false ] ; then + echo "error: Enabling UBOOTUSB requires u-boot to be enabled" + exit 1 + fi + if [ "$RPI_MODEL" != 3 ] || [ "$RPI_MODEL" != 3P ] ; then + echo "error: Enabling UBOOTUSB requires Raspberry 3" + exit 1 + fi +fi + # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then # Include bluetooth packages on supported boards @@ -314,6 +349,11 @@ else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard fi fi +if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then + echo "error: You have to compile kernel sources, if you want to enable nexmon" + exit 1 +fi + # Prepare date string for default image file name DATE="$(date +%Y-%m-%d)" if [ -z "$KERNEL_BRANCH" ] ; then @@ -335,6 +375,11 @@ if [ "$ENABLE_VIDEOCORE" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" fi +# Add deps for nexmon +if [ "$ENABLE_NEXMON" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool" +fi + # Add libncurses5 to enable kernel menuconfig if [ "$KERNEL_MENUCONFIG" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" @@ -388,6 +433,11 @@ if [ -n "$SSH_USER_PUB_KEY" ] ; then fi fi +if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then + echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON" + exit 1 +fi + # Check if all required packages are installed on the build system for package in $REQUIRED_PACKAGES ; do if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then @@ -444,6 +494,12 @@ if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then exit 1 fi +# Check if specified NEXMONSRC_DIR directory exists +if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then + echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!" + exit 1 +fi + # Check if specified CHROOT_SCRIPTS directory exists if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" @@ -495,6 +551,10 @@ fi if [ "$ENABLE_IPTABLES" = true ] ; then APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" fi +# Add apparmor for KERNEL_SECURITY +if [ "$KERNEL_SECURITY" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl" +fi # Add openssh server package if [ "$ENABLE_SSHD" = true ] ; then @@ -548,16 +608,6 @@ if [ "$ENABLE_SYSVINIT" = false ] ; then APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" fi -# Check if kernel is getting compiled -if [ "$BUILD_KERNEL" = false ] ; then - echo "Downloading precompiled kernel" - echo "error: not configured" - exit 1; -# BUILD_KERNEL=true -else - echo "No precompiled kernel repositories were added" -fi - # Configure kernel sources if no KERNELSRC_DIR if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then KERNELSRC_CONFIG=true