6 -s|--src <src dir> : Define source directory (default: $SRCDIR)
7 -n|--name <name> : Define the pnd base name (default: $PND_NAME)
8 -d|--dest <dest dir> : Define destination directory (default: $DESTDIR)
9 -a|--author <name> : programmers names (default: $AUTHOR)
10 -v|--version <version> : Define the version (default: $VERSION)
11 -w|--website <url> : Define the url (default: $WEBSITE)
12 -b|--build <build id> : Define the build number (default: $BUILD)
13 -f|--force : overide PXML.xml file if found
14 -h|--help : show this screen
22 buildApplicationList(){
23 #output "<appname> [<desktopfile>]" lines
25 DESTLST=$(find $SRCDIR -name "*desktop";find $DESTDIR -name "*desktop")
26 if [ ! -z "$DESTLST" ];then
29 EXE=$(awk -F= '/Exec/{print $2}'<$d|awk '{print $1}'|head -1)
30 if [[ "x$EXE" != "x" ]];then
31 BIN=$(find . -executable -type f -name $(basename $EXE)|head -1)
35 }|sort|awk 'BEGIN{P=""}$1!=P{print}{P=$1}'
37 find . -executable -type f \! -name "*sh"
43 L=$(find . -type d -name bin)
44 echo $L|sed "s#\./#$(pwd)/#g;s# #:#g"
48 L=$(find . -type d -name lib)
49 echo $L|sed "s#\./#$(pwd)/#g;s# #:#g"
53 S="$DESTDIR/scripts/$(basename $1).sh"
59 export PATH="$(getPATH):\${PATH:-"/usr/bin:/bin:/usr/local/bin"}"
60 export LD_LIBRARY_PATH="$(getLIBPATH):\${LD_LIBRARY_PATH:-"/usr/lib:/lib"}"
61 export HOME="/mnt/utmp/$PND_NAME" XDG_CONFIG_HOME="/mnt/utmp/$PND_NAME"
63 if [ -d /mnt/utmp/$PND_NAME/share ];then
64 export XDG_DATA_DIRS=/mnt/utmp/$PND_NAME/share:\$XDG_DATA_DIRS:/usr/share
66 export SDL_AUDIODRIVER="alsa"
68 [ -e "\$HOME/scripts/pre_script.sh" ] && . \$HOME/scripts/pre_script.sh
69 if [ -e "\$HOME/scripts/post_script.sh" ];then
71 . \$HOME/scripts/post_script.sh
79 desktop2application(){ #generate PXML application info out of a desktop file passed as parameter
81 if [ ! -z "$DESK" ];then
82 DVERSION=$(awk -F= '$1=="Version"{print $2}'<$1)
83 if [ -z "$DVERSION" ] || [[ "$DVERSION" = "1.0" ]];then
89 MAJOR=$(echo $DVERSION|awk -F. '{print $1}')
90 MINOR=$(echo $DVERSION|awk -F. '{print $2}')
91 REL=$(echo $DVERSION|awk -F. '{print $3}')
95 # Exec --------------------------
96 echo " <exec command=\"scripts/${BASEB}.sh\"/>"
98 # title -------------------------
99 if [ ! -z "$DESK" ];then
100 #awk -F= '($1~/^Name/)||$1=="Name"{print $1" "$2}'<$1|while read DN DNV;do
101 awk -F= '($1~/^Name/&&/en_US/)||$1=="Name"{print $1" "$2}'<$1|while read DN DNV;do
102 l=$(echo $DN|sed 's/Name//;s/\[//;s/\]//')
103 echo " <title lang=\"${l:-"en_US"}\">$DNV</title>"
106 echo " <title lang=\"en_US\">$PND_NAME</title>"
110 # Author ------------------------
111 echo " <author name=\"$AUTHOR\" website=\"$WEBSITE\"/>"
113 # Version -----------------------
114 echo " <version major=\"$MAJOR\" minor=\"$MINOR\" release=\"$REL\" build=\"$BUILD\"/> <!--This programs version-->"
116 # OS Version --------------------
117 echo " <osversion major=\"1\" minor=\"0\" release=\"0\" build=\"0\"/> <!--The minimum OS version required-->"
120 # Description -------------------
121 if [ ! -z "$DESK" ];then
122 #awk -F= '($1~/^Comment/)||$1=="Comment"{print $1" "$2}'<$1|while read DN DNV;do
123 awk -F= '($1~/^Comment/&&/en_US/)||$1=="Comment"{print $1" "$2}'<$1|while read DN DNV;do
124 l=$(echo $DN|sed 's/Comment//;s/\[//;s/\]//')
125 echo " <description lang=\"${l:-"en_US"}\">$DNV</description>"
128 echo " <description lang=\"en_US\">Automatically generated description from $(pwd) for PND=$PND_NAME</description>"
132 # Icon --------------------------
134 if [ ! -z "$DESK" ];then
135 ICON=$(awk -F= '$1~/^Icon/{print $2}'<$1)
137 if [ ! -z "$ICON" ];then
138 F=$(find $DESTDIR -name ${ICON}.png|head -1)
142 echo " <icon src="'"'$F'"/>'
143 if [ ! -e "$DESTDIR/icon.png" ] && [ ! -z "$(find $DESTDIR -name ${ICON}.png|head -1)" ];then
144 cp $(find $DESTDIR -name ${ICON}.png|head -1) $DESTDIR/icon.png
146 elif [ -e "$DESTDIR/icon.png" ];then
147 echo " <icon src=\"$DESTDIR/icon.png\"/>"
149 echo " <!--<icon src=\"path/to/icon.pnd\"/>-->"
153 # Preview pics ------------------
154 if [ ! -z "$(find $DESTDIR/previews -name "$BASEB*")" ];then
155 echo " <previewpics>"
156 for i in $(find $DESTDIR/previews -name "$BASEB*");do
157 echo " <pic src=\"previews/$(basename $i)\"/>"
159 echo " </previewpics>"
164 <pic src="previews/${BASEB}.png"/>
171 # Documentation -----------------
172 HTML=$(find $DESTDIR -type d -name index.html|head -1)
173 DOC=$DESTDIR/readme.txt
174 if [ ! -z "$HTML" ];then
175 for i in $(find $DESTDIR -type d -name index.html);do
176 echo " <info name=\"${BASEB} documentation\" type=\"text/html\" src=\"$i\"/>"
178 elif [ -e "$DOC" ];then
179 echo " <info name=\"${BASEB} documentation\" type=\"text/plain\" src=\"$DOC\"/>"
181 echo " <!--<info name=\"${BASEB} documentation\" type=\"text/plain\" src=\"$DOC\"/>-->"
184 # Categories --------------------
188 <!-- http://standards.freedesktop.org/menu-spec/latest/apa.html -->
191 if [ ! -z "$DESK" ];then
192 DCAT=$(awk -F= '$1=="Categories"{print $2}'<$1)
196 CATCNT=$(($(echo $DCAT|sed "s/;/ /g"|wc -w) / 2))
197 if [ $CATCNT -gt 0 ];then
198 for i in $(seq 1 $CATCNT);do
199 DCATMAJ=$(echo $DCAT|awk -F\; "{print \$$(($i*2-1))}")
200 DCATMIN=$(echo $DCAT|awk -F\; "{print \$$(($i*2))}")
202 <category name="$DCATMAJ">
203 <subcategory name="$DCATMIN"/>
209 <category name="Game">
210 <subcategory name="ArcadeGame"/>
219 # Associations ------------------
223 <association name="Deinterlaced Bitmap Image" filetype="image/bmp" exec="-f %s"/>
224 <association name="Style sheet system crasher" filetype="text/css" exec="-f %s"/>
229 # ClockSpeed --------------------
230 echo " <!--<clockspeed frequency=\"600\"/>-->"
234 # output the PXML.xml file
235 if [ -e $DESTDIR/PXML.xml ];then
236 mv $DESTDIR/PXML.xml $DESTDIR/PXML.xml.old
238 cat >$DESTDIR/PXML.xml <<ENDHEAD
239 <?xml version="1.0" encoding="UTF-8"?>
240 <PXML xmlns="http://openpandora.org/namespaces/PXML">
241 <!-- please see http://pandorawiki.org/PXML_specification for more information before editing, and remember the order does matter -->
244 if [ ! -d $DESTDIR/previews ];then
245 mkdir -p $DESTDIR/previews
247 if [ ! -d $DESTDIR/scripts ];then
248 mkdir $DESTDIR/scripts
250 buildApplicationList|while read BIN DESK;do
251 BASEB=$(basename $BIN)
253 cat >>$DESTDIR/PXML.xml <<ENDAPP
254 <application id="$PND_NAME-$(basename $BIN)-$RND" appdata="$PND_NAME">
256 desktop2application $DESK >>$DESTDIR/PXML.xml
257 cat >>$DESTDIR/PXML.xml <<ENDINFO
262 echo "</PXML>" >>$DESTDIR/PXML.xml
266 #####################
273 WEBSITE=${WEBSITE:-"http://www..openpandora.org"}
274 SRCDIR=${SRCDIR:-$(pwd)}
276 PND_NAME=${PND_NAME:-$(basename $SRCDIR|awk -F- '{print $1}')}
277 VERSION=${VERSION:-$(basename $SRCDIR|awk -F- '{print $2}')}
278 DESTDIR=${DESTDIR:-"/mnt/utmp/$PND_NAME"}
281 while [ $# -gt 0 ];do
283 -s|--src) SRCDIR=$2;shift;;
284 -d|--dest) DESTDIR=$2;shift;;
285 -b|--build) BUILD=$2;shift;;
286 -a|--author) AUTHOR=$2;shift;;
287 -n|--name) PND_NAME=$2;shift;;
288 -v|--version) VERSION=$2;shift;;
289 -w|--website) WEBSITE=$2;shift;;
290 -f|--force) FORCE=1;;
291 -h|--help) help;exit 1;;
292 *) echo "'$1' unknown argument">&2;help;exit 2;;
298 if [ ! -d $SRCDIR ];then
299 echo "$SRCDIR don't exist" >&2
303 if [ ! -d $DESTDIR ] && [ $FORCE -eq 0 ];then
304 echo "$DESTDIR don't exist" >&2
307 elif [ ! -d $DESTDIR ];then
310 echo "$DESTDIR don\'t exist and cannot be created" >&2
315 if [ $(buildApplicationList|wc -l) -le 0 ];then
316 echo "No applications found">&2
320 if [ -e $DESTDIR/PXML.xml ] && [ $FORCE -eq 0 ];then
321 echo "PXML file exist and force disabled." >&2