3 # This script can be used by a cron to generate snapshots.
5 # 35 0 * * * mkdist -r elinks-0.11 -l 0.11 -s >>mkdist.log 2>&1
6 # 40 0 * * * mkdist -r HEAD -l 0.12 -s >>mkdist.log 2>&1
9 # -g GIT_DIR Git repository from which this script exports ELinks.
10 # May be given in the environment instead.
11 # -r REVISION Git revision to be exported from the repository.
12 # -l LABEL User-friendly name of the branch or release.
13 # This ends up in the name of the tar file, and in the
14 # name of the directory it contains.
15 # -s Generate a snapshot (which has a date in the top-level
17 # -d DOCDIR Copy prebuilt documentation from DOCDIR.
18 # -o OUTDIR Place the output files in OUTDIR. Defaults to the
24 -------------------------------------------------
27 -------------------------------------------------
30 # Variables used in this script:
31 # $GIT_DIR = option -g GIT_DIR; passed in environment to Git
32 # $OPTARG = Bash special: argument of the option being parsed
33 # $OPTIND = Bash special: index of argument to be parsed next
34 # $commit = commit ID corresponding to $rev
35 # $docdir = option -d DOCDIR
36 # $label = option -l LABEL
37 # $opt = option letter being parsed, or '?' on error
38 # $outdir = option -o OUTDIR
39 # $rev = option -r REVISION
41 # $tarbasename = name of the tar file without .tar.* extensions
42 # $tartopdir = name of the top directory within the tar file
43 # $tmpdir = temporary directory created by this script
50 while getopts "g:r:l:sd:o:" opt
53 (g
) GIT_DIR
=$OPTARG ;;
60 (*) printf >&2 "%s:%d: bug found\n" "$0" "$LINENO"
67 printf >&2 "%s: too many non-option arguments\n" "$0"
73 printf >&2 "%s: Must specify -g GIT_DIR option\n" "$0"
78 printf >&2 "%s: Must specify -o OUTDIR option\n" "$0"
83 printf >&2 "%s: Must specify -r REVISION option\n" "$0"
91 commit
=$
(git
--git-dir="$GIT_DIR" rev-parse
--verify "$rev^{commit}") ||
exit 1
95 tartopdir
=elinks-
$label-$
(date +%Y
%m
%d
)
96 tarbasename
=elinks-current-
$label
98 tartopdir
=elinks-
$label
99 tarbasename
=elinks-
$label
102 tmpdir
=$
(mktemp
-d -t elinks-dist-XXXXXXXX
) ||
exit 1
104 # To make it easier to compare build logs, put the source first in an
105 # "elinks" directory, and only move to "$tartopdir" when finished.
107 git
--git-dir="$GIT_DIR" archive
--format=tar --prefix="elinks/" "$rev" |
108 (cd -- "$tmpdir" && tar -xf -)
109 printf "%s\n" "$commit" > "$tmpdir/elinks/git-commit-id"
112 cd -- "$tmpdir/elinks"
116 # Enable lots of features so that their options will appear in elinks
117 # --config-help and doc/html/elinks.conf.5.html.
118 ..
/configure
--enable-bittorrent --enable-cgi --enable-fsp --enable-nntp
121 mv contrib
/elinks.spec ..
/contrib
/
124 if [ -n "$docdir" ]; then
125 mkdir
-- "$tmpdir/elinks/doc/html"
126 cp -r -- "$docdir"/*.html
* "$tmpdir/elinks/doc/html/"
128 # cp "$docdir"/*.pdf doc/pdf
130 make -C "$tmpdir/elinks/build"
131 make -C "$tmpdir/elinks/build/doc" html
132 mkdir
-- "$tmpdir/elinks/doc/html"
133 mv -- "$tmpdir/elinks/build/doc"/*.html
* "$tmpdir/elinks/doc/html/"
134 # <http://translationproject.org/html/maintainers.html>:
135 # "this tarball should contain an up to date POT file."
136 # Build that here. The Makefile also creates potfiles.list
137 # in the source directory; that one we don't need.
138 # Use rm -f so it's not an error if the file is not there.
139 make -C "$tmpdir/elinks/build/po" ..
/..
/po
/elinks.pot
140 rm -f -- "$tmpdir/elinks/po/potfiles.list"
143 rm -rf -- "$tmpdir/elinks/build"
144 mv -- "$tmpdir/elinks" "$tmpdir/$tartopdir"
148 tar cf
"$tarbasename.tar" "$tartopdir"
149 bzip2 --keep -- "$tarbasename.tar"
150 gzip -9 -- "$tarbasename.tar"
151 md5sum --binary -- "$tarbasename.tar.gz" > "$tarbasename.tar.gz.md5"
152 md5sum --binary -- "$tarbasename.tar.bz2" > "$tarbasename.tar.bz2.md5"
155 mv -- "$tmpdir/$tarbasename.tar.gz" "$outdir"
156 mv -- "$tmpdir/$tarbasename.tar.bz2" "$outdir"
157 mv -- "$tmpdir/$tarbasename.tar.gz.md5" "$outdir"
158 mv -- "$tmpdir/$tarbasename.tar.bz2.md5" "$outdir"