WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Quick hack to convert Debian packages.
« on: July 11, 2009, 07: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
« Last Edit: June 09, 2011, 04:41:36 PM by Jason W »

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Quick hack to convert Debian packages.
« Reply #1 on: July 13, 2009, 03:49:53 PM »
Thanks for the handy script. I wonder if this could be used to install openoffice?
big pc man

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #2 on: July 13, 2009, 05: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.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Quick hack to convert Debian packages.
« Reply #3 on: October 07, 2009, 05: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?
big pc man

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #4 on: October 18, 2009, 03:44:53 AM »
Updated for tcz only and added some fixes.

Offline Pats

  • Full Member
  • ***
  • Posts: 172
Re: Quick hack to convert Debian packages.
« Reply #5 on: March 19, 2010, 11:39:41 PM »
Nice job,  Jason !
It saved me a lot of pains . Thanks really !

~ Pats

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #6 on: March 20, 2010, 05: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


Offline Pats

  • Full Member
  • ***
  • Posts: 172
Re: Quick hack to convert Debian packages.
« Reply #7 on: March 20, 2010, 06: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

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #8 on: March 20, 2010, 07: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.

Offline Pats

  • Full Member
  • ***
  • Posts: 172
Re: Quick hack to convert Debian packages.
« Reply #9 on: March 21, 2010, 03: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

Offline sbaguz

  • Newbie
  • *
  • Posts: 18
    • Mio sito di cultura tradizionale giapponese
Re: Quick hack to convert Debian packages.
« Reply #10 on: May 10, 2010, 12: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.

 :)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3796
Re: Quick hack to convert Debian packages.
« Reply #11 on: September 11, 2010, 08: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
:(
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #12 on: September 11, 2010, 12: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

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3796
Re: Quick hack to convert Debian packages.
« Reply #13 on: September 11, 2010, 02: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?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 6996
Re: Quick hack to convert Debian packages.
« Reply #14 on: September 11, 2010, 06: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?