-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile.debian
301 lines (268 loc) · 14.4 KB
/
Makefile.debian
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# Makefile for debian based package build
#
# Davíð Steinn Geirsson <[email protected]>
#
# For "API" documentation check Makefile.generic
#
# Variables used as "parameters":
# DIST
# SRC_DIR
# COMPONENT
# PACKAGE_SET (currently "dom0" or "vm")
### Load component-specific settings
# Component specific settings. Generic variables:
# SOURCE_PREP - make target to run at "prep" stage
# SOURCE_COPY_IN - make target to run after "copy-in" stage
# SOURCE_COPY_OUT - make target to run after "copy-out" stage
# Above are mainly to extend Makefile with some component-specific actions
# (like handling additional sources)
#
#
# Check Makefile.DISTRIBUTION for distribution-specific supported variables
### Load distro-specific settings
# This file should define:
# 1. variables:
# PACKAGE_LIST - list of packages to build. Targets 'build-dep', 'package' and 'copy-out'
# will be run for each word on the list, with PACKAGE set to current word
# DIST_BUILD_DIR - basedir for sources inside of chroot - relative to
# CHROOT_DIR - qubes-src will be created in this directory
# targets:
# dist-prepare-chroot - initial preparation of chroot environment
# dist-prep - some preparation of sources (if needed)
# dist-build-dep - install build dependencies (should operate on chroot directory)
# dist-package - compile package (should operate on chroot directory)
# dist-copy-out - copy compiled package out of chroot env; this target should
# move packages to ORIG_SRC (distro-specific subdir) and hardlink them to
# BUILDER_REPO_DIR
#
# dist-build-dep, dist-package and dist-copy-out targets are run in separate
# process with stdout+stderr redirected to log file. If you want to print
# some message, use 3-rd file descriptor
#
# This file can specify additional targets (like update-repo-*)
### Variables required by Makefile.generic
PACKAGE_LIST = $(DEBIAN_BUILD_DIRS)
DIST_BUILD_DIR = /home/user
ifneq (1,$(NO_ARCHIVE))
ifeq ($(shell cat $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/source/format 2>/dev/null),3.0 (quilt))
GIT_TARBALL_NAME ?= $(DEBIAN_BUILD_DIRS)/../../$(shell $(DEBIAN_PARSER) changelog --package-release-name $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog 2>/dev/null).orig.tar.xz
unexport GIT_TARBALL_NAME
endif
endif
### Variables determined by package's Makefile.builder
DIST_SRC_DEBIAN_DIR = $(DIST_SRC)/$(DEBIAN_BUILD_DIRS)
### Global variables
DEBIANVERSION = $(DIST)
DEBIAN_PARSER = $(DEBIAN_PLUGIN_DIR)/scripts/debian-parser
export DEBIANVERSION DEBIAN_PARSER
### Local variables
RUN_AS_USER = user
CHROOT_REPO_DIR ?= chroot-$(DISTRIBUTION)
CHROOT_DEBIAN_DIR = $(CHROOT_DIR)/$(DIST_SRC)/$(DEBIAN_BUILD_DIRS)
ifndef OUTPUT_DIR
OUTPUT_DIR = deb/$(DIST)
endif
listfiles = awk 'section == "Files:" { print $$5 } /^[A-Z].*.$$/ { section=$$1 }'
ifdef UPDATE_REPO
ifneq (,$(findstring current-testing,$(UPDATE_REPO)))
REPO_SUFFIX = -testing
else ifneq (,$(findstring security-testing,$(UPDATE_REPO)))
REPO_SUFFIX = -securitytesting
else ifneq (,$(findstring unstable,$(UPDATE_REPO)))
REPO_SUFFIX = -unstable
endif
endif
ifdef SNAPSHOT_REPO
ifneq (,$(findstring current-testing,$(SNAPSHOT_REPO)))
SNAPSHOT_REPO_SUFFIX = -testing
else ifneq (,$(findstring security-testing,$(SNAPSHOT_REPO)))
SNAPSHOT_REPO_SUFFIX = -securitytesting
else ifneq (,$(findstring unstable,$(SNAPSHOT_REPO)))
SNAPSHOT_REPO_SUFFIX = -unstable
endif
endif
DISTRIBUTION_CAP := $(shell echo $(DISTRIBUTION) | sed -e 's/^./\U&/';)
define aptdistributions
Origin: Qubes $(DISTRIBUTION_CAP)
Label: Qubes $(DISTRIBUTION_CAP)
Codename: $(DIST)
Architectures: amd64 source
Components: main
Description: Apt repository with qubes domU support tools for $(DISTRIBUTION_CAP) $(DIST)
Tracking: all includebuildinfos
endef
export aptdistributions
ifdef REPO_PROXY
APT_GET_OPTIONS += -o Acquire::http::Proxy=$(REPO_PROXY)
endif
DEBSIGN_ARGS ?=
ifneq (,$(SIGN_KEY))
DEBSIGN_ARGS += -k$(SIGN_KEY)
endif
ifneq (,$(GNUPG))
DEBSIGN_ARGS += -p$(GNUPG)
endif
ifeq ($(DIST),jammy)
REPREPRO := $(DEBIAN_PLUGIN_DIR)/scripts/reprepro-wrapper
else
REPREPRO := $(firstword $(wildcard /usr/bin/reprepro $(DEBIAN_PLUGIN_DIR)/scripts/reprepro-wrapper))
endif
EXTRA_REPREPRO_OPTS ?=
EXTRA_REPREPRO_OPTS += --ignore=surprisingbinary --ignore=surprisingarch
ifeq (1,$(INCREMENT_DEVEL_VERSIONS))
# don't include source packages if INCREMENT_DEVEL_VERSIONS is active, as they
# will differ and will be rejected
EXTRA_REPREPRO_OPTS += -T deb
endif
ifeq ($(DEBUG),1)
$(info ╔══ DEBUG ══════════════════════════════════════════════════════════════════════)
$(info ║ Repo Variables)
$(info ╠───────────────────────────────────────────────────────────────────────────────)
$(info ║ SRC_DIR: $(SRC_DIR)) # qubes-src
$(info ║ CHROOT_DIR: $(CHROOT_DIR)) # /home/user/qubes-builder/chroot-jessie
$(info ║ CHROOT_REPO_DIR: $(CHROOT_REPO_DIR)) # chroot-debian
$(info ║ CHROOT_DEBIAN_DIR: $(CHROOT_DEBIAN_DIR)) # /home/user/qubes/chroot-jessie//home/user/qubes-src/repo/debian
$(info ║ BUILDER_REPO_DIR: $(BUILDER_REPO_DIR)) # /home/user/qubes-builder/qubes-packages-mirror-repo/jessie
$(info ╠───────────────────────────────────────────────────────────────────────────────)
$(info ║ Chroot Variables)
$(info ╠───────────────────────────────────────────────────────────────────────────────)
$(info ║ DIST_BUILD_DIR: $(DIST_BUILD_DIR)) # /home/user
$(info ║ DIST_SRC: $(DIST_SRC)) # /home/user/qubes-src/repo
$(info ║ DIST_SRC_DEBIAN_DIR: $(DIST_SRC_DEBIAN_DIR)) # /home/user/qubes-src/repo/debian
$(info ╠───────────────────────────────────────────────────────────────────────────────)
$(info ║ Build Variables)
$(info ╠───────────────────────────────────────────────────────────────────────────────)
$(info ║ DEBIAN_PARSER: $(DEBIAN_PARSER)) # /home/user/qubes-builder/qubes-src/builder-debian//scripts/debian-parser
$(info ║ DEBIAN_PLUGIN_DIR: $(DEBIAN_PLUGIN_DIR)) # /home/user/qubes-builder/qubes-src/builder-debian/
$(info ║ OUTPUT_DIR: $(OUTPUT_DIR)) # pkgs/jessie
$(info ║ PACKAGE_LIST: $(PACKAGE_LIST)) # debian
$(info ║ DISTRIBUTION: $(DISTRIBUTION)) # debian
$(info ║ DIST: $(DIST)) # jessie
$(info ║ DEBIANVERSION: $(DEBIANVERSION)) # jessie
$(info ║ UPDATE_REPO: $(UPDATE_REPO)) #
$(info ║ REPO_SUFFIX: $(REPO_SUFFIX)) #
$(info ║ DISTRIBUTION_CAP: $(DISTRIBUTION_CAP)) # Debian
$(info ║ REPO_PROXY: $(REPO_PROXY)) #
$(info ║ APT_GET_OPTIONS: $(APT_GET_OPTIONS)) #
$(info ║ CHROOT_ENV: $(CHROOT_ENV)) # BACKEND_VMM=xen DEBIAN=/home/user/qubes-src/repo/debian
$(info ╚═══════════════════════════════════════════════════════════════════════════════)
endif
ifneq (,$(DEBIAN_BUILD_DIRS))
unexport release_name
debian-prepare-dist-src: release_name = $(shell $(DEBIAN_PARSER) changelog --package-release-name $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
endif
# fixups for DIST_SRC dir - adjust changelog, cleanup
debian-prepare-dist-src:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
# Cleanup; delete any old builds, except leave the orig that may have
# been created on copy-in build stage
cd $(CHROOT_DIR)/$(DIST_SRC)/..; GLOBIGNORE=$(release_name)*orig*; rm -f $(release_name)*; GLOBIGNORE=
rm -rf $(CHROOT_DIR)/$(DIST_SRC)/deb/*
rm -rf $(CHROOT_DIR)/$(DIST_SRC)/rpm/*
rm -rf $(CHROOT_DIR)/$(DIST_SRC)/pkgs/*
ifeq (1,$(INCREMENT_DEVEL_VERSIONS))
# hardlink changelog.{dist,$(DIST)} into build environment, since git clean
# (called when creating orig.tar.xz) might remove them
ln $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog.dist $(CHROOT_DEBIAN_DIR)/ 2>/dev/null || true
ln $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog.$(DIST) $(CHROOT_DEBIAN_DIR)/ 2>/dev/null || true
# Break the hardlink - keep modified debian/changelog only in build copy
cp $(CHROOT_DEBIAN_DIR)/changelog $(CHROOT_DEBIAN_DIR)/changelog.copy
mv $(CHROOT_DEBIAN_DIR)/changelog.copy $(CHROOT_DEBIAN_DIR)/changelog
# Update changelog with -develXX appended to version
# Note: INCREMENT_DEVEL_VERSIONS needs to be set to 1 in
# builder configuration to use this feature
cd $(CHROOT_DIR)/$(DIST_SRC); $(DEBIAN_PLUGIN_DIR)/scripts/debian-changelog.sh
# copy changelog.{dist,$(DIST)} back to original src dir to have continious +devel numbering
# if the files are already there, do nothing because they are hardlinks
cp -np $(CHROOT_DEBIAN_DIR)/changelog.dist $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/ 2>/dev/null || true
cp -np $(CHROOT_DEBIAN_DIR)/changelog.$(DIST) $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/ 2>/dev/null || true
else
# break the release build if changelog does not match version file
cd $(CHROOT_DEBIAN_DIR)/..; $(DEBIAN_PLUGIN_DIR)/scripts/debian-changelog.sh --verify
# Break the hardlink
cp $(CHROOT_DEBIAN_DIR)/changelog $(CHROOT_DEBIAN_DIR)/changelog.copy
mv $(CHROOT_DEBIAN_DIR)/changelog.copy $(CHROOT_DEBIAN_DIR)/changelog
echo "Building package in $(DIST_SRC)"
cd $(CHROOT_DIR)/$(DIST_SRC)/$(PACKAGE)/..; export LC_ALL=C DEBFULLNAME=Builder DEBEMAIL=user@localhost; \
debchange -t -l+$(DIST_TAG)u "Build for $(DIST)"; debchange -t --force-distribution -r -D $(DIST) $(DIST)
$(DEBIAN_PLUGIN_DIR)/scripts/clamp-changelog-entry-date $(CHROOT_DEBIAN_DIR)/changelog
find $(CHROOT_DIR)/$(DIST_SRC) \! -newer $(CHROOT_DEBIAN_DIR)/changelog \
-exec touch --no-dereference --reference=$(CHROOT_DEBIAN_DIR)/changelog {} +
endif
ifeq ($(USE_DIST_BUILD_TOOLS),1)
include $(DEBIAN_PLUGIN_DIR)/Makefile-pbuilder.debian
else
include $(DEBIAN_PLUGIN_DIR)/Makefile-legacy.debian
endif
ifeq (,$(DEBIAN_BUILD_DIRS))
update-repo:
${Q}true
else
unexport source_name package_ver package_ver_dist release_name_dist release_name_full
update-repo: source_name = $(shell $(DEBIAN_PARSER) changelog --package-name $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
update-repo: package_ver = $(shell $(DEBIAN_PARSER) changelog --package-version-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
update-repo: package_ver_dist = $(shell $(DEBIAN_PARSER) changelog --package-version-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog.$(DIST) 2>/dev/null)
update-repo: release_name_dist = $(shell $(DEBIAN_PARSER) changelog --package-release-name-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog.$(DIST) 2>/dev/null)
update-repo: release_name_full = $(shell $(DEBIAN_PARSER) changelog --package-release-name-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
update-repo-prepare:
${Q}mkdir -p $(UPDATE_REPO)/conf
${Q}if [ ! -e $(UPDATE_REPO)/conf/distributions ]; then \
touch $(UPDATE_REPO)/conf/distributions; \
fi
${Q}grep $(DIST) $(UPDATE_REPO)/conf/distributions > /dev/null; \
if [ $$? -ne 0 ]; then \
echo "$$aptdistributions" >> $(UPDATE_REPO)/conf/distributions; \
fi
update-repo: update-repo-prepare update-repo-do
update-repo-do:
ifndef UPDATE_REPO
$(error "You need to specify destination repo in UPDATE_REPO variable")
endif
${Q}if [ "0$(INCREMENT_DEVEL_VERSIONS)" -eq 1 -a -n "$(release_name_dist)" ]; then \
$(REPREPRO) $(EXTRA_REPREPRO_OPTS) -b $(UPDATE_REPO) include $(DEBIANVERSION)$(REPO_SUFFIX) $(BUILDER_REPO_DIR)/deb/$(release_name_dist)_amd64.changes </dev/null >/dev/null || exit 1; \
else \
$(REPREPRO) $(EXTRA_REPREPRO_OPTS) -b $(UPDATE_REPO) include $(DEBIANVERSION)$(REPO_SUFFIX) $(BUILDER_REPO_DIR)/deb/$(release_name_full)+$(DIST_TAG)u1_amd64.changes </dev/null >/dev/null || exit 1; \
fi
ifdef SNAPSHOT_FILE
${Q}if [ "0$(INCREMENT_DEVEL_VERSIONS)" -eq 1 -a -n "$(package_ver_dist)" ]; then \
echo '$$Source (== $(source_name)), Version (== $(package_ver_dist))' > $(SNAPSHOT_FILE); \
else \
echo '$$Source (== $(source_name)), Version (== $(package_ver)+$(DIST_TAG)u1)' > $(SNAPSHOT_FILE); \
fi
endif
endif
update-repo-from-snapshot: pkg_filter = $(shell cat $(SNAPSHOT_FILE))
update-repo-from-snapshot: update-repo-prepare update-repo-from-snapshot-do
update-repo-from-snapshot-do:
$(REPREPRO) --ignore=surprisingbinary -b $(UPDATE_REPO) copyfilter $(DIST)$(REPO_SUFFIX) $(DIST)$(SNAPSHOT_REPO_SUFFIX) '$(pkg_filter)'
ifeq (,$(DEBIAN_BUILD_DIRS))
check-repo:
${Q}true
else
unexport source_name package_ver
check-repo: source_name = $(shell $(DEBIAN_PARSER) changelog --package-name $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
check-repo: package_ver = $(shell $(DEBIAN_PARSER) changelog --package-version-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
check-repo:
ifndef UPDATE_REPO
$(error "You need to specify destination repo in UPDATE_REPO variable")
endif
$(REPREPRO) -b $(UPDATE_REPO) -T deb listfilter $(DEBIANVERSION)$(REPO_SUFFIX) '$$Source (== $(source_name)), Version (== $(package_ver)+$(DIST_TAG)u1)' | grep -q " "
endif
ifeq (,$(PACKAGE_LIST))
sign:
${Q}true
else
unexport release_name_full release_name_full_dist
sign: release_name_full = $(shell $(DEBIAN_PARSER) changelog --package-release-name-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog)
sign: release_name_full_dist = $(shell $(DEBIAN_PARSER) changelog --package-release-name-full $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/changelog.$(DIST))
sign:
${Q}if [ "0$(INCREMENT_DEVEL_VERSIONS)" -eq 1 -a -n "$(release_name_full_dist)" ]; then \
debsign $(DEBSIGN_ARGS) --no-re-sign \
$(BUILDER_REPO_DIR)/deb/$(release_name_full_dist)_amd64.changes; \
else \
debsign $(DEBSIGN_ARGS) --no-re-sign \
$(BUILDER_REPO_DIR)/deb/$(release_name_full)+$(DIST_TAG)u1_amd64.changes; \
fi
endif