dpkg/build.sh

459 lines
11 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

oem=$1 #厂商
password="hg123123" #电脑密码
cpu=$(arch) #cpu架构
sys=$(cat /etc/issue)
sys=${sys%% *} #操作系统
dpkgpath="" #打包路径
dpkgarch="" #打包时的版本
libname="" #动态库名字
libpath="" #打包时库路径
time2=$(date "+%g%j") #版本控制
ismount=-1 #是否挂载服务器成功 0成功 非0失败
FIND_FILE="/home/samba/dpkg" #服务器存放打包路径 不可修改
dpkgtype="app"
ver3=10
sanelibname=""
if [ $2 ];
then
password=$2
fi
echo "$password"
sleep 1
if [ "$oem" != "hg" ] \
&& [ "$oem" != "lsc" ] \
&& [ "$oem" != "hw" ] \
&& [ "$oem" != "hgweb" ] \
&& [ "$oem" != "lscweb" ] \
&& [ "$oem" != "hgso" ] \
&& [ "$oem" != "lscso" ] \
&& [ "$oem" != "hwso" ] \
&& [ "$oem" != "lscsm" ]\
&& [ "$oem" != "cts" ];
then
echo "参数错误:$oem !!!"
echo "参数:华高:hg || hgweb ||hgso 立思层:lsc || lscweb ||lscso 汉王:hw || hwweb || hwso 沧田:cts"
exit 1
fi
if [ "${oem:0-2:2}" == "so" ] || [ "${oem:0-2:2}" == "sm" ];
then
sanelibname="${oem%${oem:0-2:2}*}"
echo $sanelibname
elif [ "${oem:0-3:3}" == "web" ];
then
sanelibname="${oem%${oem:0-3:3}*}"
echo $sanelibname
else
sanelibname=$oem
echo $sanelibname
fi
function appbuild()
{
pwd
echo "-----------------------------start-----------------------------"
#GIT CODE
rm ../release/$syspath/$cpu/* -R
git -C ../release clean -df
git -C ../release checkout .
git -C ../release pull
git -C ../sdk clean -df
git -C ../sdk checkout .
git -C ../sdk pull
#git -C ../code_device clean -df
git -C ../code_device checkout .
git -C ../code_device pull
#git -C ../code_app clean -df
git -C ../code_app checkout .
git -C ../code_app pull
git -C ../code_lang checkout .
git -C ../code_lang pull
echo "-----------------------------start code_lang build-----------------------------"
./../code_lang/build.sh
echo "-----------------------------start code_device build-----------------------------"
./../code_device/build.sh $sanelibname
echo "-----------------------------over code_device build-----------------------------"
if [ $? -ne 0 ];then
echo "code_device-------->编译失败"
exit 1
fi
echo "-----------------------------start code_app build-----------------------------"
if [ ${oem:0-2:2} == "sm" ];
then
./../code_app/build.sh ${oem%${oem:0-2:2}*}
else
./../code_app/build.sh $oem
echo ""
fi
echo "-----------------------------over code_app build-----------------------------"
if [ $? -ne 0 ];then
echo "code_app-------->编译失败"
exit 1
fi
}
function getismount()
{
if [ ! -d "/home/samba" ];then
echo $password|sudo -S mkdir -p "/home/samba"
echo $password|sudo -S mount -t cifs //192.168.10.5/huagao /home/samba/ -o username=huagao,password=hg123123
fi
mountpoint -q /home/samba
ismount=$?
if [ $ismount != 0 ];then
echo "$(date):mount is fail!!! and reboot mount"
echo $password|sudo -S mount -t cifs //192.168.10.5/huagao /home/samba/ -o username=huagao,password=hg123123
if [ ! $? ];then
echo "$(date):mount is fail!!!"
exit 1
fi
ismount=$?
else
echo "$(date):mount is succeed"
fi
}
if [ "$cpu" == "x86_64" ];
then
dpkgarch="amd64"
libpath="x86_64-linux-gnu"
elif [ "$cpu" == "aarch64" ];
then
dpkgarch="arm64"
libpath="aarch64-linux-gnu"
elif [ "$cpu" == "mips64" ];
then
dpkgarch="mips64el"
libpath="mips64el-linux-gnu"
elif [ "$cpu" == "loongarch64" ];
then
dpkgarch="loongarch64"
libpath="loongarch64-linux-gnu"
else
echo "没有已知架构"
exit 1
fi
if [ "$sys" == "UnionTech" ];
then
syspath="uos"
if [ "$oem" == "hw" ];
then
dpkgpath="com.hanvonchina.hanvonscan"
elif [ "$oem" == "lsc" ];
then
dpkgpath="com.lanxumchina.lanxumscan"
elif [ "$oem" == "hg" ];
then
dpkgpath="com.huagaochina.huagoscan"
elif [ "$oem" == "cts" ];
then
dpkgpath="com.cumtennchina.cumtennscan"
elif [ "$oem" == "hgweb" ];
then
dpkgpath="huagaowebscan"
elif [ "$oem" == "lscweb" ];
then
dpkgpath="lanxumwebscan"
elif [ "$oem" == "hwweb" ];
then
dpkgpath="hanvonwebscan"
elif [ "$oem" == "ctsweb" ];
then
dpkgpath="cumtennwebscan"
elif [ "$oem" == "hgso" ];
then
dpkgpath="huagaoscansdk"
elif [ "$oem" == "lscso" ];
then
dpkgpath="lanxumscansdk"
elif [ "$oem" == "hwso" ];
then
dpkgpath="hanvonscansdk"
elif [ "$oem" == "ctsso" ];
then
dpkgpath="cumtennscansdk"
fi
else
syspath="kylin"
if [ "$oem" == "hw" ] ;
then
dpkgpath="scanner-driver-hanvon"
elif [ "$oem" == "lsc" ];
then
dpkgpath="scanner-driver-lanxum"
elif [ "$oem" == "hg" ];
then
dpkgpath="scanner-driver-huagao"
elif [ "$oem" == "cts" ];
then
dpkgpath="scanner-driver-cumtenn"
elif [ "$oem" == "hgweb" ];
then
dpkgpath="huagaowebscan"
elif [ "$oem" == "lscweb" ];
then
dpkgpath="lanxumwebscan"
elif [ "$oem" == "hwweb" ];
then
dpkgpath="hanvonwebscan"
elif [ "$oem" == "ctsweb" ];
then
dpkgpath="cumtennwebscan"
elif [ "$oem" == "hgso" ];
then
dpkgpath="huagaoscansdk"
elif [ "$oem" == "lscso" ];
then
dpkgpath="lanxumscansdk"
elif [ "$oem" == "hwso" ];
then
dpkgpath="hanvonscansdk"
elif [ "$oem" == "ctsso" ];
then
dpkgpath="cumtennscansdk"
elif [ "$oem" == "lscsm" ];
then
dpkgpath="lanxumscan"
fi
fi
if [ "$oem" == "lsc" ] \
|| [ "$oem" == "lscweb" ] \
|| [ "$oem" == "lscso" ] \
|| [ "$oem" == "lscsm" ];
then
ver3=14
elif [ "$oem" == "hw" ] \
|| [ "$oem" == "hwweb" ] \
|| [ "$oem" == "hwso" ];
then
ver3=16
elif [ "$oem" == "cts" ] \
|| [ "$oem" == "ctsweb" ] \
|| [ "$oem" == "ctsso" ];
then
ver3=18
fi
ver3=$[$ver3 * 10]
if [ "$cpu" == "x86_64" ];
then
ver3=$[$ver3 + 5]
elif [ "$cpu" == "aarch64" ];
then
ver3=$[$ver3 + 2]
elif [ "$cpu" == "mips64" ];
then
ver3=$[$ver3 + 3]
elif [ "$cpu" == "loongarch64" ];
then
ver3=$[$ver3 + 4]
fi
ver3=$[$ver3 * 100]
if [ "$sys" == "UnionTech" ];
then
ver3=$[$ver3 + 20]
elif [ "$sys" == "Kylin" ];
then
ver3=$[$ver3 + 21]
else
# unknown OS, set as linux
ver3=$[$ver3 + 10]
fi
appbuild ########开始进行编译目前只能git 后期可以选择保存本地进行替换
#从 brand.h当中获取版本号
mainverstr=$(cat ../sdk/include/huagao/brand.h |grep VERSION_MAIN)
mainverstr=${mainverstr: -2}
mainverstr=$(echo $mainverstr)
minver=$(cat ../sdk/include/huagao/brand.h |grep VERSION_SUB)
minver=${minver: -2}
minver=$(echo $minver)
ver="$mainverstr.$minver.$ver3.$time2"
echo $minver
echo "3rd version replacing pattern: "${ver3}
echo $dpkgpath
echo $ver
Version="Version: $ver"
Architecture="Architecture: $dpkgarch"
packagename="package: $dpkgpath"
echo $Architecture $Version
############## 路径以sane根目录为基准
cd ..
##############
##############进行copy语言包
cp -rf release/lang release/$syspath/$cpu
##############
sed -i "1s/.*/$packagename/g" dpkg/$syspath/$oem/DEBIAN/control
sed -i "2s/.*/$Version/g" dpkg/$syspath/$oem/DEBIAN/control
sed -i "3s/.*/$Architecture/g" dpkg/$syspath/$oem/DEBIAN/control
rm dpkg/$syspath/$oem/etc/udev/rules.d/*
cp dpkg/60-sane.rules dpkg/$syspath/$oem/etc/udev/rules.d/60-"$oem"sane.rules
#创建sane的文件目录 //必须保证这一步成功
rm -rf dpkg/$syspath/$oem/usr/lib/*
if [ $? -ne 0 ];then
echo "del sane file fail"
exit 1
fi
if [ ! -d dpkg/$syspath/$oem/usr/lib/$libpath ];
then
mkdir -p dpkg/$syspath/$oem/usr/lib/$libpath/sane
if [ $? -ne 0 ];then
echo "mkdir sane file fail !!! --->mkdir path dpkg/$syspath/$oem/usr/lib/$libpath/sane"
exit 1
fi
cp release/$syspath/$cpu/libsane-"$sanelibname"sane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-"$sanelibname"sane.so.1
if [ $? -ne 0 ];then
echo "copy libsane file fail sane name is :libsane-"$sanelibname"sane.so!!!"
exit 1
fi
#kylin sp1有其他路径无法区分sp1 还是sp版本 ,所以全部进行拷贝即可 kylin mips 特殊处理
if [ "$cpu" == "mips64" ];
then
mkdir -p dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane
if [ $? -ne 0 ];then
echo "mips64el mkdir sane file fail !!!"
exit 1
fi
cp release/$syspath/$cpu/libsane-"$sanelibname"sane.so dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane/libsane-"$sanelibname"sane.so.1
if [ $? -ne 0 ];then
echo "copy libsane file fail sane name is :libsane-"$sanelibname"sane.so!!!"
exit 1
fi
fi
else
echo "del sane file fail"
exit 1
fi
if [ "$oem" == "lscweb" ] || [ "$oem" == "hwweb" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "ctsweb" ];
then
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/bin
elif [ "$oem" == "hgso" ] || [ "$oem" == "hwso" ] || [ "$oem" == "lscso" ] || [ "$oem" == "ctsso" ];
then
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/lib
cp sdk/include/scannerlib/* dpkg/$syspath/$oem/opt/$dpkgpath/include
elif [ "$oem" == "lscsm" ];
then
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath
else
savedpkgpath="dpkg/$syspath/$oem/opt/apps/$dpkgpath"
echo $dpkgpath
if [ "$sys" == "UnionTech" ];
then
#替换uos里面的info 虽然不晓得有啥用
appid='"appid":''"'$dpkgpath'"'','
InfoArch='"arch":[''"'$dpkgarch'"']','
version='"version":''"'$ver'"'','
name='"name":''"'$oem'"'','
sed -i "5s/.*/ $InfoArch/g" "$savedpkgpath/info"
sed -i "2s/.*/ $appid/g" "dpkg/$syspath/$oem/opt/apps/$dpkgpath/info"
sed -i "4s/.*/ $version/g" "dpkg/$syspath/$oem/opt/apps/$dpkgpath/info"
sed -i "3s/.*/ $name/g" "dpkg/$syspath/$oem/opt/apps/$dpkgpath/info"
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib
mv dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib/*Scan dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/bin
mv dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib/*App dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/bin
if [ $? != 0 ];
then
echo "-----------------cp fail-----------------"
exit 1
fi
else
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/apps/$dpkgpath/lib
mv dpkg/$syspath/$oem/opt/apps/$dpkgpath/lib/*Scan dpkg/$syspath/$oem/opt/apps/$dpkgpath/bin
mv dpkg/$syspath/$oem/opt/apps/$dpkgpath/lib/*App dpkg/$syspath/$oem/opt/apps/$dpkgpath/bin
if [ $? != 0 ];
then
echo "-----------------cp fail-----------------"
exit 1
fi
fi
fi
chmod 755 dpkg -R
chmod 755 backup -R
if [ -d "backup/$syspath/$oem/$ver" ];
then
rm -rf "backup/$syspath/$oem/$ver"
fi
if [ ! -d "backup/$syspath/$oem/$ver" ];
then
mkdir -p "backup/$syspath/$oem/$ver"
fi
cp -rf dpkg/$syspath/$oem/* backup/$syspath/$oem/$ver
if [ "$oem" == "hg" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "hgso" ];
then
dpkgtype="hg"
elif [ "$oem" == "lsc" ] || [ "$oem" == "lscweb" ] || [ "$oem" == "lscso" ] || [ "$oem" == "lscsm" ];
then
dpkgtype="lsc"
elif [ "$oem" == "cts" ] || [ "$oem" == "ctsweb" ] || [ "$oem" == "ctsso" ];
then
dpkgtype="cts"
else
dpkgtype="hw"
fi
if [ ! -d "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype" ];
then
mkdir -p "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/"
fi
dpkg -b backup/$syspath/$oem/$ver backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/$dpkgpath"_"$ver"_"$dpkgarch.deb
getismount
if [ $ismount == 0 ];
then
if [ -d "$FIND_FILE/$syspath" ];
then
echo "$(date):mount is succeed and cp dpkg"
echo $password|sudo -S cp -rf backup/dpkg/$mainverstr.$minver $FIND_FILE/$syspath
fi
fi