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
23 echo "-------------------------------------------------"
26 echo "-------------------------------------------------"
28 # Variables used in this script:
29 # $GIT_DIR = option -g GIT_DIR; passed in environment to Git
30 # $OPTARG = Bash special: argument of the option being parsed
31 # $OPTIND = Bash special: index of argument to be parsed next
32 # $commit = commit ID corresponding to $rev
33 # $docdir = option -d DOCDIR
34 # $label = option -l LABEL
35 # $opt = option letter being parsed, or '?' on error
36 # $outdir = option -o OUTDIR
37 # $rev = option -r REVISION
39 # $tarbasename = name of the tar file without .tar.* extensions
40 # $tartopdir = name of the top directory within the tar file
41 # $tmpdir = temporary directory created by this script
48 while getopts "g:r:l:sd:o:" opt
51 (g
) GIT_DIR
=$OPTARG ;;
58 (*) echo >&2 "$0:$LINENO: bug found"
65 echo >&2 "$0: too many non-option arguments"
71 echo >&2 "$0: Must specify -g GIT_DIR option"
76 echo >&2 "$0: Must specify -o OUTDIR option"
81 echo >&2 "$0: Must specify -r REVISION option"
89 commit
=$
(GIT_DIR
=$GIT_DIR cg-object-id
-c "$rev") ||
exit 1
93 tartopdir
=elinks-
$label-$
(date +%Y
%m
%d
)
94 tarbasename
=elinks-current-
$label
96 tartopdir
=elinks-
$label
97 tarbasename
=elinks-
$label
100 tmpdir
=$
(mktemp
-d -t elinks-dist-XXXXXXXX
) ||
exit 1
102 # To make it easier to compare build logs, put the source first in an
103 # "elinks" directory, and only move to "$tartopdir" when finished.
105 GIT_DIR
=$GIT_DIR cg-export
-r "$rev" -- "$tmpdir/elinks"
106 mkdir
-- "$tmpdir/elinks/.git"
107 printf "%s\n" "$commit" > "$tmpdir/elinks/.git/HEAD"
110 cd -- "$tmpdir/elinks"
117 mv contrib
/elinks.spec ..
/contrib
/
120 if [ -n "$docdir" ]; then
121 mkdir
-- "$tmpdir/elinks/doc/html"
122 cp -r -- "$docdir"/*.html
* "$tmpdir/elinks/doc/html/"
124 # cp "$docdir"/*.pdf doc/pdf
127 rm -rf -- "$tmpdir/elinks/build"
128 mv -- "$tmpdir/elinks" "$tmpdir/$tartopdir"
132 tar cf
"$tarbasename.tar" "$tartopdir"
133 md5sum --binary -- "$tarbasename.tar" > "$tarbasename.md5"
134 bzip2 --keep -- "$tarbasename.tar"
135 gzip -9 -- "$tarbasename.tar"
136 md5sum --binary -- "$tarbasename.tar.gz" "$tarbasename.tar.bz2" >> "$tarbasename.md5"
139 mv -- "$tmpdir/$tarbasename.tar.gz" "$outdir"
140 mv -- "$tmpdir/$tarbasename.tar.bz2" "$outdir"
141 mv -- "$tmpdir/$tarbasename.md5" "$outdir"