Last active
January 8, 2017 21:02
-
-
Save sling00/9698a010cfa7df18cd9e2ebe992491f7 to your computer and use it in GitHub Desktop.
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 [ "$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