]> git.proxmox.com Git - pve-installer.git/blame - Makefile
tests: code-style and error handling fixes for ui2stdio
[pve-installer.git] / Makefile
CommitLineData
aee9344c 1include /usr/share/dpkg/default.mk
6db9b06a 2
9cdfeefc 3PACKAGE = proxmox-installer
59597871
TL
4BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
5
aee9344c 6DEB=$(PACKAGE)_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
0190a299 7DSC=$(PACKAGE)_$(DEB_VERSION).dsc
e70f1b2f 8
9cdfeefc 9CARGO ?= cargo
e70f1b2f
CH
10ifeq ($(BUILD_MODE), release)
11CARGO_BUILD_ARGS += --release
12CARGO_COMPILEDIR := target/release
13else
14CARGO_COMPILEDIR := target/debug
15endif
16
f3521633 17INSTALLER_SOURCES=$(shell git ls-files) country.dat
89a12446 18
aee9344c
TL
19PREFIX = /usr
20BINDIR = $(PREFIX)/bin
21USR_BIN := proxmox-tui-installer
22
23COMPILED_BINS := \
24 $(addprefix $(CARGO_COMPILEDIR)/,$(USR_BIN))
25
f3521633 26all:
f0583fd4 27
59597871
TL
28$(BUILDDIR):
29 rm -rf $@ $@.tmp; mkdir $@.tmp
30 cp -a \
0a48c149 31 .cargo \
59597871
TL
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/ \
2f65a616 46 proxmox-installer-common/ \
59597871 47 spice-vdagent.sh \
9a0d66cb 48 test/ \
59597871
TL
49 unconfigured.sh \
50 xinitrc \
51 $@.tmp
52 cp -a debian $@.tmp/
53 mv $@.tmp $@
54
f0583fd4 55country.dat: country.pl
fc2c6d3e
TL
56 ./country.pl > country.dat.tmp
57 mv country.dat.tmp country.dat
780479c5 58
99f0b523 59deb: $(DEB)
59597871
TL
60$(DEB): $(BUILDDIR)
61 cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
99f0b523 62 lintian $(DEB)
c2f72dd6 63
6ec8d163 64test-$(DEB): $(INSTALLER_SOURCES)
63ce0b1a 65 rsync --exclude='test*.img' --exclude='*.deb' --exclude='build' -a * build
6ec8d163
TL
66 cd build; dpkg-buildpackage -b -us -uc -nc
67 mv $(DEB) test-$(DEB)
68
0190a299
TL
69dsc: $(DSC)
70 $(MAKE) clean
71 $(MAKE) $(DSC)
72 lintian $(DSC)
73
74$(DSC): $(BUILDDIR)
75 cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
76
77sbuild: $(DSC)
78 sbuild $(DSC)
79
0fb71c2c
CH
80.PHONY: prepare-test-env
81prepare-test-env: cd-info.test country.dat test.img
82 rm -rf testdir
83 mkdir -p testdir/var/lib/proxmox-installer/
84 cp -v country.dat testdir/var/lib/proxmox-installer/
85 ./proxmox-low-level-installer -t test.img dump-env
86
9a0d66cb 87.PHONY: test
0fb71c2c 88test: prepare-test-env
9a0d66cb 89 $(MAKE) -C test check
a199276f
CH
90 $(CARGO) test --workspace $(CARGO_BUILD_ARGS)
91
c2f72dd6
TL
92DESTDIR=
93VARLIBDIR=$(DESTDIR)/var/lib/proxmox-installer
94HTMLDIR=$(VARLIBDIR)/html/common
89a12446 95
c2f72dd6 96.PHONY: install
99f0b523 97install: $(INSTALLER_SOURCES) $(CARGO_COMPILEDIR)/proxmox-tui-installer
c2f72dd6 98 $(MAKE) -C banner install
ab97da2c 99 $(MAKE) -C Proxmox install
99f0b523
TL
100 install -D -m 644 interfaces $(DESTDIR)/etc/network/interfaces
101 install -D -m 755 fake-start-stop-daemon $(VARLIBDIR)/fake-start-stop-daemon
c2f72dd6
TL
102 install -D -m 755 policy-disable-rc.d $(VARLIBDIR)/policy-disable-rc.d
103 install -D -m 644 country.dat $(VARLIBDIR)/country.dat
99f0b523
TL
104 install -D -m 755 unconfigured.sh $(DESTDIR)/sbin/unconfigured.sh
105 install -D -m 755 proxinstall $(DESTDIR)/usr/bin/proxinstall
aee9344c 106 install -D -m 755 proxmox-low-level-installer $(DESTDIR)/$(BINDIR)/proxmox-low-level-installer
1458d7a2 107 $(foreach i,$(USR_BIN), install -m755 $(CARGO_COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
99f0b523
TL
108 install -D -m 755 checktime $(DESTDIR)/usr/bin/checktime
109 install -D -m 644 xinitrc $(DESTDIR)/.xinitrc
110 install -D -m 755 spice-vdagent.sh $(DESTDIR)/.spice-vdagent.sh
111 install -D -m 644 Xdefaults $(DESTDIR)/.Xdefaults
89a12446 112
0889f35d
TL
113$(COMPILED_BINS): cargo-build
114.PHONY: cargo-build
115cargo-build:
aee9344c
TL
116 $(CARGO) build --package proxmox-tui-installer --bin proxmox-tui-installer $(CARGO_BUILD_ARGS)
117
c2f72dd6 118%-banner.png: %-banner.svg
9b9ddfce 119 rsvg-convert -o $@ $<
782b4acd 120
c2f72dd6 121.PHONY: upload
e23aeee4
TL
122upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
123upload: $(DEB)
99f0b523 124 tar cf - $(DEB) | ssh -X repoman@repo.proxmox.com -- upload --product pve,pmg,pbs --dist $(UPLOAD_DIST)
89a12446 125
76960140
TL
126%.img:
127 truncate -s 2G $@
89a12446 128
4a96f472
TL
129%.big.img:
130 truncate -s 8G $@
131
c2f72dd6 132.PHONY: prepare-check-env
6ec8d163 133prepare-check-env: test-$(DEB)
92cbd446 134 rm -rf testdir
6ec8d163 135 dpkg -X test-$(DEB) testdir
2630cca4 136 mkdir -p testdir/run/proxmox-installer/
c2f72dd6 137
29f32406
TL
138cd-info.test: PRODUCT ?= pve
139cd-info.test:
413ca90b
TL
140 printf '%s\n' "PRODUCT='$(or $(PRODUCT), pve)'" >$@.tmp
141 printf '%s\n' "PRODUCTLONG='$(or $(PRODUCTLONG), Proxmox VE)'" >>$@.tmp
142 printf '%s\n' "RELEASE='$(or $(RELEASE), 42.1)'" >>$@.tmp
143 printf '%s\n' "ISORELEASE='$(or $(ISORELEASE), 1)'" >>$@.tmp
144 printf '%s\n' "ISONAME='$(or $(ISONAME), proxmox-ve)'" >>$@.tmp
29f32406
TL
145 mv $@.tmp $@
146
c2f72dd6 147check-pve: prepare-check-env test.img
413ca90b 148 rm -f cd-info.test; $(MAKE) cd-info.test
4b4dfa12 149 ./proxmox-low-level-installer dump-env -t test.img
92cbd446 150 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
89a12446 151
4a96f472 152check-pve-multidisks: prepare-check-env test.img test2.img test3.img test4.img test5.big.img
413ca90b 153 rm -f cd-info.test; $(MAKE) cd-info.test
4b4dfa12 154 ./proxmox-low-level-installer dump-env -t test.img,test2.img,test3.img,test4.img,test5.big.img
4a96f472 155 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
76960140 156
0cf4be7d
TL
157check-pve-tui: prepare-check-env test.img
158 rm -f cd-info.test; $(MAKE) cd-info.test
4b4dfa12 159 ./proxmox-low-level-installer dump-env -t test.img
9ed18269 160 testdir/usr/bin/proxmox-tui-installer -t test.img 2>testdir/run/stderr
0cf4be7d 161
4b4dfa12
CH
162check-pve-tui-multidisks: prepare-check-env test.img test2.img test3.img test4.img test5.big.img
163 rm -f cd-info.test; $(MAKE) cd-info.test
164 ./proxmox-low-level-installer dump-env -t test.img,test2.img,test3.img,test4.img,test5.big.img
165 testdir/usr/bin/proxmox-tui-installer -t test.img,test2.img,test3.img,test4.img,test5.big.img
166
7e569bd6 167prepare-check-pmg: prepare-check-env test.img
413ca90b
TL
168 rm -f cd-info.test; $(MAKE) \
169 PRODUCT=pmg \
170 PRODUCTLONG="Proxmox Mail Gateway" \
171 ISONAME='proxmox-mail-gateway' \
172 cd-info.test
4b4dfa12 173 ./proxmox-low-level-installer dump-env -t test.img
7e569bd6
TL
174
175check-pmg: prepare-check-pmg
a8213c0e
DM
176 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
177
7e569bd6 178check-pmg-tui: prepare-check-pmg
9ed18269 179 testdir/usr/bin/proxmox-tui-installer -t test.img 2>testdir/run/stderr
7e569bd6 180
ce76d4c0 181prepare-check-pbs: prepare-check-env test.img
413ca90b
TL
182 rm -f cd-info.test; $(MAKE) \
183 PRODUCT='pbs' \
184 PRODUCTLONG='Proxmox Backup Server' \
185 ISONAME='proxmox-backup-server' \
186 cd-info.test
4b4dfa12 187 ./proxmox-low-level-installer dump-env -t test.img
ce76d4c0
TL
188
189check-pbs: prepare-check-pbs
53748662
OB
190 G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
191
ce76d4c0 192check-pbs-tui: prepare-check-pbs
9ed18269 193 testdir/usr/bin/proxmox-tui-installer -t test.img 2>testdir/run/stderr
53748662 194
89a12446
DM
195.phony: clean
196clean:
5a947984 197 rm -rf target build $(PACKAGE)-[0-9]* testdir
2d5382e8 198 rm -f $(PACKAGE)*.tar* *.deb packages packages.tmp *.build *.dsc *.buildinfo *.changes
5a947984 199 rm -f test*.img pve-final.pkglist country.dat final.pkglist cd-info.test
b1e23923 200 find . -name '*~' -exec rm {} ';'