summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b6ed605)
* use genpxml.sh and the schema from the dir in which pnd_make.sh is if
* no param is supplied
* check if a PXML file was actually created during the genpxml step
* add some checks for required programs (iso and squashfs stuff)
* add some more sanity checks including aborts if an error was detected
* add missing help info for the param --genpxml
* add comment at the top of the file mentioning what the file is about
* fix various typos
-
-######adjust path of genpxml.sh if you want to use that "feture"#####
-
-PXML_schema="PXML_schema.xsd"
-GENPXML_PATH="genpxml.sh"
+#
+# 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)
+
+
+PXML_schema=$(dirname ${0})/PXML_schema.xsd
+GENPXML_PATH=$(dirname ${0})/genpxml.sh
# useful functions ...
black='\E[30m'
# useful functions ...
black='\E[30m'
cyan='\E[36m'
white='\E[37m'
cyan='\E[36m'
white='\E[37m'
+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
{
cecho () # Color-echo. Argument $1 = message, Argument $2 = color
{
- --compress-squashfs / -c Define wether or not the pnd should be compressed using
+ --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.
squashfs. If this parameter is selected, a compressed pnd
will be created.
to <folder>. This option is mandatory for the script to
function correctly.
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.
--help / -h Displays this help text.
--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'
--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 your.
+ 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
--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.xsd'. If this fails, a warning
- is issued.
+ 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.
If you select the option to create a compressed squashfs, a version >=4.0 of squashfs
is required to be available in your PATH.
else
cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red
print_help
else
cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red
print_help
PXML=$FOLDER/PXML.xml
PWML_ALREADY_EXISTING="true"
else
PXML=$FOLDER/PXML.xml
PWML_ALREADY_EXISTING="true"
else
- PXMLtxt=$($GENPXML_PATH $FOLDER $ICON)
- PXML=$FOLDER/PXML.xml
- echo "$PXMLtxt" > $FOLDER/PXML.xml
- PXML_GENERATED="true"
+ if [ -f $GENPXML_PATH ];
+ then
+ PXMLtxt=$($GENPXML_PATH $FOLDER $ICON)
+ if [ -z $PXMLtxt ];
+ then
+ cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed.
+Please generate a PXML file manually." $red
+ exit 1
+ else
+ PXML=$FOLDER/PXML.xml
+ echo "$PXMLtxt" > $FOLDER/PXML.xml
+ PXML_GENERATED="true"
+ fi
+ else
+ cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red
+ exit 1
+ fi
if [ ! -d $FOLDER ];
then
echo -e
if [ ! -d $FOLDER ];
then
echo -e
- cecho "ERROR: '$FOLDER' doesnt exist or is not a folder." $red
+ cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red
exit 1
else
echo "FOLDER set to '$FOLDER'."
exit 1
else
echo "FOLDER set to '$FOLDER'."
if [ ! -f $PXML ];
then
echo -e
if [ ! -f $PXML ];
then
echo -e
- cecho "ERROR: '$PXML' doesnt exist or is not a file." $red
+ cecho "ERROR: '$PXML' doesn't exist or is not a file." $red
exit 1
else
if [ $PWML_ALREADY_EXISTING ];
then
echo "You have not explicitly specified a PXML to use, but an existing file was
exit 1
else
if [ $PWML_ALREADY_EXISTING ];
then
echo "You have not explicitly specified a PXML to use, but an existing file was
-fount. Will be using this one."
+found. Will be using this one."
elif [ $PXML_GENERATED ];
then
echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will
elif [ $PXML_GENERATED ];
then
echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will
then
if [ ! -f $ICON ]
then
then
if [ ! -f $ICON ]
then
- cecho "'$ICON' doesn't exist, will not append the selected icon to the pnd." $red
+ 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"
else
echo "ICON set to '$ICON'."
USE_ICON="true"
if [ ! -f "$PXML_schema" ];
then
VALIDATED=false
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
+ 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
else
xmllint --noout --schema $PXML_schema $PXML
if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi
cecho "Creating an iso file based on '$FOLDER'." $green
if [ $SQUASH ];
then
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
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, pleas upgrade to 4.0 or later" $red
+ cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red
exit 1
fi
mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery
else
exit 1
fi
mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery
else
mkisofs -o $PNDNAME.iso -R $FOLDER
fi
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
echo -e
cecho "Appending '$PXML' to the created iso file." $green
cat $PNDNAME.iso $PXML > $PNDNAME
rm $PNDNAME.iso #cleanup
# 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 and available
if [ $USE_ICON ];
then
# Append icon if specified and available
if [ $USE_ICON ];
then
echo -e
if [ -f $PNDNAME ];
then
echo -e
if [ -f $PNDNAME ];
then
- cecho "Finished creating the pnd '$PNDNAME'." $green
+ cecho "Successfully finished creating the pnd '$PNDNAME'." $green
else
cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check
else
cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check
-the output above for any error messages." $red
+the output above for any error messages. A possible cause for this is that there was
+not enough space available." $red
+ exit 1