[GStreamer][LearnGst] setup.sh 脚本

 在搭建gstreamer开发环境时,需要检查依赖库是否存在,插件搜索环境变量是否正确设置等等信息,这里规划做一个 setup.sh 脚本来进行这些检查,同时尽可能地做一些自动化配置。

#!/bin/bash -i

echo "1. checking dependencies.........................................."
ret1=`pkg-config --list-all|grep gstreamer-1.0|wc -l`
if [ $ret1 -eq 1 ]; then
    echo "[pass] gstreamer-1.0"
else
	echo "LACK OF gstreamer-1.0 , please instsall"
	exit 0
fi

ret2=`pkg-config --list-all|grep glog|wc -l`
if [ $ret2 -eq 1 ]; then
    echo "[pass] glog"
else
	echo "LACK OF glog , please instsall"
	exit 0
fi
echo "1. checking dependencies.......................................... Done"

echo ""

echo "2. checking environment variables.........................................."

#all pkg-config search dir
ret3=`pkg-config --variable pc_path pkg-config`
IFS=':'
read -r -a array <<< "$ret3"
#iterate all dirs for gstreamer-1.0.pc
for element in "${array[@]}"
do
  echo "$element"
  if [ -d "$element" ]; then
    reta=`ls "$element"|grep gstreamer-1.0.pc|wc -l`
    if [ $reta -eq 1 ]; then
      rets=`sed -n '/prefix/s/^.*=\(.*\)$/\1/p' "$element"/gstreamer-1.0.pc | grep -v "{"`
	  retss=`sed -n '/pluginsdir/s/^.*=\(.*\)$/\1/p' "$element"/gstreamer-1.0.pc`
	  retfinnal=${retss/"prefix"/$rets}
	  retfinnal1=`echo $retfinnal|sed 's/[{]//g;s/[$]//g;s/[}]//g'`
    fi
  fi
done

echo "default plugin dir is $retfinnal1"
echo "my plugin dir is $PWD/_OUTPUT/"
expectedpluginpath="$retfinnal1:$PWD/_OUTPUT/"
echo "expected is $expectedpluginpath"

#delete line contain GST_PLUGIN_PATH
sed -i "/GST_PLUGIN_PATH=/d" ~/.bashrc

#append new GST_PLUGIN_PATH to ~/.bashrc
echo "export GST_PLUGIN_PATH=$expectedpluginpath" >> ~/.bashrc
echo "[after modi] GST_PLUGIN_PATH -> $GST_PLUGIN_PATH"

echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"

echo "2. checking environment variables..................................... Done"

echo ""



exit 0

相关推荐

  1. Unity-脚本

    2024-05-10 15:50:14       59 阅读
  2. Shell脚本

    2024-05-10 15:50:14       48 阅读
  3. Lua<span style='color:red;'>脚本</span>

    Lua脚本

    2024-05-10 15:50:14      48 阅读
  4. python脚本

    2024-05-10 15:50:14       33 阅读
  5. .bat 脚本

    2024-05-10 15:50:14       38 阅读
  6. shell脚本

    2024-05-10 15:50:14       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-10 15:50:14       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-10 15:50:14       101 阅读
  3. 在Django里面运行非项目文件

    2024-05-10 15:50:14       82 阅读
  4. Python语言-面向对象

    2024-05-10 15:50:14       91 阅读

热门阅读

  1. 【论文合集 2】- 基于忆阻器的存内计算

    2024-05-10 15:50:14       29 阅读
  2. MySql开源闪回工具MyFlash —— 筑梦之路

    2024-05-10 15:50:14       36 阅读
  3. 少的缓存穿透是缓存击穿,大量的是缓存雪崩

    2024-05-10 15:50:14       31 阅读
  4. Redis

    2024-05-10 15:50:14       31 阅读
  5. ORACLE 生成AWR常用脚本

    2024-05-10 15:50:14       35 阅读
  6. C#中override与重载的区别

    2024-05-10 15:50:14       34 阅读
  7. 设计模式之单例模式

    2024-05-10 15:50:14       36 阅读
  8. 如何在Windows和Linux中杀死Python进程

    2024-05-10 15:50:14       37 阅读
  9. 二、Redis五种常用数据类型-String

    2024-05-10 15:50:14       34 阅读