Add a DISTRO variable.
authorDaniel Abrecht <public@danielabrecht.ch>
Fri, 28 Jun 2019 21:17:24 +0000 (21:17 +0000)
committerDaniel Abrecht <public@danielabrecht.ch>
Fri, 28 Jun 2019 21:17:24 +0000 (21:17 +0000)
README.md
chroot-build-helper/makefile
config/defaults.mk
makefile
script/assemble_image.sh
script/debootstrap.sh
src/make-helper-functions.mk

index 07ea002d30d1b6eeb85e6651175fb10cc858ac67..015327280eee22c8a2aa869df92a04cfa1db576b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -56,7 +56,8 @@ make
 | -------- | ------- | ----------- |
 | BOARD | devkit | Board specific config. Specifies which configs/board-$(BOARD).mk config file to use. |
 | IMGSIZE | 4GiB | The size of the image. Can be specified in GB, GiB, MB, MiB, etc. |
-| RELEASE | ascii | The release to debootstrap |
+| DISTRO | devuan | The distribution |
+| RELEASE | beowulf | The release of the disribution to debootstrap |
 | REPO | http://pkgmaster.devuan.org/merged/ | The repository to use for debootstraping |
 | CHROOT_REPO | $REPO | The repository to use in the /etc/apt/sources.list |
 | IMAGE_NAME | devuan-$(RELEASE)-librem5-$(BOARD)-base.img | The name of the image |
index 416f8289bf4094eb59b356fee7a0150610ea5123..8f4dc32af6b971c69776eadce3ac69f27b734f11 100644 (file)
@@ -24,13 +24,13 @@ deb-console-keyboard-multiplexer: deb-libconsolekeyboard deb-libttymultiplex deb
 repo: \
   repo/flash-kernel/.repo
 
-build@%: bin/$(RELEASE)/%/.build
+build@%: bin/$(DISTRO)/$(RELEASE)/%/.build
        @true
 
 dummy-packages/%-dummy_99_all.deb: dummy-packages/%
        cd "$(dir $<)"; equivs-build "$(notdir $<)"
 
-build-env/$(RELEASE): build-env/.dir $(CHROOT_DUMMY_PACKAGES_FILES)
+build-env/$(DISTRO)/$(RELEASE): build-env/.dir $(CHROOT_DUMMY_PACKAGES_FILES)
        mkdir -p "$@.tmp"
        $(SETUPBUILDENV) uexec rm -rf "$(CURDIR)/$@.tmp"
        $(SETUPBUILDENV) uexec --allow-setgroups debootstrap --foreign --arch=arm64 "$(RELEASE)" "$(CURDIR)/$@.tmp" "$(REPO)"
@@ -52,15 +52,15 @@ build-env/$(RELEASE): build-env/.dir $(CHROOT_DUMMY_PACKAGES_FILES)
        printf "deb file:///root/devrepo/ ./\n" "$(REPO)" "$(RELEASE)" "$(REPO)" "$(RELEASE)" >>"$@.tmp/etc/apt/sources.list"
        mv "$@.tmp" "$@"
 
-build-env/$(RELEASE)/root/%/src/.source: repo/%/.repo build-env/$(RELEASE)
+build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source: repo/%/.repo build-env/$(DISTRO)/$(RELEASE)
        mkdir -p "$(dir $(dir $(dir $@)))"
        rm -rf "$(dir $(dir $@))"
        cp -r "$(dir $<)" "$(dir $@)"
        touch "$@"
 
-bin/$(RELEASE)/deb-%/.build: build-env/$(RELEASE)/root/%/src/.source
+bin/$(DISTRO)/$(RELEASE)/deb-%/.build: build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source
        find "$(<:%/src/.source=%)/" -maxdepth 1 -type f -delete
-       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/build-env/$(RELEASE)" sh -c "\
+       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/build-env/$(DISTRO)/$(RELEASE)" sh -c "\
          set -ex; \
          cd /root/devrepo/; \
          rm -f Packages Packages.gz Packages.xz; \
@@ -68,7 +68,7 @@ bin/$(RELEASE)/deb-%/.build: build-env/$(RELEASE)/root/%/src/.source
          gzip -k Packages; \
          xz -k Packages; \
          dpkg --remove \$$(grep '^Package: ' Packages | grep -o '[^ ]*$$') || true; \
-         cd /root/$(notdir $(<:build-env/$(RELEASE)/root/%/src/.source=%))/src/; \
+         cd /root/$(notdir $(<:build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source=%))/src/; \
          apt-get update; \
          apt-get -y build-dep .; \
          debuild -b -us -uc; \
@@ -82,7 +82,9 @@ clean-repo: clean-repo@flash-kernel
 reset-repo: reset-repo@flash-kernel
 
 clean-buildenv:
-       $(SETUPBUILDENV) uexec rm -rf "$(CURDIR)/build-env/$(RELEASE)"
+       $(SETUPBUILDENV) uexec rm -rf "$(CURDIR)/build-env/$(DISTRO)/$(RELEASE)"
+       rmdir "$(CURDIR)/build-env/$(DISTRO)/" || true
+       rmdir "$(CURDIR)/build-env/" || true
 
 clean-build:
        rm -rf bin/$(RELEASE)
index 1e18a716711ab58ae077c4df7724bdd1a39a4f57..0204b2222e89735c1d7cbf9db08aa67a20c8c22d 100644 (file)
@@ -1,19 +1,17 @@
 BOARD = devkit
 IMGSIZE = 4GiB # Note: 1GB = 1000MB, 1GiB=1024MiB 
-RELEASE = ascii
+DISTRO = devuan
+RELEASE = $(DEFAULT_RELEASE-$(DISTRO))
 REPO = http://pkgmaster.devuan.org/merged/
 CHROOT_REPO = $(REPO)
 
 REPO-devuan = http://pkgmaster.devuan.org/merged/
 REPO-debian = http://deb.debian.org/debian
 
-REPO-ascii = $(REPO-devuan)
-REPO-beowulf = $(REPO-devuan)
+DEFAULT_RELEASE-devuan = beowulf
+DEFAULT_RELEASE-debian = buster
 
-REPO-stretch = $(REPO-debian)
-REPO-buster = $(REPO-debian)
-
-IMAGE_NAME = devuan-$(RELEASE)-librem5-$(BOARD)-base.img
+IMAGE_NAME = $(DISTRO)-$(RELEASE)-librem5-$(BOARD)-base.img
 
 CROSS_COMPILER = aarch64-linux-gnu-
 
index aae6e543ef787ab89501610532a5f00424632a29..9e80159119f70296dea83754bc0c2a14e95f0226 100644 (file)
--- a/makefile
+++ b/makefile
@@ -12,11 +12,11 @@ extra_packages:
        $(MAKE) -C chroot-build-helper
 
 clean-fs-all:
-       rm -rf build/$(RELEASE)/filesystem
+       rm -rf build/
 
 clean-fs:
-       rm -rf "build/$(RELEASE)/filesystem/bootfs.tar"
-       rm -rf "build/$(RELEASE)/filesystem/rootfs.tar"
+       rm -rf "build/$(DISTRO)/$(RELEASE)/bootfs.tar"
+       rm -rf "build/$(DISTRO)/$(RELEASE)/rootfs.tar"
 
 clean-image-all:
        rm -f bin/*.img
@@ -50,7 +50,7 @@ build/bin/writeTar2Ext: repo/tar2ext/.repo build/bin/.dir
        $(MAKE) -C repo/tar2ext/
        cp repo/tar2ext/bin/writeTar2Ext build/bin/
 
-build/$(RELEASE)/filesystem/rootfs.tar: \
+build/$(DISTRO)/$(RELEASE)/rootfs.tar: \
   kernel/bin/linux-image.deb \
   uboot/bin/uboot_firmware_and_dtb.bin \
   build/bin/usernsexec \
@@ -65,7 +65,7 @@ build/$(RELEASE)/filesystem/rootfs.tar: \
 bin/$(IMAGE_NAME): \
   build/bin/fuseloop \
   build/bin/writeTar2Ext \
-  build/$(RELEASE)/filesystem/rootfs.tar \
+  build/$(DISTRO)/$(RELEASE)/rootfs.tar \
   uboot/bin/uboot_firmware_and_dtb.bin \
   kernel/bin/linux-image.deb
        ./script/assemble_image.sh
index 4aa31188ed7b6d87b1499b5796d88a134ba5c1f1..8e39d90ee661f38ae6530aa552721f149c25ad12 100755 (executable)
@@ -7,8 +7,9 @@ base="$PWD"
 
 tmp="$(mktemp -d -p build)"
 
+if [ -z "$DISTRO" ]; then DISTRO="devuan"; fi
 if [ -z "$RELEASE" ]; then RELEASE="ascii"; fi
-if [ -z "$IMAGE_NAME" ]; then IMAGE_NAME="devuan-$RELEASE-librem5-devkit-base.img"; fi
+if [ -z "$IMAGE_NAME" ]; then IMAGE_NAME="$DISTRO-$RELEASE-librem5-devkit-base.img"; fi
 
 # Some programs like sfdisk are in /sbin/, but they work just fine as non-root on an image
 PATH="$base/build/bin/:$base/script/:/sbin/:/usr/sbin/:$PATH"
@@ -99,8 +100,8 @@ mkfs.ext2 -L boot "$bootdev"
 mkfs.ext4 -L root -E discard "$rootdev"
 
 # Write rootfs to partitions
-writeTar2Ext "$bootdev" < build/$RELEASE/filesystem/bootfs.tar
-writeTar2Ext "$rootdev" < build/$RELEASE/filesystem/rootfs.tar
+writeTar2Ext "$bootdev" < build/$DISTRO/$RELEASE/bootfs.tar
+writeTar2Ext "$rootdev" < build/$DISTRO/$RELEASE/rootfs.tar
 
 # Unmount & remove fuse loop devices
 umount_wait
index 32b562a8c0cb31d7446def4ded5a6c2d5e353414..5e49b32f6f615b0b531ea2e412062ffe7be326a0 100755 (executable)
@@ -20,12 +20,13 @@ then
 fi
 
 # Set release repo if not already defined
+if [ -z "$DISTRO" ]; then DISTRO=devuan; fi
 if [ -z "$RELEASE" ]; then RELEASE=ascii; fi
 if [ -z "$REPO" ]; then REPO=https://pkgmaster.devuan.org/merged/; fi
 if [ -z "$CHROOT_REPO" ]; then CHROOT_REPO="$REPO"; fi
 if [ -z "$KERNEL_DTB" ]; then echo "Pleas set KERNEL_DTB" >2; exit 1; fi
 
-tmp="$base/build/$RELEASE/filesystem/"
+tmp="$base/build/$DISTRO/$RELEASE/"
 
 # Cleanup if any of the remaining steps fails
 cleanup(){
@@ -75,7 +76,7 @@ chroot_qemu_static.sh "$tmp/rootfs/" /debootstrap/debootstrap --second-stage
 
 mkdir "$tmp/rootfs/root/temp-repo/"
 cp kernel/bin/linux-image.deb kernel/bin/linux-libc.deb kernel/bin/linux-headers.deb "$tmp/rootfs/root/temp-repo/"
-cp chroot-build-helper/bin/"$RELEASE"/deb-*/*.deb "$tmp/rootfs/root/temp-repo/"
+cp chroot-build-helper/bin/"$DISTRO"/"$RELEASE"/deb-*/*.deb "$tmp/rootfs/root/temp-repo/"
 
 # Note: The /etc/fstab is generated in assemble_image.sh
 (
index 280b8e7ab98fbf9046fedc24687295a5be068e2e..9ccf5539fecf10401f614c0a1524c65c7d0712d3 100644 (file)
@@ -27,12 +27,20 @@ ifeq ($(shell test -e "$(project_root)/config/userdefined.mk" && echo -n yes),ye
 include $(project_root)/config/userdefined.mk
 endif
 
-ifdef REPO-$(RELEASE)
-  REPO = $(REPO-$(RELEASE))
+ifdef REPO-$(DISTRO)
+  REPO = $(REPO-$(DISTRO))
 endif
 
-ifdef CHROOT_REPO-$(RELEASE)
-  CHROOT_REPO = $(CHROOT_REPO-$(RELEASE))
+ifdef REPO-$(DISTRO)-$(RELEASE)
+  REPO = $(REPO-$(DISTRO)-$(RELEASE))
+endif
+
+ifdef CHROOT_REPO-$(DISTRO)
+  CHROOT_REPO = $(CHROOT_REPO-$(DISTRO))
+endif
+
+ifdef CHROOT_REPO-$(DISTRO)-$(RELEASE)
+  CHROOT_REPO = $(CHROOT_REPO-$(DISTRO)-$(RELEASE))
 endif
 
 CONFIG_VARS := $(sort $(filter-out $(VARS_OLD) VARS_OLD,$(subst %,,$(subst *,,$(.VARIABLES)))))