From fa5baf42d72086480fb5a540fa952228dc799da6 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Fri, 29 Jul 2022 13:32:04 -0700 Subject: [PATCH] More file/dir re-organizing --- Makefile | 109 +++++++++++++++--- config/{ => debug}/busybox.config | 0 {toolchain => config/toolchain}/Dockerfile | 0 {toolchain => config/toolchain}/Makefile | 0 .../config/package-hashes-x86_64.txt | 0 .../toolchain}/config/packages-base.list | 0 .../toolchain}/config/packages-x86_64.list | 0 .../toolchain}/scripts/packages-install | 0 .../toolchain}/scripts/packages-update | 0 make/fetch.mk | 44 ------- make/keys.mk | 31 ----- src/{sample => }/init.c | 0 12 files changed, 92 insertions(+), 92 deletions(-) rename config/{ => debug}/busybox.config (100%) rename {toolchain => config/toolchain}/Dockerfile (100%) rename {toolchain => config/toolchain}/Makefile (100%) rename {toolchain => config/toolchain}/config/package-hashes-x86_64.txt (100%) rename {toolchain => config/toolchain}/config/packages-base.list (100%) rename {toolchain => config/toolchain}/config/packages-x86_64.list (100%) rename {toolchain => config/toolchain}/scripts/packages-install (100%) rename {toolchain => config/toolchain}/scripts/packages-update (100%) delete mode 100644 make/fetch.mk delete mode 100644 make/keys.mk rename src/{sample => }/init.c (100%) diff --git a/Makefile b/Makefile index 4634fd6..7bf90cc 100644 --- a/Makefile +++ b/Makefile @@ -5,16 +5,14 @@ SRC_DIR := src TARGET := local CACHE_DIR := cache CONFIG_DIR := config -TOOLCHAIN_DIR := toolchain +TOOLCHAIN_DIR := config/toolchain SRC_DIR := src USER := $(shell id -g):$(shell id -g) CPUS := $(shell nproc) ARCH := x86_64 include $(PWD)/config/global.env -include $(PWD)/make/keys.mk -include $(PWD)/make/fetch.mk -include $(PWD)/toolchain/Makefile +include $(TOOLCHAIN_DIR)/Makefile .DEFAULT_GOAL := default .PHONY: default @@ -59,8 +57,8 @@ run: default # Run ncurses busybox config menu and save output .PHONY: busybox-config busybox-config: - rm $(CONFIG_DIR)/busybox.config - make $(CONFIG_DIR)/busybox.config + rm $(CONFIG_DIR)/debug/busybox.config + make $(CONFIG_DIR)/debug/busybox.config # Run linux config menu and save output .PHONY: linux-config @@ -68,19 +66,96 @@ linux-config: rm $(CONFIG_DIR)/$(TARGET)/linux.config make $(CONFIG_DIR)/$(TARGET)/linux.config +.PHONY: keys +keys: \ + $(KEY_DIR)/$(LINUX_KEY).asc \ + $(KEY_DIR)/$(BUSYBOX_KEY).asc + +$(KEY_DIR)/$(LINUX_KEY).asc: + $(call fetch_pgp_key,$(LINUX_KEY)) + +$(KEY_DIR)/$(BUSYBOX_KEY).asc: + $(call fetch_pgp_key,,$(BUSYBOX_KEY)) + +define fetch_pgp_key + mkdir -p $(KEY_DIR) && \ + $(toolchain) ' \ + for server in \ + ha.pool.sks-keyservers.net \ + hkp://keyserver.ubuntu.com:80 \ + hkp://p80.pool.sks-keyservers.net:80 \ + pgp.mit.edu \ + ; do \ + echo "Trying: $${server}"; \ + gpg \ + --recv-key \ + --keyserver "$${server}" \ + --keyserver-options timeout=10 \ + --recv-keys "$(1)" \ + && break; \ + done; \ + gpg --export -a $(1) > $(KEY_DIR)/$(1).asc; \ + ' +endef + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(CACHE_DIR): + mkdir -p $(CACHE_DIR) + +$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig: + curl \ + --url $(BUSYBOX_SERVER)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig \ + --output $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig + +$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2: + curl \ + --url $(BUSYBOX_SERVER)/busybox-$(BUSYBOX_VERSION).tar.bz2 \ + --output $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 + +$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign: + curl \ + --url $(LINUX_SERVER)/linux-$(LINUX_VERSION).tar.sign \ + --output $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign + +$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz: + curl \ + --url $(LINUX_SERVER)/linux-$(LINUX_VERSION).tar.xz \ + --output $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz + +$(CACHE_DIR)/linux-$(LINUX_VERSION).tar: + xz -d $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz + +$(CACHE_DIR)/linux-$(LINUX_VERSION): $(CACHE_DIR)/linux-$(LINUX_VERSION).tar + $(call toolchain,$(USER), " \ + cd /cache && \ + gpg --import /keys/$(LINUX_KEY).asc && \ + gpg --verify linux-$(LINUX_VERSION).tar.sign && \ + tar xf linux-$(LINUX_VERSION).tar; \ + ") + +$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION): + $(call toolchain,$(USER), " \ + cd /cache && \ + gpg --import /keys/$(BUSYBOX_KEY).asc && \ + gpg --verify busybox-$(BUSYBOX_VERSION).tar.bz2.sig && \ + tar -xf busybox-$(BUSYBOX_VERSION).tar.bz2 \ + ") + # This can likely be eliminated with path fixes in toolchain/Makefile $(OUT_DIR)/toolchain.tar: ARCH=$(ARCH) \ - OUT_DIR=../$(OUT_DIR) \ + OUT_DIR=../../$(OUT_DIR) \ DEBIAN_HASH=$(DEBIAN_HASH) \ $(MAKE) -C $(TOOLCHAIN_DIR) \ - ../$(OUT_DIR)/toolchain.tar + ../../$(OUT_DIR)/toolchain.tar -$(CONFIG_DIR)/busybox.config: +$(CONFIG_DIR)/debug/busybox.config: $(call toolchain,$(USER), " \ cd /cache/busybox-$(BUSYBOX_VERSION) && \ KCONFIG_NOTIMESTAMP=1 make menuconfig && \ - cp .config /config/busybox.config; \ + cp .config /config/debug/busybox.config; \ ") $(CONFIG_DIR)/$(TARGET)/linux.config: @@ -96,17 +171,17 @@ $(OUT_DIR)/busybox: \ $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig $(call toolchain,$(USER)," \ cd /cache/busybox-$(BUSYBOX_VERSION) && \ - cp /config/busybox.config .config && \ + cp /config/debug/busybox.config .config && \ make -j$(CPUS) busybox && \ cp busybox /out/; \ ") -$(OUT_DIR)/sample_init: +$(OUT_DIR)/init: $(call toolchain,$(USER)," \ gcc \ -static \ - -static-libgcc /src/sample/init.c \ - -o /out/sample_init; \ + -static-libgcc /src/init.c \ + -o /out/init; \ ") $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_cpio: \ @@ -121,15 +196,15 @@ $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_cpio: \ $(OUT_DIR)/rootfs.cpio: \ $(OUT_DIR)/busybox \ - $(OUT_DIR)/sample_init \ + $(OUT_DIR)/init \ $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_cpio mkdir -p $(CACHE_DIR)/rootfs/bin ifeq ($(DEBUG), true) - cp $(OUT_DIR)/sample_init $(CACHE_DIR)/rootfs/sample_init + cp $(OUT_DIR)/init $(CACHE_DIR)/rootfs/real_init cp $(SRC_DIR)/scripts/busybox_init $(CACHE_DIR)/rootfs/init cp $(OUT_DIR)/busybox $(CACHE_DIR)/rootfs/bin/ else - cp $(OUT_DIR)/sample_init $(CACHE_DIR)/rootfs/init + cp $(OUT_DIR)/init $(CACHE_DIR)/rootfs/init endif $(call toolchain,$(USER)," \ cd /cache/rootfs && \ diff --git a/config/busybox.config b/config/debug/busybox.config similarity index 100% rename from config/busybox.config rename to config/debug/busybox.config diff --git a/toolchain/Dockerfile b/config/toolchain/Dockerfile similarity index 100% rename from toolchain/Dockerfile rename to config/toolchain/Dockerfile diff --git a/toolchain/Makefile b/config/toolchain/Makefile similarity index 100% rename from toolchain/Makefile rename to config/toolchain/Makefile diff --git a/toolchain/config/package-hashes-x86_64.txt b/config/toolchain/config/package-hashes-x86_64.txt similarity index 100% rename from toolchain/config/package-hashes-x86_64.txt rename to config/toolchain/config/package-hashes-x86_64.txt diff --git a/toolchain/config/packages-base.list b/config/toolchain/config/packages-base.list similarity index 100% rename from toolchain/config/packages-base.list rename to config/toolchain/config/packages-base.list diff --git a/toolchain/config/packages-x86_64.list b/config/toolchain/config/packages-x86_64.list similarity index 100% rename from toolchain/config/packages-x86_64.list rename to config/toolchain/config/packages-x86_64.list diff --git a/toolchain/scripts/packages-install b/config/toolchain/scripts/packages-install similarity index 100% rename from toolchain/scripts/packages-install rename to config/toolchain/scripts/packages-install diff --git a/toolchain/scripts/packages-update b/config/toolchain/scripts/packages-update similarity index 100% rename from toolchain/scripts/packages-update rename to config/toolchain/scripts/packages-update diff --git a/make/fetch.mk b/make/fetch.mk deleted file mode 100644 index 38dd926..0000000 --- a/make/fetch.mk +++ /dev/null @@ -1,44 +0,0 @@ -$(OUT_DIR): - mkdir -p $(OUT_DIR) - -$(CACHE_DIR): - mkdir -p $(CACHE_DIR) - -$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig: - curl \ - --url $(BUSYBOX_SERVER)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig \ - --output $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig - -$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2: - curl \ - --url $(BUSYBOX_SERVER)/busybox-$(BUSYBOX_VERSION).tar.bz2 \ - --output $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 - -$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign: - curl \ - --url $(LINUX_SERVER)/linux-$(LINUX_VERSION).tar.sign \ - --output $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign - -$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz: - curl \ - --url $(LINUX_SERVER)/linux-$(LINUX_VERSION).tar.xz \ - --output $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz - -$(CACHE_DIR)/linux-$(LINUX_VERSION).tar: - xz -d $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz - -$(CACHE_DIR)/linux-$(LINUX_VERSION): $(CACHE_DIR)/linux-$(LINUX_VERSION).tar - $(call toolchain,$(USER), " \ - cd /cache && \ - gpg --import /keys/$(LINUX_KEY).asc && \ - gpg --verify linux-$(LINUX_VERSION).tar.sign && \ - tar xf linux-$(LINUX_VERSION).tar; \ - ") - -$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION): - $(call toolchain,$(USER), " \ - cd /cache && \ - gpg --import /keys/$(BUSYBOX_KEY).asc && \ - gpg --verify busybox-$(BUSYBOX_VERSION).tar.bz2.sig && \ - tar -xf busybox-$(BUSYBOX_VERSION).tar.bz2 \ - ") diff --git a/make/keys.mk b/make/keys.mk deleted file mode 100644 index 52f40c1..0000000 --- a/make/keys.mk +++ /dev/null @@ -1,31 +0,0 @@ -.PHONY: keys -keys: \ - $(KEY_DIR)/$(LINUX_KEY).asc \ - $(KEY_DIR)/$(BUSYBOX_KEY).asc - -$(KEY_DIR)/$(LINUX_KEY).asc: - $(call fetch_pgp_key,$(LINUX_KEY)) - -$(KEY_DIR)/$(BUSYBOX_KEY).asc: - $(call fetch_pgp_key,,$(BUSYBOX_KEY)) - -define fetch_pgp_key - mkdir -p $(KEY_DIR) && \ - $(toolchain) ' \ - for server in \ - ha.pool.sks-keyservers.net \ - hkp://keyserver.ubuntu.com:80 \ - hkp://p80.pool.sks-keyservers.net:80 \ - pgp.mit.edu \ - ; do \ - echo "Trying: $${server}"; \ - gpg \ - --recv-key \ - --keyserver "$${server}" \ - --keyserver-options timeout=10 \ - --recv-keys "$(1)" \ - && break; \ - done; \ - gpg --export -a $(1) > $(KEY_DIR)/$(1).asc; \ - ' -endef diff --git a/src/sample/init.c b/src/init.c similarity index 100% rename from src/sample/init.c rename to src/init.c