打包解包脚本,需要安装 fakeroot
打包 ./
deb.sh ./xxx/
解包 ./
deb.sh ./xxx.deb
```shell
#!/bin/bash
set -eu -o pipefail
if [ -d "$1" ]; then
echo 'packing...'
name=$(< "$1/DEBIAN/control" grep Package | cut -d ' ' -f 2)
version=$(< "$1/DEBIAN/control" grep Version | cut -d ' ' -f 2)
arch=$(< "$1/DEBIAN/control" grep Architecture | cut -d ' ' -f 2)
fakeroot dpkg-deb -b -z9 "$1" "${name}-${version}_${arch}_p.deb"
echo "${name}-${version}_${arch}_p.deb"
elif [ -f "$1" ]; then
echo "unpacking..."
dpkg-deb -R "$1" "${1%.*}"
echo "${1%.*}"
else
echo "unsupported action"
fi
```