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