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