dpkg/build.sh

447 lines
11 KiB
Bash
Raw Normal View History

2022-09-28 09:40:51 +00:00
oem=$1 #厂商
2022-09-28 09:55:52 +00:00
password="hg123123" #电脑密码
2022-09-28 09:40:51 +00:00
cpu=$(arch) #cpu架构
2022-07-04 01:48:13 +00:00
sys=$(cat /etc/issue)
2022-09-28 09:40:51 +00:00
sys=${sys%% *} #操作系统
dpkgpath="" #打包路径
dpkgarch="" #打包时的版本
libname="" #动态库名字
libpath="" #打包时库路径
time2=$(date "+%g%j") #版本控制
ismount=-1 #是否挂载服务器成功 0成功 非0失败
FIND_FILE="/home/samba/dpkg" #服务器存放打包路径 不可修改
2022-07-04 08:31:52 +00:00
dpkgtype="app"
2022-08-04 08:20:59 +00:00
ver3=10
2022-09-29 07:06:02 +00:00
2022-08-09 09:22:55 +00:00
2022-09-28 09:55:52 +00:00
if [ $2 ];
then
password=$2
fi
2022-07-04 01:48:13 +00:00
2022-09-29 02:04:42 +00:00
echo "$password"
sleep 1
2023-01-13 07:36:32 +00:00
if [ "$oem" != "hg" ] \
&& [ "$oem" != "lsc" ] \
&& [ "$oem" != "hw" ] \
&& [ "$oem" != "hgweb" ] \
&& [ "$oem" != "lscweb" ] \
&& [ "$oem" != "hwweb" ] \
&& [ "$oem" != "hgso" ] \
&& [ "$oem" != "lscso" ] \
&& [ "$oem" != "hwso" ] \
&& [ "$oem" != "lscsm" ]\
&& [ "$oem" != "cts" ]\
&& [ "$oem" != "ctsso" ]\
&& [ "$oem" != "ctsweb" ];
2022-07-04 01:48:13 +00:00
then
2023-01-13 07:36:32 +00:00
echo "参数错误:$oem !!!"
2022-07-04 06:26:02 +00:00
echo "参数:华高:hg || hgweb 立思层:lsc || lscweb 汉王:hw || hwweb"
2022-07-04 01:48:13 +00:00
exit 1
fi
2023-01-13 09:55:21 +00:00
2022-09-28 09:40:51 +00:00
function getismount()
{
2022-09-29 02:04:42 +00:00
if [ ! -d "/home/samba" ];then
2023-01-13 07:36:32 +00:00
echo $password|sudo -S mkdir -p "/home/samba"
2023-01-04 10:32:20 +00:00
echo $password|sudo -S mount -t cifs //192.168.10.5/huagao /home/samba/ -o username=huagao,password=hg123123
2022-09-29 02:04:42 +00:00
fi
2022-09-28 09:40:51 +00:00
mountpoint -q /home/samba
ismount=$?
if [ $ismount != 0 ];then
echo "$(date):mount is fail!!! and reboot mount"
2023-01-13 07:36:32 +00:00
echo $password|sudo -S mount -t cifs //192.168.10.5/huagao /home/samba/ -o username=huagao,password=hg123123
2022-09-29 02:04:42 +00:00
if [ ! $? ];then
echo "$(date):mount is fail!!!"
exit 1
fi
ismount=$?
2022-09-28 09:40:51 +00:00
else
echo "$(date):mount is succeed"
fi
}
2023-01-13 07:36:32 +00:00
if [ "$cpu" == "x86_64" ];
then
2022-07-04 01:48:13 +00:00
dpkgarch="amd64"
libpath="x86_64-linux-gnu"
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "aarch64" ];
then
2022-07-04 01:48:13 +00:00
dpkgarch="arm64"
libpath="aarch64-linux-gnu"
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "mips64" ];
then
2022-07-04 01:48:13 +00:00
dpkgarch="mips64el"
2022-08-09 09:29:09 +00:00
libpath="mips64el-linux-gnu"
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "loongarch64" ];
then
2022-10-14 08:30:34 +00:00
dpkgarch="loongarch64"
libpath="loongarch64-linux-gnu"
2022-07-04 01:48:13 +00:00
else
echo "没有已知架构"
exit 1
fi
2023-01-13 07:36:32 +00:00
if [ "$sys" == "UnionTech" ];
then
2022-07-04 01:48:13 +00:00
syspath="uos"
2023-01-13 07:36:32 +00:00
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"
2022-07-04 01:48:13 +00:00
fi
2022-09-28 07:15:38 +00:00
else
2022-07-04 01:48:13 +00:00
syspath="kylin"
2023-01-13 09:55:21 +00:00
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
2022-07-04 01:48:13 +00:00
fi
2022-08-05 02:57:49 +00:00
2023-01-13 07:36:32 +00:00
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
2022-08-05 02:57:49 +00:00
fi
2023-01-13 07:36:32 +00:00
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 * 10]
2023-01-13 07:36:32 +00:00
if [ "$cpu" == "x86_64" ];
then
2022-11-24 09:58:42 +00:00
ver3=$[$ver3 + 5]
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "aarch64" ];
then
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 + 2]
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "mips64" ];
then
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 + 3]
2023-01-13 07:36:32 +00:00
elif [ "$cpu" == "loongarch64" ];
then
2022-10-14 08:30:34 +00:00
ver3=$[$ver3 + 4]
2022-08-04 09:24:58 +00:00
fi
2022-07-04 01:48:13 +00:00
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 * 100]
2023-01-13 07:36:32 +00:00
if [ "$sys" == "UnionTech" ];
then
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 + 20]
2023-01-13 07:36:32 +00:00
elif [ "$sys" == "Kylin" ];
then
2022-08-04 09:24:58 +00:00
ver3=$[$ver3 + 21]
else
# unknown OS, set as linux
ver3=$[$ver3 + 10]
fi
2023-01-13 07:36:32 +00:00
#GIT CODE
2022-07-04 01:48:13 +00:00
cd ../release/$syspath/$cpu/
rm * -R
git checkout .
git pull
cd ../../../sdk
git checkout .
git pull
2023-01-13 07:36:32 +00:00
cd ../code_device
git checkout .
git pull
#从 brand.h当中获取版本号
2022-09-29 07:06:02 +00:00
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)
2022-09-28 07:37:01 +00:00
2023-01-13 07:36:32 +00:00
if [ "$oem" == "hgso" ];
then
2022-09-28 07:37:01 +00:00
./build.sh hg
2023-01-13 07:36:32 +00:00
elif [ "$oem" == "hwso" ];
then
2022-09-28 07:37:01 +00:00
./build.sh hw
2023-01-13 07:36:32 +00:00
elif [ "$oem" == "lscso" ] || [ "$oem" == "lscsm" ];
then
2022-09-28 07:37:01 +00:00
./build.sh lsc
2023-01-13 07:36:32 +00:00
elif [ "$oem" == "ctsso" ];
then
2022-11-15 03:27:31 +00:00
./build.sh cts
2022-09-28 07:37:01 +00:00
else
./build.sh $oem
fi
2022-09-28 08:10:54 +00:00
2022-07-04 01:48:13 +00:00
if [ $? -ne 0 ];then
echo "code_device-------->编译失败"
exit 1
fi
cd ../code_app
git checkout .
git pull
2022-09-28 07:37:01 +00:00
2022-09-30 03:08:02 +00:00
if [ "$oem" == "lscsm" ];then
./build.sh lsc
else
./build.sh $oem
fi
2022-07-04 01:48:13 +00:00
if [ $? -ne 0 ];then
echo "code_app-------->编译失败"
exit 1
fi
2022-09-30 03:01:17 +00:00
echo "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
2022-08-09 09:22:55 +00:00
echo $minver
echo "3rd version replacing pattern: "${ver3}
echo $dpkgpath
ver="$mainverstr.$minver.$ver3.$time2"
echo $ver
2022-07-04 01:48:13 +00:00
Version="Version: $ver"
Architecture="Architecture: $dpkgarch"
packagename="package: $dpkgpath"
2022-09-28 07:15:38 +00:00
2022-07-04 01:48:13 +00:00
echo $Architecture $Version
2023-01-13 09:55:21 +00:00
##############
cd ..
##############
2023-01-13 07:36:32 +00:00
#echo "dpkg/$syspath/$oem/usr/lib/$libpath"
#echo "dpkg/$syspath/$oem/opt/apps/$dpkgpath/files/lib"
2022-07-04 01:48:13 +00:00
sed -i "1s/.*/$packagename/g" dpkg/$syspath/$oem/DEBIAN/control
sed -i "2s/.*/$Version/g" dpkg/$syspath/$oem/DEBIAN/control
2022-09-28 07:15:38 +00:00
sed -i "3s/.*/$Architecture/g" dpkg/$syspath/$oem/DEBIAN/control
2022-09-28 09:18:29 +00:00
rm dpkg/$syspath/$oem/etc/udev/rules.d/*
2022-09-30 03:37:08 +00:00
2022-07-29 09:28:21 +00:00
cp dpkg/60-sane.rules dpkg/$syspath/$oem/etc/udev/rules.d/60-"$oem"sane.rules
2022-09-30 03:01:17 +00:00
2023-01-13 09:55:21 +00:00
#创建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 !!!"
exit 1
fi
2022-10-12 09:02:49 +00:00
2023-01-13 09:55:21 +00:00
cp release/$syspath/$cpu/libsane-"$oem"sane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-"$oem"sane.so.1
if [ $? -ne 0 ];then
echo "copy libsane file fail !!!"
exit 1
fi
2023-01-13 07:36:32 +00:00
2023-01-13 09:55:21 +00:00
#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
2022-10-12 09:02:49 +00:00
2023-01-13 09:55:21 +00:00
cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane/libsane-lscsane.so.1
if [ $? -ne 0 ];then
echo "copy mips64el libsane file fail !!!"
exit 1
2022-10-12 09:02:49 +00:00
fi
2023-01-13 09:55:21 +00:00
fi
else
echo "del sane file fail"
exit 1
fi
2022-10-12 09:02:49 +00:00
2023-01-13 09:55:21 +00:00
#立思辰涉密系统打包,暂时先这样
if [ "$oem" == "lscsm" ];
then
cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/$libpath/sane/libsane-lscsane.so.1
if [ "$cpu" == "mips64" ];
then
cp release/$syspath/$cpu/libsane-lscsane.so dpkg/$syspath/$oem/usr/lib/"mips64el-linux-gunabi64"/sane/libsane-lscsane.so.1
2022-10-12 09:02:49 +00:00
fi
2023-01-13 09:55:21 +00:00
2022-07-29 09:28:21 +00:00
fi
2022-11-15 03:27:31 +00:00
if [ "$oem" == "lscweb" ] || [ "$oem" == "hwweb" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "ctsweb" ]; then
2022-11-02 08:06:47 +00:00
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/bin
2022-11-15 03:27:31 +00:00
elif [ "$oem" == "hgso" ] || [ "$oem" == "hwso" ] || [ "$oem" == "lscso" ] || [ "$oem" == "ctso" ];then
2022-11-02 08:06:47 +00:00
cp -rf release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath/lib
2022-09-30 03:01:17 +00:00
cp sdk/include/scannerlib/* dpkg/$syspath/$oem/opt/$dpkgpath/include
2022-09-28 07:37:01 +00:00
rm dpkg/$syspath/$oem/opt/$dpkgpath/lib/*Scan
2022-09-28 07:15:38 +00:00
rm dpkg/$syspath/$oem/opt/$dpkgpath/lib/*App
2022-09-30 03:01:17 +00:00
elif [ "$oem" == "lscsm" ];then
cp release/$syspath/$cpu/* dpkg/$syspath/$oem/opt/$dpkgpath
else
2023-01-13 09:55:21 +00:00
if [ "$sys" == "UnionTech" ];
then
#替换uos里面的info 虽然不晓得有啥用
appid='"appid":''"'$dpkgpath'"'','
InfoArch='"arch":[''"'$dpkgarch'"']','
version='"name":''"'$ver'"'','
name='"name":''"'$oem'"'','
sed -i "5s/.*/ $InfoArch/g" dpkg/$syspath/$oem/opt/apps/$dpkgpath/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
2022-09-28 07:15:38 +00:00
else
2023-01-13 09:55:21 +00:00
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
2022-07-04 01:48:13 +00:00
fi
2022-08-08 02:10:02 +00:00
fi
2023-01-13 09:55:21 +00:00
if [ $? != 0 ];
then
2022-10-10 08:04:57 +00:00
echo "-----------------cp fail-----------------"
2022-10-10 08:04:30 +00:00
exit 1
fi
2022-08-08 02:36:30 +00:00
pwd
2022-07-04 08:31:52 +00:00
2022-07-04 01:48:13 +00:00
chmod 755 dpkg -R
chmod 755 backup -R
2023-01-13 09:55:21 +00:00
if [ -d "backup/$syspath/$oem/$ver" ];
then
2022-07-04 01:48:13 +00:00
rm -rf backup/$syspath/$oem/$ver
fi
2023-01-13 09:55:21 +00:00
if [ ! -d "backup/$syspath/$oem/$ver" ];
then
2022-07-04 01:48:13 +00:00
mkdir -p backup/$syspath/$oem/$ver
fi
cp -rf dpkg/$syspath/$oem/* backup/$syspath/$oem/$ver
2022-09-28 08:54:15 +00:00
path=""
2023-01-13 09:55:21 +00:00
if [ "$oem" == "hg" ] || [ "$oem" == "hgweb" ] || [ "$oem" == "hgso" ];
then
2022-09-28 08:54:15 +00:00
dpkgtype="hg"
2023-01-13 09:55:21 +00:00
elif [ "$oem" == "lsc" ] || [ "$oem" == "lscweb" ] || [ "$oem" == "lscso" ] || [ "$oem" == "lscsm" ];
then
2022-09-28 08:54:15 +00:00
dpkgtype="lsc"
2023-01-13 09:55:21 +00:00
elif [ "$oem" == "cts" ] || [ "$oem" == "ctsweb" ] || [ "$oem" == "ctsso" ];
then
2022-11-15 03:27:31 +00:00
dpkgtype="cts"
2022-09-28 08:21:18 +00:00
else
2022-09-28 08:54:15 +00:00
dpkgtype="hw"
2022-11-15 03:27:31 +00:00
fi
2023-01-13 09:55:21 +00:00
if [ ! -d "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype" ];
then
2022-09-28 08:54:15 +00:00
mkdir -p "backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/"
2022-09-28 08:21:18 +00:00
fi
2022-09-28 09:40:51 +00:00
2023-01-13 09:55:21 +00:00
dpkg -b backup/$syspath/$oem/$ver backup/dpkg/$mainverstr.$minver/$time2/$dpkgtype/$dpkgpath"_"$ver"_"$dpkgarch.deb
2022-09-28 09:40:51 +00:00
getismount
2023-01-13 09:55:21 +00:00
if [ $ismount == 0 ];
then
if [ -d "$FIND_FILE/$syspath" ];
then
2022-09-29 02:04:42 +00:00
echo "$(date):mount is succeed and cp dpkg"
2022-09-29 01:12:09 +00:00
echo $password|sudo -S cp -rf backup/dpkg/$mainverstr.$minver $FIND_FILE/$syspath
2022-09-28 09:40:51 +00:00
fi
fi