git.iko.soy/typeable/nixpkgs
on master help sign in
_7zz: correct license (#163999)

* _7zz: correct license and remove p7zip dependency The code under Compress/Rar* is licensed under a specific unRAR license Also Compress/LzfseDecoder.cpp is covered by BSD3 The unRAR code is removed from the `.tar.xz` since the license posits you agree or remove the code from your hard drive This adds some complexity to updating 7zz so there is also an update script Meta has been updated and tweaked Source is now downloaded from sourceforge in the `.tar.xz` version to avoid depending on p7zip * _7zz: add notice of the license updates and optional unRAR licenced code

commitc12cec8bc39c3c1153a42032a03a83d149d1e2ac authorj-k <dev@j-k.io> dateFri 18 Mar 2022, 04:47 (5 years ago) parent056ce43
4 files changed+109−7
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+6 nixos/doc/manual/release-notes/rl-2205.section.md+2 pkgs/tools/archivers/7zz/default.nix+51−7 pkgs/tools/archivers/7zz/update.sh+50
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+6
@@ -760,6 +760,12 @@
760760 unmaintained
761761 </para>
762762 </listitem>
763+ <listitem>
764+ <para>
765+ <literal>pkgs._7zz</literal> is now correctly licensed as
766+ LGPL3+ and BSD3 with optional unfree unRAR licensed code
767+ </para>
768+ </listitem>
763769 <listitem>
764770 <para>
765771 <literal>tilp2</literal> was removed together with its module
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -304,6 +304,8 @@ In addition to numerous new and upgraded packages, this release has the followin
304304
305305- `pkgs.docbookrx` was removed since it's unmaintained
306306
307+- `pkgs._7zz` is now correctly licensed as LGPL3+ and BSD3 with optional unfree unRAR licensed code
308+
307309- `tilp2` was removed together with its module
308310
309311- The F-PROT antivirus (`fprot` package) and its service module were removed because it
pkgs/tools/archivers/7zz/default.nix+51−7
@@ -1,4 +1,14 @@
1−{ stdenv, lib, fetchurl, p7zip, uasm, useUasm ? stdenv.isx86_64 }:
1+{ stdenv
2+, lib
3+, fetchurl
4+
5+, uasm
6+, useUasm ? stdenv.isx86_64
7+
8+ # RAR code is under non-free unRAR license
9+ # see the meta.license section below for more details
10+, enableUnfree ? false
11+}:
212
313let
414 inherit (stdenv.hostPlatform) system;
@@ -14,17 +24,38 @@ stdenv.mkDerivation rec {
1424 version = "21.07";
1525
1626 src = fetchurl {
17− url = "https://7-zip.org/a/7z${lib.replaceStrings [ "." ] [ "" ] version}-src.7z";
18− sha256 = "sha256-0QdNVvQVqrmdmeWXp7ZtxFXbpjSa6KTInfdkdbahKEw=";
27+ url = "https://7-zip.org/a/7z${lib.replaceStrings [ "." ] [ "" ] version}-src.tar.xz";
28+ sha256 = {
29+ free = "sha256-SMM6kQ6AZ05s4miJjMoE4NnsXQ0tlkdWx0q2HKjhaM8=";
30+ unfree = "sha256-IT1ZRAfLjvy6NmELFSykkh7aFBYzELQ5A9E+aDE+Hjk=";
31+ }.${if enableUnfree then "unfree" else "free"};
32+ downloadToTemp = (!enableUnfree);
33+ # remove the unRAR related code from the src drv
34+ # > the license requires that you agree to these use restrictions,
35+ # > or you must remove the software (source and binary) from your hard disks
36+ # https://fedoraproject.org/wiki/Licensing:Unrar
37+ postFetch = lib.optionalString (!enableUnfree) ''
38+ mkdir tmp
39+ tar xf $downloadedFile -C ./tmp
40+ rm -r ./tmp/CPP/7zip/Compress/Rar*
41+ tar cfJ $out -C ./tmp . \
42+ --sort=name \
43+ --mtime="@$SOURCE_DATE_EPOCH" \
44+ --owner=0 --group=0 --numeric-owner \
45+ --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
46+ '';
1947 };
2048
2149 sourceRoot = "CPP/7zip/Bundles/Alone2";
2250
23− makeFlags = lib.optionals useUasm [ "MY_ASM=uasm" ];
51+ makeFlags =
52+ lib.optionals useUasm [ "MY_ASM=uasm" ] ++
53+ # it's the compression code with the restriction, see DOC/License.txt
54+ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ];
2455
2556 makefile = "../../cmpl_gcc${platformSuffix}.mak";
2657
27− nativeBuildInputs = [ p7zip ] ++ lib.optionals useUasm [ uasm ];
58+ nativeBuildInputs = lib.optionals useUasm [ uasm ];
2859
2960 enableParallelBuilding = true;
3061
@@ -40,14 +71,27 @@ stdenv.mkDerivation rec {
4071 doInstallCheck = true;
4172
4273 installCheckPhase = ''
74+ runHook preInstallCheck
75+
4376 $out/bin/7zz --help | grep ${version}
77+
78+ runHook postInstallCheck
4479 '';
4580
81+ passthru.updateScript = ./update.sh;
82+
4683 meta = with lib; {
4784 description = "Command line archiver utility";
4885 homepage = "https://7-zip.org";
49− license = licenses.lgpl21Plus;
50− maintainers = with maintainers; [ anna328p peterhoeg ];
86+ license = with licenses;
87+ # 7zip code is largely lgpl2Plus
88+ # CPP/7zip/Compress/LzfseDecoder.cpp is bsd3
89+ [ lgpl2Plus /* and */ bsd3 ] ++
90+ # and CPP/7zip/Compress/Rar* are unfree with the unRAR license restriction
91+ # the unRAR compression code is disabled by default
92+ lib.optionals enableUnfree [ unfree ];
93+ maintainers = with maintainers; [ anna328p peterhoeg jk ];
5194 platforms = platforms.linux;
95+ mainProgram = "7zz";
5296 };
5397}
pkgs/tools/archivers/7zz/update.shnew file+50
@@ -0,0 +1,50 @@
1+#! /usr/bin/env nix-shell
2+#! nix-shell -i bash -p coreutils gnused curl jq
3+set -euo pipefail
4+cd "$(dirname "${BASH_SOURCE[0]}")"
5+
6+DRV_DIR="$PWD"
7+
8+OLD_VERSION="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
9+
10+NEW_VERSION="$(curl "https://sourceforge.net/projects/sevenzip/best_release.json" | jq '.platform_releases.linux.filename' -r | cut -d/ -f3)"
11+
12+echo "comparing versions $OLD_VERSION => $NEW_VERSION"
13+if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
14+ echo "Already up to date! Doing nothing"
15+ exit 0
16+fi
17+
18+NIXPKGS_ROOT="$(realpath "$DRV_DIR/../../../..")"
19+
20+echo "getting free source hash"
21+OLD_FREE_HASH="$(nix-instantiate --eval --strict -E "with import $NIXPKGS_ROOT {}; _7zz.src.drvAttrs.outputHash" | tr -d '"')"
22+echo "getting unfree source hash"
23+OLD_UNFREE_HASH="$(nix-instantiate --eval --strict -E "with import $NIXPKGS_ROOT {}; (_7zz.override { enableUnfree = true; }).src.drvAttrs.outputHash" | tr -d '"')"
24+
25+NEW_VERSION_FORMATTED="$(echo "$NEW_VERSION" | tr -d '.')"
26+URL="https://7-zip.org/a/7z${NEW_VERSION_FORMATTED}-src.tar.xz"
27+
28+
29+NEW_FREE_HASH=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "_7zz.src" --url "$URL")
30+
31+NEW_UNFREE_OUT=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "(_7zz.override { enableUnfree = true; }).src" --url "$URL" --output raw --print-path)
32+# first line of raw output is the hash
33+NEW_UNFREE_HASH="$(echo "$NEW_UNFREE_OUT" | sed -n 1p)"
34+# second line of raw output is the src path
35+NEW_UNFREE_SRC="$(echo "$NEW_UNFREE_OUT" | sed -n 2p)"
36+# make sure to nuke the unfree src from the updater's machine
37+# > the license requires that you agree to these use restrictions, or you must remove the software (source and binary) from your hard disks
38+# https://fedoraproject.org/wiki/Licensing:Unrar
39+nix-store --delete "$NEW_UNFREE_SRC"
40+
41+
42+echo "updating version"
43+sed -i "s/version = \"$OLD_VERSION\";/version = \"$NEW_VERSION\";/" "$DRV_DIR/default.nix"
44+
45+echo "updating free hash"
46+sed -i "s@free = \"$OLD_FREE_HASH\";@free = \"$NEW_FREE_HASH\";@" "$DRV_DIR/default.nix"
47+echo "updating unfree hash"
48+sed -i "s@unfree = \"$OLD_UNFREE_HASH\";@unfree = \"$NEW_UNFREE_HASH\";@" "$DRV_DIR/default.nix"
49+
50+echo "done"