3 # (C) Copyright 2004-2007 Shawn Betts
4 # (C) Copyright 2007-2008 John J. Foerch
5 # (C) Copyright 2007-2008 Jeremy Maitin-Shepard
7 # Use, modification, and distribution are subject to the terms specified in the
10 SDK_DIR
="/usr/lib/xulrunner"
12 XPIDL
="${SDK_DIR}/xpidl"
13 XPIDL_INCLUDE
="${SDK_DIR}/idl"
19 ## This variable is for target `etags'. It specifies the destination
20 ## directory for the TAGS file.
42 echo 'bad usage. please read the source.'
48 VERSION
=$
(grep '^Version=' application.ini | cut
-d '=' -f 2)
51 ## if this is not an official release, tag on a build date.
53 ## if this is an official release, strip the subminor.
55 MILESTONE
="${VERSION##*.}"
56 BUILD_DATE
=$
(date +%Y
%m
%d
)
57 SHORT_VERSION
="$VERSION"
61 VERSION
="${VERSION%.*}" ;;
63 VERSION
="$VERSION.$BUILD_DATE"
65 echo "build target: $TARGET, $VERSION"
76 ## Temporary directory for build process.
80 function get_scratch
() {
81 if [[ -z "$SCRATCH" ]]; then
82 SCRATCH
=$
(mktemp
-d conkeror-XXXXXX
)
87 function do_cleanup
() {
88 if [[ -n "$SCRATCH" ]]; then
95 function assert_conkeror_src
() {
96 if [[ ! -e application.ini
]]; then
97 echo "The current directory does not appear to contain the Conkeror source code."
103 function copy_tree_sans_boring
() {
109 ( cd "$src"; find .
-type d
-and \
! -name '*[~#]' -print0 ) \
110 |
( cd "$dest"; xargs -0 mkdir
-p )
111 files
=($
( cd "$src"; find .
-type f
-and \
! -name '*[~#]' -print ))
112 for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
118 function do_check_milestone_for_release
()
120 if [[ "$MILESTONE" = "0" ]]; then
125 proposed
="${VERSION%.*}".$
(( ${VERSION#*.} + 1 )).0
127 echo "The version given in the file $dest does not have 0 as its last component."
128 echo -n "Shall I rewrite \`VERSION=$VERSION.$MILESTONE' to \`VERSION=$proposed'? [yN] "
130 if [[ "$REPLY" = [Yy
]* ]]; then
131 perl
-pi -e 's/^VERSION='$VERSION'\.'$MILESTONE'$/VERSION='$proposed'/' "$dest"
132 echo "Version changed in $dest. Please run this build program again."
135 echo "Leaving $dest untouched. Continuing with build."
140 function diff_wrapper
() {
145 scratchfile
="${scratch}/$dest"
146 patchfile
="${scratch}/$dest.patch"
148 echo -n "Processing $dest ..."
149 perl
-0777 -p -e "$perlexp" "$dest" > "$scratchfile"
152 if cmp "$dest" "$scratchfile" ; then
153 echo "$dest does not need to be updated"
155 diff -u "$dest" "$scratchfile" |
tee "$patchfile"
156 echo -n "Apply this patch to $dest? [yN] "
158 if [[ "$REPLY" = [Yy
]* ]]; then
161 echo "Leaving $dest untouched"
174 function do_target_xulapp
() {
175 echo -n Building XULRunner Application...
177 #build the conkeror-spawn-helper
181 mkdir
-p "$SCRATCH/chrome"
182 cp application.ini
"$SCRATCH"
183 if [ -n "$CONKEROR_APP_NAME" ]; then
184 sed -i -e "s/Name=conkeror/Name=${CONKEROR_APP_NAME}/" "${SCRATCH}/application.ini"
186 for x
in branding chrome components content defaults locale modules search-engines
help style
; do
187 copy_tree_sans_boring
"$x" "$SCRATCH/$x"
189 cp conkeror-spawn-helper
"${SCRATCH}"
192 name
="$(basename "$x")"
193 "${XPIDL}" -w -v -m typelib -I "${XPIDL_INCLUDE}" -e "$SCRATCH/components/${name%.idl}.xpt" "$x"
196 BUILD_ID
=$
(git rev-parse HEAD
2> /dev
/null
)
197 if [ "$?" != 0 ]; then
200 pushd "$SCRATCH" > /dev
/null
201 ## begin preprocessing
203 perl
-pi -e 's/BuildID=git/BuildID='${BUILD_ID}'/g' application.ini
206 zip -r ..
/conkeror.xulapp
* > /dev
/null
213 function do_target_dist_tar
() {
216 ## now we have conkeror.xulapp
217 ## package it with install.sh
219 ## some other files should probably go in here.. NEWS, for example
220 mkdir
"$SCRATCH/conkeror-$VERSION"
221 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
222 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
223 pushd "$SCRATCH" > /dev
/null
224 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
226 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
227 echo -n "Making conkeror-$VERSION.tar.gz ..."
233 function do_target_release
() {
234 do_check_milestone_for_release
235 ## Make any and all release archives.
237 ## Right now, we just make a tar.gz archive that includes an install
238 ## script. In the future, we could consider making an OSX App, a Windows
239 ## Installer EXE, and a Mozilla XPI Installer.
242 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
243 mv conkeror-
$VERSION.
tar.gz ..
/downloads
248 function do_target_announce
() {
249 do_check_milestone_for_release
250 echo Entering ..
/www
/ ... ok
251 pushd ..
/www
/ > /dev
/null
252 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
254 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
255 diff_wrapper
"$scratch" index.html
"$perlexp"
257 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'
258 diff_wrapper
"$scratch" installation.html
"$perlexp"
265 function do_target_etags
() {
266 if [[ -z "$ETAGSDIR" ]]; then
269 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
270 echo -n "Building $ETAGSDIR ..."
271 etags
-o "$ETAGSDIR" $
(find -name \
*.js
-and \
! -name '*[~#]*')
276 function do_target_notes
() {
277 FILES
=($
(find conkeror
-name \
*.js
))
278 for file in "${FILES[@]}"; do
279 fileo
="${file//\//\/}"
280 perl
-0777 -ne 's/## BLOCK COMMENTS
281 (.*\/\*\s*[A-Z][A-Z].*:.*$
284 (?{ $p = pos(); })) |
286 (.*\/\/\s*[A-Z][A-Z].*:.*$
289 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
294 function do_target_help
() {
295 echo "For this script to work, your current working directory must"
296 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
297 echo "This script expects to find the subdirectory structure,"
298 echo "\`conkeror/content', and VERSION in the current directory,"
299 echo "\`downloads' and \`www' in the parent directory, and possibly"
302 echo 'Usage: bash build.sh <TARGET>'
303 echo 'where <TARGET> is one of:'
309 echo ' release Builds a release xpi and puts it in ../downloads.'
311 echo ' announce Modify the website in ../www to announce a release.'
313 echo ' etags [DIR] Build TAGS file in etags format. If a'
314 echo ' directory is given, TAGS will be made in'
315 echo ' that directory.'
317 echo ' notes Shows specially formatted comments in'
318 echo " \`conkeror/content/*.js' Modifies no files."
320 echo ' help Shows this help message. Modifies no files.'
336 xulapp
) do_target_xulapp
;;
337 dist-tar
) do_target_dist_tar
;;
338 release
) do_target_release
;;
339 announce
) do_target_announce
;;
340 etags
) do_target_etags
;;
341 notes
) do_target_notes
;;
342 help) do_target_help
;;