dpkg–命令
-c:顯示軟體包中的檔案列表;
-e:將主控資訊解壓;
-f:把欄位內容列印到標準輸出;
-x:將軟體包中的檔案釋放到指定目錄下;
-X:將軟體包中的檔案釋放到指定目錄下,並顯示釋放檔案的詳細過程;
-W:顯示軟體包的資訊;
-l:顯示軟體包的詳細資訊;
-R:提取控制資訊和存檔的清單檔案;
-b:建立debian軟體包。
整體檔案目錄架構
|----DEBIAN
|-------control #控制檔案
|-------preinst #安裝前執行 like shell
|-------postinst #安裝後執行 like shell
|-------copyright #版權
|----opt #放置程式碼編譯檔案 安裝deb包後會直接拷貝的目錄,根目錄開始
|----- sourceCode
|----lib #放置自啓動指令碼
|----- system
生成deb檔案,生成bin檔案,build.sh
#!/bin/bash
/usr/local/bin/pyinstaller web_start.py -F -p ./web/control -p ./web/service -p ./web/config -p ./web/database -p ./web/urls
version='1.0.0'
product='Web_NF1500'
git='50bddac381a9'
system='Ubuntu16.04'
time=`date +"%Y%m%d"`
deb_dir='/data/tiger/NF2000/DebBuild'
architecture=`arch`
#architecture='aarch64'
source_dir='/data/xxx/xxx'
if [ $? -ne 0 ];then
echo "Package backend fail"
else
mv ./dist/web_start ./
rm -rf ./build ./dist
echo "success"
fi
cd ../DebBuild/DEBIAN
mkdir -p $deb_dir/opt/swweb/upgrade/backend/data
mkdir -p $deb_dir/opt/web_config
cp -rf $source_dir/backend/data/* $deb_dir/opt/swweb/upgrade/backend/data
cp -rf $source_dir/backend/data/web_config/* $deb_dir/opt/web_config
cp -rf $source_dir/backend/data_bak/* $deb_dir/opt/swweb/upgrade/backend/data
cp -rf $source_dir/backend/web_start $deb_dir/opt/swweb/upgrade/backend
#cp -rf $source_dir/frontend $deb_dir/opt/swweb/upgrade
sed -i "s/VERSION/${version}/g" ${deb_dir}/DEBIAN/control
#version='aarch64'
#if [ $version == 'x86_64' ];then
# cp ../config/amd64.control ./control
#elif [ $version == 'aarch64' ];then
# cp ../config/arm64.control ./control
#else
# echo 'success'
#fi
#make -f Makefile.builddeb
cd ../../
filename=$product'_V'$version'_'$architecture'_'$system'_'$time'_Git'$git.deb
dpkg-deb -b DebBuild/ $filename
if [ $? -ne 0 ];then
echo "Package web install deb file fail"
else
rm -rf ./DebBuild/opt
echo "Package web install deb file success"
fi
mv ./$filename ./backend/install/source_install/swweb
cd ./backend/install
./build_bin.sh $version $git
生成.bin檔案
#!/bin/sh -e
version=$1
if [ ! $version ]; then
echo 'Please enter version info'
exit -1
fi
git_version=$2
if [ ! $git_version ] ; then
echo 'Please enter git version'
exit -1
fi
#rm source_install.tar
tar -zcf source_install.tar ./source_install
build_exe(){
architecture=`arch`
time=`date +"%Y%m%d"`
md5_source=$(md5sum source_install.tar | awk '{print $1}')
file_name=SM_Web_V${version}_${architecture}_Ubuntu16.04_${time}_Git${git_version}.bin
sed -e "s/%%source_md5%%/$md5_source/" ./install.sh >$file_name
#將bin檔案執行指令碼打進去
cat source_install.tar >> ${file_name}
#生成bin檔案
chmod +x ${file_name}
echo 'Source md5 : ' $md5_source
echo 'New install bin file generated:' ${file_name}
}
if [ $? -ne 0 ];then
echo "Package backend fail"
else
build_exe
fi
bin安裝執行指令碼
#!/bin/sh -e
outname=`pwd`
tail -n +70 $0 > $outname/source_install.tar
source_md5=%%source_md5%%
echo 'Source md5 : ' $source_md5
md5_source=`md5sum source_install.tar | awk '{ print $1 }'`
if [ $md5_source != $source_md5 ];then
echo
echo ">>>ERROR: Unable to verify source archive checksum"
echo ">>>Expected: $md5_source"
echo ">>>Found : $source_md5"
exit 1
else
echo "Md5 verify pass!"
fi
echo 'Unzip sfweb dependences'
tar -xvf source_install.tar >/dev/nul
cd ./source_install/sfweb_dependence
#install ntp for web sync date time
echo 'Install sfweb dependence ntp'
dpkg -i ntp_*.deb
echo 'Install sfweb dependence ntpdate'
dpkg -i ntpdate*.deb
#install nginx for web to manager port
#stop sfrest to release port(for old version)
systemctl stop sfrest
echo 'Install nginx depends'
dpkg -i liblua*.deb
dpkg -i libgeoip1_*.deb
echo 'Install nginx common module'
dpkg -i nginx-common*.deb
cp nginx.conf /etc/nginx/
cp MyCompanyLocalhost.cer /etc/nginx
cp MyCompanyLocalhost.pvk /etc/nginx
cp default /etc/nginx/sites-enabled
echo 'Install nginx core module'
dpkg -i nginx-core*.deb
echo 'Install nginx '
dpkg -i nginx_*.deb
echo 'Install nginx success'
systemctl start sfrest
#install web server
cd ../sfweb
echo 'install sfweb server'
dpkg -i Web_*.deb
#copy uninstall file to /opt/uninstall
#rm -rf /opt/uninstall
if [ ! -d "/opt/uninstall" ];then
mkdir /opt/uninstall
fi
cp ../web_uninstall.sh /opt/uninstall
echo 'Web uninstall file install to /opt/uninstall'
echo 'Clear install source file'
rm -rf $outname/source_install*
echo ‘Install complete!’
exit 0