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"
190 name
="$(basename "$x")"
191 "${XPIDL}" -w -v -m typelib -I "${XPIDL_INCLUDE}" -e "$SCRATCH/components/${name%.idl}.xpt" "$x"
193 pushd "$SCRATCH" > /dev
/null
194 ## begin preprocessing
196 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' application.ini
197 perl
-pi -e 's/\$CONKEROR_BUILD_DATE\$/'$BUILD_DATE'/g' application.ini
198 perl
-pi -e 's/\$CONKEROR_VERSION\$/'$VERSION'/g' components
/application.js
201 zip -r conkeror.xulapp
* > /dev
/null
203 mv "$SCRATCH/conkeror.xulapp" .
209 function do_target_dist_tar
() {
212 ## now we have conkeror.xulapp
213 ## package it with install.sh
215 ## some other files should probably go in here.. NEWS, for example
216 mkdir
"$SCRATCH/conkeror-$VERSION"
217 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
218 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
219 pushd "$SCRATCH" > /dev
/null
220 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
222 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
223 echo -n "Making conkeror-$VERSION.tar.gz ..."
229 function do_target_release
() {
230 do_check_milestone_for_release
231 ## Make any and all release archives.
233 ## Right now, we just make a tar.gz archive that includes an install
234 ## script. In the future, we could consider making an OSX App, a Windows
235 ## Installer EXE, and a Mozilla XPI Installer.
238 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
239 mv conkeror-
$VERSION.
tar.gz ..
/downloads
244 function do_target_announce
() {
245 do_check_milestone_for_release
246 echo Entering ..
/www
/ ... ok
247 pushd ..
/www
/ > /dev
/null
248 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
250 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
251 diff_wrapper
"$scratch" index.html
"$perlexp"
253 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'
254 diff_wrapper
"$scratch" installation.html
"$perlexp"
261 function do_target_etags
() {
262 if [[ -z "$ETAGSDIR" ]]; then
265 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
266 echo -n "Building $ETAGSDIR ..."
267 etags
-o "$ETAGSDIR" conkeror
/content
/*.js
272 function do_target_notes
() {
273 FILES
=($
(find conkeror
-name \
*.js
))
274 for file in "${FILES[@]}"; do
275 fileo
="${file//\//\/}"
276 perl
-0777 -ne 's/## BLOCK COMMENTS
277 (.*\/\*\s*[A-Z][A-Z].*:.*$
280 (?{ $p = pos(); })) |
282 (.*\/\/\s*[A-Z][A-Z].*:.*$
285 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
290 function do_target_help
() {
291 echo "For this script to work, your current working directory must"
292 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
293 echo "This script expects to find the subdirectory structure,"
294 echo "\`conkeror/content', and VERSION in the current directory,"
295 echo "\`downloads' and \`www' in the parent directory, and possibly"
298 echo 'Usage: bash build.sh <TARGET>'
299 echo 'where <TARGET> is one of:'
305 echo ' release Builds a release xpi and puts it in ../downloads.'
307 echo ' announce Modify the website in ../www to announce a release.'
309 echo ' etags [DIR] Build TAGS file in etags format. If a'
310 echo ' directory is given, TAGS will be made in'
311 echo ' that directory.'
313 echo ' notes Shows specially formatted comments in'
314 echo " \`conkeror/content/*.js' Modifies no files."
316 echo ' help Shows this help message. Modifies no files.'
332 jar
) do_target_jar
;;
333 xulapp
) do_target_xulapp
;;
334 dist-tar
) do_target_dist_tar
;;
335 release
) do_target_release
;;
336 announce
) do_target_announce
;;
337 etags
) do_target_etags
;;
338 notes
) do_target_notes
;;
339 help) do_target_help
;;