Changeset 705

Show
Ignore:
Timestamp:
03/29/08 19:58:48 (8 months ago)
Author:
aranti..@gmail.com
Message:

* Make version numbers parameterized (with defaults)
* Collapse unnecessariliy verbose syntax
* Remove only-used-once many line "replace" function with one call to sed
* Clarify find/zip sequence by separating it out
* Create a .JAR to go inside the .XPI, patch chrome.manifest to use it
* Self document, via echo statements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/buildscript/build.sh

    r633 r705  
    11#!/bin/sh 
    2 GMMAX=0 
    3 GMMIN=8 
     2 
     3# Set up variables 
     4GMMAX=${1-0} 
     5GMMIN=${2-8} 
     6GMREL=${3-0} 
    47GMBUILD=`date +"%Y%m%d"` 
    5 GMREL=0 
    6  
    78GMNAME=greasemonkey 
    8  
    99GMVER="$GMMAX.$GMMIN.$GMBUILD.$GMREL" 
    1010GMXPI="$GMNAME-$GMVER.xpi" 
    1111 
    1212# Copy base structure to a temporary build directory and change to it 
     13echo "Creating working directory ..." 
    1314rm -rf build 
    1415mkdir build 
    15 cp chrome.manifest build/ 
    16 cp install.js build/ 
    17 cp install.rdf build/ 
    18 cp license.txt build/ 
    19 cp -r defaults build/ 
    20 cp -r components build/ 
    21 cp -r chrome build/ 
     16cp -r chrome.manifest install.js install.rdf license.txt \ 
     17        defaults components chrome \ 
     18        build/ 
    2219cd build 
    2320 
    24 # Generate locales for chrome.manifest from babelzilla directories, which 
    25 # we assume have been placed in locale/. 
     21echo "Gathering all locales into chrome.manifest ..." 
    2622GMLOC=\"en-US\" 
    27 for entry in $(ls chrome/chromeFiles/locale/); do 
     23for entry in chrome/chromeFiles/locale/*; do 
    2824  if [ $entry != en-US ]; then 
    29     echo "locale  $GMNAME  "$entry"  chrome/chromeFiles/locale/"$entry"/" >> chrome.manifest 
     25    echo "locale  $GMNAME  $entry  chrome/chromeFiles/locale/$entry/" >> chrome.manifest 
    3026    GMLOC=$GMLOC,\ \"$entry\" 
    3127  fi 
    3228done 
    3329 
    34 replace () { 
    35   TMP=`mktemp -t Greasemonkey-build.sh` 
    36   SRC=`echo "$1" | sed 's/[\/\\\\]/\\\\&/g'` 
    37   DST=`echo "$2" | sed 's/[\/\\\\]/\\\\&/g'` 
    38   sed "s/$SRC/$DST/g" "$3" > "$TMP" 
    39   if cmp -s "$3" "$TMP" ; then 
    40     # No change! Treat as a failure to react to in caller. 
    41     rm "$TMP" 
    42     return 1 
    43   fi 
    44   cp "$TMP" "$3" 
    45   rm "$TMP" 
    46   return 0 
    47 
     30echo "Patching install.rdf version ..." 
     31sed "s!<em:version>.*</em:version>!<em:version>$GMVER</em:version>!" \ 
     32  install.rdf > install.rdf.tmp 
     33mv install.rdf.tmp install.rdf 
    4834 
    49 replace '<em:version>.*</em:version>' \ 
    50         '<em:version>'$GMVER'</em:version>' \ 
    51         install.rdf 
     35echo "Cleaning up unwanted files ..." 
     36find . -depth -name '.svn' -exec rm -rf "{}" \; 
     37find . -depth -name '*~' -exec rm -rf "{}" \; 
     38find . -depth -name '#*' -exec rm -rf "{}" \; 
    5239 
    53 find . -name '.svn' -prune -or -name '.DS_Store' -or -name '*~' -or -name '#*' \ 
    54   -or -print | zip -9X -@ "$GMXPI" 
     40echo "Creating $GMNAME.jar ..." 
     41cd chrome 
     42zip -qr0X "$GMNAME.jar" chromeFiles icons 
     43rm -rf chromeFiles icons 
     44cd .. 
    5545 
    56 mv "$GMXPI" ../ 
     46echo "Patching chrome.manifest with jar ..." 
     47sed -e \ 
     48        "/^content\|^skin\|^locale/s#\(.*\) chrome/\(.*\)#\1 jar:chrome/$GMNAME.jar!/\2#" \ 
     49        chrome.manifest > chrome.manifest.jar 
     50mv chrome.manifest.jar chrome.manifest 
    5751 
    58 echo "Created $GMXPI" 
    59 exit 0 
     52echo "Creating $GMXPI ..." 
     53zip -qr9X "../$GMXPI" * 
     54 
     55echo "Cleaning up temporary files ..." 
     56cd .. 
     57rm -rf build