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" #服务器存放打包路径 不可修改 workpath="" dpkgtype="app" ver3=10 if [ $2 ]; then password=$2 fi echo "$password" sleep 1 if [ "$oem" != "hg" ] && [ "$oem" != "lsc" ] && [ "$oem" != "hw" ] && [ "$oem" != "hgweb" ] && [ "$oem" != "lscweb" ] && [ "$oem" != "hwweb" ] && [ "$oem" != "hgso" ] && [ "$oem" != "lscso" ] && [ "$oem" != "hwso" ] && [ "$oem" != "lscsm" ]; then echo "参数错误:$oem!!!" echo "参数:华高:hg || hgweb 立思层:lsc || lscweb 汉王:hw || hwweb" 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.100.140/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.100.140/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" workpath="" 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" == "hgweb" ];then dpkgpath="huagaowebscan" elif [ "$oem" == "lscweb" ];then dpkgpath="lanxumwebscan" elif [ "$oem" == "hwweb" ];then dpkgpath="hanvonwebscan" elif [ "$oem" == "hgso" ];then dpkgpath="huagaoscansdk" elif [ "$oem" == "lscso" ];then dpkgpath="lanxumscansdk" elif [ "$oem" == "hwso" ];then dpkgpath="hanvonscansdk" 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" == "hgweb" ];then dpkgpath="huagaowebscan" elif [ "$oem" == "lscweb" ];then dpkgpath="lanxumwebscan" elif [ "$oem" == "hwweb" ];then dpkgpath="hanvonwebscan" elif [ "$oem" == "hgso" ];then dpkgpath="huagaoscansdk" elif [ "$oem" == "lscso" ];then dpkgpath="lanxumscansdk" elif [ "$oem" == "hwso" ];then dpkgpath="hanvonscansdk" 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 fi ver3=$[$ver3 * 10] if [ "$cpu" == "x86_64" ]; then ver3=$[$ver3 + 1] 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 # uos ... ver3=$[$ver3 + 20] elif [ "$sys" == "Kylin" ];then # kylin ... ver3=$[$ver3 + 21] else # unknown OS, set as linux ver3=$[$ver3 + 10] fi cd ../release/$syspath/$cpu/ rm * -R git checkout . git pull cd ../../../sdk git checkout . git pull #必须先获取代码 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) cd ../code_device git checkout . git pull if [ "$oem" == "hgso" ] ;then ./build.sh hg elif [ "$oem" == "hwso" ];then ./build.sh hw elif [ "$oem" == "lscso" ] || [ "$oem" == "lscsm" ];then ./build.sh lsc else ./build.sh $oem fi sleep 3 if [ $? -ne 0 ];then echo "code_device-------->编译失败" exit 1 fi cd ../code_app git checkout . git pull if [ "$oem" == "hgso" ] ;then ./build.sh hg elif [ "$oem" == "hwso" ];then ./build.sh hw elif [ "$oem" == "lscso" ];then ./build.sh lsc fi if [ "$oem" == "lscsm" ];then ./build.sh lsc else ./build.sh $oem fi if [ $? -ne 0 ];then echo "code_app-------->编译失败" exit 1 fi echo "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" echo $minver echo "3rd version replacing pattern: "${ver3} echo $dpkgpath ver="$mainverstr.$minver.$ver3.$time2" echo $ver Version="Version: $ver" Architecture="Architecture: $dpkgarch" packagename="package: $dpkgpath" echo $Architecture $Version cd .. echo "dpkg/$syspath/$oem/usr/lib/$libpath" echo "dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib" 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 if [ -d "dpkg/$syspath/$oem/usr/lib" ];then if [ "$cpu" == "mips64" ]; then rm -rf dpkg/$syspath/$oem/usr/lib/* if [ ! -d dpkg/$syspath/$oem/usr/lib/$libpath ]; then mkdir -p dpkg/$syspath/$oem/usr/lib/$libpath/sane mkdir -p dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane if [ "$oem" == "lscsm" ];then cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-lscsane.so.1 cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane/libsane-lscsane.so.1 else cp release/$syspath/$cpu/libsane-"$oem"sane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-"$oem"sane.so.1 cp release/$syspath/$cpu/libsane-"$oem"sane.so dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane/libsane-"$oem"sane.so fi fi if [ $? != 0 ];then echo "-----------------cp mips64el libsane fail ,not find libsane-----------------" exit 1 fi else mv dpkg/$syspath/$oem/usr/lib/* dpkg/$syspath/$oem/usr/lib/$libpath rm dpkg/$syspath/$oem/usr/lib/$libpath/sane/* if [ "$oem" == "lscsm" ];then cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-lscsane.so.1 else cp release/$syspath/$cpu/libsane-"$oem"sane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-"$oem"sane.so.1 fi fi if [ $? != 0 ];then echo "-----------------cp libsane fail ,not find libsane-----------------" exit 1 fi echo "11111111111111111111111111111111111111111111111111111" sleep 3 fi if [ "$oem" == "lscweb" ] || [ "$oem" == "hwweb" ] || [ "$oem" == "hgweb" ]; then cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/bin elif [ "$oem" == "hgso" ] || [ "$oem" == "hwso" ] || [ "$oem" == "lscso" ];then cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/lib cp sdk/include/scannerlib/* dpkg/$syspath/$oem/opt/$dpkgpath/include rm dpkg/$syspath/$oem/opt/$dpkgpath/lib/*Scan rm dpkg/$syspath/$oem/opt/$dpkgpath/lib/*App elif [ "$oem" == "lscsm" ];then cp release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath else if [ "$sys" == "UnionTech" ];then if [ "$cpu" == "x86_64" ]; then sed -i "s/arm64/amd64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/mips64el/amd64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/loongarch64/amd64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info elif [ "$cpu" == "aarch64" ]; then sed -i "s/amd64/arm64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/mips64el/arm64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/loongarch64/arm64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info elif [ "$cpu" == "mips64" ]; then sed -i "s/amd64/mips64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/arm64/mips64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/loongarch64/mips64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info elif [ "$cpu" == "loongarch64" ]; then sed -i "s/amd64/loongarch64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/arm64/loongarch64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info sed -i "s/mips64/loongarch64/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/info fi cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib cp release/$syspath/$cpu/*Scan dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/bin cp release/$syspath/$cpu/*App dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/bin else cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/apps/$dpkgpath/lib cp release/$syspath/$cpu/*Scan dpkg/$syspath/$oem/opt/apps/$dpkgpath/bin cp release/$syspath/$cpu/*App dpkg/$syspath/$oem/opt/apps/$dpkgpath/bin fi fi if [ $? != 0 ];then echo "-----------------cp fail-----------------" exit 1 fi pwd 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 path="" if [ "$oem" == "hg" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "hgso" ];then dpkgtype="hg" if [ ! -d "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype" ];then mkdir -p "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/" fi elif [ "$oem" == "lsc" ] || [ "$oem" == "lscweb" ] || [ "$oem" == "lscso" ] || [ "$oem" == "lscsm" ];then dpkgtype="lsc" if [ ! -d "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype" ];then mkdir -p "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/" fi else dpkgtype="hw" if [ ! -d "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype" ];then mkdir -p "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/" fi 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