From 9615ad6216528bb437c2050b7aa291c651df12b3bd6872aee46f83372181b380 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 10 Mar 2023 08:19:23 +0000 Subject: [PATCH] Accepting request 1070588 from home:StefanBruens:branches:Publishing OBS-URL: https://build.opensuse.org/request/show/1070588 OBS-URL: https://build.opensuse.org/package/show/Publishing/transfig?expand=0&rev=83 --- ...and-CreationDate-in-PDF-reproducible.patch | 123 ++++++++++++++++ transfig.changes | 17 +++ transfig.spec | 136 +++++++++--------- 3 files changed, 205 insertions(+), 71 deletions(-) create mode 100644 0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch diff --git a/0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch b/0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch new file mode 100644 index 0000000..16d0116 --- /dev/null +++ b/0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch @@ -0,0 +1,123 @@ +From e72a9d017742366cba636d783ea121279bfb7d6c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Stefan=20Br=C3=BCns?= +Date: Thu, 9 Mar 2023 19:19:51 +0100 +Subject: [PATCH] Make ModDate and CreationDate in PDF reproducible + +Ghostscript ignores the date in the preamble and uses the current +time instead. This notably breaks the SOURCE_DATE_EPOCH support +for reproducible builds. + +Passing the creation time as DOCINFO pdfmark forces gs to use the +specified date/time. Although ghostscript still adds the unreproducible +DocumentUUID and trailer ID, it is sufficient when including the PDF +figure with pdflatex. + +Reuse the SOURCE_DATE_EPOCH code from creation_date for determining +the wanted timestamp, and return the formatted time via the new +`creation_date_pdfmark` function. +--- + fig2dev/creationdate.c | 38 +++++++++++++++++++++++++++++++++----- + fig2dev/creationdate.h | 1 + + fig2dev/dev/genps.c | 8 ++++++++ + 3 files changed, 42 insertions(+), 5 deletions(-) + +diff --git a/fig2dev/creationdate.c b/fig2dev/creationdate.c +index a51bfd4..de914a5 100644 +--- a/fig2dev/creationdate.c ++++ b/fig2dev/creationdate.c +@@ -36,8 +36,8 @@ + #include "creationdate.h" + + +-int +-creation_date(char *buf) ++static struct tm* ++parse_time() + { + time_t now; + +@@ -70,15 +70,43 @@ creation_date(char *buf) + } else { + /* no errors, epoch is valid */ + now = epoch; +- strftime(buf, CREATION_TIME_LEN, "%F %H:%M:%S", gmtime(&now)); +- return true; ++ return gmtime(&now); + } + } + #endif + + /* fall trough on errors or !source_date_epoch */ + time(&now); +- if (strftime(buf, CREATION_TIME_LEN, "%F %H:%M:%S", localtime(&now))) ++ return localtime(&now); ++} ++ ++static struct tm* ++get_time() ++{ ++ static struct tm time = { 0 }; ++ static int initialized = 0; ++ if (!initialized) { ++ time = *parse_time(); ++ initialized = 1; ++ } ++ return &time; ++} ++ ++int ++creation_date(char *buf) ++{ ++ if (strftime(buf, CREATION_TIME_LEN, "%F %H:%M:%S", get_time())) ++ return true; ++ else ++ return false; ++} ++ ++int ++creation_date_pdfmark(char *buf) ++{ ++ // Pdfmark format should be D:YYYYMMDDHHmmSSOHH’mm’. ++ // Timezone offset (O...) may be omitted ++ if (strftime(buf, CREATION_TIME_LEN, "D:%Y%m%d%H%M%S", get_time())) + return true; + else + return false; +diff --git a/fig2dev/creationdate.h b/fig2dev/creationdate.h +index 048508a..199d985 100644 +--- a/fig2dev/creationdate.h ++++ b/fig2dev/creationdate.h +@@ -21,3 +21,4 @@ + + #define CREATION_TIME_LEN 36 + extern int creation_date(char *buf); ++extern int creation_date_pdfmark(char *buf); +diff --git a/fig2dev/dev/genps.c b/fig2dev/dev/genps.c +index 5bea35c..48e05a6 100644 +--- a/fig2dev/dev/genps.c ++++ b/fig2dev/dev/genps.c +@@ -1181,6 +1181,7 @@ genps_end(void) + const int h = pageheight, w = pagewidth; + int epslen, tiflen; + struct stat fstat; ++ char date_buf[CREATION_TIME_LEN]; + + /* for multipage, translate and output objects for each page */ + if (multi_page) { +@@ -1368,6 +1369,13 @@ genps_end(void) + /* final DSC comment for eps output (EOF = end of document) */ + fputs("%EOF\n", tfp); + ++ if (pdfflag) { ++ if (creation_date_pdfmark(date_buf)) ++ fprintf(tfp, ++ "[ /ModDate (%s)\n /CreationDate (%s)\n /DOCINFO pdfmark\n", ++ date_buf, date_buf); ++ } ++ + /* all ok */ + return 0; + } +-- +2.39.2 + diff --git a/transfig.changes b/transfig.changes index 26f7436..d7ede82 100644 --- a/transfig.changes +++ b/transfig.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Thu Mar 9 19:39:39 UTC 2023 - Stefan Brüns + +- Make PDF output via ghostscript (for large parts) reproducible, + add 0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch + +------------------------------------------------------------------- +Thu Mar 9 17:02:41 UTC 2023 - Stefan Brüns + +- Fix fig2mpdf documentation: + * rerun latex to get references right. + * uudecode images for html documentation. +- Clean up spec file, remove parts for EOLed SLE 11. +- Depend on texlive-epstopdf only if texlive is installed. +- Use weak dependency on ghostscript, vector output formats + like EPS, PS and SVG do not depend on it. + ------------------------------------------------------------------- Wed Oct 6 10:45:30 UTC 2021 - Dr. Werner Fink diff --git a/transfig.spec b/transfig.spec index 26069bf..3d50896 100644 --- a/transfig.spec +++ b/transfig.spec @@ -1,7 +1,7 @@ # # spec file for package transfig # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,52 +17,14 @@ Name: transfig -BuildRequires: fdupes -BuildRequires: libjpeg-devel -BuildRequires: netpbm -BuildRequires: texlive-latex -%if %suse_version > 1220 -BuildRequires: texlive-amsfonts -BuildRequires: texlive-cm-super -BuildRequires: texlive-courier -BuildRequires: texlive-dvips -%if 0%{?suse_version} > 1315 -BuildRequires: texlive-epstopdf -%endif -BuildRequires: texlive-pdftex -BuildRequires: texlive-times -BuildRequires: tex(beamer.cls) -%if 0%{?suse_version} > 1315 -BuildRequires: tex(german.sty) -%endif -BuildRequires: tex(multimedia.sty) -BuildRequires: tex(times.sty) -BuildRequires: tex(xmpmulti.sty) -%endif -BuildRequires: libpng-devel -%if 0%{?suse_version} > 1310 -BuildRequires: pkgconfig(xpm) -%else -BuildRequires: xorg-x11-libXpm-devel -BuildRequires: xz -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%endif -# www.xfig.org is dead -URL: http://mcj.sourceforge.net/ -Provides: fig2dev -Provides: transfig.3.2.3d -Requires: ghostscript-fonts-std -Requires: ghostscript-library -Requires: netpbm -%if 0%{?suse_version} > 1315 -Requires: texlive-epstopdf -%endif Version: 3.2.8b Release: 0 Summary: Graphic Converter -#Source: http://sourceforge.net/projects/mcj/files/fig2dev-%{version}.tar.xz/download#/fig2dev-%{version}.tar.xz +# www.xfig.org is dead +URL: https://mcj.sourceforge.net/ License: MIT Group: Productivity/Graphics/Convertors +#Source: http://sourceforge.net/projects/mcj/files/fig2dev-%%{version}.tar.xz/download#/fig2dev-%%{version}.tar.xz Source: fig2dev-%{version}.tar.xz Patch0: transfig-3.2.8.dif Patch1: 1b09a8.patch @@ -70,6 +32,37 @@ Patch4: transfig-fix-afl.patch Patch43: fig2dev-3.2.6-fig2mpdf.patch Patch44: fig2dev-3.2.6-fig2mpdf-doc.patch Patch45: fig2dev-3.2.6a-RGBFILE.patch +Patch46: 0001-Make-ModDate-and-CreationDate-in-PDF-reproducible.patch +BuildRequires: fdupes +BuildRequires: libjpeg-devel +BuildRequires: libpng-devel +BuildRequires: netpbm +BuildRequires: sharutils +#!BuildIgnore: texlive-tex4ht +BuildRequires: texlive-courier +BuildRequires: texlive-latex +%if 0%{?suse_version} > 1315 +BuildRequires: texlive-epstopdf +%endif +BuildRequires: texlive-pdftex +BuildRequires: texlive-times +BuildRequires: tex(8r.enc) +BuildRequires: tex(beamer.cls) +%if 0%{?suse_version} > 1315 +BuildRequires: tex(german.sty) +%endif +BuildRequires: pkgconfig(xpm) +BuildRequires: tex(multimedia.sty) +BuildRequires: tex(times.sty) +BuildRequires: tex(xmpmulti.sty) +Provides: fig2dev +Recommends: ghostscript-fonts-std +Recommends: ghostscript-library +Requires: netpbm +Recommends: texlive-epstopdf +%if 0%{?suse_version} > 1315 +Requires: (texlive-epstopdf if texlive-latex) +%endif %description TransFig is a set of tools for creating TeX documents with graphics @@ -81,27 +74,16 @@ which generates a Makefile which translates Fig code to various graphics description languages using the fig2dev program. In previous releases, this command was implemented as a shell script. -Documentation: man transfig - - - -Authors: --------- - Anthony Starks - George Ferguson - Herbert Bauer - Micah Beck - Supoj Sutantavibul - %prep %setup -q -n fig2dev-%{version} -find -type f | xargs -r chmod a-x,go-w +find -type f -exec chmod a-x,go-w '{}' \; %patch0 -p0 -b .0 %patch1 -p0 -b .1 %patch4 -p1 -b .afl %patch43 -p1 -b .mpdf %patch44 -p1 -b .mpdfdoc %patch45 -p1 -b .p45 +%patch46 -p1 -b .pdfmark %build ulimit -v unlimited || : @@ -155,32 +137,44 @@ chmod 755 configure --docdir=%{_defaultdocdir}/%{name} \ --enable-transfig \ --enable-scale-pic2t2e -make %{?_smp_mflags} CCOPTIONS="$CFLAGS" +%make_build CCOPTIONS="$CFLAGS" + +pushd transfig/doc + ../../fig2dev/fig2dev -L latex trans.fig > trans.tex + pdflatex -draft manual.tex + pdflatex -draft manual.tex + pdflatex manual.tex +popd + +pushd fig2mpdf/doc +%if 0%{?suse_version} > 1315 + make + while $(grep -q -i 'rerunfilecheck.*warning' sample-presentation.log); do + pdflatex sample-presentation + done +%endif + mkdir htmlimg + (cd htmlimg; uudecode ../*.uue) +popd %install -find -name '*.mpdfdoc' -o -name '*.mpdf' | xargs -r rm -vf -make DESTDIR=%{buildroot} install +#find -name '*.mpdfdoc' -o -name '*.mpdf' | xargs -r rm -vf +%make_install install -m 0755 fig2mpdf/fig2mpdf %{buildroot}%{_bindir} install -m 0644 fig2mpdf/fig2mpdf.1 %{buildroot}%{_mandir}/man1/ -gzip -9 %{buildroot}%{_mandir}/man1/fig2mpdf.1 mkdir -p %{buildroot}%{_defaultdocdir}/%{name} install -m 0644 [CLNR]* %{buildroot}%{_defaultdocdir}/%{name} -%if 0%{?suse_version} > 1315 +install -m 0644 transfig/doc/manual.pdf %{buildroot}%{_defaultdocdir}/%{name}/transfig.pdf + pushd fig2mpdf/doc - make mkdir %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf - rm -f overlay-sample-?.pdf - rm -f *.aux *.log *.nav *.out *.snm *.toc - install -m 0644 * %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf/ -popd + install -m 0644 *.{html,css,lfig} %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf/ + install -m 0644 htmlimg/*.{jpg,gif,pdf} %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf/ + install -m 0644 sample-presentation.tex Makefile %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf/ +%if 0%{?suse_version} > 1315 + install -m 0644 sample-presentation.pdf %{buildroot}%{_defaultdocdir}/%{name}/fig2mpdf/ %endif -pushd transfig/doc - ../../fig2dev/fig2dev -L latex trans.fig > trans.tex - pdflatex manual.tex - pdflatex manual.tex - pdflatex manual.tex - install -m 0644 manual.pdf %{buildroot}%{_defaultdocdir}/%{name}/transfig.pdf popd %fdupes %{buildroot}