File: rules

package info (click to toggle)
linbot 0.8-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 140 kB
  • ctags: 5
  • sloc: sh: 602; makefile: 126; perl: 7
file content (408 lines) | stat: -rwxr-xr-x 14,994 bytes parent folder | download
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#!/usr/bin/make -f
#
# source:
#   /var/cvs/projects/debian/dpkg.common/rules,v
#
# revision:
#   @(#) rules,v 1.14 1998/06/06 18:43:17 jplejacq Exp
#
# copyright:
#   Copyright (C) 1998 Jean Pierre LeJacq <jplejacq@quoininc.com>
#
#   Distributed under the GNU GENERAL PUBLIC LICENSE.
#
# synopsis:
#   rules [build|binary|binary-indep|binary-arch|get-orig-source|clean]
#   rules [set-scheme-opt|set-scheme-standard|set-links|clean_dist|check]
#
# description:
#   Package building script for package.
#
#   The first synopsis shows the standard Debian package building makefile
#   targets.  The second synopsis shows my own target extensions to add extra
#   capabilities.  Generally, you will not have to use the second set of
#   targets.
#
#   I've organized this package a little differently than most Debian packages
#   to hopefully simplify building and maintaining packages.  It is fully
#   compatible with dpkg-buildpackage and abides by both the Debian policy and
#   packaging manuals.  While this package uses many components of debhelper it
#   is not fully compatible with it.  The rest of this comments describe the
#   basic architecture.
#
#   I had several goals for packaging beyond compatibility with the
#   Debian standard:
#     * Installation in either the standard directory hierarchy or an
#       alternative.  Currently, the only supported alternative is the
#       /opt hierarchy.
#     * Localize all edits to upstream original source in a single
#       script.
#     * Support multiple packages from source.
#     * Minimize need for super user access.
#     * Reuse of packaging building components across packages.  Use
#       of debhelper is one example of this.
#     * Source control of packaging files with CVS.
#
#   These goals are met by defining a number of parameterized scripts which
#   modify both the upstream sources and Debian added files.  The parameters
#   that define the files and directories are defined in a file
#   dpkg.common/substfiles and dpkg.scripts/substfiles.
#
#   debian packaging architecture:
#     I use CVS to source control the packaging scripts and files used to build
#     the package.  Many of the files are reused across different packages and
#     I use CVS's module facility to automatically provide reuse.  After
#     checkout, the directory hierarchy for the project looks like:
#
#       <source>.orig.tar.gz
#       <source>-<version>/
#         debian/
#           dpkg.common/
#             check
#             clean
#             installcontrol.in
#             installsrc.in
#             modifydpkg
#             rules
#             rules_var.mk
#             substfiles
#           dpkg.scripts/
#             build.in
#             installdirs.in
#             installfiles.in
#             installowners.in
#             modifysrc
#             substfiles
#           dpgk.src/
#             changelog
#             control
#             copyright.in
#
#     The topmost directory is given the name of the package source name and
#     version number.  At the same level is the original pristine upstream
#     source files in tar.gz format.  The directory contains three directories.
#     The "dpkg.common" directory contains files that are shared among all the
#     Debian packages I maintain.  The "dpkg.scripts" directory contains files
#     that are used to build the package and do not become part of the final
#     binary packages. The "dpkg.src" directory contains files that are added
#     to the upstream source to form the final binary packages.  I've shown
#     several files in each directory that are commonly used across my Debian
#     packages.
#
#     The following files in dpkg.common can be overridden by providing a file
#     with the same name in dpkg.scripts when a package needs to override the
#     default behavior defined.
#       check
#       clean
#       modifydpkg
#       installcontrol.in
#       installsrc.in
#
#   build process:
#     Notice that the "rules" file (which you are reading now) is package
#     independent. This was achieved by moving all of the real work into the
#     programs in the directory dpkg.scripts and using some advanced features
#     of GNU make.  The rules files provides a framework for building packages
#     by defining the processes and their execution order. It was designed to
#     work with dpkg-buildpackage with the "-r" option to gain root access.
#     I've successfully used both "super" and "fakeroot" with this architecture
#     and recommend "fakeroot".
#
#     When first checked out of the CVS repository, one additional step must be
#     done before using dpkg_buildpackage.  Similarly, before checking into
#     the CVS repository, one additional step must be taken after the normal
#     "clean" target.  After moving to the the top most directory, the total
#     steps are:
#
#       0. Setup for operation with dpkg-buildpackage (only needs to
#          be done when first checking out from CVS).
#
#          $ debian/dpkg.common/rules set-links
#
#       1. Optionally, setup for building binary packages for "/opt"
#          directory layout (This does not follow the normal Debian directory
#          hierarchy but does follow the FHS standard).
#
#          $ debian/rules set-scheme-opt
#
#       2. Optionally, download original source.
#
#          $ debian/rules get-orig-source
#
#       3. Build all binary and source packages.
#
#          $ dpkg-buildpackage -rfakeroot
#
#       4. Optionally, check the binary packages.  Currently, this
#          uses lintian and the weblint and nsgmls tools for HTML page
#          validation.  It also checks that no parameterization
#          variables remain in the binary packages.
#
#          $ debian/rules check
#
#       5. Optionally, clean build directories.
#
#          $ fakeroot debian/rules clean
#
#       6. Optionally, remove all non-source controlled files (only
#          needs to be done when committing into CVS).
#
#          $ fakeroot debian/rules clean_dist
#
#   packages:
#     The "rules" file is designed to work with Debian packages that
#     produce both single and multiple binary packages.  It achieves
#     this by using several debhelper programs to define several make
#     macros defined in the file "rules_var.mk".  After a complete
#     build the directory hierarchy looks like:
#
#      <source>.orig.tar.gz
#      <source>-<version>/
#        debian/
#          dpkg.common/
#          dpkg.scripts/
#          dpgk.src/
#          <package>.src/
#          <package>.tmp/
#
#     For each binary package a "<package>.src" directory is created
#     which contains the original source code modified by the file
#     "dpkg.scripts/modifysrc".  The final build directory for each
#     package is "<package>.tmp".
#
#   target directory hierarchy:
#     I've designed this package to be built for either installation
#     in the normal directory hierarchy or the /opt directory.  If the
#     make target "set-scheme-opt" is executed before building, the
#     /opt directory hierarchy is used.  The ability to support
#     multiple target directory hierarchies was achieved by
#     parameterizing the files in the "dpkg.src" and "dpkg.scripts".
#     These all have the suffix "*.in".  The file
#     "dpkg.scripts/substfiles" defines the directories for the
#     alternate layouts.  The files "dpkg.scripts/modifydpkg" and
#     "dpkg.scripts/modifysrc" replace all occurrences of
#     "@@variable@@" with the variables defined in substfiles.
#
#   building as normal user:
#     This program can be executed without root privilege except for the
#     following commands:
#       * chown
#       * chmod   Not always necessary, only if there is a sgid file
#                 that gets reset when the ownership is changed.
#       * tar     Not always necessary, only if file not readable by
#                 the package builder.
#       *         Any others?
#
#     The basic strategy is to build as much as possible before changing the
#     ownership from the builder to the final installed ownership.  This
#     prevents possible damage when building the package.  It also enables the
#     package to be built by the real maintainer with the resulting packages
#     pgp signed with the maintainer's real key.
#
#     I have enable a check for root using dh_testroot in all the makefile
#     targets documented in the debian packaging modules.
#
#     To enable these commands, you can use super with the "-r" option of
#     dpkg-buildpackage.  I create an entry in /etc/super.tab for
#     "debian/rules" and then protected each of the required makefile targets
#     with a call to dh_testroot.  The entry in /etc/super.tab must be an
#     absolute path to debian/rules which causes a problem when trying to
#     support multiple projects.  I solve this by always building Debian
#     projects in a set directory and use a symbolic link showing which project
#     I'm currently building.  The entry in /etc/super.tab then refers to this
#     symbolic link.  Notice that the directory containing this link should be
#     carefully protected to prevent security problems.
#
#       /home/jplejacq/projects/debian
#         drwxrws---   4 jplejacq develop  .
#         drwxrwxr-x  15 jplejacq jplejacq ..
#         drwxrwxr-x   4 jplejacq develop  cracklib
#         lrwxrwxrwx   1 jplejacq develop  current -> cracklib/
#         drwxrwxr-x   4 jplejacq develop  printop
#
#     Alternatively, you can use the fakeroot package.  This doesn't execute as
#     root at all and is therefore safer.  I recommend this approach though
#     there does seem to be problem when building on an NFS mounted directory.
#
# bugs:
#   dh_makeshlibs and dh_md5sums should not require root privileges
#   and therefore should be in the debian/build target.


include debian/dpkg.common/rules_var.mk


# public interface:
  build: $(patsubst %,debian/%.stamp-build,$(rules_pkgs))


  binary: binary-indep binary-arch


  binary-indep: $(patsubst %,debian/%.stamp-binary,$(rules_pkgs_indep))


  binary-arch: $(patsubst %,debian/%.stamp-binary,$(rules_pkgs_arch))


  get-orig-source: debian/dpkg.stamp-modify
	dh_testdir
	debian/dpkg.scripts/installsrc


  clean:
	dh_testdir
	dh_testroot
	debian/dpkg.scripts/clean



# non-standard public interface:
  #
  # Set build process to use /opt directory layout.
  #
  set-scheme-opt:
	dh_testdir
	rm -f debian/scheme-*
	touch debian/scheme-opt


  #
  # Set build process to use normal directory layout.
  #
  set-scheme-standard:
	dh_testdir
	rm -f debian/scheme-*
	touch debian/scheme-standard


  #
  # Create symbolic links so that standard debian packaging tools can
  # find required files. Only create link if package doesn't override
  # standard scripts.  Cannot use dh_testdir here since it looks for
  # debian/control.
  #
  set-links:
	ln -f -s dpkg.common/rules debian
	ln -f -s dpkg.src/changelog debian
	ln -f -s dpkg.src/control debian
	ln -f -s dpkg.src/copyright debian
	-(test -f debian/dpkg.src/shlibs.in &&\
	  ln -f -s dpkg.src/shlibs debian)
	-(test ! -f debian/dpkg.scripts/clean &&\
	  ln -f -s ../dpkg.common/clean debian/dpkg.scripts)
	-(test ! -f debian/dpkg.scripts/modifydpkg &&\
	  ln -f -s ../dpkg.common/modifydpkg debian/dpkg.scripts)
	-(test ! -f debian/dpkg.scripts/check.in &&\
	  ln -f -s ../dpkg.common/check.in debian/dpkg.scripts)
	-(test ! -f debian/dpkg.scripts/installcontrol.in &&\
	  ln -f -s ../dpkg.common/installcontrol.in debian/dpkg.scripts)
	-(test ! -f debian/dpkg.scripts/installsrc.in &&\
	  ln -f -s ../dpkg.common/installsrc.in debian/dpkg.scripts)



  #
  # Remove all files and links that are not source controlled with CVS.
  #
  clean_dist: clean
	dh_testdir
	-rm -f debian/scheme-*
	-rm -f debian/rules
	-rm -f debian/changelog
	-rm -f debian/control
	-rm -f debian/copyright
	-rm -f debian/shlibs
	-(test -L debian/dpkg.scripts/clean &&\
	  rm -f debian/dpkg.scripts/clean)
	-(test -L debian/dpkg.scripts/modifydpkg &&\
	  rm -f debian/dpkg.scripts/modifydpkg)
	-(test -L debian/dpkg.scripts/check.in &&\
	  rm -f debian/dpkg.scripts/check.in)
	-(test -L debian/dpkg.scripts/installcontrol.in &&\
	  rm -f debian/dpkg.scripts/installcontrol.in)
	-(test -L debian/dpkg.scripts/installsrc.in &&\
	  rm -f debian/dpkg.scripts/installsrc.in)
	-rm -f ../*.deb ../*.dsc ../*.changes ../*.tar.gz


   #
   # Check all binary packages.
   #
   check: $(patsubst %,debian/%.stamp-check,$(rules_pkgs))



# private interface:
  #
  # Check target for each binary package.
  #
  $(patsubst %,debian/%.stamp-check,$(rules_pkgs)):\
	  %.stamp-check : %.stamp-binary
	dh_testdir
	@echo "rules: check: checking package..."
	  debian/dpkg.scripts/check -p$(rules_pkg) -P$(rules_tmpdir)
	touch $(@)


  #
  # Binary target for each binary package.
  #
  $(patsubst %,debian/%.stamp-binary,$(rules_pkgs)):\
	  %.stamp-binary : %.stamp-build
	dh_testdir
	dh_testroot
	@echo "rules: binary: generating shlib..."
	  (umask 022 && dh_makeshlibs -p$(rules_pkg) -P$(rules_tmpdir))
	@echo "rules: binary: generating md5 checksums..."
	  (umask 022 && dh_md5sums -p$(rules_pkg) -P$(rules_tmpdir))
	@echo "rules: binary: setting ownership..."
	  debian/dpkg.scripts/installowners -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: binary: building binary package..."
	  dh_builddeb -p$(rules_pkg) -P$(rules_tmpdir)
	touch $(@)


  #
  # Build target for each binary package.
  #
  $(patsubst %,debian/%.stamp-build,$(rules_pkgs)):\
	  %.stamp-build : %.stamp-modify
	dh_testdir
	@echo "rules: build: configuring and compiling package..."
	  debian/dpkg.scripts/build -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: creating package directory hierarchy..."
	  debian/dpkg.scripts/installdirs -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: copying package files..."
	  debian/dpkg.scripts/installfiles -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: stripping binaries and libraries..."
	  dh_strip -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: creating debian control directory..."
	  debian/dpkg.scripts/installcontrol -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: calculate shared library dependencies..."
	  dh_shlibdeps -p$(rules_pkg) -P$(rules_tmpdir)
	@echo "rules: build: generating package control file..."
	  (umask 022 && dpkg-gencontrol -p$(rules_pkg) -P$(rules_tmpdir))
	touch $(@)


  #
  # Source modification target for each binary package.
  #
  $(patsubst %,debian/%.stamp-modify,$(rules_pkgs)): debian/dpkg.stamp-modify
	dh_testdir
	debian/dpkg.scripts/modifysrc -p$(rules_pkg) -P$(rules_tmpdir)
	touch $(@)


  #
  # Debian package file modification target for source package.
  #
  debian/dpkg.stamp-modify: debian/dpkg.scripts/modifydpkg
	dh_testdir
	debian/dpkg.scripts/modifydpkg
	touch $(@)


  .PHONY: build binary binary-arch binary-indep clean get-orig-source
  .PHONY: set-scheme-opt set-scheme-standard set-links clean_dist check