Page 1 of 1
Pet package 'pinstall.sh' problem!
Posted: Sun 21 Feb 2010, 14:32
by Argolance
Hello everybody!
I created a pet package that needs a pinstall.sh file to copy the right localized file to /root: Depending on the actual locale used by the system, this file should be copied from 'myapp/menus/
en/' or 'myapp/menus/
fr/' directory. ...Should be but is unfortunately not!
Code: Select all
cp -f ${SOURCE}/menus/"${LANG:0:2}"/.jwmrc-tray_3in1 /root/.jwmrc-tray;
Looking at xerrs.log, I get:
cannot stat /usr/local/myapp/menu/
C/.jwmrc-tray_3in1 not such a file... etc.
Why this
C directory when I should get '
en' or '
fr' from the variable ${LANG:0:2}? Running the pinstall.sh alone after installation, the right directory is identified and the right file correctly copied to root!
What's going wrong Doctor?
Thank you!
Posted: Sun 21 Feb 2010, 16:58
by seaside
Argolance,
Code: Select all
cp -f ${SOURCE}/menus/"${LANG:0:2}"/.jwmrc-tray_3in1 /root/.jwmrc-tray;
It appears that you are using ${SOURCE} as a path variable and "SOURCE" is also a command.
You might try setting a variable $PROGRAMPATH instead of SOURCE and see if that works.
Bon Chance,
s
Posted: Sun 21 Feb 2010, 18:18
by Argolance
Thank's for reply!
@seaside
I tried this:
Code: Select all
cp -f ${SCRIPT_DIR}/menus/"${LANG:0:2}"/.jwmrc-tray_3in1 /root/.jwmrc-tray;
... and this (without quotes!)
Code: Select all
cp -f ${SCRIPT_DIR}/menus/${LANG:0:2}/.jwmrc-tray_3in1 /root/.jwmrc-tray;
... and got this:
cp: cannot stat '/usr/local/myapp/menus/C/.jwmrc-tray_3in1'...
Where does this '
C' come from? Very strange indeed!
Don't understand...
Posted: Sun 21 Feb 2010, 19:52
by seaside
Argolance,
The only other possibility I can think of is that somehow the LANG variable may be set to "C". I think a number of scripts have "LANG=C" in them to run everything faster.
Cheers,
s
Posted: Sun 21 Feb 2010, 23:41
by Argolance
Hello!
Is there nothing else to do? Do any command or code line exist to get the actual locale of the system without using this $LANG variable? Can such a strange thing happen?
Thanks.
Regards.
Posted: Mon 22 Feb 2010, 00:34
by big_bass
Argolance
and see what is LANG=
I have this
LANG=en_US
Joe
Posted: Mon 22 Feb 2010, 03:56
by seaside
Argolance,
Since the "pinstall.sc" is under the control of the pet installer and the variable has been set to LANG=C, the normal LANG environment variable isn't seen.
An alternative is to put your code into a helper startup script which would run once when the program command is given.
The code runs properly when YOU run pinstall.sc in a terminal because "echo $LANG" will supply the default ENV LANG language.
Cheers,
s
Posted: Mon 22 Feb 2010, 14:10
by big_bass
Argolance
this is better
if another script exported LANG=C
and you ran a child process from it you get it in the echo
I don't know what version your running or anything else about your code
but only from what little info you posted
the info I posted will pin point the problem
Joe
Posted: Mon 22 Feb 2010, 14:10
by big_bass
Argolance
well it double posted so
here's a new thought
Code: Select all
DEFAULTLANG=(`env |grep "LANG="`)
if [ $DEFAULTLANG = "LANG=en_US" ]; then
echo $DEFAULTLANG
elif [ $DEFAULTLANG = "LANG=C" ]; then
echo "you got borked :D"
fi
Joe
Posted: Tue 23 Feb 2010, 05:26
by 8-bit
I have been following along and I selected your (Big Bass) code snipit and pasted it in a terminal.
The result was "en_US"
That is the first time I have pasted multiple lines of code in a terminal anyway.
So I was curious.
Posted: Tue 23 Feb 2010, 08:25
by amigo
As seaside said, the installer sets LANG=C so that sorting is more predictable, so it's a 'bug' in the installer. There is a way around this. Insetad of exporting the LANG variable, it can be set only when needed:
LANG=C sort file > new-file
Posted: Tue 23 Feb 2010, 14:06
by Argolance
Hello everybody,
Thank you a lot for your replies!
... I finally gave up and my application will be installed in English by default! User can localize it through the application itself while simply clicking on a button... Nevertheless, please, I would like to know how to do this:
LANG=C sort file > new-file
Need some explanations!
@big_bass
... Was curious about what 'borked' means. I found 'To have totally f...d something up'...
Yes indeed but slightly, slightly!
Thank you!
Posted: Tue 23 Feb 2010, 17:29
by technosaurus
some longer scripts may set LANG=C for about a 5X speed increase (search Barry's blog for details)... but not save the original LANG and set it back to preferred ... perhaps the preferred language is also stored somewhere in /etc ????
Posted: Tue 23 Feb 2010, 17:30
by big_bass
Hey Argolance
give it another try after a cup of coffee
if you want some code to change locals heres a good link
http://www.murga-linux.com/puppy/viewtopic.php?t=51630
there's a lot of code there to sort through 16 pages
but you may just need to try it first
TIP : when you plan to try again post the code you are having problems with more people can offer
help / suggestions
Joe
Posted: Tue 23 Feb 2010, 17:34
by seaside
Argolance,
Sorry you ran into this difficulty. The change that Amigo mentions "LANG=C sort file > new-file" would have to be made to the Petget installer program and not by your program.
As I mentioned before, you could provide a "helper" script alternative like this -
Rename your execute file to "ProgramName-bin"
Make up a script as follows: (pseudo code)
Code: Select all
if not exist MARKERFILE; then
cp xxxx xxxx (your code)
echo >MARKERFILE
fi
ProgramName-bin
Name the script "ProgramName" , and put it in a program path directory.
This will run the setup copy code and establish the ENV LANG only once, and then execute the program.
Maybe big_bass will provide you with a more precise translation of "borked" than Google
Cheers,
s
Posted: Tue 23 Feb 2010, 18:05
by big_bass
seaside
Maybe big_bass will provide you with a more precise translation of "borked" than Google Very Happy
well ,yes I will
here is a better way to translate it
Posted: Tue 23 Feb 2010, 21:04
by amigo
Here's a diff against (I guess) an older version of petget:
Code: Select all
--- ./petget.00 2007-09-14 11:55:56.000000000 +0200
+++ ./petget 2010-02-23 22:07:31.000000000 +0100
@@ -16,8 +16,8 @@
#13Sept2007 BK: v2.21 handle true flushing to flash drive.
#v2.17.1 trying to fix a bug...
-LANG=C
-export LANG
+# LANG=C
+# export LANG
PUPPYVERSION="`cat /etc/puppyversion`"
#v2.17.1 variables created at bootup by /initrd/usr/sbin/init...
@@ -1166,7 +1166,7 @@
#fi
-sort -u $WKGDIR/livepackages.txt > /tmp/livepackages.txt
+LANG=C sort -u $WKGDIR/livepackages.txt > /tmp/livepackages.txt
sync
PACKAGESFND="`cat /tmp/livepackages.txt`"
@@ -1308,7 +1308,7 @@
if [ ! "$PKGS2REM" = "" ];then
#v1.0.3 hiccup, see patch above, it is possible we can get duplicate entries here, if a pkg
#is listed in both alienpackages.txt and livepackages.txt. use sort...
- PKGREMNAMES="`echo "$PKGS2REM" | cut -f 1 -d " " | sort -u | tr "\n" " "`"
+ PKGREMNAMES="`echo "$PKGS2REM" | cut -f 1 -d " " | LANG=C sort -u | tr "\n" " "`"
if [ ! "$DISABLEDX" = "yes" ];then
# gxmessage -center -name "pet" -bg "orange" -buttons "REMOVE:10,ABORT:11" "You have chosen to remove these packages from Puppy:
#$PKGREMNAMES
@@ -1774,7 +1774,7 @@
cat $WKGDIR/livepackages.txt | grep -v "$MPATTERN" > /tmp/tempvvvv
sync
cat /tmp/tempnewon >> /tmp/tempvvvv
- sort /tmp/tempvvvv > $WKGDIR/livepackages.txt
+ LANG=C sort /tmp/tempvvvv > $WKGDIR/livepackages.txt
rm -f /tmp/tempvvvv
fi
rm -f /tmp/tempnewon
As you can see, petget exports LANG right at the top, which the patch comments out. The other hunks of the patch add LANG=C only where needed -at least that should be the main spots where the speedup is needed.
As for your package, as suggested, a wrapper which sets the LANG an executes your program should work, or include a setup tool for it which sets up the system LANG and copies the menu items before running the program the first time.