]> git.proxmox.com Git - pve-installer.git/blob - Makefile
buildsys: use better defined clean target
[pve-installer.git] / Makefile
1 include /usr/share/dpkg/default.mk
2
3 PACKAGE = proxmox-installer
4 BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
5
6 DEB=$(PACKAGE)_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
7
8 CARGO ?= cargo
9 ifeq ($(BUILD_MODE), release)
10 CARGO_BUILD_ARGS += --release
11 CARGO_COMPILEDIR := target/release
12 else
13 CARGO_COMPILEDIR := target/debug
14 endif
15
16 INSTALLER_SOURCES=$(shell git ls-files) country.dat
17
18 PREFIX = /usr
19 BINDIR = $(PREFIX)/bin
20 USR_BIN := proxmox-tui-installer
21
22 COMPILED_BINS := \
23 $(addprefix $(CARGO_COMPILEDIR)/,$(USR_BIN))
24
25 all:
26
27 $(BUILDDIR):
28 rm -rf $@ $@.tmp; mkdir $@.tmp
29 cp -a \
30 Cargo.toml \
31 Makefile \
32 Proxmox/ \
33 Xdefaults \
34 banner/ \
35 checktime \
36 country.pl \
37 fake-start-stop-daemon \
38 html/ \
39 interfaces \
40 policy-disable-rc.d \
41 proxinstall \
42 proxmox-low-level-installer \
43 proxmox-tui-installer/ \
44 spice-vdagent.sh \
45 unconfigured.sh \
46 xinitrc \
47 $@.tmp
48 cp -a debian $@.tmp/
49 mv $@.tmp $@
50
51 country.dat: country.pl
52 ./country.pl > country.dat.tmp
53 mv country.dat.tmp country.dat
54
55 deb: $(DEB)
56 $(DEB): $(BUILDDIR)
57 cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
58 lintian $(DEB)
59
60 test-$(DEB): $(INSTALLER_SOURCES)
61 rsync --exclude='test*.img' -a * build
62 cd build; dpkg-buildpackage -b -us -uc -nc
63 mv $(DEB) test-$(DEB)
64
65 DESTDIR=
66 VARLIBDIR=$(DESTDIR)/var/lib/proxmox-installer
67 HTMLDIR=$(VARLIBDIR)/html/common
68
69 .PHONY: install
70 install: $(INSTALLER_SOURCES) $(CARGO_COMPILEDIR)/proxmox-tui-installer
71 $(MAKE) -C banner install
72 $(MAKE) -C Proxmox install
73 install -D -m 644 interfaces $(DESTDIR)/etc/network/interfaces
74 install -D -m 755 fake-start-stop-daemon $(VARLIBDIR)/fake-start-stop-daemon
75 install -D -m 755 policy-disable-rc.d $(VARLIBDIR)/policy-disable-rc.d
76 install -D -m 644 country.dat $(VARLIBDIR)/country.dat
77 install -D -m 755 unconfigured.sh $(DESTDIR)/sbin/unconfigured.sh
78 install -D -m 755 proxinstall $(DESTDIR)/usr/bin/proxinstall
79 install -D -m 755 proxmox-low-level-installer $(DESTDIR)/$(BINDIR)/proxmox-low-level-installer
80 $(foreach i,$(USR_BIN), install -m755 $(CARGO_COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/)
81 install -D -m 755 checktime $(DESTDIR)/usr/bin/checktime
82 install -D -m 644 xinitrc $(DESTDIR)/.xinitrc
83 install -D -m 755 spice-vdagent.sh $(DESTDIR)/.spice-vdagent.sh
84 install -D -m 644 Xdefaults $(DESTDIR)/.Xdefaults
85
86 $(COMPILED_BINS):
87 $(CARGO) build --package proxmox-tui-installer --bin proxmox-tui-installer $(CARGO_BUILD_ARGS)
88
89 %-banner.png: %-banner.svg
90 rsvg-convert -o $@ $<
91
92 .PHONY: upload
93 upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
94 upload: $(DEB)
95 tar cf - $(DEB) | ssh -X repoman@repo.proxmox.com -- upload --product pve,pmg,pbs --dist $(UPLOAD_DIST)
96
97 %.img:
98 truncate -s 2G $@
99
100 %.big.img:
101 truncate -s 8G $@
102
103 .PHONY: prepare-check-env
104 prepare-check-env: test-$(DEB)
105 rm -rf testdir
106 dpkg -X test-$(DEB) testdir
107
108 cd-info.test: PRODUCT ?= pve
109 cd-info.test:
110 printf '%s\n' "PRODUCT='$(or $(PRODUCT), pve)'" >$@.tmp
111 printf '%s\n' "PRODUCTLONG='$(or $(PRODUCTLONG), Proxmox VE)'" >>$@.tmp
112 printf '%s\n' "RELEASE='$(or $(RELEASE), 42.1)'" >>$@.tmp
113 printf '%s\n' "ISORELEASE='$(or $(ISORELEASE), 1)'" >>$@.tmp
114 printf '%s\n' "ISONAME='$(or $(ISONAME), proxmox-ve)'" >>$@.tmp
115 mv $@.tmp $@
116
117 check-pve: prepare-check-env test.img
118 rm -f cd-info.test; $(MAKE) cd-info.test
119 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
120
121 check-pve-multidisks: prepare-check-env test.img test2.img test3.img test4.img test5.big.img
122 rm -f cd-info.test; $(MAKE) cd-info.test
123 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img,test2.img,test3.img,test4.img,test5.big.img
124
125 check-pve-tui: prepare-check-env test.img
126 rm -f cd-info.test; $(MAKE) cd-info.test
127 ./proxmox-low-level-installer dump-env -t
128 testdir/usr/bin/proxmox-tui-installer -t test.img
129
130 check-pmg: prepare-check-env test.img
131 rm -f cd-info.test; $(MAKE) \
132 PRODUCT=pmg \
133 PRODUCTLONG="Proxmox Mail Gateway" \
134 ISONAME='proxmox-mail-gateway' \
135 cd-info.test
136 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
137
138 check-pbs: prepare-check-env test.img
139 rm -f cd-info.test; $(MAKE) \
140 PRODUCT='pbs' \
141 PRODUCTLONG='Proxmox Backup Server' \
142 ISONAME='proxmox-backup-server' \
143 cd-info.test
144 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
145
146
147 .phony: clean
148 clean:
149 rm -rf target build $(PACKAGE)-[0-9]*
150 rm -f $(PACKAGE)*.tar* *.deb packages packages.tmp *.build *.dsc *.buildinfo *.changes
151 rm -f testdir test*.img pve-final.pkglist country.dat final.pkglist cd-info.test
152 find . -name '*~' -exec rm {} ';'