public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH cygport] Add more checks of SOURCE_DATE_EPOCH
@ 2024-02-16 12:29 Christian Franke
  2024-02-26 19:30 ` Jon Turney
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Franke @ 2024-02-16 12:29 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Add-more-checks-of-SOURCE_DATE_EPOCH.patch --]
[-- Type: text/plain, Size: 1601 bytes --]

From b04c8f5e9becd6e91095e2add551f72870c9e869 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Fri, 16 Feb 2024 13:16:06 +0100
Subject: [PATCH] Add more checks of SOURCE_DATE_EPOCH

Fail if it is out of range.  Warn if it lies in the future.
Inform whether it is set or set but not exported.
---
 bin/cygport.in | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/bin/cygport.in b/bin/cygport.in
index 5fc89eaf..3fe8a52e 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -493,14 +493,32 @@ unset restrict
 
 if [ "${SOURCE_DATE_EPOCH+y}" = "y" ]
 then
-	if [ -n "$(echo "${SOURCE_DATE_EPOCH}" | sed -e 's/^$/X/' -e 's/[0-9]//g')" ]
+	if ! [[ "${SOURCE_DATE_EPOCH}" =~ ^[0-9]+$ ]]
 	then
 		error "SOURCE_DATE_EPOCH must be an integer number (seconds since the unix epoch)"
 	fi
+	if ! _d=$(date --iso-8601=seconds -d "@${SOURCE_DATE_EPOCH}" 2>/dev/null)
+	then
+		error "SOURCE_DATE_EPOCH is out of range"
+	fi
+	if [ "${SOURCE_DATE_EPOCH}" -le "$(printf '%(%s)T')" ]
+	then
+		inform "Reproducible build: SOURCE_DATE_EPOCH='${SOURCE_DATE_EPOCH}' [$_d]"
+	else
+		warning "SOURCE_DATE_EPOCH='${SOURCE_DATE_EPOCH}' [$_d] lies in the future"
+	fi
+	unset _d
+	if [ -z "$(printenv SOURCE_DATE_EPOCH 2>/dev/null)" ]
+	then
+		inform "SOURCE_DATE_EPOCH is not exported to the environment"
+	fi
+
 	case $(peflags --version 2>/dev/null | sed -n '1s/^.* //p') in
 		4.6.[6-9]|4.[7-9]*|[5-9]*) ;;
 		*) error "SOURCE_DATE_EPOCH requires peflags 4.6.6 or later"
 	esac
+else
+	inform "SOURCE_DATE_EPOCH is not set"
 fi
 
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-10 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 12:29 [PATCH cygport] Add more checks of SOURCE_DATE_EPOCH Christian Franke
2024-02-26 19:30 ` Jon Turney
2024-02-26 19:53   ` Christian Franke
2024-03-10 13:50     ` Jon Turney
2024-03-10 15:12       ` Christian Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).