initial busybox/linux building

This commit is contained in:
Lance Vick 2022-06-24 02:02:51 -07:00
commit 1cb4d565f8
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
13 changed files with 3327 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
out

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
out/*
cache/*
.*

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
ARG DEBIAN_HASH
FROM debian@sha256:${DEBIAN_HASH}
RUN apt update && \
apt install -y \
git \
curl \
build-essential \
flex \
bison \
libncurses-dev \
bc \
libelf-dev

46
Makefile Normal file
View File

@ -0,0 +1,46 @@
NAME := qos
DEBUG := false
OUT_DIR := out
KEY_DIR := keys
TARGET := local
CACHE_DIR := cache
CONFIG_DIR := targets/$(TARGET)
CPUS := $(shell nproc)
include $(PWD)/config.env
include $(PWD)/make/keys.mk
include $(PWD)/make/fetch.mk
include $(PWD)/make/extract.mk
include $(PWD)/make/toolchain.mk
.DEFAULT_GOAL := default
default: $(OUT_DIR)/bzImage
$(CONFIG_DIR)/busybox.config:
$(toolchain) " \
cd /cache/busybox-$(BUSYBOX_VERSION) && \
make menuconfig && \
cp .config /config/busybox.config; \
"
$(CONFIG_DIR)/linux.config:
$(toolchain) " \
cd /cache/linux-$(LINUX_VERSION) && \
make menuconfig && \
cp .config /config/linux.config; \
"
$(OUT_DIR)/busybox: extract
$(toolchain) " \
cd /cache/busybox-$(BUSYBOX_VERSION) && \
cp /config/busybox.config .config && \
make -j$(CPUS) busybox && \
cp busybox /out/; \
"
$(OUT_DIR)/bzImage: extract $(OUT_DIR)/busybox
$(toolchain) " \
cd /cache/linux-$(LINUX_VERSION) && \
cp /config/linux.config .config && \
make -j$(CPUS) bzImage && \
cp arch/x86_64/boot/bzImage /out/; \
"

11
config.env Normal file
View File

@ -0,0 +1,11 @@
export BUSYBOX_VERSION = 1.33.2
export LINUX_VERSION = 5.18.5
export BUSYBOX_SERVER = https://busybox.net/downloads/
export LINUX_SERVER = https://cdn.kernel.org/pub/linux/kernel/v5.x/
export BUSYBOX_KEY = C9E9416F76E610DBD09D040F47B70C55ACC9965B
export LINUX_KEY = 647F28654894E3BD457199BE38DBBDC86092693E
export LINUX_KEYS_REPO = https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git
export DEBIAN_HASH = 3f1d6c17773a45c97bd8f158d665c9709d7b29ed7917ac934086ad96f92e4510

View File

@ -0,0 +1,78 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBE58tdUBEADY5iQsoL4k8l06dNt+uP2lH8IPi14M51/tOHsW1ZNc8Iok0stH
+uA8w0LpN97UgNhsvXFEkIK2JjLalasUTiUoIeeTshD9t+ekFBx5a9SbLCFlBrDS
TwfieK2xalzomoL22N5ztj1XbdLWh6NRM6kKMeYvgAGo8p884WJk4pPIJK6G0wEw
e9/TG6ilRSLOtxyaF9yZ+FC1eOA1S47Ld2K25Y5GsQF5agwi7nES+9tVVBZp97kB
8IOvELeiSiY0xFXi60yfwIlK6x9dfcxsx5nCyrp2qdqQiPiMD0EJMiuA6wymoi5W
XtmfCpweTB8TvW8Y8uqrwYApzmDleBDTIDP0vCY1o9eftJcWWMkRKC9c7Ziy4nT6
TzmVkNXgqC8/BuOQbpU7I/1VCMoa6e+2a8jrgy5to4dGgu6xQ6jTxWbvgDeB6Hct
WGqf8f9s5lSpH8D8OZLDOXKolqnBd5YrJr0Qmpq4cCcIqwNCMbURtsTpbW/EdWl+
AKwnStXXLI5O6Hg+m4c3O8ZwbzcnAOgTJePm2Xoi71t9SbAZZx1/W7p6/57UGrXR
Q4WfiwpOPD0siF33yO2L7G7Gmm4zh8ieX8aS8guqfWFhuSsDta77F2FB9ozD9WN0
Z5tJowiy3Z1VkxvZjZH8IbcB05yBBBV47BJxrPnSuDT+w45yNTqZ6m4VYwARAQAB
tC9HcmVnIEtyb2FoLUhhcnRtYW4gPGdyZWdraEBsaW51eGZvdW5kYXRpb24ub3Jn
PokCTgQTAQgAOBYhBGR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Xokb13OYwfAv1d84Ww2AA93grCAnNHUBomz4iVzpnMsRRxpwMoy
EnVFbutX8Zl1S631IqSKmM237X4cTItUDHABQIqUY4k7xW44UMBb62jYxyekNW6v
yVo5A/4yM8ri1E7AIUAOjoEMuWkBSYxdcq7h1jxh1Rm5QqRejiS7TNejF5EOUSlo
oPx5ijS56JHAvPJZFWu5CU0VUveTcFrv0IhqDuoYNM4uUIh/QIjo06CxBEjgviNs
kYZBwHBIBMGOIj/Vo+xzGQLySDuVxzMpDrUm9gXb49e/5skxSrQpRGVuaXMgVmxh
c2Vua28gPHZkYS5saW51eEBnb29nbGVtYWlsLmNvbT6IYAQTEQIAIAUCRX8PZwIb
AwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEEe3DFWsyZZbExwAoOTGwQOj75Hj
pDbOw99+vhlx8/uUAKCwAaxacnpRFUkhVRBsCYWIC5obf7kBDQRFfw9oEAQAjQyS
MWag/Dxc6G9Em9/2jVG9FQAi+NOPx2EigOUC8wEeErEjwQRN/9xIU8CCncttYfBe
U00b198fSL9axKZIptn0hLAMOruFODBVjVDiOY09M67DfQ47zzTRE9HWst47TgVN
LWdfNljB+wqgvEor4S6WtZpyAcq8f1kOMrX115sAAwUD/2eow67bKR7yGhHw8Me2
HWqUmd8B0+CM5QpfYGOND5p7oKnMLXDu+Q0bma6wbTasQX+urA1UxdXo0EAWrQXr
ttQTF92G6G0Gi5JcMWu2QkgTWiZMr90sY+PMAi3nGnqiJLwHVnlxhKnTSE5JdpcX
cQLJQDYDoJtBBccBUtF0o1z+iEkEGBECAAkFAkV/D2gCGwwACgkQR7cMVazJllvV
igCfbxD3ZRcgCpaZo6gZyXf89oyKCjAAnAiK5h7KxXPrwviUL4K/GlWGGFOA
=2JoA
-----END PGP PUBLIC KEY BLOCK-----

25
make/extract.mk Normal file
View File

@ -0,0 +1,25 @@
.PHONY: extract
extract: \
fetch \
$(CACHE_DIR)/linux-$(LINUX_VERSION).tar \
$(CACHE_DIR)/linux-$(LINUX_VERSION)/README \
$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION)/README
$(CACHE_DIR)/linux-$(LINUX_VERSION).tar:
xz -d $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz
$(CACHE_DIR)/linux-$(LINUX_VERSION)/README:
$(toolchain) " \
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)/README:
$(toolchain) " \
cd /cache && \
gpg --import /keys/$(BUSYBOX_KEY).asc && \
gpg --verify busybox-$(BUSYBOX_VERSION).tar.bz2.sig && \
tar -xf busybox-$(BUSYBOX_VERSION).tar.bz2 \
"

36
make/fetch.mk Normal file
View File

@ -0,0 +1,36 @@
.PHONY: fetch
fetch: \
toolchain \
keys \
$(OUT_DIR) \
$(CACHE_DIR) \
$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz \
$(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign \
$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 \
$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig
$(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

31
make/keys.mk Normal file
View File

@ -0,0 +1,31 @@
.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

24
make/toolchain.mk Normal file
View File

@ -0,0 +1,24 @@
.PHONY: toolchain-shell
build-shell: toolchain
docker run -it local/$(NAME)-build bash
.PHONY: toolchain
toolchain:
DOCKER_BUILDKIT=1 \
docker build \
--tag local/$(NAME)-build \
--build-arg DEBIAN_HASH=$(DEBIAN_HASH) \
.
toolchain := \
docker run \
--interactive \
--rm \
--user=$(shell id -u):$(shell id -g) \
-v $(PWD)/$(CONFIG_DIR):/config \
-v $(PWD)/$(KEY_DIR):/keys \
-v $(PWD)/$(CACHE_DIR):/cache \
-v $(PWD)/$(OUT_DIR):/out \
-e GNUPGHOME=/cache/.gnupg \
-t local/$(NAME)-build \
bash -c

1203
targets/local/busybox.config Normal file

File diff suppressed because it is too large Load Diff

1833
targets/local/linux.config Normal file

File diff suppressed because it is too large Load Diff