-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·719 lines (651 loc) · 23.3 KB
/
install.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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
#!/bin/bash
#set -v
set -e
GST=${GST:-"false"}
SUDO=""
if [ -f "/usr/bin/sudo" ]; then
SUDO="/usr/bin/sudo"
fi
PKGMGR=""
if [ -f "/usr/bin/dnf" ]; then
PKGMGR="/usr/bin/dnf"
elif [ -f "/usr/bin/yum" ]; then
PKGMGR="/usr/bin/yum"
fi
# Function to get the distribution name from /etc/os-release
get_distro_name() {
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "$NAME"
elif [ -f /etc/redhat-release ]; then
# Older versions of CentOS might use /etc/redhat-release
cat /etc/redhat-release
else
echo "Unknown"
fi
}
OS=$(uname)
distro_name=""
distro_type=""
if [ "$OS" = "Linux" ]; then
if [ "$PKGMGR" = "" ]; then
echo "ERROR: No package manager found, dnf and yum don't exist!!!"
exit 1
fi
distro_name=$(get_distro_name)
distro_type="unknown"
if [[ "$distro_name" == *"CentOS"* ]]; then
echo "This is a CentOS system."
distro_type="centos"
elif [[ "$distro_name" == *"AlmaLinux"* ]]; then
echo "This is an AlmaLinux system."
distro_type="alma"
else
echo "This is a Linux system, but not CentOS or AlmaLinux."
fi
## Setup Yum Repos
$SUDO $PKGMGR install -yq epel-release
if [ "$distro_type" = "alma" ]; then
$SUDO $PKGMGR config-manager --set-enabled powertools
$SUDO $PKGMGR install -yq almalinux-release-synergy
fi
$SUDO $PKGMGR install -yq which
## Standard Development tools
$SUDO $PKGMGR groupinstall -yq "Development Tools"
if [ "$distro_type" = "alma" ]; then
$SUDO $PKGMGR install -yq cmake
else
$SUDO $PKGMGR install -yq cmake3
fi
$SUDO $PKGMGR install -yq zlib-devel openssl-devel
$SUDO $PKGMGR install -yq screen
if [ "$distro_type" = "alma" ]; then
## Alma Release Synergy GRPC and Protobuf
$SUDO $PKGMGR install -yq grpc grpc-devel
$SUDO $PKGMGR install -yq protobuf-devel protobuf
$SUDO $PKGMGR install -yq grpc-plugins
fi
fi
if [ "$CLEAN" == "" ]; then
CLEAN=1
else
CLEAN=$CLEAN
fi
# Function to run a command within the SCL environment for CentOS
run_with_scl() {
OS="$(uname -s)"
if [ "$OS" = "Linux" -a "$distro_type" = "centos" ]; then
scl enable devtoolset-11 rh-python38 -- "$@"
else
"$@"
fi
}
run_with_scl_llvm() {
OS="$(uname -s)"
if [ "$OS" = "Linux" -a "$distro_type" = "centos" ]; then
scl enable devtoolset-11 llvm-toolset-7.0 -- "$@"
else
"$@"
fi
}
BUILD_DIR=$(pwd)/build
if [ ! -d $BUILD_DIR ]; then
mkdir -p $BUILD_DIR
else
if [ "$CLEAN" == "1" ]; then
rm -rf build/*
fi
fi
cd $BUILD_DIR
# Define versions for dependencies and GStreamer
GLIB_MAJOR_VERSION=2.64
GLIB_VERSION=${GLIB_MAJOR_VERSION}.6
ORC_VERSION=0.4.31
GST_VERSION=1.24.2
GST_PLUGINS_RS_VERSION=gstreamer-$GST_VERSION
LIBFFI_VERSION=3.3
NASM_VERSION=2.15.05
FFMPEG_VERSION=6.1.1
LIBZVBI_VERSION=0.2.42
# Define the installation prefix
export PREFIX=/opt/rsprobe
export PATH=$PREFIX/bin:$PATH
USER=$(whoami)
if [ "$USER" == "root" ]; then
SUDO=
fi
echo "User $USER executing script"
if [ ! -d "$PREFIX" ]; then
$SUDO mkdir -p $PREFIX
fi
$SUDO chown -R $USER $PREFIX
# Ensure necessary tools are installed
# For pkg-config to find .pc files
export PKG_CONFIG_PATH=$PREFIX/lib64/pkgconfig:${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$PREFIX/lib64:${PREFIX}/lib:$LD_LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH
CPUS=1
if [ "$OS" = "Linux" ]; then
CPUS=$(nproc)
elif [ "$OS" == "Darwin" ]; then
CPUS=$(sysctl -n hw.ncpu)
fi
if [ "$OS" = "Linux" ]; then
# Ensure the system is up to date and has the basic build tools
if [ "$distro_type" = "alma" ]; then
if [ "$GST" = "true" ]; then
$SUDO $PKGMGR install -yq python3 wget python3.12 python3.12-pip
$SUDO pip3.12 install meson
$SUDO pip3.12 install ninja
$SUDO pip3.12 install numpy
fi
else
$SUDO $PKGMGR groupinstall -yq "Development Tools"
$SUDO $PKGMGR install -yq bison flex python3 wget libffi-devel util-linux \
libmount-devel libxml2-devel glib2-devel cairo-devel \
ladspa-devel pango-devel cairo-gobject-devel cairo-gobject
$SUDO $PKGMGR install -yq centos-release-scl-rh epel-release
$SUDO $PKGMGR install -yq yum-utils
$SUDO yum-config-manager --disable epel
$SUDO $PKGMGR install --enablerepo=epel* -yq zvbi-devel cmake3
$SUDO $PKGMGR install -yq git
$SUDO $PKGMGR install -yq libstdc++-devel
$SUDO $PKGMGR install -yq llvm-toolset-7.0-llvm-devel llvm-toolset-7.0-clang
$SUDO $PKGMGR install -yq rh-python38 rh-python38-python-pip
$SUDO pip3 install meson
$SUDO pip3 install ninja
run_with_scl $SUDO pip3.8 install meson
run_with_scl $SUDO pip3.8 install ninja
fi
fi
# OpenCV installation
if [ "$GST" = "true" ]; then
if [ "$OS" = "Linux" -a "$distro_type" = "alma" ]; then
$SUDO $PKGMGR install -yq opencv-core opencv-devel opencv-contrib
else
if [ ! -d "opencv" ]; then
sh ../scripts/install_opencv.sh $PREFIX
fi
fi
fi
# Ensure Meson and Ninja are installed and use the correct Ninja
if [ "$OS" = "Darwin" ]; then
brew install meson
brew install ninja
brew install pkg-config
brew install bison
brew install wget
brew install llvm
brew install cmake
export PATH="/usr/local/opt/bison/bin:$PATH"
fi
# Download and build glib on linux
if [ "$GST" = "true" ]; then
CWD=$(pwd)
# Explicitly use cmake from $PREFIX/bin for Meson configuration
echo "[binaries]" > meson-native-file.ini
if [ "$OS" = "Linux" -a "$distro_type" = "centos" ]; then
echo "cmake = 'cmake3'" >> meson-native-file.ini
else
echo "cmake = 'cmake'" >> meson-native-file.ini
fi
MESON_NATIVE_FILE=$CWD/meson-native-file.ini
echo "------------------------------------------------------------"
echo "Installing GStreamer and essential dependencies..."
echo "------------------------------------------------------------"
if [ "$OS" = "Linux" ]; then
wget --no-check-certificate https://download.gnome.org/sources/glib/$GLIB_MAJOR_VERSION/glib-$GLIB_VERSION.tar.xz
tar xf glib-$GLIB_VERSION.tar.xz
cd glib-$GLIB_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
rm -rf glib-$GLIB_VERSION.tar.xz
rm -rf cd glib-$GLIB_VERSION
# Pcap source
if [ "$distro_type" = "centos" ]; then
wget https://www.tcpdump.org/release/libpcap-1.10.4.tar.gz
tar xfz libpcap-1.10.4.tar.gz
# Pcap build procedure (Linux)
cd libpcap-1.10.4
run_with_scl ./configure --prefix=$PREFIX --libdir=$PREFIX/lib64 --includedir=$PREFIX/include --exec_prefix=$PREFIX
run_with_scl make
cd ..
rm -rf libpcap-1.10.4.tar.gz
rm -rf libpcap-1.10.4
fi
fi
fi
# Install libFFI
if [ "$GST" = "true" ]; then
if [ "$OS" = "Linux" ]; then
if [ "$distro_type" = "centos" ]; then
if [ ! -f "libffi-installed.done" ] ; then
echo "---"
echo "Installing libffi..."
echo "---"
# Download, compile, and install libffi
if [ ! -f libffi-$LIBFFI_VERSION.tar.gz ]; then
curl ftp://sourceware.org/pub/libffi/libffi-$LIBFFI_VERSION.tar.gz -o libffi-$LIBFFI_VERSION.tar.gz
fi
if [ ! -d libffi-$LIBFFI_VERSION ]; then
tar xf libffi-$LIBFFI_VERSION.tar.gz
fi
cd libffi-$LIBFFI_VERSION
run_with_scl ./configure --prefix=$PREFIX
run_with_scl make -j $CPUS --silent
run_with_scl make install --silent
cd ..
fi
touch libffi-installed.done
fi
else
brew install libffi
fi
fi
# Install libzvbi
if [ "$GST" = "true" ]; then
if [ "$OS" = "Darwin" -o "$distro_type" = "alma" ]; then
if [ ! -f "libzvbi-installed.done" ]; then
if [ "$OS" = "Darwin" ]; then
brew install libtool autoconf automake
else
$SUDO $PKGMGR install -yq autoconf2.7x
fi
echo "---"
echo "Installing libzvbi..."
echo "---"
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone https://github.com/zapping-vbi/zvbi.git
cd zvbi
git checkout v$LIBZVBI_VERSION
if [ "$distro_type" = "alma" ]; then
export AUTOCONF=/usr/bin/autoconf27
export AUTOHEADER=/usr/bin/autoheader27
export AUTOM4TE=/usr/bin/autom4te27
export AUTORECONF=/usr/bin/autoreconf27
export AUTOUPDATE=/usr/bin/autoupdate27
export AUTOSCAN=/usr/bin/autoscan27
## Autoconf 27 override HACK
mkdir -p $PREFIX/bin
echo "#!/bin/sh" > $PREFIX/bin/autoconf
echo "/usr/bin/autoconf27" >> $PREFIX/bin/autoconf
chmod 755 $PREFIX/bin/autoconf
## End HACK
if [ ! -d "gettext-0.21" ]; then
wget https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.gz
tar -xzf gettext-0.21.tar.gz
fi
cd gettext-0.21
./configure --prefix=$PREFIX
make install --silent
cd ..
fi
touch README
run_with_scl ./autogen.sh
run_with_scl ./configure --prefix=$PREFIX
run_with_scl make -j $CPUS --silent
run_with_scl make install --silent
cd ..
fi
touch libzvbi-installed.done
rm -rf zvbi
fi
fi
# Install ORC
if [ "$OS" = "Linux" ]; then
if [ "$distro_type" = "centos" ]; then
if [ ! -f "orc-installed.done" ] ; then
echo "---"
echo "Installing ORC..."
echo "---"
# Download, compile, and install ORC
if [ ! -f orc-$ORC_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/orc/orc-$ORC_VERSION.tar.xz -o orc-$ORC_VERSION.tar.xz
fi
if [ ! -d orc-$ORC_VERSION ]; then
tar xf orc-$ORC_VERSION.tar.xz
fi
cd orc-$ORC_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
fi
touch orc-installed.done
fi
else
brew install orc
fi
# Download and compile NASM
if [ "$OS" = "Linux" ]; then
if [ "$distro_type" = "centos" ]; then
if [ ! -f "nasm-installed.done" ] ; then
if [ ! -f nasm-$NASM_VERSION.tar.gz ]; then
curl https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.gz -o nasm-$NASM_VERSION.tar.gz
fi
# Extract
if [ ! -d nasm-$NASM_VERSION ]; then
tar -xzf nasm-$NASM_VERSION.tar.gz
fi
cd nasm-$NASM_VERSION
# Compile and install
./autogen.sh
./configure --prefix=$PREFIX
make -j $CPUS --silent
make install --silent
cd ..
fi
touch nasm-installed.done
fi
else
brew install nasm
fi
if [ "$GST" = "true" ]; then
# libx264
if [ "$OS" = "Linux" ]; then
if [ ! -f "x264-installed.done" ] ; then
echo "---"
echo "Downloading and compiling libx264..."
echo "---"
echo "---"
echo "Cloning and compiling libx264..."
echo "---"
# Ensure git is installed
# Clone the repository
if [ ! -d "x264" ]; then
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone https://code.videolan.org/videolan/x264.git
fi
cd x264
# Compile
run_with_scl ./configure --prefix=$PREFIX --enable-shared --enable-static --enable-pic
run_with_scl make -j $CPUS --silent
make install --silent
cd ..
rm -rf x264
fi
touch x264-installed.done
else
brew install x264
fi
# libx265
if [ "$OS" = "Linux" ]; then
if [ ! -f "x265-installed.done" ] ; then
echo "---"
echo "Cloning and compiling x265..."
echo "---"
# Clone the x265 repository if it doesn't already exist
if [ ! -d "x265" ]; then
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone https://github.com/videolan/x265.git
fi
cd x265
# Create a build directory and navigate into it
mkdir -p build
cd build
# Use cmake3 to configure the build, respecting the PREFIX variable for installation
run_with_scl cmake3 -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX -DENABLE_SHARED:bool=on ../source
# Compile and install
run_with_scl make -j $CPUS --silent
make install --silent
# Navigate back to the initial directory
cd ../..
rm -rf x265
fi
touch x265-installed.done
else
brew install x265
fi
# FFmpeg
#if [ "$OS" = "Linux" ]; then
if [ ! -f "ffmpeg-installed.done" ] ; then
echo "---"
echo "Downloading and compiling FFmpeg..."
echo "---"
# Download
if [ ! -f ffmpeg-$FFMPEG_VERSION.tar.bz2 ]; then
wget http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2
fi
# Extract
if [ ! -d "ffmpeg-$FFMPEG_VERSION" ]; then
tar xf ffmpeg-$FFMPEG_VERSION.tar.bz2
fi
# Compile
cd ffmpeg-$FFMPEG_VERSION
run_with_scl ./configure --prefix=$PREFIX \
--enable-shared --enable-static \
--enable-pic --enable-gpl --enable-libx264 \
--enable-libx265 --enable-libzvbi \
--disable-vulkan \
--extra-cflags="-I$PREFIX/include" --extra-ldflags="-L$PREFIX/lib"
run_with_scl make -j $CPUS --silent
make install --silent
cd ..
rm -rf ffmpeg-$FFMPEG_VERSION
fi
touch ffmpeg-installed.done
#else
# brew install ffmpeg@6
#fi
# Install Gstreamer core
if [ ! -f "gstreamer-installed.done" ] ; then
echo "---"
echo "Installing Gstreamer core..."
echo "---"
# Download, compile, and install GStreamer core
if [ ! -f gstreamer-$GST_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$GST_VERSION.tar.xz -o gstreamer-$GST_VERSION.tar.xz
fi
if [ ! -d gstreamer-$GST_VERSION ]; then
tar xf gstreamer-$GST_VERSION.tar.xz
fi
cd gstreamer-$GST_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE
run_with_scl ninja -C _build
ninja -C _build install
cd ..
fi
touch gstreamer-installed.done
# Install GStreamer base plugins
if [ ! -f "gst-plugins-base-installed.done" ] ; then
echo "---"
echo "Installing Gstreamer base..."
echo "---"
# Download, compile, and install gst-plugins-base
if [ ! -f gst-plugins-base-$GST_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$GST_VERSION.tar.xz -o gst-plugins-base-$GST_VERSION.tar.xz
fi
if [ ! -d gst-plugins-base-$GST_VERSION ]; then
tar xf gst-plugins-base-$GST_VERSION.tar.xz
fi
cd gst-plugins-base-$GST_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
fi
touch gst-plugins-base-installed.done
# Install GStreamer bad plugins (includes tsdemux)
if [ ! -f "gst-plugins-bad-installed.done" ] ; then
# Install GStreamer bad plugins (includes tsdemux)
echo "---"
echo "Installing Gstreamer bad plugins..."
echo "---"
if [ ! -f gst-plugins-bad-$GST_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$GST_VERSION.tar.xz -o gst-plugins-bad-$GST_VERSION.tar.xz
fi
if [ ! -d gst-plugins-bad-$GST_VERSION ]; then
tar xf gst-plugins-bad-$GST_VERSION.tar.xz
fi
cd gst-plugins-bad-$GST_VERSION
run_with_scl meson setup _build -Dopenexr=disabled -Dopencv=disabled --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE # -Dopenexr=disabled -Dopencv=disabled
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
fi
touch gst-plugins-bad-installed.done
# GStreamer libav plugins
if [ ! -f "gst-libav-installed.done" ] ; then
echo "---"
echo "Installing Gstreamer libav plugins..."
echo "---"
PWD=$(pwd)
echo "PWD: $PWD"
if [ ! -f gst-libav-$GST_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/gst-libav/gst-libav-$GST_VERSION.tar.xz -o gst-libav-$GST_VERSION.tar.xz
fi
if [ ! -d gst-libav-$GST_VERSION ]; then
tar xf gst-libav-$GST_VERSION.tar.xz
fi
cd gst-libav-$GST_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE --pkg-config-path=$PKG_CONFIG_PATH
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
fi
touch gst-libav-installed.done
# GStreamer good plugins
if [ ! -f "gst-plugins-good-installed.done" ] ; then
echo "---"
echo "Installing GStreamer good plugins..."
echo "---"
# Download, compile, and install gst-plugins-good
if [ ! -f gst-plugins-good-$GST_VERSION.tar.xz ]; then
curl https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-$GST_VERSION.tar.xz -o gst-plugins-good-$GST_VERSION.tar.xz
fi
if [ ! -d gst-plugins-good-$GST_VERSION ]; then
tar xf gst-plugins-good-$GST_VERSION.tar.xz
fi
cd gst-plugins-good-$GST_VERSION
run_with_scl meson setup _build --prefix=$PREFIX --buildtype=release --native-file $MESON_NATIVE_FILE
run_with_scl ninja -C _build
run_with_scl ninja -C _build install
cd ..
fi
touch gst-plugins-good-installed.done
fi
if [ "$OS" == "Linux" ]; then
export RUSTFLAGS="-C link-args=-Wl,-rpath,$PREFIX/lib:$PREFIX/lib64"
else
export RUSTFLAGS="-C link-args=-Wl,-rpath,$PREFIX/lib"
fi
if [ "$GST" = "true" ]; then
# GStreamer Rust plugins
if [ ! -f "gst-plugins-rs-installed.done" ]; then
echo "---"
echo "Installing GStreamer Rust plugins..."
echo "---"
# Cargo-C for Rust
if [ "$distro_type" = "alma" ]; then
echo "Building gst-plugins-rs"
else
run_with_scl cargo install cargo-c --root=$PREFIX --quiet
echo "Building gst-plugins-rs"
fi
# Download gst-plugins-rs source code
#if [ ! -f gst-plugin-rs ]; then
# GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone https://github.com/sdroege/gst-plugin-rs.git
# cd gst-plugin-rs
# git checkout $GST_PLUGINS_RS_VERSION
# cd ..
#fi
# Build gst-plugin-closedcaption
#cd gst-plugin-rs
# Closed Caption
#echo
#echo "Building gst-plugin-closedcaption..."
#run_with_scl cargo cbuild --release --package gst-plugin-closedcaption --jobs 1
#run_with_scl cargo cinstall --release --package gst-plugin-closedcaption --prefix=$PREFIX --libdir=$PREFIX/lib64
# Audio
#echo
#echo "Building gst-plugin-audiofx..."
#run_with_scl cargo cbuild --release --package gst-plugin-audiofx --jobs 1
#run_with_scl cargo cinstall --release --package gst-plugin-audiofx --prefix=$PREFIX --libdir=$PREFIX/lib64
# Video
#echo
#echo "Building gst-plugin-videofx..."
#run_with_scl cargo cbuild --release --package gst-plugin-videofx --jobs 1
#run_with_scl cargo cinstall --release --package gst-plugin-videofx --prefix=$PREFIX --libdir=$PREFIX/lib64
#cd ..
fi
touch gst-plugins-rs-installed.done
GST_FEATURE="gst"
fi
# RsCap installation
echo
echo "Changing to RsCap directory... 'cd ../'"
cd ..
echo "------------------------------------------------------------"
echo "Cleaning RsCap..."
cargo clean --quiet
CUR_DIR=$(pwd)
echo "Building RsCap in $CUR_DIR ..."
export BUILD_TYPE=release
BUILD=$BUILD_TYPE ./scripts/compile.sh $GST_FEATURE
# Copy RsCap binaries to the installation directory
echo "Copying RsCap binaries to the installation directory..."
mkdir -p $PREFIX/bin
cp -f target/$BUILD_TYPE/probe $PREFIX/bin/
cp -f scripts/probe.sh $PREFIX/bin/
cp -f scripts/setup_env.sh $PREFIX/bin/
echo "------------------------------------------------------------"
echo "RsCap installation completed."
ls -altr $PREFIX/bin/probe
probe -V
if [ "$GST" = "true" ]; then
echo "------------------------------------------------------------"
echo "GStreamer and essential dependencies installed."
echo "------------------------------------------------------------"
# Verify GStreamer installation
echo "------------------------------------------------------------"
echo "Verifying GStreamer installation..."
echo "------------------------------------------------------------"
gst-launch-1.0 --version
fi
# Minimize size of installation
rm -rf $PREFIX/lib/pkgconfig
rm -rf $PREFIX/lib64/pkgconfig
rm -rf $PREFIX/include
rm -rf $PREFIX/cargo
rm -rf $PREFIX/share
rm -rf $PREFIX/lib/rustlib
rm -rf $PREFIX/lib/*.a
rm -rf $PREFIX/lib64/*.a
rm -rf $PREFIX/lib/*.la
rm -rf $PREFIX/lib64/*.la
#rm -rf $PREFIX/libexec
rm -rf $PREFIX/etc
rm -f $PREFIX/lib/librustc_driver-*
rm -f $PREFIX/lib/libstd-*
rm -f $PREFIX/lib/libLLVM-*
rm -f $PREFIX/bin/gtester
rm -f $PREFIX/bin/gobject-query
rm -f $PREFIX/bin/gio
rm -f $PREFIX/bin/gresource
rm -f $PREFIX/bin/gio-querymodules
rm -f $PREFIX/bin/glib-compile-schemas
rm -f $PREFIX/bin/glib-compile-resources
rm -f $PREFIX/bin/gsettings
rm -f $PREFIX/bin/gdbus
rm -f $PREFIX/bin/gapplication
rm -f $PREFIX/bin/gtester-report
rm -f $PREFIX/bin/glib-genmarshal
rm -f $PREFIX/bin/glib-mkenums
rm -f $PREFIX/bin/gdbus-codegen
rm -f $PREFIX/bin/glib-gettextize
rm -f $PREFIX/bin/rust-gdb
rm -f $PREFIX/bin/rust-gdbgui
rm -f $PREFIX/bin/rust-lldb
rm -f $PREFIX/bin/rustc
rm -f $PREFIX/bin/rustdoc
rm -f $PREFIX/bin/rust-demangler
rm -f $PREFIX/bin/cargo*
rm -f $PREFIX/bin/cargo-fmt
rm -f $PREFIX/bin/rustfmt
rm -f $PREFIX/bin/rls
rm -f $PREFIX/bin/rust-analyzer
rm -f $PREFIX/bin/cargo-clippy
rm -f $PREFIX/bin/clippy-driver
rm -f $PREFIX/bin/orcc
rm -f $PREFIX/bin/orc-bugreport
rm -f $PREFIX/bin/nasm
rm -f $PREFIX/bin/ndisasm