9 ## This variable is for target `etags'. It specifies the destination
10 ## directory for the TAGS file.
34 echo 'bad usage. please read the source.'
40 ## if this is not an official release, tag on a build date.
42 ## if this is an official release, strip the subminor.
44 MILESTONE
="${VERSION##*.}"
45 BUILD_DATE
=$
(date +%Y
%m
%d
)
46 SHORT_VERSION
="$VERSION"
50 VERSION
="${VERSION%.*}" ;;
52 VERSION
="$VERSION.$BUILD_DATE"
54 echo "build target: $TARGET, $VERSION"
65 ## Temporary directory for build process.
69 function get_scratch
() {
70 if [[ -z "$SCRATCH" ]]; then
71 SCRATCH
=$
(mktemp
-d conkeror-XXXXXX
)
76 function do_cleanup
() {
77 if [[ -n "$SCRATCH" ]]; then
84 function assert_conkeror_src
() {
85 if [[ ! -e application.ini
]]; then
86 echo "The current directory does not appear to contain the Conkeror source code."
92 function copy_tree_sans_boring
() {
98 ( cd "$src"; find .
-name CVS
-prune -or \
( -type d
-and \
99 \
! -name '*[~#]' -print0 \
) ) \
100 |
( cd "$dest"; xargs -0 mkdir
-p )
101 files
=($
( cd "$src"; find .
-name CVS
-prune -or \
( -type f
-and \
102 \
! -name '*[~#]' -print \
) ))
103 for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
109 function do_check_milestone_for_release
()
111 if [[ "$MILESTONE" = "0" ]]; then
116 proposed
="${VERSION%.*}".$
(( ${VERSION#*.} + 1 )).0
118 echo "The version given in the file $dest does not have 0 as its last component."
119 echo -n "Shall I rewrite \`VERSION=$VERSION.$MILESTONE' to \`VERSION=$proposed'? [yN] "
121 if [[ "$REPLY" = [Yy
]* ]]; then
122 perl
-pi -e 's/^VERSION='$VERSION'\.'$MILESTONE'$/VERSION='$proposed'/' "$dest"
123 echo "Version changed in $dest. Please run this build program again."
126 echo "Leaving $dest untouched. Continuing with build."
131 function diff_wrapper
() {
136 scratchfile
="${scratch}/$dest"
137 patchfile
="${scratch}/$dest.patch"
139 echo -n "Processing $dest ..."
140 perl
-0777 -p -e "$perlexp" "$dest" > "$scratchfile"
143 if cmp "$dest" "$scratchfile" ; then
144 echo "$dest does not need to be updated"
146 diff -u "$dest" "$scratchfile" |
tee "$patchfile"
147 echo -n "Apply this patch to $dest? [yN] "
149 if [[ "$REPLY" = [Yy
]* ]]; then
152 echo "Leaving $dest untouched"
165 function do_target_jar
() {
166 echo -n Building JAR...
168 jarbuild
="$SCRATCH/jar-build"
170 cp -r conkeror
"$jarbuild/conkeror"
171 pushd "$jarbuild" > /dev
/null
172 FILES
=($
(find conkeror
-name CVS
-prune -or \
( -type f
-and \
! -name '*[~#]' -print \
)))
173 zip conkeror.jar
"${FILES[@]}" > /dev
/null
175 mv "$jarbuild/conkeror.jar" .
181 function do_target_xulapp
() {
183 echo -n Building XULRunner Application...
185 mkdir
-p "$SCRATCH/chrome"
186 cp application.ini
"$SCRATCH"
187 mv conkeror.jar
"$SCRATCH/chrome/"
188 cp chrome.manifest.for-jar
"$SCRATCH/chrome/chrome.manifest"
189 copy_tree_sans_boring defaults
"$SCRATCH/defaults"
190 copy_tree_sans_boring components
"$SCRATCH/components"
191 pushd "$SCRATCH" > /dev
/null
192 ## begin preprocessing
194 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' application.ini
195 perl
-pi -e 's/\$CONKEROR_BUILD_DATE\$/'$BUILD_DATE'/g' application.ini
196 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' components
/application.js
199 zip -r conkeror.xulapp
* > /dev
/null
201 mv "$SCRATCH/conkeror.xulapp" .
207 function do_target_dist_tar
() {
210 ## now we have conkeror.xulapp
211 ## package it with install.sh
213 ## some other files should probably go in here.. NEWS, for example
214 mkdir
"$SCRATCH/conkeror-$VERSION"
215 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
216 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
217 pushd "$SCRATCH" > /dev
/null
218 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
220 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
221 echo -n "Making conkeror-$VERSION.tar.gz ..."
227 function do_target_release
() {
228 do_check_milestone_for_release
229 ## Make any and all release archives.
231 ## Right now, we just make a tar.gz archive that includes an install
232 ## script. In the future, we could consider making an OSX App, a Windows
233 ## Installer EXE, and a Mozilla XPI Installer.
236 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
237 mv conkeror-
$VERSION.
tar.gz ..
/downloads
242 function do_target_announce
() {
243 do_check_milestone_for_release
244 echo Entering ..
/www
/ ... ok
245 pushd ..
/www
/ > /dev
/null
246 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
248 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
249 diff_wrapper
"$scratch" index.html
"$perlexp"
251 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'
252 diff_wrapper
"$scratch" installation.html
"$perlexp"
259 function do_target_etags
() {
260 if [[ -z "$ETAGSDIR" ]]; then
263 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
264 echo -n "Building $ETAGSDIR ..."
265 etags
-o "$ETAGSDIR" conkeror
/content
/*.js
270 function do_target_notes
() {
271 FILES
=($
(find conkeror
-name \
*.js
))
272 for file in "${FILES[@]}"; do
273 fileo
="${file//\//\/}"
274 perl
-0777 -ne 's/## BLOCK COMMENTS
275 (.*\/\*\s*[A-Z][A-Z].*:.*$
278 (?{ $p = pos(); })) |
280 (.*\/\/\s*[A-Z][A-Z].*:.*$
283 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
288 function do_target_help
() {
289 echo "For this script to work, your current working directory must"
290 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
291 echo "This script expects to find the subdirectory structure,"
292 echo "\`conkeror/content', and VERSION in the current directory,"
293 echo "\`downloads' and \`www' in the parent directory, and possibly"
296 echo 'Usage: bash build.sh <TARGET>'
297 echo 'where <TARGET> is one of:'
303 echo ' release Builds a release xpi and puts it in ../downloads.'
305 echo ' announce Modify the website in ../www to announce a release.'
307 echo ' etags [DIR] Build TAGS file in etags format. If a'
308 echo ' directory is given, TAGS will be made in'
309 echo ' that directory.'
311 echo ' notes Shows specially formatted comments in'
312 echo " \`conkeror/content/*.js' Modifies no files."
314 echo ' help Shows this help message. Modifies no files.'
330 jar
) do_target_jar
;;
331 xulapp
) do_target_xulapp
;;
332 dist-tar
) do_target_dist_tar
;;
333 release
) do_target_release
;;
334 announce
) do_target_announce
;;
335 etags
) do_target_etags
;;
336 notes
) do_target_notes
;;
337 help) do_target_help
;;