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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
|
#!/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 HDF. The full HDF copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
# Make a release of hdf4.
# Function definitions
#
# Print Usage page
USAGE()
{
cat << EOF
Usage: $0 -d <dir> [-h] [--private] [--revision [--branch BRANCHNAME]] <methods> ...
-d DIR The name of the directory where the release(s) should be
placed.
--branch BRANCHNAME This is to get the correct version of the branch name from the
repository. BRANCHNAME for v4.2.16 should be hdf4_2_16.
-h print the help page.
--private Make a private release with today's date in version information.
--revision Make a private release with the code revision number in version information.
This must be run at the top level of the source directory.
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" is assumed):
tar -- use tar and don't do any compressing.
gzip -- use gzip with "-9" and append ".gz" to the output name.
bzip2 -- use bzip2 with "-9" and append ".bz2" to the output name.
zip -- convert all text files to DOS style and form a zip file for Windows use.
cmake-tgz -- create a tar file using the gzip default level with a build-unix.sh
command file and all other CMake files needed to build HDF4 source
using CMake on unix machines.
cmake-zip -- convert all text files to DOS style and create a zip file including cmake
scripts and .bat files to build HDF4 source using CMake on Windows.
A sha256 checksum is produced for each archive created and stored in the sha256 file.
Examples:
$ bin/release -d /tmp
/tmp/hdf-4.2.15-RELEASE.txt
/tmp/hdf-4.2.15.sha256
/tmp/hdf-4.2.15.tar
$ bin/release -d /tmp gzip
/tmp/hdf-4.2.15-RELEASE.txt
/tmp/hdf-4.2.15.sha256
/tmp/hdf-4.2.15.tar.gz
$ bin/release -d /tmp tar gzip zip
/tmp/hdf-4.2.15-RELEASE.txt
/tmp/hdf-4.2.15.sha256
/tmp/hdf-4.2.15.tar
/tmp/hdf-4.2.15.tar.gz
/tmp/hdf-4.2.15.zip
EOF
}
# Function name: tar2zip
# Convert the release tarball to a Windows zipball.
#
# Steps:
# 1. untar the tarball in a temporary directory;
# Note: do this in a temporary directory to avoid changing
# the original source directory which may be around.
# 2. convert all its text files to DOS (LF-CR) style;
# 3. form a zip file which is usable by Windows users.
#
# Parameters:
# $1 version
# $2 release tarball
# $3 output zipball file name
#
# Returns 0 if successful; 1 otherwise
#
tar2zip()
{
if [ $# -ne 3 ]; then
echo "usage: tar2zip <tarfilename> <zipfilename>"
return 1
fi
ztmpdir=/tmp/ztmpdir$$
mkdir -p $ztmpdir
version=$1
tarfile=$2
zipfile=$3
# step 1: untar tarball in ztmpdir
(cd $ztmpdir; tar xf -) < $tarfile
# sanity check
if [ ! -d $ztmpdir/$version ]; then
echo "untar did not create $ztmpdir/$version source dir"
# cleanup
rm -rf $ztmpdir
return 1
fi
# step 2: convert text files
# There maybe a simpler way to do this.
# options used in unix2dos:
# -k Keep the date stamp
# -q quiet mode
# grep redirect output to /dev/null because -q or -s are not portable.
find $ztmpdir/$version | \
while read inf; do \
if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \
unix2dos -q -k $inf; \
fi\
done
# step 3: make zipball
# -9 maximum compression
# -y Store symbolic links as such in the zip archive
# -r recursive
# -q quiet
(cd $ztmpdir; zip -9 -y -r -q $version.zip $version)
mv $ztmpdir/$version.zip $zipfile
# cleanup
rm -rf $ztmpdir
}
# Function name: tar2cmakezip
# Convert the release tarball to a Windows zipball with files to run CMake build.
#
# Steps:
# 1. untar the tarball in a temporary directory;
# Note: do this in a temporary directory to avoid changing
# the original source directory which may be around.
# 2. add build-unix.sh script.
# 3. add LIBAEC.tar.gz, ZLib.tar.gz and cmake files to top level directory.
# 4. create gzipped tar file with these contents:
# build-unix.sh script
# hdf4-<version> source code directory extracted from tar file
# CTestScript.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# HDF4config.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# HDF4options.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# LIBAEC.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# ZLib.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# JPEG9e.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# Parameters:
# $1 version
# $2 release tarball
# $3 output zipball file name
#
# Returns 0 if successful; 1 otherwise
#
# need function to create another temporary directory, extract the
# $tmpdir/$HDF4_VERS.tar into it, create build-VS*.bat files,
# add CTestScript.cmake, HDF4config.cmake, LIBAEC.tar.gz, ZLib.tar.gz,
# and JPEG9e.tar.gz, HDF4 examples and then zip it.
tar2cmakezip()
{
if [ $# -ne 3 ]; then
echo "usage: tar2cmakezip <tarfilename> <zipfilename>"
return 1
fi
cmziptmpdir=/tmp/cmziptmpdir$$
cmziptmpsubdir=$cmziptmpdir/CMake-$HDF4_VERS
mkdir -p $cmziptmpsubdir
version=$1
tarfile=$2
zipfile=$3
# step 1: untar tarball in cmgztmpdir
(cd $cmziptmpsubdir; tar xf -) < $tarfile
# sanity check
if [ ! -d $cmziptmpsubdir/$version ]; then
echo "untar did not create $cmziptmpsubdir/$version source dir"
# cleanup
rm -rf $cmziptmpdir
return 1
fi
# step 2: add batch file for building CMake on Windows
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS2015 -C Release -V -O hdf4.log" > build-VS2015-32.bat; chmod 755 build-VS2015-32.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS201564 -C Release -V -O hdf4.log" > build-VS2015-64.bat; chmod 755 build-VS2015-32.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS2017 -C Release -V -O hdf4.log" > build-VS2017-32.bat; chmod 755 build-VS2017-32.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS201764 -C Release -V -O hdf4.log" > build-VS2017-64.bat; chmod 755 build-VS2017-64.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS2019 -C Release -V -O hdf4.log" > build-VS2019-32.bat; chmod 755 build-VS2019-32.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS201964 -C Release -V -O hdf4.log" > build-VS2019-64.bat; chmod 755 build-VS2019-64.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS2022 -C Release -V -O hdf4.log" > build-VS2022-32.bat; chmod 755 build-VS2022-32.bat)
(cd $cmziptmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=VS202264 -C Release -V -O hdf4.log" > build-VS2022-64.bat; chmod 755 build-VS2022-32.bat)
# step 3: add LIBAEC.tar.gz, ZLib.tar.gz and cmake files
cp /mnt/scr1/pre-release/hdf4/CMake/LIBAEC.tar.gz $cmziptmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/ZLib.tar.gz $cmziptmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/JPEG9e.tar.gz $cmziptmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/HDF4Examples-0.3.10-Source.zip $cmziptmpsubdir
cp $cmziptmpsubdir/$version/config/cmake/scripts/CTestScript.cmake $cmziptmpsubdir
cp $cmziptmpsubdir/$version/config/cmake/scripts/HDF4config.cmake $cmziptmpsubdir
cp $cmziptmpsubdir/$version/config/cmake/scripts/HDF4options.cmake $cmziptmpsubdir
# step 4: convert text files
# There maybe a simpler way to do this.
# options used in unix2dos:
# -k Keep the date stamp
# -q quiet mode
# grep redirect output to /dev/null because -q or -s are not portable.
find $cmziptmpsubdir/$version | \
while read inf; do \
if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \
unix2dos -q -k $inf; \
fi\
done
# step 3: make zipball
# -9 maximum compression
# -y Store symbolic links as such in the zip archive
# -r recursive
# -q quiet
(cd $cmziptmpdir; zip -9 -y -r -q CMake-$version.zip *)
mv $cmziptmpdir/CMake-$version.zip $zipfile
# cleanup
rm -rf $cmziptmpdir
}
# Function name: tar2cmaketgz
# Convert the release tarball to a gzipped tar file with files to run CMake build.
#
#
# Steps:
# 1. untar the tarball in a temporary directory;
# Note: do this in a temporary directory to avoid changing
# the original source directory which may be around.
# 2. add build-unix.sh script.
# 3. add LIBAEC.tar.gz, ZLib.tar.gz and cmake files to top level directory.
# 4. create gzipped tar file with these contents:
# build-unix.sh script
# hdf4-<version> source code directory extracted from tar file
# CTestScript.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# HDF4config.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# HDF4options.cmake cmake file copied from <hdf4 source code>/config/cmake/scripts
# LIBAEC.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# ZLib.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# JPEG8d.tar.gz copied from /mnt/scr1/pre-release/hdf4/CMake
# Parameters:
# $1 version
# $2 release tarball
# $3 output zipball file name
#
# Returns 0 if successful; 1 otherwise
#
# need function to create another temporary directory, extract the
# $tmpdir/$HDF4_VERS.tar into it, create build-unix.sh,
# add CTestScript.cmake, HDF4config.cmake, LIBAEC.tar.gz
# ZLib.tar.gz, JPEG9e.tar.gz, HDF4 examples and then tar.gz it.
tar2cmaketgz()
{
if [ $# -ne 3 ]; then
echo "usage: tar2cmaketgz <tarfilename> <tgzfilename>"
return 1
fi
cmgztmpdir=/tmp/cmgztmpdir$$
cmgztmpsubdir=$cmgztmpdir/CMake-$HDF4_VERS
mkdir -p $cmgztmpsubdir
version=$1
tarfile=$2
tgzfile=$3
# step 1: untar tarball in cmgztmpdir
(cd $cmgztmpsubdir; tar xf -) < $tarfile
# sanity check
if [ ! -d $cmgztmpsubdir/$version ]; then
echo "untar did not create $cmgztmpsubdir/$version source dir"
# cleanup
rm -rf $cmgztmpdir
return 1
fi
# step 2: add build-unix.sh script
(cd $cmgztmpsubdir; echo "ctest -S HDF4config.cmake,BUILD_GENERATOR=Unix -C Release -V -O hdf4.log" > build-unix.sh; chmod 755 build-unix.sh)
# step 3: add LIBAEC.tar.gz, ZLib.tar.gz and cmake files
cp /mnt/scr1/pre-release/hdf4/CMake/LIBAEC.tar.gz $cmgztmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/ZLib.tar.gz $cmgztmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/JPEG9e.tar.gz $cmgztmpsubdir
cp /mnt/scr1/pre-release/hdf4/CMake/HDF4Examples-0.3.10-Source.tar.gz $cmgztmpsubdir
cp $cmgztmpsubdir/$version/config/cmake/scripts/CTestScript.cmake $cmgztmpsubdir
cp $cmgztmpsubdir/$version/config/cmake/scripts/HDF4config.cmake $cmgztmpsubdir
cp $cmgztmpsubdir/$version/config/cmake/scripts/HDF4options.cmake $cmgztmpsubdir
tar czf $DEST/CMake-$HDF4_VERS.tar.gz -C $cmgztmpdir . || exit 1
# cleanup
rm -rf $cmgztmpdir
}
# This command must be run at the top level of the hdf4 source directory.
# Verify this requirement.
if [ ! \( -f configure.ac -a -f bin/release \) ]; then
echo "$0 must be run at the top level of the hdf4 source directory"
exit 1
fi
# Defaults
DEST=releases
VERS=`perl bin/h4vers`
VERS_OLD=
test "$VERS" || exit 1
verbose=yes
check=yes
release_date=`date +%F`
today=`date +%Y%m%d`
pmode='no'
revmode='no'
tmpdir="../#release_tmp.$$" # tmp work directory
MAINT_MODE_ENABLED=""
# If maintainer mode is enabled in configure, it should be disabled for release,
# and enabled again after release files have been created. If already disabled
# there's no need to do either.
MAINT_MODE_ENABLED=`grep ^AM_MAINTAINER_MODE ./configure.ac | grep enable`
if [ "${MAINT_MODE_ENABLED}" != "" ]; then
bin/switch_maint_mode -disable ./configure.ac
fi
# Restore previous Version information
RESTORE_VERSION()
{
if [ X-${VERS_OLD} != X- ]; then
echo restoring version information back to $VERS_OLD
bin/h4vers -s $VERS_OLD
VERS_OLD=
fi
}
# Command-line arguments
while [ -n "$1" ]; do
arg=$1
shift
case "$arg" in
-d)
DEST=$1
shift
;;
-h)
USAGE
exit 0
;;
--private)
pmode=yes
;;
--revision)
revmode=yes
;;
--branch)
BRANCHNAME=$1
shift
;;
-*)
echo "Unknown switch: $arg" 1>&2
USAGE
exit 1
;;
*)
methods="$methods $arg"
;;
esac
done
# Default method is tar
if [ "X$methods" = "X" ]; then
methods="tar"
fi
# Create the temporary work directory.
if mkdir $tmpdir; then
echo "temporary work directory for release. "\
"Can be deleted after release completes." > $tmpdir/README
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.
# (h4vers does not correctly handle just m.n.r-$today.)
VERS=`echo $VERS | sed -e s/-.*//`-of$today
echo Private release of $VERS
bin/h4vers -s $VERS
fi
if [ X$revmode = Xyes ]; then
VERS_OLD=$VERS
echo "Save old version $VERS_OLD for restoration later."
if [ "${BRANCHNAME}" = "" ]; then
BRANCHNAME=`git symbolic-ref -q --short HEAD`
fi
revision=`git rev-parse --short HEAD`
# Set version information to m.n.r-r$revision.
# (h4vers does not correctly handle just m.n.r-$today.)
VERS=`echo $VERS | sed -e s/-.*//`-$revision
echo Private release of $VERS
HDF4_VERS=hdf4-$BRANCHNAME-$revision
echo file base of $HDF4_VERS
bin/h4vers -s $VERS
# use a generic directory name for revision releases
HDF4_IN_VERS=hdfsrc
else
# Store hdf4-$VERS ("hdf-4.2.15", e.g.) to a variable to avoid typos
HDF4_VERS=hdf-$VERS
# directory name matches tar file name for non-revision releases
HDF4_IN_VERS=$HDF4_VERS
fi
test "$verbose" && echo "Releasing $HDF4_VERS to $DEST" 1>&2
if [ ! -d $DEST ]; then
echo " Destination directory $DEST does not exist" 1>&2
exit 1
fi
# Create a symlink to the source so files in the tarball have the prefix
# we want (gnu's --transform isn't portable)
ln -s `pwd` $tmpdir/$HDF4_IN_VERS || exit 1
# Save a backup copy of Makefile if exists.
test -f Makefile && mv Makefile $tmpdir/Makefile.x
cp -p Makefile.dist Makefile
# Update README.md and release_notes/RELEASE.txt with release information in
# line 1.
for f in README.md release_notes/RELEASE.txt; do
echo "HDF version $VERS released on $release_date" >$f.x
sed -e 1d $f >>$f.x
mv $f.x $f
# Make sure new files are of the right access mode
chmod 644 $f
done
# Create the tar file
test "$verbose" && echo " Running tar..." 1>&2
(cd "$tmpdir" && exec tar -ch --exclude-vcs --exclude=.clang-format --exclude=.git* -f "$HDF4_VERS.tar" "./$HDF4_IN_VERS" || exit 1 )
# Compress
SHA256=$HDF4_VERS.sha256
cp /dev/null $DEST/$SHA256
for comp in $methods; do
case $comp in
tar)
cp -p $tmpdir/$HDF4_VERS.tar $DEST/$HDF4_VERS.tar
(cd $DEST; sha256sum $HDF4_VERS.tar >> $SHA256)
;;
gzip)
test "$verbose" && echo " Running gzip..." 1>&2
gzip -9 <$tmpdir/$HDF4_VERS.tar >$DEST/$HDF4_VERS.tar.gz
(cd $DEST; sha256sum $HDF4_VERS.tar.gz >> $SHA256)
;;
cmake-tgz)
test "$verbose" && echo " Creating CMake tar.gz file..." 1>&2
tar2cmaketgz $HDF4_IN_VERS $tmpdir/$HDF4_VERS.tar $DEST/CMake-$HDF4_VERS.tar.gz 1>&2
(cd $DEST; sha256sum CMake-$HDF4_VERS.tar.gz >> $SHA256)
;;
bzip2)
test "$verbose" && echo " Running bzip2..." 1>&2
bzip2 -9 <$tmpdir/$HDF4_VERS.tar >$DEST/$HDF4_VERS.tar.bz2
(cd $DEST; sha256sum $HDF4_VERS.tar.bz2 >> $SHA256)
;;
zip)
test "$verbose" && echo " Creating zip ball..." 1>&2
tar2zip $HDF4_IN_VERS $tmpdir/$HDF4_VERS.tar $DEST/$HDF4_VERS.zip 1>&2
(cd $DEST; sha256sum $HDF4_VERS.zip >> $SHA256)
;;
cmake-zip)
test "$verbose" && echo " Creating CMake-zip ball..." 1>&2
tar2cmakezip $HDF4_IN_VERS $tmpdir/$HDF4_VERS.tar $DEST/CMake-$HDF4_VERS.zip 1>&2
(cd $DEST; sha256sum CMake-$HDF4_VERS.zip >> $SHA256)
;;
*)
echo "***Error*** Unknown method $comp"
exit 1
;;
esac
done
# If AM_MAINTAINER_MODE was enabled before running this script
# restore it to "enabled".
if [ "${MAINT_MODE_ENABLED}" != "" ]; then
bin/switch_maint_mode -enable ./configure.ac
fi
# Copy the RELEASE.txt to the release area.
cp release_notes/RELEASE.txt $DEST/$HDF4_VERS-RELEASE.txt
# Remove distributed Makefile and restore previous Makefile if existed.
rm -f Makefile
test -f $tmpdir/Makefile.x && mv $tmpdir/Makefile.x Makefile
# Restore OLD version information, then no need for trap.
if [ X$pmode = Xyes ] || [ X$revmode = Xyes ]; then
echo "Restore the original version $VERS_OLD"
RESTORE_VERSION
trap 0
fi
# Remove temporary things
rm -rf $tmpdir
echo "DONE"
exit 0
|