-
Notifications
You must be signed in to change notification settings - Fork 345
/
Makefile
91 lines (71 loc) · 2.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
SHELL=bash
CFLAGS=-std=gnu99 -static -s -Wall -Werror -O3
TEST_PACKAGE_DEPS := build-essential python python-pip procps python-dev python-setuptools
DOCKER_RUN_TEST := docker run -v $(PWD):/mnt:ro
VERSION = $(shell cat VERSION)
.PHONY: build
build: VERSION.h
$(CC) $(CFLAGS) -o dumb-init dumb-init.c
VERSION.h: VERSION
echo '// THIS FILE IS AUTOMATICALLY GENERATED' > VERSION.h
echo '// Run `make VERSION.h` to update it after modifying VERSION.' >> VERSION.h
xxd -i VERSION >> VERSION.h
.PHONY: clean
clean: clean-tox
rm -rf dumb-init dist/ *.deb
.PHONY: clean-tox
clean-tox:
rm -rf .tox
.PHONY: release
release: python-dists
cd dist && \
sha256sum --binary dumb-init_$(VERSION)_amd64.deb dumb-init_$(VERSION)_x86_64 dumb-init_$(VERSION)_ppc64el.deb dumb-init_$(VERSION)_ppc64le dumb-init_$(VERSION)_s390x.deb dumb-init_$(VERSION)_s390x dumb-init_$(VERSION)_arm64.deb dumb-init_$(VERSION)_aarch64 \
> sha256sums
.PHONY: python-dists
python-dists: VERSION.h
python setup.py sdist
docker run \
--user $$(id -u):$$(id -g) \
-v $(PWD)/dist:/dist:rw \
quay.io/pypa/manylinux1_x86_64:latest \
bash -exc ' \
/opt/python/cp35-cp35m/bin/pip wheel --wheel-dir /tmp /dist/*.tar.gz && \
auditwheel repair --wheel-dir /dist /tmp/*.whl --wheel-dir /dist \
'
.PHONY: builddeb
builddeb:
debuild --set-envvar=CC=musl-gcc -us -uc -b
mkdir -p dist
mv ../dumb-init_*.deb dist/
# Extract the built binary from the Debian package
dpkg-deb --fsys-tarfile dist/dumb-init_$(VERSION)_$(shell dpkg --print-architecture).deb | \
tar -C dist --strip=3 -xvf - ./usr/bin/dumb-init
mv dist/dumb-init dist/dumb-init_$(VERSION)_$(shell uname -m)
.PHONY: builddeb-docker
builddeb-docker: docker-image
mkdir -p dist
docker run --user $$(id -u):$$(id -g) -v $(PWD):/tmp/mnt dumb-init-build
.PHONY: docker-image
docker-image:
docker build -t dumb-init-build .
.PHONY: test
test:
tox
tox -e pre-commit
.PHONY: install-hooks
install-hooks:
tox -e pre-commit -- install -f --install-hooks
ITEST_TARGETS = itest_xenial itest_bionic itest_buster
.PHONY: itest $(ITEST_TARGETS)
itest: $(ITEST_TARGETS)
itest_xenial: _itest-ubuntu-xenial
itest_bionic: _itest-ubuntu-bionic
itest_buster: _itest-debian-buster
itest_tox:
$(DOCKER_RUN_TEST) debian:buster /mnt/ci/docker-tox-test
_itest-%: _itest_deb-% _itest_python-%
@true
_itest_python-%:
$(DOCKER_RUN_TEST) $(shell sed 's/-/:/' <<< "$*") /mnt/ci/docker-python-test
_itest_deb-%: builddeb-docker
$(DOCKER_RUN_TEST) $(shell sed 's/-/:/' <<< "$*") /mnt/ci/docker-deb-test