Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: Jason W on July 11, 2009, 11: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
-
Thanks for the handy script. I wonder if this could be used to install openoffice?
-
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.
-
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
#!/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?
-
Updated for tcz only and added some fixes.
-
Nice job, Jason !
It saved me a lot of pains . Thanks really !
~ Pats
-
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
-
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:
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
-
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.
-
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 :
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
-
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.
:)
-
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
rpm2cpio ../google-talkplugin_current_i386.rpm | cpio -id
rpm2cpio: invalid gzip magic
:(
-
It works for me on my box:
tc@box:~/Downloads$ rpm2cpio google-talkplugin_current_i386.rpm | cpio -id
35218 blocks
-
???
Jason, could you please try
busybox rpm2cpio google-talkplugin_current_i386.rpm | cpio -id
to exclude that in your case an executable independent of busybox is used?
-
It still works here:
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?
-
hi
Thanks for the script.
Any chance of making this a sticky?
-
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 .
-
dashism - did you make the file itself executable after downloading?
aus9 - thanks, but I think it is best left like it is.
-
of course yes .
I used #chmod +x deb2tc .
is there any extra information that I don't know ?
thanks
-
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.
-
Is there any particular reason you put it into /sbin ?
seems rather unorthodox to me... ::)
-
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
-
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.
-
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".
-
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.
-
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?
-
Hi coreplayer
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 ./
-
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..
-
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.
-
yes thanks I found that that was the issue already :D
-
I will give this script some attention in the near future.
-
Script has been updated and attached to the original post.
-
Wow, when you say near future you really mean it.
-
Wow that's cool. Thanks for the quick fix, I know others like me appreciate the effort Thanks
-
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
-
Works here.
Does the message "Install the squashfs-tools package before proceeding." still show up after
tce-load -i squashfs-tools.tcz
?
-
Works here.
Does the message "Install the squashfs-tools package before proceeding." still show up after
tce-load -i squashfs-tools.tcz
?
For me it didnt. The script worked without errors (and saved me from despair). Thanks to the author!
-
Can we download "steam" with this!?
-
hello, i know this chat is a long time ago but i can't seem to use the script
-
I updated the script with a few minor changes, it should work now:
#!/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
-
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.
#!/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!
-
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
-
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.
-
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