-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.debian
executable file
·252 lines (211 loc) · 10.3 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
#!/usr/bin/make -f
# -*- makefile -*-
# ===== You may wish to customize these =====
# Distribution aliases and real codenames
DISTALIASES = stable,testing,unstable
DISTNAMES = sarge,etch,sid
# This is used in pattern-matching/globbing
ALLDISTS = $(DISTALIASES),$(DISTNAMES)
# DIST = default distribution as seen by user
# DDIST = default distribution by codename used by pbuilder
DIST = stable
DDIST = sarge
# Make sure we make clean by excluding -I patterns
DEBBUILDOPTS = -i'CVS|.svn|pkg-.*|build-($(subst ,,|,$(ALLDISTS)))(\.log)?|\.swp$$|~$$' -ICVS -Idebian -I*.swp -I*~ -I.svn* -Ibuild-{$(ALLDISTS)}*
ORIGTAROPTS = --exclude CVS --exclude debian --exclude .svn --exclude pkg-* --exclude build-* --exclude .*.swp --exclude *~ --exclude Makefile.debian
# Repository and mirror setup
# OTHERMIRROR defines which sources to include in chrooted /etc/apt/sources.list
# REPOPATH defines where to copy built results (generally repository's incoming directory)
REPO ?= localhost
OTHERMIRROR ?= http://$(REPO)/debian/
REPOPATH ?= $(REPO):/var/www/debian/mini-dinstall/incoming
REQD = pbuilder sudo devscripts build-essential
BUILDPLACE ?= /tmp/cvs-build
BUILDRESULT ?= $(CURDIR)
FULLNAME ?= $(USER)
EMAIL ?= $(USER)@$(shell hostname)
# ===== DO NOT EDIT THESE =====
BASENAME = $(shell cat $(CURDIR)/debian/control | grep "^Source" | awk '{print $$NF}')
MAJOR = $(shell grep $(BASENAME) $(CURDIR)/debian/changelog | awk -F'[()]' '{print $$2}' | head -1 | cut -d- -f1)
ORIGTAR = $(CURDIR)/../$(BASENAME)_$(MAJOR).orig.tar.gz
# Some help for poor folks
help:
@echo "Makefile.debian is intended to be used w/ Debianized sources."
@echo "As such it expects to find debian/ directory in the same directory from which it was invoked."
@echo "All required dependencies will be satisfied by both Makefile and contents of debian/control."
@echo ""
@echo "Current settings:"
@echo " Your Full Name <email>: $(FULLNAME) <$(EMAIL)> [FULLNAME, EMAIL]"
@echo " Build directory: $(BUILDPLACE) [BUILDPLACE]"
@echo " Results will be placed relative to $(BUILDRESULT) [BUILDRESULT]"
@echo " Additional mirrors: $(OTHERMIRROR) [OTHERMIRROR]"
@echo " Releases will be uploaded to: $(REPOPATH) [REPOPATH]"
@echo ""
@echo "You may additionally define these environment variable prior to running ./Makefile.debian:"
@echo " REPO=$(REPO) - Will swap domainname for both REPOPATH and OTHERMIRROR"
@echo " NODEBCHANGES=1 - Will not edit debian/changelog"
@echo ""
@echo "Usage: ./Makefile.debian <target>"
@echo "Targets:"
@echo " pkg-test - Attempts to build source and binary packages"
@echo " pkg-stable - Same goal as pkg-test, but building is done inside stable chroot"
@echo " pkg-sarge - Same as above, but referenced via codename"
@echo " pkg-all - Same as above, but for every distribution defined in Makefile.debian"
@echo " pkg-release-stable - Same as pkg-stable, but also uploads built source and binary files"
@echo " to a repository specified inside the Makefile"
@echo " pkg-release-all - Same as above, but for every distribution defined in Makefile.debian"
@echo " pkg-clean - Cleans up cruft from previous pkg-* runs"
@echo " dist-clean - Cleans up everything"
@echo ""
# Clean up everything
dist-clean: pkg-clean
-rm -f pkg-conf pkg-clean pkg-{$(ALLDISTS)}
-rm -f build-{$(ALLDISTS)}.log
-rm -f pkg-release-{$(ALLDISTS)}
-rm -rf $(BUILDRESULT)/build-{$(ALLDISTS)}
-sudo rm -rf $(BUILDPLACE)
sudo $(CURDIR)/debian/rules clean
ifneq ($(wildcard $(CURDIR)/$(BASENAME)_*.changes),)
-tac $(CURDIR)/$(BASENAME)_*.changes | sed -n "/^Files/q;p" | awk '{print $$NF}' | xargs -i rm -f $(CURDIR)/{}
-rm -f $(CURDIR)/$(BASENAME)_*.{asc,dsc,build,changes}
endif
# Clean up after package builds
pkg-clean:
-rm -f $(BUILDRESULT)/build-{$(ALLDISTS)}.log
-rm -f pkg-conf pkg-{$(ALLDISTS)}
touch pkg-clean
# Prep build env
pkg-conf: pkg-clean
@echo "===== Attempting to install missing and outdated packages ====="
sudo apt-get install $(REQD)
@echo "===== Faking existence of original source ====="
tar czvf $(ORIGTAR) $(ORIGTAROPTS) .
@echo "===== Preparing Build Environment ====="
sudo mkdir -p $(BUILDPLACE)
sudo pbuilder create --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT) --distribution $(DDIST) --preserve-buildplace
touch pkg-conf
# Test package
pkg-test: pkg-clean
@echo "===== Faking existence of original source ====="
tar czvf $(ORIGTAR) $(ORIGTAROPTS) .
@echo "===== Testing if the package builds ====="
debuild --noconf -rsudo -us -uc $(DEBBUILDOPTS)
@echo "===== Moving built results to $(BUILDRESULT) ====="
tac $(CURDIR)/../$(BASENAME)_*.changes | sed -n "/^Files/q;p" | awk '{print $$NF}' | sudo xargs -i mv $(CURDIR)/../{} $(BUILDRESULT)
-sudo mv $(CURDIR)/../$(BASENAME)_*.{asc,dsc,build,changes} $(BUILDRESULT)
-sudo chown -R $(USER):$(USER) $(BUILDRESULT)/*$(BASENAME)*_*.{deb,asc,dsc,build,changes}
touch pkg-test
# Update changelog
pkg-changelog:
ifndef NODEBCHANGES
cp -a $(CURDIR)/debian/changelog /tmp/$(BASENAME).changelog
@echo "=============================================================="
@echo "Please update version string, name and email address, and enter changes made to the package."
@echo "Or simply remove the topmost stanza."
@echo "PRESS ENTER" && read
DEBFULLNAME=$(FULLNAME) EMAIL=$(EMAIL) dch -i
diff $(CURDIR)/debian/changelog /tmp/$(BASENAME).changelog >& /dev/null || rm -f pkg-{stable,testing,unstable}
endif
# ===== BUILDS =====
# as codenames of distributions change, so should these phone targets like pkg-sarge, pkg-etch etc...
# Build stable
pkg-sarge: DIST = sarge
pkg-sarge: DDIST = sarge
pkg-sarge: pkg-stable
pkg-stable: DIST = stable
pkg-stable: DDIST = sarge
pkg-stable: pkg-conf
mkdir -p $(BUILDRESULT)/build-$(DIST)
@echo "===== BUILDING INSIDE STABLE ====="
test -d $(BUILDPLACE) && \
sudo pbuilder update --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./$(DIST)/" --distribution $(DDIST) --preserve-buildplace || \
(mkdir -p $(BUILDPLACE) && \
sudo pbuilder create --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./$(DIST)/" --distribution $(DDIST) --preserve-buildplace)
sudo pdebuild --buildsourceroot sudo \
--pbuilderroot sudo \
--buildresult $(BUILDRESULT)/build-$(DIST) \
--debbuildopts "$(DEBBUILDOPTS)" \
--logfile $(BUILDRESULT)/build-$(DIST).log \
-- \
--buildplace $(BUILDPLACE) --othermirror "$(OTHERMIRROR)" --distribution $(DDIST) --preserve-buildplace
@echo "===== FIXING PERMS ====="
sudo chown -R $(USER):$(USER) $(BUILDRESULT)/build-$(DIST)
@echo "===== UPDATING DISTRIBUTION FIELD IN DEBIAN/CHANGELOG ====="
sed -i "s/^Distribution:.*$$/Distribution: $(DDIST)/" $(BUILDRESULT)/build-$(DIST)/*.changes
touch pkg-stable
# Build testing
pkg-etch: DIST = etch
pkg-etch: DDIST = etch
pkg-etch: pkg-testing
pkg-testing: DIST = testing
pkg-testing: DDIST = etch
pkg-testing: pkg-conf
mkdir -p $(BUILDRESULT)/build-$(DIST)
@echo "===== BUILDING INSIDE TESTING ====="
test -d $(BUILDPLACE) && \
sudo pbuilder update --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./testing/" --distribution $(DDIST) --preserve-buildplace || \
(mkdir -p $(BUILDPLACE) && \
sudo pbuilder create --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./testing/" --distribution $(DDIST) --preserve-buildplace)
sudo pdebuild --buildsourceroot sudo \
--pbuilderroot sudo \
--buildresult $(BUILDRESULT)/build-$(DIST) \
--debbuildopts "$(DEBBUILDOPTS)" \
--logfile $(BUILDRESULT)/build-$(DIST).log \
-- \
--buildplace $(BUILDPLACE) --othermirror "$(OTHERMIRROR)" --distribution $(DDIST) --preserve-buildplace
@echo "===== FIXING PERMS ====="
sudo chown -R $(USER):$(USER) $(BUILDRESULT)/build-$(DIST)
@echo "===== UPDATING DISTRIBUTION FIELD IN DEBIAN/CHANGELOG ====="
sed -i "s/^Distribution:.*$$/Distribution: $(DDIST)/" $(BUILDRESULT)/build-$(DIST)/*.changes
touch pkg-testing
# Build testing
pkg-sid: DIST = sid
pkg-sid: DDIST = sid
pkg-sid: pkg-unstable
pkg-unstable: DIST = unstable
pkg-unstable: DDIST = sid
pkg-unstable: pkg-conf
mkdir -p $(BUILDRESULT)/build-$(DIST)
@echo "===== BUILDING INSIDE UNSTABLE ====="
test -d $(BUILDPLACE) && \
sudo pbuilder update --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./$(DIST)/" --distribution $(DDIST) --preserve-buildplace || \
(mkdir -p $(BUILDPLACE) && \
sudo pbuilder create --buildplace $(BUILDPLACE) --buildresult $(BUILDRESULT)/build-$(DIST) --othermirror "deb $(OTHERMIRROR) ./$(DIST)/" --distribution $(DDIST) --preserve-buildplace)
sudo pdebuild --buildsourceroot sudo \
--pbuilderroot sudo \
--buildresult $(BUILDRESULT)/build-$(DIST) \
--debbuildopts "$(DEBBUILDOPTS)" \
--logfile $(BUILDRESULT)/build-$(DIST).log \
-- \
--buildplace $(BUILDPLACE) --othermirror "$(OTHERMIRROR)" --distribution $(DDIST) --preserve-buildplace
@echo "===== FIXING PERMS ====="
sudo chown -R $(USER):$(USER) $(BUILDRESULT)/build-$(DIST)
@echo "===== UPDATING DISTRIBUTION FIELD IN DEBIAN/CHANGELOG ====="
sed -i "s/^Distribution:.*$$/Distribution: $(DDIST)/" $(BUILDRESULT)/build-$(DIST)/*.changes
touch pkg-unstable
# Build package
pkg-all: pkg-stable pkg-testing pkg-unstable
# Release packages
pkg-release-all: pkg-release-stable pkg-release-testing pkg-release-unstable
pkg-release-sarge: DIST = sarge
pkg-release-sarge: pkg-release-stable
pkg-release-stable: DIST = stable
pkg-release-stable: pkg-conf pkg-changelog pkg-stable
# ===== Uploading to $(REPOPATH) =====
scp $(BUILDRESULT)/build-$(DIST)/* $(REPOPATH)
touch pkg-release-stable
pkg-release-etch: DIST = etch
pkg-release-etch: pkg-release-testing
pkg-release-testing: DIST = testing
pkg-release-testing: pkg-conf pkg-changelog pkg-testing
# ===== Uploading to $(REPOPATH) =====
scp $(BUILDRESULT)/build-$(DIST)/* $(REPOPATH)
touch pkg-release-testing
pkg-release-sid: DIST = sid
pkg-release-sid: pkg-release-unstable
pkg-release-unstable: DIST = unstable
pkg-release-unstable: pkg-conf pkg-changelog pkg-unstable
# ===== Uploading to $(REPOPATH) =====
scp $(BUILDRESULT)/build-$(DIST)/* $(REPOPATH)
touch pkg-release-unstable
.PHONY: pkg-all, pkg-sarge, pkg-etch, pkg-sid, pkg-release-sarge, pkg-release-etch, pkg-release-sid, pkg-release-all