diff --git a/.gitignore b/.gitignore index ec91fd6..d9926f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ deploy/* work/* config +postrun.sh SKIP .pc *-pc diff --git a/README.md b/README.md index 2c6748e..f38ff56 100755 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ IMG_NAME='Hassbian' ## Docker Build ```bash -vi config # Edit your config file. See above. +nano config # Edit your config file. See above. ./build-docker.sh ``` If everything goes well, your finished image will be in the `deploy/` folder. @@ -99,7 +99,7 @@ maintenance and allows for more easy customization. specific packages are installed, permissions are set and users created. This is the only stage we add to the original build script. - The original **Stage 3** and **Stage 4** are removed since they are not + The original **Stage 4** and **Stage 5** are removed since they are not used on the HASSbian image. ### Stage specification @@ -112,3 +112,4 @@ Then remove the `EXPORT*` files from `./stage4` (if building up to stage 2) or f $ touch ./stage3/SKIP $ rm stage3/EXPORT* ``` +If you wish to build further configurations upon (for example) the lite system, you can also delete the contents of `./stage3` and `./stage4` and replace with your own contents in the same format. diff --git a/build.sh b/build.sh index 2656be8..25a8539 100755 --- a/build.sh +++ b/build.sh @@ -67,10 +67,10 @@ EOF ./${i}-run.sh log "End ${SUB_STAGE_DIR}/${i}-run.sh" fi - if [ -f ${i}-run-chroot ]; then - log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot" - on_chroot < ${i}-run-chroot - log "End ${SUB_STAGE_DIR}/${i}-run-chroot" + if [ -f ${i}-run-chroot.sh ]; then + log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot.sh" + on_chroot < ${i}-run-chroot.sh + log "End ${SUB_STAGE_DIR}/${i}-run-chroot.sh" fi done popd > /dev/null @@ -132,8 +132,8 @@ export IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"} export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export SCRIPT_DIR="${BASE_DIR}/scripts" -export WORK_DIR="${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}" -export DEPLOY_DIR="${BASE_DIR}/deploy" +export WORK_DIR=${WORK_DIR:-"${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}"} +export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"} export LOG_FILE="${WORK_DIR}/build.log" export CLEAN @@ -148,6 +148,8 @@ export PREV_STAGE_DIR export ROOTFS_DIR export PREV_ROOTFS_DIR export IMG_SUFFIX +export NOOBS_NAME +export NOOBS_DESCRIPTION export EXPORT_DIR export EXPORT_ROOTFS_DIR @@ -172,13 +174,21 @@ done CLEAN=1 for EXPORT_DIR in ${EXPORT_DIRS}; do STAGE_DIR=${BASE_DIR}/export-image - IMG_SUFFIX=$(cat ${EXPORT_DIR}/EXPORT_IMAGE) + source "${EXPORT_DIR}/EXPORT_IMAGE" EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename ${EXPORT_DIR})/rootfs run_stage if [ -e ${EXPORT_DIR}/EXPORT_NOOBS ]; then + source ${EXPORT_DIR}/EXPORT_NOOBS STAGE_DIR=${BASE_DIR}/export-noobs run_stage fi done +if [ -x postrun.sh ]; then + log "Begin postrun.sh" + cd "${BASE_DIR}" + ./postrun.sh + log "End postrun.sh" +fi + log "End ${BASE_DIR}" diff --git a/export-image/03-set-partuuid/00-run.sh b/export-image/03-set-partuuid/00-run.sh new file mode 100755 index 0000000..f19884e --- /dev/null +++ b/export-image/03-set-partuuid/00-run.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e +IMG_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img" + +IMGID="$(fdisk -l ${IMG_FILE} | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p')" + +BOOT_PARTUUID="${IMGID}-01" +ROOT_PARTUUID="${IMGID}-02" + +sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" ${ROOTFS_DIR}/etc/fstab +sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" ${ROOTFS_DIR}/etc/fstab + +sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" ${ROOTFS_DIR}/boot/cmdline.txt diff --git a/export-image/03-finalise/01-run.sh b/export-image/04-finalise/01-run.sh similarity index 67% rename from export-image/03-finalise/01-run.sh rename to export-image/04-finalise/01-run.sh index c64c92b..2de42ca 100755 --- a/export-image/03-finalise/01-run.sh +++ b/export-image/04-finalise/01-run.sh @@ -18,6 +18,29 @@ if [ -e ${ROOTFS_DIR}/etc/ld.so.preload.disabled ]; then mv ${ROOTFS_DIR}/etc/ld.so.preload.disabled ${ROOTFS_DIR}/etc/ld.so.preload fi +rm -f ${ROOTFS_DIR}/etc/apt/sources.list~ +rm -f ${ROOTFS_DIR}/etc/apt/trusted.gpg~ + +rm -f ${ROOTFS_DIR}/etc/passwd- +rm -f ${ROOTFS_DIR}/etc/group- +rm -f ${ROOTFS_DIR}/etc/shadow- +rm -f ${ROOTFS_DIR}/etc/gshadow- + +rm -f ${ROOTFS_DIR}/var/cache/debconf/*-old +rm -f ${ROOTFS_DIR}/var/lib/dpkg/*-old + +rm -f ${ROOTFS_DIR}/usr/share/icons/*/icon-theme.cache + +rm -f ${ROOTFS_DIR}/var/lib/dbus/machine-id + +true > ${ROOTFS_DIR}/etc/machine-id + +for _FILE in $(find ${ROOTFS_DIR}/var/log/ -type f); do + true > ${_FILE} +done + +rm -f "${ROOTFS_DIR}/root/.vnc/private.key" + update_issue $(basename ${EXPORT_DIR}) install -m 644 ${ROOTFS_DIR}/etc/rpi-issue ${ROOTFS_DIR}/boot/issue.txt install files/LICENSE.oracle ${ROOTFS_DIR}/boot/ diff --git a/export-image/03-finalise/files/LICENSE.oracle b/export-image/04-finalise/files/LICENSE.oracle similarity index 100% rename from export-image/03-finalise/files/LICENSE.oracle rename to export-image/04-finalise/files/LICENSE.oracle diff --git a/export-image/prerun.sh b/export-image/prerun.sh index a3581b3..661fc4e 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -8,19 +8,19 @@ rm -f ${IMG_FILE} rm -rf ${ROOTFS_DIR} mkdir -p ${ROOTFS_DIR} -BOOT_SIZE=$(du -sh ${EXPORT_ROOTFS_DIR}/boot -B M | cut -f 1 | tr -d M) -TOTAL_SIZE=$(du -sh ${EXPORT_ROOTFS_DIR} -B M | cut -f 1 | tr -d M) +BOOT_SIZE=$(du -s ${EXPORT_ROOTFS_DIR}/boot --block-size=1 | cut -f 1) +TOTAL_SIZE=$(du -s ${EXPORT_ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1) -IMG_SIZE=$(expr $BOOT_SIZE \* 2 \+ $TOTAL_SIZE \+ 512)M +IMG_SIZE=$((BOOT_SIZE + TOTAL_SIZE + (400 * 1024 * 1024))) fallocate -l ${IMG_SIZE} ${IMG_FILE} -fdisk ${IMG_FILE} > /dev/null 2>&1 < /dev/null +mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null mkfs.ext4 -O ^huge_file $ROOT_DEV > /dev/null mount -v $ROOT_DEV ${ROOTFS_DIR} -t ext4 mkdir -p ${ROOTFS_DIR}/boot mount -v $BOOT_DEV ${ROOTFS_DIR}/boot -t vfat -rsync -aHAXx ${EXPORT_ROOTFS_DIR}/ ${ROOTFS_DIR}/ +rsync -aHAXx --exclude var/cache/apt/archives ${EXPORT_ROOTFS_DIR}/ ${ROOTFS_DIR}/ diff --git a/export-noobs/00-release/00-run.sh b/export-noobs/00-release/00-run.sh index dab3d8c..25f62fd 100755 --- a/export-noobs/00-release/00-run.sh +++ b/export-noobs/00-release/00-run.sh @@ -5,7 +5,7 @@ NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}" install -v -m 744 files/partition_setup.sh ${NOOBS_DIR}/ install -v files/partitions.json ${NOOBS_DIR}/ install -v files/os.json ${NOOBS_DIR}/ -install -v files/Raspbian.png ${NOOBS_DIR}/ +install -v files/OS.png ${NOOBS_DIR}/ install -v files/release_notes.txt ${NOOBS_DIR}/ tar -v -c -C files/marketing -f ${NOOBS_DIR}/marketing.tar . @@ -19,13 +19,18 @@ ROOT_SIZE=$(expr ${ROOT_SIZE} / 1000000 \+ 1) BOOT_NOM=$(expr ${BOOT_SIZE} \* 3) ROOT_NOM=$(expr ${ROOT_SIZE} \+ 400) +mv "${NOOBS_DIR}/OS.png" "${NOOBS_DIR}/$(echo ${NOOBS_NAME} | sed 's/ /_/g').png" + sed ${NOOBS_DIR}/partitions.json -i -e "s|BOOT_SIZE|${BOOT_SIZE}|" sed ${NOOBS_DIR}/partitions.json -i -e "s|ROOT_SIZE|${ROOT_SIZE}|" sed ${NOOBS_DIR}/partitions.json -i -e "s|BOOT_NOM|${BOOT_NOM}|" sed ${NOOBS_DIR}/partitions.json -i -e "s|ROOT_NOM|${ROOT_NOM}|" -sed ${NOOBS_DIR}/release_notes.txt -i -e "s|UNRELEASED|${IMG_DATE}|" sed ${NOOBS_DIR}/os.json -i -e "s|UNRELEASED|${IMG_DATE}|" +sed ${NOOBS_DIR}/os.json -i -e "s|NOOBS_NAME|${NOOBS_NAME}|" +sed ${NOOBS_DIR}/os.json -i -e "s|NOOBS_DESCRIPTION|${NOOBS_DESCRIPTION}|" + +sed ${NOOBS_DIR}/release_notes.txt -i -e "s|UNRELEASED|${IMG_DATE}|" cp -a ${NOOBS_DIR} ${DEPLOY_DIR}/ diff --git a/export-noobs/00-release/files/Raspbian.png b/export-noobs/00-release/files/OS.png similarity index 100% rename from export-noobs/00-release/files/Raspbian.png rename to export-noobs/00-release/files/OS.png diff --git a/export-noobs/00-release/files/os.json b/export-noobs/00-release/files/os.json index 9f88da1..a667a09 100644 --- a/export-noobs/00-release/files/os.json +++ b/export-noobs/00-release/files/os.json @@ -1,8 +1,8 @@ { - "description": "A community-created port of Debian jessie for the Raspberry Pi", + "description": "NOOBS_DESCRIPTION", "feature_level": 35120124, "kernel": "4.4", - "name": "Raspbian", + "name": "NOOBS_NAME", "password": "raspberry", "release_date": "UNRELEASED", "supported_hex_revisions": "2,3,4,5,6,7,8,9,d,e,f,10,11,12,14,19,1040,1041,0092,0093,2082", diff --git a/export-noobs/00-release/files/partition_setup.sh b/export-noobs/00-release/files/partition_setup.sh index edc66b8..81cef4d 100644 --- a/export-noobs/00-release/files/partition_setup.sh +++ b/export-noobs/00-release/files/partition_setup.sh @@ -12,10 +12,22 @@ mkdir -p /tmp/1 /tmp/2 mount "$part1" /tmp/1 mount "$part2" /tmp/2 -sed /tmp/1/cmdline.txt -i -e "s|root=/dev/[^ ]*|root=${part2}|" +sed /tmp/1/cmdline.txt -i -e "s|root=[^ ]*|root=${part2}|" sed /tmp/2/etc/fstab -i -e "s|^.* / |${part2} / |" sed /tmp/2/etc/fstab -i -e "s|^.* /boot |${part1} /boot |" +if [ -f /mnt/ssh ]; then + cp /mnt/ssh /tmp/1/ +fi + +if [ -f /mnt/ssh.txt ]; then + cp /mnt/ssh.txt /tmp/1/ +fi + +if [ -f /settings/wpa_supplicant.conf ]; then + cp /settings/wpa_supplicant.conf /tmp/1/ +fi + if ! grep -q resize /proc/cmdline; then sed -i 's| quiet init=/usr/lib/raspi-config/init_resize.sh||' /tmp/1/cmdline.txt fi diff --git a/export-noobs/00-release/files/partitions.json b/export-noobs/00-release/files/partitions.json index 908f82d..c2e2bcb 100644 --- a/export-noobs/00-release/files/partitions.json +++ b/export-noobs/00-release/files/partitions.json @@ -3,6 +3,7 @@ { "filesystem_type": "FAT", "label": "boot", + "mkfs_options": "-F 32", "partition_size_nominal": BOOT_NOM, "uncompressed_tarball_size": BOOT_SIZE, "want_maximised": false diff --git a/export-noobs/00-release/files/release_notes.txt b/export-noobs/00-release/files/release_notes.txt index 4d06294..e3c8feb 100644 --- a/export-noobs/00-release/files/release_notes.txt +++ b/export-noobs/00-release/files/release_notes.txt @@ -1,4 +1,27 @@ UNRELEASED: + * Wolfram Mathematica updated to version 11.0.1 + * Adobe Flash Player updated to version 25.0.0.127 + * Use PARTUUID to support USB boot +2017-03-02: + * Updated kernel and firmware (final Pi Zero W support) + * Wolfram Mathematica updated to version 11 + * NOOBS installs now checks for presence of 'ssh' file on the NOOBS partition. +2017-02-16: + * Chromium browser updated to version 56 + * Adobe Flash Player updated to version 24.0.0.221 + * RealVNC Server and Viewer updated to version 6.0.2 (RealVNC Connect) + * Sonic Pi updated to version 2.11 + * Node-RED updated to version 0.15.3 + * Scratch updated to version 120117 + * Detection of SSH enabled with default password moved into PAM + * Updated desktop GL driver to support use of fake KMS option + * Raspberry Pi Configuration and raspi-config allow setting of fixed HDMI resolution + * raspi-config allows enabling of serial hardware independent of serial terminal + * Updates to kernel and firmware + * Various minor bug fixes and usability and appearance tweaks +2017-01-11: + * Re-release of the 2016-11-25 image with a FAT32-formatted boot partition +2016-11-25: * SSH disabled by default; can be enabled by creating a file with name "ssh" in boot partition * Prompt for password change at boot when SSH enabled with default password unchanged * Adobe Flash Player included diff --git a/scripts/common b/scripts/common index a67140f..bd18a07 100644 --- a/scripts/common +++ b/scripts/common @@ -28,7 +28,7 @@ copy_previous(){ false fi mkdir -p "${ROOTFS_DIR}" - rsync -aHAXx "${PREV_ROOTFS_DIR}/" "${ROOTFS_DIR}/" + rsync -aHAXx --exclude var/cache/apt/archives "${PREV_ROOTFS_DIR}/" "${ROOTFS_DIR}/" } export -f copy_previous diff --git a/stage1/00-boot-files/files/cmdline.txt b/stage1/00-boot-files/files/cmdline.txt index 45c7f58..2b0634b 100644 --- a/stage1/00-boot-files/files/cmdline.txt +++ b/stage1/00-boot-files/files/cmdline.txt @@ -1 +1 @@ -dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait +dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait diff --git a/stage1/00-boot-files/files/config.txt b/stage1/00-boot-files/files/config.txt index 69dfef2..9c6860c 100644 --- a/stage1/00-boot-files/files/config.txt +++ b/stage1/00-boot-files/files/config.txt @@ -1,5 +1,5 @@ # For more options and information see -# http://www.raspberrypi.org/documentation/configuration/config-txt.md +# http://rpf.io/configtxtreadme # Some settings may impact device functionality. See link above for details # uncomment if you get no picture on HDMI for a default "safe" mode diff --git a/stage1/01-sys-tweaks/files/fstab b/stage1/01-sys-tweaks/files/fstab index 68e5816..f16e3fb 100644 --- a/stage1/01-sys-tweaks/files/fstab +++ b/stage1/01-sys-tweaks/files/fstab @@ -1,3 +1,3 @@ proc /proc proc defaults 0 0 -/dev/mmcblk0p1 /boot vfat defaults 0 2 -/dev/mmcblk0p2 / ext4 defaults,noatime 0 1 +BOOTDEV /boot vfat defaults 0 2 +ROOTDEV / ext4 defaults,noatime 0 1 diff --git a/stage2/01-sys-tweaks/00-debconf b/stage2/01-sys-tweaks/00-debconf index dead1e7..4ad0378 100644 --- a/stage2/01-sys-tweaks/00-debconf +++ b/stage2/01-sys-tweaks/00-debconf @@ -5,8 +5,7 @@ console-setup console-setup/charmap47 select UTF-8 # Choices: . Arabic, # Armenian, # Cyrillic - KOI8-R and KOI8-U, # Cyrillic - non-Slavic languages, # Cyrillic - Slavic languages (also Bosnian and Serbian Latin), . Ethiopic, # Georgian, # Greek, # Hebrew, # Lao, # Latin1 and Latin5 - western Europe and Turkic languages, # Latin2 - central Europe and Romanian, # Latin3 and Latin8 - Chichewa; Esperanto; Irish; Maltese and Welsh, # Latin7 - Lithuanian; Latvian; Maori and Marshallese, . Latin - Vietnamese, # Thai, . Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic, . Combined - Latin; Slavic Cyrillic; Greek, . Combined - Latin; Slavic and non-Slavic Cyrillic, Guess optimal character set console-setup console-setup/codeset47 select Guess optimal character set # Font for the console: -# Choices: Fixed, Goha, GohaClassic, Terminus, TerminusBold, TerminusBoldVGA, VGA, Do not change the boot/kernel font, Let the -system select a suitable font +# Choices: Fixed, Goha, GohaClassic, Terminus, TerminusBold, TerminusBoldVGA, VGA, Do not change the boot/kernel font, Let the system select a suitable font console-setup console-setup/fontface47 select Do not change the boot/kernel font # Geographic area: # Choices: Africa, America, Antarctica, Australia, Arctic Ocean, Asia, Atlantic Ocean, Europe, Indian Ocean, Pacific Ocean, System V timezones, US, None of the above diff --git a/stage2/01-sys-tweaks/00-packages b/stage2/01-sys-tweaks/00-packages index e2535c4..45ff003 100644 --- a/stage2/01-sys-tweaks/00-packages +++ b/stage2/01-sys-tweaks/00-packages @@ -15,3 +15,4 @@ pi-bluetooth apt-listchanges usb-modeswitch apt-transport-https +libpam-chksshpwd diff --git a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff index 97f7c19..0701641 100644 --- a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff +++ b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff @@ -1,5 +1,5 @@ --- a/rootfs/boot/cmdline.txt +++ b/rootfs/boot/cmdline.txt @@ -1 +1 @@ --dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait -+dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh +-dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait ++dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index d1952de..6261b80 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -9,6 +9,7 @@ install -m 644 files/ttyoutput.conf ${ROOTFS_DIR}/etc/systemd/system/rc-local. install -m 644 files/50raspi ${ROOTFS_DIR}/etc/apt/apt.conf.d/ +install -m 644 files/console-setup ${ROOTFS_DIR}/etc/default/ on_chroot << EOF systemctl disable hwclock.sh diff --git a/stage2/01-sys-tweaks/files/console-setup b/stage2/01-sys-tweaks/files/console-setup new file mode 100644 index 0000000..6508cdc --- /dev/null +++ b/stage2/01-sys-tweaks/files/console-setup @@ -0,0 +1,16 @@ +# CONFIGURATION FILE FOR SETUPCON + +# Consult the console-setup(5) manual page. + +ACTIVE_CONSOLES="/dev/tty[1-6]" + +CHARMAP="UTF-8" + +CODESET="guess" +FONTFACE="" +FONTSIZE="" + +VIDEOMODE= + +# The following is an example how to use a braille font +# FONT='lat9w-08.psf.gz brl-8x8.psf' diff --git a/stage2/01-sys-tweaks/files/resize2fs_once b/stage2/01-sys-tweaks/files/resize2fs_once index 7236921..38a4d47 100644 --- a/stage2/01-sys-tweaks/files/resize2fs_once +++ b/stage2/01-sys-tweaks/files/resize2fs_once @@ -12,7 +12,7 @@ case "$1" in start) log_daemon_msg "Starting resize2fs_once" - ROOT_DEV=`grep -Eo 'root=[[:graph:]]+' /proc/cmdline | cut -d '=' -f 2-` && + ROOT_DEV=$(findmnt / -o source -n) && resize2fs $ROOT_DEV && update-rc.d resize2fs_once remove && rm /etc/init.d/resize2fs_once && diff --git a/stage2/03-cleanup/00-run.sh b/stage2/03-cleanup/00-run.sh deleted file mode 100755 index 071a164..0000000 --- a/stage2/03-cleanup/00-run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -e - -on_chroot << EOF -apt-get clean -EOF diff --git a/stage3/00-install-packages/00-packages b/stage3/00-install-packages/00-packages index 01bdd98..2c8854c 100644 --- a/stage3/00-install-packages/00-packages +++ b/stage3/00-install-packages/00-packages @@ -1 +1 @@ -git python3 python3-venv python3-pip bluetooth libbluetooth-dev rng-tools rpi-update htop tmux avahi-daemon +git python3 python3-venv python3-pip bluetooth libbluetooth-dev rng-tools rpi-update htop tmux avahi-daemon libtool autoconf