synit/packaging/Makefile

104 lines
2.9 KiB
Makefile

__ignored__ := $(shell ./copy-local-resources-into-package-folders.sh)
.PHONY: check-tools build-image build sign clean veryclean keyfile
# 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
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-rust:$(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
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
sign: build-image
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
%.apk: build-image
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
%.checksum: build-image
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
clean:
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.rust.$(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