Created
May 14, 2012 18:17
-
-
Save jperras/2695461 to your computer and use it in GitHub Desktop.
For when you need to dive into a .deb and edit the control file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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 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