Last active
January 3, 2022 11:55
-
-
Save nuxlli/ddd3fa2ceed7b2cecdd3 to your computer and use it in GitHub Desktop.
Convert debian package to tce/tcz package
This file contains 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 | |
# Create tce/tcz from Debian package | |
# Usage: $ scriptname packagename.deb packaganame.tce | |
# Depends: squashfs-tools, findutils, binutils | |
# References: | |
# - http://forum.tinycorelinux.net/index.php/topic,2325.msg12127.html | |
# - http://pastebin.com/ed5KSPsH | |
TMP1="`mktemp -d /tmp/tce.1.XXXXXX`" | |
TMP2="$TMP1"/pkg | |
FILE="$1" | |
APPNAME="$2" | |
INPUT=${FILE##*.} | |
extract() { | |
mkdir "$TMP2" | |
ar p "$FILE" data.tar.gz > "$TMP1"/data.tar.gz | |
tar xzvf "$TMP1"/data.tar.gz -C "$TMP2" | |
cd "$TMP2" | |
[ -d usr/share/doc ] && rm -r usr/share/doc | |
[ -d usr/share/man ] && rm -r usr/share/man | |
[ -d usr/share/menu ] && rm -r usr/share/menu | |
find . -type d -empty | xargs rmdir > /dev/null 2&>1 | |
} | |
make() { | |
extract | |
if [ "$1" == "tce" ]; then | |
find `ls` -not -type d > "$TMP1"/list | |
tar -T "$TMP1"/list -czvf /home/"$USER"/"$APPNAME" | |
else | |
mksquashfs "$TMP2" /home/"$USER"/"$APPNAME" | |
fi | |
cd | |
rm -r "$TMP1" | |
} | |
[ "$USER" == "root" ] && echo "Do not run as root." && exit 1 | |
[ -z "$APPNAME" ] && echo "You must specify an extension name." && exit 1 | |
[ -f /home/"$USER"/"$APPNAME" ] && echo "You have an existing extension in your \ | |
home directory, you need to move or delete it before trying again." && exit 1 | |
[ -z "$1" ] && echo "You must specify a file." | |
if [ ! "$INPUT" == "deb" ] ; then | |
echo "Only Debian packages work with this." | |
exit 1 | |
fi | |
EXT=${APPNAME##*.} | |
if [ `echo "$EXT" | grep "tce"` 2>/dev/null ]; then | |
make tce | |
elif [ `echo "$EXT" | grep "tcz"` 2>/dev/null ]; then | |
make tcz | |
else | |
echo "You need to specify either a tcz or tce for the output file." | |
exit 1 | |
fi | |
if [ -f /home/"$USER"/"$APPNAME" ]; then | |
echo "Success." | |
else | |
echo "Something went wrong." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i get this when i try to convert a .deb file to .tcz any idea what this could be?