Set permissions for appdata folder
[pandora-libraries.git] / testdata / scripts / pnd_make.sh
1 #!/bin/bash
2  
3 ######adjust path of genpxml.sh if you want to use that "feture"#####
4  
5 TEMP=`getopt -o p:d:x:i: -- "$@"`
6  
7 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
8  
9 eval set -- "$TEMP"
10 while true ; do
11         case "$1" in
12                 -p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;;
13                 -d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;;
14                 -x) echo "PXML set to $2" ;PXML=$2;shift 2 ;;
15                 -i) echo "ICON set to $2" ;ICON=$2;shift 2 ;;
16                 --) shift ; break ;;
17                 *) echo "Error while parsing arguments! $2" ; exit 1 ;;
18         esac
19 done
20  
21 rnd=$RANDOM; # random number for genpxml and index$rnd.xml
22  
23 #generate pxml if guess or empty
24 if [ ! $PXML ] || [ $PXML = "guess" ] && [  $PNDNAME ] && [ $FOLDER ];  then
25         PXMLtxt=$(./genpxml.sh $FOLDER $ICON)
26         PXML=tmp$rnd.pxml
27         echo "$PXMLtxt" > tmp$rnd.pxml
28 fi
29  
30 #check arguments
31 if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then
32         echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x 
33         your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png"
34         exit 1
35 fi
36 if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists
37 if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists
38  
39 #make iso from folder
40 mkisofs -o $PNDNAME.iso -R $FOLDER
41 #append pxml to iso
42 cat $PNDNAME.iso $PXML >  $PNDNAME
43 rm $PNDNAME.iso #cleanup
44  
45 #append icon if specified
46 if [ $ICON ]; then # check if we want to add an icon
47         if [ ! -f $ICON ]; then #does the icon actually exist?
48                 echo "$ICON doesnt exist"
49         else # yes
50         mv $PNDNAME $PNDNAME.tmp
51         cat $PNDNAME.tmp $ICON > $PNDNAME # append icon
52         rm $PNDNAME.tmp #cleanup
53         fi
54 fi
55  
56 if [ $PXML = "guess" ];then rm tmp$rnd.pxml; fi #cleanup