1#!/bin/sh
2#
3# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4#                         University Research and Technology
5#                         Corporation.  All rights reserved.
6# Copyright (c) 2004-2005 The University of Tennessee and The University
7#                         of Tennessee Research Foundation.  All rights
8#                         reserved.
9# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10#                         University of Stuttgart.  All rights reserved.
11# Copyright (c) 2004-2005 The Regents of the University of California.
12#                         All rights reserved.
13# Copyright (c) 2009-2015 Cisco Systems, Inc.  All rights reserved.
14# Copyright (c) 2015-2019 Research Organization for Information Science
15#                         and Technology (RIST).  All rights reserved.
16# Copyright (c) 2015      Los Alamos National Security, LLC. All rights
17#                         reserved.
18# Copyright (c) 2017      Intel, Inc. All rights reserved.
19# $COPYRIGHT$
20#
21# Additional copyrights may follow
22#
23# $HEADER$
24#
25
26srcdir=$1
27builddir=$PWD
28distdir=$builddir/$2
29PMIX_REPO_REV=$3
30
31if test x"$2" = x ; then
32    echo "*** ERROR: Must supply relative distdir as argv[2] -- aborting"
33    exit 1
34elif test ! -d "$distdir" ; then
35    echo "*** ERROR: dist dir does not exist"
36    echo "*** ERROR:   $distdir"
37    exit 1
38fi
39
40# We can catch some hard (but possible) to do mistakes by looking at
41# our repo's revision, but only if we are in the source tree.
42# Otherwise, use what configure told us, at the cost of allowing one
43# or two corner cases in (but otherwise VPATH builds won't work).
44repo_rev=$PMIX_REPO_REV
45if test -e .git ; then
46    repo_rev=$(config/pmix_get_version.sh VERSION --repo-rev)
47fi
48
49#
50# Update VERSION:repo_rev with the best value we have.
51#
52perl -pi -e 's/^repo_rev=.*/repo_rev='$repo_rev'/' -- "${distdir}/VERSION"
53# need to reset the timestamp to not annoy AM dependencies
54touch -r "${srcdir}/VERSION" "${distdir}/VERSION"
55
56echo "*** Updated VERSION file with repo rev: $repo_rev"
57echo "*** (via dist-hook / config/distscript.sh)"
58
59#
60# Update pmix.spec:%{version} with the main version
61#
62PMIX_SPEC=contrib/pmix.spec
63perl -pi -e 's/^Version:.*/Version: '$PMIX_REPO_REV'/' -- "${distdir}/$PMIX_SPEC"
64touch -r "${srcdir}/$PMIX_VERSION" "${distdir}/$PMIX_VERSION"
65
66echo "*** Updated $PMIX_SPEC file with repo rev: $PMIX_REPO_REV"
67echo "*** (via dist-hook / config/distscript.sh)"
68