Mercurial > octave
annotate build-aux/get-source-mtime.sh @ 33584:3fe954c2fd25 default tip @
maint: merge stable to default
author | Rik <rik@octave.org> |
---|---|
date | Mon, 13 May 2024 11:41:11 -0700 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
24077
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
1 #! /bin/sh |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2 |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 ######################################################################## |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
4 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
5 ## Copyright (C) 2017-2024 The Octave Project Developers |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
7 ## See the file COPYRIGHT.md in the top-level directory of this |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
8 ## distribution or <https://octave.org/copyright/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
9 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
10 ## This file is part of Octave. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
11 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
12 ## Octave is free software: you can redistribute it and/or modify it |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
13 ## under the terms of the GNU General Public License as published by |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
14 ## the Free Software Foundation, either version 3 of the License, or |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
15 ## (at your option) any later version. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
16 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
17 ## Octave is distributed in the hope that it will be useful, but |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
18 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
20 ## GNU General Public License for more details. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
21 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
22 ## You should have received a copy of the GNU General Public License |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
23 ## along with Octave; see the file COPYING. If not, see |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
24 ## <https://www.gnu.org/licenses/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
25 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
26 ######################################################################## |
24077
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
27 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
28 # Generate a timestamp that best represents the last modification time |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
29 # of this source tree. The time value is printed on stdout in units of |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
30 # time_t. If a reasonable representation of the source tree last |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
31 # modification time can't be determined, then the current system time is |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
32 # printed instead. A valid time_t value is always printed on stdout. |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
33 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
34 set -e |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
35 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
36 PERL=${PERL:-perl} |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
37 SED=${SED:-sed} |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
38 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
39 if [ $# -ne 1 ]; then |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
40 echo "usage: get-source-mtime.sh SRCDIR" 1>&2 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
41 exit 1 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
42 fi |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
43 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
44 srcdir="$1" |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
45 |
25800
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
46 ## A user's ~/.hgrc may redefine or add default options to any hg subcommand, |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
47 ## potentially altering its behavior and possibly its standard output. Always |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
48 ## run hg subcommands with configuration variables set to ensure that the |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
49 ## user's preferences do not influence the expected behavior. |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
50 hg_safe () |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
51 { |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
52 cmd=$1; shift |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
53 hg --config alias.${cmd}=${cmd} --config defaults.${cmd}= ${cmd} "$@" |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
54 } |
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
55 |
24077
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
56 if [ x"$SOURCE_DATE_EPOCH" != x ]; then |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
57 # Allow the source modification time to be overridden by SOURCE_DATE_EPOCH |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
58 t=$SOURCE_DATE_EPOCH |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
59 elif [ -d $srcdir/.hg ]; then |
25800
7b2312def76b
build: ensure hg commands are not affected by user settings
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
60 t=$( cd $srcdir && hg_safe log --rev . --template '{date|hgdate}' ) |
24077
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
61 t=$( echo $t | $SED -n 's/^\([0-9]\+\) .*/\1/p' ) |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
62 elif [ -f $srcdir/HG-ID ]; then |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
63 t=$( $PERL -e '@s = stat($ARGV[0]); print($s[9]) if @s;' $srcdir/HG-ID ) |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
64 elif [ -f $srcdir/configure ]; then |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
65 t=$( $PERL -e '@s = stat($ARGV[0]); print($s[9]) if @s;' $srcdir/configure ) |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
66 fi |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
67 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
68 if [ x"$t" = x ]; then |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
69 t=$( date +%s ) |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
70 fi |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
71 |
e483dcb5777d
build the source distribution archives reproducibly
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
72 echo $t |