forked from nyanmisaka/jellyfin-ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-build.sh
executable file
·136 lines (125 loc) · 6.07 KB
/
docker-build.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
135
136
#!/bin/bash
# Builds the DEB inside the Docker container
set -o errexit
set -o xtrace
# Prepare the cross-toolchain
prepare_crossbuild_env_armhf() {
# Prepare the Ubuntu-specific cross-build requirements
if [[ $( lsb_release -i -s ) == "Ubuntu" ]]; then
CODENAME="$( lsb_release -c -s )"
# Remove the default sources.list
rm /etc/apt/sources.list
# Add arch-specific list files
cat <<EOF > /etc/apt/sources.list.d/amd64.list
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME} main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-updates main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-backports main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-security main restricted universe multiverse
EOF
cat <<EOF > /etc/apt/sources.list.d/armhf.list
deb [arch=armhf] http://ports.ubuntu.com/ ${CODENAME} main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${CODENAME}-updates main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${CODENAME}-backports main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ ${CODENAME}-security main restricted universe multiverse
EOF
fi
# Add armhf architecture
dpkg --add-architecture armhf
# Update and install cross-gcc-dev
apt-get update
yes | apt-get install -y cross-gcc-dev
# Generate gcc cross source
TARGET_LIST="armhf" cross-gcc-gensource ${GCC_VER}
# Install dependencies
pushd cross-gcc-packages-amd64/cross-gcc-${GCC_VER}-armhf
ln -fs /usr/share/zoneinfo/America/Toronto /etc/localtime
yes | apt-get install -y -o APT::Immediate-Configure=0 gcc-${GCC_VER}-source libstdc++6-armhf-cross binutils-arm-linux-gnueabihf bison flex libtool gdb sharutils netbase libmpc-dev libmpfr-dev libgmp-dev systemtap-sdt-dev autogen expect chrpath zlib1g-dev zip libc6-dev:armhf linux-libc-dev:armhf libgcc1:armhf libcurl4-openssl-dev:armhf libfontconfig1-dev:armhf libfreetype6-dev:armhf liblttng-ust0:armhf libstdc++6:armhf
popd
# Fetch RasPi headers to build MMAL support
pushd ${SOURCE_DIR}
git clone --depth=1 https://github.com/raspberrypi/firmware mmalheaders
git clone --depth=1 https://github.com/raspberrypi/userland piuserland
cp -a mmalheaders/opt/vc/include/* /usr/include/
cp -a mmalheaders/opt/vc/lib/* /usr/lib/
cp -a piuserland/interface/* /usr/include/
popd
}
prepare_crossbuild_env_arm64() {
# Prepare the Ubuntu-specific cross-build requirements
if [[ $( lsb_release -i -s ) == "Ubuntu" ]]; then
CODENAME="$( lsb_release -c -s )"
# Remove the default sources.list
rm /etc/apt/sources.list
# Add arch-specific list files
cat <<EOF > /etc/apt/sources.list.d/amd64.list
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME} main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-updates main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-backports main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${CODENAME}-security main restricted universe multiverse
EOF
cat <<EOF > /etc/apt/sources.list.d/arm64.list
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME} main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-backports main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-security main restricted universe multiverse
EOF
fi
# Add armhf architecture
dpkg --add-architecture arm64
# Update and install cross-gcc-dev
apt-get update
yes | apt-get install -y cross-gcc-dev
# Generate gcc cross source
TARGET_LIST="arm64" cross-gcc-gensource ${GCC_VER}
# Install dependencies
pushd cross-gcc-packages-amd64/cross-gcc-${GCC_VER}-arm64
ln -fs /usr/share/zoneinfo/America/Toronto /etc/localtime
yes | apt-get install -y -o APT::Immediate-Configure=0 gcc-${GCC_VER}-source libstdc++6-arm64-cross binutils-aarch64-linux-gnu bison flex libtool gdb sharutils netbase libmpc-dev libmpfr-dev libgmp-dev systemtap-sdt-dev autogen expect chrpath zlib1g-dev zip libc6-dev:arm64 linux-libc-dev:arm64 libgcc1:arm64 libcurl4-openssl-dev:arm64 libfontconfig1-dev:arm64 libfreetype6-dev:arm64 liblttng-ust0:arm64 libstdc++6:arm64
popd
}
# Set the architecture-specific options
case ${ARCH} in
'amd64')
CONFIG_SITE=""
DEP_ARCH_OPT=""
BUILD_ARCH_OPT=""
;;
'armhf')
prepare_crossbuild_env_armhf
ln -s /usr/bin/arm-linux-gnueabihf-gcc-6 /usr/bin/arm-linux-gnueabihf-gcc
CONFIG_SITE="/etc/dpkg-cross/cross-config.${ARCH}"
DEP_ARCH_OPT="--host-arch armhf"
BUILD_ARCH_OPT="-aarmhf"
;;
'arm64')
prepare_crossbuild_env_arm64
#ln -s /usr/bin/arm-linux-gnueabihf-gcc-6 /usr/bin/arm-linux-gnueabihf-gcc
CONFIG_SITE="/etc/dpkg-cross/cross-config.${ARCH}"
DEP_ARCH_OPT="--host-arch arm64"
BUILD_ARCH_OPT="-aarm64"
;;
esac
# Download and install the nvidia headers from deb-multimedia
git clone --depth=1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
pushd nv-codec-headers
make
make install
popd
# Download and setup AMD AMF headers from AMD official github repo
# https://www.ffmpeg.org/general.html#AMD-AMF_002fVCE
apt-get update
yes | apt-get install subversion
svn checkout https://github.com/GPUOpen-LibrariesAndSDKs/AMF/trunk/amf/public/include
pushd include
mkdir -p /usr/include/AMF && mv * /usr/include/AMF
popd
# Move to source directory
pushd ${SOURCE_DIR}
# Install dependencies and build the deb
yes | mk-build-deps -i ${DEP_ARCH_OPT}
dpkg-buildpackage -b -rfakeroot -us -uc ${BUILD_ARCH_OPT}
popd
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
mv /jellyfin-ffmpeg_* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}