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"
60 export PATH="$(getPATH):\${PATH:-"/usr/bin:/bin:/usr/local/bin"}"
61 export LD_LIBRARY_PATH="$(getLIBPATH):\${LD_LIBRARY_PATH:-"/usr/lib:/lib"}"
62 export HOME="/mnt/utmp/$PND_NAME" XDG_CONFIG_HOME="/mnt/utmp/$PND_NAME"
64 if [ -d /mnt/utmp/$PND_NAME/share ];then
65 export XDG_DATA_DIRS=/mnt/utmp/$PND_NAME/share:\$XDG_DATA_DIRS:/usr/share
67 export SDL_AUDIODRIVER="alsa"
69 [ -e "\$HOME/scripts/pre_script.sh" ] && . \$HOME/scripts/pre_script.sh
70 if [ -e "\$HOME/scripts/post_script.sh" ];then
72 . \$HOME/scripts/post_script.sh
80 desktop2application(){ #generate PXML application info out of a desktop file passed as parameter
82 if [ ! -z "$DESK" ];then
83 DVERSION=$(awk -F= '$1=="Version"{print $2}'<$1)
84 if [ -z "$DVERSION" ] || [[ "$DVERSION" = "1.0" ]];then
90 MAJOR=$(echo $DVERSION|awk -F. '{print $1}')
91 MINOR=$(echo $DVERSION|awk -F. '{print $2}')
92 REL=$(echo $DVERSION|awk -F. '{print $3}')
96 # Exec --------------------------
97 echo " <exec command=\"scripts/${BASEB}.sh\"/>"
99 # title -------------------------
100 if [ ! -z "$DESK" ];then
101 #awk -F= '($1~/^Name/)||$1=="Name"{print $1" "$2}'<$1|while read DN DNV;do
102 awk -F= '($1~/^Name/&&/en_US/)||$1=="Name"{print $1" "$2}'<$1|while read DN DNV;do
103 l=$(echo $DN|sed 's/Name//;s/\[//;s/\]//')
104 echo " <title lang=\"${l:-"en_US"}\">$DNV</title>"
107 echo " <title lang=\"en_US\">$PND_NAME</title>"
111 # Author ------------------------
112 echo " <author name=\"$AUTHOR\" website=\"$WEBSITE\"/>"
114 # Version -----------------------
115 echo " <version major=\"$MAJOR\" minor=\"$MINOR\" release=\"$REL\" build=\"$BUILD\"/> <!--This programs version-->"
117 # OS Version --------------------
118 echo " <osversion major=\"1\" minor=\"0\" release=\"0\" build=\"0\"/> <!--The minimum OS version required-->"
121 # Description -------------------
122 if [ ! -z "$DESK" ];then
123 #awk -F= '($1~/^Comment/)||$1=="Comment"{print $1" "$2}'<$1|while read DN DNV;do
124 awk -F= '($1~/^Comment/&&/en_US/)||$1=="Comment"{print $1" "$2}'<$1|while read DN DNV;do
125 l=$(echo $DN|sed 's/Comment//;s/\[//;s/\]//')
126 echo " <description lang=\"${l:-"en_US"}\">$DNV</description>"
129 echo " <description lang=\"en_US\">Automatically generated description from $(pwd) for PND=$PND_NAME</description>"
133 # Icon --------------------------
135 if [ ! -z "$DESK" ];then
136 ICON=$(awk -F= '$1~/^Icon/{print $2}'<$1)
138 if [ ! -z "$ICON" ];then
139 F=$(find $DESTDIR -name ${ICON}.png|head -1)
143 echo " <icon src="'"'$F'"/>'
144 if [ ! -e "$DESTDIR/icon.png" ] && [ ! -z "$(find $DESTDIR -name ${ICON}.png|head -1)" ];then
145 cp $(find $DESTDIR -name ${ICON}.png|head -1) $DESTDIR/icon.png
147 elif [ -e "$DESTDIR/icon.png" ];then
148 echo " <icon src=\"$DESTDIR/icon.png\"/>"
150 echo " <!--<icon src=\"path/to/icon.pnd\"/>-->"
154 # Preview pics ------------------
155 if [ ! -z "$(find $DESTDIR/previews -name "$BASEB*")" ];then
156 echo " <previewpics>"
157 for i in $(find $DESTDIR/previews -name "$BASEB*");do
158 echo " <pic src=\"previews/$(basename $i)\"/>"
160 echo " </previewpics>"
161 elif [ $(buildApplicationList|wc -l) -eq 1 ] && [ ! -z "$(find $DESTDIR/previews -type f)" ];then
162 echo " <previewpics>"
163 for i in $(find $DESTDIR/previews -type f);do
164 echo " <pic src=\"previews/$(basename $i)\"/>"
166 echo " </previewpics>"
171 <pic src="previews/${BASEB}.png"/>
177 # Preview pics ------------------
181 <license name="GPLv3" url="http://www.gnu.org/copyleft/gpl.html" sourcecodeurl="http://www.kernel.org/default"/>
187 # Documentation -----------------
188 HTML=$(find $DESTDIR -type d -name index.html|head -1)
189 DOC=$DESTDIR/readme.txt
190 if [ ! -z "$HTML" ];then
191 for i in $(find $DESTDIR -type d -name index.html);do
192 echo " <info name=\"${BASEB} documentation\" type=\"text/html\" src=\"$i\"/>"
194 elif [ -e "$DOC" ];then
195 echo " <info name=\"${BASEB} documentation\" type=\"text/plain\" src=\"$DOC\"/>"
197 echo " <!--<info name=\"${BASEB} documentation\" type=\"text/plain\" src=\"$DOC\"/>-->"
200 # Categories --------------------
204 <!-- http://standards.freedesktop.org/menu-spec/latest/apa.html -->
207 if [ ! -z "$DESK" ];then
208 DCAT=$(awk -F= '$1=="Categories"{print $2}'<$1)
212 CATCNT=$(($(echo $DCAT|sed "s/;/ /g"|wc -w) / 2))
213 if [ $CATCNT -gt 0 ];then
214 for i in $(seq 1 $CATCNT);do
215 DCATMAJ=$(echo $DCAT|awk -F\; "{print \$$(($i*2-1))}")
216 DCATMIN=$(echo $DCAT|awk -F\; "{print \$$(($i*2))}")
218 <category name="$DCATMAJ">
219 <subcategory name="$DCATMIN"/>
225 <category name="Game">
226 <subcategory name="ArcadeGame"/>
235 # Associations ------------------
239 <association name="Deinterlaced Bitmap Image" filetype="image/bmp" exec="-f %s"/>
240 <association name="Style sheet system crasher" filetype="text/css" exec="-f %s"/>
245 # ClockSpeed --------------------
246 echo " <!--<clockspeed frequency=\"600\"/>-->"
250 # output the PXML.xml file
251 if [ -e $DESTDIR/PXML.xml ];then
252 mv $DESTDIR/PXML.xml $DESTDIR/PXML.xml.old
255 MAJOR=$(echo $VERSION|awk -F. '{print $1}')
256 MINOR=$(echo $VERSION|awk -F. '{print $2}')
257 REL=$(echo $DVERSION|awk -F. '{print $3}')
261 cat >$DESTDIR/PXML.xml <<ENDHEAD
262 <?xml version="1.0" encoding="UTF-8"?>
263 <PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd">
264 <!-- please see http://pandorawiki.org/PXML_specification for more information before editing, and remember the order does matter -->
266 <package id="$PND_NAME">
267 <author name="$AUTHOR" website="$WEBSITE"/>
268 <version major="$MAJOR" minor="$MINOR" release="$REL" build="$BUILD"/>
270 <title lang="en_US">$PND_NAME</title>
273 <description lang="en_US">$PND_NAME</description>
278 if [ ! -d $DESTDIR/previews ];then
279 mkdir -p $DESTDIR/previews
281 if [ ! -d $DESTDIR/scripts ];then
282 mkdir $DESTDIR/scripts
284 buildApplicationList|while read BIN DESK;do
285 BASEB=$(basename $BIN)
287 cat >>$DESTDIR/PXML.xml <<ENDAPP
288 <application id="$PND_NAME-$(basename $BIN)-$RND" appdata="$PND_NAME">
290 desktop2application $DESK >>$DESTDIR/PXML.xml
291 cat >>$DESTDIR/PXML.xml <<ENDINFO
296 echo "</PXML>" >>$DESTDIR/PXML.xml
300 #####################
306 AUTHOR=${AUTHOR:-${PND_AUTHOR:-"$(whoami)"}}
307 WEBSITE=${WEBSITE:-${PND_WEBSITE:-"http://www.openpandora.org/"}}
308 SRCDIR=${SRCDIR:-$(pwd)}
309 PND_NAME=${PND_NAME:-${PRJ:-$(basename $SRCDIR|awk -F- '{print $1}')}}
310 VERSION=${VERSION:-$(basename $SRCDIR|awk -F- '{print $2}')}
311 DESTDIR=${DESTDIR:-"/mnt/utmp/$PND_NAME"}
314 while [ $# -gt 0 ];do
316 -s|--src) SRCDIR=$2;shift;;
317 -d|--dest) DESTDIR=$2;shift;;
318 -b|--build) BUILD=$2;shift;;
319 -a|--author) AUTHOR=$2;shift;;
320 -n|--name) PND_NAME=$2;shift;;
321 -v|--version) VERSION=$2;shift;;
322 -w|--website) WEBSITE=$2;shift;;
323 -f|--force) FORCE=1;;
324 -h|--help) help;exit 1;;
325 *) echo "'$1' unknown argument">&2;help;exit 2;;
331 if [ ! -d $SRCDIR ];then
332 echo "$SRCDIR don't exist" >&2
336 if [ ! -d $DESTDIR ] && [ $FORCE -eq 0 ];then
337 echo "$DESTDIR don't exist" >&2
340 elif [ ! -d $DESTDIR ];then
343 echo "$DESTDIR don\'t exist and cannot be created" >&2
348 if [ $(buildApplicationList|wc -l) -le 0 ];then
349 echo "No applications found">&2
353 if [ -e $DESTDIR/PXML.xml ] && [ $FORCE -eq 0 ];then
354 echo "PXML file exist and force disabled." >&2