Skip to content

Commit bbef392

Browse files
committed
Merge branch 'devel'
2 parents d50d417 + 75782de commit bbef392

File tree

11 files changed

+138
-39
lines changed

11 files changed

+138
-39
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/build.conf
2+
/buildroot.conf
23
/bootfs/
34
/config/
45
!/config/apt/custom_sources.txt

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: bash
2+
sudo: false
3+
install: gem install mdl
4+
script:
5+
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
6+
- mdl --verbose --rules '~MD013, ~MD036' .

BUILD.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ On a Debian system those are the following, excluding packages with priority ess
1414
- dosfstools
1515
- binutils
1616
- bc
17+
- cpio
1718

1819
On Debian based systems you can install them as root or with sudo as follows:
1920

@@ -24,11 +25,26 @@ aptitude install git curl bzip2 zip xz-utils gnupg kpartx dosfstools binutils bc
2425
The following scripts are used to build the raspberrypi-ua-netinst installer, listed in the same order they would be used:
2526

2627
- `clean.sh` - Start with a clean slate by removing everything created by earlier builds. This is not needed on a first build, but won't hurt either.
28+
2729
- `update.sh` - Downloads latest Raspbian packages that will be used to build the installer.
30+
2831
- `build.sh` - Builds the installer initramfs and .zip package for Windows/Mac SD card extraction method. Transfer the .zip package to a Windows/Mac computer, then simply unzip it and copy the files onto a FAT formatted SD card.
29-
- `buildroot.sh` - Builds the installer SD card image, it requires root privileges and it makes some assumptions like not having any other loop devices in use. You only need to execute this script if you need more than a .zip package. The script produces an .img package and also its bzip2 and xz compressed versions.
32+
33+
- `buildroot.sh` - Builds the installer SD card image, it requires
34+
root privileges and it makes some assumptions like not having any
35+
other loop devices in use. You only need to execute this script if
36+
you need more than a .zip package. The script produces an .img
37+
package and then its bzip2 and xz compressed versions, but this is
38+
configurable (see below).
3039

3140
To set build options, create a file named `build.conf`, which contains the appropriate variable settings. Supported variables are:
3241

3342
- `mirror_raspbian_cache` - Sets a apt caching proxy for the raspbian.org repository. (e.g. "192.168.0.1:3142")
3443
- `mirror_raspberrypi_cache` - Sets a apt caching proxy for the raspberrypi.org repository. (e.g. "192.168.0.1:3142")
44+
45+
To set buildroot options, create a file named `buildroot.conf`, which contains the appropriate variable settings. Supported variables are:
46+
47+
- `compress_bz2=1` - create a bz2-compressed image
48+
- `compress_xz=1` - create a xz-compressed image
49+
50+
By default both bzip2 and xz compressed versions of the image will be created and the uncompressed image will deleted, but either or both can be disabled. If both are disabled, the uncompressed image will be left in place.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## raspberrypi-ua-netinst v2.2.0
4+
5+
- support for model 3B+
6+
- added installer output via telnet
7+
- improved compatibility with RPi Compute Module 3
8+
- improved SD card compatibility
9+
- added or changed configuration variables
10+
- disable telnet output
11+
- many build improvements and fixes
12+
313
## raspberrypi-ua-netinst v2.1.0
414

515
- moved `cpufrequtils` from base to minimal preset

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016 Andreas Eberlein <[email protected]>
1+
Copyright (c) 2016-2018 Andreas Eberlein <[email protected]>
22
Copyright (c) 2013 Toni Spets <[email protected]>
33

44
Permission to use, copy, modify, and distribute this software for any

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ The installer with the default settings configures eth0 with DHCP to get interne
3030

3131
### Features
3232

33-
- completely unattended, you only need a working internet connection through the ethernet port or use the onboard wireless LAN (supported on model 3B and 0W)
33+
- completely unattended, you only need a working internet connection through the ethernet port or use the onboard wireless LAN (supported on model 3B, 3B+ and 0W)
3434
- DHCP and static IP configuration (DHCP is the default)
3535
- always installs the latest version of Raspbian
3636
- configurable default settings
3737
- extra configuration over HTTP possible - gives unlimited flexibility
3838
- installation takes about **20 minutes** with fast internet from power on to sshd running
3939
- can fit on a 512MB SD card, but 1GB is more reasonable
40-
- default installation includes `fake-hwclock` to save time on shutdown
40+
- default installation includes `fake-hwclock` to save the current time at shutdown
4141
- default installation includes NTP to keep time
4242
- `/tmp` is mounted as tmpfs to improve speed
4343
- no clutter included, you only get the bare essential packages
4444
- option to install root to a USB drive
4545

4646
## Requirements
4747

48-
- a Raspberry Pi (from model 1B up to 3B or Zero including Zero W)
48+
- a Raspberry Pi (from model 1B up to 3B, 3B+ or Zero including Zero W)
4949
- SD card with at least 1GB, or at least 128MB for USB root install (without customization)
5050
- ethernet or wireless LAN with a working internet connection
5151

@@ -74,7 +74,7 @@ If you don't have a display attached, you can monitor the ethernet card LEDs to
7474

7575
If the installation process fails, you will see **SOS** in Morse code (... --- ...) on an led. In this case, power off the Pi and check the log on the sd card.
7676

77-
If you do have a display, you can follow the progress and catch any possible errors in the default configuration or your own modifications.
77+
If you do have a display, you can follow the progress and catch any possible errors in the default configuration or your own modifications. Once a network connection has been established, the process can also be followed via telnet (port 23).
7878

7979
If you have a serial cable connected, installer output can be followed there, too. If 'console=tty1' at then end of the `cmdline.txt` file is removed, you have access to the console in case of problems.
8080

@@ -137,7 +137,7 @@ The default **root** password is **raspbian**.
137137
- Configure your timezone: `dpkg-reconfigure tzdata`
138138

139139
Optional:
140-
Create a swap file with `fallocate -l 512M /swap && mkswap /swap && chmod 600 /swap` (example is 512MB) and enable it on boot by appending `/swap none swap sw 0 0` to `/etc/fstab`.
140+
Create a swap file with `dd if=/dev/zero of=/swap bs=1M count=512 && chmod 600 /swap && mkswap /swap` (example is 512MB) and enable it on boot by appending `/swap none swap sw 0 0` to `/etc/fstab`.
141141

142142
## Logging
143143

build.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ else
2222
zipfile="raspberrypi-ua-netinst-$(date +%Y%m%d).zip"
2323
fi
2424

25-
INSTALL_MODULES="kernel/fs/btrfs/btrfs.ko"
26-
INSTALL_MODULES="$INSTALL_MODULES kernel/drivers/scsi/sg.ko"
25+
INSTALL_MODULES+=("kernel/fs/btrfs/btrfs.ko")
26+
INSTALL_MODULES+=("kernel/drivers/scsi/sg.ko")
2727

2828
# defines array with kernel versions
2929
function get_kernels {
@@ -67,16 +67,16 @@ function check_dependencies {
6767
local dep
6868
# iterate over the passed modules
6969
for mod in "${mods[@]}"; do
70-
# find the modules dependencies, convert into array
71-
mapfile -t deps < <(grep "^${mod}" "${depmod_file}" | cut -d':' -f2)
70+
# find the module's dependencies, convert into array
71+
deps=($(grep "^${mod}" "${depmod_file}" | cut -d':' -f2))
7272
# iterate over the found dependencies
7373
for dep in "${deps[@]}"; do
7474
# check if the dependency is in $modules, if not, add to temp array
75-
contains_element "${dep}" "${modules[@]}" || new_found[${#new_found[@]}]="${dep}"
75+
contains_element "${dep}" "${modules[@]}" || new_found+=("${dep}")
7676
done
7777
done
7878
# add the newly found dependencies to the end of the $modules array
79-
modules=("${modules[@]}" "${new_found[@]}")
79+
modules+=("${new_found[@]}")
8080
# set the global variable to the number of newly found dependencies
8181
new_count=${#new_found[@]}
8282
}
@@ -410,6 +410,9 @@ function create_cpio {
410410
cp --preserve=xattr,timestamps tmp/etc/rpc rootfs/etc/
411411
cp --preserve=xattr,timestamps tmp/etc/services rootfs/etc/
412412

413+
# netcat-openbsd
414+
cp --preserve=xattr,timestamps tmp/bin/nc.openbsd rootfs/bin/nc
415+
413416
# ntpdate components
414417
cp --preserve=xattr,timestamps tmp/etc/default/ntpdate rootfs/etc/default/
415418
# don't use /etc/ntp.conf since we don't have it
@@ -467,6 +470,9 @@ function create_cpio {
467470
# libblkid1 components
468471
cp --preserve=xattr,timestamps tmp/lib/*/libblkid.so.1.* rootfs/lib/libblkid.so.1
469472

473+
# libbsd0 components
474+
cp --preserve=xattr,timestamps tmp/lib/*/libbsd.so.0.* rootfs/lib/libbsd.so.0
475+
470476
# libbz2-1.0 components
471477
cp --preserve=xattr,timestamps tmp/lib/*/libbz2.so.1.0.* rootfs/lib/libbz2.so.1.0
472478

buildroot.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
set -e # exit if any command fails
44

5+
# Set defaults for configurable behavior
6+
7+
# Controls production of a bz2-compressed image
8+
compress_bz2=1
9+
10+
# Controls production of an xz-compressed image
11+
compress_xz=1
12+
13+
# If a configuration file exists, import its settings
14+
if [ -e buildroot.conf ]; then
15+
# shellcheck disable=SC1091
16+
source buildroot.conf
17+
fi
18+
519
build_dir=build_dir
620

721
version_tag="$(git describe --exact-match --tags HEAD 2> /dev/null || true)"
@@ -60,16 +74,24 @@ else
6074
fi
6175

6276
# Create archives
63-
rm -f "${build_dir}/${imagename}.img.xz"
64-
if ! xz -9v --keep "${image}"; then
65-
# This happens e.g. on Raspberry Pi because xz runs out of memory.
66-
echo "WARNING: Could not create '${IMG}.xz' variant." >&2
77+
78+
if [ "$compress_xz" = "1" ]; then
79+
rm -f "${image}.xz"
80+
if ! xz -9v --keep "${image}"; then
81+
# This happens e.g. on Raspberry Pi because xz runs out of memory.
82+
echo "WARNING: Could not create '${IMG}.xz' variant." >&2
83+
fi
84+
rm -f "${imagename}.img.xz"
85+
mv "${image}.xz" ./
6786
fi
68-
rm -f "${imagename}.img.xz"
69-
mv "${image}.xz" ./
7087

71-
rm -f "${imagename}.img.bz2"
72-
( bzip2 -9v > "${imagename}.img.bz2" ) < "${image}"
88+
if [ "$compress_bz2" = "1" ]; then
89+
rm -f "${imagename}.img.bz2"
90+
( bzip2 -9v > "${imagename}.img.bz2" ) < "${image}"
91+
fi
7392

7493
# Cleanup
75-
rm -f "${image}"
94+
95+
if [ "$compress_xz" = "1" ] || [ "$compress_bz2" = "1" ]; then
96+
rm -f "${image}"
97+
fi

doc/INSTALL_CUSTOM.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
| Parameter | Default | Options | Description |
9898
|-------------------------|------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
99-
| `gpu_mem` | | | Specifies the amount of RAM in MB that should be reserved for the GPU. To allow the VideoCore GPU kernel driver to be loaded correctly, you should use at least "32". If not defined, the bootloader sets it to 64MB. The minimum value is "16". |
99+
| `gpu_mem` | `16` | | Specifies the amount of RAM in MB that should be reserved for the GPU. To allow the VideoCore GPU kernel driver to be loaded correctly, you should use at least "32". If not defined, the bootloader sets it to 64MB. The minimum value is "16". |
100100
| `console_blank` | | | Sets console blanking timeout (screensaver) in seconds. Default kernel setting is 10 minutes (`600`). The value `0` disables the blanking completely. |
101101
| `hdmi_type` | | `tv`/ `monitor` | Forces HDMI mode and disables automatic display identification. Choose between TV or monitor mode and specify the resolution with the options below. If not defined, the automatic display setting is used to determine the information sent by the display. |
102102
| `hdmi_tv_res` | `1080p` | `720p`/ `1080i`/ `1080p` | Specifies the display resolution if `hdmi_type` is set to TV mode. |
@@ -126,9 +126,8 @@
126126
| `cleanup` | `0` | `0`/`1` | Remove installer files after success. To also remove log files, note the option below. |
127127
| `cleanup_logfiles` | `0` | `0`/`1` | Removes installer log files after success. |
128128
| `cmdline` | `"dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 elevator=deadline fsck.repair=yes"` | | |
129-
| `rootfs_install_mount_options` | | | |
130-
| `rootfs_mount_options` | | | |
131129
| `final_action` | `reboot` | `reboot`/ `poweroff`/ `halt`/ `console` | Action at the end of install. |
130+
| `installer_telnet` | `1` | `0`/`1` | Send installer console output via telnet. |
132131
| `installer_retries` | `3` | | Number of retries if installation fails. |
133132
| `installer_networktimeout` | `15` | | Timeout in seconds for network interface initialization. |
134133
| `installer_pkg_updateretries` | `3` | | Number of retries if package update fails. |

scripts/opt/raspberrypi-ua-netinst/install.sh

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ variables_reset() {
7676
usbboot=
7777
cmdline=
7878
rootfstype=
79-
final_action=
79+
installer_telnet=
8080
installer_retries=
8181
installer_networktimeout=
8282
installer_pkg_updateretries=
@@ -152,6 +152,7 @@ variables_set_defaults() {
152152
variable_set "cmdline" "dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 elevator=deadline fsck.repair=yes"
153153
variable_set "rootfstype" "f2fs"
154154
variable_set "final_action" "reboot"
155+
variable_set "installer_telnet" "1"
155156
variable_set "installer_retries" "3"
156157
variable_set "installer_networktimeout" "15"
157158
variable_set "installer_pkg_updateretries" "3"
@@ -362,8 +363,7 @@ install_files() {
362363
echo
363364
}
364365

365-
output_filter() {
366-
local filterstring
366+
set_filter() {
367367
filterstring="^$"
368368
filterstring+="|^Setcap failed on \S.*, falling back to setuid$"
369369
filterstring+="|^dpkg: warning: ignoring pre-dependency problem"'!'"$"
@@ -390,12 +390,12 @@ output_filter() {
390390
filterstring+="|\(Reading database \.\.\. [0..9]{1,3}\%"
391391
filterstring+="|^E$"
392392
filterstring+="|^: $"
393+
}
393394

394-
while IFS= read -r line ; do
395-
if [[ "$line" =~ ${filterstring} ]] ; then
396-
:
397-
else
398-
echo " $line"
395+
output_filter() {
396+
while IFS= read -r line; do
397+
if [[ ! "${line}" =~ ${filterstring} ]]; then
398+
echo " ${line}"
399399
fi
400400
done
401401
}
@@ -498,7 +498,7 @@ installer_swapfile=/rootfs/installer-swap
498498
wlan_configfile=/tmp/wpa_supplicant.conf
499499
rootdev=/dev/mmcblk0
500500
tmp_bootfs=/tmp/bootfs
501-
final_action=reboot
501+
set_filter
502502

503503
mkdir -p /proc
504504
mkdir -p /sys
@@ -659,6 +659,7 @@ case "${rpi_hardware}" in
659659
"a020a0") rpi_hardware_version="Compute Module 3 (Lite)" ;;
660660
"a22082") rpi_hardware_version="3 Model B" ;;
661661
"a32082") rpi_hardware_version="3 Model B" ;;
662+
"a020d3") rpi_hardware_version="3 Model B+" ;;
662663
*) rpi_hardware_version="unknown (${rpi_hardware})" ;;
663664
esac
664665

@@ -939,6 +940,21 @@ else
939940
echo "OK"
940941
fi
941942

943+
# Start telnet console output
944+
if [ "${installer_telnet}" = "1" ]; then
945+
mkfifo telnet.pipe
946+
mkfifo /dev/installer-telnet
947+
tee < telnet.pipe /dev/installer-telnet &
948+
while IFS= read -r line; do
949+
if [[ ! "${line}" =~ userpw|rootpw ]]; then
950+
echo "${line}"
951+
fi
952+
done < "/dev/installer-telnet" | /bin/nc -klC -p 23 > /dev/null &
953+
exec &> telnet.pipe
954+
rm telnet.pipe
955+
echo "Printing console to telnet output started."
956+
fi
957+
942958
# This will record the time to get to this point
943959
PRE_NETWORK_DURATION=$(date +%s)
944960

@@ -1483,9 +1499,9 @@ mdev -s
14831499

14841500
echo -n "Initializing /boot as vfat... "
14851501
if [ -z "${boot_volume_label}" ]; then
1486-
mkfs.vfat "${bootpartition}" &> /dev/null || fail
1502+
mkfs.vfat -F 32 -s 1 "${bootpartition}" &> /dev/null || fail
14871503
else
1488-
mkfs.vfat -n "${boot_volume_label}" "${bootpartition}" &> /dev/null || fail
1504+
mkfs.vfat -F 32 -s 1 -n "${boot_volume_label}" "${bootpartition}" &> /dev/null || fail
14891505
fi
14901506
echo "OK"
14911507

@@ -1505,8 +1521,13 @@ if [ "${kernel_module}" = true ]; then
15051521
fi
15061522
fi
15071523

1524+
15081525
echo -n "Initializing / as ${rootfstype}... "
1509-
eval mkfs."${rootfstype}" "${rootfs_mkfs_options}" "${rootpartition}" &> /dev/null || fail
1526+
eval mkfs."${rootfstype}" "${rootfs_mkfs_options}" "${rootpartition}" | sed 's/^/ /'
1527+
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
1528+
fail
1529+
fi
1530+
15101531
echo "OK"
15111532

15121533
echo -n "Mounting new filesystems... "
@@ -1685,6 +1706,7 @@ if [ -n "${username}" ]; then
16851706
if [ -z "${userpw}" ]; then
16861707
echo -n " Setting '${username}' to sudo without a password... "
16871708
echo -n "${username} ALL = (ALL) NOPASSWD: ALL" > "/rootfs/etc/sudoers.d/${username}" || fail
1709+
chmod 440 "/rootfs/etc/sudoers.d/${username}" || fail
16881710
echo "OK"
16891711
fi
16901712
fi
@@ -1781,8 +1803,18 @@ if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "ifupdown";
17811803
ln -s /dev/null /rootfs/etc/udev/rules.d/75-persistent-net-generator.rules
17821804
fi
17831805

1784-
if [ "${ip_addr}" != "dhcp" ]; then
1785-
cp /etc/resolv.conf /rootfs/etc/ || fail
1806+
# copy resolv.conf
1807+
echo -n " Configuring nameserver... "
1808+
if [ -e "/etc/resolv.conf" ]; then
1809+
if cp /etc/resolv.conf /rootfs/etc/; then
1810+
echo "OK"
1811+
else
1812+
echo "FAILED !"
1813+
fail
1814+
fi
1815+
else
1816+
echo "MISSING !"
1817+
fail
17861818
fi
17871819

17881820
echo "OK"
@@ -2214,6 +2246,11 @@ if [ -n "${wlan_country}" ]; then
22142246
fi
22152247
fi
22162248

2249+
# disable wlan country warning
2250+
if [ -e "/rootfs/etc/wifi-country.sh" ]; then
2251+
sed -i "1 iexit 0" /rootfs/etc/wifi-country.sh
2252+
fi
2253+
22172254
# set hdmi options
22182255
if [ "${hdmi_type}" = "tv" ] || [ "${hdmi_type}" = "monitor" ]; then
22192256
config_set "/rootfs/boot/config.txt" "hdmi_ignore_edid" "0xa5000080"

0 commit comments

Comments
 (0)