...
 
Commits (2)
......@@ -32,12 +32,12 @@ WIREGUARD_URL=https://git.zx2c4.com/WireGuard/snapshot/WireGuard-$(WIREGUARD_VER
#If we're building a specific image, automatically set the ARCH based on that.
ARCHS := #Needed so ARCHS+=$(ARCH) expands $(ARCH) immediately, not recursively.
ARM_TARGETS:=rpi3_img rpi3_zip rip3_zip_clean rpi3_img_clean chip_img chip_img_clean
ARM_TARGETS:=rpi3_img rpi3_zip rpi3_img_clean rip3_zip_clean
ifneq ($(filter $(ARM_TARGETS), $(MAKECMDGOALS)),)
override ARCH:=arm64
ARCHS+=$(ARCH)
endif
AMD64_TARGETS:=pc_img pc_img_clean
AMD64_TARGETS:=pc_img pc_zip pc_img_clean pc_zip_clean
ifneq ($(filter $(AMD64_TARGETS), $(MAKECMDGOALS)),)
override ARCH:=amd64
ARCHS+=$(ARCH)
......@@ -51,7 +51,6 @@ KERNEL_IMG=zImage
KERNEL_EXTRAS=dtbs
UBOOT_ARCH=arm
UBOOT_IMG=u-boot.bin
BOOT_MNT=/dev/mmcblk0p1
CROSS_PREFIX=arm-linux-gnueabihf-
FROM_PREFIX=arm32v7/
QEMU_ARCH=arm
......@@ -61,7 +60,6 @@ KERNEL_IMG=Image
KERNEL_EXTRAS=dtbs
UBOOT_ARCH=arm
UBOOT_IMG=u-boot.bin
BOOT_MNT=/dev/mmcblk0p1
CROSS_PREFIX=aarch64-linux-gnu-
FROM_PREFIX=arm64v8/
QEMU_ARCH=aarch64
......@@ -69,7 +67,6 @@ else ifeq ($(ARCH), amd64)
KERNEL_ARCH=x86
KERNEL_IMG=bzImage
KERNEL_EXTRAS=
BOOT_MNT=LABEL=ISOLINUX
CROSS_PREFIX=
FROM_PREFIX=
else
......@@ -132,7 +129,7 @@ FAKEROOT := $(SCRIPTDIR)/lockedfakeroot
#XXX Make sure the CROSS_PREFIX (or native) toolchain exists.
#XXX new enough cross tools, u-boot-tools (mkenvimage), mtools, grub (EFI and pc),
# docker, xorriso, gpg2, etc.
# docker, syslinux, gpg2, etc.
#Make sure binfmt is configured properly for cross-builds
ifneq ($(shell echo '50c12d79f40fc1cacc4819ae9bac6bb1 /proc/sys/fs/binfmt_misc/qemu-arm' | \
......@@ -329,7 +326,6 @@ $(INITRD): $(INITRDSRCDIR)/*
@mkdir -p $(INITRDDIR)
docker build $(DOCKER_BUILD_PROXY) \
--build-arg FROM_PREFIX=$(FROM_PREFIX) \
--build-arg BOOT_MNT=$(BOOT_MNT) \
-t $(FROM_PREFIX)initrd $(INITRDSRCDIR)
docker container create --name=$(shell echo $(FROM_PREFIX) | tr -d '/')initrd \
$(FROM_PREFIX)initrd
......@@ -354,8 +350,7 @@ initrd_clean:
ROOTFS := $(IMGFSDIR)/layers/rootfs.layers
rootfs: $(ROOTFS)
$(ROOTFS): $(ROOTSRCDIR)/* $(SCRIPTDIR)/untar-docker-image
$(SCRIPTDIR)/mkcontainer -r \
-aARCH=$(ARCH) -aBOOT_MNT=$(BOOT_MNT) \
$(SCRIPTDIR)/mkcontainer -r -aARCH=$(ARCH) \
rootfs '$(FROM_PREFIX)' $(ROOTSRCDIR) \
$(FSDIR) \
$(IMGFSDIR)/layers \
......@@ -547,8 +542,6 @@ IMG_DEPS += \
$(UBOOT_ENV) \
$(BOOTFW) \
$(CONFIG_TXT)
else ifeq ($(ARCH), amd64)
IMG_DEPS += $(SRCDIR)/pc/grub.cfg
endif
RPI3_IMG := $(IMAGESDIR)/rpi3image.bin
......@@ -576,33 +569,56 @@ rpi3_zip_clean:
PC_IMG := $(IMAGESDIR)/pcimage.bin
pc_img: $(PC_IMG)
$(PC_IMG): $(IMG_DEPS)
$(PC_IMG): $(IMG_DEPS) $(SRCDIR)/pc/grub.cfg
@mkdir -p $(IMAGESDIR)
cp -r $(filter-out $(IMGFSDIR)/%, $(IMG_DEPS)) $(IMGFSDIR)
mkdir -p $(IMGFSDIR)/boot/grub
cp $(IMGFSDIR)/grub.cfg $(IMGFSDIR)/boot/grub/
cp $(SRCDIR)/pc/grub.cfg $(IMGFSDIR)/boot/grub/
dd if=/dev/zero of=$(IMGFSDIR)/SPACER bs=4096 count=1024 #HACK to make room for apikey
grub-mkrescue -volid $(subst LABEL=,,$(BOOT_MNT)) -o $(PC_IMG) $(IMGFSDIR)
grub-mkrescue -o $(PC_IMG) $(IMGFSDIR)
@rm $(IMGFSDIR)/SPACER
PHONY += pc_img_clean
pc_img_clean:
rm $(PC_IMG)
PC_ZIP := $(IMAGESDIR)/pc.zip
pc_zip: $(PC_ZIP)
$(PC_ZIP): $(IMG_DEPS) $(SRCDIR)/pc/syslinux.cfg
@mkdir -p $(IMAGESDIR)
rm -f $(PC_ZIP)
cp -r $(filter-out $(IMGFSDIR)/%, $(IMG_DEPS)) $(IMGFSDIR)
mkdir -p $(IMGFSDIR)/EFI/boot
cp $(SRCDIR)/pc/syslinux.cfg /usr/lib/syslinux/modules/efi64/ldlinux.e64 $(IMGFSDIR)/EFI/boot/
cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi $(IMGFSDIR)/EFI/boot/bootx64.efi
( cd $(IMGFSDIR) && zip -r $(PC_ZIP) * -x pairingkey wifi.txt )
PHONY += pc_zip_clean
pc_zip_clean:
rm $(PC_ZIP)
PHONY += img zip
ifeq ($(ARCH:arm%=),)
img: rpi3_img
zip: rpi3_zip
else ifeq ($(ARCH), amd64)
img: pc_img
zip: pc_zip
endif
########################
# Deploy images
PHONY += deploy
ifeq ($(ARCH:arm%=),)
deploy: $(RPI3_ZIP)
@test $(SERVER)
scp $(RPI3_ZIP) root@$(SERVER):~/data/sslnginx/html/images/
else ifeq ($(ARCH), amd64)
deploy: $(PC_ZIP)
@test $(SERVER)
scp $(PC_ZIP) root@$(SERVER):~/data/sslnginx/html/images/
endif
########################
# Qemu emulation targets
......
......@@ -2,11 +2,8 @@ ARG FROM_PREFIX
FROM ${FROM_PREFIX}busybox:1.28.0-uclibc
ARG BOOT_MNT
RUN mkdir /boot /newroot
COPY init /
COPY fstab /etc/
RUN sed -i "s|XBOOT_MNTX|$BOOT_MNT|g" /etc/fstab
proc /proc proc nosuid,noexec,nodev
devtmpfs /dev devtmpfs nosuid,noexec
XBOOT_MNTX /boot auto ro
......@@ -8,7 +8,21 @@ sleep 2
# and /boot for the new root image.
mount /proc
mount /dev
mount /boot
#Try all partitions until one has /layers/rootfs.layers
for i in `egrep -o ' (mmcblk[0-9]+p[0-9]+|[sh]d[a-z]+[0-9]+)$' /proc/partitions`; do
#XXX Maybe check that it is fat/vfat/exfat before trying to mount?
if ! mount /dev/$i /boot; then
continue
fi
if [ -f /boot/layers/rootfs.layers ]; then
break
fi
umount /boot
done
if ! [ -f /boot/layers/rootfs.layers ]; then
echo "FAILED TO MOUNT /boot" >&2
exit 99
fi
# Switch to the real root.
......@@ -49,4 +63,5 @@ mount --move /boot /newroot/boot
# XXX debugging: leave old root visible under the new root
#mount --bind / /newroot/mnt
echo "initrd finished, switching roots"
exec switch_root /newroot /sbin/init
DEFAULT linux
LABEL linux
SAY SYSLINUX booting boundery...
KERNEL /bzImage
INITRD /initrd
APPEND console=tty0 console=ttyS0,115200
......@@ -3,7 +3,6 @@ ARG FROM_PREFIX
FROM ${FROM_PREFIX}debian:stretch-slim
ARG ARCH
ARG BOOT_MNT
COPY *.pub /keys/
......@@ -45,7 +44,6 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
COPY fstab mdev.conf /etc/
RUN sed -i "s|XBOOT_MNTX|$BOOT_MNT|g" /etc/fstab
COPY modules.${ARCH} /etc/modules
COPY sethostname /etc/dhcp/dhclient-exit-hooks.d/
COPY wpa_supplicant.conf /usr/local/etc/
......
XBOOT_MNTX /boot auto ro
sysfs /sys sysfs nosuid,noexec,nodev
proc /proc proc nosuid,noexec,nodev
devtmpfs /dev devtmpfs nosuid,noexec,size=16k
......