Skip to content

Instantly share code, notes, and snippets.

@sling00
Last active January 8, 2017 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sling00/9698a010cfa7df18cd9e2ebe992491f7 to your computer and use it in GitHub Desktop.
Save sling00/9698a010cfa7df18cd9e2ebe992491f7 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$1" = "extractall" ]; then
for f in `ls *.deb`; do
FOLDER=$(echo "$f" | sed 's/.deb//g' )
echo $FOLDER
mkdir -p $FOLDER/DEBIAN
dpkg -x $f $FOLDER
dpkg -e $f $FOLDER/DEBIAN
done
elif [ "$1" = "extract" ]; then
ISPACKAGE=$(echo "$2" grep -c ".deb" )
if [ ! -z "$2" ] && [ "$ISPACKAGE" != "0" ]; then
for f in "$2"; do
FOLDER=$(echo "$f" | sed 's/.deb//g' )
echo $FOLDER
mkdir -p $FOLDER/DEBIAN
dpkg -x $f $FOLDER
dpkg -e $f $FOLDER/DEBIAN
done
elif [ -z "$2" ]; then
echo "Package filename required"
elif [ "$ISPACKAGE" = "0" ];then
echo "Specified filename \"$2\" is not a package"
fi
elif [ "$1" = "rebuild" ]; then
if [ ! -z "$2" ] && [ -d "$2" ];then
fakeroot dpkg-deb -b "$2"
fi
elif [ -z "$1" ] || [ "$1" = "help" ]; then
echo "Usage: pkgbuilder \<operation\> \"filename\""
echo ""
echo "Operations:"
echo "extract - extract a single .deb file to folder with the same name."
echo "extractall - extract all debs in working directory to folder of same name."
echo "rebuild - rebuild a package once you have finished modifying it."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment