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