diff --git a/.gitignore b/.gitignore index e2e4991..99bdb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -SOURCES/libpaper_1.1.24+nmu4.tar.gz -/libpaper_1.1.24+nmu4.tar.gz +libpaper-2.1.1.tar.gz diff --git a/gating.yaml b/gating.yaml deleted file mode 100644 index cf5f35b..0000000 --- a/gating.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- !Policy -product_versions: - - rhel-8 -decision_context: osci_compose_gate -rules: - - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} - - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tedude.validation} diff --git a/libpaper-covscan.patch b/libpaper-covscan.patch deleted file mode 100644 index 43d0794..0000000 --- a/libpaper-covscan.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/lib/paper.c b/lib/paper.c -index 57db599..8817aea 100644 ---- a/lib/paper.c -+++ b/lib/paper.c -@@ -211,7 +211,10 @@ PAPERSIZEVAR, fall-back to the old behaviour. - fclose(ps); - - paperstr = malloc((strlen(papername) + 1) * sizeof(char)); -- if (! paperstr) return 0; -+ if (! paperstr) { -+ free(papername); -+ return 0; -+ } - - strcpy(paperstr, papername); - free(papername); diff --git a/libpaper-file-leak.patch b/libpaper-file-leak.patch deleted file mode 100644 index 47b878b..0000000 --- a/libpaper-file-leak.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -up libpaper-1.1.24+nmu5/lib/paper.c.file-leak libpaper-1.1.24+nmu5/lib/paper.c ---- libpaper-1.1.24+nmu5/lib/paper.c.file-leak 2018-03-09 16:21:01.028345956 +0100 -+++ libpaper-1.1.24+nmu5/lib/paper.c 2018-03-09 16:40:57.824279357 +0100 -@@ -140,7 +140,7 @@ char* systempapername(void) { - char* paperstr; - char* paperenv; - const char* paperdef; -- FILE* ps; -+ FILE* ps = NULL; - struct stat statbuf; - const struct paper* pp; - int c; -@@ -224,6 +224,9 @@ PAPERSIZEVAR, fall-back to the old behav - } - } - -+ if (ps) -+ fclose(ps); -+ - paperdef = defaultpapername(); - paperstr = malloc((strlen(paperdef) + 1) * sizeof(char)); - diff --git a/libpaper-useglibcfallback.patch b/libpaper-useglibcfallback.patch deleted file mode 100644 index 1216055..0000000 --- a/libpaper-useglibcfallback.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff -up libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback libpaper-1.1.24+nmu3/lib/paper.c ---- libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback 2010-04-24 08:12:11.000000000 -0400 -+++ libpaper-1.1.24+nmu3/lib/paper.c 2014-04-22 15:58:33.120039001 -0400 -@@ -20,6 +20,9 @@ - - #include - -+#include -+#include -+ - #include "paper.h" - - struct paper { -@@ -108,6 +111,27 @@ in PAPERCONFVAR, fall-back to the old be - } - - const char* defaultpapername(void) { -+#if defined(LC_PAPER) && defined(_GNU_SOURCE) -+ -+#define NL_PAPER_GET(x) \ -+ ((union { char *string; unsigned int word; })nl_langinfo(x)).word -+ -+#define PT_TO_MM(v) (unsigned int)((v * 2.54 * 10 / 72) + 0.5) -+ -+ const struct paper* pp; -+ -+ unsigned int w = NL_PAPER_GET(_NL_PAPER_WIDTH); -+ unsigned int h = NL_PAPER_GET(_NL_PAPER_HEIGHT); -+ -+ for (pp = paperfirst(); pp; pp = papernext(pp)) { -+ if ( -+ PT_TO_MM(pp->pswidth) == w && -+ PT_TO_MM(pp->psheight) == h -+ ) { -+ return pp->name; -+ } -+ } -+#endif - return PAPERSIZE; - } - -diff -up libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback libpaper-1.1.24+nmu3/man/paperconf.1.in ---- libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback 2014-04-22 15:58:33.121038995 -0400 -+++ libpaper-1.1.24+nmu3/man/paperconf.1.in 2014-04-22 16:00:15.973428376 -0400 -@@ -48,10 +48,12 @@ looking in order at the - .B @PAPERSIZEVAR@ - environment variable, at the contents of the file specified by the - .B @PAPERCONFVAR@ --environment variable, at the contents of -+environment variable, at the contents of the file - .B @PAPERCONF@ --or by using --.B letter -+, consulting the values controlled by the -+.B LC_PAPER -+locale setting, or by using -+.B @PAPERSIZE@ - as a fall-back value if none of the other alternatives are successful. - By default, width and height of the paper are printed in PostScript points. - .SH OPTIONS -diff -up libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback libpaper-1.1.24+nmu3/src/paperconf.c ---- libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback 2012-05-03 15:05:12.000000000 -0400 -+++ libpaper-1.1.24+nmu3/src/paperconf.c 2014-04-22 15:58:33.121038995 -0400 -@@ -13,6 +13,7 @@ - #include - - #include -+#include - - - /* needed for GNU/Hurd */ -@@ -99,6 +100,8 @@ int main(int argc, char** argv) - - const char* progname; - -+ setlocale(LC_ALL, ""); -+ - progname = strrchr(*argv, '/'); - if (progname) { - ++progname; diff --git a/libpaper.spec b/libpaper.spec index d21bb65..7156240 100644 --- a/libpaper.spec +++ b/libpaper.spec @@ -1,93 +1,204 @@ -%global nmu +nmu4 - Name: libpaper -Version: 1.1.24 -Release: 22%{?dist} +Version: 2.1.1 +Release: 7%{?dist} +# Needed to replace separate paper package +Epoch: 1 Summary: Library and tools for handling papersize -License: GPLv2 -URL: http://packages.qa.debian.org/libp/libpaper.html -Source0: http://ftp.debian.org/debian/pool/main/libp/libpaper/%{name}_%{version}%{nmu}.tar.gz -# Filed upstream as: -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481213 -Patch2: libpaper-useglibcfallback.patch -# Memory leak -Patch3: libpaper-file-leak.patch -# 1606989 - Please review important issues found by covscan in "libpaper-1.1.24-21.el8+7" package -Patch4: libpaper-covscan.patch +# libpaper is LGPL-2.1+ +# bundled libgnu is LGPL-2.1+, LGPL-2+ and GPL-3+ +# paperspecs is Public Domain +# localepaper.c is FSFAP +License: LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND GPL-3.0-or-later AND LGPL-2.0-or-later AND FSFAP +URL: https://github.com/rrthomas/libpaper/ +Source0: https://github.com/rrthomas/libpaper/archive/v%{version}/%{name}-%{version}.tar.gz +# Pulled from paper +Source1: localepaper.c # gcc is no longer in buildroot by default BuildRequires: gcc -BuildRequires: libtool, gettext, gawk +# use git for autosetup +BuildRequires: git-core +# uses make +BuildRequires: make +BuildRequires: libtool, gettext, gawk, autoconf, automake +BuildRequires: help2man, tar, gnupg2, perl-interpreter + +Provides: bundled(gnulib) %description -The paper library and accompanying files are intended to provide a -simple way for applications to take actions based on a system- or -user-specified paper size. This release is quite minimal, its purpose -being to provide really basic functions (obtaining the system paper name -and getting the height and width of a given kind of paper) that -applications can immediately integrate. +The libpaper package enables users to indicate their preferred paper +size and specifies system-wide and per-user paper size catalogues, which can +also be used directly (see paperspecs(5)). %package devel Summary: Headers/Libraries for developing programs that use libpaper -Requires: %{name} = %{version}-%{release} +Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} %description devel -This package contains headers and libraries that programmers will need +This package contains headers and libraries that programmers will need to develop applications which use libpaper. +%package -n paper +Summary: Print paper size information +Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} +# This is licensed differently from libpaper. +# paper.c is GPL-3.0-or-later +# paperconf.c is GPL 2.0 only +# localepaper.c is FSFAP (except it is missing the warranty disclaimer... but the intent is clear) +License: GPL-3.0-or-later AND FSFAP AND GPL-2.0-only + +%description -n paper +The paper(1) utility can be used to find the user's preferred +default paper size and give information about known sizes. + %prep -%setup -q -n %{name}-%{version}%{nmu} -%patch2 -p1 -b .useglibcfallback -%patch3 -p1 -b .file-leak -%patch4 -p1 -b .covscan -libtoolize +%autosetup -S git +cp %{SOURCE1} src/ + +%if 0 +sed -i 's|gnulib_tool=$gnulib_path/gnulib-tool|gnulib_tool=%{_bindir}/gnulib-tool|g' bootstrap +sed -i 's|./gnulib/gnulib-tool|%{_bindir}/gnulib-tool|g' bootstrap.conf +sed -i '/doc\/INSTALL/d' bootstrap +./bootstrap --gnulib-srcdir=%{_datadir}/gnulib/ --skip-git +%endif %build -touch AUTHORS NEWS -aclocal -autoconf -automake -a %configure --disable-static -# Disable rpath -sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool -sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool -make %{?_smp_mflags} +%make_build + +# localepaper +pushd src +%{__cc} %{optflags} -I.. -Ilibgnu -o localepaper localepaper.c libgnu/.libs/libgnupaper.a %{_hardening_ldflags} +popd + +%check +# No upstream tests +echo "Testing localepaper tool" +locale width height > expected +./src/localepaper | tr ' ' "\n" > got +diff -u expected got +# No real way to test the paper tool %install -make DESTDIR=$RPM_BUILD_ROOT install +%make_install rm $RPM_BUILD_ROOT%{_libdir}/*.la mkdir -p $RPM_BUILD_ROOT%{_sysconfdir} -echo '# Simply write the paper name. See papersize(5) for possible values' > $RPM_BUILD_ROOT%{_sysconfdir}/papersize -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/libpaper.d +# maybe someday the translations will return +%if 0 for i in cs da de es fr gl hu it ja nl pt_BR sv tr uk vi; do mkdir -p $RPM_BUILD_ROOT%{_datadir}/locale/$i/LC_MESSAGES/; msgfmt debian/po/$i.po -o $RPM_BUILD_ROOT%{_datadir}/locale/$i/LC_MESSAGES/%{name}.mo; done %find_lang %{name} +%endif + +mkdir %{buildroot}%{_libexecdir} +install -m0755 src/localepaper %{buildroot}%{_libexecdir} %ldconfig_scriptlets -%files -f %{name}.lang +%files %doc ChangeLog README %license COPYING -%config(noreplace) %{_sysconfdir}/papersize -%dir %{_sysconfdir}/libpaper.d -%{_bindir}/paperconf -%{_libdir}/libpaper.so.1.1.2 -%{_libdir}/libpaper.so.1 -%{_sbindir}/paperconfig -%{_mandir}/man1/* -%{_mandir}/man5/* -%{_mandir}/man8/* +%config(noreplace) %{_sysconfdir}/paperspecs +%{_libdir}/libpaper.so.2* %files devel %{_includedir}/paper.h %{_libdir}/libpaper.so -%{_mandir}/man3/* + +%files -n paper +%{_bindir}/paper +%{_bindir}/paperconf +%{_libexecdir}/localepaper +%{_mandir}/man1/* +%{_mandir}/man5/* %changelog -* Mon Dec 03 2018 Zdenek Dohnal - 1.1.24-22 -- 1606989 - Please review important issues found by covscan in "libpaper-1.1.24-21.el8+7" package +* Tue Oct 29 2024 Troy Dawson - 1:2.1.1-7 +- Bump release for October 2024 mass rebuild: + Resolves: RHEL-64018 + +* Mon Jun 24 2024 Troy Dawson - 1:2.1.1-6 +- Bump release for June 2024 mass rebuild + +* Mon May 13 2024 Zdenek Dohnal - 1:2.1.1-5 +- remove gnulib dependency and use bundled one + +* Tue Apr 23 2024 Zdenek Dohnal - 1:2.1.1-4 +- RHEL-33500 - apply hardening ldflags for localepaper + +* Thu Jan 25 2024 Fedora Release Engineering - 1:2.1.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 1:2.1.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Tue Jul 25 2023 Zdenek Dohnal - 1:2.1.1-1 +- 2.1.1 + +* Thu Jul 20 2023 Fedora Release Engineering - 1:2.1.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Apr 14 2023 Tom Callaway - 1:2.1.0-1 +- update to 2.1.0 + +* Fri Mar 3 2023 Tom Callaway - 1:2.0.10-1 +- update to 2.0.10 + +* Thu Feb 23 2023 Tom Callaway - 1:2.0.9-1 +- update to 2.0.9 + +* Tue Feb 14 2023 Tom Callaway - 1:2.0.8-1 +- update to 2.0.8 + +* Thu Jan 19 2023 Fedora Release Engineering - 1:2.0.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Mon Jan 9 2023 Tom Callaway - 2.0.4-2 +- move /etc/paperspecs to libpaper to ensure proper functionality in cases where paper subpackage + is not installed +- fix Requires to include epoch + +* Sun Jan 8 2023 Tom Callaway - 2.0.4-1 +- update to 2.0.4 + +* Thu Jul 21 2022 Fedora Release Engineering - 1.1.28-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 1.1.28-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Fedora Release Engineering - 1.1.28-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Jan 26 2021 Fedora Release Engineering - 1.1.28-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Thu Nov 05 2020 Zdenek Dohnal - 1.1.28-1 +- 1.1.28 + +* Tue Jul 28 2020 Fedora Release Engineering - 1.1.24-28 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jul 13 2020 Tom Stellard - 1.1.24-27 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + +* Wed Jan 29 2020 Fedora Release Engineering - 1.1.24-26 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 1.1.24-25 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 1.1.24-24 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Mon Dec 03 2018 Zdenek Dohnal - 1.1.24-23 +- fixing covscan issue - memory leak + +* Fri Jul 13 2018 Fedora Release Engineering - 1.1.24-22 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild * Fri Mar 09 2018 Zdenek Dohnal - 1.1.24-21 - remove nmu5 from .gitignore and sources diff --git a/localepaper.c b/localepaper.c new file mode 100644 index 0000000..78404a3 --- /dev/null +++ b/localepaper.c @@ -0,0 +1,44 @@ +/* + * localepaper: print the dimensions in mm of the current locale's + * paper size, if possible. + * + * Based on a patch by Caolan McNamara: + * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481213 + * + * Copyright (C) Reuben Thomas , 2013. + * + * Copying and distribution of this file, with or without modification, + * are permitted in any medium without royalty provided the copyright + * notice and this notice are preserved. + */ + +#include + +#include +#include +#include +#if defined LC_PAPER && defined _GNU_SOURCE +#include +#endif + +#include "progname.h" + +int main(int argc, char *argv[]) +{ + set_program_name(argv[0]); + argc = argc; /* Avoid a compiler warning. */ + +#if defined LC_PAPER && defined _GNU_SOURCE + setlocale(LC_ALL, ""); + +#define NL_PAPER_GET(x) \ + ((union { char *string; unsigned word; })nl_langinfo(x)).word + + printf("%d %d\n", NL_PAPER_GET(_NL_PAPER_WIDTH), NL_PAPER_GET(_NL_PAPER_HEIGHT)); + return EXIT_SUCCESS; + +#else + printf("%s: locale paper size information is not supported on this system", program_name); + return EXIT_FAILURE; +#endif +} diff --git a/sources b/sources index 8485681..6aabe27 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (libpaper_1.1.24+nmu4.tar.gz) = 4412139ffab7b9658f186a825c7d4ae3ba397ff32852a66decccef7b74647dd365573b9f00145fe2fa95dd16e30c280a8aeeac90a14006ed140f5b85e2f0e508 +SHA512 (libpaper-2.1.1.tar.gz) = 90fabb586115d99c9fb4d4ecee87ac0d1b2ac17ddf0c89287eb82e21834b0a2bc7cd5049fb73f3e20e4b494c374413c388b28c3274ceb278ce81928e17fde288