forked from leahneukirchen/xtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (72 loc) · 2.7 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
92
93
94
95
96
97
98
PREFIX=${HOME}/.local
DESTDIR=
all:
lint: shellcheck shfmt
shellcheck:
shellcheck $$(shfmt --find .)
shfmt:
shfmt -d -ci $$(shfmt --find .)
install:
for f in x*[!~1]; do install -Dm0755 $$f $(DESTDIR)$(PREFIX)/bin/$$f; done
install -Dm644 _xtools $(DESTDIR)/$(PREFIX)/share/zsh/site-functions/_xtools
install -Dm644 xtools.1 $(DESTDIR)/$(PREFIX)/share/man/man1/xtools.1
for f in x*[!~1]; do ln -sf xtools.1 $(DESTDIR)$(PREFIX)/share/man/man1/$$f.1; done
README: xtools.1
mandoc -Tutf8 $< | col -bx >$@
.PHONY: all lint shellcheck shfmt
# framework
# Directory containing this makefile.
ROOT := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
HOSTDIR := $(ROOT)/hostdir
export PATH := $(ROOT)/xtools-extra:${PATH}
export XBPS_DISTDIR := $(ROOT)/void-packages
XBPS_GIT = git -C $(XBPS_DISTDIR)
REMOTE := https://github.com/void-linux/void-packages.git
XBPS_SRC_FLAGS = -H $(HOSTDIR)
XBPS_SRC = $(XBPS_DISTDIR)/xbps-src $(XBPS_SRC_FLAGS)
PRIVKEY := privkey.pem
REPO_CONF := /etc/xbps.d/00-repository-local.conf
TARGET_PKGS := $(notdir $(realpath $(wildcard srcpkgs/*)))
.PHONY: all install sync pkgs sign clean
all: pkgs
# Install repository configuration.
install: $(REPO_CONF)
$(REPO_CONF):
echo "# local repositories" > $@
echo "repository=$(HOSTDIR)/binpkgs" >> $@
echo "repository=$(HOSTDIR)/binpkgs/nonfree" >> $@
echo "repository=$(HOSTDIR)/binpkgs/multilib" >> $@
echo "repository=$(HOSTDIR)/binpkgs/multilib/nonfree" >> $@
echo "repository=$(HOSTDIR)/binpkgs/debug" >> $@
pkgs: XBPS_SRC_FLAGS += -E
# Build all packages in `srcpkgs` directory.
pkgs: $(TARGET_PKGS)
$(TARGET_PKGS): sync $(XBPS_DISTDIR)/etc/conf
$(XBPS_SRC) pkg $@
sign: $(PRIVKEY)
# Sign directories with repository data.
find $(HOSTDIR)/binpkgs -type f -name '*-repodata' -printf '%h\0' \
| xargs -0 -n1 xbps-rindex --sign --signedby 'antivoid-packages' --privkey $(PRIVKEY)
# Sign all packages.
find $(HOSTDIR)/binpkgs -type f -name '*.xbps' -print0 \
| xargs -0 xbps-rindex --sign-pkg --privkey $(PRIVKEY)
# Generate private key for repository signing.
$(PRIVKEY):
openssl genrsa -out $@ 4096 || ssh-keygen -b 4096 -t rsa -m PEM -N '' -f $@
# Update void-packages and masterdir
sync: xtools-extra $(XBPS_DISTDIR) $(XBPS_DISTDIR)/etc/conf
$(XBPS_GIT) fetch --depth=1
$(XBPS_GIT) reset --hard origin/master
$(XBPS_SRC) binary-bootstrap
$(XBPS_SRC) bootstrap-update
xpunt srcpkgs/*
# Set up xbps-src configuration.
$(XBPS_DISTDIR)/etc/conf: $(XBPS_DISTDIR) xbps-src.conf
cat xbps-src.conf > $@
# Initialize void-packages.
$(XBPS_DISTDIR):
git clone --depth=1 $(REMOTE) $(XBPS_DISTDIR)
xtools-extra:
command -v xpunt >/dev/null || ./fetch-xtools-extra.sh
clean:
$(RM) -r $(XBPS_DISTDIR) $(HOSTDIR) $(PRIVKEY) xtools-extra{,.tar.gz}