-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathship
More file actions
executable file
·40 lines (36 loc) · 815 Bytes
/
ship
File metadata and controls
executable file
·40 lines (36 loc) · 815 Bytes
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
#!/bin/sh
set -e -u
dst=submission.tgz
bot=$1
rustlib=$(ldd "$bot" | \
while read soname arrow libfile stuff
do if [ "$soname" = librustrt.so ]
then echo "${libfile%/*}"; break
fi
done)
if [ -z "$rustlib" ]
then echo "Rust libraries not found." >&2; exit 1
fi
set -x
t=`mktemp -d`
git clone . "$t"/src
:> "$t"/PACKAGES
cp README "$t"/README
echo '#!/bin/sh' | tee "$t"/install
tee "$t"/lifter <<EOF
#!/bin/sh
LD_LIBRARY_PATH=\\\$ORIGIN/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
exec "\$0".real
EOF
cp "$bot" "$t"/lifter.real
chmod +x "$t"/install "$t"/lifter "$t"/lifter.real
mkdir "$t"/lib
cp "$rustlib"/librustrt* "$t"/lib/
cp "$rustlib"/libcore-* "$t"/lib/
cp "$rustlib"/libstd-* "$t"/lib/
( cd "$t" && tar zcf - . ) > "$dst"
rm -rf "$t"
set +x
echo
echo "$bot => $dst"