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="" syspath="" #系统库路径 dpkgtype="" #哪种打包方式 uos 还是kylin #web so 只走kylin的打包方式 if [ $2 ]; then dpkgtype=$2 #可以手动设置操作系统来进行打包 echo "$dpkgtype" else if [ "$sys" == "UnionTech" ]; then dpkgtype=uos else dpkgtype=kylin fi fi if [ $3 ]; then password=$3 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" != "ctsso" ]\ && [ "$oem" != "cts" ]\ && [ "$oem" != "zg" ]\ && [ "$oem" != "zgso" ]\ && [ "$oem" != "zgweb" ]\ && [ "$oem" != "dl" ]\ && [ "$oem" != "zj" ]\ && [ "$oem" != "zjso" ]\ && [ "$oem" != "zjweb" ]\ && [ "$oem" != "neu" ]; 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 dpkgtype=kylin sanelibname="${oem%${oem:0-2:2}*}" echo $sanelibname elif [ "${oem:0-3:3}" == "web" ]; then dpkgtype=kylin 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/* 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 $dpkgtype 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" elif [ "$cpu" == "sw_64" ]; then dpkgarch="sw_64" libpath="sw_64-linux-gnu" else echo "没有已知架构" exit 1 fi if [ "$syspath" == "uos" ] || [ "$sys" == "UnionTech" ]; then syspath="uos" elif [ "$syspath" == "kylin" ] && [ "$sys" == "UnionTech" ]; then syspath="uos" elif [ "$syspath" == "" ] && [ "$sys" == "UnionTech" ]; then syspath="uos" elif [ "$syspath" == "kylin" ] || [ "$sys" == "Kylin" ]; then syspath="kylin" elif [ "$syspath" == "uos" ] && [ "$sys" == "Kylin" ]; then syspath="kylin" elif [ "$syspath" == "" ] && [ "$sys" == "Kylin" ]; then syspath="kylin" else syspath="kylin" fi echo $syspath if [ $dpkgtype == "uos" ]; then 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" == "zj" ]; then dpkgpath="com.microtekchina.microtekscan-ex" elif [ "$oem" == "zg" ]; then dpkgpath="com.unischina.uniscan" elif [ "$oem" == "dl" ]; then dpkgpath="com.delichina.deliscan" elif [ "$oem" == "neu" ]; then dpkgpath="com.neutralchina.neuscan" fi else 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" == "zj" ]; then dpkgpath="scanner-driver-microtek-ex" elif [ "$oem" == "zg" ]; then dpkgpath="scanner-driver-unis" elif [ "$oem" == "dl" ]; then dpkgpath="scanner-driver-deli" elif [ "$oem" == "neu" ]; then dpkgpath="scanner-driver-neutral" 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" == "zjweb" ]; then dpkgpath="Microtekwebscan" 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" == "zjso" ]; then dpkgpath="Microtekscansdk" 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 elif [ "$oem" == "zj" ]\ || [ "$oem" == "zjweb" ]\ || [ "$oem" == "zjsso" ]; then ver3=20 elif [ "$oem" == "zg" ]; then ver3=22 elif [ "$oem" == "dl" ]; then ver3=24 elif [ "$oem" == "neu" ]; then ver3=26 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] elif [ "$cpu" == "sw_64" ]; then ver3=$[$ver3 + 7] fi ver3=$[$ver3 * 100] if [ "$dpkgtype" == "uos" ]; then ver3=$[$ver3 + 20] elif [ "$dpkgtype" == "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 .. ############## ##############lsc不替换 if [ "$oem" != "lscsm" ]; then ##############进行copy语言包 cp -rf release/lang release/$syspath/$cpu sed -i "1s/.*/$packagename/g" dpkg/$dpkgtype/$oem/DEBIAN/control sed -i "2s/.*/$Version/g" dpkg/$dpkgtype/$oem/DEBIAN/control fi sed -i "3s/.*/$Architecture/g" dpkg/$dpkgtype/$oem/DEBIAN/control rm dpkg/$dpkgtype/$oem/etc/udev/rules.d/* cp dpkg/60-sane.rules dpkg/$dpkgtype/$oem/etc/udev/rules.d/60-"$oem"sane.rules if [ "${oem:0-2:2}" != "so" ] && [ "${oem:0-3:3}" != "web" ]; then #创建sane的文件目录 //必须保证这一步成功 rm -rf dpkg/$dpkgtype/$oem/usr/lib/* if [ $? -ne 0 ];then echo "del sane file fail" exit 1 fi if [ ! -d dpkg/$dpkgtype/$oem/usr/lib/$libpath ]; then mkdir -p dpkg/$dpkgtype/$oem/usr/lib/$libpath/sane if [ $? -ne 0 ];then echo "mkdir sane file fail !!! --->mkdir path dpkg/$dpkgtype/$oem/usr/lib/$libpath/sane" exit 1 fi cp release/$syspath/$cpu/libsane-"$sanelibname"sane.so dpkg/$dpkgtype/$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/$dpkgtype/$oem/usr/lib/"mips64el-linux-gnuabi64"/sane if [ $? -ne 0 ];then echo "mips64el mkdir sane file fail !!!" exit 1 fi cp release/$syspath/$cpu/libsane-"$sanelibname"sane.so dpkg/$dpkgtype/$oem/usr/lib/"mips64el-linux-gnuabi64"/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 fi if [ "$oem" == "lscweb" ] || [ "$oem" == "hwweb" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "ctsweb" ] || [ "$oem" == "zjweb" ]; then cp -rf release/$syspath/$cpu/* dpkg/$dpkgtype/$oem/opt/$dpkgpath/bin elif [ "$oem" == "hgso" ] || [ "$oem" == "hwso" ] || [ "$oem" == "lscso" ] || [ "$oem" == "ctsso" ] || [ "$oem" == "zjso" ]; then cp -rf release/$syspath/$cpu/* dpkg/$dpkgtype/$oem/opt/$dpkgpath/lib cp sdk/include/scannerlib/* dpkg/$dpkgtype/$oem/opt/$dpkgpath/include elif [ "$oem" == "lscsm" ]; then cp -rf release/$syspath/$cpu/* dpkg/$dpkgtype/$oem/opt/$dpkgpath else #暂时只拷贝立思辰 if [ "$oem" == "lsc" ]; then if [ ! -d "dpkg/$syspath/$oem/usr/local/lib/sane/" ]; then mkdir -p "dpkg/$syspath/$oem/usr/local/lib/sane/" fi cp release/$syspath/$cpu/libsane-"$sanelibname"sane.so dpkg/$dpkgtype/$oem/usr/local/lib/sane/libsane-"$sanelibname"sane.so.1 fi savedpkgpath="dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath" echo $dpkgpath if [ "$dpkgtype" == "uos" ]; 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/$dpkgtype/$oem/opt/apps/$dpkgpath/info" sed -i "4s/.*/ $version/g" "dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/info" sed -i "3s/.*/ $name/g" "dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/info" cp -rf release/$syspath/$cpu/* dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib if [ "$oem" == "hg" ]; then mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/*App dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/bin fi mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/*OCR dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/bin if [ "$oem" == "dl" ]; then mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/"DELI SCAN" dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/bin/DELISCAN else mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/*Scan dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/bin/ fi if [ "$oem" == "zj" ]; then mkdir dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/settings cp -rf release/win/x86/Release/microtek-settings/0439.hsc dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/files/lib/settings/0439.hsc fi if [ $? != 0 ]; then echo "-----------------cp fail-----------------" exit 1 fi else cp -rf release/$syspath/$cpu/* dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib if [ "$oem" == "hg" ]; then mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/*App dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/bin fi mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/*OCR dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/bin if [ "$oem" == "dl" ]; then mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/"DELI SCAN" dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/bin/DELISCAN else mv dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/*Scan dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/bin fi if [ "$oem" == "zj" ]; then mkdir dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/settings cp -rf release/win/x86/Release/microtek-settings/0439.hsc dpkg/$dpkgtype/$oem/opt/apps/$dpkgpath/lib/settings/0439.hsc fi if [ $? != 0 ]; then echo "-----------------cp fail-----------------" exit 1 fi fi fi chmod 755 dpkg -R chmod 755 backup -R if [ -d "backup/$dpkgtype/$oem/$ver" ]; then rm -rf "backup/$dpkgtype/$oem/$ver" fi if [ ! -d "backup/$dpkgtype/$oem/$ver" ]; then mkdir -p "backup/$dpkgtype/$oem/$ver" fi cp -rf dpkg/$dpkgtype/$oem/* backup/$dpkgtype/$oem/$ver if [ ! -d "backup/dpkg/$dpkgtype/$mainverstr.$minver/$time2/$sanelibname" ]; then mkdir -p "backup/dpkg/$dpkgtype/$mainverstr.$minver/$time2/$sanelibname/" fi dpkg -b backup/$dpkgtype/$oem/$ver backup/dpkg/$dpkgtype/$mainverstr.$minver/$time2/$sanelibname/$dpkgpath"_"$ver"_"$dpkgarch.deb getismount if [ $ismount == 0 ]; then if [ -d "$FIND_FILE/$dpkgtype" ]; then echo "$(date):mount is succeed and cp dpkg" echo $password|sudo -S cp -rf backup/dpkg/$dpkgtype/$mainverstr.$minver $FIND_FILE/$dpkgtype fi fi