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