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