-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg_full_amd_ocheb
More file actions
221 lines (194 loc) · 7.35 KB
/
ffmpeg_full_amd_ocheb
File metadata and controls
221 lines (194 loc) · 7.35 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
## Arch linux packages system is required, overlay filesystem support is required too.
## Author Andrew S License for this script itself is GPL
## License for result depends on components, some of them are nonfree
## https://gitlab.com/quarkscript/arch_linux_scripts/tree/master/pkgs_builds_scripts
## https://github.com/quarkscript/Build_from_source
echo "
This script is try to build ffmpeg-full-amd in overlayed chrooted environment,
as a result all downloaded and builded components (except already installed on system) will be
included to final package. It is better to install specific drivers and software before run,
like gcc make and so on. This script utilize arch linux packages system, and it uses
3rd party PKGBUILDs from AUR for required components and for ffmpeg-full-amd...
Final license of rezulted package is complex and nonfree.
Build process is not fully automatic, your presence is required (for a sudo privileges)
"
sleep 15
who=$(whoami)
if [ "$who" == "root" ]; then echo "
to run this script you must be a regular user who can run sudo, but not a root
" ; exit 1 ; fi
if !(cat /proc/filesystems | grep -q overlay ); then
echo !!! superuser password is required for modprobe overlay
sudo modprobe overlay
fi
if !(cat /proc/filesystems | grep -q overlay ); then
echo "
Seems current linux kernel doesn't support overlay filesystem.
overlayfs is required... current build impossible without it
"; exit 1
fi
mkdir upper work processdir
mkdir upper/build
chown $who upper/build
if [ -f get_ffmpeg-full_arch ]; then
cp get_ffmpeg-full_arch upper/build/get_ffmpeg-full_arch
fi
if [ -f sfslib ]; then
cp sfslib upper/build/sfslib
fi
cat<<EOf>upper/build/runscript
#!/bin/bash
echo "$who ALL=(ALL) NOPASSWD: ALL
" >>/etc/sudoers
if [ ! -f get_ffmpeg-full_arch ]; then
wget https://gitlab.com/quarkscript/arch_linux_scripts/raw/master/pkgs_builds_scripts/get_ffmpeg-full_arch
fi
if [ ! -f get_ffmpeg-full_arch ]; then
wget https://raw.githubusercontent.com/quarkscript/Build_from_source/master/get_ffmpeg-full_arch
fi
if [ ! -f get_ffmpeg-full_arch ]; then
echo "There is some problem of getting required get_ffmpeg-full_arch
you can download it manually from mirrors:
https://gitlab.com/quarkscript/arch_linux_scripts/tree/master/pkgs_builds_scripts
https://github.com/quarkscript/Build_from_source
and palce with current script, then rerun current script.
Build process interrupted"
exit 1
fi
## extra optimizations off
cat get_ffmpeg-full_arch | sed 's/#cat sfslib/cat sfslib/g' | sed 's/#echo /echo /g' | sed "s@ffmpeg-full@ffmpeg-amd-full-git@g" >get_ffmpeg-full_arch.
## extra optimizations on
#cat get_ffmpeg-full_arch | sed 's/#cat sfslib/cat sfslib/g' | sed "s@ffmpeg-full@ffmpeg-amd-full-git@g" >get_ffmpeg-full_arch.
## get sfslib
if [ ! -f sfslib ]; then
## get required Simple_func_scripts from github source
wget https://raw.githubusercontent.com/quarkscript/Simple_func_scripts/master/sfslib
fi
if [ ! -f sfslib ]; then
## get required Simple_func_scripts from gitlab source
wget https://gitlab.com/quarkscript/arch_linux_scripts/raw/master/pkgs_builds_scripts/sfslib
fi
chown $who sfslib
chmod +x sfslib
if [ ! -x sfslib ]; then
echo '
There is some problem of getting required sfslib
you may download it manually from one of sourses:
https://github.com/quarkscript/Build_from_source
https://gitlab.com/quarkscript/arch_linux_scripts/tree/master/pkgs_builds_scripts
Build process interrupted'
exit 1
fi
## fix tensorflow include dir
./sfslib adnlalwp 'get_ffmpeg-full_arch.' 'mod_condition_0; then' "./sfslib adnlalwp 'ffmpeg-amd-full-git/PKGBUILD' 'Running ffmpeg configure script...' '_cflags+=-I/usr/include/tensorflow'"
./sfslib adnlalwp 'get_ffmpeg-full_arch.' 'mod_condition_0; then' '## crutch to fix tensorflow include dir'
chown $who get_ffmpeg-full_arch.
chmod +x get_ffmpeg-full_arch.
sudo -u $who ./get_ffmpeg-full_arch.
EOf
chmod +x upper/build/runscript
echo !!! superuser password is required for mount overlay folder and chroot it
sudo mount -t overlay overlay -o,lowerdir=/,upperdir=upper,workdir=work processdir
## additional check of mounted overlay
## continue without overlay may harm your system
if ! $(mount | grep overlay | grep processdir -q); then
echo '
Something wrong with mounting overlayfs
Process interrupted...'
exit 1
fi
sudo mount --bind /proc processdir/proc
sudo mount --bind /dev processdir/dev
sudo mount --bind /sys processdir/sys
sudo mount --bind /tmp processdir/tmp
## run
sudo chroot processdir /bin/bash <<EEOOF
cd /build
./runscript |& tee build.log
chown $who build.log
EEOOF
echo !!! superuser password is required for unmount overlay folder
sudo umount processdir/tmp
sudo umount processdir/proc
sudo umount processdir/dev
sudo umount processdir/sys
sudo umount processdir
# if $(cat upper/build/build.log | grep -v --regexp="failed retrieving file" | grep -iq --regexp="error: "); then
# echo "
# It seems something goes wrong... Build fail
# Check upper/build/build.log
# "
# exit 1
# fi
cp -f upper/build/build.log build.log
echo clear build
sudo rm -fr processdir work upper/build upper/tmp upper/root upper/var upper/home upper/etc/sudoers
echo search and remove character files
for ii in $(find upper/ ! -type d); do
if [ -c "$ii" ]; then sudo rm -f $ii ; fi
done
tar -czvf source.tar.gz upper
## remove upper dir
sudo rm -fr upper
## set final pkg params, change it as you want
pkgname=ffmpeg-full-amd-ocheb
installdir='/opt'
prefix='amd_'
## do not change next variables
pkgdir='$pkgdir'
i='$i'
j='$j'
set '$@'
## gen PKGBUILD
cat<<EOf>PKGBUILD
pkgname=$pkgname
pkgver=$(date +%Y.%m.%e | sed 's/ //g')
pkgrel=1
pkgdesc='ffmpeg-full no-intel no-nvidia overlayed chrooted env. build. Main PKGBUILD taken from https://aur.archlinux.org/packages/ffmpeg-amd-full-git'
arch=('i686' 'x86_64')
url='https://www.ffmpeg.org/'
license=(nonfree)
conflicts=($pkgname)
source=(source.tar.gz)
sha512sums=(SKIP)
package() {
mkdir -p $pkgdir$installdir/$pkgname
cp -r upper/* $pkgdir$installdir/$pkgname
echo "binpath $installdir/$pkgname/usr/local/sbin:$installdir/$pkgname/usr/local/bin:$installdir/$pkgname/usr/bin">path.txt
echo "libpath $installdir/$pkgname/usr/lib:$installdir/$pkgname/usr/local/lib">>path.txt
install -Dm 644 path.txt $pkgdir$installdir/$pkgname/path.txt
mkdir -p $pkgdir/usr/bin
for j in ffmpeg ffplay ffprobe; do
echo '#!/bin/bash
export PATH=''$''(cat $installdir/$pkgname/path.txt | grep binpath | sed "s/binpath //g"):''$''PATH
export LD_LIBRARY_PATH=''$''(cat $installdir/$pkgname/path.txt | grep libpath | sed "s/libpath //g"):''$''LD_LIBRARY_PATH
ffmpeg_string="'$j' "
ttt=$''#
for ((i=1; i<=$''ttt; i+=1)); do
ffmpeg_string+='"'"'"$''{'"'"'$i'"'"'}"'" '"'
done
eval $''ffmpeg_string
'>$prefix''$j
install -m755 $prefix''$j $pkgdir/usr/bin/$prefix''$j
done
}
EOf
makepkg
rm -fr pkg src
if $(cat build.log | grep -v --regexp="failed retrieving file" | grep -iq --regexp="error: "); then
echo "
It seems some errors happens. Package may be incomplete. Check build.log for 'error: '"
fi
if (ls | grep $pkgname | grep -q pkg.tar.xz); then
echo "
the package is
'$(ls | grep $pkgname | grep pkg.tar.xz)'
do not forget to install it
This may work on system where it was built, other systems are questionable
new commands are: $prefix""ffmpeg , $prefix""ffplay , $prefix""ffprobe
"
else echo "
Something goes wrong... final package was not built
"
fi