Skip to content

Instantly share code, notes, and snippets.

@devbug
Created July 6, 2015 15:37
Show Gist options
  • Save devbug/0a9b936ca3c173c2bf55 to your computer and use it in GitHub Desktop.
Save devbug/0a9b936ca3c173c2bf55 to your computer and use it in GitHub Desktop.
Back up deb file from installed package
#!/usr/bin/env bash
#ref: http://www.jailbreakqa.com/questions/117086/create-deb-from-installed-package-no-longer-available-in-cydia
package="$1"
if [ ! "$package" ]
then
echo "Usage: $0 package"
exit 1
fi
if ! control="$(dpkg -p "$package" 2> /dev/null)"
then
echo "Package not found: $package"
exit 1
fi
dir="$(mktemp -d)"
cd "$dir"
mkdir "DEBIAN"
echo "$control
" > "DEBIAN/control"
for f in $(dpkg -L "$package")
do
if [ -d "$f" ]
then
mkdir -p "./$f"
elif [ -f "$f" ]
then
cp "$f" "./$f"
fi
done
deb="/var/mobile/Documents/$package.deb"
dpkg -b . "$deb" &> /dev/null
rm -rf "$dir"
if [ -e "$deb" ]
then
echo "Saved deb to: $deb"
else
echo "Failed to save: $package"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment