Bash build script: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
mNo edit summary
(wasn't working on MacOSX, see http://forums.mozillazine.org/viewtopic.php?t=172953)
Line 35: Line 35:


if [ $HAS_DEFAULTS = 1 ]; then
if [ $HAS_DEFAULTS = 1 ]; then
   DEFAULT_FILES="`find ./defaults -path './*CVS*' -prune -o -type f -print | grep -v \~`"
   DEFAULT_FILES="`find defaults -path '*CVS*' -prune -o -type f -print | grep -v \~`"
   cp --parents $DEFAULT_FILES $TMP_DIR
   cp --parents $DEFAULT_FILES $TMP_DIR
fi
fi
Line 43: Line 43:


# generate the JAR file, excluding CVS and temporary files
# generate the JAR file, excluding CVS and temporary files
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find ./content -path './*CVS*' -prune -o -type f -print | grep -v \~`
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find content -path '*CVS*' -prune -o -type f -print | grep -v \~`
if [ $HAS_LOCALE = 1 ]; then
if [ $HAS_LOCALE = 1 ]; then
   zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find ./locale -path './*CVS*' -prune -o -type f -print | grep -v \~`
   zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find locale -path '*CVS*' -prune -o -type f -print | grep -v \~`
fi
fi
if [ $HAS_SKIN = 1 ]; then
if [ $HAS_SKIN = 1 ]; then
   zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find ./skin -path './*CVS*' -prune -o -type f -print | grep -v \~`
   zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find skin -path '*CVS*' -prune -o -type f -print | grep -v \~`
fi
fi



Revision as of 23:31, 28 November 2004

Here is a bash script I'm using to package my extensions (under Linux and Cygwin). For Windows script see Dev : Extensions : Windows cmd build script.

#!/bin/bash
# build.sh: build JAR and XPI files from source
# based on Nathan Yergler's build script

#### editable items (none of these can be blank)
APP_NAME=menuedit    # short-name, jar and xpi files name.
HAS_DEFAULTS=1       # whether the ext. provides default values for user prefs etc.
HAS_COMPONENTS=0     # whether the ext. includes any components
HAS_LOCALE=1         # package APP_NAME.jar/locale/ ?
HAS_SKIN=0           # package APP_NAME.jar/skin/ ?
KEEP_JAR=1           # leave the jar when done?
ROOT_FILES="license.txt install.rdf" # put these files in root of xpi
#### editable items end

TMP_DIR=build.tmp

#uncomment to debug
#set -x

# remove any left-over files
rm $APP_NAME.jar
rm $APP_NAME.xpi
rm -rf $TMP_DIR

# create xpi directory layout and populate it
mkdir $TMP_DIR
mkdir $TMP_DIR/chrome

if [ $HAS_COMPONENTS = 1 ]; then
  mkdir $TMP_DIR/components
  cp components/* $TMP_DIR/components
fi

if [ $HAS_DEFAULTS = 1 ]; then
  DEFAULT_FILES="`find defaults -path '*CVS*' -prune -o -type f -print | grep -v \~`"
  cp --parents $DEFAULT_FILES $TMP_DIR
fi

# Copy other files to the root of future XPI.
cp $ROOT_FILES $TMP_DIR

# generate the JAR file, excluding CVS and temporary files
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find content -path '*CVS*' -prune -o -type f -print | grep -v \~`
if [ $HAS_LOCALE = 1 ]; then
  zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find locale -path '*CVS*' -prune -o -type f -print | grep -v \~`
fi
if [ $HAS_SKIN = 1 ]; then
  zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find skin -path '*CVS*' -prune -o -type f -print | grep -v \~`
fi

# generate the XPI file
cd $TMP_DIR
zip -r ../$APP_NAME.xpi *
cd ..

if [ $KEEP_JAR = 1 ]; then
  # save the jar file
  mv $TMP_DIR/chrome/$APP_NAME.jar .
fi

# remove the working files
rm -rf $TMP_DIR