-
Notifications
You must be signed in to change notification settings - Fork 12
/
deb.sh
executable file
·46 lines (42 loc) · 1.29 KB
/
deb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
#
# author:李玉江<[email protected]>
#
# 切换到当前脚本所在的目录
echo "之前工作目录:${PWD}"
_CURRENT_FILE="${BASH_SOURCE[0]}"
_DIR_NAME="$(dirname "${_CURRENT_FILE}")"
echo "当前脚本路径:${_CURRENT_FILE}"
echo "脚本目录路径:${_DIR_NAME}"
cd "${_DIR_NAME}" || exit
echo "当前工作目录:${PWD}"
_DEB="out/ApkDecompiler.deb"
_DIST="dist/"
function extractDeb() {
echo "解开deb包到${_DIST}"
# dpkg --help
# 将deb包中的文件解压到指定的目录下
dpkg --vextract ${_DEB} ${_DIST}
# 将deb包中的控制信息解压到指定的目录下
dpkg --control ${_DEB} ${_DIST}DEBIAN/
echo "deb包${_DEB}解开到${_DIST}结束"
}
function builddDeb() {
chmod -R 0755 ${_DIST}DEBIAN
# dpkg-deb --help
# 将指定的目录下的所有文件打包为deb格式的文件
dpkg-deb --build ${_DIST} ${_DEB}
echo "从${_DIST}构建deb包为${_DEB}结束"
}
if [[ $1 == "--extract" || $1 == "-e" ]]; then
extractDeb
elif [[ $1 == "--build" || $1 == "-b" ]]; then
builddDeb
else
echo ""
echo "======================================="
echo "使用说明:./deb.sh <option>"
echo "打包:./deb.sh -b 或 ./deb.sh --build"
echo "解包:./deb.sh -e 或 ./deb.sh --extract"
echo "======================================="
fi