[Scummvm-cvs-logs] scummvm master -> b27e6ac1dcaa678f7f078f6ded12ee784e44baf2

djwillis John.Willis at Distant-earth.com
Thu Jul 7 22:46:23 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b27e6ac1dc OPENPANDORA: Update support scripts that create .PND distribution file.


Commit: b27e6ac1dcaa678f7f078f6ded12ee784e44baf2
    https://github.com/scummvm/scummvm/commit/b27e6ac1dcaa678f7f078f6ded12ee784e44baf2
Author: David-John Willis (John.Willis at Distant-earth.com)
Date: 2011-07-07T13:43:08-07:00

Commit Message:
OPENPANDORA: Update support scripts that create .PND distribution file.

Changed paths:
  A backends/platform/openpandora/build/PXML_schema.xsd
    backends/platform/openpandora/build/PXML.xml
    backends/platform/openpandora/build/pnd_make.sh



diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml
index f4d2e2a..a87c49e 100755
--- a/backends/platform/openpandora/build/PXML.xml
+++ b/backends/platform/openpandora/build/PXML.xml
@@ -1,34 +1,55 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd">
-
-  <application id="scummvm.djwillis.0001" appdata="scummvm">
-
-    <title lang="en_US">ScummVM</title>
-
-    <exec command="./runscummvm.sh"/>
-    <icon src="icon/scummvm.png"/>
-
-    <previewpics>
-      <pic src="icon/preview-pic.png"/>
-    </previewpics>
-
-    <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/>
-
-    <description lang="en_US">Point & click game interpreter.</description>
-
-    <author name="DJWillis" website="http://www.scummvm.org/"/>
-
-    <version major="1" minor="1" release="1" build="1"/><!--This programs version-->
-    <osversion major="1" minor="0" release="0" build="0"/><!--The minimum OS version required-->
-
-    <categories>
-      <category name="Game"><!--category like "Games", "Graphics", "Internet" etc-->
-	<subcategory name="Adventure Games"/><!--subcategory, like "Board Games", "Strategy", "First Person Shooters"-->
-      </category>
-    </categories>
-
-    <clockspeed frequency="500"/><!--Frequency in Hz-->
-
-  </application>
-
+    <!-- This is the package, in our case ScummVM -->
+    <package id="scummvm.djwillis.0001">
+        <author name="DJWillis" website="http://www.scummvm.org/"/>
+        <!-- version type can be alpha, beta or release, set to release in branch -->
+        <version major="1" minor="4" release="0" build="1" type="alpha"/>
+        <!-- Both title and titles are needed -->
+        <title lang="en_US">ScummVM</title>
+        <titles>
+            <title lang="en_US">ScummVM</title>
+        </titles>
+        <descriptions>
+            <description lang="en_US">
+                ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed!
+
+                ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more.
+            </description>
+        </descriptions>
+        <icon src="icon/scummvm.png"/>
+    </package>
+
+    <!-- This is the application, the ScummVM binary -->
+    <application id="scummvm.djwillis.0001" appdata="scummvm">
+        <exec command="./runscummvm.sh"/>
+        <author name="DJWillis" website="http://www.scummvm.org/"/>
+        <!-- version type can be alpha, beta or release, set to release in branch -->
+        <version major="1" minor="4" release="0" build="1" type="alpha"/>
+        <!-- Both title and titles are needed -->
+        <title lang="en_US">ScummVM</title>
+        <titles>
+            <title lang="en_US">ScummVM</title>
+        </titles>
+        <descriptions>
+            <description lang="en_US">
+                ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed!
+
+                ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more.
+            </description>
+        </descriptions>
+        <licenses>
+            <license name="GPLv2" url="http://www.gnu.org/licenses/gpl-2.0.html" sourcecodeurl="http://www.scummvm.org"/>
+        </licenses>
+        <icon src="icon/scummvm.png"/>
+        <previewpics>
+            <pic src="icon/preview-pic.png"/>
+        </previewpics>
+        <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/>
+        <categories>
+            <category name="Game">
+                <subcategory name="AdventureGame"/>
+            </category>
+        </categories>
+    </application>
 </PXML>
diff --git a/backends/platform/openpandora/build/PXML_schema.xsd b/backends/platform/openpandora/build/PXML_schema.xsd
new file mode 100644
index 0000000..335efe5
--- /dev/null
+++ b/backends/platform/openpandora/build/PXML_schema.xsd
@@ -0,0 +1,341 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema targetNamespace="http://openpandora.org/namespaces/PXML" xmlns="http://openpandora.org/namespaces/PXML" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
+	
+	
+	<!-- declare some simpleTypes for later usage -->
+	
+	<!-- Specify params allows with the 'x11' entry in exec -->
+	<xs:simpleType name="x11Param">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="req" />
+			<xs:enumeration value="stop" />
+			<xs:enumeration value="ignore" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Specify the valid documentation formats in the <info> block -->
+	<xs:simpleType name="docType">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="text/html" />
+			<xs:enumeration value="text/plain" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Make sure that version numbers only consist of letters, numbers and + as well as - -->
+	<xs:simpleType name="versionNumber">
+		<xs:restriction base="xs:string">
+			<xs:minLength value="1"/>
+			<xs:pattern value="[a-zA-Z0-9+-]*" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Specify what is valid as release type -->
+	<xs:simpleType name="releaseType">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="alpha" />
+			<xs:enumeration value="beta" />
+			<xs:enumeration value="release" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Specify what makes an email address "valid" -->
+	<xs:simpleType name="emailAddress">
+		<xs:restriction base="xs:string">
+			<xs:pattern value="[^@]+@[^\.]+\..+"/>
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- some restrictions regarding file names that are eg not allowed/possible when using sd cards formated as fat32 -->
+	<xs:simpleType name="dumbPath">
+		<xs:restriction base="xs:normalizedString">
+			<xs:pattern value="[^?>:]+" />
+		</xs:restriction>
+	</xs:simpleType>
+	<xs:simpleType name="dumbFolderName">
+		<xs:restriction base="xs:normalizedString">
+			<xs:pattern value="[^?>:/]+" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Specify lang codes -->
+	<xs:simpleType name="isoLangcode">
+		<xs:restriction base="xs:string">
+			<xs:minLength value="2"/>
+			<xs:pattern value="[a-zA-Z]{2,3}(_[a-zA-Z0-9]{2,3})*" />
+		</xs:restriction>
+	</xs:simpleType>
+	<xs:simpleType name="isoLangcode_en_US">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="en_US" />
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Definition of all allowed categories following the FDO specs -->
+	<xs:simpleType name="fdoCategory">
+		<xs:restriction base="xs:string">
+			<xs:pattern value="AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Settings|System|Utility"/>
+		</xs:restriction>
+	</xs:simpleType>
+	<!-- Definition of all allowed subcategories following the FDO specs (should be based upon the given main categories, but would significantly increase complexity of the schema) -->
+	<xs:simpleType name="fdoSubCategory">
+		<xs:restriction base="xs:string">
+			<xs:pattern value="Building|Debugger|IDE|GUIDesigner|Profiling|RevisionControl|Translation|Calendar|ContactManagement|Database|Dictionary|Chart|Email|Finance|FlowChart|PDA|ProjectManagement|Presentation|Spreadsheet|WordProcessor|2DGraphics|VectorGraphics|RasterGraphics|3DGraphics|Scanning|OCR|Photography|Publishing|Viewer|TextTools|DesktopSettings|HardwareSettings|Printing|PackageManager|Dialup|InstantMessaging|Chat|IRCClient|FileTransfer|HamRadio|News|P2P|RemoteAccess|Telephony|TelephonyTools|VideoConference|WebBrowser|WebDevelopment|Midi|Mixer|Sequencer|Tuner|TV|AudioVideoEditing|Player|Recorder|DiscBurning|ActionGame|AdventureGame|ArcadeGame|BoardGame|BlocksGame|CardGame|KidsGame|LogicGame|RolePlaying|Simulation|SportsGame|StrategyGame|Art|Construction|Music|Languages|Science|ArtificialIntelligence|Astronomy|Biology|Chemistry|ComputerScience|DataVisualization|Economy|Electricity|Geography|Geology|Geoscience|History|ImageProcessing|Literature|Math|NumericalAnalysis|Medi
 calSoftware|Physics|Robotics|Sports|ParallelComputing|Amusement|Archiving|Compression|Electronics|Emulator|Engineering|FileTools|FileManager|TerminalEmulator|Filesystem|Monitor|Security|Accessibility|Calculator|Clock|TextEditor|Documentation|Core|KDE|GNOME|GTK|Qt|Motif|Java|ConsoleOnly"/>
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<!-- Create some way to enforce entries to be nonempty -->
+	<xs:simpleType name="nonempty_token">
+		<xs:restriction base="xs:token">
+			<xs:minLength value="1"/>
+		</xs:restriction>
+	</xs:simpleType>
+		<xs:simpleType name="nonempty_string">
+		<xs:restriction base="xs:string">
+			<xs:minLength value="1"/>
+		</xs:restriction>
+	</xs:simpleType>
+		<xs:simpleType name="nonempty_normalizedString">
+		<xs:restriction base="xs:string">
+			<xs:minLength value="1"/>
+		</xs:restriction>
+	</xs:simpleType>
+	
+	
+	
+	<!-- declare some complexTypes for later usage -->
+	
+	<!-- type used for file associations -->
+	<xs:complexType name="association_data">
+		<xs:attribute name="name" use="required" type="nonempty_normalizedString" />
+		<xs:attribute name="filetype" use="required" type="nonempty_token" />
+		<xs:attribute name="exec" use="required" type="nonempty_token" />
+	</xs:complexType>
+	
+	<!-- type used for author info -->
+	<xs:complexType name="author_data">
+		<xs:attribute name="name" use="required" type="nonempty_normalizedString" />
+		<xs:attribute name="website" use="optional" type="xs:anyURI" />
+		<xs:attribute name="email" use="optional" type="emailAddress" />
+	</xs:complexType>
+	
+	<!-- type used for version informations (full entry as well as os version) -->
+	<xs:complexType name="app_version_info">
+		<xs:attribute name="major" use="required" type="versionNumber" />
+		<xs:attribute name="minor" use="required" type="versionNumber" />
+		<xs:attribute name="release" use="required" type="versionNumber" />
+		<xs:attribute name="build" use="required" type="versionNumber" />
+		<xs:attribute name="type" use="optional" type="releaseType" />
+	</xs:complexType>
+	<xs:complexType name="os_version_info">
+		<xs:attribute name="major" use="required" type="versionNumber" />
+		<xs:attribute name="minor" use="required" type="versionNumber" />
+		<xs:attribute name="release" use="required" type="versionNumber" />
+		<xs:attribute name="build" use="required" type="versionNumber" />
+	</xs:complexType>
+	
+	<!-- type used for exec entries -->
+	<xs:complexType name="exec_params">
+		<xs:attribute name="command" use="required" type="nonempty_token" />
+		<xs:attribute name="arguments" use="optional" type="nonempty_token" />
+		<xs:attribute name="background" use="optional" type="xs:boolean" />
+		<xs:attribute name="startdir" use="optional" type="dumbPath" />
+		<xs:attribute name="standalone" use="optional" type="xs:boolean" />
+		<xs:attribute name="x11" use="optional" type="x11Param" />
+	</xs:complexType>
+	
+	<!-- type used for tiles or descriptions, once in 'normal' version, once enforcing usage of en_US -->
+	<xs:complexType name="title_or_description">
+		<xs:simpleContent>
+			<xs:extension base="nonempty_string">
+				<xs:attribute name="lang" use="required" type="isoLangcode" />
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	<xs:complexType name="title_or_description_enUS">
+		<xs:simpleContent>
+			<xs:extension base="nonempty_string">
+				<xs:attribute name="lang" use="required" type="isoLangcode_en_US" />
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	
+	<!-- type used for referencing images -->
+	<xs:complexType name="image_entry">
+		<xs:attribute name="src" use="required" type="dumbPath" />
+	</xs:complexType>
+	
+	<!-- type for referencing manuals/readme docs -->
+	<xs:complexType name="information_entry">
+		<xs:attribute name="name" use="required" type="nonempty_normalizedString" />
+		<xs:attribute name="type" use="required" type="docType" />
+		<xs:attribute name="src" use="required" type="dumbPath" />
+	</xs:complexType>
+	
+	<!-- type used for the license information -->
+	<xs:complexType name="license_info">
+		<xs:attribute name="name" use="required" type="nonempty_normalizedString" />
+		<xs:attribute name="url" use="optional" type="xs:anyURI" />
+		<xs:attribute name="sourcecodeurl" use="optional" type="xs:anyURI" />
+	</xs:complexType>
+	
+	
+	
+	<!-- Combine the symple and complex types into the "real" PXML specification -->
+	
+	<xs:element name="PXML">
+		<xs:complexType>
+			<xs:sequence>
+				<!-- specify the <package> tag with info about the complete package, information providable:
+					author
+					version
+					title(s)
+					description(s)
+					icon
+					-->
+				<xs:element name="package" minOccurs="1" maxOccurs="1">
+					<xs:complexType>
+						<xs:all>
+							<!--Author info-->
+							<xs:element name="author" type="author_data" minOccurs="1" />
+							<!--App version info-->
+							<xs:element name="version" type="app_version_info" minOccurs="1" />
+							<!--Title-->
+							<xs:element name="titles" minOccurs="1">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" />
+										<xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Description-->
+							<xs:element name="descriptions" minOccurs="0">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="title" type="title_or_description_enUS" minOccurs="0" maxOccurs="1" />
+										<xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Icon-->
+							<xs:element name="icon" type="image_entry" minOccurs="0" />
+						</xs:all>
+						<!--Package ID-->
+						<xs:attribute name="id" use="required" type="dumbFolderName" />
+					</xs:complexType>
+				</xs:element>
+				<!-- specify the <application> tag with info about a single program
+					executable call
+					author
+					version (of the application)
+					osversion (min OS version supported)
+					title(s) (allowing compatibility to <HF6, too!)
+					description(s) (allowing compatibility to <HF6, too!)
+					icon
+					license
+					preview pictures
+					info/manual/readme entry
+					categories
+					associations to file types
+					clockspeed
+					-->
+				<xs:element name="application" minOccurs="1" maxOccurs="unbounded">
+					<xs:complexType>
+						<xs:all>
+							<!--Execution params -->
+							<xs:element name="exec" type="exec_params" minOccurs="1" />
+							<!--Author info-->
+							<xs:element name="author" type="author_data" minOccurs="1" />
+							<!--App version info-->
+							<xs:element name="version" type="app_version_info" minOccurs="1" />
+							<!--OS Version info-->
+							<xs:element name="osversion" type="os_version_info" minOccurs="0" />
+							<!--Title-->
+							<!-- via <titles> element, used for HF6+ -->
+							<xs:element name="titles" minOccurs="1">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" />
+										<xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Title-->
+							<!-- via <title> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 -->
+							<xs:element name="title" type="title_or_description_enUS" minOccurs="0" />
+							<!--Description-->
+							<!-- via <descriptions> element, used for HF6+ -->
+							<xs:element name="descriptions" minOccurs="0">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="description" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" />
+										<xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Description-->
+							<!-- via <description> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 -->
+							<xs:element name="description" type="title_or_description_enUS" minOccurs="0" />
+							<!--Icon-->
+							<xs:element name="icon" type="image_entry" minOccurs="0" />
+							<!--License-->
+							<xs:element name="licenses" minOccurs="1">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="license" type="license_info" minOccurs="1" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Preview pics-->
+							<xs:element name="previewpics" minOccurs="0">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="pic" type="image_entry" minOccurs="0" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Info (aka manual or readme entry)-->
+							<xs:element name="info" type="information_entry" minOccurs="0" />
+							<!--Categories-->
+							<xs:element name="categories" minOccurs="1">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
+											<xs:complexType>
+												<xs:sequence>
+													<xs:element name="subcategory" minOccurs="0" maxOccurs="unbounded">
+														<xs:complexType>
+															<xs:attribute name="name" type="fdoSubCategory" />
+														</xs:complexType>
+													</xs:element>
+												</xs:sequence>
+												<xs:attribute name="name" use="required" type="fdoCategory" />
+											</xs:complexType>
+										</xs:element>
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Associations-->
+							<xs:element name="associations" minOccurs="0">
+								<xs:complexType>
+									<xs:sequence>
+										<xs:element name="association" type="association_data" maxOccurs="unbounded" />
+									</xs:sequence>
+								</xs:complexType>
+							</xs:element>
+							<!--Clockspeed-->
+							<xs:element name="clockspeed" minOccurs="0">
+								<xs:complexType>
+									<xs:attribute name="frequency" use="required" type="xs:positiveInteger" />
+								</xs:complexType>
+							</xs:element>
+						</xs:all>
+						<!--AppID-->
+						<xs:attribute name="id" use="required" type="dumbFolderName" />
+						<xs:attribute name="appdata" use="optional" type="dumbFolderName" />
+					</xs:complexType>
+				</xs:element>
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>
\ No newline at end of file
diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh
index b19de87..0c03e81 100755
--- a/backends/platform/openpandora/build/pnd_make.sh
+++ b/backends/platform/openpandora/build/pnd_make.sh
@@ -1,65 +1,321 @@
-#!/bin/sh
+#!/bin/bash
+#
+# pnd_make.sh
+#
+# This script is meant to ease generation of a pnd file. Please consult the output
+# when running --help for a list of available parameters and an explaination of
+# those.
+#
+# Required tools when running the script:
+# bash
+# echo, cat, mv, rm
+# mkisofs or mksquashfs (the latter when using the -c param!)
+# xmllint (optional, only for validation of the PXML against the schema)
 
-######adjust path of genpxml.sh if you want to use that "feture"#####
 
-TEMP=`getopt -o p:d:x:i:c -- "$@"`
+PXML_schema=$(dirname ${0})/PXML_schema.xsd
+GENPXML_PATH=$(dirname ${0})/genpxml.sh
 
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+# useful functions ...
+black='\E[30m'
+red='\E[31m'
+green='\E[32m'
+yellow='\E[33m'
+blue='\E[34m'
+magenta='\E[35m'
+cyan='\E[36m'
+white='\E[37m'
 
-eval set -- "$TEMP"
-while true ; do
-	case "$1" in
-		-p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;;
-		-d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;;
-		-x) echo "PXML set to $2" ;PXML=$2;shift 2 ;;
-		-i) echo "ICON set to $2" ;ICON=$2;shift 2 ;;
-		-c) echo "-c set, will create compressed squasfs image instead of iso $2" ;SQUASH=1;shift 1 ;;
-		--) shift ; break ;;
-		*) echo "Error while parsing arguments! $2" ; exit 1 ;;
-	esac
+check_for_tool()
+{
+	which $1 &> /dev/null
+	if [ "$?" -ne "0" ];
+	then
+		cecho "ERROR: Could not find the program '$1'. Please make sure
+that it is available in your PATH since it is required to complete your request." $red
+		exit 1
+	fi
+}
+
+cecho ()	# Color-echo. Argument $1 = message, Argument $2 = color
+{
+	local default_msg="No message passed."   # Doesn't really need to be a local variable.
+	message=${1:-$default_msg}               # Defaults to default message.
+	color=${2:-$black}                       # Defaults to black, if not specified.
+	echo -e "$color$message"
+	tput sgr0                                # Reset to normal.
+	return
+} 
+
+
+print_help()
+{
+	cat << EOSTREAM
+pnd_make.sh - A script to package "something" into a PND.
+
+Usage:
+  $(basename ${0}) {--directory|-d} <folder> {--pndname|-p} <file> [{--compress-squashfs|-c}]
+                   [{--genpxml} <file>] [{--icon|-i} <file>] [{--pxml|-x} <file>]
+                   [{--schema|-s} <file>] [{--help|-h}]
+
+
+Switches:
+  --compress-squashfs / -c  Define whether or not the pnd should be compressed using
+                            squashfs. If this parameter is selected, a compressed pnd
+                            will be created.
+
+  --directory / -d          Sets the folder that is to be used for the resulting pnd
+                            to <folder>. This option is mandatory for the script to
+                            function correctly.
+
+  --genpxml                 Sets the script used for generating a PXML file (if none
+                            is available already) to <file>. Please make sure to either
+                            provide a full path or prefix a script in the current folder
+                            with './' so that the script can actually be executed. If
+                            this variable is not specified, $GENPXML_PATH
+                            will be used.
+
+  --help / -h               Displays this help text.
+
+  --icon / -i               Sets the icon that will be appended in the pnd to <file>.
+
+  --pndname / -p            Sets the output filename of the resulting pnd to <file>.
+                            This option is mandatory for the script to function
+                            correctly.
+
+  --pxml / -x               Sets the PXML file that is to be used to <file>. If you
+                            neither provide a PXML file or set this entry to 'guess',
+                            an existing 'PXML.xml' in your selected '--directory'
+                            will be used, or the script $GENPXML_PATH
+                            will be called to try to generate a basic PXML file for you.
+
+  --schema / -s             Sets the schema file, that is to be used for validation,
+                            to <file. If this is not defined, the script will try to
+                            use the file '$PXML_schema'. If this fails,
+                            a warning is issued.
+
+If you select the option to create a compressed squashfs, a version >=4.0 of squashfs
+is required to be available in your PATH.
+EOSTREAM
+}
+
+
+# Parse command line parameters
+while [ "${1}" != "" ]; do
+	if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ];
+	then
+		SQUASH=1
+		shift 1
+	elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ];
+	then
+		FOLDER=$2
+		shift 2
+	elif [ "${1}" = "--genpxml" ];
+	then
+		GENPXML_PATH=$2
+		shift 2
+	elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ];
+	then
+		print_help
+		exit 0
+	elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ];
+	then
+		ICON=$2
+		shift 2
+	elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ];
+	then
+		PNDNAME=$2
+		shift 2
+	elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ];
+	then
+		PXML=$2
+		shift 2
+	elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ]
+	then
+		PXML_schema=$2
+		shift 2
+	else
+		cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red
+		print_help
+		exit 1
+	fi
 done
 
-rnd=$RANDOM; # random number for genpxml and index$rnd.xml
 
-#generate pxml if guess or empty
-if [ ! $PXML ] || [ $PXML = "guess" ] && [  $PNDNAME ] && [ $FOLDER ];  then
-	PXMLtxt=$(/home/user/libpnd/pandora-libraries/testdata/scripts/genpxml.sh $FOLDER $ICON)
-	PXML=$FOLDER/PXML.xml
-	echo "$PXMLtxt" > $FOLDER/PXML.xml
+# Generate a PXML if the param is set to Guess or it is empty.
+if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ];
+then
+	if [ -f $FOLDER/PXML.xml ]; # use the already existing PXML.xml file if there is one...
+	then
+		PXML=$FOLDER/PXML.xml
+		PXML_ALREADY_EXISTING="true"
+	else
+		if [ -f $GENPXML_PATH ];
+		then
+			$GENPXML_PATH --src $FOLDER --dest $FOLDER --author $USER
+			if [ -f $FOLDER/PXML.xml ];
+			then
+				PXML_GENERATED="true"
+			else
+				cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed.
+Please generate a PXML file manually." $red
+				exit 1
+			fi
+		else
+			cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red
+			exit 1
+		fi
+	fi
 fi
 
-#check arguments
-if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then
-	echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x
-	your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png"
+
+# Probe if required variables were set
+echo -e
+cecho "Checking if all required variables were set." $green
+if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ];
+then
+	echo -e
+	cecho "ERROR: Not all required options were set! Please see the --help information below." $red
+	echo -e
+	print_help
 	exit 1
+else
+	echo "PNDNAME set to '$PNDNAME'."
+fi
+# Check if the selected folder actually exists
+if [ ! -d $FOLDER ];
+then
+	echo -e
+	cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red
+	exit 1
+else
+	echo "FOLDER set to '$FOLDER'."
+fi
+# Check if the selected PXML file actually exists
+if [ ! -f $PXML ];
+then
+	echo -e
+	cecho "ERROR: '$PXML' doesn't exist or is not a file." $red
+	exit 1
+else
+	if [ $PXML_ALREADY_EXISTING ];
+	then
+		echo "You have not explicitly specified a PXML to use, but an existing file was
+found. Will be using this one."
+	elif [ $PXML_GENERATED ];
+	then
+		echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will
+not be removed at the end of this script because you might want to review it, adjust
+single entries and rerun the script to generate a pnd with a PXML file with all the
+information you want to have listed."
+	fi
+	echo "PXML set to '$PXML'."
 fi
-if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists
-if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists
 
-#make iso from folder
-if [ ! $SQUASH ]; then
-	mkisofs -o $PNDNAME.iso -R $FOLDER
+# Print the other variables:
+if [ $ICON ];
+then
+	if [ ! -f $ICON ]
+	then
+		cecho "WARNING: '$ICON' doesn't exist, will not append the selected icon to the pnd." $red
+	else
+		echo "ICON set to '$ICON'."
+		USE_ICON="true"
+	fi
+fi
+if [ $SQUASH ];
+then
+	echo "Will use a squashfs for '$PNDNAME'."
+fi
+
+
+# Validate the PXML file (if xmllint is available)
+# Errors and problems in this section will be shown but are not fatal.
+echo -e
+cecho "Trying to validate '$PXML' now. Will be using '$PXML_schema' to do so." $green
+which xmllint &> /dev/null
+if [ "$?" -ne "0" ];
+then
+	VALIDATED=false
+	cecho "WARNING: Could not find 'xmllint'. Validity check of '$PXML' is not possible!" $red
 else
-	if [ $(mksquashfs -version |  awk '{if ($3 >= 4) print 1}') = 1 ]; then
-		echo "your squashfs version is older then version 4, please upgrade to 4.0 or later"
+	if [ ! -f "$PXML_schema" ];
+	then
+		VALIDATED=false
+		cecho "WARNING: Could not find '$PXML_schema'. If you want to validate your
+PXML file please make sure to provide a schema using the --schema option." $red
+	else
+		xmllint --noout --schema $PXML_schema $PXML
+		if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi
+	fi
+fi
+# Print some message at the end about the validation in case the user missed the output above
+if [ $VALIDATED = "false" ]
+then
+	cecho "WARNING: Could not successfully validate '$PXML'. Please check the output
+above. This does not mean that your pnd will be broken. Either you are not following the strict
+syntax required for validation or you don't have all files/programs required for validating." $red
+else
+	cecho "Your file '$PXML' was validated successfully. The resulting pnd should
+work nicely with libpnd." $green
+fi
+
+
+# Make iso from folder
+echo -e
+cecho "Creating an iso file based on '$FOLDER'." $green
+if [ $SQUASH ];
+then
+	check_for_tool mksquashfs
+	if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ];
+	then
+		cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red
 		exit 1
 	fi
-	mksquashfs -no-recovery -nopad $FOLDER $PNDNAME.iso
+	mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery
+else
+	check_for_tool mkisofs
+	mkisofs -o $PNDNAME.iso -R $FOLDER
+fi
+
+# Check that the iso file was actually created before continuing
+if [ ! -f $PNDNAME.iso ];
+then
+	cecho "ERROR: The temporary file '$PNDNAME.iso' could not be created.
+Please check the output above for any errors and retry after fixing them. Aborting." $red
+	exit 1
 fi
-#append pxml to iso
-cat $PNDNAME.iso $PXML >  $PNDNAME
+
+
+# Append pxml to iso
+echo -e
+cecho "Appending '$PXML' to the created iso file." $green
+cat $PNDNAME.iso $PXML > $PNDNAME
 rm $PNDNAME.iso #cleanup
 
-#append icon if specified
-if [ $ICON ]; then # check if we want to add an icon
-	if [ ! -f $ICON ]; then #does the icon actually exist?
-		echo "$ICON doesnt exist"
-	else # yes
+
+# Append icon if specified and available
+if [ $USE_ICON ];
+then
+	echo -e
+	cecho "Appending the icon '$ICON' to the pnd." $green
 	mv $PNDNAME $PNDNAME.tmp
 	cat $PNDNAME.tmp $ICON > $PNDNAME # append icon
 	rm $PNDNAME.tmp #cleanup
-	fi
 fi
 
-if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup
+
+# Final message
+echo -e
+if [ -f $PNDNAME ];
+then
+	cecho "Successfully finished creating the pnd '$PNDNAME'." $green
+else
+	cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check
+the output above for any error messages. A possible cause for this is that there was
+not enough space available." $red
+	exit 1
+fi
+
+
+#if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup






More information about the Scummvm-git-logs mailing list