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