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