Tiny Core Linux

General TC => Programming & Scripting - Unofficial => Topic started by: Jason W on July 11, 2009, 08:22:58 PM

Title: Quick hack to convert Debian packages.
Post by: Jason W on July 11, 2009, 08:22:58 PM
This may come in handy for grabbing a .deb and making it into a tce/tcz.  This is a tool for personal means of easily installing debs as tce/tcz, it is not meant as a way to create submittable extensions.
Example:  Save script as deb2tc, make executable.  Then:

deb2tc emelfm_0.9.2-8_i386.deb emelfm.tcz

Will place emelfm.tcz in your home directory.

Depends: squashfs-tools, findutils

Script is attached.

Download the script, then enter the directory where you have the script.  Also have your .deb package in the same directory.

Then enter these commands, without the #, and run as root:

#chmod a+x deb2tcz
#./deb2tcz package.deb package.tcz
Title: Re: Quick hack to convert Debian packages.
Post by: bigpcman on July 13, 2009, 04:49:53 PM
Thanks for the handy script. I wonder if this could be used to install openoffice?
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on July 13, 2009, 06:43:19 PM
I had small things in mind like libdvdcss for Xine, but the openoffice debs would get converted.  But getting such a big and complex set of packages made for another distro to work on TC could be a challenge.
Title: Re: Quick hack to convert Debian packages.
Post by: bigpcman on October 07, 2009, 06:35:42 PM
This may come in handy for grabbing a .deb and making it into a tce/tcz.  This is a tool for personal means of easily installing debs as tce/tcz, it is not meant as a way to create submittable extensions.
Example:  Save script as deb2tc, make executable.  Then:

deb2tc emelfm_0.9.2-8_i386.deb emelfm.tcz

Will place emelfm.tcz in your home directory.

Depends: squashfs-tools

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


TMP1="`mktemp -d /tmp/tce.1.XXXXXX`"
TMP2="$TMP1"/pkg
FILE="$1"
APPNAME="$2"
INPUT=${FILE##*.}

make_tce() {
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
find `ls` -not -type d > "$TMP1"/list
tar -T "$TMP1"/list -czvf /home/"$USER"/"$APPNAME"
cd
rm -r "$TMP1"
}

make_tcz() {
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
mksquashfs "$TMP2" /home/"$USER"/"$APPNAME"
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


Does this still work in tc2.4rc5?
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on October 18, 2009, 04:44:53 AM
Updated for tcz only and added some fixes.
Title: Re: Quick hack to convert Debian packages.
Post by: Pats on March 20, 2010, 12:39:41 AM
Nice job,  Jason !
It saved me a lot of pains . Thanks really !

~ Pats
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on March 20, 2010, 06:52:10 AM
Rpms are easy to convert as well.  I will use RealPlayer.rpm as an example.  In the directory you have the rpm, do this:

mkdir directory
cd directory
rpm2cpio ../Realplayer.rpm | cpio -id
cd ..
mksqashfs directory realplayer.tcz

Title: Re: Quick hack to convert Debian packages.
Post by: Pats on March 20, 2010, 07:51:50 AM
I successfully converted simple apps like joe and other 4/5 from .deb to .tcz and an old version of gcc from here:
http://ftp.jp.debian.org/debian/pool/main/g/gcc-3.4/gcc-3.4_3.4.6-5_i386.deb

to .tcz. All works fine ! Marvelous !

But:
Quote
rpm2cpio ../Realplayer.rpm | cpio -id

Sorry for my limited IQ, but from where can I get this rpm2cpio script ? Should I make the relevent changes in the script myself to accomodate rpm routine ?

Secondly, although I have not tried deb2tcz on the very latest and complex .debs like Opera or Firefox or even emacs - can you tell me - your scripts limitations on the higher side ?

Thirdly, you have said that this script should not be used to submit any deb to tcz converted extension to the repo. How can you know if someone has already used it for such a submision or will be used for it ?

~ Pats
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on March 20, 2010, 08:58:55 AM
rpm2cpio is an executable in base.

As for complexity, converting any other distros packages is simply converting a package format of a single package.  Things like dependencies are not accounted for.  With big or complex packages, a lot could be missing for it to run on TC, the error output would indicate what.  In general the conversion routine was meant for small and simple packages for quick use.

As for how folks have made packages for the repo, there is a degree of trust involved, as with anything.
Title: Re: Quick hack to convert Debian packages.
Post by: Pats on March 21, 2010, 04:24:26 AM
Thnks for teaching me, how to fish -  while converting debs and rpms to tczs !
This will be helpful to me a lot whenever I need some older versions of a
package or a very recent version - which is not available in the repo.

By the way - while doing this rpm2tcz conversion, I got this permision
error :
Code: [Select]
tc@box:~/d1$  rpm2cpio ../tar-1.13.19-4.i386.rpm | cpio -id
cpio: cannot create symlink from ./bin/gtar to tar: Operation not permitted
1401 blocks

( I tried the same command pre-pending `sudo` to it, but the same error. I
do not know, why ! ) But anyhow, the resultant tcz was working OK !

Then I tried something more bigger, converted following (older, stock rpms
from the RH CD):

emacs-20.7-34.i386.rpm
emacs-X11-20.7-34.i386.rpm
emacs-el-20.7-34.i386.rpm
emacs-leim-20.7-34.i386.rpm
emacs-nox-20.7-34.i386.rpm

And frankly, I was NOT expecting any success, but again the resultant tczs
are working seamlessly OK !
Thouhgt, I should give the success-feedback to you - in anticipation ! So if
any newbees are interested in this rpm2tcz conversion - this may be helpful
!
( My next target is experimenting with Firefox and Xorg 7.5 ...)  :|))

Thnks again !

~ Pats
Title: Re: Quick hack to convert Debian packages.
Post by: sbaguz on May 10, 2010, 01:14:26 AM
Thanks a lot Jason!
This is a really great tool I would add by default to any Tiny Core release.
It works like a charm: please, keep it always updated to follow TC new versions.

 :)
Title: Re: Quick hack to convert Debian packages.
Post by: tinypoodle on September 11, 2010, 09:08:29 AM
Rpms are easy to convert as well.  I will use RealPlayer.rpm as an example.  In the directory you have the rpm, do this:

mkdir directory
cd directory
rpm2cpio ../Realplayer.rpm | cpio -id
cd ..
mksqashfs directory realplayer.tcz


Code: [Select]
rpm2cpio ../google-talkplugin_current_i386.rpm  | cpio -id
rpm2cpio: invalid gzip magic
:(
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on September 11, 2010, 01:02:44 PM
It works for me on my box:


Code: [Select]
tc@box:~/Downloads$ rpm2cpio google-talkplugin_current_i386.rpm | cpio -id
35218 blocks
Title: Re: Quick hack to convert Debian packages.
Post by: tinypoodle on September 11, 2010, 03:52:13 PM
 ???

Jason, could you please try
Code: [Select]
busybox rpm2cpio google-talkplugin_current_i386.rpm | cpio -id
to exclude that in your case an executable independent of busybox is used?
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on September 11, 2010, 07:03:13 PM
It still works here:

Code: [Select]
tc@box:~/Downloads/1$ busybox rpm2cpio ../google-talkplugin_current_i386.rpm | c
pio -id
35218 blocks
tc@box:~/Downloads/1$

maybe you have a corrupt or partially downloaded google-talkplugin_current_i386.rpm?
Title: Re: Quick hack to convert Debian packages.
Post by: aus9 on September 11, 2010, 10:36:28 PM
hi

Thanks for the script.

Any chance of making this a sticky?
Title: Re: Quick hack to convert Debian packages.
Post by: dashism on September 12, 2010, 02:43:51 AM
thanks for the script
but when i try to use it Iface with this error : "sh: deb2tc: not found!" :o
I added the executable file to /sbin folder but error exist.
any help will be appreciated .
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on September 12, 2010, 03:37:34 AM
dashism - did you make the file itself executable after downloading?

aus9 - thanks, but I think it is best left like it is.
Title: Re: Quick hack to convert Debian packages.
Post by: dashism on September 12, 2010, 04:11:50 AM
of course yes .
 I used  #chmod +x deb2tc .
is there any extra information that I don't know ?
thanks

Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on September 12, 2010, 05:56:22 AM
Only other thing I can think of is to make sure #!/bin/sh is on the first line and not below it.  I corrected the  quoted script as there was a space there, which would cause issue if that space was copied.
Title: Re: Quick hack to convert Debian packages.
Post by: tinypoodle on September 12, 2010, 12:06:05 PM
Is there any particular reason you put it into /sbin ?
seems rather unorthodox to me...   ::)
Title: Re: Quick hack to convert Debian packages.
Post by: dashism on September 12, 2010, 11:08:32 PM
no , but when I tried to use it in a directory I experience the same problem so I put it into /sbin .
If you know another or the correct way to use this executable file please help me . ;)
I also solved my problem to some extend by using the .rpm version of the package and converting it to .tcz .
thanks
Title: Re: Quick hack to convert Debian packages.
Post by: pix on December 02, 2010, 05:51:27 AM
Thank you for this amazing tip! I have been looking enviously at Tinycore for a little while now, trying to decide how I can use it at home. I'm looking to build a home server project and eventually my desktop on Tinycore. A modular OS is what I have craved since I was 12 years old and BARTPE NEARLY gave me what I was looking for, but tincore should produce something even better with a smaller footprint!!! With v3.3 released and looking good, this tip to import addiitional software may be enough! :)

Thank you again.

Title: Re: Quick hack to convert Debian packages.
Post by: SamK on December 29, 2010, 03:43:14 AM
Don't know if you're already aware of this one, so just in case...

Without modification, the script fails when used with TC3 as it requires "squashfs-tools-4.0".  In the TC3 repo this is named "squashfs-tools-4.x.tcz".
   
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on December 29, 2010, 06:45:57 AM
Thanks.  I will use a check like "which mksquashfs" instead of looking for a specific extension name so the eventual move to squashfs-tools 5.x won't break it again.
Title: Re: Quick hack to convert Debian packages.
Post by: coreplayer on June 08, 2011, 08:37:32 PM
This is so cool however I just wish there was less guessing at each step..

I'm a newbie here and need a little guidance?

First created the blank file in the same directory as the deb file to be converted. next copied the script into it and named it deb2tc

opened a terminal window at this location and you guessed it:  ERROR file not found

ok a ton of reading later and placed the script file in /bin

Error do not run as root..   

ok who would have thought!  oh well opened a terminal as user and all is well

so the first two hurdles "Filed not found" and "do not run as root"

next problem; 

Error  Install squashfs-tools-4.0 before proceeding :(

How can this be?  I mean the extension was installed prior to running the script. 

squashfs-tools-4.0 was installed as "On-Boot"  and rebooted earlier. 

If the ext is already installed why would I need to run install squashfs-tools-4.0 at the terminal?  I don't get it and am getting tired of feeling around in the dark..

So anyone what 's missing please?

 
Title: Re: Quick hack to convert Debian packages.
Post by: Rich on June 08, 2011, 09:58:58 PM
Hi coreplayer

Quote
First created the blank file in the same directory as the deb file to be converted. next copied the script into it and named it deb2tc

opened a terminal window at this location and you guessed it:  ERROR file not found

Try ./deb2tc and it will find it. If you want to execute a file in the directory you are in AND that directory
is not listed in the PATH variable then you need to precede the filename with  ./
Title: Re: Quick hack to convert Debian packages.
Post by: coreplayer on June 08, 2011, 10:10:47 PM
cool thanks for the tip.

Any assistance with the issue of "Install squashfs-tools-4.0 before proceeding "  ??  

Only thing I can see is the script call for version squashfs-tools-4.0  yet the version installed is "squashfs-tools-4.x"  maybe a co-coincidence?

Ok this was indeed the issue!!   project completed  phew!!  I could have done without that pita  hope I remember what i did the next time..
Title: Re: Quick hack to convert Debian packages.
Post by: jur on June 08, 2011, 10:16:24 PM
No, that's it - the squashfs-tools was 4.0 a while ago when that script was written, but is now changed to 4.x. So you need to find the code snippets containing 4.0 and change that to 4.x.
Title: Re: Quick hack to convert Debian packages.
Post by: coreplayer on June 08, 2011, 10:24:07 PM
yes thanks I found that that was the issue already :D
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on June 09, 2011, 04:02:16 PM
I will give this script some attention in the near future.
Title: Re: Quick hack to convert Debian packages.
Post by: Jason W on June 09, 2011, 05:39:26 PM
Script has been updated and attached to the original post.
Title: Re: Quick hack to convert Debian packages.
Post by: Rich on June 09, 2011, 06:05:49 PM
Wow, when you say near future you really mean it.
Title: Re: Quick hack to convert Debian packages.
Post by: coreplayer2 on June 09, 2011, 06:21:17 PM
Wow  that's cool.  Thanks for the quick fix, I know others like me appreciate the effort Thanks
Title: Re: Quick hack to convert Debian packages.
Post by: k318wilcoxa on August 16, 2016, 07: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
Title: Re: Quick hack to convert Debian packages.
Post by: Misalf on August 16, 2016, 07: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
?
Title: Re: Quick hack to convert Debian packages.
Post by: marttt on December 16, 2016, 02: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!
Title: Re: Quick hack to convert Debian packages.
Post by: xor on July 20, 2020, 10:13:48 AM
Can we download "steam" with this!?
Title: Re: Hack rapide pour convertir les paquets Debian.
Post by: Mathimino on June 15, 2021, 12:13:52 PM
hello, i know this chat is a long time ago but i can't seem to use the script