Skip to content

Commit

Permalink
Introduction of Raspberry Pi OS
Browse files Browse the repository at this point in the history
* Replace raspbian by raspios due to renaming of the OS
* (beta) Added initial support for building 64-bit images
* Set default runlevel to multi-user.target, disable auto-login
* Update documentation

Signed-off-by: Holger Friedrich <[email protected]>
  • Loading branch information
holgerfriedrich committed Jun 17, 2020
1 parent 0eaaa06 commit 0a31499
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 11 deletions.
4 changes: 3 additions & 1 deletion build-image/first-boot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ fail_inprogress() {
exit 1
}

echo "$(timestamp) [openHABian] Starting the openHABian initial setup."
###### start ######
sleep 5
echo -e "\n\n$(timestamp) [openHABian] Starting the openHABian initial setup."
rm -f /opt/openHABian-install-failed
touch /opt/openHABian-install-inprogress

Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions build-image/openhabian.pi-raspios64beta.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Modify your openHABian settings
# Handle with care, only touch if you need to!!

hostname=openhab
username=openhabian
userpw=openhabian

# Language and time. Be sure to set these to valid values
timeserver=0.pool.ntp.org
locales="en_US.UTF-8 de_DE.UTF-8"
system_default_locale="en_US.UTF-8"
#timezone=Europe/Berlin

# Wi-Fi settings. An ethernet connection is recommended
# Requirement: RPi4, RPi3, RPi0W or a supported external Wi-Fi dongle
# Fill in your SSID and password below, leave empty to use ethernet
# ATTENTION: you need to escape these special characters: $, `, ", \, (newline)
# 'Escaping' means to put an additional \ in front of that character
wifi_ssid=""
wifi_psk=""

# Wi-Fi setting. Select a two-letter country code suitable for your location
# E.g. US (default), DE, AU, NZ...
# You may infringe on local legislature otherwise
# See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 or /usr/share/zoneinfo/zone.tab
wifi_country=""

# Eventually disable all IPv6 e.g. on installation problems
# values: "enable", "disable"
ipv6=enable

# repo to clone from (if not master for build and test)
repositoryurl=https://github.com/openhab/openhabian.git
clonebranch=stable

# debug verbosity mode
# off, on (verbose output in log) or maximum (show every command)
# as long as image is still beta, default to on
debugmode=on

# Hardware
# pi0, pi0w, pi1, cm1, pi2, pi3, cm3, pi3+, cm3+, pi4
#hw=pi3

# Hardware architecture
# x86_64, amd64, armv6l, armv7l, aarch64, arm64
#hwarch=armv7l

# OS Release
# ubuntu, raspbian, debian
# stretch, buster
# bionic, focal
#release=buster

# Java architecture mode
# Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64"
java_opt=Zulu11-64

# vim: filetype=sh
44 changes: 34 additions & 10 deletions build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

usage() {
echo -e "Usage: $(basename "$0") <platform> [dev-git|dev-url] <branch> <url>"
echo -e "\\nCurrently supported platforms: rpi"
echo -e "\\nCurrently supported platforms: rpi, rpi64 (beta)"
}

##########################
Expand Down Expand Up @@ -141,9 +141,13 @@ echo_process "This script will build the openHABian image file."

# Identify hardware platform
if [ "$1" == "rpi" ]; then
hw_platform="pi-raspbian"
hw_platform="pi-raspios32"
echo_process "Hardware platform: Raspberry Pi (rpi)"

elif [ "$1" == "rpi64" ]; then
hw_platform="pi-raspios64beta"
echo_process "Hardware platform: Raspberry Pi (rpi64) - BETA -"

elif [ "$1" == "pine64" ]; then
hw_platform="pine64-xenial"
echo_process "Hardware platform: Pine A64 (pine64)"
Expand Down Expand Up @@ -265,7 +269,17 @@ if [ "$hw_platform" == "pine64-xenial" ]; then
if mv $buildfolder/xenial-pine64-*.img $imagefile; then echo "OK"; else echo "FAILED"; exit 1; fi

# Build Raspberry Pi image
elif [ "$hw_platform" == "pi-raspbian" ]; then
elif [ "$hw_platform" == "pi-raspios32" ] || [ "$hw_platform" == "pi-raspios64beta" ]; then
if [ "$hw_platform" == "pi-raspios64beta" ]; then
zipfile=raspios_lite_arm64_latest.zip
baseurl="https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip"
bits=64
else
zipfile=raspios_lite_armhf_latest.zip
baseurl="https://downloads.raspberrypi.org/raspios_lite_armhf_latest"
bits=32
fi

# Prerequisites
echo_process "Checking prerequisites... "
REQ_COMMANDS="git wget unzip crc32 dos2unix xz"
Expand All @@ -286,16 +300,16 @@ elif [ "$hw_platform" == "pi-raspbian" ]; then
fi
check_command_availability_and_exit "$REQ_COMMANDS" "$REQ_PACKAGES"

if [ -f "raspbian.zip" ]; then
echo_process "Using local copy of Raspbian Lite image, raspbian.zip... "
cp raspbian.zip $buildfolder/raspbian.zip
if [ -f "$zipfile" ]; then
echo_process "Using local copy of Raspberry Pi OS ($bits-bit) Lite image, $zipfile... "
cp $zipfile "$buildfolder/$zipfile"
else
echo_process "Downloading latest Raspbian Lite image (no local copy raspbian.zip found)... "
wget -nv -O $buildfolder/raspbian.zip "https://downloads.raspberrypi.org/raspbian_lite_latest"
echo_process "Downloading latest Raspberry Pi OS ($bits-bit) Lite image (no local copy of $zipfile found)... "
wget -nv -O "$buildfolder/$zipfile" "$baseurl"
fi
echo_process "Unpacking image... "
unzip $buildfolder/raspbian.zip -d $buildfolder
mv $buildfolder/*raspbian*.img $imagefile
unzip $buildfolder/$zipfile -d $buildfolder
mv $buildfolder/*-rasp*.img $imagefile

echo_process "Mounting the image for modifications... "
mkdir -p $buildfolder/boot $buildfolder/root
Expand All @@ -309,6 +323,16 @@ elif [ "$hw_platform" == "pi-raspbian" ]; then
echo_process "Injecting 'openhabian-installer.service', 'first-boot.bash' and 'openhabian.conf'... "
cp $sourcefolder/openhabian-installer.service $buildfolder/root/etc/systemd/system/
ln -s $buildfolder/root/etc/systemd/system/openhabian-installer.service $buildfolder/root/etc/systemd/system/multi-user.target.wants/openhabian-installer.service

echo_process "Setting default runlevel multiuser.target... "
( # open a subshell, returns to current dir automatically
cd $buildfolder/root/etc/systemd/system/ || exit 1
rm -rf default.target
ln -s ../../../lib/systemd/system/multi-user.target default.target
# disable autologin
rm -f $buildfolder/root/etc/systemd/system/[email protected]/autologin.conf
)

touch $buildfolder/root/opt/openHABian-install-inprogress
# maybe we should use a trap to get this done in case of error
umount_image_file_root "$imagefile" "$buildfolder"
Expand Down
6 changes: 6 additions & 0 deletions functions/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,17 @@ is_ubuntu() {
[[ $(cat /etc/*release*) =~ "Ubuntu" ]]
return $?
}
# introduction of Raspberry Pi OS:
# 32 bit returns false (1)
# 64 bit returns true (0)
is_debian() {
if [[ "$release" == "debian" ]]; then return 0; fi
[[ $(cat /etc/*release*) =~ "Debian" ]]
return $?
}
# introduction of Raspberry Pi OS:
# 32 bit returns true (0)
# 64 bit returns false (1)
is_raspbian() {
if [[ "$release" == "raspbian" ]]; then return 0; fi
[[ "$(cat /etc/*release*)" =~ "Raspbian" ]]
Expand Down

0 comments on commit 0a31499

Please sign in to comment.