Help - Search - Members - Calendar
Full Version: The End Of Ipkg-link(i Hope So :) )
OESF Forums > Distros, Development, and Model Specific Forums > Distro Support and Discussion > pdaXrom
urielka
CODE
#!/bin/sh

# klik wrapper 0.7.1
# by probono at myrealbox.com
# genericized - allows moving the AppDir around

APPNAME="okle"
SUBSTUSR=""
ARGS=""

######### there should be no need to edit below

# cd to the AppDir
DIRNAME=`cd \`dirname $0\` && pwd`
cd $DIRNAME

# our normal prefix
PRE="$DIRNAME/usr"

# link substitute for /usr in case we need it
if [ -n "$SUBSTUSR" ]
then
sudo ln -sf $PRE $SUBSTUSR
PRE="$SUBSTUSR"
fi

# determine whether we want to run in GUI mode
export GUIMODE=$(tty -s; echo $?)
# ( echo $GUIMODE | grep 1 >/dev/null ) # && echo "Running in GUI mode"

# determine DIALOG
if [ -z $DIALOG ]
then
dialog=Xdialog
pidof -x kdesktop >/dev/null && DIALOG=kdialog
pidof -x gnome-panel >/dev/null && DIALOG=zenity # if we are running GNOME
fi

# replace relative with absolute paths in command line arguments, thanks bfree
NEWCMD=$(perl -e '$newcmd=shift(@ARGV);foreach $arg (@ARGV){ @part=split(/\=/,$arg); foreach $part (@part){ (-e "$ENV{PWD}/$part") && ($part="$ENV{PWD}/$part");}$newcmd.=" ".join ("=",@part);} print "$newcmd";' $@)
set -- $NEWCMD

# set paths
export PATH=$DIRNAME/sbin:$DIRNAME/bin:$PRE/sbin:$PRE/bin:$PRE/X11R6/bin:$PRE/local/sbin:$PRE/local/bin:$PRE/games:$PATH
export LD_LIBRARY_PATH=$DIRNAME/lib:$PRE/lib/:$DIRNAME/opt/kde3/lib:$DIRNAME/usr/X11R6/lib/:$LD_LIBRARY_PATH

# support for KDE
export KDEDIRS=$PRE/:$KDEDIRS

# support for man pages (interpreted by KDE)
export MANPATH=$PRE/share/man:$PRE/X11R6/man:$MANPATH

# support for PYTHON
MYPYTHONPATH=$(find $PRE/lib/python2.3/site-packages/ -type d -printf %p: 2>/dev/null)
MYPYTHONPATH2=$(find $PRE/lib/python2.4/site-packages/ -type d -printf %p: 2>/dev/null)
export PYTHONPATH=$MYPYTHONPATH:$MYPYTHONPATH2:$PYTHONPATH

# support for PERL
export PERL5LIB=./local/lib/perl/5.8.4:./local/share/perl/5.8.4:./lib/perl5:./share/perl5:./lib/perl/5.8:./share/perl/5.8:./local/lib/site_perl

# support for GTK
# still to be done, as patching seems to do the trick
# =$PRE
# see http://www-eleves-isia.cma.fr/documentation/GtkDoc/gtk/gtk-running.html

# if commandline arguments are passed, use the first argument as the name of the application to be called, and remove $1  from $@
if [ $1 ]; then APPNAME=$1; shift; fi

# ask the user which application to use if APPNAME is not correct
if [ !  $(which $APPNAME) ]
then
    BINARIES="$(find $DIRNAME/sbin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $DIRNAME/bin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/sbin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/bin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/X11R6/bin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/local/sbin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/local/bin/* -perm +1 -type f 2>/dev/null) $BINARIES"
    BINARIES="$(find $PRE/games/* -perm +1 -type f 2>/dev/null) $BINARIES"
    for BINARI in $BINARIES
    do
 OPTIONSTRING="$BINARI $(basename $BINARI) $OPTIONSTRING"
    done
    export APPNAME=$(kdialog  --menu "" --caption "" $OPTIONSTRING)
fi

BINARY=$(which $APPNAME) || exit 1  #  kdialog --error "Can't find the binary to run." --caption ""
# doesn't work: # if [ -z $BINARY ]; then echo "Can't find the binary to run." > /dev/stderr; exit 1; fi

# check whether this is a commandline app, in this case run it in konsole
# TODO: find a more reliable way to thell whether an app is a commandline tool
KONSOLE="konsole --noclose  --notoolbar --nomenubar --caption $(basename $APPNAME) -e"
[ $DIALOG = "zenity" ] && KONSOLE="gnome-terminal -x "
( ldd $BINARY | grep libX11 >/dev/null ) && export KONSOLE=""

# if we don't run in GUI mode, then we don't need konsole since we are on a cmdline
# ( echo $GUIMODE | grep 0 >/dev/null ) && export KONSOLE=""
( tty | grep ^/dev/tty >/dev/null ) && export KONSOLE=""
( tty | grep ^/dev/pts >/dev/null ) && export KONSOLE=""

# start the app together with all command line arguments
cd $PRE/ # neccessary for patched apps
$KONSOLE $BINARY $ARGS "$@"
if [ "$?" = "0" ]
then
while pidof -x $BINARY &>/dev/null; do sleep 1; done
else
RESULT="error"
fi

# remove link substitute for /usr in case we needed it
if [ -n "$SUBSTUSR" ]
then
sudo rm -f $SUBSTUSR
fi

if [ "$RESULT" = "error" ]
then
exit 1
else
exit 0
fi

this code is from a klik app ( Klik).
this code enable to run an app that is not in a normal prefix(/usr /opt) and enable to use the librarys from alot of paths.
basicly this code enable the use of cf and sd packages without the need of links(which consume alot of memory and is very slow and based on bash which is slowwwwwww!!!).
CODE
NEWCMD=$(perl -e '$newcmd=shift(@ARGV);foreach $arg (@ARGV){ @part=split(/\=/,$arg); foreach $part (@part){ (-e "$ENV{PWD}/$part") && ($part="$ENV{PWD}/$part");}$newcmd.=" ".join ("=",@part);} print "$newcmd";' $@)
set -- $NEWCMD
###for cf card
PRE=/mnt/cf
DIRNAME=/mnt/cf
###for sd card
PRE=/mnt/card
DIRNAME=/mnt/card
###
PATH=$DIRNAME/sbin:$DIRNAME/bin:$PRE/sbin:$PRE/bin:$PRE/X11R6/bin:$PRE/local/sbin:$PRE/local/bin:$PRE/games:$PATH
export LD_LIBRARY_PATH=$DIRNAME/lib:$PRE/lib/:$DIRNAME/opt/kde3/lib:$DIRNAME/usr/X11R6/lib/:$LD_LIBRARY_PATH

# support for KDE
export KDEDIRS=$PRE/:$KDEDIRS

# support for man pages (interpreted by KDE)
export MANPATH=$PRE/share/man:$PRE/X11R6/man:$MANPATH

# support for PYTHON
MYPYTHONPATH=$(find $PRE/lib/python2.3/site-packages/ -type d -printf %p: 2>/dev/null)
MYPYTHONPATH2=$(find $PRE/lib/python2.4/site-packages/ -type d -printf %p: 2>/dev/null)
export PYTHONPATH=$MYPYTHONPATH:$MYPYTHONPATH2:$PYTHONPATH

# support for PERL
export PERL5LIB=./local/lib/perl/5.8.4:./local/share/perl/5.8.4:./lib/perl5:./share/perl5:./lib/perl/5.8:./share/perl/5.8:./local/lib/site_perl
if [ $1 ]; then APPNAME=$1; shift; fi
# start the app together with all command line arguments
cd $PRE/ # neccessary for patched apps
$BINARY $ARGS "$@"
if [ "$?" = "0" ]
then
while pidof -x $BINARY &>/dev/null; do sleep 1; done
else
RESULT="error"
fi

this code should be cleaned alot and should be run in the boot time.
this way you can run apps from cf and sd without the need of links to the root partiton which means no ipkg-link in the boot time(takes about 10 minutes on my Zaurus with alot of apps) and uses almost all the mem(from 30Megs in login to 2 Megs after a while).
i highly recommend to use this as it is more fast,low memory use and a simple solution
pgas
Though you can surely avoid a lot of links with this script, I'm pretty sure you will still need some.

For instance, what about an application that tries to load a conf file in /etc/?
emacs looks into a pretermined place to find its elisp library
matchbox looks into /usr/share/applications for the .desktop files.
What about the icons that applications expect to find in /usr/share/pixmaps?

I don't think a solution as generic as ipkg-link is easy to find.
Maybe a filesystem like unionfs...
rmrfchik
Haha, today, on my way to office I though about klik in Z. Klik's applications distributed as a single file with cramfs and can be run directly from this file.

I think klik (or other klik-like technology) should be discussed as way to distribute/use the apps under pdaXrom.

Sash, what do u think?
urielka
/etc is kept on root partition coz it doesn`t consume so much space!
to make it clear:every thing that is consider configuration should be on the root partition.
smuelas
QUOTE(urielka @ Jan 4 2006, 01:47 PM)
/etc is kept on root partition coz it doesn`t consume so much space!
to make it clear:every thing that is consider configuration should be on the root partition.
*

Thanks Urielka for those scripts.
Nevertheless I will ask you to make them a little bit clearer for me.
I have tried the second one and it seems to run without any negative message, BUT, no chage is perceived. I run it after "login" and before launching the X's. Is that O.K.? When I look at the free memory after launching KDE, I see that I've used almost 60 Mb. or RAM, so the SWAP is needed.
Regarding the first script, I've tried it to launch an application, "korganizer". So I have changed
the name of the program. Afterwards I receive a message of not having the close bracket at line 93. I have installed PERL to run it. I find also a problem with "ldd", but I have used the one that I have in Debian, and it seems to run.
The result is the same as with the second script: the application runs but with no differences with the usual way of launching it.
Your figures are so excellent that I'm sure I'm not doing things o.k.
Any help?

smuelas
urielka
the script is not mine but i will try to write it ok once i restore the nand flash to my C1000(i erased it ,now i need to do a flash restore but i can`t find my card reader to do so smile.gif ).
in the end with my script you should not run ipkg-link at all(you can test it as moving ipkg-link to ipkg-link_notinuse or so so it will not run as you insert a card).
this also means that you willn`t need to install kde-striped-symlinks(if you use the good script).
plz don`t use this script if your level of bash/linux is not above 3-4 years of use(so you don`t fucked up your system).
just give my a few days and i will show the concept.
Sash and Laze ,are you interset in this?
pgas
QUOTE
Sash and Laze ,are you interset in this?


What about the problems I mentioned?

You say configuration files should be put in root, so people packaging application should put a postinstall script to move the configuration file to /.

What about applications with hardcoded link to images, data and the rest?
Should we put these on / too?

What about the C3000 where the root space is very limited?

Have you tried to use ruby emacs kdepimpi microemacs xmms tuxpaint .... installed in /mnt/card with your script?

Should we check every application for hardcoded path and issue patches so that they read /etc/ipkg.conf and search for the files in every destination?

A lot more work will be required when porting and packaging applications.

I don't say that a script like this doesn't work for some application and is not usefull, but it is not a solution as simple and as generic as ipkg-link.
urielka
i can`t test anything right now coz my Z isn`t working right now i need to reflash it and i can`t find my card reader.
ipkg-link maybe works for anything but it is slow and non-efficent.
ipkg-link runs after installing a application(if the application is on cf or sd) so if we change ipkg-link it can do all the post-installing things like the /etc and stuff.
we can also have some symlinks but it will be good to have the minimum of links.
most of the app have a VARIBALE that can be change to change the hardcode stuff.
packaging will take abit more but the we get a symlinks-free system.
pgas
QUOTE
ipkg-link runs after installing a application(if the application is on cf or sd) so if we change ipkg-link it can do all the post-installing things like the /etc and stuff.

You can allready add preinst,postinst,prerm,postrm scripts to the ipkg package

QUOTE
most of the app have a VARIBALE that can be change to change the hardcode stuff.

At compile-time, not at runtime:

See what is said on the klik site:

QUOTE
Making your application "relocateable"

Most Autoconf/Automake projects use hardcoded paths.

Because klik does not use traditional filesystem paths, your application will run best if it does not use absolute paths like /usr. In order to make existing application run, klik today patches binaries to convert absolute to relative paths. While this works for some applications, it is only a temporary solution and you should clearly try to avoid absolute paths in your application altogether.
urielka
give my all packages that you find them difficult to use with the script.
so i can test everything and maybe bring a better solution.
pgas
try these:

dillo ruby emacs kdepimpi microemacs xmms tuxpaint opie-reader every other application that have some files in /usr/share, or /usr/lib/

See what could be done (repackage, hack ipkg) so that the applications icons are shown in the menu.

Take into acount that /mnt/card and /mnt/cf, /mnt/user are not the only possible destination, on 3100 /mnt/hdda or something, theorically every destination in /etc/ipkg.conf are.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.