@@ -1,5 +1,6 @@ | |||||
deploy/* | deploy/* | ||||
work/* | work/* | ||||
config | |||||
postrun.sh | postrun.sh | ||||
SKIP | SKIP | ||||
SKIP_IMAGES | SKIP_IMAGES | ||||
@@ -1,12 +1,13 @@ | |||||
FROM i386/debian:buster | |||||
FROM debian:buster | |||||
ENV DEBIAN_FRONTEND noninteractive | ENV DEBIAN_FRONTEND noninteractive | ||||
RUN apt-get -y update && \ | RUN apt-get -y update && \ | ||||
apt-get -y install \ | |||||
apt-get -y install --no-install-recommends \ | |||||
git vim parted \ | git vim parted \ | ||||
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \ | quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \ | ||||
bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod\ | |||||
bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ | |||||
binfmt-support ca-certificates \ | |||||
&& rm -rf /var/lib/apt/lists/* | && rm -rf /var/lib/apt/lists/* | ||||
COPY . /pi-gen/ | COPY . /pi-gen/ | ||||
@@ -14,7 +14,7 @@ To install the required dependencies for pi-gen you should run: | |||||
```bash | ```bash | ||||
apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \ | apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \ | ||||
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl | |||||
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl bc | |||||
``` | ``` | ||||
The file `depends` contains a list of tools needed. The format of this | The file `depends` contains a list of tools needed. The format of this | ||||
@@ -36,6 +36,11 @@ The following environment variables are supported: | |||||
but you should use something else for a customized version. Export files | but you should use something else for a customized version. Export files | ||||
in stages may add suffixes to `IMG_NAME`. | in stages may add suffixes to `IMG_NAME`. | ||||
* `RELEASE` (Default: buster) | |||||
The release version to build images against. Valid values are jessie, stretch | |||||
buster, bullseye, and testing. | |||||
* `APT_PROXY` (Default: unset) | * `APT_PROXY` (Default: unset) | ||||
If you require the use of an apt proxy, set it here. This proxy setting | If you require the use of an apt proxy, set it here. This proxy setting | ||||
@@ -82,7 +87,7 @@ The following environment variables are supported: | |||||
Default system locale. | Default system locale. | ||||
* `HOSTNAME` (Default: "raspberrypi" ) | |||||
* `TARGET_HOSTNAME` (Default: "raspberrypi" ) | |||||
Setting the hostname to the specified value. | Setting the hostname to the specified value. | ||||
@@ -119,11 +124,11 @@ The following environment variables are supported: | |||||
* `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset) | * `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset) | ||||
If these are set, they are use to configure `wpa_supplicant.conf`, so that the raspberry pi can automatically connect to a wifi network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wifi network will be configured. | |||||
If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wifi network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wifi network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters. | |||||
* `ENABLE_SSH` (Default: `0`) | * `ENABLE_SSH` (Default: `0`) | ||||
Setting to `1` will enable ssh server for remote log in. Note that if you are using a common password such as the defaults there is a high risk of attackers taking over you RaspberryPi. | |||||
Setting to `1` will enable ssh server for remote log in. Note that if you are using a common password such as the defaults there is a high risk of attackers taking over you Raspberry Pi. | |||||
* `STAGE_LIST` (Default: `stage*`) | * `STAGE_LIST` (Default: `stage*`) | ||||
@@ -32,7 +32,7 @@ done | |||||
# Ensure that the configuration file is an absolute path | # Ensure that the configuration file is an absolute path | ||||
if test -x /usr/bin/realpath; then | if test -x /usr/bin/realpath; then | ||||
CONFIG_FILE=$(realpath -s "$CONFIG_FILE") | |||||
CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE") | |||||
fi | fi | ||||
# Ensure that the confguration file is present | # Ensure that the confguration file is present | ||||
@@ -41,7 +41,7 @@ if test -z "${CONFIG_FILE}"; then | |||||
exit 1 | exit 1 | ||||
else | else | ||||
# shellcheck disable=SC1090 | # shellcheck disable=SC1090 | ||||
source "${CONFIG_FILE}" | |||||
source ${CONFIG_FILE} | |||||
fi | fi | ||||
CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} | CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} | ||||
@@ -73,7 +73,7 @@ fi | |||||
# Modify original build-options to allow config file to be mounted in the docker container | # Modify original build-options to allow config file to be mounted in the docker container | ||||
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" | BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" | ||||
${DOCKER} build --no-cache --network=host -t pi-gen "${DIR}" | |||||
${DOCKER} build -t pi-gen "${DIR}" | |||||
if [ "${CONTAINER_EXISTS}" != "" ]; then | if [ "${CONTAINER_EXISTS}" != "" ]; then | ||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM | trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM | ||||
time ${DOCKER} run --rm --privileged \ | time ${DOCKER} run --rm --privileged \ | ||||
@@ -174,7 +174,7 @@ export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"} | |||||
export DEPLOY_ZIP="${DEPLOY_ZIP:-1}" | export DEPLOY_ZIP="${DEPLOY_ZIP:-1}" | ||||
export LOG_FILE="${WORK_DIR}/build.log" | export LOG_FILE="${WORK_DIR}/build.log" | ||||
export HOSTNAME=${HOSTNAME:-raspberrypi} | |||||
export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi} | |||||
export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} | export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} | ||||
export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry} | export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry} | ||||
@@ -232,6 +232,11 @@ if [[ -n "${APT_PROXY}" ]] && ! curl --silent "${APT_PROXY}" >/dev/null ; then | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
if [[ -n "${WPA_PASSWORD}" && ${#WPA_PASSWORD} -lt 8 || ${#WPA_PASSWORD} -gt 63 ]] ; then | |||||
echo "WPA_PASSWORD" must be between 8 and 63 characters | |||||
exit 1 | |||||
fi | |||||
mkdir -p "${WORK_DIR}" | mkdir -p "${WORK_DIR}" | ||||
log "Begin ${BASE_DIR}" | log "Begin ${BASE_DIR}" | ||||
@@ -16,3 +16,4 @@ xxd | |||||
file | file | ||||
git | git | ||||
lsmod:kmod | lsmod:kmod | ||||
bc |
@@ -0,0 +1,10 @@ | |||||
version: '2' | |||||
services: | |||||
apt-cacher-ng: | |||||
restart: unless-stopped | |||||
image: sameersbn/apt-cacher-ng:latest | |||||
ports: | |||||
- "3142:3142" | |||||
volumes: | |||||
- ./apt-cacher-ng:/var/cache/apt-cacher-ng |
@@ -18,7 +18,7 @@ ALIGN="$((4 * 1024 * 1024))" | |||||
# some overhead (since actual space usage is usually rounded up to the | # some overhead (since actual space usage is usually rounded up to the | ||||
# filesystem block size) and gives some free space on the resulting | # filesystem block size) and gives some free space on the resulting | ||||
# image. | # image. | ||||
ROOT_MARGIN=$((800*1024*1024)) | |||||
ROOT_MARGIN="$(echo "($ROOT_SIZE * 0.2 + 200 * 1024 * 1024) / 1" | bc)" | |||||
BOOT_PART_START=$((ALIGN)) | BOOT_PART_START=$((ALIGN)) | ||||
BOOT_PART_SIZE=$(((BOOT_SIZE + ALIGN - 1) / ALIGN * ALIGN)) | BOOT_PART_SIZE=$(((BOOT_SIZE + ALIGN - 1) / ALIGN * ALIGN)) | ||||
@@ -2,6 +2,8 @@ | |||||
install -m 644 files/sources.list "${ROOTFS_DIR}/etc/apt/" | install -m 644 files/sources.list "${ROOTFS_DIR}/etc/apt/" | ||||
install -m 644 files/raspi.list "${ROOTFS_DIR}/etc/apt/sources.list.d/" | install -m 644 files/raspi.list "${ROOTFS_DIR}/etc/apt/sources.list.d/" | ||||
sed -i "s/RELEASE/${RELEASE}/g" "${ROOTFS_DIR}/etc/apt/sources.list" | |||||
sed -i "s/RELEASE/${RELEASE}/g" "${ROOTFS_DIR}/etc/apt/sources.list.d/raspi.list" | |||||
if [ -n "$APT_PROXY" ]; then | if [ -n "$APT_PROXY" ]; then | ||||
install -m 644 files/51cache "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" | install -m 644 files/51cache "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" | ||||
@@ -1,3 +1,3 @@ | |||||
deb http://archive.raspberrypi.org/debian/ buster main | |||||
deb http://archive.raspberrypi.org/debian/ RELEASE main | |||||
# Uncomment line below then 'apt-get update' to enable 'apt-get source' | # Uncomment line below then 'apt-get update' to enable 'apt-get source' | ||||
#deb-src http://archive.raspberrypi.org/debian/ buster main | |||||
#deb-src http://archive.raspberrypi.org/debian/ RELEASE main |
@@ -1,3 +1,3 @@ | |||||
deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian buster main contrib non-free rpi | |||||
deb http://raspbian.raspberrypi.org/raspbian/ RELEASE main contrib non-free rpi | |||||
# Uncomment line below then 'apt-get update' to enable 'apt-get source' | # Uncomment line below then 'apt-get update' to enable 'apt-get source' | ||||
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi | |||||
#deb-src http://raspbian.raspberrypi.org/raspbian/ RELEASE main contrib non-free rpi |
@@ -1,5 +1,5 @@ | |||||
#!/bin/bash -e | #!/bin/bash -e | ||||
if [ ! -d "${ROOTFS_DIR}" ]; then | if [ ! -d "${ROOTFS_DIR}" ]; then | ||||
bootstrap buster "${ROOTFS_DIR}" http://raspbian.raspberrypi.org/raspbian/ | |||||
bootstrap ${RELEASE} "${ROOTFS_DIR}" http://raspbian.raspberrypi.org/raspbian/ | |||||
fi | fi |
@@ -1,6 +1,6 @@ | |||||
#!/bin/bash -e | #!/bin/bash -e | ||||
echo "${HOSTNAME}" > "${ROOTFS_DIR}/etc/hostname" | |||||
echo "127.0.1.1 ${HOSTNAME}" >> "${ROOTFS_DIR}/etc/hosts" | |||||
echo "${TARGET_HOSTNAME}" > "${ROOTFS_DIR}/etc/hostname" | |||||
echo "127.0.1.1 ${TARGET_HOSTNAME}" >> "${ROOTFS_DIR}/etc/hosts" | |||||
ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" | ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" |
@@ -28,3 +28,4 @@ vl805fw | |||||
ntfs-3g | ntfs-3g | ||||
pciutils | pciutils | ||||
rpi-eeprom | rpi-eeprom | ||||
raspinfo |
@@ -12,7 +12,8 @@ fi | |||||
if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then | if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then | ||||
on_chroot <<EOF | on_chroot <<EOF | ||||
wpa_passphrase "${WPA_ESSID}" "${WPA_PASSWORD}" >> "/etc/wpa_supplicant/wpa_supplicant.conf" | |||||
set -o pipefail | |||||
wpa_passphrase "${WPA_ESSID}" "${WPA_PASSWORD}" | tee -a "/etc/wpa_supplicant/wpa_supplicant.conf" | |||||
EOF | EOF | ||||
elif [ -v WPA_ESSID ]; then | elif [ -v WPA_ESSID ]; then | ||||
cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL | cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL | ||||
@@ -26,5 +27,5 @@ fi | |||||
# Disable wifi on 5GHz models | # Disable wifi on 5GHz models | ||||
mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/" | mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/" | ||||
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmc:wlan" | |||||
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmc:wlan" | |||||
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan" | |||||
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan" |