2586ac68ec30ac9b24c95752617d0f38e88bc993
[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 # \!/ black magic ahead
5  
6 TEMP=`getopt -o p:d:x:i: -- "$@"`
7  
8 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
9  
10 eval set -- "$TEMP"
11 while true ; do
12         case "$1" in
13                 -p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;;
14                 -d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;;
15                 -x) echo "PXML set to $2" ;PXML=$2;shift 2 ;;
16                 -i) echo "ICON set to $2" ;ICON=$2;shift 2 ;;
17                 --) shift ; break ;;
18                 *) echo "Error while parsing arguments! $2" ; exit 1 ;;
19         esac
20 done
21  
22 rnd=$RANDOM; # random number for genpxml and index$rnd.xml
23  
24 if [ $PXML = "guess" ] && [  $PNDNAME ] && [ $FOLDER ];  then
25         PXMLtxt=$(~/pndtest/genxml.sh $FOLDER $ICON)
26         PXML=tmp$rnd.pxml
27         echo "$PXMLtxt" > tmp$rnd.pxml
28 fi
29  
30 if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then
31         echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x 
32         your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png"
33         exit 1
34 fi
35  
36 if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi
37 if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi
38  
39  
40 mkisofs -o $PNDNAME.iso -R $FOLDER
41 #pxmlstart=$(stat -c%s "$PNDNAME.iso")
42  
43 cat $PNDNAME.iso $PXML >  $PNDNAME
44 rm $PNDNAME.iso
45  
46 if [ $ICON ]; then # is -i used?
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
52         fi
53 fi
54  
55 if [ $PXML = "guess" ];then rm tmp$rnd.pxml; fi
56  
57 #printf %08d $pxmlstart >> $PNDNAME #append end of iso/start of pxml offset
58