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