-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-youtubedl.sh
executable file
·135 lines (113 loc) · 3.75 KB
/
build-youtubedl.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
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
#!/bin/bash
if [[ -z "$ARCH" ]]; then
export ARCH=arm #x86_64, i686, arm, aarch64
fi
PKGFILE="../required-packages.txt"
YOUTUBEDL="../youtube-dl"
YOUTUBEDLSH="../youtube-dl.sh"
PKGDIR="../ffmpeg-packges-${ARCH}"
PREFIX="/data/data/sng.darajnish.ytube_dl/files/"
rm_obvious () {
rm -rvf data/data/com.termux/files/usr/include/
rm -rvf data/data/com.termux/files/usr/lib/pkgconfig/
rm -rvf data/data/com.termux/files/usr/lib/cmake/
rm -rvf data/data/com.termux/files/usr/lib/glib-2.0
rm -rvf data/data/com.termux/files/usr/bin/
rm -rvf data/data/com.termux/files/usr/share
rm -rvf data/data/com.termux/files/usr/etc/fonts/conf.d/
}
build() {
export TERMUX_ARCH="${ARCH}"
export TERMUX_PREFIX="${PREFIX}/usr"
export TERMUX_ANDROID_HOME="${PREFIX}/home"
_CDIR="$(pwd)"
cd ..
./clean.sh
./build-package.sh librav1e
./build-package.sh ffmpeg
./build-package.sh python
cd "${_CDIR}"
mv -v ../output "${PKGDIR}"
}
extract_clean() {
if [[ ! -f "$PKGFILE" ]]; then
echo "Error: pkgfile.txt not found in the current directory!"
exit 2
fi
if [[ ! -d "$PKGDIR" ]]; then
echo "Error: The packages directory ${PKGDIR} doesn't exist!"
exit 2
fi
if [[ $(ls -l | head -n1) != 'total 0' ]]; then
echo "Error: The directory must be empty!"
exit 2
fi
while read line; do
if [[ $line == 'ffmpeg'* ]]; then
dpkg-deb -xv "${PKGDIR}/${line}_${ARCH}.deb" .
rm -rvf data/data/com.termux/files/usr/include/
rm -rvf data/data/com.termux/files/usr/share/doc/
rm -rvf data/data/com.termux/files/usr/share/man/
rm -rvf data/data/com.termux/files/usr/lib/pkgconfig/
rm -rvf data/data/com.termux/files/usr/share/ffmpeg/examples/
elif [[ $line == 'python'* ]]; then
dpkg-deb -xv "${PKGDIR}/${line}_${ARCH}.deb" .
rm -rvf data/data/com.termux/files/usr/lib/pkgconfig/
rm -rvf data/data/com.termux/files/usr/share/
rm -rvf data/data/com.termux/files/usr/include/
rm -rvf data/data/com.termux/files/usr/bin/2to3*
rm -rvf data/data/com.termux/files/usr/bin/pydoc*
rm -rvf data/data/com.termux/files/usr/bin/python*-config
rm -rvf data/data/com.termux/files/usr/lib/python3.9/unittest
rm -rvf data/data/com.termux/files/usr/lib/python3.9/site-packages/xcbgen/
rm -rvf data/data/com.termux/files/usr/lib/python3.9/ensurepip/
rm -rvf data/data/com.termux/files/usr/lib/python3.9/lib2to3/
rm -rvf data/data/com.termux/files/usr/lib/python3.9/distutils/
rm -rvf data/data/com.termux/files/usr/lib/python3.9/pydoc_data/
rm -rvf data/data/com.termux/files/usr/lib/python3.9/pydoc.py
elif [[ $line == 'ca-certificates'* ]]; then
dpkg-deb -xv "${PKGDIR}/${line}_all.deb" .
rm_obvious
else
dpkg-deb -xv "${PKGDIR}/${line}_${ARCH}.deb" .
rm_obvious
fi
done < "${PKGFILE}"
cp -v /home/builder/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/${ARCH}/libomp.so data/data/com.termux/files/usr/lib/
mkdir -v "data/data/com.termux/files/usr/lib/youtube-dl"
cp -v "${YOUTUBEDL}" "data/data/com.termux/files/usr/lib/youtube-dl"
cp -v "${YOUTUBEDLSH}" "data/data/com.termux/files/usr/bin/youtube-dl"
chmod +x "data/data/com.termux/files/usr/bin/youtube-dl"
}
package() {
#export XZ_OPT=-e9
cd "data/data/com.termux/files"
XZ_OPT=-e9 tar -acvf "../../../../../youtubedl-${ARCH}.tar.xz" *
cd "../../../../"
}
clean() {
rm -rvf *
../clean.sh
}
show_help() {
cat << "EOF"
Usage: build-youtubedl.sh [build | extract | package]
build Execute the build task
extract Execute extraction and cleaning
package Execute the packaging task
clean Cleans off the current directory
EOF
}
if [[ "$1" == "build" ]]; then
build
elif [[ "$1" == "extract" ]]; then
extract_clean
elif [[ "$1" == "package" ]]; then
package
elif [[ "$1" == "clean" ]]; then
clean
elif [[ "$1" == "--help" ]]; then
show_help
else
show_help
fi