3 SDK_DIR
="/usr/lib/xulrunner"
5 XPIDL
="${SDK_DIR}/xpidl"
6 XPIDL_INCLUDE
="${SDK_DIR}/idl"
12 ## This variable is for target `etags'. It specifies the destination
13 ## directory for the TAGS file.
35 echo 'bad usage. please read the source.'
41 VERSION
=$
(grep '^Version=' application.ini | cut
-d '=' -f 2)
44 ## if this is not an official release, tag on a build date.
46 ## if this is an official release, strip the subminor.
48 MILESTONE
="${VERSION##*.}"
49 BUILD_DATE
=$
(date +%Y
%m
%d
)
50 SHORT_VERSION
="$VERSION"
54 VERSION
="${VERSION%.*}" ;;
56 VERSION
="$VERSION.$BUILD_DATE"
58 echo "build target: $TARGET, $VERSION"
69 ## Temporary directory for build process.
73 function get_scratch
() {
74 if [[ -z "$SCRATCH" ]]; then
75 SCRATCH
=$
(mktemp
-d conkeror-XXXXXX
)
80 function do_cleanup
() {
81 if [[ -n "$SCRATCH" ]]; then
88 function assert_conkeror_src
() {
89 if [[ ! -e application.ini
]]; then
90 echo "The current directory does not appear to contain the Conkeror source code."
96 function copy_tree_sans_boring
() {
102 ( cd "$src"; find .
-type d
-and \
! -name '*[~#]' -print0 ) \
103 |
( cd "$dest"; xargs -0 mkdir
-p )
104 files
=($
( cd "$src"; find .
-type f
-and \
! -name '*[~#]' -print ))
105 for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
111 function do_check_milestone_for_release
()
113 if [[ "$MILESTONE" = "0" ]]; then
118 proposed
="${VERSION%.*}".$
(( ${VERSION#*.} + 1 )).0
120 echo "The version given in the file $dest does not have 0 as its last component."
121 echo -n "Shall I rewrite \`VERSION=$VERSION.$MILESTONE' to \`VERSION=$proposed'? [yN] "
123 if [[ "$REPLY" = [Yy
]* ]]; then
124 perl
-pi -e 's/^VERSION='$VERSION'\.'$MILESTONE'$/VERSION='$proposed'/' "$dest"
125 echo "Version changed in $dest. Please run this build program again."
128 echo "Leaving $dest untouched. Continuing with build."
133 function diff_wrapper
() {
138 scratchfile
="${scratch}/$dest"
139 patchfile
="${scratch}/$dest.patch"
141 echo -n "Processing $dest ..."
142 perl
-0777 -p -e "$perlexp" "$dest" > "$scratchfile"
145 if cmp "$dest" "$scratchfile" ; then
146 echo "$dest does not need to be updated"
148 diff -u "$dest" "$scratchfile" |
tee "$patchfile"
149 echo -n "Apply this patch to $dest? [yN] "
151 if [[ "$REPLY" = [Yy
]* ]]; then
154 echo "Leaving $dest untouched"
167 function do_target_xulapp
() {
168 echo -n Building XULRunner Application...
170 #build the spawn-process-helper
174 mkdir
-p "$SCRATCH/chrome"
175 cp application.ini
"$SCRATCH"
176 if [ -n "$CONKEROR_APP_NAME" ]; then
177 sed -i -e "s/Name=conkeror/Name=${CONKEROR_APP_NAME}/" "${SCRATCH}/application.ini"
179 for x
in branding chrome components content defaults locale modules search-engines
; do
180 copy_tree_sans_boring
"$x" "$SCRATCH/$x"
182 cp spawn-process-helper
"${SCRATCH}"
185 name
="$(basename "$x")"
186 "${XPIDL}" -w -v -m typelib -I "${XPIDL_INCLUDE}" -e "$SCRATCH/components/${name%.idl}.xpt" "$x"
189 BUILD_ID
=$
(git rev-parse HEAD
2> /dev
/null
)
190 if [ "$?" != 0 ]; then
193 pushd "$SCRATCH" > /dev
/null
194 ## begin preprocessing
196 perl
-pi -e 's/BuildID=git/BuildID='${BUILD_ID}'/g' application.ini
199 zip -r ..
/conkeror.xulapp
* > /dev
/null
206 function do_target_dist_tar
() {
209 ## now we have conkeror.xulapp
210 ## package it with install.sh
212 ## some other files should probably go in here.. NEWS, for example
213 mkdir
"$SCRATCH/conkeror-$VERSION"
214 mv conkeror.xulapp
"$SCRATCH/conkeror-$VERSION/"
215 cp install.sh
"$SCRATCH/conkeror-$VERSION/"
216 pushd "$SCRATCH" > /dev
/null
217 tar c conkeror-
$VERSION |
gzip > conkeror-
$VERSION.
tar.gz
219 mv "$SCRATCH/conkeror-$VERSION.tar.gz" .
220 echo -n "Making conkeror-$VERSION.tar.gz ..."
226 function do_target_release
() {
227 do_check_milestone_for_release
228 ## Make any and all release archives.
230 ## Right now, we just make a tar.gz archive that includes an install
231 ## script. In the future, we could consider making an OSX App, a Windows
232 ## Installer EXE, and a Mozilla XPI Installer.
235 echo -n Putting conkeror-
$VERSION.
tar.gz
in downloads directory ...
236 mv conkeror-
$VERSION.
tar.gz ..
/downloads
241 function do_target_announce
() {
242 do_check_milestone_for_release
243 echo Entering ..
/www
/ ... ok
244 pushd ..
/www
/ > /dev
/null
245 scratch
=$
(mktemp
-d conkeror-XXXXXX
)
247 perlexp
='s/(?<=<!--\scontrolled\scontent\sinsertion\spoint::whatsnew\s-->\n) ()(?!.*'$VERSION'.*$)/<li>'$VERSION' released! \('"$(date '+%b %d, %Y')"'\)<\/li>\n/mxg'
248 diff_wrapper
"$scratch" index.html
"$perlexp"
250 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'
251 diff_wrapper
"$scratch" installation.html
"$perlexp"
258 function do_target_etags
() {
259 if [[ -z "$ETAGSDIR" ]]; then
262 ETAGSDIR
="${ETAGSDIR%/}/TAGS"
263 echo -n "Building $ETAGSDIR ..."
264 etags
-o "$ETAGSDIR" $
(find -name \
*.js
-and \
! -name '*[~#]*')
269 function do_target_notes
() {
270 FILES
=($
(find conkeror
-name \
*.js
))
271 for file in "${FILES[@]}"; do
272 fileo
="${file//\//\/}"
273 perl
-0777 -ne 's/## BLOCK COMMENTS
274 (.*\/\*\s*[A-Z][A-Z].*:.*$
277 (?{ $p = pos(); })) |
279 (.*\/\/\s*[A-Z][A-Z].*:.*$
282 /print "'$fileo':$p\n" . $& . "\n\n"/mexg' < "$file"
287 function do_target_help
() {
288 echo "For this script to work, your current working directory must"
289 echo "be \`<CONKEROR>/src' where <CONKEROR> is the project root."
290 echo "This script expects to find the subdirectory structure,"
291 echo "\`conkeror/content', and VERSION in the current directory,"
292 echo "\`downloads' and \`www' in the parent directory, and possibly"
295 echo 'Usage: bash build.sh <TARGET>'
296 echo 'where <TARGET> is one of:'
302 echo ' release Builds a release xpi and puts it in ../downloads.'
304 echo ' announce Modify the website in ../www to announce a release.'
306 echo ' etags [DIR] Build TAGS file in etags format. If a'
307 echo ' directory is given, TAGS will be made in'
308 echo ' that directory.'
310 echo ' notes Shows specially formatted comments in'
311 echo " \`conkeror/content/*.js' Modifies no files."
313 echo ' help Shows this help message. Modifies no files.'
329 xulapp
) do_target_xulapp
;;
330 dist-tar
) do_target_dist_tar
;;
331 release
) do_target_release
;;
332 announce
) do_target_announce
;;
333 etags
) do_target_etags
;;
334 notes
) do_target_notes
;;
335 help) do_target_help
;;