]> git.plutz.net Git - rpi_small/blobdiff - Makefile
make busybox tools available in default $PATH
[rpi_small] / Makefile
index 4b7f0bd2c43ecddbb310a599ca2f69cf6132a022..58c32d96fc351d068b4fa4622a836ad5f06b151c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,18 +26,16 @@ endef
 
 PACKAGES := apt bluez bluez-firmware bluez-tools btrfs-tools busybox-static bzip2 ca-certificates cron debian-archive-keyring deborphan firmware-brcm80211 firmware-linux-free firmware-misc-nonfree gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openssh-client openssh-server pi-bluetooth psmisc raspberrypi-bootloader raspberrypi-kernel rsync ssh sshfs sudo systemd traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip
 
-# Do not change, only override in config.mk
-WIFI-SSID = 
-WIFI-PASS = 
-
 IMGFILE = raspi.img
 
 config.mk: config.example
        cp -n "$<" "$@"
 include config.mk
 
-.PHONY: imgfile imgmount root_copy norecommends apt_keys
+.PHONY: imgfile imgmount root_copy norecommends apt_keys wifi_cfg ssh_key busybox
+
 export SOURCES
+export WIFI_CFG
 
 raspi_root:
        btrfs subvolume create "$@" || mkdir "$@"
@@ -72,19 +70,6 @@ raspi_root/: raspi_root norecommends apt_keys .FORCE
        chroot "$@" rm /usr/local/sbin/invoke-rc.d
        touch "$@"
 
-id_rsa.pub:
-       ssh-keygen -b 2048 -t rsa -N '' -f id_rsa
-
-files/etc/network/interfaces.d/wifi: wifi.tmpl
-       sed 's;#WIFI-SSID#;${WIFI-SSID};; s;#WIFI-PASS#;${WIFI-PASS};;' <'$<' >'$@'
-       chmod 644 '$@'
-
-files/root/.ssh/authorized_keys: id_rsa.pub
-       mkdir -p files/root/.ssh/
-       cat '$<' >>'$@'
-       chmod 700 files/root/ files/root/.ssh/
-       chmod 600 '$@'
-
 imgfile: raspi_root/  # do not set up image file before chroot
 imgfile: partitions
        dd bs=1M count=0 seek=1280 of="${IMGFILE}"  # set up sparse file
@@ -105,11 +90,28 @@ imgmount: imgfile
        losetup -o $$((start * 512)) --sizelimit $$((size * 512)) "$${lo}" "$$image" && \
        mkfs.fat -F 32 -n boot "$$lo" && mount -t vfat "$$lo" "$@/boot";
 
-root_copy: files/root/.ssh/authorized_keys files/etc/network/interfaces.d/wifi
 root_copy: imgmount raspi_root/ files/
        cp -a "raspi_root/." "files/." "$</"
 
-${IMGFILE}: imgmount root_copy
+id_rsa.pub:
+       ssh-keygen -b 2048 -t rsa -N '' -f id_rsa
+
+ssh_key: imgmount root_copy id_rsa.pub
+       mkdir -p "$</root/.ssh/"
+       cat id_rsa.pub >>"$</root/.ssh/authorized_keys"
+       chmod 700 "$</root" "$</root/.ssh"
+       chmod 600 "$</root/.ssh/authorized_keys"
+
+wifi_cfg: imgmount root_copy
+       printf '%s\n' "$$WIFI_CFG" >"$</etc/network/interfaces.d/wifi"
+       chmod 644 "$</etc/network/interfaces.d/wifi"
+       chroot "$<" systemctl disable systemd-networkd-wait-online.service
+
+busybox: imgmount root_copy
+       mkdir -p -m 755 "$</opt/busybox"
+       chroot "$<" busybox --install -s /opt/busybox
+
+${IMGFILE}: imgmount root_copy wifi_cfg ssh_key busybox
        umount "$</boot/" "$</"
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d