##// END OF EJS Templates
Renamed FIRMWAREDIR parameter to RPI_FIRMWARE_DIR
Renamed FIRMWAREDIR parameter to RPI_FIRMWARE_DIR

Fichier de la dernière révision:

r95:735ddd320fa7
r98:f7bc32d5b6e1
Show More
rpi23-gen-image.sh
570 lines | 17.6 KiB | application/x-sh | BashLexer
Jan Wagner
first public release
r2 #!/bin/sh
########################################################################
drtyhlpr
Added Raspberry Pi 3 model support
r94 # rpi23-gen-image.sh 2015-2016
Jan Wagner
first public release
r2 #
drtyhlpr
Added Raspberry Pi 3 model support
r94 # Advanced Debian "jessie" and "stretch" bootstrap script for RPi2/3
Jan Wagner
first public release
r2 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
drtyhlpr
Fixed: DEFLOCAL now works with MINBASE, author added on request
r88 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
#
# Big thanks for patches and enhancements by 10+ github contributors!
Jan Wagner
first public release
r2 ########################################################################
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Are we running as root?
if [ "$(id -u)" -ne "0" ] ; then
echo "error: this script must be executed with root privileges!"
exit 1
fi
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 # Check if ./functions.sh script exists
if [ ! -r "./functions.sh" ] ; then
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 echo "error: './functions.sh' required script not found!"
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 exit 1
fi
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 # Load utility functions
. ./functions.sh
Filip Pytloun
Option to disable rsyslog and improvements (also security)...
r45
Jan Wagner
code cleanup and even more spliting
r70 # Introduce settings
Jan Wagner
first public release
r2 set -e
drtyhlpr
Added Raspberry Pi 3 model support
r94 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
Jan Wagner
first public release
r2 set -x
drtyhlpr
Added Raspberry Pi 3 model support
r94 # Raspberry Pi model configuration
RPI_MODEL=${RPI_MODEL:=2}
RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
Jan Wagner
fix: ENABLE_SOUND
r21 # Debian release
Jan Wagner
first public release
r2 RELEASE=${RELEASE:=jessie}
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 KERNEL_ARCH=${KERNEL_ARCH:=arm}
RELEASE_ARCH=${RELEASE_ARCH:=armhf}
CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
Jan Wagner
first public release
r2
drtyhlpr
Added ENABLE_NONFREE support and more
r91 # URLs
KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
drtyhlpr
Added Raspberry Pi 3 model support
r94 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm}
drtyhlpr
Added ENABLE_NONFREE support and more
r91 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:=git://git.denx.de/u-boot.git}
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Build directories
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 BASEDIR="$(pwd)/images/${RELEASE}"
BUILDDIR="${BASEDIR}/build"
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82
# Chroot directories
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 R="${BUILDDIR}/chroot"
drtyhlpr
Added Raspberry Pi 3 model support
r94 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"
Jan Wagner
first public release
r2
Stephen A. Brandli
Added FIRMWAREDIR option to use local copy of firmware.
r83 # Firmware directory: Blank if download from github
drtyhlpr
Added Raspberry Pi 3 model support
r94 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
drtyhlpr
Fixes for Debian stretch release support
r93
Jan Wagner
first public release
r2 # General settings
drtyhlpr
Added Raspberry Pi 3 model support
r94 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
Jan Wagner
first public release
r2 PASSWORD=${PASSWORD:=raspberry}
DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
Jan Wagner
fix for a upcomming merge
r32 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
Filip Pytloun
Option to expand partition and rootfs on first boot...
r46 EXPANDROOT=${EXPANDROOT:=true}
Jan Wagner
first public release
r2
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 # Keyboard settings
XKB_MODEL=${XKB_MODEL:=""}
XKB_LAYOUT=${XKB_LAYOUT:=""}
XKB_VARIANT=${XKB_VARIANT:=""}
XKB_OPTIONS=${XKB_OPTIONS:=""}
# Network settings (DHCP)
Vincent Knecht
Add support for static network configuration.
r25 ENABLE_DHCP=${ENABLE_DHCP:=true}
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67
# Network settings (static)
Vincent Knecht
Add support for static network configuration.
r25 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:=""}
Jan Wagner
first public release
r2 # APT settings
APT_PROXY=${APT_PROXY:=""}
APT_SERVER=${APT_SERVER:="ftp.debian.org"}
# Feature settings
ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
ENABLE_IPV6=${ENABLE_IPV6:=true}
ENABLE_SSHD=${ENABLE_SSHD:=true}
drtyhlpr
Added ENABLE_NONFREE support and more
r91 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
drtyhlpr
Added Raspberry Pi 3 model support
r94 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
Jan Wagner
first public release
r2 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}
Jan Wagner
Replaced: ENABLE_FLUXBOX -\> ENABLE_WM
r22 ENABLE_WM=${ENABLE_WM:=""}
Filip Pytloun
Option to disable rsyslog and improvements (also security)...
r45 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
ENABLE_USER=${ENABLE_USER:=true}
Stephen A. Brandli
Added custom user name (other than "pi")
r84 USER_NAME=${USER_NAME:="pi"}
Filip Pytloun
Option to disable rsyslog and improvements (also security)...
r45 ENABLE_ROOT=${ENABLE_ROOT:=false}
ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
Jan Wagner
first public release
r2
# Advanced settings
Jan Wagner
Added: ENABLE_MINBASE, Fix: Use systemd-networkd
r16 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
drtyhlpr
fixed typo
r90 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
Jan Wagner
Added ENABLE_UBOOT support
r3 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
Jan Wagner
Added: ENABLE_FBTURBO
r20 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
Jan Wagner
first public release
r2 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
drtyhlpr
Added Debian stretch release support
r92 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
Jan Wagner
first public release
r2
Jan Wagner
Added: BUILD_KERNEL - build latest rpi2 kernel
r55 # Kernel compilation settings
BUILD_KERNEL=${BUILD_KERNEL:=false}
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 KERNEL_THREADS=${KERNEL_THREADS:=1}
Filip Pytloun
Enhance kernel build by headers install, parallelism and cleanup
r60 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
# Kernel compilation from source directory settings
KERNELSRC_DIR=${KERNELSRC_DIR:=""}
KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
Jan Wagner
Added: BUILD_KERNEL - build latest rpi2 kernel
r55
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Reduce disk usage settings
REDUCE_APT=${REDUCE_APT:=true}
REDUCE_DOC=${REDUCE_DOC:=true}
REDUCE_MAN=${REDUCE_MAN:=true}
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 REDUCE_VIM=${REDUCE_VIM:=false}
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 REDUCE_BASH=${REDUCE_BASH:=false}
REDUCE_HWDB=${REDUCE_HWDB:=true}
REDUCE_SSHD=${REDUCE_SSHD:=true}
REDUCE_LOCALE=${REDUCE_LOCALE:=true}
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Encrypted filesystem settings
ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
# Stop the Crypto Wars
DISABLE_FBI=${DISABLE_FBI:=false}
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Chroot scripts directory
Chris Landa
Added functionality to run custom scripts after base bootstrap
r40 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
Jan Wagner
first public release
r2
Jan Wagner
Added: ENABLE_FBTURBO
r20 # Packages required in the chroot build environment
Chris Landa
Added functionality to add custom packages to APT_INCLUDES
r39 APT_INCLUDES=${APT_INCLUDES:=""}
drtyhlpr
Added Debian stretch release support
r92 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
Jan Wagner
first public release
r2
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Packages required for bootstrapping
Axel Beckert
Use package git instead of git-core: Don't pull in obsolete packages...
r79 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git"
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 MISSING_PACKAGES=""
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 set +x
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72
drtyhlpr
Added Raspberry Pi 3 model support
r94 # Set Raspberry Pi model specific configuration
if [ "$RPI_MODEL" = 2 ] ; then
DTB_FILE=${RPI2_DTB_FILE}
UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
elif [ "$RPI_MODEL" = 3 ] ; then
DTB_FILE=${RPI3_DTB_FILE}
UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
drtyhlpr
Added Debian stretch release support
r92 BUILD_KERNEL=true
drtyhlpr
Added Raspberry Pi 3 model support
r94 else
echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
exit 1
fi
# Check if the internal wireless interface is supported by the RPi model
if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" != 3 ] ; then
echo "error: The selected Raspberry Pi model has no internal wireless interface"
exit 1
fi
# Set compiler packages and build RPi2/3 Linux kernel if required by Debian release
if [ "$RELEASE" = "jessie" ] ; then
COMPILER_PACKAGES="linux-compiler-gcc-4.8-arm g++ make bc"
elif [ "$RELEASE" = "stretch" ] ; then
COMPILER_PACKAGES="linux-compiler-gcc-5-arm g++ make bc"
BUILD_KERNEL=true
else
echo "error: Debian release ${RELEASE} is not supported!"
exit 1
drtyhlpr
Added Debian stretch release support
r92 fi
Jan Wagner
Added: BUILD_KERNEL - build latest rpi2 kernel
r55 # Add packages required for kernel cross compilation
if [ "$BUILD_KERNEL" = true ] ; then
REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 fi
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Add libncurses5 to enable kernel menuconfig
if [ "$KERNEL_MENUCONFIG" = true ] ; then
REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
Jan Wagner
Added: BUILD_KERNEL - build latest rpi2 kernel
r55 fi
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Stop the Crypto Wars
if [ "$DISABLE_FBI" = true ] ; then
ENABLE_CRYPTFS=true
fi
# Add cryptsetup package to enable filesystem encryption
if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
APT_INCLUDES="${APT_INCLUDES},cryptsetup"
if [ -z "$CRYPTFS_PASSWORD" ] ; then
echo "error: no password defined (CRYPTFS_PASSWORD)!"
exit 1
fi
ENABLE_INITRAMFS=true
fi
# Add initramfs generation tools
if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
fi
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Check if all required packages are installed on the build system
Jan Wagner
fix: confirm y/n installation of required packages
r8 for package in $REQUIRED_PACKAGES ; do
if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
Jan Wagner
fix: confirm y/n installation of required packages
r8 fi
done
Jan Wagner
fix: collabora keyring fix
r10 # Ask if missing packages should get installed right now
Jan Wagner
fix: confirm y/n installation of required packages
r8 if [ -n "$MISSING_PACKAGES" ] ; then
echo "the following packages needed by this script are not installed:"
echo "$MISSING_PACKAGES"
echo -n "\ndo you want to install the missing packages right now? [y/n] "
read confirm
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 [ "$confirm" != "y" ] && exit 1
Jan Wagner
fix: confirm y/n installation of required packages
r8 fi
Jan Wagner
fix: collabora keyring fix
r10 # Make sure all required packages are installed
Jan Wagner
fix: confirm y/n installation of required packages
r8 apt-get -qq -y install ${REQUIRED_PACKAGES}
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Check if ./bootstrap.d directory exists
if [ ! -d "./bootstrap.d/" ] ; then
echo "error: './bootstrap.d' required directory not found!"
exit 1
fi
# Check if ./files directory exists
if [ ! -d "./files/" ] ; then
echo "error: './files' required directory not found!"
exit 1
fi
# Check if specified KERNELSRC_DIR directory exists
if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_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)!"
exit 1
fi
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Check if specified device mapping already exists (will be used by cryptsetup)
if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
exit 1
fi
Jan Wagner
first public release
r2 # Don't clobber an old build
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 if [ -e "$BUILDDIR" ] ; then
echo "error: directory ${BUILDDIR} already exists, not proceeding"
exit 1
fi
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 # Setup chroot directory
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 mkdir -p "${R}"
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 # Check if build directory has enough of free disk space >512MB
if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
Jan Wagner
first public release
r2 exit 1
fi
set -x
# Call "cleanup" function on various signals and errors
trap cleanup 0 1 2 3 6
Jan Wagner
Added: ENABLE_MINBASE, Fix: Use systemd-networkd
r16 # Add required packages for the minbase installation
drtyhlpr
Fixed: DEFLOCAL/MINBASE better fix
r89 if [ "$ENABLE_MINBASE" = true ] ; then
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
drtyhlpr
Fixed: DEFLOCAL/MINBASE better fix
r89 fi
# Add required locales packages
if [ "$DEFLOCAL" != "en_US.UTF-8" ] ; then
Vincent Knecht
Added support for keyboard configuration
r27 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
Jan Wagner
Added: ENABLE_MINBASE, Fix: Use systemd-networkd
r16 fi
Filip Pytloun
Option to expand partition and rootfs on first boot...
r46 # Add parted package, required to get partprobe utility
if [ "$EXPANDROOT" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},parted"
fi
Jan Wagner
first public release
r2 # Add dbus package, recommended if using systemd
if [ "$ENABLE_DBUS" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},dbus"
fi
Jan Wagner
fix: ENABLE_IPTABLES
r17 # Add iptables IPv4/IPv6 package
if [ "$ENABLE_IPTABLES" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},iptables"
fi
Jan Wagner
first public release
r2 # Add openssh server package
if [ "$ENABLE_SSHD" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},openssh-server"
fi
Jan Wagner
fix: ENABLE_SOUND
r21 # Add alsa-utils package
if [ "$ENABLE_SOUND" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},alsa-utils"
fi
Jan Wagner
first public release
r2 # Add rng-tools package
if [ "$ENABLE_HWRANDOM" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},rng-tools"
fi
Jan Wagner
Added: ENABLE_FBTURBO
r20 # Add fbturbo video driver
if [ "$ENABLE_FBTURBO" = true ] ; then
# Enable xorg package dependencies
ENABLE_XORG=true
fi
Jan Wagner
Replaced: ENABLE_FLUXBOX -\> ENABLE_WM
r22 # Add user defined window manager package
if [ -n "$ENABLE_WM" ] ; then
APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
Jan Wagner
fix: ENABLE_IPTABLES
r17
Jan Wagner
Added: ENABLE_FBTURBO
r20 # Enable xorg package dependencies
Jan Wagner
fix: ENABLE_IPTABLES
r17 ENABLE_XORG=true
fi
# Add xorg package
if [ "$ENABLE_XORG" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},xorg"
Jan Wagner
first public release
r2 fi
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Replace selected packages with smaller clones
if [ "$ENABLE_REDUCE" = true ] ; then
# Add levee package instead of vim-tiny
if [ "$REDUCE_VIM" = true ] ; then
APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
fi
# Add dropbear package instead of openssh-server
if [ "$REDUCE_SSHD" = true ] ; then
APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
fi
fi
# Configure kernel sources if no KERNELSRC_DIR
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
KERNELSRC_CONFIG=true
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 fi
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Configure reduced kernel
if [ "$KERNEL_REDUCE" = true ] ; then
KERNELSRC_CONFIG=false
fi
# Execute bootstrap scripts
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 for SCRIPT in bootstrap.d/*.sh; do
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 head -n 3 "$SCRIPT"
. "$SCRIPT"
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 done
Jan Wagner
Added ENABLE_UBOOT support
r3
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 ## Execute custom bootstrap scripts
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 if [ -d "custom.d" ] ; then
for SCRIPT in custom.d/*.sh; do
Jan Wagner
Added: KERNELSRC_PREBUILT, KERNELSRC_ rename, fix-quotes
r75 . "$SCRIPT"
Jan Wagner
fix: custom.d directory error
r63 done
fi
Jan Wagner
Added ENABLE_UBOOT support
r3
Jan Wagner
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
r76 # Execute custom scripts inside the chroot
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
Chris Landa
Added functionality to run custom scripts after base bootstrap
r40 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
Jan Wagner
Added: KERNEL_SRCDIR, path-checks, code-cleanup
r72 chroot_exec /bin/bash -x <<'EOF'
for SCRIPT in /chroot_scripts/* ; do
if [ -f $SCRIPT -a -x $SCRIPT ] ; then
$SCRIPT
fi
done
EOF
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 rm -rf "${R}/chroot_scripts"
Chris Landa
Added functionality to run custom scripts after base bootstrap
r40 fi
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73 # Remove apt-utils
drtyhlpr
Fixes for Debian stretch release support
r93 if [ "$RELEASE" = "jessie" ] ; then
chroot_exec apt-get purge -qq -y --force-yes apt-utils
fi
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Generate required machine-id
MACHINE_ID=$(dbus-uuidgen)
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
drtyhlpr
Added Raspberry Pi 3 model support
r94 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73 # APT Cleanup
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 chroot_exec apt-get -y clean
chroot_exec apt-get -y autoclean
chroot_exec apt-get -y autoremove
Jan Wagner
first public release
r2 # Unmount mounted filesystems
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 umount -l "${R}/proc"
umount -l "${R}/sys"
Jan Wagner
first public release
r2
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73 # Clean up directories
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 rm -rf "${R}/run/*"
rm -rf "${R}/tmp/*"
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73
Jan Wagner
first public release
r2 # Clean up files
drtyhlpr
Added Raspberry Pi 3 model support
r94 rm -f "${ETC_DIR}/ssh/ssh_host_*"
rm -f "${ETC_DIR}/dropbear/dropbear_*"
rm -f "${ETC_DIR}/apt/sources.list.save"
rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
rm -f "${ETC_DIR}/*-"
rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
rm -f "${ETC_DIR}/resolv.conf"
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 rm -f "${R}/root/.bash_history"
rm -f "${R}/var/lib/urandom/random-seed"
rm -f "${R}/initrd.img"
rm -f "${R}/vmlinuz"
Jan Wagner
Added: ENABLE_REDUCE - down to 160MB used space,fix-resolve,fix-machineid
r73 rm -f "${R}${QEMU_BINARY}"
Jan Wagner
first public release
r2
Chris Landa
Make the rootfs partition 20% bigger than the used size of the chroot directory
r41 # Calculate size of the chroot directory in KB
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
Jan Wagner
first public release
r2
Chris Landa
Make the rootfs partition 20% bigger than the used size of the chroot directory
r41 # Calculate the amount of needed 512 Byte sectors
TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
Jan Wagner
first public release
r2
Chris Landa
Make the rootfs partition 20% bigger than the used size of the chroot directory
r41 # The root partition is EXT4
# This means more space than the actual used space of the chroot is used.
drtyhlpr
Fixes for Debian stretch release support
r93 # As overhead for journaling and reserved blocks 25% are added.
ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 25) \* 1024 \/ 512)
Chris Landa
Make the rootfs partition 20% bigger than the used size of the chroot directory
r41
# Calculate required image size in 512 Byte sectors
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
Jan Wagner
first public release
r2
# Prepare date string for image file name
DATE="$(date +%Y-%m-%d)"
# Prepare image file
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 if [ "$ENABLE_SPLITFS" = true ] ; then
dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS}
dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS}
dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77
# Write firmware/boot partition tables
sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" 2> /dev/null <<EOM
${TABLE_SECTORS},${FRMW_SECTORS},c,*
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 EOM
Jan Wagner
first public release
r2
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Write root partition table
sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" 2> /dev/null <<EOM
${TABLE_SECTORS},${ROOT_SECTORS},83
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 EOM
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Setup temporary loop devices
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)"
ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)"
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 else # ENABLE_SPLITFS=false
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
Jan Wagner
first public release
r2
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 # Write partition table
sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" 2> /dev/null <<EOM
${TABLE_SECTORS},${FRMW_SECTORS},c,*
${ROOT_OFFSET},${ROOT_SECTORS},83
Jan Wagner
first public release
r2 EOM
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Setup temporary loop devices
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
fi
Jan Wagner
first public release
r2
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77 if [ "$ENABLE_CRYPTFS" = true ] ; then
# Create dummy ext4 fs
mkfs.ext4 "$ROOT_LOOP"
# Setup password keyfile
echo -n ${CRYPTFS_PASSWORD} > .password
Jan Wagner
shred-fix
r78 chmod 600 .password
Jan Wagner
Added: ENABLE_CRYPTFS - encrypted rootfs, use-latest-bootloader, cp-cleanup
r77
# Initialize encrypted partition
echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
# Open encrypted partition and setup mapping
cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
# Secure delete password keyfile
shred -zu .password
# Update temporary loop device
ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
# Wipe encrypted partition (encryption cipher is used for randomness)
dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
fi
Vincent Knecht
Added ENABLE_SPLITFS option to produce distinct /boot/firmware and root images
r66 # Build filesystems
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 mkfs.vfat "$FRMW_LOOP"
mkfs.ext4 "$ROOT_LOOP"
Jan Wagner
first public release
r2
# Mount the temporary loop devices
mkdir -p "$BUILDDIR/mount"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 mount "$ROOT_LOOP" "$BUILDDIR/mount"
Jan Wagner
first public release
r2
mkdir -p "$BUILDDIR/mount/boot/firmware"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
Jan Wagner
first public release
r2
# Copy all files from the chroot to the loop device mount point directory
Jan Wagner
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup
r82 rsync -a "${R}/" "$BUILDDIR/mount/"
Jan Wagner
first public release
r2
# Unmount all temporary loop devices and mount points
cleanup
Jan Wagner
vknecht-master-merge
r68 # Create block map file(s) of image(s)
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 if [ "$ENABLE_SPLITFS" = true ] ; then
Jan Wagner
vknecht-master-merge
r68 # Create block map files for "bmaptool"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img"
bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img"
Jan Wagner
first public release
r2
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 # Image was successfully created
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
echo "$BASEDIR/${DATE}-debian-${RELEASE}-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 else
Jan Wagner
vknecht-master-merge
r68 # Create block map file for "bmaptool"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
Jan Wagner
first public release
r2
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 # Image was successfully created
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
Vincent Knecht
Added ENABLE_SPLITFS option to create distinct images for firmware and root partitions
r65 fi