You are not logged in.

#1 2008-11-18 16:49:45

alcafar
Member
From: Italy
Registered: 2008-03-23
Posts: 47

Help with a shell script for schroot

Since I replaced dchroot with schroot I have a problem.
In /usr/bin I have a script run32.sh to run 32 bit applications, and symbolic links like acroread32 pointing to run32.sh, firefox32 pointing to run32.sh etc.
Here is the run32.sh I had before

#!/bin/bash

cmd=`basename $0 | sed -n s/32//p`

for (( i=1; $i<=$#; i=$i+1 )); do
  esc[$i]=$(sed -e 's#\([^[:alnum:]]\)#\\\1#g' <<<${!i})
done

exec schroot -p "$cmd" "${esc[@]}"

The for loop is a trick I stole from the web for escaping some characters.
But this is not working anymore with schroot.
So I modified run32.sh like this:

#!/bin/bash

cmd=`basename $0 | sed -n s/32//p`

ct=0

arg=\"

for i in "$@"
do
    ct=$(($ct+1))

    if [ $ct -eq 1 ]
    then
        arg="$arg$i"
    else
        arg="$arg $i"
    fi
done

arg=$arg\"

echo exec schroot -p $cmd $arg
exec schroot -p $cmd $arg

Notice that at the end I echo the exec command and then I execute it.
It works fine for simple arguments, like

acroread32 foo.pdf

but not for composite arguments like

acroread32 foo boo.pdf

or

acroread32 foo\ boo.pdf

(this last one is when I use the tab key to complete the name of the file).

The thing that I really don't understand is that, typing

acroread32 foo boo.pdf

the echoed command is

exec schroot -p acroread "foo boo.pdf"

and I get an error

I: [Arch32-8398824e-10d9-4adf-a299-10c09116e262 chroot] Running command: "acroread foo boo.pdf"

but then, if i type directly to the command line

exec schroot -p acroread "foo boo.pdf"

it opens the file!

Has somebody a solution to deal both with files like "foo.pdf" and "foo boo.pdf"?

Offline

#2 2008-11-20 09:35:30

jacko
Member
Registered: 2007-11-23
Posts: 840

Re: Help with a shell script for schroot

Is there any reason your choosing to use acroread over some other form of pdf viewer via a chroot?

Offline

#3 2008-11-20 17:51:52

alcafar
Member
From: Italy
Registered: 2008-03-23
Posts: 47

Re: Help with a shell script for schroot

jacko wrote:

Is there any reason your choosing to use acroread over some other form of pdf viewer via a chroot?

Usually I use kpdf but for some particular features acroread is better. But it's not the point, acroread is just an example. You can do another example with firefox 32 bit, that I use for flash and jre, and mplayer 32 bit, that I use for some win32 codecs.

Offline

#4 2008-11-20 18:27:14

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help with a shell script for schroot

I personally ditched schroot and went back to dchroot.  No need to fix something that isn't broken.  I just made my own pkgbuild and renamed the package to dchroot_old so that it is not automatically updated by pacman (no idea why schroot wants to automatically replace dchroot).

I posted the PKGBUILD in this thread: http://bbs.archlinux.org/viewtopic.php?id=56785

Offline

Board footer

Powered by FluxBB