synit/packaging/Makefile

116 lines
3.4 KiB
Makefile

.PHONY: check-tools build-image build sign clean veryclean keyfile prepare-all clean-all
# If you run:
# docker run --rm --name squid adricu/alpine-squid
# and set DOCKER_SQUID_CONTAINER=squid
# then you can avoid repeated downloads of a lot of alpine packages.
#
DOCKER_SQUID_CONTAINER?=squid
ifeq ($(DOCKER_SQUID_CONTAINER),)
DOCKER_SQUID_OPTS=
else
DOCKER_SQUID_OPTS=--link $(DOCKER_SQUID_CONTAINER):squid \
-e http_proxy=http://squid:3128/ \
-e https_proxy=http://squid:3128/
DOCKER_SQUID_IP=$(shell docker inspect squid | preserves-tool convert -o unquoted --select '/ . "NetworkSettings" . "IPAddress"')
HTTP_PROXY=http://$(DOCKER_SQUID_IP):3128/
endif
export ARCH?=aarch64
DOCKER_ARCH=$(shell ./map_docker_arch.sh $(ARCH))
KEYFILE?=synit-apk-key
UID:=$(shell id -u)
GID:=$(shell id -g)
BUILD_USER?=build
DOCKER_CMD=\
mkdir -p $(CURDIR)/distfiles && \
docker run --platform linux/$(DOCKER_ARCH) -it --rm \
$(DOCKER_SQUID_OPTS) \
-v `pwd`:/data \
-v `pwd`/$(KEYFILE):/home/$(BUILD_USER)/.abuild/$(KEYFILE) \
-v $(CURDIR)/distfiles:/var/cache/distfiles \
synit-build:$(ARCH)
DOCKER_BUILD_ARGS=\
--build-arg http_proxy=$(HTTP_PROXY) \
--build-arg http_proxy_hostname=$(DOCKER_SQUID_IP) \
--build-arg ALPINE_ARCH=$(ARCH) \
--build-arg DOCKER_ARCH=$(DOCKER_ARCH) \
--build-arg KEYFILE=$(KEYFILE) \
--build-arg UID=$(UID) \
--build-arg BUILD_USER=$(BUILD_USER)
build: build-image prepare-all
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
sign: build-image
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
%.apk: build-image %.prepare
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
%.checksum: build-image %.prepare
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
%.buildshell: build-image %.prepare
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
prepare-all: $(patsubst %,%.prepare,$(file < package-list))
%.prepare:
@if [ -f packages/$*/Makefile.external ]; then \
$(MAKE) -C packages/$* -f Makefile.external prepare; fi
clean-all: $(patsubst %,%.clean,$(file < package-list))
%.clean:
@if [ -f packages/$*/Makefile.external ]; then \
$(MAKE) -C packages/$* -f Makefile.external clean; fi
clean: clean-all
rm -f .build-image.*
-docker rmi synit-build:aarch64
-docker rmi synit-build:x86_64
-docker rmi synit-build:armv7
-docker rmi synit-build-rust:aarch64
-docker rmi synit-build-rust:x86_64
-docker rmi synit-build-rust:armv7
veryclean: clean
rm -rf target
build-image: check-tools .build-image.$(ARCH)
.build-image.$(ARCH): $(KEYFILE)
docker buildx build \
--progress plain \
$(DOCKER_BUILD_ARGS) \
--platform=linux/$(DOCKER_ARCH) \
-t synit-build:$(ARCH) .
touch $@
.build-image.rust.$(ARCH): .build-image.$(ARCH)
docker buildx build \
--progress plain \
$(DOCKER_BUILD_ARGS) \
--platform=linux/$(DOCKER_ARCH) \
-t synit-build-rust:$(ARCH) -f Dockerfile.rust .
touch $@
keyfile: $(KEYFILE)
$(KEYFILE):
docker run -it --rm \
-v `pwd`:/data \
alpine \
sh -c "apk add abuild && echo /data/$(KEYFILE) | abuild-keygen && chown $(UID):$(GID) /data/$(KEYFILE)*"
check-tools:
@rm -f .versions
@preserves-tool --version >> .versions
@git --version >> .versions
@ssh -V >> .versions 2>&1
@rsync --version | head -1 >> .versions
@python3 --version >> .versions
@rustc --version >> .versions
@cargo --version >> .versions
@make --version | head -1 >> .versions
@docker --version >> .versions