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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#!/bin/bash
# copyright (c) 2006 Jon Dowland <jon@alcopop.org>
# distributed under the terms of the GNU Public Licence (GPL) v2 -
# see /usr/share/common-licenses/GPL-2 for details.
set -e
# doom-package: manage installation of doom2 IWAD into a debian system:
# take the dummy doom2-wad .deb and insert the real IWAD.
# saves the resulting .deb in the current directory
DATADIR="usr/share/games/doom-package"
DEB="/$DATADIR/doom2-wad_5_all.deb"
die() {
if [ -n "$2" ]; then RET=$2
else RET=1
fi
echo $0: "$1" >&2
exit $RET
}
# takes one argument: the doom2.wad file
if [ -z "$1" -o ! -e "$1" ]; then
diemsg="usage:
make-wad-package /path/to/doom2.wad
Generates a .deb package for the doom2 IWAD file specified
on the command line."
[ -e "$1" ] || echo " $1 does not appear to exist"
die "$diemsg"
fi
IWAD="$1"
# only supports `doom2.wad' so far
tmp=$(basename $IWAD)
[ "doom2.wad" = "$tmp" ] ||\
[ "DOOM2.WAD" = "$tmp" ] ||\
die "supplied IWAD must be called doom2.wad."
xOLDPWD="$(pwd)"
WORKDIR=$(mktemp -dt make-wad-package.XXXXXX) ||\
die "error creating a working directory."
(
set -e
cp "$DEB" "$WORKDIR"
cp "$IWAD" "$WORKDIR/doom2.wad"
cd "$WORKDIR"
DEB=$(basename "$DEB")
IWAD=doom2.wad
chmod 644 "$IWAD"
#
# slipstream(deb,iwad)
# takes the .deb file and inserts the .wad into place
#
slipstream() {
DEB="$1"
IWAD="$2"
[ -w "$DEB" ] || (
ls -l "$DEB"
die "wrong permissions on $DEB"
)
[ -r "$IWAD" ] || die "wrong permissions on $IWAD"
[ -w . ] || die "cannot write to $PWD"
# unpack the .deb and stick the new IWAD in
dpkg-deb -e "$DEB" "DEBIAN"
dpkg-deb -x "$DEB" "foo"
mv -f "$IWAD" "./foo/$DATADIR"
# add a line to md5sums
cd "./foo"
md5sum "$DATADIR/$IWAD" >> "../DEBIAN/md5sums"
cd ..
# figure out the new installed-size
set -- $(du -sk foo)
INSTSIZE=$1
sed -i "s/^Installed-Size.*/Installed-Size: $INSTSIZE/" \
"DEBIAN/control"
# repack
mv DEBIAN foo
fakeroot dpkg-deb -b foo "$DEB"
}
slipstream "$DEB" "$IWAD"
cp -a "$DEB" "$xOLDPWD"
)
RET=$?
rm -rf "$WORKDIR"
[ $RET -eq 0 ] || die "subshell exited abnormally" $RET
|