General TC > Programming & Scripting - Unofficial
Quick hack to convert Debian packages.
CentralWare:
Another update! :)
deb2tcz packagename[.deb] to convert DEB to TCZ
deb2tcz ~packagename[.deb] to DOWNLOAD package, then convert
There's a few TO-DO items noted within that haven't been completed.
--- Code: ---#!/bin/sh
#############################################################################
# Create TCZ extension from a Debian package # Original By: Jason_W #
# Usage: deb2tcz packagename.deb packaganame.tcz # Revision By: CentralWare #
#############################################################################
. /etc/init.d/tc-functions
HERE=`pwd`
#############################################################
## The first part of this extension is to allow the user ##
## to actually DOWNLOAD the package they're after based ##
## on the version of TCL they're running right now. As ##
## always, there are limitations and exceptions... ##
#############################################################
FILE=$1
if [ "${FILE:0:1}" == "~" ]; then
#####################################################
# We're going to use the tilde (~) to be our marker #
# telling our app we want to DOWNLOAD the package #
# ~filename.deb from the master debian repository. #
#####################################################
FILE=${FILE:1}; FILE=${FILE/.deb/}; FILE=$(echo $FILE)
INDEX=${FILE:0:1}; [ "${FILE:0:3}" == "lib" ] && INDEX=${FILE:0:4}
REPO="http://ftp.debian.org/debian/pool/main/${INDEX}/${FILE}/"
wget $REPO -q -O - | grep href | grep -v PARENT | grep -v .tar. > file.lst
cat file.lst | grep .deb > file.debs 2>/dev/null
cat file.lst | grep .dsc > file.dscs 2>/dev/null
cat file.debs | awk -Fhref '{print $2}' | awk -F\" '{print $2}' > debs 2>/dev/null
cat file.dscs | awk -Fhref '{print $2}' | awk -F\" '{print $2}' > dscs 2>/dev/null
rm ./file.lst -f; rm ./file.debs -f; rm ./file.dscs -f 2>/dev/null
test=$(cat debs)
if [ "${test}" == "" ]; then
echo "${RED}ERROR: ${YELLOW}Package ${CYAN}$FILE ${YELLOW}not found or error finding it${NORMAL}"
exit 1
fi
# Now, we need to determine which platform we're running on
case $(uname -r) in
*picore*) PLAT="armel" ;;
*picore64*) PLAT="arm64" ;;
*64*) PLAT="amd64" ;;
*) PLAT="i386" ;;
esac
cat debs | grep $PLAT > choices
CHOICES=$(cat choices)
if [ "${CHOICES}" == "" ]; then
echo "${RED}ERROR: ${YELLOW}Choices for the platform ${CYAN}${PLAT}${YELLOW} are unavailable${NORMAL}"
exit 1
fi
COUNT=1; echo; echo
for CHOICE in $CHOICES
do
[ ! "${CHOICE}" == "" ] && echo "${COUNT}. ${CHOICE}" && COUNT=$(expr $COUNT + 1)
done
echo -n "Selection: "; read SELECTION
[ "${SELECTION}" == "" ] && exit
COUNT=1
for CHOICE in $CHOICES
do
[ ! "${CHOICE}" == "" ] && [ "${COUNT}" == "${SELECTION}" ] && SELECT=$CHOICE
[ ! "${CHOICE}" == "" ] && COUNT=$(expr $COUNT + 1)
done
[ "${SELECT}" == "" ] && exit
echo; echo "Downloading $SELECT"
wget $REPO/$SELECT || exit 1
## CLEAN UP, YOU FILTHY PROGRAMMER... ##
rm choices -f 2>/dev/null
rm debs -f 2>/dev/null
rm dscs -f 2>/dev/null
## We should now have our PACKAGE; let's RE-RUN this app ##
ME=$(basename $0)
sh $HERE/$ME $SELECT
exit 0
fi
## Manage dependencies of this app ##
if [ ! "$(whoami)" == "root" ]; then
DEPS="findutils squashfs-tools"
for DEP in $DEPS
do
[ ! -d /tmp/tcloop/$DEP ] && tce-load -w $DEP && tce-load -i $DEP
[ ! -d /tmp/tcloop/$DEP ] && echo "${RED}Dependency error! ${YELLOW}Be sure you're running this app as TC${NORMAL}" && exit 1
done
fi
## Once dependencies are handled, let's run as root ##
if [ ! "$(whoami)" == "root" ]; then
ME=$(basename $0)
sudo sh $HERE/$ME $@
exit 0
fi
make_tcz() {
echo "${WHITE}Extracting ${CYAN}$FILE${NORMAL}"
# ar t "$HERE/$FILE"
DEST2="${DEST}2" && mkdir -p $DEST2
cd $DEST2
ar p "$HERE/$FILE" control.tar.xz > control.tar.xz
tar -xf control.tar.xz
rm control.tar.xz -f
cd $DEST
ar p "$HERE/$FILE" data.tar.xz > data.tar.xz
tar -xf data.tar.xz
rm data.tar.xz -f
[ -d "$DEST"/usr/share/doc ] && rm -r "$DEST"/usr/share/doc
[ -d "$DEST"/usr/share/man ] && rm -r "$DEST"/usr/share/man
[ -d "$DEST"/usr/share/menu ] && rm -r "$DEST"/usr/share/menu
find . -type d -empty | xargs rmdir > /dev/null 2>&1
cd $TMP
mksquashfs ${FILE/.deb/} "$HERE"/"$APPNAME" -noappend >/dev/null 2>&1
###########
### TO DO ###
##########################################################################
# Using DEST2/control create a new APPNAME.tcz.info file from that data #
# Using DEST2/control create a new APPNAME.tcz.dep file from that data #
# Create APPNAME.tcz.md5.txt and APPNAME.tcz.list from our local files #
##########################################################################
}
FILE="$1"; APPNAME="$2"
FILE=${FILE/.deb/}; FILE=$(echo $FILE)
[ "$APPNAME" == "" ] && APPNAME=$FILE; APPNAME=${APPNAME/.tcz/}; APPNAME=$(echo $APPNAME)
if [ -z "$FILE" ]; then
echo "You must specify a Debian package name"
echo "${YELLOW}$(basename $0) ${CYAN}packagename[.deb] to convert DEB to TCZ${NORMAL}"
echo "${YELLOW}$(basename $0) ${MAGENTA}~${CYAN}packagename[.deb] to DOWNLOAD package, then convert${NORMAL}"
exit 1
fi
TMP="/tmp/deb2tcz" && mkdir -p $TMP
DEST=$TMP/${FILE} && mkdir -p $DEST && rm $DEST -fR && mkdir -p $DEST
sudo chown tc:staff $DEST -fR && sudo chmod 777 $DEST
FILE="${FILE}.deb"; APPNAME="${APPNAME}.tcz"
echo "Debian File: $FILE"
echo "Target File: $APPNAME"
make_tcz
[ -d $TMP ] && sudo rm $TMP -fR
--- End code ---
EXAMPLE: deb2tcz ~mc
The tilde ( ~ ) informs the app you want to download "mc" and then convert it.
Once entered, it opens the repository and finds "mc" and all of the releases it has are displayed -- you select which one you want and voila'... TCZ extension built!
socks:
I tried to download Jason's version of deb2tcz from the post#1.
The browser complains that its an insecure process.
I respond ' do it anyway' but download fails.
I wonder where/what the problem is ?
I was able to copy/paste the latter versions further down the thread.
Thanks to everyone for their work
Sean
Rich:
Hi socks
It downloaded just fine for me (Firefox 115.4.0esr).
--- Quote from: socks on April 26, 2024, 08:50:19 PM --- ... The browser complains that its an insecure process. ...
--- End quote ---
Are you connecting to the forum with:
http://forum.tinycorelinux.net
or with:
https://forum.tinycorelinux.net ?
You should be using the second one.
socks:
Hi Rich
You were right about my lack of on 's' in the forum bookmark URL.
My collection of bookmarks will have been copied over to new contexts many time since I first added the TC forum and I have a 'if works OK don't fix it' approach to most things.
I just tried the link and it works fine now.
Sean
Navigation
[0] Message Index
[*] Previous page
Go to full version