2020-06-15 18:04:50 +00:00
|
|
|
NAME := airgap
|
|
|
|
IMAGE := local/$(NAME):latest
|
2020-07-19 08:31:10 +00:00
|
|
|
TARGET := x86_64
|
|
|
|
DEVICES := librem13v4 librem15v4
|
2020-07-17 02:15:03 +00:00
|
|
|
GIT_REF := $(shell git log -1 --format=%H config)
|
|
|
|
GIT_AUTHOR := $(shell git log -1 --format=%an config)
|
|
|
|
GIT_KEY := $(shell git log -1 --format=%GP config)
|
|
|
|
GIT_EPOCH := $(shell git log -1 --format=%at config)
|
2020-07-19 08:31:10 +00:00
|
|
|
GIT_DATETIME := \
|
|
|
|
$(shell git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S' config)
|
|
|
|
VERSION := "develop"
|
|
|
|
RELEASE_DIR := release/$(VERSION)
|
2020-07-17 02:15:03 +00:00
|
|
|
ifeq ($(strip $(shell git status --porcelain 2>/dev/null)),)
|
|
|
|
GIT_STATE=clean
|
|
|
|
else
|
|
|
|
GIT_STATE=dirty
|
|
|
|
endif
|
2020-07-11 23:08:30 +00:00
|
|
|
OUT_DIR := build/buildroot/output/images
|
2020-06-15 08:08:20 +00:00
|
|
|
docker = docker
|
|
|
|
executables = $(docker)
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
|
|
|
## Primary Targets
|
|
|
|
|
|
|
|
.PHONY: all
|
2020-07-19 08:31:10 +00:00
|
|
|
all: image fetch build hash
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: build-os build-fw
|
|
|
|
|
2020-06-15 08:08:20 +00:00
|
|
|
.PHONY: image
|
|
|
|
image:
|
2020-10-10 07:56:44 +00:00
|
|
|
$(docker) build \
|
2020-06-15 08:08:20 +00:00
|
|
|
--tag $(IMAGE) \
|
|
|
|
--file $(PWD)/config/container/Dockerfile \
|
|
|
|
$(IMAGE_OPTIONS) \
|
|
|
|
$(PWD)
|
|
|
|
|
|
|
|
.PHONY: fetch
|
|
|
|
fetch:
|
|
|
|
mkdir -p build release
|
|
|
|
$(contain) fetch
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
$(contain) clean
|
|
|
|
|
2020-07-19 08:31:10 +00:00
|
|
|
.PHONY: mrproper
|
|
|
|
mrproper:
|
2020-07-24 10:07:39 +00:00
|
|
|
docker image rm -f $(IMAGE)
|
2020-07-19 08:31:10 +00:00
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
.PHONY: build-os
|
|
|
|
build-os:
|
|
|
|
$(contain) build-os
|
|
|
|
mkdir -p $(RELEASE_DIR)
|
|
|
|
cp $(OUT_DIR)/rootfs.iso9660 $(RELEASE_DIR)/airgap_$(TARGET).iso
|
|
|
|
|
|
|
|
.PHONY: build-fw
|
|
|
|
build-fw:
|
|
|
|
$(contain) build-fw
|
|
|
|
mkdir -p $(RELEASE_DIR)
|
|
|
|
for device in $(DEVICES); do \
|
|
|
|
cp \
|
|
|
|
build/heads/build/$${device}/coreboot.rom \
|
|
|
|
$(RELEASE_DIR)/$${device}.rom ; \
|
|
|
|
done
|
|
|
|
|
2020-07-24 10:07:39 +00:00
|
|
|
## Release Targets
|
|
|
|
|
|
|
|
.PHONY: audit
|
|
|
|
audit:
|
2020-07-25 00:51:05 +00:00
|
|
|
mkdir -p build/audit
|
2020-07-24 10:07:39 +00:00
|
|
|
$(contain) audit
|
|
|
|
|
2020-07-19 08:31:10 +00:00
|
|
|
.PHONY: hash
|
|
|
|
hash:
|
|
|
|
if [ ! -f release/$(VERSION)/hashes.txt ]; then \
|
2020-07-24 10:07:39 +00:00
|
|
|
openssl sha256 -r release/$(VERSION)/*.rom \
|
2020-07-19 08:31:10 +00:00
|
|
|
> release/$(VERSION)/hashes.txt; \
|
2020-07-24 10:07:39 +00:00
|
|
|
openssl sha256 -r release/$(VERSION)/*.iso \
|
2020-07-19 08:31:10 +00:00
|
|
|
>> release/$(VERSION)/hashes.txt; \
|
|
|
|
fi
|
|
|
|
|
2020-07-24 10:07:39 +00:00
|
|
|
.PHONY: verify
|
|
|
|
verify:
|
2020-07-25 01:00:07 +00:00
|
|
|
mkdir -p build/audit/$(VERSION)
|
2020-07-24 10:07:39 +00:00
|
|
|
openssl sha256 -r $(RELEASE_DIR)/*.rom \
|
2020-07-25 01:00:07 +00:00
|
|
|
> build/audit/$(VERSION)/release_hashes.txt
|
2020-07-24 10:07:39 +00:00
|
|
|
openssl sha256 -r $(RELEASE_DIR)/*.iso \
|
2020-07-25 01:00:07 +00:00
|
|
|
>> build/audit/$(VERSION)/release_hashes.txt
|
|
|
|
diff -q build/audit/$(VERSION)/release_hashes.txt $(RELEASE_DIR)/hashes.txt;
|
2020-07-24 10:07:39 +00:00
|
|
|
|
|
|
|
.PHONY: sign
|
|
|
|
sign: $(RELEASE_DIR)/*.rom $(RELEASE_DIR)/*.iso
|
2020-07-26 00:53:15 +00:00
|
|
|
set -e; \
|
2020-07-24 10:07:39 +00:00
|
|
|
for file in $^; do \
|
|
|
|
gpg --armor --detach-sig "$${file}"; \
|
2020-07-26 00:53:15 +00:00
|
|
|
fingerprint=$$(\
|
|
|
|
gpg --list-packets $${file}.asc \
|
|
|
|
| grep "issuer key ID" \
|
|
|
|
| sed 's/.*\([A-Z0-9]\{16\}\).*/\1/g' \
|
|
|
|
); \
|
|
|
|
mv $${file}.asc $${file}.$${fingerprint}.asc; \
|
2020-07-24 10:07:39 +00:00
|
|
|
done
|
|
|
|
|
2020-07-19 08:31:10 +00:00
|
|
|
|
2020-06-15 08:08:20 +00:00
|
|
|
## Development Targets
|
|
|
|
|
|
|
|
.PHONY: shell
|
|
|
|
shell:
|
|
|
|
$(docker) inspect "$(NAME)" \
|
2020-10-15 23:26:28 +00:00
|
|
|
&& $(docker) exec --interactive --user=root --tty "$(NAME)" shell \
|
2020-06-15 08:08:20 +00:00
|
|
|
|| $(contain) shell
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: menuconfig
|
|
|
|
menuconfig:
|
|
|
|
$(contain) menuconfig
|
|
|
|
|
2020-10-15 23:26:28 +00:00
|
|
|
.PHONY: linux-menuconfig
|
2020-07-15 01:35:16 +00:00
|
|
|
linux-menuconfig:
|
|
|
|
$(contain) linux-menuconfig
|
|
|
|
|
2020-06-15 08:08:20 +00:00
|
|
|
.PHONY: vm
|
|
|
|
vm:
|
|
|
|
$(contain) vm
|
|
|
|
|
|
|
|
.PHONY: update-packages
|
|
|
|
update-packages:
|
2020-10-08 01:24:58 +00:00
|
|
|
docker rm -f "$(NAME)-update-packages" || :
|
|
|
|
docker run \
|
2020-06-15 08:08:20 +00:00
|
|
|
--rm \
|
|
|
|
--detach \
|
2020-10-08 01:24:58 +00:00
|
|
|
--name "$(NAME)-update-packages" \
|
2020-06-15 08:08:20 +00:00
|
|
|
--user $(userid):$(groupid) \
|
2020-07-23 11:12:31 +00:00
|
|
|
--env GIT_EPOCH="$(GIT_EPOCH)" \
|
2020-10-08 01:24:58 +00:00
|
|
|
--volume $(PWD)/config/container/packages.list:/etc/apt/packages-old.list \
|
|
|
|
--volume $(PWD)/config/container/apt.conf:/etc/apt/apt.conf \
|
|
|
|
--volume $(PWD)/scripts:/usr/local/bin \
|
|
|
|
debian tail -f /dev/null
|
|
|
|
docker exec -it --user=root "$(NAME)-update-packages" update-packages
|
|
|
|
docker cp \
|
|
|
|
"$(NAME)-update-packages:/etc/apt/packages.list" \
|
2020-06-15 08:08:20 +00:00
|
|
|
"$(PWD)/config/container/packages.list"
|
2020-10-08 01:24:58 +00:00
|
|
|
docker cp \
|
|
|
|
"$(NAME)-update-packages:/etc/apt/sources.list" \
|
2020-07-23 11:12:31 +00:00
|
|
|
"$(PWD)/config/container/sources.list"
|
2020-10-16 00:08:15 +00:00
|
|
|
docker cp \
|
|
|
|
"$(NAME)-update-packages:/etc/apt/package-hashes.txt" \
|
|
|
|
"$(PWD)/config/container/package-hashes.txt"
|
2020-10-08 01:24:58 +00:00
|
|
|
docker rm -f "$(NAME)-update-packages"
|
2020-06-15 08:08:20 +00:00
|
|
|
|
|
|
|
## Make Helpers
|
|
|
|
|
|
|
|
check_executables := $(foreach exec,$(executables),\$(if \
|
|
|
|
$(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
|
|
|
|
|
|
|
|
userid = $(shell id -u)
|
|
|
|
groupid = $(shell id -g)
|
|
|
|
contain := \
|
|
|
|
$(docker) run \
|
|
|
|
--rm \
|
|
|
|
--tty \
|
|
|
|
--interactive \
|
|
|
|
--name "$(NAME)" \
|
|
|
|
--hostname "$(NAME)" \
|
2020-07-19 08:31:10 +00:00
|
|
|
--env TARGET="$(TARGET)" \
|
|
|
|
--env DEVICES="$(DEVICES)" \
|
2020-07-11 23:08:30 +00:00
|
|
|
--env GIT_DATETIME="$(GIT_DATETIME)" \
|
|
|
|
--env GIT_EPOCH="$(GIT_EPOCH)" \
|
2020-07-17 02:15:03 +00:00
|
|
|
--env GIT_REF="$(GIT_REF)" \
|
|
|
|
--env GIT_AUTHOR="$(GIT_AUTHOR)" \
|
|
|
|
--env GIT_KEY="$(GIT_KEY)" \
|
|
|
|
--env GIT_STATE="$(GIT_STATE)" \
|
2020-10-15 23:26:28 +00:00
|
|
|
--env UID="$(shell id -u)" \
|
|
|
|
--env GID="$(shell id -g)" \
|
2020-06-15 08:08:20 +00:00
|
|
|
--volume $(PWD)/build:/home/build/build \
|
|
|
|
--volume $(PWD)/config:/home/build/config \
|
|
|
|
--volume $(PWD)/release:/home/build/release \
|
|
|
|
--volume $(PWD)/scripts:/home/build/scripts \
|
|
|
|
$(IMAGE)
|