diff --git a/bootstrap.d/10-bootstrap.sh b/bootstrap.d/10-bootstrap.sh index c4d229a..7a5315c 100644 --- a/bootstrap.d/10-bootstrap.sh +++ b/bootstrap.d/10-bootstrap.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Debootstrap basic system # @@ -8,7 +7,6 @@ VARIANT="" COMPONENTS="main" -EXCLUDES="" # Use non-free Debian packages if needed if [ "$ENABLE_NONFREE" = true ] ; then @@ -20,13 +18,8 @@ if [ "$ENABLE_MINBASE" = true ] ; then VARIANT="--variant=minbase" fi -# Exclude packages if required by Debian release -if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - EXCLUDES="--exclude=init,systemd-sysv" -fi - # Base debootstrap (unpack only) -http_proxy=${APT_PROXY} debootstrap ${EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}" +http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}" # Copy qemu emulator binary to chroot install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" diff --git a/bootstrap.d/11-apt.sh b/bootstrap.d/11-apt.sh index 5dc9ca3..b833dfa 100644 --- a/bootstrap.d/11-apt.sh +++ b/bootstrap.d/11-apt.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup APT repositories # @@ -21,11 +20,6 @@ else echo "No precompiled kernel repositories were added" fi -#ipinfo=$(curl ipinfo.io | grep country ) -#grep -o '\"[^"]*\"' $ipinfo | tr -d '"' -#grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) -#sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" - # Upgrade package index and update all installed packages and changed dependencies chroot_exec apt-get -qq -y update chroot_exec apt-get -qq -y -u dist-upgrade diff --git a/bootstrap.d/12-locale.sh b/bootstrap.d/12-locale.sh index b7481e0..c469ec3 100644 --- a/bootstrap.d/12-locale.sh +++ b/bootstrap.d/12-locale.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup Locales and keyboard settings # @@ -11,7 +10,6 @@ echo "${TIMEZONE}" > "${ETC_DIR}/timezone" chroot_exec dpkg-reconfigure -f noninteractive tzdata # Install and setup default locale and keyboard configuration - if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957 diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index e077315..fd18094 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Build and Setup RPi2/3 Kernel # @@ -109,7 +108,7 @@ if [ "$BUILD_KERNEL" = true ] ; then echo "CONFIG_CRYPTO_XTS=y" echo "CONFIG_CRYPTO_SHA512=y" echo "CONFIG_CRYPTO_MANAGER=y" - } >> "${KERNEL_DIR}"/.config + } >> ${KERNEL_DIR}/.config fi fi @@ -241,7 +240,8 @@ if [ "$BUILD_KERNEL" = true ] ; then chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" fi fi -elif [ "$BUILD_KERNEL" = false ] ; then + +else # BUILD_KERNEL=false echo " Install precompiled kernel..." echo "error: not implemented" # Check if kernel installation was successful diff --git a/bootstrap.d/14-fstab.sh b/bootstrap.d/14-fstab.sh index 8d20dda..c954ce6 100644 --- a/bootstrap.d/14-fstab.sh +++ b/bootstrap.d/14-fstab.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup fstab and initramfs # @@ -63,4 +62,3 @@ if [ "$BUILD_KERNEL" = true ] && [ "$ENABLE_INITRAMFS" = true ] ; then chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" fi fi - diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 066c284..42f3b36 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup RPi2/3 config and cmdline # @@ -122,7 +121,7 @@ install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf" # Load hardware random module at boot if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then - sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" + sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" fi # Load sound module at boot @@ -159,4 +158,3 @@ install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi # Install sysctl.d configuration files install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" - diff --git a/bootstrap.d/20-networking.sh b/bootstrap.d/20-networking.sh index 2ae1d86..d53b78b 100644 --- a/bootstrap.d/20-networking.sh +++ b/bootstrap.d/20-networking.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup Networking # diff --git a/bootstrap.d/21-firewall.sh b/bootstrap.d/21-firewall.sh index f193050..d078ba1 100644 --- a/bootstrap.d/21-firewall.sh +++ b/bootstrap.d/21-firewall.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup Firewall # @@ -10,6 +9,8 @@ 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 if ! [ "$RELEASE" = jessie ] ; then chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy fi diff --git a/bootstrap.d/30-security.sh b/bootstrap.d/30-security.sh index 3a9f1c9..5fbfc7a 100644 --- a/bootstrap.d/30-security.sh +++ b/bootstrap.d/30-security.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup users and security settings # @@ -12,8 +11,8 @@ ENCRYPTED_USER_PASSWORD=$(mkpasswd -m sha-512 "${USER_PASSWORD}") # Setup default user if [ "$ENABLE_USER" = true ] ; then - chroot_exec adduser --gecos "$USER_NAME" --add_extra_groups --disabled-password "$USER_NAME" - chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" "$USER_NAME" + chroot_exec adduser --gecos $USER_NAME --add_extra_groups --disabled-password $USER_NAME + chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" $USER_NAME fi # Setup root password or not diff --git a/bootstrap.d/31-logging.sh b/bootstrap.d/31-logging.sh index 6995c32..0e2415e 100644 --- a/bootstrap.d/31-logging.sh +++ b/bootstrap.d/31-logging.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup Logging # diff --git a/bootstrap.d/32-sshd.sh b/bootstrap.d/32-sshd.sh index 2f7baf4..9d28d51 100644 --- a/bootstrap.d/32-sshd.sh +++ b/bootstrap.d/32-sshd.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Setup SSH settings and public keys # @@ -114,4 +113,4 @@ if [ "$ENABLE_SSHD" = true ] ; then if [ "$ENABLE_REDUCE" = true ] && [ "$REDUCE_SSHD" = true ] ; then sed "s|^DROPBEAR_EXTRA_ARGS=.*|DROPBEAR_EXTRA_ARGS=\"${DROPBEAR_ARGS}\"|g" "${ETC_DIR}/default/dropbear" fi -fi +fi \ No newline at end of file diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh index c279257..992e532 100644 --- a/bootstrap.d/41-uboot.sh +++ b/bootstrap.d/41-uboot.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Build and Setup U-Boot # @@ -40,6 +39,7 @@ if [ "$ENABLE_UBOOT" = true ] ; then install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" + # Install and setup U-Boot command file install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" @@ -58,9 +58,9 @@ if [ "$ENABLE_UBOOT" = true ] ; then sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" if [ "$BUILD_KERNEL" = false ] ; then - # Remove dtbfile from U-Boot mkfile - sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" - printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" + # Remove dtbfile from U-Boot mkfile + sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" + printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" else printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" fi @@ -80,14 +80,14 @@ if [ "$ENABLE_UBOOT" = true ] ; then sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" fi + # Set mkfile to use the correct dtb file + sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" + # Set mkfile to use the correct mach id if [ "$ENABLE_QEMU" = true ] ; then sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" fi - # Set mkfile to use the correct dtb file - sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" - # Set mkfile to use kernel image sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" diff --git a/bootstrap.d/42-fbturbo.sh b/bootstrap.d/42-fbturbo.sh index 88ea809..a5ede42 100644 --- a/bootstrap.d/42-fbturbo.sh +++ b/bootstrap.d/42-fbturbo.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Build and Setup fbturbo Xorg driver # diff --git a/bootstrap.d/50-firstboot.sh b/bootstrap.d/50-firstboot.sh index d7c3162..cc76f34 100644 --- a/bootstrap.d/50-firstboot.sh +++ b/bootstrap.d/50-firstboot.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # First boot actions # diff --git a/bootstrap.d/99-reduce.sh b/bootstrap.d/99-reduce.sh index dcf39d0..25ec9fe 100644 --- a/bootstrap.d/99-reduce.sh +++ b/bootstrap.d/99-reduce.sh @@ -1,4 +1,3 @@ -#!/bin/bash # # Reduce system disk usage # diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index bfa83bc..e0ba54a 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -49,136 +49,137 @@ export RELEASE=${RELEASE:=buster} export KERNEL_BRANCH=${KERNEL_BRANCH:=""} # URLs -export KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} -export FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} -export WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} -export FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} -export UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} -export VIDEOCORE_URL=${VIDEOCORE_URL=https://github.com/raspberrypi/userland} - -# Firmware directory: Blank if download from github -export RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} +KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} +FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} +WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} +COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} +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} # Build directories -export BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} -export BUILDDIR="${BASEDIR}/build" +BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} +BUILDDIR="${BASEDIR}/build" # Prepare date string for default image file name DATE="$(date +%Y-%m-%d)" if [ -z "$KERNEL_BRANCH" ] ; then - export IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} + IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} else - export IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} + IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} fi # Chroot directories -export R="${BUILDDIR}/chroot" -export ETC_DIR="${R}/etc" -export LIB_DIR="${R}/lib" -export BOOT_DIR="${R}/boot/firmware" -export KERNEL_DIR="${R}/usr/src/linux" -export WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm" +R="${BUILDDIR}/chroot" +ETC_DIR="${R}/etc" +LIB_DIR="${R}/lib" +BOOT_DIR="${R}/boot/firmware" +KERNEL_DIR="${R}/usr/src/linux" +WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm" +# Firmware directory: Blank if download from github +RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} # General settings -export SET_ARCH=${SET_ARCH:=32} -export HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} -export PASSWORD=${PASSWORD:=raspberry} -export USER_PASSWORD=${USER_PASSWORD:=raspberry} -export DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} -export TIMEZONE=${TIMEZONE:="Europe/Berlin"} -export EXPANDROOT=${EXPANDROOT:=true} +SET_ARCH=${SET_ARCH:=32} +HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} +PASSWORD=${PASSWORD:=raspberry} +USER_PASSWORD=${USER_PASSWORD:=raspberry} +DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} +TIMEZONE=${TIMEZONE:="Europe/Berlin"} +EXPANDROOT=${EXPANDROOT:=true} # Keyboard settings -export XKB_MODEL=${XKB_MODEL:=""} -export XKB_LAYOUT=${XKB_LAYOUT:=""} -export XKB_VARIANT=${XKB_VARIANT:=""} -export XKB_OPTIONS=${XKB_OPTIONS:=""} +XKB_MODEL=${XKB_MODEL:=""} +XKB_LAYOUT=${XKB_LAYOUT:=""} +XKB_VARIANT=${XKB_VARIANT:=""} +XKB_OPTIONS=${XKB_OPTIONS:=""} # Network settings (DHCP) -export ENABLE_DHCP=${ENABLE_DHCP:=true} +ENABLE_DHCP=${ENABLE_DHCP:=true} # Network settings (static) -export NET_ADDRESS=${NET_ADDRESS:=""} -export NET_GATEWAY=${NET_GATEWAY:=""} -export NET_DNS_1=${NET_DNS_1:=""} -export NET_DNS_2=${NET_DNS_2:=""} -export NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} -export NET_NTP_1=${NET_NTP_1:=""} -export NET_NTP_2=${NET_NTP_2:=""} +NET_ADDRESS=${NET_ADDRESS:=""} +NET_GATEWAY=${NET_GATEWAY:=""} +NET_DNS_1=${NET_DNS_1:=""} +NET_DNS_2=${NET_DNS_2:=""} +NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} +NET_NTP_1=${NET_NTP_1:=""} +NET_NTP_2=${NET_NTP_2:=""} # APT settings -export APT_PROXY=${APT_PROXY:=""} -export APT_SERVER=${APT_SERVER:="ftp.debian.org"} +APT_PROXY=${APT_PROXY:=""} +APT_SERVER=${APT_SERVER:="ftp.debian.org"} # Feature settings -export ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} -export ENABLE_I2C=${ENABLE_I2C:=false} -export ENABLE_SPI=${ENABLE_SPI:=false} -export ENABLE_IPV6=${ENABLE_IPV6:=true} -export ENABLE_SSHD=${ENABLE_SSHD:=true} -export ENABLE_NONFREE=${ENABLE_NONFREE:=false} -export ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} -export ENABLE_SOUND=${ENABLE_SOUND:=true} -export ENABLE_DBUS=${ENABLE_DBUS:=true} -export ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} -export ENABLE_MINGPU=${ENABLE_MINGPU:=false} -export ENABLE_XORG=${ENABLE_XORG:=false} -export ENABLE_WM=${ENABLE_WM:=""} -export ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} -export ENABLE_USER=${ENABLE_USER:=true} -export USER_NAME=${USER_NAME:="pi"} -export ENABLE_ROOT=${ENABLE_ROOT:=false} -export ENABLE_QEMU=${ENABLE_QEMU:=false} +ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} +ENABLE_I2C=${ENABLE_I2C:=false} +ENABLE_SPI=${ENABLE_SPI:=false} +ENABLE_IPV6=${ENABLE_IPV6:=true} +ENABLE_SSHD=${ENABLE_SSHD:=true} +ENABLE_NONFREE=${ENABLE_NONFREE:=false} +ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} +ENABLE_SOUND=${ENABLE_SOUND:=true} +ENABLE_DBUS=${ENABLE_DBUS:=true} +ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} +ENABLE_MINGPU=${ENABLE_MINGPU:=false} +ENABLE_XORG=${ENABLE_XORG:=false} +ENABLE_WM=${ENABLE_WM:=""} +ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} +ENABLE_USER=${ENABLE_USER:=true} +USER_NAME=${USER_NAME:="pi"} +ENABLE_ROOT=${ENABLE_ROOT:=false} +ENABLE_QEMU=${ENABLE_QEMU:=false} +ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} # SSH settings -export SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} -export SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} -export SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} -export SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} -export SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} +SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} +SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} +SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} +SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} +SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} # Advanced settings -export ENABLE_MINBASE=${ENABLE_MINBASE:=false} -export ENABLE_REDUCE=${ENABLE_REDUCE:=false} -export ENABLE_UBOOT=${ENABLE_UBOOT:=false} -export UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} -export ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} -export ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} -export ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} -export VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} -export FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} -export ENABLE_HARDNET=${ENABLE_HARDNET:=false} -export ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} -export ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} -export ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} -export ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} -export DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} +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:=true} +VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} +FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} +ENABLE_HARDNET=${ENABLE_HARDNET:=false} +ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} +ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} +ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} +ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} +DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} # Kernel compilation settings -export BUILD_KERNEL=${BUILD_KERNEL:=true} -export KERNEL_REDUCE=${KERNEL_REDUCE:=false} -export KERNEL_THREADS=${KERNEL_THREADS:=1} -export KERNEL_HEADERS=${KERNEL_HEADERS:=true} -export KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} -export KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} -export KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} -export KERNEL_CCACHE=${KERNEL_CCACHE:=false} +BUILD_KERNEL=${BUILD_KERNEL:=true} +KERNEL_REDUCE=${KERNEL_REDUCE:=false} +KERNEL_THREADS=${KERNEL_THREADS:=1} +KERNEL_HEADERS=${KERNEL_HEADERS:=true} +KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} +KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} +KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} +KERNEL_CCACHE=${KERNEL_CCACHE:=false} # Kernel compilation from source directory settings -export KERNELSRC_DIR=${KERNELSRC_DIR:=""} -export KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} -export KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} -export KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} +KERNELSRC_DIR=${KERNELSRC_DIR:=""} +KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} +KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} +KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} # Reduce disk usage settings -export REDUCE_APT=${REDUCE_APT:=true} -export REDUCE_DOC=${REDUCE_DOC:=true} -export REDUCE_MAN=${REDUCE_MAN:=true} -export REDUCE_VIM=${REDUCE_VIM:=false} -export REDUCE_BASH=${REDUCE_BASH:=false} -export REDUCE_HWDB=${REDUCE_HWDB:=true} -export REDUCE_SSHD=${REDUCE_SSHD:=true} -export REDUCE_LOCALE=${REDUCE_LOCALE:=true} +REDUCE_APT=${REDUCE_APT:=true} +REDUCE_DOC=${REDUCE_DOC:=true} +REDUCE_MAN=${REDUCE_MAN:=true} +REDUCE_VIM=${REDUCE_VIM:=false} +REDUCE_BASH=${REDUCE_BASH:=false} +REDUCE_HWDB=${REDUCE_HWDB:=true} +REDUCE_SSHD=${REDUCE_SSHD:=true} +REDUCE_LOCALE=${REDUCE_LOCALE:=true} # Encrypted filesystem settings ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} @@ -191,16 +192,20 @@ CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} # Packages required in the chroot build environment -export APT_INCLUDES=${APT_INCLUDES:=""} +APT_INCLUDES=${APT_INCLUDES:=""} APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" # Packages required for bootstrapping -export REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" -export MISSING_PACKAGES="" +REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" +MISSING_PACKAGES="" # Packages installed for c/c++ build environment in chroot (keep empty) -export COMPILER_PACKAGES="" +COMPILER_PACKAGES="" +#ipinfo=$(curl ipinfo.io | grep country ) +#grep -o '\"[^"]*\"' $ipinfo | tr -d '"' +#grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) +#sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" #autconfigure best apt server to not spam ftp.debian.org #rm files/apt/sources.list #netselect-apt does not know buster yet @@ -219,6 +224,8 @@ if [ "$ENABLE_NONFREE" = true ] ; then else netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" fi + +#sed and cut the result string so we can use it as APT_SERVER APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) APT_SERVER=${APT_SERVER::-1} @@ -395,7 +402,7 @@ 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 + if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then MISSING_PACKAGES="${MISSING_PACKAGES} $package" fi done @@ -476,6 +483,8 @@ if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then exit 1 fi +set -x + # Call "cleanup" function on various signals and errors trap cleanup 0 1 2 3 6 @@ -556,11 +565,19 @@ if [ "$KERNEL_REDUCE" = true ] ; then KERNELSRC_CONFIG=false fi -set -x +# Configure qemu compatible kernel +if [ "$ENABLE_QEMU" = true ] ; then + DTB_FILE=vexpress-v2p-ca15_a7.dtb + UBOOT_CONFIG=vexpress_ca15_tc2_defconfig + KERNEL_DEFCONFIG="vexpress_defconfig" + if [ "$KERNEL_MENUCONFIG" = false ] ; then + KERNEL_OLDDEFCONFIG=true + fi +fi # Execute bootstrap scripts for SCRIPT in bootstrap.d/*.sh; do - head -n 4 "$SCRIPT" + head -n 3 "$SCRIPT" . "$SCRIPT" done @@ -620,14 +637,6 @@ rm -f "${R}/vmlinuz" rm -f "${R}${QEMU_BINARY}" if [ "$ENABLE_QEMU" = true ] ; then - # Configure qemu compatible kernel - DTB_FILE=vexpress-v2p-ca15_a7.dtb - UBOOT_CONFIG=vexpress_ca15_tc2_defconfig - KERNEL_DEFCONFIG="vexpress_defconfig" - if [ "$KERNEL_MENUCONFIG" = false ] ; then - KERNEL_OLDDEFCONFIG=true - fi - # Setup QEMU directory mkdir "${BASEDIR}/qemu" @@ -700,12 +709,12 @@ if [ "$ENABLE_SPLITFS" = true ] ; then # Write firmware/boot partition tables sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null < /dev/null < /dev/null < .password + echo -n ${CRYPTFS_PASSWORD} > .password # Initialize encrypted partition echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password