From 5378014c9618e72df8c39f9c53d5193dd4894e82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 29 Oct 2018 00:23:13 +0100 Subject: [PATCH] debootstrap raspbian and build image file from it --- .gitignore | 3 ++ Makefile | 68 ++++++++++++++++++++++++++++++++ raspberrypi-archive-keyring.gpg | Bin 0 -> 1191 bytes raspbian-archive-keyring.gpg | Bin 0 -> 1233 bytes 4 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 raspberrypi-archive-keyring.gpg create mode 100644 raspbian-archive-keyring.gpg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..daa9384 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.*.swp +raspi_root/ +raspi.img diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d8f3d96 --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +.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 + +define SOURCES = +deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi\n\ +deb http://archive.raspberrypi.org/debian stretch main\n +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 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 + +raspi_root: /usr/bin/qemu-arm-static + btrfs subvolume create "$@" || mkdir "$@" + mkdir -p "$@/usr/bin" + chmod 755 -R "$@/" + cp -p "$<" "$@/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 + -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 clean + touch "$@" + +raspi.img: raspi_root/ + -rmdir "$@.mnt" + mkdir "$@.mnt" + dd bs=1M count=0 seek=1024 of="$@" + printf '${PARTITIONS}' |sfdisk "$@" + lo=$$(losetup -f); image='$@'; \ + start=$$(sfdisk --dump "$$image" |sed -rn 's;^.*start= *([0-9]+),.*type=83;\1;p'); \ + size=$$(sfdisk --dump "$$image" |sed -rn 's;^.*size= *([0-9]+),.*type=83;\1;p'); \ + losetup -o $$((start * 512)) --sizelimit $$((size * 512)) "$${lo}" "$$image" && \ + mkfs.ext4 "$$lo" && mount -t ext4 "$$lo" "$@.mnt/"; + mkdir "$@.mnt/boot" + lo=$$(losetup -f); image='$@'; \ + start=$$(sfdisk --dump "$$image" |sed -rn 's;^.*start= *([0-9]+),.*type=c;\1;p'); \ + size=$$(sfdisk --dump "$$image" |sed -rn 's;^.*size= *([0-9]+),.*type=c;\1;p'); \ + losetup -o $$((start * 512)) --sizelimit $$((size * 512)) "$${lo}" "$$image" && \ + mkfs.vfat "$$lo" && mount -t vfat "$$lo" "$@.mnt/boot"; + rsync -av "$<" "$@.mnt/" + umount "$@.mnt/boot/" "$@.mnt/" + losetup -a |sed -rn '/$@/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d + losetup -a |sed -rn '/$@/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d + rmdir "$@.mnt/" diff --git a/raspberrypi-archive-keyring.gpg b/raspberrypi-archive-keyring.gpg new file mode 100644 index 0000000000000000000000000000000000000000..ec758a15dcb7aa849fe5c286d88adf537da07687 GIT binary patch literal 1191 zcmV;Y1X%l-0SyFC-R_S82mq_Xq#AHyU!QwtGcm4R@PLL6L4LMVuSDD}S^bWgD(f z8w646R_0hcFid6w?MWv(jM768U&qzSWkZrTA!qok;;q3vaYXnZGm3m&Gv>jivG za7)9LBadobb$$-gJ~#86|Z)G z%BB^`+S8w79&uRUhy-a*cWx%zsymS~@PC5px>1zk^v%a-A^ z13H#9Tj$tY4{F+9kGCywy`qeEep!&8DzKv`*{N6(L9GGfT7*K6E!DjGLsa7J_RK9f zW^EDTumS)Bxd9CXPu=d10SExim0Lk&PPcw;{Yo+6v#`8q#B-r`j5`_*xDK zCWa;5&EWUr(pJybQ^)J&POU8XkEbCWTKcbsFX(Y%-Uo*o0P6WeG3XV3_DasA*Yw)< zR-_tBg0tOjR4)HDw++^#0=kPr`=+4gygHzpz2-5t@qBRfOC;^{=j86C`T`B9XNJ9H z(niMc5|SMZaB5p%m}J#v1NrE9exdgvr-_TKZ8n5mbCwsoG7FxcifEjV6OfUqMmZ)X z&JTK#?=a&(OP)X7<1VSFDqBKy-hRn}1jf{`&zV=AD3~~!d@W%@g8pHf#+Y752}@j6 zSJLgCjkjX;`FY$uL5?8+5di=Ji2)x37y$wR2?YXA-R_S98w>yn2@ry@DUyGqFg`_! z2mf?{wW`p}O}n`w!a2E<*Xw+8b)hjp)*tuBD&&2iSYD3FRC^H|z}pS?gpD#~3hFzm zRP`ih9UMXy@vrMIrd@T+MaiRNZpMf{twCpv|9l$}uq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