1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

scdoc: 1.5.2 -> 1.6.0

This commit is contained in:
Michael Weiss 2018-11-19 12:06:54 +01:00
parent 47b677e216
commit b53a60087d
2 changed files with 2 additions and 79 deletions

View file

@ -2,15 +2,13 @@
stdenv.mkDerivation rec {
name = "scdoc-${version}";
version = "1.5.2";
version = "1.6.0";
src = fetchurl {
url = "https://git.sr.ht/~sircmpwn/scdoc/archive/${version}.tar.gz";
sha256 = "0a9sxifzsbj24kjnpc0525i91ni2vkwizhgvwx1m9shvfkiisnc6";
sha256 = "1ca3js4arkg28gg2iszxxyrq7kgsrz482d1szv5dfd471h3vr5m3";
};
patches = [ ./use-source-date-epoch.patch ];
postPatch = ''
substituteInPlace Makefile \
--replace "-static" "" \

View file

@ -1,75 +0,0 @@
diff --git a/src/main.c b/src/main.c
index 14b08d2..e2cc33e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#define __USE_XOPEN
#include <time.h>
#include <unistd.h>
#include "string.h"
@@ -66,10 +67,17 @@ static void parse_preamble(struct parser *p) {
int section = -1;
uint32_t ch;
char date[256];
- time_t now;
- time(&now);
- struct tm *now_tm = localtime(&now);
- strftime(date, sizeof(date), "%F", now_tm);
+ char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch != NULL) {
+ struct tm source_date_epoch_tm;
+ strptime(source_date_epoch, "%s", &source_date_epoch_tm);
+ strftime(date, sizeof(date), "%F", &source_date_epoch_tm);
+ } else {
+ time_t now;
+ time(&now);
+ struct tm *now_tm = localtime(&now);
+ strftime(date, sizeof(date), "%F", now_tm);
+ }
while ((ch = parser_getch(p)) != UTF8_INVALID) {
if ((ch < 0x80 && isalnum(ch)) || ch == '_' || ch == '-' || ch == '.') {
assert(str_append_ch(name, ch) != -1);
diff --git a/test/preamble b/test/preamble
index 03e2d0c..eeb734b 100755
--- a/test/preamble
+++ b/test/preamble
@@ -38,31 +38,31 @@ EOF
end 0
begin "Writes the appropriate header"
-scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date +'%F')"'"' >/dev/null
+scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date +'%F' --date=@${SOURCE_DATE_EPOCH:-$(date +'%s')})"'"' >/dev/null
test(8)
EOF
end 0
begin "Preserves dashes"
-scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'"' >/dev/null
+scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F' --date=@${SOURCE_DATE_EPOCH:-$(date +'%s')})"'"' >/dev/null
test-manual(8)
EOF
end 0
begin "Handles extra footer field"
-scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "Footer"' >/dev/null
+scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F' --date=@${SOURCE_DATE_EPOCH:-$(date +'%s')})"'" "Footer"' >/dev/null
test-manual(8) "Footer"
EOF
end 0
begin "Handles both extra fields"
-scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "Footer" "Header"' >/dev/null
+scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F' --date=@${SOURCE_DATE_EPOCH:-$(date +'%s')})"'" "Footer" "Header"' >/dev/null
test-manual(8) "Footer" "Header"
EOF
end 0
begin "Emits empty footer correctly"
-scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "" "Header"' >/dev/null
+scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F' --date=@${SOURCE_DATE_EPOCH:-$(date +'%s')})"'" "" "Header"' >/dev/null
test-manual(8) "" "Header"
EOF
end 0