diff options
author | Jan Wagner <mail@jwagner.eu> | 2016-03-13 22:48:59 +0100 |
---|---|---|
committer | Jan Wagner <mail@jwagner.eu> | 2016-03-13 22:48:59 +0100 |
commit | 9d88180e4b8d9e36b5116fc17f2408c1a592e968 (patch) | |
tree | a2320d5220ae64f6c0e8879f0f2459508cf6c566 /bootstrap.d | |
parent | b855bcffebe13327660e4e7955de5e38018bcb90 (diff) | |
download | rpi2-gen-image-9d88180e4b8d9e36b5116fc17f2408c1a592e968.tar.gz rpi2-gen-image-9d88180e4b8d9e36b5116fc17f2408c1a592e968.tar.bz2 rpi2-gen-image-9d88180e4b8d9e36b5116fc17f2408c1a592e968.zip |
Added: KERNEL_SRCDIR, path-checks, code-cleanup
Diffstat (limited to 'bootstrap.d')
-rw-r--r-- | bootstrap.d/11-apt.sh | 1 | ||||
-rw-r--r-- | bootstrap.d/13-kernel.sh | 45 | ||||
-rw-r--r-- | bootstrap.d/30-security.sh | 4 | ||||
-rw-r--r-- | bootstrap.d/31-logging.sh | 4 | ||||
-rw-r--r-- | bootstrap.d/41-uboot.sh | 4 | ||||
-rw-r--r-- | bootstrap.d/42-fbturbo.sh | 8 |
6 files changed, 45 insertions, 21 deletions
diff --git a/bootstrap.d/11-apt.sh b/bootstrap.d/11-apt.sh index 3ee51d8..f3a642e 100644 --- a/bootstrap.d/11-apt.sh +++ b/bootstrap.d/11-apt.sh @@ -27,3 +27,4 @@ sed -i "s/ jessie/ ${RELEASE}/" $R/etc/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 +chroot_exec apt-get -qq -y check diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index 8ec8856..5163f0d 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -7,32 +7,55 @@ # Fetch and build latest raspberry kernel if [ "$BUILD_KERNEL" = true ] ; then - # Fetch current raspberrypi kernel sources - git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux + # Setup source directory + mkdir -p $R/usr/src - # Load default raspberry kernel configuration - make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} bcm2709_defconfig + # Copy existing kernel sources into chroot directory + if [ -n "$KERNEL_SRCDIR" ] && [ -d "$KERNEL_SRCDIR" ] ; then + # Copy kernel sources + cp -r "${KERNEL_SRCDIR}" "${R}/usr/src" + + # Clean the kernel sources + if [ "$KERNEL_CLEANSRC" = true ] ; then + make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} mrproper + fi + else # KERNEL_SRCDIR="" + # Fetch current raspberrypi kernel sources + git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux + fi # Calculate optimal number of kernel building threads - if [ "$KERNEL_THREADS" = 1 ] ; then - if [ -f /proc/cpuinfo ] ; then + if [ "$KERNEL_THREADS" = "1" ] ; then + if [ -r /proc/cpuinfo ] ; then KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) fi fi - # Start menu-driven kernel configuration (interactive) - if [ "$KERNEL_MENUCONFIG" = true ] ; then - make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig + if [ "$KERNEL_CONFIGSRC" = true ] ; then + # Load default raspberry kernel configuration + make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} ${KERNEL_DEFCONFIG} + + # Start menu-driven kernel configuration (interactive) + if [ "$KERNEL_MENUCONFIG" = true ] ; then + make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig + fi fi # Cross compile kernel and modules make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} zImage modules dtbs + # Check if kernel compilation was successful + if [ ! -r $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage ] ; then + echo "error: kernel compilation failed!" + cleanup + exit 1 + fi + # Install kernel modules make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=../../.. modules_install # Install kernel headers - if [ "$KERNEL_HEADERS" = true ]; then + if [ "$KERNEL_HEADERS" = true ] ; then make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_HDR_PATH=../.. headers_install fi @@ -47,7 +70,7 @@ if [ "$BUILD_KERNEL" = true ] ; then cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README $R/boot/firmware/overlays/ # Remove kernel sources - if [ "$KERNEL_RMSRC" = true ]; then + if [ "$KERNEL_RMSRC" = true ] ; then rm -fr $R/usr/src/linux fi diff --git a/bootstrap.d/30-security.sh b/bootstrap.d/30-security.sh index 3f25e4e..2bdacd9 100644 --- a/bootstrap.d/30-security.sh +++ b/bootstrap.d/30-security.sh @@ -15,10 +15,10 @@ if [ "$ENABLE_USER" = true ] ; then fi # Setup root password or not -if [ "$ENABLE_ROOT" = true ]; then +if [ "$ENABLE_ROOT" = true ] ; then chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root - if [ "$ENABLE_ROOT_SSH" = true ]; then + if [ "$ENABLE_ROOT_SSH" = true ] ; then sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" $R/etc/ssh/sshd_config fi else diff --git a/bootstrap.d/31-logging.sh b/bootstrap.d/31-logging.sh index cfb99a2..740161b 100644 --- a/bootstrap.d/31-logging.sh +++ b/bootstrap.d/31-logging.sh @@ -6,8 +6,8 @@ . ./functions.sh # Disable rsyslog -if [ "$ENABLE_RSYSLOG" = false ]; then +if [ "$ENABLE_RSYSLOG" = false ] ; then sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" $R/etc/systemd/journald.conf chroot_exec systemctl disable rsyslog - chroot_exec apt-get purge -q -y --force-yes rsyslog + chroot_exec apt-get -qq -y --force-yes purge rsyslog fi diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh index 0767452..4968bdd 100644 --- a/bootstrap.d/41-uboot.sh +++ b/bootstrap.d/41-uboot.sh @@ -6,8 +6,8 @@ . ./functions.sh # Install gcc/c++ build environment inside the chroot -if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then - chroot_exec apt-get install -q -y --force-yes --no-install-recommends linux-compiler-gcc-4.9-arm g++ make bc +if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ] ; then + chroot_exec apt-get -q -y --force-yes --no-install-recommends install linux-compiler-gcc-4.9-arm g++ make bc fi # Fetch and build U-Boot bootloader diff --git a/bootstrap.d/42-fbturbo.sh b/bootstrap.d/42-fbturbo.sh index 2ed523b..c02b38f 100644 --- a/bootstrap.d/42-fbturbo.sh +++ b/bootstrap.d/42-fbturbo.sh @@ -10,7 +10,7 @@ if [ "$ENABLE_FBTURBO" = true ] ; then git -C $R/tmp clone https://github.com/ssvb/xf86-video-fbturbo.git # Install Xorg build dependencies - chroot_exec apt-get install -q -y --no-install-recommends xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev + chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev # Build and install fbturbo driver inside chroot chroot_exec /bin/bash -x <<'EOF' @@ -25,10 +25,10 @@ EOF install_readonly files/xorg/99-fbturbo.conf $R/usr/share/X11/xorg.conf.d/99-fbturbo.conf # Remove Xorg build dependencies - chroot_exec apt-get -q -y purge --auto-remove xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev + chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev fi # Remove gcc/c++ build environment from the chroot -if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then - chroot_exec apt-get -y -q purge --auto-remove bc binutils cpp cpp-4.9 g++ g++-4.9 gcc gcc-4.9 libasan1 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libgcc-4.9-dev libgomp1 libisl10 libmpc3 libmpfr4 libstdc++-4.9-dev libubsan0 linux-compiler-gcc-4.9-arm linux-libc-dev make +if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ] ; then + chroot_exec apt-get -qq -y --auto-remove purge bc binutils cpp cpp-4.9 g++ g++-4.9 gcc gcc-4.9 libasan1 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libgcc-4.9-dev libgomp1 libisl10 libmpc3 libmpfr4 libstdc++-4.9-dev libubsan0 linux-compiler-gcc-4.9-arm linux-libc-dev make fi |