Skip to content

Instantly share code, notes, and snippets.

@chetan
Created November 30, 2011 20:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save chetan/1410666 to your computer and use it in GitHub Desktop.
Save chetan/1410666 to your computer and use it in GitHub Desktop.
bash script for modifying .deb dependencies (debian control file)
#!/bin/bash
# usage: save as 'videbcontrol.sh'; chmod 755 videbcontrol.sh; ./videbcontrol.sh foo.deb
#
# from: http://ubuntuforums.org/showthread.php?t=636724
if [[ -z "$1" ]]; then
echo "Syntax: $0 debfile"
exit 1
fi
DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb
if [[ -e "$OUTPUT" ]]; then
echo "$OUTPUT exists."
rm -r "$TMPDIR"
exit 1
fi
dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN
if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
echo DEBIAN/control not found.
rm -r "$TMPDIR"
exit 1
fi
CONTROL="$TMPDIR"/DEBIAN/control
MOD=`stat -c "%y" "$CONTROL"`
vi "$CONTROL"
if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
echo Not modfied.
else
echo Building new deb...
dpkg -b "$TMPDIR" "$OUTPUT"
fi
rm -r "$TMPDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment