Chameleon

Chameleon Commit Details

Date:2012-02-27 23:06:10 (8 years 3 months ago)
Author:blackosx
Commit:1834
Parents: 1833
Message:Fix (patch) building process. Resources now download and build successfully so package can be made. Checks are now needed to see if this works on different localizations and different systems. I have a feeling more work weill be needed to handle the unicodes etc.
Changes:
M/branches/blackosx/package/buildpkg.sh
M/branches/blackosx/package/Resources.source/ConvertResourcesTextFile.pl

File differences

branches/blackosx/package/Resources.source/ConvertResourcesTextFile.pl
77
88
99
10
11
10
11
12
13
1214
13
14
15
16
1517
18
1619
1720
1821
19
20
22
23
2124
22
25
26
2327
2428
2529
......
5963
6064
6165
62
66
6367
6468
65
66
69
70
6771
6872
6973
......
7175
7276
7377
78
79
7480
75
76
81
82
7783
78
84
7985
8086
8187
......
97103
98104
99105
100
106
101107
102108
103109
......
105111
106112
107113
114
108115
#
# The human readable file is hosted on Google Docs at:
# www.......
# The file should be saved from Google Docs by using:
# File -> Download As -> Text (current sheet)
# The spreadsheet is a published file and will be
# automatically downloaded as a UTF-8, tabbed delimited
# text file which will be savedd in the same folder as
# this script.
#
# This saves a UTF-8, tabbed delimited text file which
# should be placed in the same folder as this script.
# Call this script with:
# ./ConvertResourcesTextFile.pl ResourcesSourceFile.txt
#
#
use LWP::Simple;
if ($#ARGV < 0) {
print stderr "A destination file is needed\n";
if ($#ARGV < 1) {
print stderr "A destination path and filename is needed\n";
} else {
$destination_file=$ARGV[0];
$destination_dir=$ARGV[0];
$destination_file=$ARGV[1];
}
sub set_indent {
#--------------------------------------------------------------------------
$googlePublishedDoc = 'https://docs.google.com/spreadsheet/pub?key=0Aj0jJ2rdmK_sdFdNbm45NlpNYU1PcjRmOHVXX0FNa3c&single=true&gid=0&output=txt';
$sourceFileToRead="PackageInstallerResourceText.tsv";
getstore ($googlePublishedDoc, $sourceFileToRead) or die "Couldn't get master file";
getstore ($googlePublishedDoc, $destination_dir."/".$sourceFileToRead) or die "Couldn't get master file";
#--------------------------------------------------------------------------
open (FILE, "$sourceFileToRead");
open (OUTFILE, ">$destination_file");
open (FILE, "$destination_dir"."/"."$sourceFileToRead");
open (OUTFILE, ">$destination_dir"."/"."$destination_file");
print OUTFILE "\n"; # Output blank line.
# This is needed so after converting to rtf using textutil in later bash script
while (<FILE>) {
$indent = " ";
chomp;
s/&amp;/and/g; # Handle '&amp;' for now by converting to 'and'.
s/&/and/g; # Handle '&' for now by converting to 'and'.
@fieldsReadIn = split("\t");
$startFirstField=substr($fieldsReadIn[0],0,1); # First charatcer of first field
$startSecondField=substr($fieldsReadIn[1],0,1); # First charatcer of second field
$startFirstField=substr($fieldsReadIn[0],0,1); # First character of first field.
$startSecondField=substr($fieldsReadIn[1],0,1); # First character of second field.
if ($startFirstField ne "#" ) { # Ignore lines beginning with a hash
if ($startFirstField ne "#" ) { # Ignore lines beginning with a hash.
if ($startFirstField ne "") { # Check first field for language identifier.
print OUTFILE "language: $fieldsReadIn[0]\n"; # Output first field - LANGUAGE.
}
$headedFieldCount++;
$indent=calculateIndent;
print OUTFILE $indent."$fieldsWithoutLanguage[$loop]: $fieldsReadIn[$loop]\n";
$fieldsWithHeadersSet[$headedFieldCount]=1; # Set value in this array to mark that we've written to it.
$fieldsWithHeadersSet[$headedFieldCount]=1; # Set value in this array to mark that we've written to it.
}
}
}
}
close (FILE);
close (OUTFILE);
unlink("$destination_dir"."/"."$sourceFileToRead"); # Remove downloaded Google Doc file.
exit;
branches/blackosx/package/buildpkg.sh
975975
976976
977977
978
979
978
980979
981
982
983
984
980
981
982
983
985984
986985
987986
......
989988
990989
991990
992
993
994
991
992
993
994
995995
996
997
998
999
1000
1001
996
997
998
999
1000
1001
10021002
1003
1004
1005
1006
1007
1003
1004
1005
1006
1007
10081008
1009
1010
1009
1010
10111011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
10251025
1026
1027
1028
1026
1027
1028
10291029
1030
1031
1032
1033
1034
1035
1030
1031
1032
1033
1034
1035
10361036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
10491055
1050
1051
1052
1053
1054
1055
10561056
1057
1058
1059
1060
1061
1062
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
10631070
1064
1065
1066
1067
1068
1069
10701071
1071
1072
1072
1073
1074
1075
1076
1077
10731078
10741079
10751080
buildresources() {
ResourcesSourceFolder="${PKGROOT}/Resources.source"
ResourcesSourceFile="ResourcesSourceFile.txt"
ResourcesLanguageFile="${ResourcesSourceFolder}/${ResourcesSourceFile}"
# Check for ResourcesSourceFile.txt.
# If it doesn't exist then run perl script to make another one from
# the UTF-8 .tsv file saved from the master Google docs spreadsheet.
if [ -f "${ResourcesLanguageFile}" ]; then
"${ResourcesSourceFolder}/ConvertResourcesTextFile.pl" "${ResourcesLanguageFile}"
# It now won't exist, so call perl script to download the published
# Google docs spreadsheet as UTF-8 .tsv file and make another one.
if [ ! -f "${PKG_BUILD_DIR}/${ResourcesSourceFile}" ]; then
"${ResourcesSourceFolder}/ConvertResourcesTextFile.pl" "${PKG_BUILD_DIR}" "${ResourcesSourceFile}"
fi
#Initialise Variables
resetVars
# begin
while read -r line
do
case "${line%%:*}" in
if [ -f "${PKG_BUILD_DIR}/${ResourcesSourceFile}" ]; then
while read -r line
do
case "${line%%:*}" in
"language" )
foundLanguage="${line#*: }"
if [ ! -d "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage" ]; then
echo -e "\tCreating Language Resource Folder: $foundLanguage"
mkdir -p "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage"
fi
"language" )
foundLanguage="${line#*: }"
if [ ! -d "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage" ]; then
echo -e "\tCreating Language Resource Folder: $foundLanguage"
mkdir -p "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage"
fi
## Add License.rtf file to Language folder
if [ ! -f "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/License.rtf" ]; then
echo -e "\t\tAdding License.rtf file"
ditto --noextattr --noqtn "${ResourcesSourceFolder}/License.rtf" "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage"
fi
## Add License.rtf file to Language folder
if [ ! -f "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/License.rtf" ]; then
echo -e "\t\tAdding License.rtf file"
ditto --noextattr --noqtn "${ResourcesSourceFolder}/License.rtf" "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage"
fi
resetVars
;;
resetVars
;;
"file" )
# Have we already built an array of codes for the Welcome, Conclusion or Description Resource files?
if [ ${#buildCodes[@]} -ne 0 ]; then
for (( n=0; n<${#buildCodes[@]}; n++ ))
do
templateStrings[${#templateStrings[*]}]="--subst=${buildCodes[$n]}"
done
# Send the pre-built arrays to addTemplateResources() for completing template.
addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage" \
"${templateStrings[@]}" \
--type="" \
"$resourceToUse"
fi
"file" )
# Have we already built an array of codes for the Welcome, Conclusion or Description Resource files?
if [ ${#buildCodes[@]} -ne 0 ]; then
for (( n=0; n<${#buildCodes[@]}; n++ ))
do
templateStrings[${#templateStrings[*]}]="--subst=${buildCodes[$n]}"
done
# Send the pre-built arrays to addTemplateResources() for completing template.
addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage" \
"${templateStrings[@]}" \
--type="" \
"$resourceToUse"
fi
resourceToUse="${line#*: }"
echo -e "\t\tComposing $resourceToUse File"
;;
resourceToUse="${line#*: }"
echo -e "\t\tComposing $resourceToUse File"
;;
"codeID" ) foundCode="${line#*: }" ;;
"messageName" ) foundMessageName="${line#*: }" ;;
"objectName" ) foundObjectName="${line#*: }"; foundObjectName="${foundObjectName%%_title*}" ;;
"objectTitle" ) foundObjectTitle="${line#*: }" ;;
"description" ) foundDescription="${line#*: }" ;;
esac
"codeID" ) foundCode="${line#*: }" ;;
"messageName" ) foundMessageName="${line#*: }" ;;
"objectName" ) foundObjectName="${line#*: }"; foundObjectName="${foundObjectName%%_title*}" ;;
"objectTitle" ) foundObjectTitle="${line#*: }" ;;
"description" ) foundDescription="${line#*: }" ;;
esac
if [[ "$foundLanguage" != "" ]]; then
# Build an array for each the Welcome, Conclusion and Description Resource files per language.
if [[ "$foundCode" != "" ]] && [[ "$foundDescription" != "" ]]; then
if [[ "$resourceToUse" == "Welcome" ]] || [[ "$resourceToUse" == "Conclusion" ]]; then
# Convert description from UFT8 to raw unicode markup
convertedFoundDescription=$( echo $foundDescription | textutil -convert rtf -encoding UTF-8 -stdin -stdout )
# Strip away unicode text up to and including '\f0\fs24 \cf0' - take what's after.
strippedConvertedFoundDescription="${convertedFoundDescription#*\\f0\\fs24 \\cf0 }"
# Remove last character from string and replace all backslashes with a double backslash.
fixStrippedConvertedFoundDescription=$( echo "${strippedConvertedFoundDescription%?}" | sed -e 's/\\/\\\\/g' )
#echo "$fixStrippedConvertedFoundDescription"
buildCodes[${#buildCodes[*]}]="$foundCode=$fixStrippedConvertedFoundDescription"
if [[ "$foundLanguage" != "" ]]; then
# Build an array for each the Welcome, Conclusion and Description Resource files per language.
if [[ "$foundCode" != "" ]] && [[ "$foundDescription" != "" ]]; then
if [[ "$resourceToUse" == "Welcome" ]] || [[ "$resourceToUse" == "Conclusion" ]]; then
# Convert description from UFT8 to raw unicode markup
convertedFoundDescription=$( echo $foundDescription | textutil -convert rtf -encoding UTF-8 -stdin -stdout )
# Strip away unicode text up to and including '\f0\fs24 \cf0' - take what's after.
strippedConvertedFoundDescription="${convertedFoundDescription#*\\f0\\fs24 \\cf0 }"
# Remove last character from string and replace all backslashes with a double backslash.
fixStrippedConvertedFoundDescription=$( echo "${strippedConvertedFoundDescription%?}" | sed -e 's/\\/\\\\/g' )
#echo "$fixStrippedConvertedFoundDescription"
buildCodes[${#buildCodes[*]}]="$foundCode=$fixStrippedConvertedFoundDescription"
fi
if [[ "$resourceToUse" == "Description" ]]; then
# No need to convert the text for the Description file as it's not RTF.
buildCodes[${#buildCodes[*]}]="$foundCode=$foundDescription"
fi
foundCode=""; foundDescription=""
fi
if [[ "$resourceToUse" == "Description" ]]; then
# No need to convert the text for the Description file as it's not RTF.
buildCodes[${#buildCodes[*]}]="$foundCode=$foundDescription"
fi
foundCode=""; foundDescription=""
fi
# No need for an array for Localizable.strings. These can be written straight to file.
if [[ "$resourceToUse" == "LocalizableStrings" ]]; then
if [[ "$foundMessageName" != "" ]] && [[ "$foundDescription" != "" ]]; then
echo "\"${foundMessageName}\" = \"${foundDescription}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
foundMessageName=""; foundDescription=""
# No need for an array for Localizable.strings. These can be written straight to file.
if [[ "$resourceToUse" == "LocalizableStrings" ]]; then
if [[ "$foundMessageName" != "" ]] && [[ "$foundDescription" != "" ]]; then
echo "\"${foundMessageName}\" = \"${foundDescription}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
foundMessageName=""; foundDescription=""
fi
if [[ "$foundObjectName" != "" ]] && [[ "$foundObjectTitle" != "" ]] && [[ "$foundDescription" != "" ]]; then
echo "\"${foundObjectName}_title\" = \"${foundObjectTitle}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "\"${foundObjectName}_description\" = \"${foundDescription}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
foundObjectName=""; foundObjectTitle=""; foundDescription=""
fi
fi
if [[ "$foundObjectName" != "" ]] && [[ "$foundObjectTitle" != "" ]] && [[ "$foundDescription" != "" ]]; then
echo "\"${foundObjectName}_title\" = \"${foundObjectTitle}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "\"${foundObjectName}_description\" = \"${foundDescription}\";" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
echo "" >> "${PKG_BUILD_DIR}/${packagename}/Resources/$foundLanguage/Localizable.strings"
foundObjectName=""; foundObjectTitle=""; foundDescription=""
fi
fi
fi
done < $ResourcesLanguageFile
done < "${PKG_BUILD_DIR}/${ResourcesSourceFile}"
rm "${PKG_BUILD_DIR}/${ResourcesSourceFile}"
else
echo -e "\tError. ${ResourcesLanguageFile} not created."
exit 1
fi
echo -e "\tAdding background.tiff file"
ditto --noextattr --noqtn "${ResourcesSourceFolder}/background.tiff" "${PKG_BUILD_DIR}/${packagename}/Resources"

Archive Download the corresponding diff file

Revision: 1834