updated pnd_run which now uses sudo (needs edit to /etc/sudoers to work), now works nicely even as non-root!
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 testdata/apps/*.pnd
+ ${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 testdata/dotdesktop/*.png
find . -name "*~*" -exec rm {} \; -print
# component targets
* NOTE: clock speed will be set prior to invoking the script, and set back on exit
* NOTE: No values can be except clockspeed; a 0 clockspeed means 'leave alone'. Set startdoir to "." instead of NULL.
* fork() is implied; calling this function does not kill this process :)
+ * NOTE: PAss in the full path to the awesomeapp.pnd or to the directory containing PXML.xml (not the PXML.xml itself.)
*/
unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, unsigned int clockspeed );
typedef struct {
// base
unsigned char object_type; // see enum above
- char *path_to_object; // full path to the PXML.xml or awesomeapp.pnd file
+ char *object_path; // directory containing pnd or PXML.xml (does not include filename)
+ char *object_filename; // filename within object_path of the app: the PXML.xml or awesomeapp.pnd file itself
unsigned int pnd_icon_pos; // offset to the byte after end of PXML in a pnd file (should be icon if present)
// strdup'd from PXML
char *title_en;
argv [ f++ ] = fullpath;
argv [ f++ ] = "-e";
argv [ f++ ] = rel_exec;
+ argv [ f++ ] = "-s";
+ argv [ f++ ] = rel_startdir;
// skip -a (arguments) for now
//argv [ f++ ] = "-b";
#include <stdio.h> /* for FILE etc */
#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for unlink */
#define __USE_GNU /* for strcasestr */
#include <string.h> /* for making ftw.h happy */
p = pnd_box_allocinsert ( disco_box, (char*) fpath, sizeof(pnd_disco_t) );
- // base path
- p -> path_to_object = strdup ( fpath );
- if ( ( fixpxml = strcasestr ( p -> path_to_object, PXML_FILENAME ) ) ) {
+ // base paths
+ p -> object_path = strdup ( fpath );
+
+ if ( ( fixpxml = strcasestr ( p -> object_path, PXML_FILENAME ) ) ) {
*fixpxml = '\0'; // if this is not a .pnd, lop off the PXML.xml at the end
+ } else if ( ( fixpxml = strrchr ( p -> object_path, '/' ) ) ) {
+ *(fixpxml+1) = '\0'; // for pnd, lop off to last /
+ }
+
+ if ( ( fixpxml = strrchr ( fpath, '/' ) ) ) {
+ p -> object_filename = strdup ( fixpxml + 1 );
}
// png icon path
#endif
if ( p -> exec ) {
- snprintf ( buffer, 1020, "Exec=%s -p %s -e %s -u\n", pndrun, p -> path_to_object, p -> exec );
+ if ( p -> object_type == pnd_object_type_directory ) {
+ snprintf ( buffer, 1020, "Exec=%s -p %s -e %s -u\n", pndrun, p -> object_path, p -> exec );
+ } else if ( p -> object_type == pnd_object_type_pnd ) {
+ snprintf ( buffer, 1020, "Exec=%s -p %s/%s -e %s -u\n", pndrun, p -> object_path, p -> object_filename, p -> exec );
+ }
fprintf ( f, "%s", buffer );
}
}
unsigned char pnd_emit_icon ( char *targetpath, pnd_disco_t *p ) {
- char buffer [ FILENAME_MAX ];
+ char buffer [ FILENAME_MAX ]; // target filename
+ char from [ FILENAME_MAX ]; // source filename
char bits [ 8 * 1024 ];
unsigned int bitlen;
+ FILE *pnd, *target;
+
+ // prelim
+ if ( ( p -> object_type == pnd_object_type_pnd ) &&
+ ( ! p -> pnd_icon_pos ) )
+ {
+ return ( 0 ); // discover code didn't find it, so FAIL
+ }
- // filename
- sprintf ( buffer, "%s/%u.png", targetpath, p -> unique_id );
+ // filenames
+ sprintf ( buffer, "%s/%s.png", targetpath, p -> unique_id ); // target
// first.. are we looking through a pnd file or a dir?
if ( p -> object_type == pnd_object_type_directory ) {
} else if ( p -> object_type == pnd_object_type_pnd ) {
// if we can get it from pnd file, copy it into destination
- if ( ! p -> pnd_icon_pos ) {
- return ( 0 ); // discover code didn't find it, so FAIL
- }
-
- FILE *pnd, *target;
unsigned int len;
- pnd = fopen ( p -> path_to_object, "r" );
+ sprintf ( from, "%s/%s", p -> object_path, p -> object_filename ); // target
+
+ pnd = fopen ( from, "r" );
if ( ! pnd ) {
return ( 0 );
} else {
printf ( "%s [-e] [-i] [-d]\n", argv [ 0 ] );
printf ( "-e\tOptional. Attempt to exec a random app.\n" );
- printf ( "-i\tOptional. Attempt to dump icon files from the end of pnd's to /tmp.\n" );
- printf ( "-d\tOptional. Attempt to dump dotdesktop files from the end of pnd's to /tmp.\n" );
+ printf ( "-i\tOptional. Attempt to dump icon files from the end of pnd's to ./testdata/dotdesktop.\n" );
+ printf ( "-d\tOptional. Attempt to dump dotdesktop files from the end of pnd's to ./testdata/dotdesktop.\n" );
exit ( 0 );
}
printf ( "App: %s (type %u)\n", pnd_box_get_key ( d ), d -> object_type );
- printf ( " Base path: %s\n", d -> path_to_object );
+ printf ( " Base path: %s filename: %s\n", d -> object_path, d -> object_filename );
if ( d -> title_en ) {
printf ( " Name: %s\n", d -> title_en );
}
if ( do_dotdesktop ) {
- pnd_emit_dotdesktop ( "/tmp", pndrun, d );
+ pnd_emit_dotdesktop ( "./testdata/dotdesktop", pndrun, d );
}
if ( do_icon ) {
- pnd_emit_icon ( "/tmp", d );
+ pnd_emit_icon ( "./testdata/dotdesktop", d );
}
// next!
d = pnd_box_get_next ( d );
if ( d ) {
- pnd_apps_exec ( pndrun, d -> path_to_object, d -> unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ) );
+ char fullpath [ FILENAME_MAX ];
+ if ( d -> object_type == pnd_object_type_directory ) {
+ sprintf ( fullpath, "%s", d -> object_path );
+ } else if ( d -> object_type == pnd_object_type_pnd ) {
+ sprintf ( fullpath, "%s/%s", d -> object_path, d -> object_filename );
+ }
+ printf ( "Trying to exec '%s'\n", fullpath );
+ pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ) );
}
}
# -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: -- "$@"`
+TEMP=`getopt -o p:e:a:b:s:u:: --long p-long,e-long:,a-long: -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
#detect fs
if [ $DFS = ISO ]; then
- mntline="mount -o loop,fmask=000 $PND /mnt/pnd/$BASENAME"
+ mntline="sudo mount -o loop,mode=777 $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"
+ mntline="sudo mount --bind -o ro $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
#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
+if [ ! -d /mnt/pnd/$BASENAME ]; then sudo mkdir -p /mnt/pnd/$BASENAME ; fi
+if [ ! -d $MOUNTPOINT/appdata/$BASENAME ]; then sudo mkdir -p $MOUNTPOINT/appdata/$BASENAME; fi
+if [ ! -d /mnt/utmp/$BASENAME ]; then sudo 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
+ mount | grep "on /mnt/utmp/$BASENAME type" # > /dev/null
if [ ! $? -eq 0 ]; then
-
+ echo "mounting union!"
$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?
+
+ sudo mount -t aufs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro none /mnt/utmp/$BASENAME # put union on top
else
- echo "doh!"
+ echo "Union already mounted"
fi
#start app
cd /mnt/utmp/$BASENAME
if [ $STARTDIR ]; then cd $STARTDIR; fi
- $EXENAME $ARGUMENTS
+ ./$EXENAME $ARGUMENTS
#app exited
+ cd $oCWD
else
$mntline
cd /mnt/pnd/$BASENAME
if [ $STARTDIR ]; then cd $STARTDIR; fi
- $EXENAME $ARGUMENTS
+ echo $(pwd)
+ ./$EXENAME $ARGUMENTS
+ cd $oCWD
fi
#clean up
-umount /mnt/utmp/$BASENAME
+if [ ! $UNION ] ; then sudo umount /mnt/utmp/$BASENAME; fi
+if [ $UNION ] ; then sudo umount /mnt/pnd/$BASENAME; fi
if [ $? -eq 0 ]; then
-
- umount /mnt/pnd/$BASENAME
- rmdir /mnt/pnd/$BASENAME
- rmdir /mnt/utmp/$BASENAME
-
+ sudo umount /mnt/pnd/$BASENAME
+ sudo rmdir /mnt/pnd/$BASENAME
+ if [ ! $UNION ] ; then sudo rmdir /mnt/utmp/$BASENAME; fi
fi