nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 autoreconfHook,
7 gettext,
8 coreutils,
9 updateAutotoolsGnuConfigScriptsHook,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "sharutils";
14 version = "4.15.2";
15
16 src = fetchurl {
17 url = "mirror://gnu/sharutils/sharutils-${finalAttrs.version}.tar.xz";
18 sha256 = "16isapn8f39lnffc3dp4dan05b7x6mnc76v6q5nn8ysxvvvwy19b";
19 };
20
21 hardeningDisable = [ "format" ];
22
23 # GNU Gettext is needed on non-GNU platforms.
24 buildInputs = [
25 autoreconfHook
26 coreutils
27 gettext
28 ];
29 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
30
31 # These tests try to hit /etc/passwd to find out your username if pass in a submitter
32 # name on the command line. Since we block access to /etc/passwd on the Darwin sandbox
33 # that cause shar to just segfault. It isn't a problem on Linux because their sandbox
34 # remaps /etc/passwd to a trivial file, but we can't do that on Darwin so I do this
35 # instead. In this case, I pass in the very imaginative "submitter" as the submitter name
36
37 patches = [
38 # CVE-2018-1000097
39 (fetchurl {
40 url = "https://sources.debian.org/data/main/s/sharutils/1:4.15.2-2+deb9u1/debian/patches/01-fix-heap-buffer-overflow-cve-2018-1000097.patch";
41 sha256 = "19g0sxc8g79aj5gd5idz5409311253jf2q8wqkasf0handdvsbxx";
42 })
43 (fetchurl {
44 url = "https://sources.debian.org/data/main/s/sharutils/1:4.15.2-4/debian/patches/02-fix-ftbfs-with-glibc-2.28.patch";
45 sha256 = "15kpjqnfs98n6irmkh8pw7masr08xala7gx024agv7zv14722vkc";
46 })
47
48 # pending upstream build fix against -fno-common compilers like >=gcc-10
49 # Taken from https://lists.gnu.org/archive/html/bug-gnu-utils/2020-01/msg00002.html
50 (fetchpatch {
51 name = "sharutils-4.15.2-Fix-building-with-GCC-10.patch";
52 url = "https://lists.gnu.org/archive/html/bug-gnu-utils/2020-01/txtDL8i6V6mUU.txt";
53 sha256 = "0kfch1vm45lg237hr6fdv4b2lh5b1933k0fn8yj91gqm58svskvl";
54 })
55 (fetchpatch {
56 name = "sharutils-4.15.2-Do-not-include-lib-md5.c-into-src-shar.c.patch";
57 url = "https://lists.gnu.org/archive/html/bug-gnu-utils/2020-01/txt5Z_KZup0yN.txt";
58 sha256 = "0an8vfy3qj6sss9w0i4j8ilf7g5mbc7y13l644jy5bcm9przcjbd";
59 })
60
61 # various build fixes for >= gcc 15, sourced from
62 # https://lists.gnu.org/archive/html/bug-gnu-utils/2025-03/msg00000.html
63 ./gcc15-stdboolm4-backport.patch
64 ./gcc15-getcwdm4-port.patch
65 ./gcc15-c23-port.patch
66 ];
67
68 postPatch =
69 let
70 # This evaluates to a string containing:
71 #
72 # substituteInPlace tests/shar-2 --replace '${SHAR}' '${SHAR} -s submitter'
73 # substituteInPlace tests/shar-2 --replace '${SHAR}' '${SHAR} -s submitter'
74 shar_sub = "\${SHAR}";
75 in
76 ''
77 substituteInPlace tests/shar-1 --replace '${shar_sub}' '${shar_sub} -s submitter'
78 substituteInPlace tests/shar-2 --replace '${shar_sub}' '${shar_sub} -s submitter'
79
80 substituteInPlace intl/Makefile.in --replace "AR = ar" ""
81 '';
82
83 # Workaround to fix the static build on macOS.
84 env.NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
85
86 doCheck = true;
87
88 meta = {
89 description = "Tools for remote synchronization and `shell archives'";
90 longDescription = ''
91 GNU shar makes so-called shell archives out of many files, preparing
92 them for transmission by electronic mail services. A shell archive
93 is a collection of files that can be unpacked by /bin/sh. A wide
94 range of features provide extensive flexibility in manufacturing
95 shars and in specifying shar smartness. For example, shar may
96 compress files, uuencode binary files, split long files and
97 construct multi-part mailings, ensure correct unsharing order, and
98 provide simplistic checksums.
99
100 GNU unshar scans a set of mail messages looking for the start of
101 shell archives. It will automatically strip off the mail headers
102 and other introductory text. The archive bodies are then unpacked
103 by a copy of the shell. unshar may also process files containing
104 concatenated shell archives.
105 '';
106 homepage = "https://www.gnu.org/software/sharutils/";
107 license = lib.licenses.gpl3Plus;
108 maintainers = [ ];
109 platforms = lib.platforms.all;
110 };
111})