WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Quick hack to convert Debian packages.  (Read 61993 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Quick hack to convert Debian packages.
« Reply #30 on: June 09, 2011, 07:02:16 PM »
I will give this script some attention in the near future.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Quick hack to convert Debian packages.
« Reply #31 on: June 09, 2011, 08:39:26 PM »
Script has been updated and attached to the original post.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Quick hack to convert Debian packages.
« Reply #32 on: June 09, 2011, 09:05:49 PM »
Wow, when you say near future you really mean it.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Quick hack to convert Debian packages.
« Reply #33 on: June 09, 2011, 09:21:17 PM »
Wow  that's cool.  Thanks for the quick fix, I know others like me appreciate the effort Thanks

Offline k318wilcoxa

  • Newbie
  • *
  • Posts: 1
Re: Quick hack to convert Debian packages.
« Reply #34 on: August 16, 2016, 10:01:23 AM »
I'm having issues as well.. I know this post hasn't had activity in years. I'm new to TC. The script is also prompting for "Install the squashfs-tools" package?? I installed but still not moving forward?? Any help would be appreciated.

Thanks Abe

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Quick hack to convert Debian packages.
« Reply #35 on: August 16, 2016, 10:41:29 AM »
Works here.
Does the message "Install the squashfs-tools package before proceeding." still show up after
Code: [Select]
tce-load -i squashfs-tools.tcz
?
Download a copy and keep it handy: Core book ;)

Offline marttt

  • Newbie
  • *
  • Posts: 9
Re: Quick hack to convert Debian packages.
« Reply #36 on: December 16, 2016, 05:17:16 PM »
Works here.
Does the message "Install the squashfs-tools package before proceeding." still show up after
Code: [Select]
tce-load -i squashfs-tools.tcz
?
For me it didnt. The script worked without errors (and saved me from despair). Thanks to the author!

Offline xor

  • Hero Member
  • *****
  • Posts: 1268
Re: Quick hack to convert Debian packages.
« Reply #37 on: July 20, 2020, 01:13:48 PM »
Can we download "steam" with this!?

Offline Mathimino

  • Newbie
  • *
  • Posts: 1
Re: Hack rapide pour convertir les paquets Debian.
« Reply #38 on: June 15, 2021, 03:13:52 PM »
hello, i know this chat is a long time ago but i can't seem to use the script

Offline Green_goblin

  • Newbie
  • *
  • Posts: 6
Re: Quick hack to convert Debian packages.
« Reply #39 on: November 24, 2023, 05:20:10 PM »
I updated the script with a few minor changes, it should work now:

Code: [Select]
#!/bin/sh
# Create tce/tcz from Debian package
# Usage: $ deb2tcz packagename.deb packaganame.tcz

if [ `/usr/bin/id -u` -ne 0 ]; then
echo "Please run as root".
exit 1
fi

HERE=`pwd`
PKGDIR=/tmp/deb2tcz.1234
PKG="$PKGDIR"/pkg
FILE="$1"
APPNAME="$2"
INPUT=${FILE##*.}

[ -d "$PKGDIR" ] || mkdir -p "$PKGDIR"

make_tcz() {

mkdir -p "$PKG"
ar p "$FILE" data.tar.xz > "$PKGDIR"/data.tar.xz # unpack .deb
tar xf "$PKGDIR"/data.tar.xz -C "$PKG" # unpack .tar

[ -d "$PKG"/usr/share/doc ] && rm -r "$PKG"/usr/share/doc
[ -d "$PKG"/usr/share/man ] && rm -r "$PKG"/usr/share/man
[ -d "$PKG"/usr/share/menu ] && rm -r "$PKG"/usr/share/menu
cd "$PKG"
find . -type d -empty | xargs rmdir > /dev/null 2>&1
cd "$PKGDIR"
mksquashfs pkg "$HERE"/"$APPNAME" -noappend
cd "$HERE"
rm -r "$PKGDIR"
}



if [ ! -f /usr/local/tce.installed/findutils ]; then
echo "Install findutils.tcz before proceeding."
exit 1
fi

if [ ! `which mksquashfs` ]; then
echo "Install the squashfs-tools package before proceeding."
exit 1
fi



[ -z "$APPNAME" ] && echo "You must specify an extension name." && 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 "tcz"` 2>/dev/null ]; then
make_tcz
else
echo "You need to specify a tcz  for the output file."
exit 1
fi

if [ -f "$APPNAME" ]; then
echo "Success."
else
echo "Something went wrong."
fi

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 776
Re: Quick hack to convert Debian packages.
« Reply #40 on: February 11, 2024, 05:53:02 AM »
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: [Select]
#!/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

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!
« Last Edit: February 11, 2024, 05:54:46 AM by CentralWare »

Offline socks

  • Newbie
  • *
  • Posts: 15
Re: Quick hack to convert Debian packages.
« Reply #41 on: April 26, 2024, 08:50:19 PM »
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 

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Quick hack to convert Debian packages.
« Reply #42 on: April 26, 2024, 09:45:06 PM »
Hi socks
It downloaded just fine for me (Firefox 115.4.0esr).

... The browser complains that its an insecure process. ...
Are you connecting to the forum with:
http://forum.tinycorelinux.net
or with:
https://forum.tinycorelinux.net ?

You should be using the second one.

Offline socks

  • Newbie
  • *
  • Posts: 15
Re: Quick hack to convert Debian packages.
« Reply #43 on: May 17, 2024, 12:11:46 AM »
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