3e8ad8bcff9707e0a9fed0a3047ffe757f2a84ea
[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:c -- "$@"`
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                 -c) echo "-c set, will create compressed squasfs image instead of iso $2" ;SQUASH=1;shift 1 ;;
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 #generate pxml if guess or empty
25 if [ ! $PXML ] || [ $PXML = "guess" ] && [  $PNDNAME ] && [ $FOLDER ];  then
26         PXMLtxt=$(/home/user/libpnd/pandora-libraries/testdata/scripts/genpxml.sh $FOLDER $ICON)
27         PXML=$FOLDER/PXML.xml
28         echo "$PXMLtxt" > $FOLDER/PXML.xml
29 fi
30  
31 #check arguments
32 if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then
33         echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x 
34         your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png"
35         exit 1
36 fi
37 if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists
38 if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists
39  
40 #make iso from folder
41 if [ ! $SQUASH ]; then
42         mkisofs -o $PNDNAME.iso -R $FOLDER
43 else
44         if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') = 0 ]; then
45                 echo "your squashfs version is older then version 4, pleas upgrade to 4.0 or later"
46                 exit 1
47         fi
48         mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery
49 fi
50 #append pxml to iso
51 cat $PNDNAME.iso $PXML >  $PNDNAME
52 rm $PNDNAME.iso #cleanup
53  
54 #append icon if specified
55 if [ $ICON ]; then # check if we want to add an icon
56         if [ ! -f $ICON ]; then #does the icon actually exist?
57                 echo "$ICON doesnt exist"
58         else # yes
59         mv $PNDNAME $PNDNAME.tmp
60         cat $PNDNAME.tmp $ICON > $PNDNAME # append icon
61         rm $PNDNAME.tmp #cleanup
62         fi
63 fi
64  
65 if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup