]> git.donarmstrong.com Git - debian/debian-policy.git/blob - debian/rules
debian/rules: Fix a race condition while generating DEBIAN/md5sums.
[debian/debian-policy.git] / debian / rules
1 #!/usr/bin/make -f
2
3 ifdef ARCH
4   ha:=-a$(ARCH)
5 endif
6
7 # set the dpkg-architecture vars; but we don't use them, so we'll comment out
8 export DEB_BUILD_ARCH      ?= $(shell dpkg-architecture $(ha) -qDEB_BUILD_ARCH)
9 export DEB_BUILD_GNU_CPU   ?= $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_CPU)
10 export DEB_BUILD_GNU_SYSTEM?= $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_SYSTEM)
11 export DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_TYPE)
12 export DEB_HOST_ARCH       ?= $(shell dpkg-architecture $(ha) -qDEB_HOST_ARCH)
13 export DEB_HOST_GNU_CPU    ?= $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_CPU)
14 export DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_SYSTEM)
15 export DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_TYPE)
16
17 arch    := $(shell dpkg --print-architecture)
18
19 # Basic information
20 package := $(shell grep Source debian/control | sed 's/^Source: //')
21 date    := $(shell date +"%Y-%m-%d")
22 version := $(shell awk -F '[()]' '/^$(package)/{ print $$2; exit }' debian/changelog)
23
24 # Location of the source dir
25 SRCTOP    := $(CURDIR)
26 TMPTOP    := $(SRCTOP)/debian/tmp
27 DOCDIR    := $(TMPTOP)/usr/share/doc/$(package)
28 LIBDIR    := $(TMPTOP)/usr/share/doc-base
29
30 sanitycheck := debian/rules policy.sgml
31
32 SGML_FILES := policy menu-policy mime-policy perl-policy
33 DESC_FILES := debian-policy debian-menu-policy debian-perl-policy \
34               debian-mime-policy debconf-spec fhs
35
36 # While we have two versions of the FHS installed in the source package,
37 # we need to modify this to handle it.  This is the easiest way to do it.
38 # FHS_ARCHIVE := $(wildcard fhs*.tar.gz)
39 FHS_ARCHIVE  := fhs-2.3-source.tar.gz
40 FHS_HTML     := fhs-2.3.html
41 FHS_FILES    := fhs-2.3.ps.gz fhs-2.3.txt.gz fhs-2.3.pdf.gz
42 FHS_NEW_ARCHIVE  := 
43 FHS_NEW_HTML     := 
44 FHS_NEW_FILES    := 
45
46 POLICY_FILES = $(SGML_FILES:=.sgml) $(SGML_FILES:=.txt.gz) \
47                virtual-package-names-list.txt \
48                upgrading-checklist.txt libc6-migration.txt version.ent \
49                debconf_spec/debconf_specification.html \
50                debconf_spec/debconf_specification.txt.gz \
51                policy.ps.gz policy.pdf.gz
52
53 # policy.{pdf,ps,tpt,txt} are generated files
54 FILES_TO_CLEAN  = debian/files debian/buildinfo  debian/substvars \
55                   debian/postinst debian/prerm \
56                   version.ent upgrading-checklist.txt \
57                   $(SGML_FILES:=.txt.gz) $(SGML_FILES:=.html.tar.gz) \
58                   policy.pdf.gz policy.ps.gz \
59                   debconf_specification.xml.tar.gz \
60                   policy.pdf policy.ps policy.txt policy. \
61                   body.tmp head.tmp policy.tpt
62
63 STAMPS_TO_CLEAN := stamp-policy stamp-build
64 DIRS_TO_CLEAN   := debian/tmp fhs $(SGML_FILES:=.html)
65
66
67 install_file    := install -p   -o root -g root  -m  644
68 install_program := install -p   -o root -g root  -m  755
69 make_directory  := install -p -d        -o root -g root  -m  755
70
71
72 all build: stamp-build
73 stamp-build: version.ent $(sanitycheck)
74         $(MAKE) $(SGML_FILES:=.sgml.validate) \
75                 $(SGML_FILES:=.html.tar.gz) \
76                 $(SGML_FILES:=.txt.gz) \
77                 policy.ps.gz policy.pdf.gz
78         links -dump upgrading-checklist.html | perl -pe 's/[\r\0]//g' > \
79                     upgrading-checklist.txt
80         $(MAKE) -C debconf_spec all
81         touch stamp-build
82
83 configure: version.ent
84 version.ent: debian/changelog
85         rm -f $@
86         echo "<!entity version \"$(version)\">" >> $@
87         echo "<!entity date    \"$(date)\">"    >> $@
88
89 clean: $(sanitycheck)
90 # Undoes the effect of `make -f debian/rules build'.
91         $(MAKE) -C debconf_spec clean
92         rm -f  $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
93         rm -rf $(DIRS_TO_CLEAN)
94         rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o \
95           -name '*~' -o -name '*.bak' -o -name '#*#' -o \
96           -name '.*.orig' -o -name '.*.rej' -o -name '.SUMS' -o \
97           -size 0 \) -print` TAGS
98
99
100 binary:         binary-indep binary-arch
101 binary-arch:    build $(sanitycheck)
102 # There are no architecture-dependent files to be uploaded
103 # generated by this package.  If there were any they would be
104 # made here.
105
106 binary-indep:   stamp-policy
107 stamp-policy:  build $(sanitycheck)
108         @test $$(id | sed -e 's/(.*$$//' -e 's/^uid=//') || \
109                 (echo need root priviledges; exit 1)
110 #       This is unnecessary; commenting out
111 #       test -f stamp-build     || $(MAKE) -f        debian/rules build
112         rm -rf                  $(TMPTOP)
113         $(make_directory)       $(TMPTOP)/DEBIAN
114         $(make_directory)       $(DOCDIR)/fhs
115         $(make_directory)       $(LIBDIR)
116         # create a substvar to reference from debian/control so that
117         # we don't hardcode the policy compliance of the policy
118         # package.  I guess some might question this but I take it as
119         # a given that the debian-policy pkg must always comply with
120         # itself...
121         echo "debian-policy:Version=$(version)"      > debian/substvars
122         $(install_file)     $(POLICY_FILES)          $(DOCDIR)/
123         $(install_file)     debian/changelog         $(DOCDIR)/
124         # Be more specific with file compression
125         gzip -f9            $(DOCDIR)/*.txt $(DOCDIR)/*.sgml \
126                                 $(DOCDIR)/changelog
127 # These are allready compressed
128         #$(install_file)    $(FHS_NEW_FILES)         $(DOCDIR)/fhs/
129         $(install_file)     $(FHS_FILES)             $(DOCDIR)/fhs/
130         $(install_file)     debian/copyright         $(DOCDIR)/
131         GZIP=-9 cd debconf_spec && \
132           tar -zcf ../debconf_specification.xml.tar.gz *
133         $(install_file)     debconf_specification.xml.tar.gz $(DOCDIR)/
134         @set -ex; \
135         for file in $(DESC_FILES); do \
136           $(install_file) $$file.desc $(LIBDIR)/$$file; \
137         done
138         @set -ex; \
139         for file in $(SGML_FILES); do \
140           tar -C $(DOCDIR) -zxf $$file.html.tar.gz; \
141         done
142         $(install_file)     $(FHS_HTML)   $(DOCDIR)/fhs
143         @set -ex; \
144         cd debian/tmp; \
145         find . -path "./DEBIAN" -prune -o -type f -printf '%P\0' \
146            | xargs -r0 md5sum > DEBIAN/md5sums
147         dpkg-gencontrol     -p$(package) -Pdebian/tmp -isp
148         chown               -R root:root debian/tmp
149         chmod               -R go=rX debian/tmp
150         dpkg                --build debian/tmp ..
151         touch               stamp-policy
152
153
154 .PHONY: configure build binary binary-arch binary-indep clean checkroot
155
156 #Local variables:
157 #mode: makefile
158 #End: