-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_osv_hardcoded.sh
executable file
·65 lines (50 loc) · 1.73 KB
/
build_osv_hardcoded.sh
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
#!/bin/sh
CWD="$(pwd)"
[ -d "osv" ] || git clone https://github.com/cloudius-systems/osv.git
cd osv
sed -i 's/-nostartfiles//g' Makefile
sed -i 's/-nodefaultlibs//g' Makefile
sed -i '1930s/\/usr//' Makefile
git submodule update --init --recursive
cd apps
[ -d "rusty-nail" ] || git clone https://github.com/olivercalder/rusty-nail.git
cd rusty-nail
cat > Makefile <<EOF
.PHONY: module
module: target/release/rusty-nail
echo '/rusty-nail: \$\${MODULE_DIR}/target/release/rusty-nail' > usr.manifest
echo '/mount: /usr/bin/mount' >> usr.manifest
target/release/rusty-nail: src/main.rs src/png.rs
cargo --version && cargo build --release || echo "Please install Rust"
clean:
-cargo clean
rm -f usr.manifest
EOF
cat > module.py <<EOF
from osv.modules import api
default = api.run(cmdline="mount -t virtiofs mydir /mnt; rusty-nail /mnt/image.png /mnt/thumbnail.png")
EOF
grep 'rustc_version_runtime' Cargo.toml || echo 'rustc_version_runtime = "0.1.*"' >> Cargo.toml
cd "${CWD}/osv"
./scripts/build image=rusty-nail
cd "$CWD"
command -v virtiofsd > /dev/null
if [ $? -ne 0 ]; then
# Ofted, virtiofsd
mkdir -p "$HOME/.local/bin"
if [ -f "/usr/libexec/virtiofsd" ]; then # location on Fedora
ln -s "/usr/libexec/virtiofsd" "$HOME/.local/bin/"
elif [ -f "/usr/lib/qemu/virtiofsd" ]; then # location on Ubuntu
ln -s "/usr/lib/qemu/virtiofsd" "$HOME/.local/bin/"
fi
# Add $HOME/.local/bin to path if it is not yet in the path
case ":${PATH}:" in
*:"${HOME}/.local/bin":*)
;;
*)
export PATH="${HOME}/.local/bin:${PATH}"
;;
esac
# If osv/scripts/run.py is run in a different terminal, may need to export
# path to include $HOME/.local/bin again manually
fi