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