Added deployment directory with some possibly production conf's
authorskeezix <skeezix@flotsam-vm.(none)>
Mon, 23 Feb 2009 23:45:21 +0000 (18:45 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Mon, 23 Feb 2009 23:45:21 +0000 (18:45 -0500)
Added deploy make target to create deployment dir stuff
Added another sample pnd file (no icon), and added icon to the x86_ls sample
Added target 'pnd' that can make the sample pnd files

18 files changed:
Makefile
deployment/.keepdir [new file with mode: 0644]
deployment/etc/pandora/conf/apps [new file with mode: 0644]
deployment/etc/pandora/conf/desktop [new file with mode: 0644]
deployment/usr/bin/pndnotifyd [new file with mode: 0755]
deployment/usr/lib/libpnd.a [new file with mode: 0644]
deployment/usr/lib/libpnd.so.1 [new file with mode: 0755]
deployment/usr/lib/libpnd.so.1.0.1 [new file with mode: 0755]
deployment/usr/lib/libpnd.txt [new file with mode: 0644]
deployment/usr/pandora/apps/.keepdir [new file with mode: 0644]
deployment/usr/pandora/scripts/pnd_make.sh [new file with mode: 0755]
deployment/usr/pandora/scripts/pnd_run.sh [new file with mode: 0755]
testdata/pndsample/x86_echo.pnd [new file with mode: 0644]
testdata/pndsample/x86_echo/PXML.xml [new file with mode: 0644]
testdata/pndsample/x86_echo/my_echo [new file with mode: 0755]
testdata/pndsample/x86_ls.pnd
testdata/pndsample/x86_ls/PXML.xml
testdata/pndsample/x86_ls/zeldaicon.png [new file with mode: 0644]

index 14564da..f1b169e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,9 +25,12 @@ ALLOBJ = pnd_conf.o pnd_container.o pnd_discovery.o pnd_pxml.o pnd_notify.o pnd_
 all: ${SOLIB} ${LIB} conftest discotest notifytest locatetest pndnotifyd
 
 clean:
-       ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop
+       ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/apps/*.pnd
        find . -name "*~*" -exec rm {} \; -print
 
+# component targets
+#
+
 libpnd.a:      ${ALLOBJ} ${XMLOBJ}
        ${AR} r ${LIB} ${ALLOBJ} ${XMLOBJ}
        ${RANLIB} ${LIB}
@@ -36,6 +39,36 @@ libpnd.so.1: ${ALLOBJ} ${XMLOBJ}
        ${CC} -shared -Wl,-soname,${SOLIB} -o ${SOLIB1} ${ALLOBJ} ${XMLOBJ}
        ln -f -s ${SOLIB1} ${SOLIB}
 
+pndnotifyd:    pndnotifyd.o ${SOLIB1}
+       ${CC} -lstdc++ -o bin/pndnotifyd pndnotifyd.o ${SOLIB1}
+
+# deployment and assembly components
+#
+
+pnd:
+       # build x86_ls with icon
+       cd testdata/pndsample; ../scripts/pnd_make.sh x86_ls.pnd x86_ls/PXML.xml x86_ls
+       cd testdata/pndsample; cat x86_ls/zeldaicon.png >> x86_ls.pnd
+       # build x86_echo with no icon
+       cd testdata/pndsample; ../scripts/pnd_make.sh x86_echo.pnd x86_echo/PXML.xml x86_echo
+
+deploy: 
+       # populate deployment directory for copying into image bakes
+       # make dirs
+       mkdir -p deployment/etc/pandora/conf
+       mkdir -p deployment/usr/lib
+       mkdir -p deployment/usr/bin
+       mkdir -p deployment/usr/pandora/apps
+       mkdir -p deployment/usr/pandora/scripts
+       # copy in goodies
+       cp libpnd* deployment/usr/lib
+       cp bin/pndnotifyd deployment/usr/bin
+       cp testdata/scripts/* deployment/usr/pandora/scripts
+       # copy in freebee .pnd apps to /usr/pandora/apps
+
+# test tool targets
+#
+
 conftest:      conftest.o ${LIB}
        ${CC} -lstdc++ -o bin/conftest conftest.o libpnd.a
 
@@ -47,6 +80,3 @@ notifytest:   notifytest.o ${LIB}
 
 locatetest:    locatetest.o ${SOLIB1}
        ${CC} -lstdc++ -o bin/locatetest locatetest.o ${SOLIB1}
-
-pndnotifyd:    pndnotifyd.o ${SOLIB1}
-       ${CC} -lstdc++ -o bin/pndnotifyd pndnotifyd.o ${SOLIB1}
diff --git a/deployment/.keepdir b/deployment/.keepdir
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/deployment/etc/pandora/conf/apps b/deployment/etc/pandora/conf/apps
new file mode 100644 (file)
index 0000000..11f2cd8
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Open Pandora
+# Application configuration
+
+[autodiscovery]
+searchpath     /mnt/sd1/pandora/apps:/mnt/sd2/pandora/apps:/usr/pandora/apps   # path to depth-search for PXMLs
+
+# PXMLs may be overridden .. ie: overrides are a subset of PXML, where the values are copied over the full PXML
+[overrides]
+searchpath     ~/pxml-overrides
+
+# [pnd] defines where to locate the pnd support scripts, so the user may override pnd_run.sh without clobbering built in
+[pnd]
+searchpath     /mnt/sd1/pandora/scripts:/mnt/sd2/pandora/scripts:/usr/pandora/scripts
+runscript      pnd_run.sh
diff --git a/deployment/etc/pandora/conf/desktop b/deployment/etc/pandora/conf/desktop
new file mode 100644 (file)
index 0000000..9923fea
--- /dev/null
@@ -0,0 +1,6 @@
+
+# Open Pandora
+# Desktop configuration
+
+[dotfiles]
+dotdesktoppath /usr/share/applications/        # path for pndnotifyd to spit .desktop files into
diff --git a/deployment/usr/bin/pndnotifyd b/deployment/usr/bin/pndnotifyd
new file mode 100755 (executable)
index 0000000..edb413b
Binary files /dev/null and b/deployment/usr/bin/pndnotifyd differ
diff --git a/deployment/usr/lib/libpnd.a b/deployment/usr/lib/libpnd.a
new file mode 100644 (file)
index 0000000..563f639
Binary files /dev/null and b/deployment/usr/lib/libpnd.a differ
diff --git a/deployment/usr/lib/libpnd.so.1 b/deployment/usr/lib/libpnd.so.1
new file mode 100755 (executable)
index 0000000..d63c646
Binary files /dev/null and b/deployment/usr/lib/libpnd.so.1 differ
diff --git a/deployment/usr/lib/libpnd.so.1.0.1 b/deployment/usr/lib/libpnd.so.1.0.1
new file mode 100755 (executable)
index 0000000..d63c646
Binary files /dev/null and b/deployment/usr/lib/libpnd.so.1.0.1 differ
diff --git a/deployment/usr/lib/libpnd.txt b/deployment/usr/lib/libpnd.txt
new file mode 100644 (file)
index 0000000..e5b2f25
--- /dev/null
@@ -0,0 +1,42 @@
+
+Overview
+--------
+
+libpnd is a basic collection of functions and tools to make working Pandora-specific
+operations easier; to wit, it is hoped multiple applications will make use of this
+library rather than re-implement similar functionality and lead to problems down the
+road. (Instead we can run into problems together and thus clobberize them.)
+
+The library is broken into parts:
+
+include            - include these files to make use of the lib
+lib        - the code that produces the lib
+test       - mini tools to test various pieces of the lib in isolation
+bin        - test tools
+testdata/   - for testing /etc/pandora; will contain 'conf' dir, for example
+
+Revisions
+---------
+
+The initial version of this code will be very limited and meant to kick-start further
+work, yet provide basic functionaliy.
+
+TODO
+----
+
+o We need an actual matchbox plugin that uses this lib to obtain app list
+
+o PND-file handling, so iso/cram/zip app bundles actually work when pnd_apps_exec()'d
+
+o PXML parser has to actually be an XML parser
+
+o UNICODE support? ie: paths and filenames and app-names..
+
+Nice to do:
+
+o Handle regexp's or globbing in searchpaths, so can do tricks like /mnt/*/app etc
+
+jeff
+
+PS: Yes, I know, the entire thing could be done in 20 lines of perl, but we wanted C to
+maximize availability.
diff --git a/deployment/usr/pandora/apps/.keepdir b/deployment/usr/pandora/apps/.keepdir
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/deployment/usr/pandora/scripts/pnd_make.sh b/deployment/usr/pandora/scripts/pnd_make.sh
new file mode 100755 (executable)
index 0000000..867f247
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+pkgname=$1
+folder=$3
+xml=$2
+mkisofs -o $pkgname.iso -R $folder
+cat $pkgname.iso $xml >  $pkgname
+rm $pkgname.iso
diff --git a/deployment/usr/pandora/scripts/pnd_run.sh b/deployment/usr/pandora/scripts/pnd_run.sh
new file mode 100755 (executable)
index 0000000..b26ccf2
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/bash
+#input pnd_run.sh -p "/path/to/foobar.pnd" -e "exe" --a "arguments for exe"
+# -u to skip union mount
+# -s startdir
+# arguments can be inside -e, -a is optional
+############################# dont forget to remove the echos! ############################
+# parse arguments
+TEMP=`getopt -o p:e:a:b:u::s: --long p-long,e-long:,a-long: -- "$@"`
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+while true ; do
+        case "$1" in
+                -p|--p-long) echo "pnd set to \`$2'" ;PND=$2;shift 2;;
+                -e|--e-long) echo "exec set to \`$2'" ;EXENAME=$2;shift 2 ;;
+                -u) echo "u set, no union pls!";UNION=1;shift 2 ;;
+                -b) echo "BASENAME set to $2";BASENAME=$2;shift 2;;
+                -s) echo "startdir set to $2";STARTDIR=$2;shift 2;;
+                -a|--a-long) 
+                        case "$2" in
+                                "") echo "no arguments"; shift 2 ;;
+                                *)  echo "args set to \`$2'" ;ARGUMENTS=$2;shift 2 ;;
+                        esac ;;
+                --) shift ; break ;;
+                *) echo "Error while parsing arguments!" ; exit 1 ;;
+        esac
+done
+# add sanity check
+#vars
+DFS=$(file -b $PND | awk '{ print $1 }') # is -p a zip iso or folder?
+MOUNTPOINT=$(df $PND | grep -vE '^Filesystem' | awk '{ print $6  }') #find out which mountpoint the pnd/folder is on
+#if -b is set use that as basename, else generate it from PND
+#get basename (strip extension if file) for union mountpoints etc, maybe  this should be changed to something specified inside the xml
+if [ ! $BASENAME ]; then BASENAME=$(basename "$PND" | cut -d'.' -f1) ; fi
+oCWD=$(pwd)
+# add sanity check
+#detect fs
+if [ $DFS = ISO ]; then
+        mntline="mount -o loop,fmask=000 $PND /mnt/pnd/$BASENAME"
+        echo "Filetype is $DFS"
+elif [ $DFS = Zip ]; then
+        mntline="fuse-zip $PND /mnt/pnd/$BASENAME -o ro,fmask=000"
+        echo "Filetype is $DFS"
+elif [ $DFS = directory ]; then
+        mntline="mount --bind -o ro,fmask=000 $PND /mnt/pnd/$BASENAME"
+#we bind the folder, now it can be treated in a unified way ATENTION: -o ro doesnt work for --bind at least on 25, on 26 its possible using remount, may have changed on 27
+        echo "Filetype is $DFS"
+else
+        echo "error"
+        exit 1;
+fi
+#create mountpoints
+if [ ! -d /mnt/pnd/$BASENAME ]; then echo "mkdir -p /mnt/pnd/$BASENAME "; fi
+if [ ! -d $MOUNTPOINT/appdata/$BASENAME ]; then echo "mkdir -p $MOUNTPOINT/appdata/$BASENAME "; fi
+if [ ! -d /mnt/utmp/$BASENAME ]; then echo "mkdir -p /mnt/utmp/$BASENAME "; fi 
+#mount
+if [ ! $UNION ] ; then
+        #is the union already mounted? if not mount evrything, else launch the stuff
+        mount | grep "on /mnt/utmp/$BASENAME type" > /dev/null
+        if [ ! $? -eq 0 ]; then 
+                $mntline #mount the pnd/folder
+                #mount -t unionfs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro unionfs /mnt/utmp/$BASENAME #union mount
+                #aufs, one of those should work, bit unsure.
+                mount -t aufs -o exec,fmask=000,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro none /mnt/utmp/$BASENAME #aufs?
+                #mount -t aufs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro aufs /mnt/utmp/$BASENAME #aufs?
+        else
+                echo "doh!"
+        fi
+        #start app
+        cd /mnt/utmp/$BASENAME
+        if [ $STARTDIR ]; then cd $STARTDIR; fi
+        $EXENAME $ARGUMENTS 
+        #app exited
+else
+        $mntline
+        cd /mnt/pnd/$BASENAME
+        if [ $STARTDIR ]; then cd $STARTDIR; fi
+        $EXENAME $ARGUMENTS 
+fi
+#clean up
+umount /mnt/utmp/$BASENAME
+if [ $? -eq 0 ]; then 
+        umount /mnt/pnd/$BASENAME
+        rmdir /mnt/pnd/$BASENAME
+        rmdir /mnt/utmp/$BASENAME
+fi
diff --git a/testdata/pndsample/x86_echo.pnd b/testdata/pndsample/x86_echo.pnd
new file mode 100644 (file)
index 0000000..a5ff2db
Binary files /dev/null and b/testdata/pndsample/x86_echo.pnd differ
diff --git a/testdata/pndsample/x86_echo/PXML.xml b/testdata/pndsample/x86_echo/PXML.xml
new file mode 100644 (file)
index 0000000..8523743
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<PXML>
+<title>
+       <en>x86 echo</en>
+       <de>Program Title in German Language</de>
+       <fr>Program Title in French Language</fr>
+       <it>Program Title in Italian Language</it>
+</title>
+
+<unique_id>123456x86echo</unique_id>
+
+<standalone>Yes</standalone>
+
+<exec>my_echo</exec>
+
+<category>
+       <main>Main category</main>
+       <subcategory1>Subcategory 1</subcategory1>
+       <subcategory2>Subcategory 2</subcategory2>
+</category>
+
+<clockspeed>200</clockspeed>
+
+</PXML>
diff --git a/testdata/pndsample/x86_echo/my_echo b/testdata/pndsample/x86_echo/my_echo
new file mode 100755 (executable)
index 0000000..36c9fc2
Binary files /dev/null and b/testdata/pndsample/x86_echo/my_echo differ
index 7ff984d..dfea9e6 100644 (file)
Binary files a/testdata/pndsample/x86_ls.pnd and b/testdata/pndsample/x86_ls.pnd differ
index 7977b97..7a77137 100644 (file)
@@ -11,7 +11,7 @@
 
 <standalone>Yes</standalone>
 
-<icon>program.png</icon>
+<icon>zeldaicon.png</icon>
 
 <description>
        <en>This is the [b]English Description[/b] of the file.
diff --git a/testdata/pndsample/x86_ls/zeldaicon.png b/testdata/pndsample/x86_ls/zeldaicon.png
new file mode 100644 (file)
index 0000000..140a393
Binary files /dev/null and b/testdata/pndsample/x86_ls/zeldaicon.png differ