-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile.packaging
70 lines (63 loc) · 2.74 KB
/
Makefile.packaging
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
UBUNTU_RELEASE := $(shell lsb_release -cs)
# version in the code is authoritative
# Use := here, not =, it's really important, otherwise UPSTREAM_VERSION
# will be updated behind your back with the current result of that
# command everytime it is mentioned/used.
UPSTREAM_VERSION := $(shell python3 -c "from landscape import UPSTREAM_VERSION; print(UPSTREAM_VERSION)")
CHANGELOG_VERSION := $(shell dpkg-parsechangelog | grep ^Version | cut -f 2 -d " " | cut -f 1 -d '-')
GIT_HASH := $(shell git rev-parse --short HEAD)
# We simulate a git "revno" for the sake of sortability.
GIT_REVNO := $(shell git rev-list --count HEAD)
ifeq (+git,$(findstring +git,$(UPSTREAM_VERSION)))
TARBALL_VERSION := $(UPSTREAM_VERSION)
else
TARBALL_VERSION := $(UPSTREAM_VERSION)+git$(GIT_REVNO)
endif
.PHONY: origtarball
origtarball: sdist
cp -f sdist/landscape-client-$(TARBALL_VERSION).tar.gz \
../landscape-client_$(TARBALL_VERSION).orig.tar.gz
.PHONY: prepchangelog
prepchangelog:
@_=$$(dpkg-query -s libdistro-info-perl 2>&1) ;\
if [ "$$?" -ne 0 ]; then \
echo sudo apt-get install libdistro-info-perl ;\
sudo apt-get install libdistro-info-perl ;\
fi
@if [ "$$DEBEMAIL" = "" ]; then \
echo "ERROR: please set \$$DEBEMAIL (NAME <EMAIL>)" 1>&2 ;\
exit 1 ;\
fi
# add a temporary entry for a local build if needed
ifeq (,$(findstring +git,$(CHANGELOG_VERSION)))
dch -v $(TARBALL_VERSION)-0ubuntu0 "New local test build" --distribution $(UBUNTU_RELEASE)
else
# just update the timestamp
dch --distribution $(UBUNTU_RELEASE) --release $(UBUNTU_RELEASE)
endif
.PHONY: updateversion
updateversion:
sed -i -e "s/^UPSTREAM_VERSION.*/UPSTREAM_VERSION = \"$(TARBALL_VERSION)\"/g" \
landscape/__init__.py
.PHONY: package
package: clean prepchangelog updateversion ## Generate the debian packages (use with DEBUILD_OPTS="-us -uc").
debuild -b $(DEBUILD_OPTS)
.PHONY: sourcepackage
sourcepackage: origtarball prepchangelog updateversion
# need to remove sdist here because it doesn't exist in the
# orig tarball
rm -rf sdist
debuild -S $(DEBUILD_OPTS)
.PHONY: releasetarball
releasetarball:
$(MAKE) sdist TARBALL_VERSION=$(UPSTREAM_VERSION)
.PHONY: sdist
sdist: clean
mkdir -p sdist/landscape-client-$(TARBALL_VERSION)
git ls-files --recurse-submodules | xargs -I {} cp -r --parents {} sdist/landscape-client-$(TARBALL_VERSION)
rm -rf sdist/landscape-client-$(TARBALL_VERSION)/debian
sed -i -e "s/^UPSTREAM_VERSION.*/UPSTREAM_VERSION = \"$(TARBALL_VERSION)\"/g" \
sdist/landscape-client-$(TARBALL_VERSION)/landscape/__init__.py
cd sdist && tar cfz landscape-client-$(TARBALL_VERSION).tar.gz landscape-client-$(TARBALL_VERSION)
cd sdist && md5sum landscape-client-$(TARBALL_VERSION).tar.gz > landscape-client-$(TARBALL_VERSION).tar.gz.md5
rm -rf sdist/landscape-client-$(TARBALL_VERSION)