Skip to content

Instantly share code, notes, and snippets.

@CzBiX
Created March 4, 2017 11:10
Show Gist options
  • Save CzBiX/1ce5d8df91363cd48708b4c10652f9ba to your computer and use it in GitHub Desktop.
Save CzBiX/1ce5d8df91363cd48708b4c10652f9ba to your computer and use it in GitHub Desktop.
script to modify control file in deb.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo Use fakeroot to run this script.
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 -R "$DEBFILE" "$TMPDIR"
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-deb -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