From 8bf8f7e95ebb0537eebb01a7a825988b6fbbde99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 14 Jul 2019 16:58:28 +0200 Subject: [PATCH] general structure, + squash builder --- .gitignore | 10 ++ Makefile | 183 +++++++++++++++++++++++++ keys/debian-archive-stretch-stable.gpg | Bin 0 -> 2275 bytes keys/raspberrypi-archive-keyring.gpg | Bin 0 -> 1191 bytes keys/raspbian-archive-keyring.gpg | Bin 0 -> 1233 bytes 5 files changed, 193 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 keys/debian-archive-stretch-stable.gpg create mode 100644 keys/raspberrypi-archive-keyring.gpg create mode 100644 keys/raspbian-archive-keyring.gpg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4853b85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +cfg_root/ +sys_root/ +rpi_root/ +img_mount/ +part_boot.img +part_root.img +rpi_boot.img +rpi_root.img +.*.swp +.*.swo diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..65005eb --- /dev/null +++ b/Makefile @@ -0,0 +1,183 @@ + +DEFAULT: _target +.PHONY: _target _qemu _partition _format _mount _bootstrap _install _sparse _copy _config _syslinux _umount _partcopy _squash _mbr + +ARCH := amd64 +KEYRING := keys/debian-archive-stretch-stable.gpg +BOOTSTRAP := http://cdn.debian.net/debian + +define SOURCES = +deb http://cdn.debian.net/debian stretch main +endef +PACKAGES := ${PACKAGES} apt btrfs-tools busybox-static bzip2 ca-certificates cron debian-archive-keyring deborphan firmware-linux-free gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client psmisc rsync sshfs sudo systemd traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip + +ifdef disk +VOLUME := ${disk} +PBOOT := ${disk}1 +PROOT := ${disk}2 +SYSROOT := hdd_mount/ +CFGROOT := hdd_mount/ + +_target: _mbr _umount _config _install _partition + +_partition: +_format: _partition +_mount: _format +_bootstrap: _mount +_install: _bootstrap _mount +_config: _install _mount +_syslinux: _mount +_umount: _mount _config _syslinux +_mbr: _umount _syslinux + +else ifdef image +VOLUME := ${image} +PBOOT := part_boot.img +PROOT := part_root.img +SYSROOT := sys_root/ +CFGROOT := img_mount/ + +_target: _mbr _umount _partcopy _config _install + +_bootstrap: +_install: _bootstrap +_sparse: +_format: _sparse +_mount: _format +_copy: _install _mount +_config: _copy _mount +_syslinux: _mount +_umount: _mount _config _syslinux +_partition: +_partcopy: _partition _umount +_mbr: _partcopy _syslinux + +else ifdef squash +SQUASH := ${squash} +SYSROOT := sys_root/ +CFGROOT := cfg_root/ + +_target: _squash _install _config + +_bootstrap: +_install: _bootstrap +_copy: _install +_config: _copy +_squash: _config + +else ifdef raspi +VOLUME := ${image} +PBOOT := rpi_boot.img +PROOT := rpi_root.img +SYSROOT := rpi_root/ +CFGROOT := img_mount/ + +ARCH := armhf +KEYRING := keys/raspbian-archive-keyring.gpg +BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian + +define SOURCES = +deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi +deb http://archive.raspberrypi.org/debian stretch main +endef +PACKAGES := ${PACKAGES} firmware-brcm8011 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel + +_target: _umount _partcopy _config _install + +_qemu: +_bootstrap: _qemu +_install: _bootstrap +_sparse: +_format: _sparse +_mount: _format +_copy: _install _mount +_config: _copy _mount +_umount: _mount _config +_partition: +_partcopy: _partition _umount + +else +_target: + false + +endif + +ifeq "${ARCH}" "amd64" +PACKAGES := ${PACKAGES} linux-image-amd64 +else ifeq "${ARCH}" "i386" +PACKAGES := ${PACKAGES} linux-image-686 +endif + +export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP + +${SYSROOT}: + btrfs subvol create "$$SYSROOT" || mkdir -p "$$SYSROOT}" + chmod 755 "$@" + +_qemu: ${SYSROOT}/usr/bin/qemu-arm-static +${SYSROOT}/usr/bin/qemu-arm-static: /usr/bin/qemu-arm-static ${SYSROOT} + mkdir -p "$${SYSROOT}"/usr/bin + chmod 755 "$${SYSROOT}/usr" "$${SYSROOT}/usr/bin" + cp -p "$<" "$@" + +_bootstrap: ${SYSROOT}/bin/sh +${SYSROOT}/bin/sh: | ${SYSROOT} + debootstrap --variant=minbase --arch="$${ARCH}" \ + --keyring="$${KEYRING}" \ + stretch "$${SYSROOT}" "$${BOOTSTRAP}" + +.PHONY: _aptkeys _norecommends +_aptkeys: ${SYSROOT}/etc/apt/trusted.gpg.d/ +_norecommends: ${SYSROOT}/etc/apt/apt.conf.d/10norecommends + +${SYSROOT}/etc/apt/apt.conf.d/10norecommends: ${SYSROOT} + mkdir -p "$(dir $@)" + printf 'APT::Install-Recommends "false";\n' >"$@" + chmod 644 "$@" + +${SYSROOT}/etc/apt/trusted.gpg.d/: ${SYSROOT} + mkdir -p "$@" + cp keys/*.gpg "$@" + +_install: ${SYSROOT} _aptkeys _norecommends + printf %s "$${SOURCES}" >"$${SYSROOT}/etc/apt/sources.list" + -cp /etc/resolv.conf "$${SYSROOT}/etc/" + -chroot "$${SYSROOT}" sh -c 'apt-mark showmanual |xargs apt-mark auto' + -chroot "$${SYSROOT}" apt-get update + chroot "$${SYSROOT}" ln -sf /bin/true /usr/local/sbin/invoke-rc.d + chroot "$${SYSROOT}" apt-get --yes install ${PACKAGES} + chroot "$${SYSROOT}" apt-get --yes --auto-remove purge + -chroot "$${SYSROOT}" apt-get --yes --auto-remove upgrade + chroot "$${SYSROOT}" apt-get clean + chroot "$${SYSROOT}" rm /usr/local/sbin/invoke-rc.d + +_copy: ${SYSROOT} + btrfs sub snap "$${SYSROOT}" "$${CFGROOT}" || \ + cp -a "$${SYSROOT}/." "$${CFGROOT}/" + +.PHONY: _main_config +_config: _main_config +_main_config: ${CFGROOT} cfg_seed/ + cp -a cfg_seed/. "$${CFGROOT}" + +${SQUASH}: ${CFGROOT} + -rm "$@" + mksquashfs "$$CFGROOT" "$$SQUASH" -comp xz + +_squash: ${SQUASH} + +clean: + [ "$${SYSROOT#/}" ] && [ "$${CFGROOT#/}" ] || false # (abort receipe) + -mount |grep -qwF "$${SYSROOT}/boot" && umount "$${SYSROOT}/boot" + -mount |grep -qwF "$${SYSROOT}/proc" && umount "$${SYSROOT}/proc" + -mount |grep -qwF "$${SYSROOT}/sys" && umount "$${SYSROOT}/sys" + -mount |grep -qwF "$${SYSROOT}/dev" && umount "$${SYSROOT}/dev" + -mount |grep -qwF "$${SYSROOT}" && umount "$${SYSROOT}" + -mount |grep -qwF "$${CFGROOT}" && umount "$${CFGROOT}" + if [ -d "$${SYSROOT}" ] && ! mount |grep -qwFe "$${SYSROOT}"; then \ + btrfs sub del "$${SYSROOT}" || echo rm -r "$${SYSROOT}"; \ + fi + if [ -d "$${CFGROOT}" ] && ! mount |grep -qwFe "$${CFGROOT}"; then \ + btrfs sub del "$${CFGROOT}" || echo rm -r "$${CFGROOT}"; \ + fi + -rm "$${SQUASH}" diff --git a/keys/debian-archive-stretch-stable.gpg b/keys/debian-archive-stretch-stable.gpg new file mode 100644 index 0000000000000000000000000000000000000000..2c3f78fc729cdb331b87a90bc9142ee38de699b6 GIT binary patch literal 2275 zcmV<92pspB0u2ONAc@@p5CG30Fki)pHEYrlV~=+aX%E^Vr6AyZA0=qw$|AUHhj+Ab zqqA`Y0sOl!bra4BVoLFZZXJ**n|C0n>uElr1|H+;07dIOS z$Mir)$kDmb=bmGmqH$3{7Rq|2AzV7bQ=`c$53f0)jzWaWAG`s&enu=?{Q+}WvZIMR z^|g0pB(hL4+ANV=UTveJox_48)fWLj3Ys!-yi+zzwuVw;t|$AGWw0U41HsDx$!0Rl zMO}HFoWDsi>crhQ2ySUA#=TLmEEd%MXY+~6Q)rqCkxb+eF!`FZk$cs#zE%mqb?a!k z+NNE`Y6D}5Y<8-1Z|=a{KFU-Z%Gkdaf_-pU>b96i+OU;BtTrKf$p&`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Jc!sGZCz zpv#qsmQLj{2c?5$2S}N)0ssJs0vrSo0SEvF1p-+o7W)7S2@u83UBbme%~_AZ5C2@b z832iZbT2L<%2*=Mq6BqjDQ^Ndgk(5cYH zR!|t2S08!-5!z+gtT2NQ#I;A`QJ_|g6_ld8v~Qqlo??r6=?o*1SDi@9hYMuP=!)R5 z%TjXv&T4FX*h6iM@SGF@ab47c-Uwvt3KMB7IKecqR4(|yJjNtLCBK_)Jc}sum8D#+ z4IV3q=&OO5$F!5`*n_a0b5t*jeW&aKULN*@4dJ9Vfd`KW5yBNS!Ee6imrk@k8$aG!U*svdTc1IRiK zF5(}o30vTGl{;*;W#;a|>1S5FgZhU_BE_>#QZFHv96J-KI71PfQM?6OD9!k(o*7wJ xSkjaNs>Q-6L51!sIRW-*@Uv0iG^w%#p06`x`}%gF>-*mv*6h%KZQ`&3000OsE~5Yd literal 0 HcmV?d00001 diff --git a/keys/raspberrypi-archive-keyring.gpg b/keys/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(niMc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