forked from postgrespro/mamonsu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.pkg
108 lines (88 loc) · 3.37 KB
/
Makefile.pkg
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
104
105
106
107
108
TOKEN ?= $(PACKAGECLOUD_TOKEN)
# Check for SUSE and alt linux which need specific spec file
ifeq "$(wildcard /etc/SuSE-rel*)" ""
ifeq "$(wildcard /etc/altlinux-rel*)" ""
SPEC=mamonsu.spec
else
SPEC=mamonsu.alt.spec
endif
else
SPEC=mamonsu.suse.spec
endif
prepare_builddir: clean
mkdir -p build
tar --transform='s,^\.,mamonsu-$(VERSION),'\
-czf build/mamonsu-$(VERSION).tar.gz .\
--exclude=build || echo ok
tar xvf build/mamonsu-$(VERSION).tar.gz -C build
cp build/mamonsu-$(VERSION).tar.gz \
$(BUILDDIR)/packaging/rpm/SOURCES
chown -R root.root $(BUILDDIR)
deb: prepare_builddir
cd $(BUILDDIR) && cp -a $(WORKDIR)/packaging/debian . && dpkg-buildpackage -b
cp -av build/mamonsu*.deb .
rpm: prepare_builddir $(BUILDDIR)/packaging/rpm/SPECS/$(SPEC)
mkdir -p $(BUILDDIR)/packaging/rpm/RPMS $(BUILDDIR)/packaging/rpm/BUILD $(BUILDDIR)/packaging/rpm/SRPMS
rpmbuild -ba --define '_topdir $(BUILDDIR)/packaging/rpm'\
$(BUILDDIR)/packaging/rpm/SPECS/$(SPEC)
cp -av $(BUILDDIR)/packaging/rpm/RPMS/noarch/mamonsu*.rpm .
pkg: build/prepare build/all
docker run -v "$(WORKDIR)":/src --rm debian:wheezy bash -exc " \
cp /src/packaging/push.rb /src/build/out && cd /src/build/out && \
(apt-get update -m || apt-get update -m || apt-get update -m) && \
apt-get install -y ruby-dev && gem install --no-ri --no-rdoc package_cloud -v 0.2.37 && \
TOKEN=$(TOKEN) ruby push.rb"
build/prepare:
mkdir -p build
touch build/prepare
build/all: build/pkg_debian build/pkg_ubuntu build/pkg_centos
@echo Build for all platform: done
touch build/all
build/pkg_debian: build/pkg_debian_7 build/pkg_debian_8 build/pkg_debian_9
@echo Debian: done
build/pkg_ubuntu: build/pkg_ubuntu_14_04 build/pkg_ubuntu_16_04 build/pkg_ubuntu_17_10 build/pkg_ubuntu_18_04
@echo Ubuntu: done
build/pkg_centos: build/pkg_centos_6 build/pkg_centos_7
@echo Centos: done
define build_deb
docker run -v "$(WORKDIR)":/src --rm $1:$2 bash -exc " \
cp -a /src /var/build && \
find /var/build -type d -exec chmod 0755 {} \; && find /var/build -type f -exec chmod 0644 {} \; && \
cd /var/build && (apt-get update -m || apt-get update -m || apt-get update -m) && \
apt-get install -y make dpkg-dev debhelper python-dev python-setuptools && make deb && \
mkdir -p /src/build/out/$1/$2 && cp *.deb /src/build/out/$1/$2"
endef
define build_rpm
docker run -v "$(WORKDIR)":/src --rm $1:$2 bash -exc " \
cp -a /src /var/build && \
find /var/build -type d -exec chmod 0755 {} \; && find /var/build -type f -exec chmod 0644 {} \; && \
cd /var/build && yum install -y tar make rpm-build python2-devel python-setuptools && make rpm && \
mkdir -p /src/build/out/el/$2 && cp *.rpm /src/build/out/el/$2"
endef
build/pkg_debian_7:
$(call build_deb,debian,wheezy)
touch build/pkg_debian_7
build/pkg_debian_8:
$(call build_deb,debian,jessie)
touch build/pkg_debian_8
build/pkg_debian_9:
$(call build_deb,debian,stretch)
touch build/pkg_debian_9
build/pkg_ubuntu_14_04:
$(call build_deb,ubuntu,trusty)
touch build/pkg_ubuntu_14_04
build/pkg_ubuntu_16_04:
$(call build_deb,ubuntu,xenial)
touch build/pkg_ubuntu_16_04
build/pkg_ubuntu_17_10:
$(call build_deb,ubuntu,artful)
touch build/pkg_ubuntu_17_10
build/pkg_ubuntu_18_04:
$(call build_deb,ubuntu,bionic)
touch build/pkg_ubuntu_18_04
build/pkg_centos_6:
$(call build_rpm,centos,6)
touch build/pkg_centos_6
build/pkg_centos_7:
$(call build_rpm,centos,7)
touch build/pkg_centos_7