-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (131 loc) · 5.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.DEFAULT_GOAL := build
PREFIX ?= /usr
BINDIR ?= ${PREFIX}/bin
SBINDIR ?= ${PREFIX}/sbin
SHAREDIR ?= ${PREFIX}/share/podman-pilot
FLAKEDIR ?= ${PREFIX}/share/flakes
TEMPLATEDIR ?= /etc/flakes
PKG_NAME ?= flake-pilot
PILOTS_SRC ?= pilots/src
ARCH = $(shell uname -m)
.PHONY: package
package: clean vendor sourcetar
rm -rf package/build
mkdir -p package/build
gzip package/${PKG_NAME}.tar
mv package/${PKG_NAME}.tar.gz package/build
cp package/${PKG_NAME}.spec package/build
cp package/cargo_config package/build
cp package/gcc_fix_static.sh package/build
cp package/${PKG_NAME}-rpmlintrc package/build
# update changelog using reference file
helper/update_changelog.py --since package/${PKG_NAME}.changes.ref > \
package/build/${PKG_NAME}.changes
helper/update_changelog.py --file package/${PKG_NAME}.changes.ref >> \
package/build/${PKG_NAME}.changes
@echo "Find package data at package/build"
vendor:
cargo vendor
sourcetar:
rm -rf package/${PKG_NAME}
mkdir package/${PKG_NAME}
cp Makefile package/${PKG_NAME}
cp -a pilots package/${PKG_NAME}
cp -a flake-ctl package/${PKG_NAME}
cp -a flake-studio package/${PKG_NAME}/
cp -a doc package/${PKG_NAME}
cp -a utils package/${PKG_NAME}
cp -a vendor package/${PKG_NAME}
cp -a common package/${PKG_NAME}
cp Cargo.toml package/${PKG_NAME}
# Delete any target directories that may be present
find package/${PKG_NAME} -type d -wholename "*/target" -prune -exec rm -rf {} \;
# Delete large chunk windows and wasm dependencies
# Use filtered vendoring in the future
# https://github.com/rust-lang/cargo/issues/7058
find package/${PKG_NAME} -type d -wholename "*/vendor/winapi*" -prune -exec \
rm -rf {}/src \; -exec mkdir -p {}/src \; -exec touch {}/src/lib.rs \; -exec rm -rf {}/lib \;
find package/${PKG_NAME} -type d -wholename "*/vendor/windows*" -prune -exec \
rm -rf {}/src \; -exec mkdir -p {}/src \; -exec touch {}/src/lib.rs \; -exec rm -rf {}/lib \;
rm -rf package/${PKG_NAME}/vendor/web-sys/src/*
rm -rf package/${PKG_NAME}/vendor/web-sys/webidls
touch package/${PKG_NAME}/vendor/web-sys/src/lib.rs
tar -C package -cf package/${PKG_NAME}.tar ${PKG_NAME}
rm -rf package/${PKG_NAME}
.PHONY:build
build: man
cargo build -v --release
cd ${PILOTS_SRC}/firecracker-pilot/guestvm-tools/sci && RUSTFLAGS='-C target-feature=+crt-static' cargo build -v --release --target $(ARCH)-unknown-linux-gnu
clean:
cd pilots && cargo -v clean
cd flake-ctl && cargo -v clean
cd ${PILOTS_SRC}/firecracker-pilot/firecracker-service/service && cargo -v clean
cd ${PILOTS_SRC}/firecracker-pilot/guestvm-tools/sci && cargo -v clean
rm -rf pilots/vendor
rm -rf flake-ctl/vendor
${MAKE} -C doc clean
$(shell find . -name Cargo.lock | xargs rm -f)
$(shell find . -type d -name vendor | xargs rm -rf)
test:
cargo nextest run
install:
install -d -m 755 $(DESTDIR)$(BINDIR)
install -d -m 755 $(DESTDIR)$(SBINDIR)
install -d -m 755 $(DESTDIR)$(SHAREDIR)
install -d -m 755 $(DESTDIR)$(TEMPLATEDIR)
install -d -m 755 $(DESTDIR)$(FLAKEDIR)
install -d -m 755 ${DESTDIR}/usr/share/man/man8
install -m 755 target/release/oci-pilot \
$(DESTDIR)$(BINDIR)/podman-pilot
install -m 755 target/release/firecracker-pilot \
$(DESTDIR)$(BINDIR)/firecracker-pilot
install -m 755 target/release/firecracker-service \
$(DESTDIR)$(BINDIR)/firecracker-service
install -m 755 target/$(ARCH)-unknown-linux-gnu/release/sci \
$(DESTDIR)$(SBINDIR)/sci
install -m 755 target/release/flake-ctl \
$(DESTDIR)$(BINDIR)/flake-ctl
install -m 755 target/release/flake-studio \
$(DESTDIR)$(BINDIR)/flake-studio
install -m 755 target/release/flake-ctl-podman \
$(DESTDIR)$(BINDIR)/flake-ctl-podman
install -m 755 target/release/flake-ctl-firecracker \
$(DESTDIR)$(BINDIR)/flake-ctl-firecracker
install -m 755 flake-ctl/flake-ctl-podman/debbuild/oci-deb \
$(DESTDIR)$(BINDIR)/oci-deb
install -m 644 flake-ctl/flake-ctl-podman/debbuild/container.spec.in \
$(DESTDIR)$(SHAREDIR)/container.spec.in
install -m 644 ${PILOTS_SRC}/firecracker-pilot/template/firecracker.json \
$(DESTDIR)$(TEMPLATEDIR)/firecracker.json
install -m 644 doc/*.8 ${DESTDIR}/usr/share/man/man8
install -m 755 utils/* $(DESTDIR)$(SBINDIR)
install -m 644 flake-ctl/flake-ctl-firecracker/templates/firecracker.yaml \
$(DESTDIR)$(TEMPLATEDIR)
install -m 644 flake-ctl/flake-ctl-podman/templates/podman.yaml \
$(DESTDIR)$(TEMPLATEDIR)
# dpkg
install -d -m 755 $(DESTDIR)$(FLAKEDIR)/package/dpkg
install -m 644 flake-ctl/flake-ctl-build-dpkg/templates/* $(DESTDIR)$(FLAKEDIR)/package/dpkg
install -m 755 target/release/flake-ctl-build-dpkg $(DESTDIR)$(BINDIR)/flake-ctl-build-dpkg
# rpmbuild
install -d -m 755 $(DESTDIR)$(FLAKEDIR)/package/rpmbuild
install -m 644 flake-ctl/flake-ctl-build-rpmbuild/templates/* $(DESTDIR)$(FLAKEDIR)/package/rpmbuild
install -m 755 target/release/flake-ctl-build-rpmbuild $(DESTDIR)$(BINDIR)/flake-ctl-build-rpmbuild
uninstall:
rm -f $(DESTDIR)$(BINDIR)/flake-ctl
rm -f $(DESTDIR)$(BINDIR)/flake-ctl-podman
rm -f $(DESTDIR)$(BINDIR)/flake-ctl-firecracker
rm -f $(DESTDIR)$(BINDIR)/flake-ctl-build
rm -f $(DESTDIR)$(BINDIR)/flake-ctl-build-dpkg
rm -f $(DESTDIR)$(BINDIR)/flake-ctl-build-rpmbuild
rm -f $(DESTDIR)$(BINDIR)/flake-studio
rm -f $(DESTDIR)$(BINDIR)/podman-pilot
rm -f $(DESTDIR)$(BINDIR)/firecracker-pilot
rm -f $(DESTDIR)$(BINDIR)/firecracker-service
rm -rf $(DESTDIR)$(FLAKEDIR) $(DESTDIR)$(SHAREDIR) $(DESTDIR)$(TEMPLATEDIR)
man:
${MAKE} -C doc man
cargo:
for path in $(shell find . -name Cargo.toml ! -path "*/vendor/*");do \
pushd `dirname $$path`; cargo build || exit 1; popd;\
done