summaryrefslogtreecommitdiffstats
path: root/bin/release
blob: 9a43461fdd8ac1bc48edda6e85128ca4cc11bbfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/sh
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the files COPYING and Copyright.html.  COPYING can be found at the root
# of the source code distribution tree; Copyright.html can be found at the
# root level of an installed copy of the electronic HDF5 document set and
# is linked from the top-level documents page.  It can also be found at
# http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.
#

# Make a release of hdf5.  The command-line switches are:
#
#  -d DIR	The name of the directory where the releas(es) should be
#               placed.  By default, the directory is ./releases
#
#  --nocheck	Ignore errors in MANIFEST file.
#          
# The other command-line options are the names of the programs to use
# for compressing the resulting tar archive (if none are given then
# `tar md5' is assumed):
#
#   tar		-- use tar and don't do any compressing.
#   compress	-- use compress and append `.Z' to the output name.
#   gzip	-- use gzip with `-9' and append `.gz' to the output name.
#   bzip2       -- use bzip2 with `-9' and append `.bz2' to the output name.
#   md5         -- produce a md5 checksum in addition to the archive.
#
# Examples:
#
#   $ release
#   releases/hdf5-1.0.38.tar
#   releases/hdf5-1.0.38.tar.md5
#
#   $ release gzip
#   releases/hdf5-1.0.38.tar.gz
#
#   $ release -d /tmp tar compress gzip bzip2 md5
#   /tmp/hdf5-1.0.38.tar
#   /tmp/hdf5-1.0.38.tar.Z
#   /tmp/hdf5-1.0.38.tar.gz
#   /tmp/hdf5-1.0.38.tar.bz2
#   /tmp/hdf5-1.0.38.tar.md5
#
# Modifications
#   Robb Matzke, 1999-07-16
#   The SunOS 5.6 sed *must* have slashes as delimiters. I changed things like
#   `sed s+/CVS++' to `sed 's/\/CVS//'
#
#   Albert Cheng, 1999-10-26
#   Moved the MANIFEST checking to a separate command file so that
#   it can be invoked individually.

# Function definitions
#
# Print Usage page
USAGE()
{
cat << EOF
Usage: $0 [--nocheck] [-d <dir>] [-h] <methods> ...
   -d DIR	The name of the directory where the releas(es) should be
                placed.  By default, the directory is ./releases

   --nocheck	Ignore errors in MANIFEST file.
         
   --private	Make a private release with today's date in version information.
         
The other command-line options are the names of the programs to use
for compressing the resulting tar archive (if none are given then
"tar md5" is assumed):

    tar		-- use tar and don't do any compressing.
    compress	-- use compress and append ".Z" to the output name.
    gzip	-- use gzip with "-9" and append ".gz" to the output name.
    bzip2       -- use bzip2 with "-9" and append ".bz2" to the output name.
    md5         -- produce a md5 checksum in addition to the archive.

Examples:

    $ release
    releases/hdf5-1.0.38.tar
    releases/hdf5-1.0.38.tar.md5

    $ release gzip
    releases/hdf5-1.0.38.tar.gz

    $ release -d /tmp tar compress gzip bzip2 md5
    /tmp/hdf5-1.0.38.tar
    /tmp/hdf5-1.0.38.tar.Z
    /tmp/hdf5-1.0.38.tar.gz
    /tmp/hdf5-1.0.38.tar.bz2
    /tmp/hdf5-1.0.38.tar.md5

EOF

}

# This command must be run at the top level of the hdf5 source directory.
# Verify this requirement.
if [ ! \( -f configure -a -f bin/release \) ]; then
    echo "$0 must be run at the top level of the hdf5 source directory"
    exit 1
fi

# Defaults
DEST=releases
VERS=`perl bin/h5vers`
VERS_OLD=
test "$VERS" || exit 1
verbose=yes
check=yes
today=`date +%Y%m%d`
pmode='no'
tmpdir="../#release_tmp.$$"	# tmp work directory

# Restore previous Version information
RESTORE_VERSION()
{
    if [ X-${VERS_OLD} != X- ]; then
	echo restoring version information back to $VERS_OLD
	bin/h5vers -s $VERS_OLD
	VERS_OLD=
    fi
}


# Command-line arguments
while [ -n "$1" ]; do
    arg=$1
    shift
    case "$arg" in
	-d)
	    DEST=$1
	    shift
	    ;;
	--nocheck)
	    check=no
	    ;;
	-h)
	    USAGE
	    exit 0
	    ;;
	--private)
	    pmode=yes
	    ;;
	-*)
	    echo "Unknown switch: $arg" 1>&2
	    USAGE
	    exit 1
	    ;;
	*)
	    methods="$methods $arg"
	    ;;
    esac
done

# Default methods are tar and md5
if [ "X$methods" = "X" ]; then
    methods="tar md5"
fi

# Create the temporay work directory.
if mkdir $tmpdir; then
    echo "temporary work directory for release.  "\
         "Can be deleted after release completes." > $tmpdir/READEME
else
    echo "Failed to mkdir tmpdir($tmpdir)"
    exit 1
fi

# setup restoration in case of abort.
trap RESTORE_VERSION 0

if [ X$pmode = Xyes ]; then
    VERS_OLD=$VERS
    # Set version information to m.n.r-of$today.
    # (h5vers does not correctly handle just m.n.r-$today.)
    VERS=`echo $VERS | sed -e s/-.*//`-of$today
    echo Private release of $VERS
    bin/h5vers -s $VERS
fi

# Store hdf5-$VERS ("hdf5-1.7.51", e.g.) to a variable to avoid typos
HDF5_VERS=hdf5-$VERS

test "$verbose" && echo "Releasing $HDF5_VERS to $DEST" 1>&2
if [ ! -d $DEST ]; then
    echo "   Destination directory $DEST does not exist" 1>&2
    exit 1
fi

# Check the validity of the MANIFEST file.
bin/chkmanifest || fail=yes
if [ "X$fail" = "Xyes" ]; then
    if [ $check = yes ]; then
        exit 1
    else
	echo "Continuing anyway..."
    fi
fi

# Create a manifest that contains only files for distribution.
MANIFEST=$tmpdir/H5_MANIFEST
grep '^\.' MANIFEST | grep -v _DO_NOT_DISTRIBUTE_ >$MANIFEST

# Prepare the source tree for a release.
ln -s `pwd` $tmpdir/$HDF5_VERS || exit 1
mv Makefile $tmpdir/Makefile.x 2>/dev/null #might fail
cp -p Makefile.dist Makefile

# Update README.txt and release_docs/RELEASE.txt with release information.
for f in README.txt release_docs/RELEASE.txt; do
    echo "HDF5 version $VERS released on `date`" >$f.x
    tail +2l $f >>$f.x
    mv $f.x $f
    # Make sure new files are of the right access mode
    chmod 644 $f
done

# synchronize the HISTORY.tx and RELEASE.tx files in the doc area
cp release_docs/HISTORY.txt release_docs/RELEASE.txt doc/html/ADGuide/.

# Create the tar file
test "$verbose" && echo "   Running tar..." 1>&2
( \
    cd $tmpdir; \
    tar cf $HDF5_VERS.tar $HDF5_VERS/Makefile \
	`sed 's/^\.\//hdf5-'$VERS'\//' $MANIFEST` || exit 1 \
)

# Compress
for comp in $methods; do
    case $comp in
	tar)
	    cp -p $tmpdir/$HDF5_VERS.tar $DEST/$HDF5_VERS.tar
	    ;;
	compress)
	    test "$verbose" && echo "   Running compress..." 1>&2
	    compress -c <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.Z
	    ;;
	gzip)
	    test "$verbose" && echo "   Running gzip..." 1>&2
	    gzip -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.gz
	    ;;
	bzip2)
	    test "$verbose" && echo "   Running bzip2..." 1>&2
	    bzip2 -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.bz2
	    ;;
	md5)
	    test "$verbose" && echo "   Creating checksum..." 1>&2
	    (cd $tmpdir; md5sum $HDF5_VERS.tar ) > $DEST/$HDF5_VERS.tar.md5
	    ;;
    esac
done

# Copy the RELEASE.txt to the release area.
cp release_docs/RELEASE.txt $DEST/$HDF5_VERS-RELEASE.txt

# Restore previous Makefile if existed.
test -f $tmpdir/Makefile.x && mv $tmpdir/Makefile.x Makefile

# Restore OLD version information, then no need for trap.
if [ X$pmode = Xyes ]; then
    RESTORE_VERSION
    trap 0
fi

# Remove temporary things
rm -rf $tmpdir

exit 0