Commit | Line | Data |
---|---|---|
e043b5aa OL |
1 | # -*- Makefile -*- |
2 | ||
7cf8d4b7 | 3 | DIR = ../master/ |
e043b5aa OL |
4 | |
5 | CONFIGDIR = debian/ | |
6 | ||
7 | FILES = $(shell cd $(DIR); find etc/ -type f) | |
8 | ||
7cf8d4b7 | 9 | TARGET = ../$(MODULE)_$(VERSION)_$(ARCH).deb |
e043b5aa OL |
10 | |
11 | OBJECTS = deb/DEBIAN/preinst \ | |
12 | deb/DEBIAN/postrm \ | |
84523910 | 13 | deb/DEBIAN/postinst |
e043b5aa OL |
14 | |
15 | SHELL=/bin/bash | |
7cf8d4b7 | 16 | MODULE = $(shell basename `pwd`) |
e043b5aa OL |
17 | ARCH = all |
18 | ||
19 | .DEFAULT: all | |
20 | .PHONY: clean deb all | |
21 | ||
22 | VERSION = $(shell awk '/^$(MODULE)/ { gsub(/[()]/, ""); print $$2; exit }' debian/debian-changelog) | |
23 | ||
24 | ||
25 | all: $(TARGET) deb | |
26 | ||
27 | clean: | |
28 | rm -rf deb $(OBJECTS) $(TARGETS) | |
29 | ||
30 | deb: | |
31 | rm -rf deb | |
32 | mkdir --parent deb/etc/webconfig/ deb/etc/default/ deb/DEBIAN | |
33 | ||
34 | deb/DEBIAN/preinst: debian/debian-preinst deb $(addprefix $(DIR)/, $(FILES)) $(MAKEFILE_LIST) | |
35 | rm -f $@ | |
36 | cat $< > $@~ | |
37 | for f in $(FILES); do echo '[ -f "/'$$f'" ] && dpkg-divert --add /'$$f; done >>$@~ | |
38 | echo "exit 0" >>$@~ | |
39 | chmod +x $@~ | |
40 | mv $@~ $@ | |
41 | ||
42 | deb/DEBIAN/postrm: debian/debian-postrm deb $(addprefix $(DIR)/, $(FILES)) $(MAKEFILE_LIST) | |
43 | rm -f $@ | |
44 | cat $< > $@~ | |
45 | for f in $(FILES); do echo '[ -f "/'$$f'" ] && dpkg-divert --remove /'$$f; done >>$@~ | |
46 | echo "exit 0" >>$@~ | |
47 | chmod +x $@~ | |
48 | mv $@~ $@ | |
49 | ||
50 | deb/DEBIAN/postinst: debian/debian-postinst deb | |
51 | cp $< $@ | |
52 | ||
e043b5aa OL |
53 | $(TARGET): deb $(OBJECTS) |
54 | sed s/@@version@@/$(VERSION)/ debian/debian-control > deb/DEBIAN/control | |
55 | mkdir -p deb/usr/share/doc/$(MODULE) | |
56 | cp debian/debian-changelog deb/usr/share/doc/$(MODULE)/changelog | |
57 | cp -r $(DIR)/* deb/ | |
58 | fakeroot dpkg --build deb | |
59 | mv deb.deb $@ |