5 SDK_DIR
="/usr/lib/xulrunner"
7 XPIDL
="${SDK_DIR}/xpidl"
8 XPIDL_INCLUDE
="${SDK_DIR}/idl"
14 ## This variable is for target `etags'. It specifies the destination
15 ## directory for the TAGS file.
39 echo 'bad usage. please read the source.'
45 #build the spawn-process-helper
49 ## if this is not an official release, tag on a build date.
51 ## if this is an official release, strip the subminor.
53 MILESTONE
="${VERSION##*.}"
54 BUILD_DATE
=$
(date +%Y
%m
%d
)
55 SHORT_VERSION
="$VERSION"
59 VERSION
="${VERSION%.*}" ;;
61 VERSION
="$VERSION.$BUILD_DATE"
63 echo "build target: $TARGET, $VERSION"
74 ## Temporary directory for build process.
78 function get_scratch
() {
79 if [[ -z "$SCRATCH" ]]; then
80 SCRATCH
=$
(mktemp
-d conkeror-XXXXXX
)
85 function do_cleanup
() {
86 if [[ -n "$SCRATCH" ]]; then
93 function assert_conkeror_src
() {
94 if [[ ! -e application.ini
]]; then
95 echo "The current directory does not appear to contain the Conkeror source code."
101 function copy_tree_sans_boring
() {
107 ( cd "$src"; find .
-type d
-and \
! -name '*[~#]' -print0 ) \
108 |
( cd "$dest"; xargs -0 mkdir
-p )
109 files
=($
( cd "$src"; find .
-type f
-and \
! -name '*[~#]' -print ))
110 for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
116 function do_check_milestone_for_release
()
118 if [[ "$MILESTONE" = "0" ]]; then
123 proposed
="${VERSION%.*}".$
(( ${VERSION#*.} + 1 )).0
125 echo "The version given in the file $dest does not have 0 as its last component."
126 echo -n "Shall I rewrite \`VERSION=$VERSION.$MILESTONE' to \`VERSION=$proposed'? [yN] "
128 if [[ "$REPLY" = [Yy
]* ]]; then
129 perl
-pi -e 's/^VERSION='$VERSION'\.'$MILESTONE'$/VERSION='$proposed'/' "$dest"
130 echo "Version changed in $dest. Please run this build program again."
133 echo "Leaving $dest untouched. Continuing with build."
138 function diff_wrapper
() {
143 scratchfile
="${scratch}/$dest"
144 patchfile
="${scratch}/$dest.patch"
146 echo -n "Processing $dest ..."
147 perl
-0777 -p -e "$perlexp" "$dest" > "$scratchfile"
150 if cmp "$dest" "$scratchfile" ; then
151 echo "$dest does not need to be updated"
153 diff -u "$dest" "$scratchfile" |
tee "$patchfile"
154 echo -n "Apply this patch to $dest? [yN] "
156 if [[ "$REPLY" = [Yy
]* ]]; then
159 echo "Leaving $dest untouched"
172 function do_target_jar
() {
173 echo -n Building JAR...
174 FILES
=($
(find content branding locale modules
-type f
-and \
! -name '*[~#]' -print ))
175 zip "conkeror.jar" "${FILES[@]}" > /dev
/null
180 function do_target_xulapp
() {
182 echo -n Building XULRunner Application...
184 mkdir
-p "$SCRATCH/chrome"
185 cp application.ini
"$SCRATCH"
186 if [ -n "$CONKEROR_APP_NAME" ]; then
187 sed -i -e "s/Name=conkeror/Name=${CONKEROR_APP_NAME}/" "${SCRATCH}/application.ini"
189 mv conkeror.jar
"$SCRATCH/chrome/"
190 cp chrome.manifest.for-jar
"$SCRATCH/chrome/chrome.manifest"
191 copy_tree_sans_boring defaults
"$SCRATCH/defaults"
192 copy_tree_sans_boring components
"$SCRATCH/components"
195 name
="$(basename "$x")"
196 "${XPIDL}" -w -v -m typelib -I "${XPIDL_INCLUDE}" -e "$SCRATCH/components/${name%.idl}.xpt" "$x"
199 pushd "$SCRATCH" > /dev
/null
200 ## begin preprocessing
202 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' application.ini
203 perl
-pi -e 's/\$CONKEROR_BUILD_DATE\$/'$BUILD_DATE'/g' application.ini
204 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' components
/application.js
207 zip -r conkeror.xulapp
* > /dev
/null
209 mv "$SCRATCH/conkeror.xulapp" .
215 function do_target_dist_tar
() {
218 ## now we have conkeror.xulapp
219 ## package it with install.sh
221 ## some other files should probably go in here.. NEWS, for example
222 mkdir
"$SCRATCH/conkeror-$VERSION"
223 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
224 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
225 pushd "$SCRATCH" > /dev
/null
226 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
228 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
229 echo -n "Making conkeror-$VERSION.tar.gz ..."
235 function do_target_release
() {
236 do_check_milestone_for_release
237 ## Make any and all release archives.
239 ## Right now, we just make a tar.gz archive that includes an install
240 ## script. In the future, we could consider making an OSX App, a Windows
241 ## Installer EXE, and a Mozilla XPI Installer.
244 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
245 mv conkeror-
$VERSION.
tar.gz ..
/downloads
250 function do_target_announce
() {
251 do_check_milestone_for_release
252 echo Entering ..
/www
/ ... ok
253 pushd ..
/www
/ > /dev
/null
254 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
256 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
257 diff_wrapper
"$scratch" index.html
"$perlexp"
259 perlexp
='s/(?<=<!-- begin controlled content. do not edit manually. id:newestlink -->).*?(?=<!-- end controlled content. -->)/<a href="http:\/\/downloads.mozdev.org\/conkeror\/conkeror-'$VERSION'.tar.gz">conkeror-'$VERSION'.tar.gz<\/a>/g'
260 diff_wrapper
"$scratch" installation.html
"$perlexp"
267 function do_target_etags
() {
268 if [[ -z "$ETAGSDIR" ]]; then
271 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
272 echo -n "Building $ETAGSDIR ..."
273 etags
-o "$ETAGSDIR" $
(find -name \
*.js
-and \
! -name '*[~#]*')
278 function do_target_notes
() {
279 FILES
=($
(find conkeror
-name \
*.js
))
280 for file in "${FILES[@]}"; do
281 fileo
="${file//\//\/}"
282 perl
-0777 -ne 's/## BLOCK COMMENTS
283 (.*\/\*\s*[A-Z][A-Z].*:.*$
286 (?{ $p = pos(); })) |
288 (.*\/\/\s*[A-Z][A-Z].*:.*$
291 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
296 function do_target_help
() {
297 echo "For this script to work, your current working directory must"
298 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
299 echo "This script expects to find the subdirectory structure,"
300 echo "\`conkeror/content', and VERSION in the current directory,"
301 echo "\`downloads' and \`www' in the parent directory, and possibly"
304 echo 'Usage: bash build.sh <TARGET>'
305 echo 'where <TARGET> is one of:'
311 echo ' release Builds a release xpi and puts it in ../downloads.'
313 echo ' announce Modify the website in ../www to announce a release.'
315 echo ' etags [DIR] Build TAGS file in etags format. If a'
316 echo ' directory is given, TAGS will be made in'
317 echo ' that directory.'
319 echo ' notes Shows specially formatted comments in'
320 echo " \`conkeror/content/*.js' Modifies no files."
322 echo ' help Shows this help message. Modifies no files.'
338 jar
) do_target_jar
;;
339 xulapp
) do_target_xulapp
;;
340 dist-tar
) do_target_dist_tar
;;
341 release
) do_target_release
;;
342 announce
) do_target_announce
;;
343 etags
) do_target_etags
;;
344 notes
) do_target_notes
;;
345 help) do_target_help
;;