-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble_runtime_libraries.sh
executable file
·75 lines (54 loc) · 1.21 KB
/
assemble_runtime_libraries.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
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Builds an tar.gz file that can be send and extracted on a target machine
die() {
echo "Error: $1"
exit 1
}
make_resources() {
mkdir -p $TAR_DIR
}
unmake_resources() {
rm -rf $TAR_DIR
}
gather_libraries() {
local lib_dir=$1
cd $lib_dir
cp -r * $TAR_DIR
rm -rf $TAR_DIR/*.la
rm -rf $TAR_DIR/*.a
rm -rf $TAR_DIR/*.py
cd - > /dev/null
}
pack_libraries() {
local out=$1
cd $TAR_DIR
tar -czf ${OLD_DIR}/${out} *
cd - > /dev/null
}
[ ! -f ./variables ] && die "Expected an 'variable' file"
OLD_DIR=$(pwd)
OUTPUT=libraries.tgz
TAR_DIR=/tmp/.tarred-$RANDOM
make_resources
trap unmake_resources EXIT
. ./variables
cd $PREFIX
[ ! -d "$TARGET_ARCH" ] && die "Could not find built image '$TARGET_ARCH' in '$PREFIX'"
cd $TARGET_ARCH
echo "Finding libraries directory..."
LIBDIR=""
if [ -d "lib64" ]; then
LIBDIR="lib64"
elif [ -d "lib" ]; then
LIBDIR="lib"
else
die "No libraries directory detected"
fi
echo "Found libraries directory '$LIBDIR'."
echo "Copying libraries..."
gather_libraries "$LIBDIR"
echo "Copied libraries."
echo "Packing libraries into '$OUTPUT'..."
pack_libraries "$OUTPUT"
echo "Packed libraries into '$OUTPUT'."
cd $OLD_DIR