Pandora Copy files from PND to appdata?


Silent-Hunter

Hardcore Member
Joined
May 29, 2010
Messages
3,485
How do I make a PND copy files from within itself to its appdata folder?

The PND I have made needs the right nub to have the scroll function, so I created PND_pre_script.sh and PND_post_script.sh but they don't work when packaged into the PND, they have to be in the appdata folder. So I want to make the PND copy them there on first run. I've tried to find how to do this, but no luck.

EDIT:

I figured out how to do it, but it doesn't work the first time the PND runs, the scripts are moved, but they don't run properly until I quit and restart the PND.

Here's the run.sh from the PND:


#!/bin/sh

[ ! -d 'PND_pre_script.sh' ] && cp -Rpn pre_script.sh PND_pre_script.sh

[ ! -d 'PND_post_script.sh' ] && cp -Rpn post_script.sh PND_post_script.sh

./svgviewer

And here is the contents of the .out:


=======================================================================================
PND : /media/2/build/out.pnd
PND_FSTYPE : Squashfs
APPDATADIR : /media/2/pandora/appdata/svgviewer
APPDD_FSTYPE : ext3
PND_CPUSPEED : <unset>
EXENAME : run.sh
ARGUMENTS : <unset>
=======================================================================================
[ START ]--- Mount the PND ----------
Mounting : mount -t squashfs -o ro "/dev/loop2" "/mnt/utmp/svgviewer"
Mounting the Union FS : mount -t aufs -o exec,dirs="/media/2/pandora/appdata/svgviewer=rw+nolwh":"/mnt/pnd/svgviewer=rr" none "/mnt/utmp/svgviewer"
[SUCCESS]--- Mount the PND ----------
[ START ]--- Starting the application (run.sh ) ----------
[SUCCESS]--- Starting the application (run.sh ) ----------
[ START ]--- Starting user configured post-script ----------
cat: /tmp/nub0mode_before: No such file or directory
cat: /tmp/nub1mode_before: No such file or directory
usage:
/usr/pandora/scripts/op_nubchange.sh <left_nub_mode> <right_nub_mode>
rm: cannot remove `/tmp/nub0mode_before': No such file or directory
rm: cannot remove `/tmp/nub1mode_before': No such file or directory
[ FAILED]--- Starting user configured post-script ----------
[ START ]--- Restoring the frame buffer status ----------
[SUCCESS]--- Restoring the frame buffer status ----------
[ START ]--- uMount the PND ----------
[ START ]--- Waiting the Union to be available ----------
[SUCCESS]--- Waiting the Union to be available ----------
auplink:plink.c:223: AUFS_CTL_PLINK_MAINT: Inappropriate ioctl for device
rmdir: failed to remove `/mnt/utmp/svgviewer': Device or resource busy
[ START ]--- Waiting the PND mount dir to be free ----------
[SUCCESS]--- Waiting the PND mount dir to be free ----------
cleanup done
[SUCCESS]--- uMount the PND ----------
=======================================================================================
Return code is : 6


It appears as though it can't see the PND_pre_script.sh, even though I know it copied it because I checked that it's there, and it works on subsequent runs.
 
Last edited by a moderator:
PNDs that use this setup have some kind of first-run check, which copy the scripts over, and pop-up a message saying something like "first run initialisation complete. Please re-start the PND". They'll never work first time, because the process is:

1. Execute pre-script

2. Execute main-script

3. Execute post-script

The pre-script doesn't exist until the main-script creates it. On it's first run, your PND can't execute something that doesn't exist.

To solve it, just run the pre and post scripts directly from your main script. So your run.sh would look like:


#!/bin/bash

. ./pre-script.sh

./svgviewer

. ./post-script.sh
The "." is bash's syntax for 'include', so your pre and post scripts get included and run as part of your main script.

----

On a completely separate / irrelevant note, "[ ! -d 'PND_pre_script.sh' ]" checks for a directory, not a file, so that test always fails and the files get copied over every time (you would have wanted something like "[ ! -f 'PND_pre_script.sh' ]").
 
PNDs that use this setup have some kind of first-run check, which copy the scripts over, and pop-up a message saying something like "first run initialisation complete. Please re-start the PND". They'll never work first time, because the process is:


1. Execute pre-script


2. Execute main-script


3. Execute post-script


The pre-script doesn't exist until the main-script creates it. On it's first run, your PND can't execute something that doesn't exist.


To solve it, just run the pre and post scripts directly from your main script. So your run.sh would look like:


#!/bin/bash

. ./pre-script.sh

./svgviewer

. ./post-script.sh

The "." is bash's syntax for 'include', so your pre and post scripts get included and run as part of your main script.


----


On a completely separate / irrelevant note, "[ ! -d 'PND_pre_script.sh' ]" checks for a directory, not a file, so that test always fails and the files get copied over every time (you would have wanted something like "[ ! -f 'PND_pre_script.sh' ]").
Oh my god, I'm an idiot. I'm always overcomplicating things like that, thanks very much for your help!

Is [ ! -f 'somescript.sh' ] Pandora specific, or is it in all UNIX/Linux? And where can I find more info it seems useful.
 
Last edited by a moderator:
Is [ ! -f 'somescript.sh' ] Pandora specific, or is it in all UNIX/Linux? And where can I find more info it seems useful.
It's not Pandora specific, it's just part of Bash scripting (which pretty much all Linux OSs support). The complete list of available tests is here.
 
OK. What I don't understand is how does adding that get it to copy stuff to appdata? Because before I put that in, it was copying those files into the PND itself.
 
Last edited by a moderator:
It doesn't, that part just tests whether the 'PND_pre_script.sh' already exists or not. You'd still need the full line to actually copy stuff e.g.


[ ! -f 'PND_pre_script.sh' ] && cp pre_script.sh PND_pre_script.sh
I just meant, for the testing part, you wanted 'f' rather than 'd'. Sorry for any confusion.
 
The trick here is..

The pre-/post scripts are really for putting 'hacks' against existing jobs.

If you want to fiddle with the settings yourslef, in your job, every time.. just do them in your job, you don't need pre/post scripts at all :)   Like, if your job is going to do..,

i) pre-work

ii) main work

iii) post-work

... every time, then just do it all in your main script, or whatever. Making other scripts, so the pnd-system has to do it, just looks like making trouble.

At the same time, if you want to leave it open to the user, so they can create their own pre/post tweaks, and you not clobber them, then dropping out the default pre/post scripts is an interesting take on that; but yeah, then you'd need a first-run/exit/next-runs cycle on your pnd, like some do.. first run setrting things up and then bailing out, and user running it again.

jeff

and remember.. appdata is your current working directory; anythign you wreite to "./foo" will end up as 'foo' in your appdata. ie: If your pnd includes a directory 'defaults', and you do a "cp ./defaults/foo ./foo", then 'foo' ends up in your appdata, but ./defaults/foo is _also_ available to your app of course, since its mounted. Look at your pnd and your appdata as one thing, and any changes get dropped into appdata since the pnd itself is read-only.
 
Last edited by a moderator:
Back
Top