Move list of packages to build to packages/*/build files
authorDaniel Abrecht <public@danielabrecht.ch>
Sun, 14 Jul 2019 00:18:20 +0000 (02:18 +0200)
committerDaniel Abrecht <public@danielabrecht.ch>
Sun, 14 Jul 2019 00:18:20 +0000 (02:18 +0200)
chroot-build-helper/dummy-packages/.dir [new file with mode: 0644]
chroot-build-helper/dummy-packages/man-db [deleted file]
chroot-build-helper/makefile
script/generate_make_build_dependencies_for_debs.sh [new file with mode: 0755]
script/mkdummydeb.sh [new file with mode: 0755]
src/make-helper-functions.mk
src/package_list.mk

diff --git a/chroot-build-helper/dummy-packages/.dir b/chroot-build-helper/dummy-packages/.dir
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/chroot-build-helper/dummy-packages/man-db b/chroot-build-helper/dummy-packages/man-db
deleted file mode 100644 (file)
index dc4dfd4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-Section: misc
-Priority: optional
-Standards-Version: 3.9.2
-
-Package: man-db-dummy
-Version: 99:99
-Provides: man-db
-Architecture: all
-Description: Dummy man-db package to work around qemu-user seccomp lockup
index 4ac75e0ca8be1216ccdc91f58892780e6231dfef..fc249b5c004ecf0ef4dd61d86148b3ef431b8451 100644 (file)
@@ -1,48 +1,33 @@
 include ../src/make-helper-functions.mk
 
+TMPDEP := $(shell mktemp)
+$(shell make -f "../src/make-helper-functions.mk" TMP_TARGET_FILE="$(TMPDEP)" DEP_PREFIX="bin/$(DISTRO)/$(RELEASE)/" DEP_SUFFIX="/.build" generate_make_build_dependencies_for_debs >/dev/null)
+include $(TMPDEP)
+
+bla:
+       echo
+
 # Only one thing at a time can chroot into the buildenv
 .NOTPARALLEL:
 
 CURDIR=$(realpath .)
 
-TARGETS += deb-flash-kernel
-TARGETS += deb-consolation
-TARGETS += deb-libttymultiplex
-TARGETS += deb-libconsolekeyboard
-TARGETS += deb-console-keyboard-basic
-TARGETS += deb-console-keyboard-multiplexer
-
-ifndef no-custom-mesa-$(DISTRO)-$(RELEASE)
-  TARGETS += deb-mesa
-endif
-
-TARGETS += $(CROSSBUILD_SOURCE_PACKAGES)
-
 # Packages using seccomp will hang qemu-user, so let's replace them
-CHROOT_DUMMY_PACKAGES += man-db
-
-CHROOT_DUMMY_PACKAGES_FILES = $(addprefix dummy-packages/,$(addsuffix -dummy_99_all.deb,$(CHROOT_DUMMY_PACKAGES)))
+CHROOT_DUMMY_PACKAGES_FILES = $(addprefix dummy-packages/,$(addsuffix .deb,$(PACKAGES_BOOTSTRAP_WORKAROUND)))
 
-all: $(addprefix build@,$(TARGETS))
-
-deb-console-keyboard-basic: deb-libconsolekeyboard
-deb-console-keyboard-multiplexer: deb-libconsolekeyboard deb-libttymultiplex deb-console-keyboard-basic
-
-pkg-repo@deb-%: repo@%
-       @true
-
-repo: $(addprefix pkg-repo@,$(TARGETS))
+all: $(addprefix build@,$(PACKAGES_TO_BUILD)) $(CHROOT_DUMMY_PACKAGES_FILES)
+repo: $(addprefix repo@,$(PACKAGES_TO_BUILD))
 
 build@%: bin/$(DISTRO)/$(RELEASE)/%/.build
        @true
 
-dummy-packages/%-dummy_99_all.deb: dummy-packages/%
-       cd "$(dir $<)"; equivs-build "$(notdir $<)"
+dummy-packages/%.deb:
+       mkdummydeb.sh "$@"
 
 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)"
+       uexec rm -rf "$(CURDIR)/$@.tmp"
+       uexec --allow-setgroups debootstrap --foreign --arch=arm64 "$(RELEASE)" "$(CURDIR)/$@.tmp" "$(REPO)"
        mkdir -p "$@.tmp/root/helper" "$@.tmp/root/dummy-debs" "$@.tmp/root/devrepo"
        cp $(CHROOT_DUMMY_PACKAGES_FILES) "$@.tmp/root/dummy-debs/"
        # Stub things which won't work in a chroot
@@ -54,11 +39,11 @@ build-env/$(DISTRO)/$(RELEASE): build-env/.dir $(CHROOT_DUMMY_PACKAGES_FILES)
        # Stub man stuff, because it may use seccomp, would hand qemu-user-static :(
        touch "$@.tmp/dev/null"
        chmod 666 "$@.tmp/dev/null"
-       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" /debootstrap/debootstrap --second-stage
-       CHROOT_REPO="$$REPO" ../script/getrfsfile.sh "rootfs_custom_files/etc/apt/sources.list" >"$@.tmp/etc/apt/sources.list"
-       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get update
-       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" sh -c "dpkg -i /root/dummy-debs/*.deb"
-       $(SETUPBUILDENV) uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get -y install --no-install-recommends build-essential dh-make debhelper devscripts fakeroot
+       uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" /debootstrap/debootstrap --second-stage
+       CHROOT_REPO="$$REPO" getrfsfile.sh "rootfs_custom_files/etc/apt/sources.list" >"$@.tmp/etc/apt/sources.list"
+       uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get update
+       uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" sh -c "dpkg -i /root/dummy-debs/*.deb"
+       uexec --allow-setgroups chroot_qemu_static.sh "$(CURDIR)/$@.tmp" apt-get -y install --no-install-recommends build-essential dh-make debhelper devscripts fakeroot
        printf "\ndeb file:///root/devrepo/ ./\n" >>"$@.tmp/etc/apt/sources.list"
        mv "$@.tmp" "$@"
 
@@ -68,16 +53,19 @@ build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source: repo/%/.repo build-env/$(DIST
        cp -r "$(dir $<)" "$(dir $@)"
        touch "$@"
 
-bin/$(DISTRO)/$(RELEASE)/deb-%/.build: build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source
+bin/$(DISTRO)/$(RELEASE)/%/.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/$(DISTRO)/$(RELEASE)" sh -c "\
+       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; \
          dpkg-scanpackages -m . > Packages; \
          gzip -k Packages; \
          xz -k Packages; \
-         dpkg --remove \$$(grep '^Package: ' Packages | grep -o '[^ ]*$$') || true; \
+         for package in \$$(grep '^Package: ' Packages | grep -o '[^ ]*$$'); \
+           do apt-get purge "$$package"; \
+         done; \
+         apt-get autoremove --purge
          cd /root/$(notdir $(<:build-env/$(DISTRO)/$(RELEASE)/root/%/src/.source=%))/src/; \
          apt-get update; \
          apt-get -y build-dep .; \
@@ -88,18 +76,11 @@ bin/$(DISTRO)/$(RELEASE)/deb-%/.build: build-env/$(DISTRO)/$(RELEASE)/root/%/src
        find "$(<:%/src/.source=%)" -maxdepth 1 -iname '*.deb' -not -iname '*dbgsym*' -exec cp {} "$(dir $@)/" \; ; \
        touch "$@"
 
-pkg-clean-repo@deb-%: clean-repo@%
-       @true
-
-clean-repo: $(addprefix pkg-clean-repo@,$(TARGETS))
-
-pkg-reset-repo@deb-%: reset-repo@%
-       @true
-
-reset-repo: $(addprefix pkg-reset-repo@,$(TARGETS))
+clean-repo: $(addprefix clean-repo@,$(PACKAGES_TO_BUILD))
+reset-repo: $(addprefix reset-repo@,$(PACKAGES_TO_BUILD))
 
 clean-buildenv:
-       $(SETUPBUILDENV) uexec rm -rf "$(CURDIR)/build-env/$(DISTRO)/$(RELEASE)"
+       uexec rm -rf "$(CURDIR)/build-env/$(DISTRO)/$(RELEASE)"
        rmdir "$(CURDIR)/build-env/$(DISTRO)/" || true
        rmdir "$(CURDIR)/build-env/" || true
 
diff --git a/script/generate_make_build_dependencies_for_debs.sh b/script/generate_make_build_dependencies_for_debs.sh
new file mode 100755 (executable)
index 0000000..2455c84
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+for package in $PACKAGES_TO_BUILD
+do
+  bulddeps="$(tr '\n' '\1' <"repo/$package/debian/control" |
+    grep -o "$(printf '\(^\|\1\)Build-Depends:[^\1]*\(\1\\s\+[^\1]*\)*')" |
+    tr '\1\n' '  ' | sed 's/ Build-Depends: //' |
+    sed 's/([^)]*)//g;s/\(\,\|\s\)\+/ /g')"
+  for dep in $bulddeps
+  do
+    for repo in $PACKAGES_TO_BUILD
+    do
+      debs="$(grep '^Package: \|^Provides: ' "repo/$repo/debian/control" | sed 's/^Package: //;s/Provides: //')"
+      for deb in $debs
+      do
+        if [ "$dep" = "$deb" ]
+        then
+          echo "$DEP_PREFIX$package$DEP_SUFFIX: $DEP_PREFIX$repo$DEP_SUFFIX"
+        fi
+      done
+    done
+  done
+done
diff --git a/script/mkdummydeb.sh b/script/mkdummydeb.sh
new file mode 100755 (executable)
index 0000000..787df97
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh -x
+
+[ -n "$1" ] || exit 1
+
+name="$(basename "$1" .deb)"
+cd "$(dirname "$1")"
+
+version=$2
+
+if [ -z "$2" ]
+  then version=99
+fi
+
+equivs-build - <<EOF
+Section: misc
+Priority: optional
+Standards-Version: 3.9.2
+
+Package: $name-dummy
+Version: $version
+Provides: $name
+Architecture: all
+Description: Dummy $name package. It probably caused problems in the changeroot.
+EOF
+
+mv "$name-dummy_${version}_all.deb" "$name.deb"
index 623d7f1d63a3d71938d9ceb43d5ba29b1e7b42dd..c439057e3ba3a1f019a2b6779cddb2f6de39cb6b 100644 (file)
@@ -6,6 +6,11 @@ default_target: all
 project_root := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..)
 export project_root
 
+define newline
+
+
+endef
+
 VARS_OLD := $(subst %,,$(subst *,,$(.VARIABLES)))
 
 ifeq ($(shell test -e "$(project_root)/config/userdefined.mk" && echo -n yes),yes)
@@ -63,6 +68,14 @@ endif
 
 include $(project_root)/src/package_list.mk
 
+generate_make_build_dependencies_for_debs:
+       export DEP_PREFIX=$(DEP_PREFIX); \
+       export DEP_SUFFIX=$(DEP_SUFFIX); \
+       if [ -n "$(TMP_TARGET_FILE)" ]; \
+         then generate_make_build_dependencies_for_debs.sh >"$(TMP_TARGET_FILE)"; \
+         else generate_make_build_dependencies_for_debs.sh; \
+       fi
+
 %/.dir:
        mkdir -p "$(dir $@)"
        touch "$@"
index e85a1fd2526cf0df8e2dd0bd36bd818f057579c7..d881a182efe11afdf2772bf9436e4d5208fa550b 100644 (file)
@@ -1,17 +1,17 @@
 define parse_package_list
-$(shell
-    for list in $(PACKAGE_LIST_PATH);
+$(shell for list in $(PACKAGE_LIST_PATH);
     do
       cat "$(project_root)/packages/$$list/$(1)" 2>/dev/null || true;
     done | sed 's/#.*//' | tr '\n' ' ' | sed 's/\s\+/ /g' | sed 's/^\s\+\|\s\+$$//g';
   )
 endef
 
-PACKAGES_INSTALL_DEBOOTSTRAP = $(call parse_package_list,install_debootstrap)
-PACKAGES_INSTALL_EARLY       = $(call parse_package_list,install_early)
-PACKAGES_INSTALL_TARGET      = $(call parse_package_list,install_target)
-PACKAGES_TO_DOWNLOAD         = $(call parse_package_list,download)
-PACKAGES_TO_BUILD            = $(call parse_package_list,build)
+PACKAGES_INSTALL_DEBOOTSTRAP  = $(call parse_package_list,install_debootstrap)
+PACKAGES_INSTALL_EARLY        = $(call parse_package_list,install_early)
+PACKAGES_INSTALL_TARGET       = $(call parse_package_list,install_target)
+PACKAGES_TO_DOWNLOAD          = $(call parse_package_list,download)
+PACKAGES_TO_BUILD             = $(call parse_package_list,build)
+PACKAGES_BOOTSTRAP_WORKAROUND = $(call parse_package_list,defer_installation_of_problemetic_package)
 
 ifneq ($(AARCH64_EXECUTABLE),yes)
   PACKAGES_INSTALL_DEBOOTSTRAP+=fakechroot"
@@ -37,3 +37,4 @@ export PACKAGES_INSTALL_EARLY
 export PACKAGES_INSTALL_TARGET
 export PACKAGES_TO_DOWNLOAD
 export PACKAGES_TO_BUILD
+export PACKAGES_BOOTSTRAP_WORKAROUND