-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
prefetch-lib.sh
64 lines (57 loc) · 1.65 KB
/
prefetch-lib.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
#!/bin/bash
VERSION="$1"
BUILD_INFO="$2"
ARCH=$3
mkdir -p .tmp/lib;
if [ -d ".cache/$VERSION-$ARCH/deb" ]; then
echo -e "\033[0;32mPrefetch dependencies $BUILD_INFO from cache \033[0m"
cp .cache/$VERSION-$ARCH/deb/* .tmp/lib
exit 0
fi
echo "Prefetch dependencies $BUILD_INFO"
mkdir -p .tmp/lib-unary;
cp "$BUILD_INFO" .tmp/lib-unary
cd .tmp/lib-unary
getDependencies() {
echo $(awk '
/^Installed-Build-Depends:/ || /^ / && deps {
sub(/^[^ ]+: /, "")
deps = 1
dep_str = dep_str ", " $0
next
}
{ deps=0 }
END {
split(dep_str, dep_array, /[,|] */)
for (d in dep_array) {
dep = dep_array[d]
gsub(/[^a-z0-9_.-].*$/, "", dep)
if (dep && !seen[dep]++) print dep
}
}' $1) | sort | uniq
echo "libpciaccess0" #vainfo
echo "libstdc++" #jellyfin
echo "libgnutls30" #jellyfin-ffmpeg
}
for var in $(getDependencies $BUILD_INFO); do
apt-get download "$var" -o APT::Architecture=$ARCH
done
cd ../..
mkdir -p .cache/$VERSION-$ARCH/deb
cp .tmp/lib-unary/* .cache/$VERSION-$ARCH/deb
# Remove some debs that doesnt contain libs
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*cross*
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*dbg*
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*doc*
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*dev*
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*pic*
rm -rf .cache/$VERSION-$ARCH/deb/libstdc*eabi*
rm -rf .cache/$VERSION-$ARCH/deb/perl*
rm -rf .cache/$VERSION-$ARCH/deb/python*
rm -rf .cache/$VERSION-$ARCH/deb/man-db*
rm -rf .cache/$VERSION-$ARCH/deb/gcc-*
rm -rf .cache/$VERSION-$ARCH/deb/cpp-*
cp .cache/$VERSION-$ARCH/deb/* .tmp/lib
rm -rf .tmp/lib-unary
echo "Finished prefetch dependencies $VERSION"
exit 0