mgba/tools/sanitize-deb.sh

67 lines
1.4 KiB
Bash
Raw Normal View History

#!/bin/sh
# Clean up the caveats that CPack leaves behind
BINARY=mgba
rmdep () {
local DEP=$1
echo Removing dependency $DEP
sed -i~ "s/[^, ]*$DEP[^,]*//g" deb-temp/DEBIAN/control
}
adddep() {
local DEP=$1
echo Adding dependency $DEP
sed -i~ "s/^Depends: /&$DEP,/" deb-temp/DEBIAN/control
}
while [ $# -gt 0 ]; do
DEB=$1
dpkg-deb -R $DEB deb-temp
PKG=`head -n1 deb-temp/DEBIAN/control | cut -f2 -d ' '`
2018-05-06 06:31:45 +00:00
echo Found package $PKG
case $PKG in
2018-05-06 06:31:45 +00:00
*-base)
PKG=lib$BINARY
rmdep sdl
rmdep qt
;;
2018-05-06 06:31:45 +00:00
*-qt)
PKG=$BINARY-qt
rmdep libav
rmdep libedit
rmdep libpng
rmdep libzip
rmdep libmagickwand
rmdep libswscale
rmdep zlib
adddep lib$BINARY
;;
2018-05-06 06:31:45 +00:00
*-sdl)
PKG=$BINARY-sdl
rmdep libav
rmdep libedit
rmdep libpng
rmdep qt
rmdep libzip
rmdep libmagickwand
rmdep libswscale
rmdep zlib
adddep lib$BINARY
;;
*)
echo Unknown package!
esac
sed -i~ "s/,,*/,/g" deb-temp/DEBIAN/control
sed -i~ "s/,$//g" deb-temp/DEBIAN/control
sed -i~ "/^[^:]*: $/d" deb-temp/DEBIAN/control
2018-05-06 06:31:45 +00:00
sed -i~ "s/^Package: .*$/Package: $PKG/" deb-temp/DEBIAN/control
rm deb-temp/DEBIAN/control~
chmod 644 deb-temp/DEBIAN/md5sums
2015-07-28 08:15:48 +00:00
chown -R root:root deb-temp
2018-05-06 06:31:45 +00:00
dpkg-deb -b deb-temp $PKG.deb
rm -rf deb-temp
shift
done