Permalink
Browse files

Added Debian stretch release support

  • Loading branch information...
1 parent 491ef8b commit 09d30ea4bc55ca11400507b7d530352b36debf92 @rfswarm rfswarm committed Aug 6, 2016
View
@@ -1,6 +1,6 @@
# rpi2-gen-image
## Introduction
-`rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time only supports the bootstrapping of the current stable Debian 8 "jessie" release.
+`rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch".
## Build dependencies
The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user.
@@ -22,6 +22,7 @@ BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi2-gen-image.sh
ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
+RELEASE=stretch BUILD_KERNEL=true ./rpi2-gen-image.sh
```
#### APT settings:
@@ -35,6 +36,9 @@ Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will sp
A comma separated list of additional packages to be installed during bootstrapping.
#### General system settings:
+##### `RELEASE`="jessie"
+Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". `BUILD_KERNEL`=true will automatically be set if the Debian release `stretch` is used.
+
##### `HOSTNAME`="rpi2-jessie"
Set system host name. It's recommended that the host name is unique in the corresponding subnet.
@@ -171,6 +175,9 @@ Path to a directory with scripts that should be run in the chroot before the ima
##### `ENABLE_INITRAMFS`=false
Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
+##### `ENABLE_IFNAMES`=true
+Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian release `stretch` is used.
+
#### Kernel compilation:
##### `BUILD_KERNEL`=false
Build and install the latest RPi2 Linux kernel. Currently only the default RPi2 kernel configuration is used.
@@ -7,6 +7,7 @@
VARIANT=""
COMPONENTS="main"
+EXCLUDES=""
# Use non-free Debian packages if needed
if [ "$ENABLE_NONFREE" = true ] ; then
@@ -18,8 +19,13 @@ if [ "$ENABLE_MINBASE" = true ] ; then
VARIANT="--variant=minbase"
fi
+# Exclude packages if required by Debian release
+if [ "$RELEASE" = "stretch" ] ; then
+ EXCLUDES="--exclude=init,systemd-sysv"
+fi
+
# Base debootstrap (unpack only)
-http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian"
+http_proxy=${APT_PROXY} debootstrap ${EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian"
# Copy qemu emulator binary to chroot
install_exec "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
@@ -34,4 +40,8 @@ chroot_exec /debootstrap/debootstrap --second-stage
# Mount required filesystems
mount -t proc none "${R}/proc"
mount -t sysfs none "${R}/sys"
-mount --bind /dev/pts "${R}/dev/pts"
+
+# Mount pseudo terminal slave if supported by Debian release
+if [ -d "${R}/dev/pts" ] ; then
+ mount --bind /dev/pts "${R}/dev/pts"
+fi
View
@@ -171,9 +171,9 @@ fi
# Setup firmware boot cmdline
if [ "$ENABLE_SPLITFS" = true ] ; then
- CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
+ CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
else
- CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
+ CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
fi
# Add encrypted root partition to cmdline.txt
@@ -195,6 +195,18 @@ if [ "$ENABLE_IPV6" = false ] ; then
CMDLINE="${CMDLINE} ipv6.disable=1"
fi
+# Automatically assign predictable network interface names
+if [ "$ENABLE_IFNAMES" = false ] ; then
+ CMDLINE="${CMDLINE} net.ifnames=0"
+else
+ CMDLINE="${CMDLINE} net.ifnames=1"
+fi
+
+# Set init to systemd if required by Debian release
+if [ "$RELEASE" = "stretch" ] ; then
+ CMDLINE="${CMDLINE} init=/bin/systemd"
+fi
+
# Install firmware boot cmdline
echo "${CMDLINE}" > "${BOOTDIR}/cmdline.txt"
@@ -56,6 +56,12 @@ fi
# Remove empty settings from network configuration
sed -i "/.*=\$/d" "${ETCDIR}/systemd/network/eth.network"
+# Move systemd network configuration if required by Debian release
+if [ "$RELEASE" = "stretch" ] ; then
+ mv -v "${ETCDIR}/systemd/network/eth.network" "${LIBDIR}/systemd/network/10-eth.network"
+ rm -fr "${ETCDIR}/systemd/network"
+fi
+
# Enable systemd-networkd service
chroot_exec systemctl enable systemd-networkd
@@ -29,10 +29,20 @@ cat files/firstboot/24-generate-machineid.sh >> "${ETCDIR}/rc.firstboot"
# Create /etc/resolv.conf symlink
cat files/firstboot/25-create-resolv-symlink.sh >> "${ETCDIR}/rc.firstboot"
+# Configure automatic network interface names
+if [ "$ENABLE_IFNAMES" = true ] ; then
+ cat files/firstboot/26-config-ifnames.sh >> "${ETCDIR}/rc.firstboot"
+fi
+
# Finalize rc.firstboot script
cat files/firstboot/99-finish.sh >> "${ETCDIR}/rc.firstboot"
chmod +x "${ETCDIR}/rc.firstboot"
+# Install default rc.local if it does not exist
+if [ ! -f "${ETCDIR}/rc.local" ] ; then
+ install_exec files/etc/rc.local "${ETCDIR}/rc.local"
+fi
+
# Add rc.firstboot script to rc.local
sed -i '/exit 0/d' "${ETCDIR}/rc.local"
echo /etc/rc.firstboot >> "${ETCDIR}/rc.local"
View
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+#
+# By default this script does nothing.
+
+exit 0
@@ -0,0 +1,13 @@
+logger -t "rc.firstboot" "Configuring network interface name"
+
+INTERFACE_NAME=$(dmesg | grep "renamed from eth0" | awk -F ":| " '{ print $9 }')
+
+if [ ! -z INTERFACE_NAME ] ; then
+ if [ -r "/etc/systemd/network/eth.network" ] ; then
+ sed -i "s/eth0/${INTERFACE_NAME}/" /etc/systemd/network/eth.network
+ fi
+
+ if [ -r "/lib/systemd/network/10-eth.network" ] ; then
+ sed -i "s/eth0/${INTERFACE_NAME}/" /lib/systemd/network/10-eth.network
+ fi
+fi
@@ -1,3 +1,7 @@
+logger -t "rc.firstboot" "Reload systemd manager configuration"
+systemctl daemon-reload
+systemctl restart networking.service
+systemctl restart systemd-networkd.service
logger -t "rc.firstboot" "First boot actions finished"
rm -f /etc/rc.firstboot
sed -i '/.*rc.firstboot/d' /etc/rc.local
View
@@ -3,7 +3,7 @@
########################################################################
# rpi2-gen-image.sh 2015-2016
#
-# Advanced debian "jessie" bootstrap script for RPi2
+# Advanced Debian "jessie" and "stretch" bootstrap script for RPi2
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -61,6 +61,7 @@ BUILDDIR="${BASEDIR}/build"
# Chroot directories
R="${BUILDDIR}/chroot"
ETCDIR="${R}/etc"
+LIBDIR="${R}/lib"
BOOTDIR="${R}/boot/firmware"
KERNELDIR="${R}/usr/src/linux"
@@ -122,6 +123,7 @@ 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}
# Kernel compilation settings
BUILD_KERNEL=${BUILD_KERNEL:=false}
@@ -162,14 +164,19 @@ CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
# Packages required in the chroot build environment
APT_INCLUDES=${APT_INCLUDES:=""}
-APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo"
+APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
# Packages required for bootstrapping
REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git"
MISSING_PACKAGES=""
set +x
+# Build latest RPi2 Linux kernel if required by Debian release
+if [ "$RELEASE" = "stretch" ] ; then
+ BUILD_KERNEL=true
+fi
+
# Add packages required for kernel cross compilation
if [ "$BUILD_KERNEL" = true ] ; then
REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"

0 comments on commit 09d30ea

Please sign in to comment.