2022-07-23 15:58:24 +00:00
|
|
|
.PHONY: check-tools build-image build sign clean veryclean keyfile prepare-all clean-all
|
2021-11-11 18:38:35 +00:00
|
|
|
|
|
|
|
# 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
|
2021-11-12 12:15:20 +00:00
|
|
|
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/
|
2021-11-11 18:38:35 +00:00
|
|
|
endif
|
|
|
|
|
2022-07-23 12:47:44 +00:00
|
|
|
export ARCH?=aarch64
|
2021-11-11 18:38:35 +00:00
|
|
|
DOCKER_ARCH=$(shell ./map_docker_arch.sh $(ARCH))
|
2021-11-11 21:42:08 +00:00
|
|
|
KEYFILE?=synit-apk-key
|
2021-11-11 18:38:35 +00:00
|
|
|
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 \
|
2021-11-11 21:42:08 +00:00
|
|
|
-v `pwd`/$(KEYFILE):/home/$(BUILD_USER)/.abuild/$(KEYFILE) \
|
2022-10-17 15:07:58 +00:00
|
|
|
-v `pwd`/$(KEYFILE).pub:/home/$(BUILD_USER)/.abuild/$(KEYFILE).pub \
|
2021-11-11 18:38:35 +00:00
|
|
|
-v $(CURDIR)/distfiles:/var/cache/distfiles \
|
2022-07-24 15:34:56 +00:00
|
|
|
synit-build:$(ARCH)
|
2021-11-11 18:38:35 +00:00
|
|
|
|
2021-11-13 11:37:03 +00:00
|
|
|
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)
|
|
|
|
|
2022-07-23 12:47:44 +00:00
|
|
|
build: build-image prepare-all
|
2021-11-11 21:42:08 +00:00
|
|
|
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
|
2021-11-11 18:38:35 +00:00
|
|
|
sign: build-image
|
2021-11-11 21:42:08 +00:00
|
|
|
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
|
2022-07-23 12:47:44 +00:00
|
|
|
%.apk: build-image %.prepare
|
2021-11-11 21:42:08 +00:00
|
|
|
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
|
2022-07-23 12:47:44 +00:00
|
|
|
%.checksum: build-image %.prepare
|
2021-11-11 21:42:08 +00:00
|
|
|
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
|
2022-07-25 12:47:11 +00:00
|
|
|
%.buildshell: build-image %.prepare
|
|
|
|
$(DOCKER_CMD) make -f Makefile.internal $@ KEYFILE=$(KEYFILE)
|
2021-11-11 18:38:35 +00:00
|
|
|
|
2022-07-23 12:47:44 +00:00
|
|
|
prepare-all: $(patsubst %,%.prepare,$(file < package-list))
|
|
|
|
|
|
|
|
%.prepare:
|
|
|
|
@if [ -f packages/$*/Makefile.external ]; then \
|
|
|
|
$(MAKE) -C packages/$* -f Makefile.external prepare; fi
|
|
|
|
|
2022-07-23 15:58:24 +00:00
|
|
|
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
|
2021-11-11 18:38:35 +00:00
|
|
|
rm -f .build-image.*
|
|
|
|
-docker rmi synit-build:aarch64
|
|
|
|
-docker rmi synit-build:x86_64
|
|
|
|
-docker rmi synit-build:armv7
|
2022-07-22 19:29:20 +00:00
|
|
|
-docker rmi synit-build-rust:aarch64
|
|
|
|
-docker rmi synit-build-rust:x86_64
|
|
|
|
-docker rmi synit-build-rust:armv7
|
2021-11-11 18:38:35 +00:00
|
|
|
|
|
|
|
veryclean: clean
|
|
|
|
rm -rf target
|
|
|
|
|
2022-07-24 15:34:56 +00:00
|
|
|
build-image: check-tools .build-image.$(ARCH)
|
2021-11-11 18:38:35 +00:00
|
|
|
|
|
|
|
.build-image.$(ARCH): $(KEYFILE)
|
|
|
|
docker buildx build \
|
2021-11-12 12:15:20 +00:00
|
|
|
--progress plain \
|
2021-11-13 11:37:03 +00:00
|
|
|
$(DOCKER_BUILD_ARGS) \
|
2021-11-11 18:38:35 +00:00
|
|
|
--platform=linux/$(DOCKER_ARCH) \
|
|
|
|
-t synit-build:$(ARCH) .
|
|
|
|
touch $@
|
|
|
|
|
2021-11-13 11:37:03 +00:00
|
|
|
.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 $@
|
|
|
|
|
2021-11-11 18:38:35 +00:00
|
|
|
keyfile: $(KEYFILE)
|
|
|
|
|
|
|
|
$(KEYFILE):
|
|
|
|
docker run -it --rm \
|
2021-11-11 21:42:08 +00:00
|
|
|
-v `pwd`:/data \
|
2021-11-11 18:38:35 +00:00
|
|
|
alpine \
|
2021-11-11 21:42:08 +00:00
|
|
|
sh -c "apk add abuild && echo /data/$(KEYFILE) | abuild-keygen && chown $(UID):$(GID) /data/$(KEYFILE)*"
|
2022-07-22 13:35:31 +00:00
|
|
|
|
|
|
|
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
|