X-Git-Url: https://git.plutz.net/?p=rpi_small;a=blobdiff_plain;f=Makefile;h=4b7f0bd2c43ecddbb310a599ca2f69cf6132a022;hp=d8f3d9615b11df5d53d3353df3ad3d200159d975;hb=28a2eadda267e3d45823a6f730381b4434d0c063;hpb=5378014c9618e72df8c39f9c53d5193dd4894e82 diff --git a/Makefile b/Makefile index d8f3d96..4b7f0bd 100644 --- a/Makefile +++ b/Makefile @@ -1,68 +1,116 @@ +# Generator for Oktopus boot media +# Copyright (C) 2018 Hochschule für Technik und Wirtschaft Berlin +# written by Paul Hänsch +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + .FORCE: -define PARTITIONS = -label: dos\n\ -unit: sectors\n\ -\n\ -: start=8192, size=114688, type=1, type=c\n\ -: start=122880, type=83\n -endef +BOOTSTRAP = http://raspbian.raspberrypi.org/raspbian define SOURCES = -deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi\n\ -deb http://archive.raspberrypi.org/debian stretch main\n +deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi +deb http://archive.raspberrypi.org/debian stretch main endef -BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian -define SOURCES = -deb http://localhost/raspbian stretch main non-free firmware rpi\n -endef -BOOTSTRAP := http://localhost/raspbian +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 = -PACKAGES := apt apt-transport-https bluez bluez-firmware btrfs-tools busybox-static bzip2 ca-certificates cron deborphan firmware-atheros firmware-brcm80211 firmware-libertas firmware-linux-free firmware-misc-nonfree firmware-realtek gzip htop ifupdown init iptables iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openssh-client openssh-server p7zip-full raspberrypi-bootloader raspberrypi-kernel rpi-update rsync ssh sshfs sudo systemd traceroute unace unrar-free unzip vim wget wireless-tools wpasupplicant xz-utils zip +IMGFILE = raspi.img -raspi_root: /usr/bin/qemu-arm-static +config.mk: config.example + cp -n "$<" "$@" +include config.mk + +.PHONY: imgfile imgmount root_copy norecommends apt_keys +export SOURCES + +raspi_root: btrfs subvolume create "$@" || mkdir "$@" mkdir -p "$@/usr/bin" chmod 755 -R "$@/" - cp -p "$<" "$@/usr/bin/" + cp -p "/usr/bin/qemu-arm-static" "$@/usr/bin/" debootstrap --keyring=./raspbian-archive-keyring.gpg \ --arch=armhf --variant=minbase \ stretch "$@/" "${BOOTSTRAP}" -raspi_root/: raspi_root .FORCE - printf '${SOURCES}' >$@/etc/apt/sources.list - -chroot "$@" apt-key add - <./raspberrypi-archive-keyring.gpg +norecommends: raspi_root/etc/apt/apt.conf.d/10norecommends +raspi_root/etc/apt/apt.conf.d/10norecommends: raspi_root + mkdir -p "$"$@" + chmod 644 "$@" + +apt_keys: raspi_root + -chroot "$<" apt-key add - <./raspbian-archive-keyring.gpg + -chroot "$<" apt-key add - <./raspberrypi-archive-keyring.gpg + -chroot "$<" apt-key add - <./debian-archive-stretch-stable.gpg + +raspi_root/: raspi_root norecommends apt_keys .FORCE + printf %s "$$SOURCES" >$@/etc/apt/sources.list -cp /etc/resolv.conf "$@etc/" - # for tree in ${CONFIG}; do for file in apt default timezone; do cp -av "$$tree/etc/$$file" "$@/etc/" || true; done; done -chroot "$@" sh -c 'apt-mark showmanual |xargs apt-mark auto' -chroot "$@" apt-get update chroot "$@" ln -sf /bin/true /usr/local/sbin/invoke-rc.d chroot "$@" apt-get --yes install ${PACKAGES} chroot "$@" apt-get --yes --auto-remove purge - chroot "$@" apt-get --yes --auto-remove upgrade - chroot "$@" rm /usr/local/sbin/invoke-rc.d + -chroot "$@" apt-get --yes --auto-remove upgrade chroot "$@" apt-get clean + chroot "$@" rm /usr/local/sbin/invoke-rc.d touch "$@" -raspi.img: raspi_root/ - -rmdir "$@.mnt" - mkdir "$@.mnt" - dd bs=1M count=0 seek=1024 of="$@" - printf '${PARTITIONS}' |sfdisk "$@" - lo=$$(losetup -f); image='$@'; \ +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 + sfdisk "${IMGFILE}"