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