tools/sanitize-deb.sh (view raw)
1#!/bin/sh
2# Clean up the caveats that CPack leaves behind
3BINARY=mgba
4
5rmdep () {
6 local DEP=$1
7 echo Removing dependency $DEP
8 sed -i~ "s/[^, ]*$DEP[^,]*//g" deb-temp/DEBIAN/control
9}
10
11adddep() {
12 local DEP=$1
13 echo Adding dependency $DEP
14 sed -i~ "s/^Depends: /&$DEP,/" deb-temp/DEBIAN/control
15}
16
17while [ $# -gt 0 ]; do
18 DEB=$1
19 dpkg-deb -R $DEB deb-temp
20 PKG=`grep Package deb-temp/DEBIAN/control | cut -f2 -d ' '`
21 echo Found package $PKG
22
23 case $PKG in
24 *-base)
25 PKG=lib$BINARY
26 rmdep sdl
27 rmdep qt
28 ;;
29 *-qt)
30 PKG=$BINARY-qt
31 rmdep libav
32 rmdep libedit
33 rmdep libelf
34 rmdep libpng
35 rmdep libzip
36 rmdep libmagickwand
37 rmdep libsqlite3
38 rmdep libswresample
39 rmdep libswscale
40 rmdep zlib
41 adddep lib$BINARY
42 ;;
43 *-sdl)
44 PKG=$BINARY-sdl
45 rmdep libav
46 rmdep libedit
47 rmdep libelf
48 rmdep libpng
49 rmdep qt
50 rmdep libzip
51 rmdep libmagickwand
52 rmdep libsqlite3
53 rmdep libswresample
54 rmdep libswscale
55 rmdep zlib
56 adddep lib$BINARY
57 ;;
58 *)
59 echo Unknown package!
60 esac
61
62 sed -i~ "s/,,*/,/g" deb-temp/DEBIAN/control
63 sed -i~ "s/,$//g" deb-temp/DEBIAN/control
64 sed -i~ "/^[^:]*: $/d" deb-temp/DEBIAN/control
65 sed -i~ "s/^Package: .*$/Package: $PKG/" deb-temp/DEBIAN/control
66 rm deb-temp/DEBIAN/control~
67 chmod 644 deb-temp/DEBIAN/md5sums
68 chown -R root:root deb-temp
69 dpkg-deb -b deb-temp $PKG.deb
70 rm -rf deb-temp
71 shift
72done