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 ## if this is not an official release, tag on a build date.
47 ## if this is an official release, strip the subminor.
49 MILESTONE
="${VERSION##*.}"
50 BUILD_DATE
=$
(date +%Y
%m
%d
)
51 SHORT_VERSION
="$VERSION"
55 VERSION
="${VERSION%.*}" ;;
57 VERSION
="$VERSION.$BUILD_DATE"
59 echo "build target: $TARGET, $VERSION"
70 ## Temporary directory for build process.
74 function get_scratch
() {
75 if [[ -z "$SCRATCH" ]]; then
76 SCRATCH
=$
(mktemp
-d conkeror-XXXXXX
)
81 function do_cleanup
() {
82 if [[ -n "$SCRATCH" ]]; then
89 function assert_conkeror_src
() {
90 if [[ ! -e application.ini
]]; then
91 echo "The current directory does not appear to contain the Conkeror source code."
97 function copy_tree_sans_boring
() {
103 ( cd "$src"; find .
-type d
-and \
! -name '*[~#]' -print0 ) \
104 |
( cd "$dest"; xargs -0 mkdir
-p )
105 files
=($
( cd "$src"; find .
-type f
-and \
! -name '*[~#]' -print ))
106 for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
112 function do_check_milestone_for_release
()
114 if [[ "$MILESTONE" = "0" ]]; then
119 proposed
="${VERSION%.*}".$
(( ${VERSION#*.} + 1 )).0
121 echo "The version given in the file $dest does not have 0 as its last component."
122 echo -n "Shall I rewrite \`VERSION=$VERSION.$MILESTONE' to \`VERSION=$proposed'? [yN] "
124 if [[ "$REPLY" = [Yy
]* ]]; then
125 perl
-pi -e 's/^VERSION='$VERSION'\.'$MILESTONE'$/VERSION='$proposed'/' "$dest"
126 echo "Version changed in $dest. Please run this build program again."
129 echo "Leaving $dest untouched. Continuing with build."
134 function diff_wrapper
() {
139 scratchfile
="${scratch}/$dest"
140 patchfile
="${scratch}/$dest.patch"
142 echo -n "Processing $dest ..."
143 perl
-0777 -p -e "$perlexp" "$dest" > "$scratchfile"
146 if cmp "$dest" "$scratchfile" ; then
147 echo "$dest does not need to be updated"
149 diff -u "$dest" "$scratchfile" |
tee "$patchfile"
150 echo -n "Apply this patch to $dest? [yN] "
152 if [[ "$REPLY" = [Yy
]* ]]; then
155 echo "Leaving $dest untouched"
168 function do_target_jar
() {
169 echo -n Building JAR...
170 FILES
=($
(find content branding locale modules
-type f
-and \
! -name '*[~#]' -print ))
171 zip "conkeror.jar" "${FILES[@]}" > /dev
/null
176 function do_target_xulapp
() {
178 echo -n Building XULRunner Application...
180 mkdir
-p "$SCRATCH/chrome"
181 cp application.ini
"$SCRATCH"
182 if [ -n "$CONKEROR_APP_NAME" ]; then
183 sed -i -e "s/Name=conkeror/Name=${CONKEROR_APP_NAME}/" "${SCRATCH}/application.ini"
185 mv conkeror.jar
"$SCRATCH/chrome/"
186 cp chrome.manifest.for-jar
"$SCRATCH/chrome/chrome.manifest"
187 copy_tree_sans_boring defaults
"$SCRATCH/defaults"
188 copy_tree_sans_boring components
"$SCRATCH/components"
191 name
="$(basename "$x")"
192 "${XPIDL}" -w -v -m typelib -I "${XPIDL_INCLUDE}" -e "$SCRATCH/components/${name%.idl}.xpt" "$x"
195 pushd "$SCRATCH" > /dev
/null
196 ## begin preprocessing
198 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' application.ini
199 perl
-pi -e 's/\$CONKEROR_BUILD_DATE\$/'$BUILD_DATE'/g' application.ini
200 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' components
/application.js
203 zip -r conkeror.xulapp
* > /dev
/null
205 mv "$SCRATCH/conkeror.xulapp" .
211 function do_target_dist_tar
() {
214 ## now we have conkeror.xulapp
215 ## package it with install.sh
217 ## some other files should probably go in here.. NEWS, for example
218 mkdir
"$SCRATCH/conkeror-$VERSION"
219 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
220 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
221 pushd "$SCRATCH" > /dev
/null
222 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
224 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
225 echo -n "Making conkeror-$VERSION.tar.gz ..."
231 function do_target_release
() {
232 do_check_milestone_for_release
233 ## Make any and all release archives.
235 ## Right now, we just make a tar.gz archive that includes an install
236 ## script. In the future, we could consider making an OSX App, a Windows
237 ## Installer EXE, and a Mozilla XPI Installer.
240 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
241 mv conkeror-
$VERSION.
tar.gz ..
/downloads
246 function do_target_announce
() {
247 do_check_milestone_for_release
248 echo Entering ..
/www
/ ... ok
249 pushd ..
/www
/ > /dev
/null
250 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
252 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
253 diff_wrapper
"$scratch" index.html
"$perlexp"
255 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'
256 diff_wrapper
"$scratch" installation.html
"$perlexp"
263 function do_target_etags
() {
264 if [[ -z "$ETAGSDIR" ]]; then
267 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
268 echo -n "Building $ETAGSDIR ..."
269 etags
-o "$ETAGSDIR" $
(find -name \
*.js
-and \
! -name '*[~#]*')
274 function do_target_notes
() {
275 FILES
=($
(find conkeror
-name \
*.js
))
276 for file in "${FILES[@]}"; do
277 fileo
="${file//\//\/}"
278 perl
-0777 -ne 's/## BLOCK COMMENTS
279 (.*\/\*\s*[A-Z][A-Z].*:.*$
282 (?{ $p = pos(); })) |
284 (.*\/\/\s*[A-Z][A-Z].*:.*$
287 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
292 function do_target_help
() {
293 echo "For this script to work, your current working directory must"
294 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
295 echo "This script expects to find the subdirectory structure,"
296 echo "\`conkeror/content', and VERSION in the current directory,"
297 echo "\`downloads' and \`www' in the parent directory, and possibly"
300 echo 'Usage: bash build.sh <TARGET>'
301 echo 'where <TARGET> is one of:'
307 echo ' release Builds a release xpi and puts it in ../downloads.'
309 echo ' announce Modify the website in ../www to announce a release.'
311 echo ' etags [DIR] Build TAGS file in etags format. If a'
312 echo ' directory is given, TAGS will be made in'
313 echo ' that directory.'
315 echo ' notes Shows specially formatted comments in'
316 echo " \`conkeror/content/*.js' Modifies no files."
318 echo ' help Shows this help message. Modifies no files.'
334 jar
) do_target_jar
;;
335 xulapp
) do_target_xulapp
;;
336 dist-tar
) do_target_dist_tar
;;
337 release
) do_target_release
;;
338 announce
) do_target_announce
;;
339 etags
) do_target_etags
;;
340 notes
) do_target_notes
;;
341 help) do_target_help
;;