public
Created

Script to change .deb control file and repackage

  • Download Gist
videbcontrol.sh
Shell
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
#!/bin/bash
 
# Change .deb control file and repackage
# credits Loevborg http://ubuntuforums.org/showthread.php?t=636724&p=3925729#post3925729
 
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`.modified.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 modified.
else
echo Building new deb...
dpkg -b "$TMPDIR" "$OUTPUT"
fi
 
rm -r "$TMPDIR"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.