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