I've been doing some dodgy hackery with my Pandora as of late, and thought I'd share what I've been up to. I've already got a toolchain set up to run via PND ( see Torpor's dev thread for more info on that ) and I've been pulling over other things.
Though I thought that perhaps writing up a quick HOWTO on what I'm up to may be an idea, for those adventurous to have a go themselves.
Essentially, I'm trying to avoid writing to the NAND if at all possible, but there's all them lovely apps sitting in the Angstrom repository!
The PND system is also somewhat funky in that it brings with it the wonderful AUFS filesystem doohickey, which allows you to perform all manner of really nifty things ( I've another guide coming up with just how nifty things can get! ) including where your app can save to it's current directory ( ./ ) and it'll get auto-dumped into /pandora/appdata/your.app.id for you.
With this in mind, how about converting some apps from Angstrom into PNDs while we wait for our own repository? It'll be good practice in using the PND system, and good to abuse it to see how much we can get away with! ( turns out, it's a lot! )
This guide is being written as I convert GIMP, having already done the toolchain thing, but I'll cover over my initial steps as well.
First things first, on your Pandora, you're going to want to update opkg. This is about the only thing that touches the NAND in this process, for the most part anyway.
This part is probably optional, but I did it anyway.. if you're scared of something going horrifically wrong, you should be able to skip it.
So, open up a terminal, and type "sudo opkg update" ... pay careful attention that it's "update" you type and *NOT* "upgrade".
Do not, under any circumstances, do an upgrade unless OpenPandora have setup their own repository, and you're linked to that. You're very much capable of hosing your system otherwise. BE CAREFUL!
Whether you've updated it or not, you'll want to jump to your SD Card. Make sure you've a fair amount of space on it, and just cd to it in your terminal "cd /media/mmcblk0p1" if your card is in the left slot ( next to the headphone socket ) or "cd /media/mmcblk1p1" if it's in the right slot ( next to the volume wheel. )
You can get a nice big list of what's in the Angstrom repository here: http://www.angstrom-...ution.org/repo/
We're after the gimp for the time being, so what we want to do now is use opkg to download it, and all dependencies for us.
Make a folder for it on your SD card: "mkdir gimp" and change to it "cd gimp"
Now, lets get opkg to do a fair chunk of work for us: "sudo opkg install gimp --download-only" ( replace gimp with whatever packages you want )
This downloads gimp, and all dependencies for us, and plonks them in the current directory for us.
We now have a lot of .ipk files!
The next bit is tricky though, as it relies on having a Linux-based file system.
You can do what I did, and remove the card and plug it into a Linux machine, or if you're adventurous, you may have an EXT2 formatted SD card laying around. Either way, you'll want to copy all those ipk files into a temporary folder on a Linux-based file system.
The reason being, we need to extract these ipk files, and as they spit out Linux files which will include symbolic links ( think of them as Windows shortcuts, only you can treat them as if the file is ACTUALLY there, and the shortcut isn't a file in it's own right ) you can't use a FAT or NTSC based file system - it doesn't understand them.
You might get away with using Mac OS X as well, depending on how your drive is formatted.
Anyway, you have your ipk files in a folder somewhere on a Linux compatible file system.
We need to extract them.
I created a little script to do just that:
mkdir $1 for i in `ls` do ar x $i tar -zxvf data.tar.gz -C $1 doneSave that as extract.sh, make it executable: "chmod +x ./extract.sh" and then run it "./extract.sh gimp"
This'll create a folder "gimp" and extract all ipk files into there.
That's half the battle done!
Now comes the fun part.. we've pretty much got everything we need to run our app, as we've downloaded it, and all dependencies from our Pandora, so it should just be a case of packing it up as a PND and throwing it over, right?
Let's see why.
First create the PXML file. There's a good amount of documentation on this on the wiki, but here's mine for completeness sake:
<?xml version="1.0" encoding="UTF-8"?> <PXML xmlns="http://openpandora.org/namespaces/PXML"> <application id="stuckie.gimp-2.6" appdata="gimp-2.6"> <title lang="en_US">Gimp 2.6</title> <exec background="true" command="start.sh" /> <description lang="en_US">GIMP - The GNU Image Manipulation Program.</description> <author name="Ported by Stuckie" website="http://www.gimp.org"/> <version major="2" minor="6" release="8" build="5"/> <osversion major="1" minor="0" release="0" build="0"/> <categories> <category name="Graphics"> </category> </categories> </application> </PXML>
Obviously, you don't want to use this, or at the very least, change the application id and author parts!
Anyway, you'll notice that we want to run "start.sh" .. we haven't created this yet, but this is where the magic will happen.
If you've looked at the extracted files, you'll notice it's given us two folders in our gimp folder - etc and usr. Within usr, there's bin, lib and share. This is problematic, as gimp is going to at least need it's library files to function, so let's at least give it access to them.
Create a new "start.sh" file and plonk the following in it:
export GIMP_PATH=/mnt/pnd/gimp-2.6 export LD_LIBRARY_PATH=$GIMP_PATH/usr/lib export PATH=$GIMP_PATH/usr/bin:$PATH terminal -T "Test Terminal"
So what's this up to?
Your PND will get automatically mounted in /mnt/pnd/your-appdata-name, so we export a variable so we can easily get this.
We then want to force the library path to have the libraries that gimp wants. These are in our usr/lib folder, and will be mounted under our PND's path.
Then, we want to set up the main PATH, which allows the system to find the binaries we invoke, to include our usr/bin first, and then everything else afterwards.
Finally, and this might seem completely barmy just now, we open up a Terminal. We don't immediately want to run gimp yet, and you'll find out why in a moment.
So, in our gimp folder we should have: etc, usr, gimp.pxml, start.sh
That's enough for a PND!
Jump back a folder so we don't mess things up: "cd .."
PND files are effectively just ISOs with bits tagged on the end, with this in mind, we can create our PND like so: "mkisofs -o gimp.iso -R gimp/" which creates an ISO out of our directory, with Rock Ridge enabled.
Now to convert this to a PND: "cat gimp.iso gimp/gimp.pxml > gimp.pnd" which appends our PXML file onto the end of the ISO. We could put an icon on as well, but it's not absolutely needed just now.
Copy your PND into pandora/menu or pandora/desktop or where ever you like on your SD card, and put it back into your Pandora.
This is where it can all go completely wrong!
You should see our app appear on the desktop or the menu, so start it up and you should get the Terminal window.
Let's try running gimp and see what happens! Type "gimp" and hit return.. if we're lucky, it'll start up! if we're not... we'll get some errors ( this is why we started a terminal, so we could catch them )
In this case, it's complaining about a library - libgegl-0.0.0.so - which is odd, as there's already a libgegl-0.1.so.0 in our usr/lib folder.
Ok well, if that's what it wants, go back to your extracted gimp folder "cd /path/to/extracted/gimp", jump into it's usr/lib folder "cd usr/lib" and we'll create a symbolic link and see if that fixes it: "ln -s libgegl-0.1.so.0 libgegl-0.0.so.0"
Shutdown the Terminal so that our PND gets automatically unmounted for us, and we can remove our card if needed.
Create the PND again, and copy it over our old one.
Now let's try and run it.
We get a "User Installation Failed!" notification, but it's an actual GIMP window so we're getting there.
Let's see, why's it failed on us? Ah.. it's trying to create some stuff in our home folder and copying some stuff out of /etc which doesn't exist! The stuff it's looking for is in our etc though.
Hmm.. we could do a couple of things here. We could edit our start.sh to copy the etc files over to home, and see if that works... but at that point, we've instantly failed in our mission to install stuff by avoiding the NAND!
Let's perform some "creative solutions" instead.
However, the cheeky bugger has already created this folder, so we best remove it while we remember "rm -rf ~/.gimp-2.6"
Jump back to our start.sh file, we're going to do some fiddling.
Again, shutdown the Terminal so that our PND gets automatically unmounted for us, and we can remove our card if needed.
We now know that gimp wants to create files in our home directory. We also know where it wants to store them - ".gimp-2.6" in our home folder, and we have a rough idea on what it wants to store there as well, the files from our etc folder. Where do we have access to write? Our appdata folder, of course! Now, technically, we're still having to write to the NAND here, but it's only going to be the one file, and seeing as you have various logs and bash histories being written to the NAND anyway, it's still a damn sight better than writing a mass amount of files and filling it up over time by installing things directly.
We want to add the following to start.sh, before the Terminal command:
if [ -L ~/.gimp-2.6 ]; then echo "Already linked ~/.gimp-2.6 to our SD card" else mkdir .gimp-2.6 ln -s /mnt/utmp/gimp-2.6/.gimp-2.6 ~/.gimp-2.6 cp etc/gimp/2.0/* .gimp-2-6/ fiWhat we're doing, is checking if we already have a symbolic link from .gimp-2.6 in our home folder, to where our PND gets mounted. If not, we create it, and copy the etc files it was looking for into it.
That should be it, so recreate the PND and stuff it on to our card and try again!
Look at all those warnings and errors fly past! And then, we almost get there, we have a GIMP window! only it's living up to it's name-sake and is quite gimped.
Hmm.. it's still looking for the etc things, and now it's looking for the share items as well.
We can use the same trick, but we need to be careful here as we'd be modifying the root file system, and not just playing about in the home directory.
Close down the terminal window ( our gimped gimp will close with it ) and lets head back to start.sh and add the following before the Terminal command:
if [ -L /etc/gimp ]; then echo "Already have an /etc/gimp link" else gksudo "ln -s $GIMP_PATH/etc/gimp /etc/gimp" fi if [ -L /usr/share/gimp ]; then echo "Already have a /usr/share/gimp link" else gksudo "ln -s $GIMP_PATH/usr/share/gimp /usr/share/gimp" fi
You should roughly know what's going on here.. we check if we have an /etc/gimp link, and create it if not. The important bit to note is we call gksudo to ask the user for rights to do this. This will show up a box for them to type their password in, as well as giving them the command that's about to be run so they can veto it if they want. We do the same for the /usr/share/gimp link.
Now, let's try that again! Create the PND, copy it over, and run it.
You'll notice that it'll ask you for permission to create the links before the terminal pops up. It should only do this once, as it checks they exist, and only creates them if they don't.
Now, would you look at that, it's running! Fantastic
Curiously, if you tell it to quit, it takes an absolute age to do so.. it seems to be saving settings all over the .gimp-2.6 structure for some reason, as you'll notice this from the workout the SD activity light is getting. If you're becoming impatient, you can click the X of the main gimp window, and it'll force a kill. It doesn't seem to have any ill effects, but may not be the best thing to do.
Obviously, we don't want our users to have to type "gimp" into a command window! so we head back to our start.sh, and replace the Terminal call with just a gimp call. Our final start.sh now looks like this:
export GIMP_PATH=/mnt/pnd/gimp-2.6 export LD_LIBRARY_PATH=$GIMP_PATH/usr/lib export PATH=$GIMP_PATH/usr/bin:$PATH if [ -L ~/.gimp-2.6 ]; then echo "Already linked ~/.gimp-2.6 to our SD card" else mkdir .gimp-2.6 ln -s /mnt/utmp/gimp-2.6/.gimp-2.6 ~/.gimp-2.6 cp etc/gimp/2.0/* .gimp-2-6/ fi if [ -L /etc/gimp ]; then echo "Already have an /etc/gimp link" else gksudo "ln -s $GIMP_PATH/etc/gimp /etc/gimp" fi if [ -L /usr/share/gimp ]; then echo "Already have a /usr/share/gimp link" else gksudo "ln -s $GIMP_PATH/usr/share/gimp /usr/share/gimp" fi gimp
Obviously, this could be cleaned up a bit with some assumptions made.. if you don't have a ~/.gimp-2.6, you probably don't have an /etc/gimp or /usr/share/gimp...
If we create the PND, copy it over, and run it.. we should get into gimp without any prompts.. we've already "installed it" so, there's nothing for the script to do. We need to check this though, so close gimp if you've got it running still, and call up a terminal and do the cleanup we need:
"rm -rf ~/.gimp-2.6" - clean up the link.
"sudo rm -rf /etc/gimp" - remove the /etc/gimp link - MAKE SURE you are deleting /etc/gimp and NOT just /etc!!
"sudo rm -rf /usr/share/gimp" - remove the /usr/share/gimp link - MAKE SURE you are deleting /usr/share/gimp and NOT just /usr or /usr/share!!
Now try it again, we should be prompted that it's modifying our file system ( unless you were quick enough for sudo's cache to keep the password ) This is what our users will see when they run our PND for the first time.
You could spruce the PND up a bit with an icon as well ( there are a few in the usr/share of our gimp package ) but I haven't done this.
I therefore present to you, our copy of gimp in ~20mb PND format, right here: http://www.stuckiega...ra/gimp-2.6.pnd
I'll put this up on the archives soon, once a few people have confirmed everything is working.
So, to recap what we've just done.
We've told our Pandora to do a download-only install of gimp to our SD card, so we have gimp and all it's dependencies.
We then extracted all of them, and built up a PND around it.
We tested this, and found some issues with it - it wanted to write to our home directory, so we fixed that with a symlink and performed an install, and it wanted some files in /etc and /usr/share .. so we symlinked them as well.
Our final PND creates three symlinks - our home settings, the /etc/gimp link and the /usr/share/gimp link. It creates them once, and never again.
Assuming future versions of gimp follow the same PND naming ( gimp-2.6 ) then there should never be any problems, whether I am the one that creates the PND or not!
Also, three symlinks versus however many files gimp has spread across the place? it's got stuff stored in your home folder, stuff in etc and stuff in three usr folders! I think three symlinks which are created once and never again is pretty good going, don't you?
This'll get posted up on the Wiki as well, but for now, pour over it and see if it makes sense, and once I get some feedback and proof reads, I'll push it over
Feel free to try walking through it and seeing if you can get gimp up and running as well, with my instructions - though I will admit, I had access to a Linux machine... Windows users may have issues, sadly.
Fixed the PXML file a bit[/edit]
Edited by Stuckie, 06 June 2010 - 03:25 PM.