forked from fboender/ansible-cmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (81 loc) · 3.33 KB
/
Makefile
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
.PHONY: doc test example
PROG=ansible-cmdb
fake:
# NOOP
test:
cd test && ./test.sh
example:
example/generate.sh
release_clean: clean
@if [ "$(shell git status --porcelain)" != "" ]; then echo "Repo not clean. Not building"; exit 1; fi
release: release_src release_deb release_rpm
doc:
markdown_py README.md > README.html
release_src: release_clean doc
@echo "Making release for version $(REL_VERSION)"
@if [ -z "$(REL_VERSION)" ]; then echo "REL_VERSION required"; exit 1; fi
# Cleanup
rm -rf $(PROG)-$(REL_VERSION)
# Prepare source
mkdir $(PROG)-$(REL_VERSION)
cp -ar src/* $(PROG)-$(REL_VERSION)/
cp -r lib/mako $(PROG)-$(REL_VERSION)/
cp -r lib/yaml $(PROG)-$(REL_VERSION)/
cp LICENSE $(PROG)-$(REL_VERSION)/
cp README.md $(PROG)-$(REL_VERSION)/
cp CHANGELOG.txt $(PROG)-$(REL_VERSION)/
cp contrib/release_Makefile $(PROG)-$(REL_VERSION)/Makefile
cp contrib/ansible-cmdb.man.1 $(PROG)-$(REL_VERSION)/
# Bump version numbers
find $(PROG)-$(REL_VERSION)/ -type f -print0 | xargs -0 sed -i "s/%%MASTER%%/$(REL_VERSION)/g"
# Create archives
zip -q -r $(PROG)-$(REL_VERSION).zip $(PROG)-$(REL_VERSION)
tar -czf $(PROG)-$(REL_VERSION).tar.gz $(PROG)-$(REL_VERSION)
release_deb: release_clean doc
@if [ -z "$(REL_VERSION)" ]; then echo "REL_VERSION required"; exit 1; fi
# Cleanup
rm -rf rel_deb
mkdir -p rel_deb/usr/bin
mkdir -p rel_deb/usr/lib/${PROG}
mkdir -p rel_deb/usr/lib/${PROG}/mako
mkdir -p rel_deb/usr/lib/${PROG}/yaml
mkdir -p rel_deb/usr/share/doc/$(PROG)
mkdir -p rel_deb/usr/share/man/man1
# Copy the source to the release directory structure.
cp LICENSE rel_deb/usr/share/doc/$(PROG)/
cp README.md rel_deb/usr/share/doc/$(PROG)/
cp README.html rel_deb/usr/share/doc/$(PROG)/
cp CHANGELOG.txt rel_deb/usr/share/doc/$(PROG)/
cp -r src/* rel_deb/usr/lib/${PROG}/
cp -r lib/mako rel_deb/usr/lib/${PROG}/
cp -r lib/yaml rel_deb/usr/lib/${PROG}/
ln -s /usr/lib/$(PROG)/ansible-cmdb rel_deb/usr/bin/ansible-cmdb
cp -ar contrib/debian/DEBIAN rel_deb/
cp -ar contrib/ansible-cmdb.man.1 rel_deb/usr/share/man/man1/ansible-cmdb.1
gzip rel_deb/usr/share/man/man1/ansible-cmdb.1
# Bump version numbers
find rel_deb/ -type f -print0 | xargs -0 sed -i "s/%%MASTER%%/$(REL_VERSION)/g"
# Create debian pacakge
fakeroot dpkg-deb --build rel_deb > /dev/null
mv rel_deb.deb $(PROG)-$(REL_VERSION).deb
# Cleanup
rm -rf rel_deb
rm -rf $(PROG)-$(REL_VERSION)
release_rpm: release_clean release_deb
alien -r -g $(PROG)-$(REL_VERSION).deb
sed -i '\:%dir "/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/share/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/share/man/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/share/man/man1/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/lib/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
sed -i '\:%dir "/usr/bin/":d' $(PROG)-$(REL_VERSION)/$(PROG)-$(REL_VERSION)-2.spec
cd $(PROG)-$(REL_VERSION) && rpmbuild --buildroot='$(shell readlink -f $(PROG)-$(REL_VERSION))/' -bb --target noarch '$(PROG)-$(REL_VERSION)-2.spec'
clean:
rm -f *.rpm
rm -f *.deb
rm -f *.tar.gz
rm -f *.zip
rm -f README.html
find ./ -name "*.pyc" -delete
find ./ -name "__pycache__" -type d -delete