Pet package 'pinstall.sh' problem!

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

Pet package 'pinstall.sh' problem!

#1 Post 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. :shock:
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!

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#2 Post 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

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post 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...

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#4 Post 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. :D

Cheers,
s

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#5 Post 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.

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#6 Post by big_bass »

Argolance

Code: Select all

env
and see what is LANG=


I have this
LANG=en_US


Joe

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#7 Post 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

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#8 Post by big_bass »

Argolance

this is better

Code: Select all

 env |grep  "LANG="

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

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#9 Post 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 :wink:

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#10 Post 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.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#11 Post 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

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#12 Post 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'... :shock: Yes indeed but slightly, slightly!
Thank you!

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#13 Post 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 ????
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#14 Post 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 :shock:
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

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#15 Post 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 :D

Cheers,
s

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#16 Post 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 :D
Attachments
swedish-chef.jpg
(33.86 KiB) Downloaded 377 times

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#17 Post 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.

Post Reply