Refactoring. reset-repo -> update-repo, *@* -> *//*. Use git clone --mirror instead...
authorDaniel Abrecht <public@danielabrecht.ch>
Sun, 26 Dec 2021 01:54:17 +0000 (02:54 +0100)
committerDaniel Abrecht <public@danielabrecht.ch>
Sun, 26 Dec 2021 01:54:32 +0000 (02:54 +0100)
15 files changed:
README.md
chroot-build-helper/makefile
chroot-build-helper/real-makefile
kernel/makefile
makefile
platform/librem5/README.md
platform/librem5/makefile
platform/librem5/platform.mk
platform/librem5/uboot/makefile
platform/makefile
platform/pinephone-pro/makefile
platform/pinephone-pro/uboot/makefile
repo/.dir [deleted file]
script/with-repo.sh [new file with mode: 0755]
src/make-helper-functions.mk

index cf6cfd6c1acd2bbed2e0a17ffdbe3eb747e65fa5..92d6cab2e561717b5623cf42335f7a86de89f1e4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -83,7 +83,7 @@ make
 | IMAGE_BUILDER_REPO | `deb https://repo.dpa.li/apt/dpa-image-builder/ $(DISTRO)/$(RELEASE) $(BUILDER_PLATFORM)` | If $USE_IMAGE_BUILDER_REPO is set to yes, this repos is used & added. |
 | IMAGE_BUILDER_REPO_KEY | https://repo.dpa.li/apt/dpa-image-builder/key.gpg | If $USE_IMAGE_BUILDER_REPO is set to "yes", this repo key is added. |
 
-You can use the config-set@% and the config-unset@% targets to change these variables or the urls or branches of any of the repos. See the next section on how to use that feature.
+You can use the config-set//% and the config-unset//% targets to change these variables or the urls or branches of any of the repos. See the next section on how to use that feature.
 
 You can also specify them in the make command directly instead, but if you do it that way, you need to take care of the following yourself:
 
@@ -95,7 +95,7 @@ There are also make targets for that.
 Packages can be built even if BUILD_PACKAGES is set to "no". For this, just enter
 the `chroot-build-helper` subdirectory. In there, you can use `make` as normal,
 including the `repo`, `reset*` and `clean*` make targets. You can also build an individual
-package that way, using the `make build@%` make target (just replace `%` with the repo name).
+package that way, using the `make build//%` make target (just replace `%` with the repo name).
 
 ## Platform specific things
 
@@ -108,8 +108,8 @@ package that way, using the `make build@%` make target (just replace `%` with th
 | ---- | ------- |
 | all  | Build the image |
 | config-list | List all config variables, this includes the repo urls and branches |
-| [CONF=path/to/config] config-set@variable-name TO=new-value | Set variable-name to new-value in file conf/$CONF, which defaults to userdefined. This will also clean up or reset images and repos as needed. |
-| [CONF=path/to/config] config-unset@variable-name | Remove variable from file conf/$CONF. This will also clean up or reset images and repos as needed. |
+| [CONF=path/to/config] config-set//variable-name TO=new-value | Set variable-name to new-value in file conf/$CONF, which defaults to userdefined. This will also clean up or reset images and repos as needed. |
+| [CONF=path/to/config] config-unset//variable-name | Remove variable from file conf/$CONF. This will also clean up or reset images and repos as needed. |
 | bootloader | builds the uboot bootloader at uboot/bin/uboot_firmware_and_dtb.bin |
 | enter-buildenv | Setup environment & PATH most scripts of this repo use & execute $SHELL (unfortunately, make sets thet to sh...) |
 | linux | builds the kernel packages |
@@ -119,15 +119,15 @@ package that way, using the `make build@%` make target (just replace `%` with th
 | clean-image | Removes the image for the current release. |
 | clean-image-all | Removes all images in the bin/ folder |
 | repo | Clones all repositories into repo/* |
-| repo@reponame | Clones the specified repository to repo/reponame |
+| repo//reponame | Clones the specified repository to repo/remote |
 | clean-build  | remove all build files. (the files in build/, bin/ etc.) |
 | clean-repo | Completely removes all repositories |
-| clean-repo@reponame | Completly removes repo/reponame |
-| reset-repo | Remove all files in the repos except .git, cleanly check them out again from the local repo in .git, and update them if possible |
-| reset-repo@reponame | same as the above, but for a speciffic repo |
+| clean-repo//reponame | Completly removes repo |
+| update-repo | Update mirror all repos |
+| update-repo//reponame | same as the above, but for a speciffic repo |
 | clean-all | short for clean-repo and clean-build, removes pretty much everithing. |
 | reset | Short for reset-repo and clean-build, mostly the same as clean-all, but doesn't require downloading all repos again |
-| chroot@path/to/env/ | Chroot to a directory. Useful to look into a build environment in chroot-build-helper/build-env/*/ and similar stuff. |
+| chroot//path/to/env/ | Chroot to a directory. Useful to look into a build environment in chroot-build-helper/build-env/*/ and similar stuff. |
 
 The urls and reponame of all used repositories as well as the defaults of most variables can be found in the config/ directory, with the exception of the imx firmware from nxp, which is still in src/repositories.mk.
 
@@ -164,8 +164,8 @@ These subdirectories contain the following files:
 
 All config and package lists in the search path are combined. Config settings
 in config files later in the path override earlier ones. The special config file
-`config/user_config_override`, which is the default for the `config-set@%' and
-`config-unset@%` makefile targets, can override the settings from all other config
+`config/user_config_override`, which is the default for the `config-set//%' and
+`config-unset//%` makefile targets, can override the settings from all other config
 files and will be ignored in the git repo. It is useful for changing local
 settings & preferences, such as the repos to use for bootstrapping, the image
 files size, or using a different branch or remote for a repo, or generally
@@ -181,7 +181,7 @@ These files can also have an extension with a special meaning:
  * `.ignore`: If there was a file with the same name earlier in the config path, ignore it.
 
 The recommended way of creating an image with your own additional packages & files
-in it is to create a new image variant. Use `make config-set@VARIANT TO=your-new-variant`
+in it is to create a new image variant. Use `make config-set//VARIANT TO=your-new-variant`
 to change the default variant. After that, you can check in which directories
 the build script will now search the configs: `make config-list | grep '^CONFIG_PATH'`.
 You can then add & make changes to the configs related to your new image variant.
index 0a7ec1688045e2f12fd887a1aecd30eeae2b7c09..52870106a4f040c65cffbfda05639830a129e4e9 100644 (file)
@@ -15,7 +15,7 @@ include ../src/make-helper-functions.mk
 # the make dependencies for all debian packages, and thus also checks out the
 # repos of all packages to be built.
 
-repo reset-repo clean-repo clean-build clean-build-all: force
+repo update-repo clean-repo clean-build clean-build-all: force
        $(MAKE) -f real-makefile "$@"
 
 %: force
index 751875e274ba6ae69e3f4c207ed7474352c55c00..24f40c7fe90b60ad62c4d35c0bba70b160f566c7 100644 (file)
@@ -4,10 +4,10 @@ include $(GENERATED_DEPENDENCIES_FILE)
 UEXEC=../build/bin/uexec
 
 all: $(patsubst %,bin/$(DISTRO)/$(RELEASE)/%/.build,$(PACKAGES_TO_BUILD))
-repo: $(addprefix repo@,$(PACKAGES_TO_BUILD))
+repo: $(addprefix repo//,$(PACKAGES_TO_BUILD))
 
-build@%: DONT_BUILD_IF_IN_REPO=no
-build@%: bin/$(DISTRO)/$(RELEASE)/%/.build
+build//%: DONT_BUILD_IF_IN_REPO=no
+build//%: bin/$(DISTRO)/$(RELEASE)/%/.build
        @true
 
 build-env/$(DISTRO)/$(RELEASE)/deb/%.deb: build-env/$(DISTRO)/$(RELEASE)/deb/.dir
@@ -43,18 +43,45 @@ build-env/$(DISTRO)/$(RELEASE)/rootfs: build-env/.dir | $(DEBOOTSTRAP_SCRIPT) $(
        mv "$@.tmp" "$@"
        uexec rm -rf "$@.old"
 
-bin/$(DISTRO)/$(RELEASE)/%/.build: repo/.%.repo build-env/$(DISTRO)/$(RELEASE)/rootfs | $(UEXEC) bin/$(DISTRO)/$(RELEASE)/.dir
+repo-add//%:
+       set -x; \
+       cd "bin/$(DISTRO)/$(RELEASE)/$(patsubst repo-add//%,%,$@)/"; \
+       name="$$(printf '%s' *.changes)"; \
+       addrepo.sh "$$name"
+
+clean-repo: $(addprefix clean-repo//,$(PACKAGES_TO_BUILD))
+update-repo: $(addprefix update-repo//,$(PACKAGES_TO_BUILD))
+
+clean-buildenv: | $(UEXEC)
+       uexec rm -rf "build-env/$(DISTRO)/$(RELEASE)"
+       rmdir "build-env/$(DISTRO)/" || true
+       rm -f "build-env/.dir"
+       rmdir "build-env/" || true
+
+clean-bin:
+       rm -rf bin/$(DISTRO)/$(RELEASE)
+       rmdir bin/$(DISTRO)/ || true
+       rmdir bin || true
+
+clean-build: clean-buildenv clean-bin
+
+clean-build-all:
+       uexec rm -rf "build-env/" "bin/"
+
+.SECONDEXPANSION:
+bin/$(DISTRO)/$(RELEASE)/%/.build: $$(call repodir,%) build-env/$(DISTRO)/$(RELEASE)/rootfs | $(UEXEC) bin/$(DISTRO)/$(RELEASE)/.dir
        DO_LOCK=2 chns "build-env/$(DISTRO)/$(RELEASE)/rootfs/" sh -ex -c "apt-get -y update && apt-get -y dist-upgrade" || true; \
        # If repo is needed & packages to be built for it, make sure it's created if necessary
        if [ "$(USE_IMAGE_BUILDER_REPO)" = yes ] && [ -n "$(IMAGE_BUILDER_REPO)" ] && [ -n "$(IMAGE_BUILDER_REPO_KEY)" ] && [ "$(ADD_TO_EXTERNAL_REPO)" = "yes" ]; then addrepo.sh; fi
        project="$(patsubst bin/$(DISTRO)/$(RELEASE)/%/.build,%,$@)" \
        branch="$(repo-branch@$(patsubst bin/$(DISTRO)/$(RELEASE)/%/.build,%,$@))" \
+       repodir="$(call repodir,$(patsubst bin/$(DISTRO)/$(RELEASE)/%/.build,%,$@))" \
        CHNS_OVERLAY=1 \
        CHNS_EXTRA="( \
          set -x; \
          mkdir -p tmp/repo/pool/ build/; \
          mount -o rbind,rprivate \"\$$project_root/chroot-build-helper/bin/\$$DISTRO/\$$RELEASE/\" tmp/repo/pool/; \
-         git clone --shared -b \"\$$branch\" \"\$$project_root/repo/\$$project/.git\" build/src; \
+         git clone --shared -b \"\$$branch\" \"$$project_root/\$$repodir\" build/src; \
        ); \
        export commit=\"\$$(cd build/src/ && git rev-parse HEAD)\$$([ -z \"\$$(cd build/src/ && git status --porcelain)\" ] || echo -dirty)\"; \
        export version=\"\$$(cd build/src/ && dpkg-parsechangelog --show-field Version | grep -o '^[^+~-]*' | tr -d '\n')+ib~c\$$(cd build/src/ && git rev-list HEAD --count)-\$$commit\"; \
@@ -74,13 +101,14 @@ bin/$(DISTRO)/$(RELEASE)/%/.build: repo/.%.repo build-env/$(DISTRO)/$(RELEASE)/r
          echo \"deb [trusted=yes] file:///tmp/repo/ ./\" >\"/etc/apt/sources.list.d/devrepo.list\"; \
          apt-get -y update && apt-get -y dist-upgrade; \
          cd /build/src/; \
-          if [ \"\$$DONT_BUILD_IF_IN_REPO\" = yes ] && ( \
-              for package in \$$(gawk 'BEGIN{RS=\"\\n\\n\";FS=\"\\n\"}{ if (\$$0 ~ /\\nArchitecture:.* (arm64|any|all).*\\n/ && \$$1 ~ /Package:/) { match(\$$1, /Package: *([^ ]*) */, package); print package[1] } }' <debian/control); \
-                do if apt-cache show \"\$$package=\$$version\" >/dev/null 2>&1; then exit 0; fi; \
-              done; \
-              exit 1; \
-            ); \
-            then echo 'Not building package, this version is already in the repo, and DONT_BUILD_IF_IN_REPO is set to yes'; exit 0; \
+         if [ \"\$$DONT_BUILD_IF_IN_REPO\" = yes ] \
+           && ( \
+             for package in \$$(gawk 'BEGIN{RS=\"\\n\\n\";FS=\"\\n\"}{ if (\$$0 ~ /\\nArchitecture:.* (arm64|any|all).*\\n/ && \$$1 ~ /Package:/) { match(\$$1, /Package: *([^ ]*) */, package); print package[1] } }' <debian/control); \
+               do if apt-cache show \"\$$package=\$$version\" >/dev/null 2>&1; then exit 0; fi; \
+             done; \
+             exit 1; \
+           ); \
+           then echo 'Not building package, this version is already in the repo, and DONT_BUILD_IF_IN_REPO is set to yes'; exit 0; \
          fi; \
          dch -b -D \"\$$DISTRO-\$$RELEASE\" --force-distribution -v \"\$$version\" \"Version suffix automatically added by dpa-image-builder. Git commit \$$commit.\"; \
          apt-get -y build-dep .; \
@@ -93,31 +121,6 @@ bin/$(DISTRO)/$(RELEASE)/%/.build: repo/.%.repo build-env/$(DISTRO)/$(RELEASE)/r
          find .. -maxdepth 1 -type f -exec cp {} \"/tmp/repo/pool/\$$project/\" ';' -print; \
        "
        if [ "$(ADD_TO_EXTERNAL_REPO)" = "yes" ]; \
-         then make -f real-makefile "repo-add@$(patsubst bin/$(DISTRO)/$(RELEASE)/%/.build,%,$@)" || true; \
+         then make -f real-makefile "repo-add//$(patsubst bin/$(DISTRO)/$(RELEASE)/%/.build,%,$@)" || true; \
        fi
        touch "$@"
-
-repo-add@%:
-       set -x; \
-       cd "bin/$(DISTRO)/$(RELEASE)/$(patsubst repo-add@%,%,$@)/"; \
-       name="$$(printf '%s' *.changes)"; \
-       addrepo.sh "$$name"
-
-clean-repo: $(addprefix clean-repo@,$(PACKAGES_TO_BUILD))
-reset-repo: $(addprefix reset-repo@,$(PACKAGES_TO_BUILD))
-
-clean-buildenv: | $(UEXEC)
-       uexec rm -rf "build-env/$(DISTRO)/$(RELEASE)"
-       rmdir "build-env/$(DISTRO)/" || true
-       rm -f "build-env/.dir"
-       rmdir "build-env/" || true
-
-clean-bin:
-       rm -rf bin/$(DISTRO)/$(RELEASE)
-       rmdir bin/$(DISTRO)/ || true
-       rmdir bin || true
-
-clean-build: clean-buildenv clean-bin
-
-clean-build-all:
-       uexec rm -rf "build-env/" "bin/"
index e5122ee3fbdb18e8c0b5ccfb7ea1300765294696..8001044fea23c2562024273813c06c4c0b0a2e6d 100644 (file)
@@ -1,38 +1,42 @@
 include ../src/make-helper-functions.mk
 
-all: bin/.done
-       @true
+.SECONDEXPANSION:
 
-config: repo/linux/.config
+all: bin/.done
        @true
 
-menuconfig: repo/linux/.config
-       $(MAKE) -C repo/linux ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILER) menuconfig
-       $(MAKE) -C repo/linux ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILER) savedefconfig
-       cp repo/linux/defconfig configs/$(KERNEL_CONFIG_TARGET)
-
-repo: repo/.linux.repo
+menuconfig: $$(call repodir,linux) 
+       with-repo.sh linux bash -ex -c '\
+         if [ -f "configs/$$KERNEL_CONFIG_TARGET" ]; \
+           then cp "configs/$$KERNEL_CONFIG_TARGET" "repo/linux/arch/arm64/configs/$${KERNEL_CONFIG_TARGET}_defconfig"; \
+         fi; \
+         $(MAKE) -C "$$repodir/linux" ARCH=arm64 CROSS_COMPILE="$$CROSS_COMPILER" "$$KERNEL_CONFIG_TARGET"_defconfig; \
+         $(MAKE) -C "$$repodir/linux" ARCH=arm64 CROSS_COMPILE="$$CROSS_COMPILER" menuconfig; \
+         $(MAKE) -C "$$repodir/linux" ARCH=arm64 CROSS_COMPILE="$$CROSS_COMPILER" savedefconfig; \
+         cp "$$repodir/linux" "configs/$$KERNEL_CONFIG_TARGET"; \
+       '
+
+repo: $$(call repodir,linux)
        @true
 
-repo/linux/.config: repo/.linux.repo
-       if [ -f "configs/$(KERNEL_CONFIG_TARGET)" ]; \
-         then cp "configs/$(KERNEL_CONFIG_TARGET)" "repo/linux/arch/arm64/configs/$(KERNEL_CONFIG_TARGET)_defconfig"; \
-       fi
-       $(MAKE) -C repo/linux ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILER) $(KERNEL_CONFIG_TARGET)_defconfig
-
-bin/.done: repo/.linux.repo repo/linux/.config bin/.dir
-       $(MAKE) -C repo/linux ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILER) KBUILD_IMAGE=arch/arm64/boot/Image bindeb-pkg
-       cp repo/linux-libc-*.deb bin/linux-libc.deb || true
-       cp repo/linux-image-*[^g]_*_*.deb bin/linux-image.deb
-       cp repo/linux-image-*g_*_*.deb bin/linux-image-dbg.deb || true
-       cp repo/linux-headers-*.deb bin/linux-headers.deb || true
-       rm repo/linux-*
-       touch bin/.done
-
-clean-repo: clean-repo@linux
+bin/.done: $$(call repodir,linux) | bin/.dir
+       with-repo.sh linux bash -ex -c '\
+         if [ -f "configs/$$KERNEL_CONFIG_TARGET" ]; \
+           then cp "configs/$$KERNEL_CONFIG_TARGET" "repo/linux/arch/arm64/configs/$${KERNEL_CONFIG_TARGET}_defconfig"; \
+         fi; \
+         $(MAKE) -C "$$repodir/linux" ARCH=arm64 CROSS_COMPILE="$$CROSS_COMPILER" "$$KERNEL_CONFIG_TARGET"_defconfig; \
+         $(MAKE) -C "$$repodir/linux" ARCH=arm64 CROSS_COMPILE="$$CROSS_COMPILER" KBUILD_IMAGE=arch/arm64/boot/Image bindeb-pkg; \
+         cp "$$repodir"/linux-libc-*.deb bin/linux-libc.deb || true; \
+         cp "$$repodir"/linux-image-*[^g]_*_*.deb bin/linux-image.deb; \
+         cp "$$repodir"/linux-image-*g_*_*.deb bin/linux-image-dbg.deb || true; \
+         cp "$$repodir"/linux-headers-*.deb bin/linux-headers.deb || true; \
+       '
+       touch bin/.done;
+
+clean-repo: clean-repo//linux
        @true
 
-reset-repo: reset-repo@linux
+reset-repo: reset-repo//linux
        @true
 
 clean-build-all: clean-build
index c35ef1ce8fbe3b221171a9efc97c826ffe7d97a7..98f2c51ae545de31934e2cd30b0fdf5d41c4e3d6 100644 (file)
--- a/makefile
+++ b/makefile
@@ -33,22 +33,7 @@ kernel/bin/linux-image.deb:
        mkdir -p "$(dir $@)"
        touch "$@"
 
-build/bin/fuseloop: repo/.fuseloop.repo build/bin/.dir
-       $(MAKE) -C repo/fuseloop/
-       cp repo/fuseloop/fuseloop build/bin/
-
-build/bin/usernsexec: repo/.usernsexec.repo build/bin/.dir
-       $(MAKE) -C repo/usernsexec/
-       cp repo/usernsexec/bin/usernsexec build/bin/
-       cp repo/usernsexec/script/uexec build/bin/
-
-build/bin/tar2ext: repo/.tar2ext.repo build/bin/.dir
-       $(MAKE) -C repo/tar2ext/
-       cp repo/tar2ext/scripts/sload.ext4 build/bin/
-       ( cd build/bin/; ln -sf sload.ext4 sload.ext3; ln -sf sload.ext4 sload.ext2; )
-       cp repo/tar2ext/bin/tar2ext build/bin/
-
-build/$(IMAGE_NAME)/deb/%.deb: build/$(IMAGE_NAME)/deb/.dir
+build/$(IMAGE_NAME)/deb/%.deb: | build/$(IMAGE_NAME)/deb/.dir
        getdeb.sh "$@"
 
 $(DEBOOTSTRAP_SCRIPT): build/$(IMAGE_NAME)/deb/debootstrap.deb
@@ -84,26 +69,16 @@ always:
 rebuild: clean-fs clean-image always
        $(MAKE) all
 
-repo: always \
-  repo/.fuseloop.repo \
-  repo/.usernsexec.repo \
-  repo/.tar2ext.repo
-       $(MAKE) -C platform repo
-       $(MAKE) -C kernel repo
-       if [ "$(BUILD_PACKAGES)" != no ]; \
-         then $(MAKE) -C chroot-build-helper repo; \
-       fi
-
-clean-repo: clean-repo@fuseloop clean-repo@usernsexec clean-repo@tar2ext
+clean-repo: clean-repo//fuseloop clean-repo//usernsexec clean-repo//tar2ext
        $(MAKE) -C platform clean-repo
        $(MAKE) -C kernel clean-repo
        $(MAKE) -C chroot-build-helper clean-repo
 
-reset-repo: reset-repo@fuseloop reset-repo@usernsexec reset-repo@tar2ext
-       $(MAKE) -C platform reset-repo
-       $(MAKE) -C kernel reset-repo
+update-repo: update-repo//fuseloop update-repo//usernsexec update-repo//tar2ext
+       $(MAKE) -C platform update-repo
+       $(MAKE) -C kernel update-repo
        if [ "$(BUILD_PACKAGES)" != no ]; \
-         then $(MAKE) -C chroot-build-helper reset-repo; \
+         then $(MAKE) -C chroot-build-helper update-repo; \
        fi
 
 clean-build: clean-image clean-fs
@@ -124,3 +99,35 @@ chroot:
 
 emulate: bin/$(IMAGE_NAME) kernel/bin/linux-image.deb
        qemu-system-aarch64 -M virt -cpu cortex-a53 -m 3G -kernel repo/linux/debian/tmp/boot/vmlinuz-* -append "root=/dev/vda3" -drive if=none,file=bin/"$(IMAGE_NAME)",format=raw,id=hd -device virtio-blk-device,drive=hd -nographic
+
+.SECONDEXPANSION:
+repo: always \
+  $$(call repodir,fuseloop) \
+  $$(call repodir,usernsexec) \
+  $$(call repodir,tar2ext)
+       $(MAKE) -C platform repo
+       $(MAKE) -C kernel repo
+       if [ "$(BUILD_PACKAGES)" != no ]; \
+         then $(MAKE) -C chroot-build-helper repo; \
+       fi
+
+build/bin/fuseloop: $$(call repodir,fuseloop) | build/bin/.dir
+       with-repo.sh fuseloop bash -ex -c "\
+         $(MAKE) -C \"\$$repodir/fuseloop\"; \
+         cp \"\$$repodir/fuseloop/fuseloop\" build/bin/; \
+       "
+
+build/bin/usernsexec: $$(call repodir,usernsexec) | build/bin/.dir
+       with-repo.sh usernsexec bash -ex -c "\
+         $(MAKE) -C \"\$$repodir/usernsexec/\"; \
+         cp \"\$$repodir/usernsexec/bin/usernsexec\" build/bin/; \
+         cp \"\$$repodir/usernsexec/script/uexec\" build/bin/; \
+       "
+
+build/bin/tar2ext: $$(call repodir,tar2ext) | build/bin/.dir
+       with-repo.sh tar2ext bash -ex -c "\
+         $(MAKE) -C \"\$$repodir/tar2ext/\"; \
+         cp \"\$$repodir/tar2ext/scripts/sload.ext4\" build/bin/; \
+         cp \"\$$repodir/tar2ext/bin/tar2ext\" build/bin/; \
+       "
+       ( cd build/bin/; ln -sf sload.ext4 sload.ext3; ln -sf sload.ext4 sload.ext2; )
index 8f2f795f1fa8eb13fc2313517cac1948fc6bab46..93d78f1158ccc183beeb1ec796739f99535b89f5 100644 (file)
@@ -20,7 +20,7 @@ The uuu scripts this image builder uses are in `script/uuu/`.
 | uuu-flash | flash the image to emmc0 using uuu. You can specify a different image using IMAGE_NAME. If this image doesn't have an uboot usable for flashing, use IMAGE_UBOOT_UNFLASHABLE=1 to use the uboot from uboot/bin/uboot_firmware_and_dtb.bin instead for that step. |
 | uuu-uboot-flash | flash uboot (doesn't include m4) |
 | uuu-test-uboot | Just boot using uboot bootloader from uboot/bin/uboot_firmware_and_dtb.bin (doesn't quiet work as intended yet) |
-| uuu-test-uboot@image | Just boot using uboot bootloader from bin/$(IMAGE_NAME). (doesn't quiet work as intended yet) |
+| uuu-test-uboot//image | Just boot using uboot bootloader from bin/$(IMAGE_NAME). (doesn't quiet work as intended yet) |
 | uuu-test-kernel | Just boot using kernel from .(kernel/bin/linux-image-*.deb. (doesn't quiet work as intended yet) |
 
 ## Other important stuff
index 1ef9a1cf0cf92ef08dec6a27570e4f5ed462413f..cc6468c60532fc8920fc98b1a6ac018e2adf9295 100644 (file)
@@ -2,5 +2,5 @@ include ../../src/make-helper-functions.mk
 
 L5_PLATFORM_COMPONENTS=$(dir $(wildcard */makefile))
 
-all repo clean-repo reset-repo clean-build clean-build-all:
+all repo clean-repo update-repo clean-build clean-build-all:
        for dir in $(L5_PLATFORM_COMPONENTS); do $(MAKE) -C "$$dir" "$@"; done
index 953a44d13b0455bb1f4f52d82b5caa3cc135244e..f4b59ca0e22d48a011abde18d6824ebca28f6dd6 100644 (file)
@@ -46,13 +46,13 @@ uuu-image-do-%: script/uuu/%.lst build/.dir
 uuu-test-uboot: uuu-uboot-do-test-uboot
        @true
 
-uuu-test-uboot@image: uuu-image-do-test-uboot
+uuu-test-uboot//image: uuu-image-do-test-uboot
        @true
 
 uuu-uboot-flash: uuu-uboot-do-uboot-flash
        @true
 
-uuu-flash uuu-flash@image: uuu-image-do-flash
+uuu-flash uuu-flash//image: uuu-image-do-flash
        @true
 
 uuu-test-kernel: kernel/bin/linux-image.deb
index af78562da39a8b0de2cbaeb07c0e9e326ff57b89..8a1865a2927af9736592ed5729900898d2954d90 100644 (file)
@@ -1,5 +1,7 @@
 include ../../../src/make-helper-functions.mk
 
+.SECONDEXPANSION:
+
 UMAKE=env -u MAKEFLAGS make
 
 BOOTLOADER_COMPONENTS += firmware/m4.bin
@@ -18,30 +20,32 @@ BOOTLOADER_COMPONENTS += $(NONFREE_FIRMWARE_CRAP)
 all: bin/uboot_firmware_and_dtb.bin
        @true
 
-config: repo/uboot/.config
-       @true
-
 repo: \
-  repo/.Cortex_M4.repo \
-  repo/.arm-trusted-firmware.repo \
-  repo/.firmware-imx.repo
-
-repo/uboot/.config: repo/.uboot.repo
-       $(UMAKE) -C repo/uboot ARCH=arm CROSS_COMPILE=$(CROSS_COMPILER) $(UBOOT_CONFIG_TARGET)
-
-bin/uboot_firmware_and_dtb.bin: repo/.uboot.repo repo/uboot/.config bin/.dir $(BOOTLOADER_COMPONENTS)
-       cp $(BOOTLOADER_COMPONENTS) repo/uboot/
-       $(UMAKE) -C repo/uboot ARCH=arm CROSS_COMPILE=$(CROSS_COMPILER) flash.bin
-       $(UMAKE) -C repo/uboot ARCH=arm CROSS_COMPILE=$(CROSS_COMPILER) u-boot.imx
-       cp repo/uboot/u-boot.imx "$@"
-
-firmware/m4.bin: repo/.Cortex_M4.repo firmware/.dir
-       $(UMAKE) -C repo/Cortex_M4/
-       cp repo/Cortex_M4/m4.bin firmware/
-
-firmware/bl31.bin: repo/.arm-trusted-firmware.repo firmware/.dir
-       $(UMAKE) -C repo/arm-trusted-firmware/ PLAT=$(ATF_PLATFORM) CROSS_COMPILE=$(CROSS_COMPILER) bl31
-       cp repo/arm-trusted-firmware/build/imx8mq/release/bl31.bin firmware/
+  repo/.firmware-imx.repo \
+  $$(call repodir,Cortex_M4) \
+  $$(call repodir,arm-trusted-firmware) \
+  $$(call repodir,uboot)
+
+bin/uboot_firmware_and_dtb.bin: $$(call repodir,uboot) $(BOOTLOADER_COMPONENTS) | bin/.dir
+       with-repo.sh uboot bash -ex -c '\
+         cp $(BOOTLOADER_COMPONENTS) "$$repodir/uboot/"; \
+         $(UMAKE) -C "$$repodir/uboot/" ARCH=arm CROSS_COMPILE="$$CROSS_COMPILER" "$$UBOOT_CONFIG_TARGET"; \
+         $(UMAKE) -C "$$repodir/uboot/" ARCH=arm CROSS_COMPILE="$$CROSS_COMPILER" flash.bin; \
+         $(UMAKE) -C "$$repodir/uboot/" ARCH=arm CROSS_COMPILE="$$CROSS_COMPILER" u-boot.imx; \
+         cp "$$repodir/uboot/u-boot.imx" "$@"; \
+       '
+
+firmware/m4.bin: $$(call repodir,Cortex_M4) | firmware/.dir
+       with-repo.sh Cortex_M4 bash -ex -c '\
+         $(UMAKE) -C "$$repodir/Cortex_M4/"; \
+         cp "$$repodir/Cortex_M4/m4.bin" "$@"; \
+       '
+
+firmware/bl31.bin: $$(call repodir,arm-trusted-firmware) | bin/.dir
+       with-repo.sh arm-trusted-firmware bash -ex -c '\
+         $(UMAKE) -C "$$repodir/arm-trusted-firmware/" PLAT="$$ATF_PLATFORM" CROSS_COMPILE="$$CROSS_COMPILER" bl31; \
+         cp "$$repodir/arm-trusted-firmware/build/imx8mq/release/bl31.bin" "$@"; \
+       '
 
 firmware/.fw: repo/.firmware-imx.repo
        fwbin=$(wildcard repo/firmware-imx/firmware-imx-*.bin); \
@@ -58,10 +62,10 @@ firmware/.fw: repo/.firmware-imx.repo
 $(NONFREE_FIRMWARE_CRAP): firmware/.fw
        true
 
-clean-repo: clean-repo@uboot clean-repo@Cortex_M4 clean-repo@arm-trusted-firmware clean-repo@firmware-imx
-reset-repo: reset-repo@uboot reset-repo@Cortex_M4 reset-repo@arm-trusted-firmware
+clean-repo: clean-repo//uboot clean-repo//arm-trusted-firmware
+update-repo: update-repo//uboot update-repo//arm-trusted-firmware
 
 clean-build-all: clean-build
 
 clean-build:
-       rm -rf firmware bin repo/uboot/.built
+       rm -rf firmware bin
index ca6d24f2f5f819edfc831e70b9e1080485a24888..5a4f0c0db6406e67d30ca6f2fbf650e26cf13972 100644 (file)
@@ -1,6 +1,6 @@
 include ../src/make-helper-functions.mk
 
-all repo reset-repo clean-repo clean-build clean-build-all: force
+all repo update-repo clean-repo clean-build clean-build-all: force
        make -C $(BUILDER_PLATFORM) $@
 
 %: always
index 7553997f340b497b8008ed1b70edeb60a524f8ed..b8551ef325916e0d5f7e5cf9406b3046daf1abb0 100644 (file)
@@ -2,5 +2,5 @@ include ../../src/make-helper-functions.mk
 
 PLATFORM_COMPONENTS=$(dir $(wildcard */makefile))
 
-all repo clean-repo reset-repo clean-build clean-build-all:
+all repo clean-repo update-repo clean-build clean-build-all:
        for dir in $(PLATFORM_COMPONENTS); do $(MAKE) -C "$$dir" "$@"; done
index 2b7b01e08b91ec50c61bfe6e7b2cb9eeb8780487..b1b8713ca0ebc4748eab0c4506e16038656b1b5b 100644 (file)
@@ -1,5 +1,7 @@
 include ../../../src/make-helper-functions.mk
 
+.SECONDEXPANSION:
+
 UMAKE=env -u MAKEFLAGS make
 
 BOOTLOADER_COMPONENTS += bin/bl31.bin
@@ -7,25 +9,26 @@ BOOTLOADER_COMPONENTS += bin/bl31.bin
 all: bin/u-boot.bin
        @true
 
-config: repo/uboot/.config
-       @true
-
-repo: repo/.arm-trusted-firmware.repo repo/.uboot.repo
-
-repo/uboot/.config: repo/.uboot.repo
-       $(UMAKE) -C repo/uboot ARCH=arm CROSS_COMPILE=$(CROSS_COMPILER) $(UBOOT_CONFIG_TARGET)
-
-bin/u-boot.bin: repo/.uboot.repo repo/uboot/.config bin/.dir bin/bl31.elf
-       cp bin/bl31.elf repo/uboot/
-       $(UMAKE) -C repo/uboot ARCH=arm CROSS_COMPILE=$(CROSS_COMPILER)
-       cp repo/uboot/u-boot-rockchip.bin $@
-
-bin/bl31.elf: repo/.arm-trusted-firmware.repo
-       $(UMAKE) -C repo/arm-trusted-firmware/ PLAT=$(ATF_PLATFORM) CROSS_COMPILE=$(CROSS_COMPILER)
-       cp repo/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf bin/
-
-clean-repo: clean-repo@uboot clean-repo@arm-trusted-firmware
-reset-repo: reset-repo@uboot reset-repo@arm-trusted-firmware
+repo: \
+  $$(call repodir,arm-trusted-firmware) \
+  $$(call repodir,uboot)
+
+bin/u-boot.bin: $$(call repodir,uboot) bin/bl31.elf | bin/.dir
+       with-repo.sh uboot bash -ex -c '\
+         cp bin/bl31.elf "$$repodir/uboot/"; \
+         $(UMAKE) -C "$$repodir/uboot/" ARCH=arm CROSS_COMPILE="$$CROSS_COMPILER" "$$UBOOT_CONFIG_TARGET"; \
+         $(UMAKE) -C "$$repodir/uboot/" ARCH=arm CROSS_COMPILE="$$CROSS_COMPILER"; \
+         cp "$$repodir/uboot/u-boot-rockchip.bin" "$@"; \
+       '
+
+bin/bl31.elf: $$(call repodir,arm-trusted-firmware) | bin/.dir
+       with-repo.sh arm-trusted-firmware bash -ex -c '\
+         $(UMAKE) -C "$$repodir/arm-trusted-firmware/" PLAT="$$ATF_PLATFORM" CROSS_COMPILE="$$CROSS_COMPILER"; \
+         cp "$$repodir/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf" "$@"; \
+       '
+
+clean-repo: clean-repo//uboot clean-repo//arm-trusted-firmware
+update-repo: update-repo//uboot update-repo//arm-trusted-firmware
 
 clean-build-all: clean-build
 
diff --git a/repo/.dir b/repo/.dir
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/script/with-repo.sh b/script/with-repo.sh
new file mode 100755 (executable)
index 0000000..e41cab5
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+if [ -z "$project_root" ]; then
+  echo "Error: project_root is not set! This script has to be called from the makefile build env" >&2
+  exit 1
+fi
+
+mkdir -p "$project_root/build/repo/"
+
+unshare -mr /bin/bash -ex -c '
+cleanup(){ umount "$project_root/build/repo/"; }
+trap cleanup EXIT TERM INT
+mount -t tmpfs none "$project_root/build/repo/"
+clone_repo(){
+  name="$1"
+  repo_branch="$(printenv -- "repo-branch@$name")"
+  repo_source="$(printenv -- "repo-source@$name")"
+  gitrepo="$project_root/repo/$(sed "s / ∕ g" <<<"$repo_source").git"
+  git clone --shared -b "$repo_branch" "$gitrepo" "$repodir/$name"
+}
+export repodir="$project_root/build/repo"
+while IFS=, read name; do clone_repo "$name"; done <<<"$1"
+shift
+read _ uid _ </proc/self/uid_map
+read _ gid _ </proc/self/gid_map
+unshare --map-user="$uid" --map-group="$gid" -- "$@"
+' -- "$@"
index a5cf8177c1dfb097c5f0776bb7833448778a0fbe..339ae95c7b0d317f764366218ed0281c8292bcfc 100644 (file)
@@ -1,4 +1,8 @@
 
+# I don't like doing this, but dash removes environment variables which aren't named to it's liking
+# I use some bash scripts anyway, and bash doesn't do such nonesense, so... yea, this'll use bash now too, sorry.
+SHELL=/bin/bash
+
 default_target: all
 
 .SECONDARY:
@@ -54,7 +58,7 @@ CONF = user_config_override
 ifndef TO
 ifndef BUILDER_PLATFORM
 KNOWN_BOARDS=$(shell basename -a "$(project_root)/config/default/"b-*/ | sed 's|^b-||')
-$(error "Please specify a board. Pass BOARD= to make, or set it in the config using `make config-set@BOARD TO=my-board`. Availabe boards are: $(KNOWN_BOARDS)")
+$(error "Please specify a board. Pass BOARD= to make, or set it in the config using `make config-set//BOARD TO=my-board`. Availabe boards are: $(KNOWN_BOARDS)")
 endif
 endif
 
@@ -73,6 +77,11 @@ endif
 export X_DEBOOTSTRAP_DIR = $(project_root)/build/$(IMAGE_NAME)/debootstrap_script/
 export DEBOOTSTRAP_SCRIPT = $(X_DEBOOTSTRAP_DIR)/usr/share/debootstrap/scripts/$(RELEASE)
 
+define repodir
+repo/$(shell printf '%s\n' "$(repo-source@$(1))" | sed 's / ∕ g').git
+endef
+
+
 generate_make_build_dependencies_for_debs:
        export DEP_PREFIX=$(DEP_PREFIX); \
        export DEP_SUFFIX=$(DEP_SUFFIX); \
@@ -85,62 +94,43 @@ generate_make_build_dependencies_for_debs:
        mkdir -p "$(dir $@)"
        touch "$@"
 
-chroot@%:
+chroot//%:
        export PROMPT_COMMAND="export PS1='$@ (\u)> '"; \
-       CHNS_INTERACTIVE=1 chns "$(realpath $(patsubst chroot@%,%,$@))" /bin/bash
+       CHNS_INTERACTIVE=1 chns "$(realpath $(patsubst chroot//%,%,$@))" /bin/bash
 
 clean:
-       ! echo -n "Please use one of:\n * make clean-build\t# remove all files built for the target image (includes the image)\n * make clean-build-all\t# remove all files that have been built\n * make clean-repo\t# remove the downloaded repos\n * make reset-repo\t# clean up all changes made to the repo & update it if possible\n * make clean-all\t# same as 'make clean-repo clean-build'\n * make clean-all-all\t# same as 'make clean-repo clean-build-all'\n * make reset\t\t# same as 'make reset-repo clean-build'\n * make reset-all\t# same as 'make reset-repo clean-build-all'\n"
+       ! echo -n "Please use one of:\n * make clean-build\t# remove all files built for the target image (includes the image)\n * make clean-build-all\t# remove all files that have been built\n * make clean-repo\t# remove the downloaded repos\n * make update-repo\t# clean up all changes made to the repo & update it if possible\n * make clean-all\t# same as 'make clean-repo clean-build'\n * make clean-all-all\t# same as 'make clean-repo clean-build-all'\n * make reset\t\t# same as 'make update-repo clean-build'\n * make reset-all\t# same as 'make update-repo clean-build-all'\n"
 
-repo/.%.repo:
-       branch="$(repo-branch@$(patsubst repo/.%.repo,%,$@))"; \
-       source="$(repo-source@$(patsubst repo/.%.repo,%,$@))"; \
-       mkdir -p "repo/$(patsubst repo/.%.repo,%,$@)" && cd "repo/$(patsubst repo/.%.repo,%,$@)" && git clone -b "$$branch" "$$source" . && git submodule init && git submodule update
-       touch "repo/$(patsubst repo/.%.repo,%,$@)"
-       touch "$@"
+repo/%.git:
+       repo="$(shell echo "$(patsubst repo/%.git,%,$@)" | sed 's ∕ / g')"; \
+       git clone --mirror "$$repo" "$@"
 
-repo@%:
-       make repo/.$(patsubst repo@%,%,$@).repo
-
-clean-repo@%:
-       rm -rf "repo/$(patsubst clean-repo@%,%,$@)"
-       rm -f "repo/.$(patsubst clean-repo@%,%,$@).repo"
-
-reset-repo@%:
-       set -e; \
-       repo="repo/$(patsubst reset-repo@%,%,$@)"; \
-       source="$(repo-source@$(patsubst reset-repo@%,%,$@))"; \
-       branch="$(repo-branch@$(patsubst reset-repo@%,%,$@))"; \
-       if [ -d "$$repo/.git" ]; \
-       then \
-         cd "$$repo"; \
-         git remote set-url origin "$$source"; \
-         git fetch origin || [ -z "$(FETCH_REQUIRED_TO_SUCCEED)" ]; \
-         find -maxdepth 1 -not -name .git -not -name . -exec rm -rf {} \;; \
-         git reset --hard; \
-         git -c checkout.defaultRemote=origin checkout -f --detach || true; \
-         git branch -D "$$branch" || true; \
-         git -c checkout.defaultRemote=origin checkout -f "$$branch" >/dev/null; \
-         git reset --hard >/dev/null; \
-         git submodule init; \
-         git submodule update; \
-         touch .; \
-         touch "../.$(patsubst reset-repo@%,%,$@).repo"; \
-       fi
+mirror//%:
+       $(MAKE) "repo/$(shell echo "$(patsubst mirror//%,%,$@)" | sed 's / ∕ g').git"
+
+repo//%:
+       $(MAKE) "$(call repodir,$(patsubst repo//%,%,$@))"
+
+clean-repo//%:
+       rm -rf "$(call repodir,$(patsubst clean-repo//%,%,$@))"
+
+update-repo//%:
+       repo="$(call repodir,$(patsubst update-repo//%,%,$@))"; \
+       if [ -f "$$repo" ]; then cd "$$repo" && git remote update && touch .; fi
 
 config-list:
        @$(foreach VAR,$(CONFIG_VARS), echo "$(VAR)" = "$($(VAR))"; )
 
-config-after-update@%:
+config-after-update//%:
        @ set -e; \
-       case "$(patsubst config-after-update@%,%,$@)" in \
+       case "$(patsubst config-after-update//%,%,$@)" in \
          "IMGSIZE"    ) $(MAKE) clean-image ;; \
          "REPO"       ) $(MAKE) clean-fs ;; \
          "CHROOT_REPO") $(MAKE) clean-fs ;; \
          "KERNEL_DTB" ) $(MAKE) clean-fs ;; \
          "IMAGE_NAME" ) $(MAKE) clean-image ;; \
-         "repo-branch@"*) $(MAKE) "reset-repo@$(patsubst config-after-update@repo-branch@%,%,$@)" ;; \
-         "repo-source@"*) $(MAKE) "reset-repo@$(patsubst config-after-update@repo-source@%,%,$@)" FETCH_REQUIRED_TO_SUCCEED=true ;; \
+         "repo-branch@"*) $(MAKE) "update-repo//$(patsubst config-after-update//repo-branch@%,%,$@)" ;; \
+         "repo-source@"*) $(MAKE) "update-repo//$(patsubst config-after-update//repo-source@%,%,$@)" FETCH_REQUIRED_TO_SUCCEED=true ;; \
          "UBOOT_DTB" | "UBOOT_CONFIG_TARGET" | "repo-source@uboot" | "repo-branch@uboot") \
            $(MAKE) -C "$(project_root)/platform/$(BUILDER_PLATFORM)/" clean-build \
          ;; \
@@ -149,29 +139,24 @@ config-after-update@%:
          ;; \
        esac
 
-config-pre-set-check@%:
-       @case "$(patsubst config-pre-set-check@%,%,$@)" in \
-         *) ;; \
-       esac
-
-config-set@%: config-pre-set-check@%
+config-set//%:
        @ if [ -z "$(TO)" ]; \
-         then echo "Usage: config-set@variablename TO=new_value"; \
+         then echo "Usage: config-set//variablename TO=new_value"; \
          false; \
        fi
-       V="$(patsubst config-set@%,%,$@)"; \
+       V="$(patsubst config-set//%,%,$@)"; \
        sed -i "/^$$V[ ]*=/d" "$(project_root)/config/$(CONF)" 2>&-; \
        echo "$$V = $(TO)" >> $(project_root)/config/$(CONF)
-       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-set@%,%,$@))" "config-after-update@$(patsubst config-set@%,%,$@)"
+       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-set//%,%,$@))" "config-after-update//$(patsubst config-set//%,%,$@)"
 
-config-unset@%:
-       V="$(patsubst config-unset@%,%,$@)"; \
+config-unset//%:
+       V="$(patsubst config-unset//%,%,$@)"; \
        sed -i "/^$$V[ ]*=/d" "$(project_root)/config/$(CONF)"
-       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-unset@%,%,$@))" "config-after-update@$(patsubst config-unset@%,%,$@)"
+       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-unset//%,%,$@))" "config-after-update@$(patsubst config-unset//%,%,$@)"
 
 clean-all: clean-repo clean-build
 clean-all-all: clean-repo clean-build-all
-reset: reset-repo clean-build
-reset-all: reset-repo clean-build-all
+reset: update-repo clean-build
+reset-all: update-repo clean-build-all
 
-.PHONY: all repo reset-repo clean-repo clean clean-all clean-all-all clean-build clean-build-all
+.PHONY: all repo update-repo clean-repo clean clean-all clean-all-all clean-build clean-build-all