måndag 16 februari 2015

Linux - Bash .sh Easily modify dependencies of a .deb file

#!/bin/bashEDITOR=geditif [[ -z "$1" ]]; then  echo "Syntax: $0 debfile"  exit 1fiDEBFILE="$1"TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1OUTPUT=`basename "$DEBFILE" .deb`.modfied.debif [[ -e "$OUTPUT" ]]; then  echo "$OUTPUT exists."  rm -r "$TMPDIR"  exit 1fidpkg-deb -x "$DEBFILE" "$TMPDIR"dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIANif [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then  echo DEBIAN/control not found.  rm -r "$TMPDIR"  exit 1fiCONTROL="$TMPDIR"/DEBIAN/controlMOD=`stat -c "%y" "$CONTROL"`$EDITOR "$CONTROL"if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then  echo Not modfied.else  echo Building new deb...  dpkg -b "$TMPDIR" "$OUTPUT"firm -r "$TMPDIR"
Skicka en kommentar