From 8be55fe6ebd1a51c37838c2e61fb12802c0acced Mon Sep 17 00:00:00 2001 From: Psy-Fer Date: Wed, 14 Oct 2026 18:52:47 +1100 Subject: [PATCH] Third-party notices for ported code, in source and in what we shipThird-party notices for ported code and linked crates, in source and in what we ship --- .dockerignore | 1 - .github/workflows/ci.yml | 12 ++ .github/workflows/release.yml | 27 +++ .gitignore | 1 + CHANGELOG.md | 19 ++ Cargo.toml | 2 +- Dockerfile | 11 ++ LICENSES/DEGNORM_LICENSE | 10 + LICENSES/LIBCXX_LICENSE | 311 ++++++++++++++++++++++++++++++++ LICENSES/README.md | 24 ++- LICENSES/SGT_LICENSE | 41 +++++ README.md | 6 +- about.hbs | 30 +++ about.toml | 76 ++++++++ scripts/third-party-licenses.sh | 56 ++++++ src/solo/libcxx_rng.rs | 5 + src/solo/sgt.rs | 36 +++- tests/data/cr4_opal_oracle.cpp | 3 +- 18 files changed, 662 insertions(+), 9 deletions(-) create mode 100644 LICENSES/DEGNORM_LICENSE create mode 100644 LICENSES/LIBCXX_LICENSE create mode 100644 LICENSES/SGT_LICENSE create mode 100644 about.hbs create mode 100644 about.toml create mode 100755 scripts/third-party-licenses.sh diff --git a/.dockerignore b/.dockerignore index f61b20cc..1a1f021f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,5 @@ test/ tests/ docs/ *.md -LICENSE .gitignore .dockerignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bd63982..f0adbf2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,6 +121,17 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + # The release ships THIRD_PARTY_LICENSES.md; generating it here catches a + # dependency with an unaccepted licence, or a changed licence file, on the PR + # that introduces it rather than on release day. + licenses: + name: Third-party licences + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1 + - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable + - run: scripts/third-party-licenses.sh + # Check that all tests defined above pass. This makes it easy to set a single "required" test in branch # protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why. check: @@ -132,6 +143,7 @@ jobs: - clippy - msrv - audit + - licenses runs-on: ubuntu-latest steps: - uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # ratchet:re-actors/alls-green@v1.3.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88aacae1..569ad941 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,8 +83,26 @@ jobs: # ------------------------------------------------------------------ # 1. Build binaries for each target (always, to catch breakage) # ------------------------------------------------------------------ + # The licence notices of every crate linked into the binaries, generated + # once (they are the same on every platform: cargo-about lists the crates of + # all targets) and shipped in each archive. + third-party-licenses: + name: Third-party licences + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1 + - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable + - name: Generate THIRD_PARTY_LICENSES.md + run: scripts/third-party-licenses.sh + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # ratchet:actions/upload-artifact@v7.0.1 + with: + name: third-party-licenses + path: THIRD_PARTY_LICENSES.md + retention-days: 1 + build-binaries: name: Build ${{ matrix.name }} + needs: [third-party-licenses] runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -211,6 +229,11 @@ jobs: env: TARGET_CPU: ${{ matrix.target_cpu || '' }} + - name: Download third-party licences + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # ratchet:actions/download-artifact@v8.0.1 + with: + name: third-party-licenses + - name: Package id: package shell: bash @@ -222,6 +245,10 @@ jobs: mkdir -p "staging/${ARCHIVE}" cp "target/${{ matrix.target }}/release/${BIN}${EXT}" "staging/${ARCHIVE}/" cp README.md LICENSE "staging/${ARCHIVE}/" 2>/dev/null || true + # Third-party notices, which their licences require in binary + # distributions too: code ported into our source (LICENSES/) and + # the crates linked into the binary (THIRD_PARTY_LICENSES.md). + cp -R LICENSES THIRD_PARTY_LICENSES.md "staging/${ARCHIVE}/" cd staging tar czf "../${ARCHIVE}.tar.gz" "${ARCHIVE}" diff --git a/.gitignore b/.gitignore index 042ce739..d0146956 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ TODO.md # macOS Finder metadata .DS_Store +THIRD_PARTY_LICENSES.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 200160ff..b3fa6e5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,25 @@ Sections commonly used: Features, Bug fixes, Other changes. ### Other changes +- Third-party notices completed. `LICENSES/` gains the licences of code + ported from DegNorm (MIT) and David Elworthy's `sgt.h` via STAR (BSD + 2-clause), and of libc++ (Apache 2.0 with LLVM Exceptions), whose random + number behaviour `libcxx_rng.rs` reimplements; the files name them; `src/solo/sgt.rs` carries Elworthy's full notice, as his + licence requires of source copies. The release archives and the Docker + image now include `LICENSES/` (and the image `LICENSE`), since the notices + of STAR and the others are required in binary distributions too. The + crate's declared licence is now `MIT AND BSD-2-Clause`, since + `src/solo/sgt.rs` is a port of BSD 2-clause code. + + The release archives and the Docker image also ship + `THIRD_PARTY_LICENSES.md`, the licence notices of every crate linked into + the binary (including the C libraries libdeflate and mimalloc that two of + them compile in), generated by `scripts/third-party-licenses.sh` with a + pinned, checksum-verified `cargo-about`. Only permissive licences are + accepted (`about.toml`); a CI job runs the same generation, so a + dependency under any other licence, or a changed licence file, fails on + the pull request that brings it in. + - ruzstd 0.9.0 → 0.9.1 for RUSTSEC-2026-0344 (a small zstd input could exhaust memory). Only builds with the optional `zstd` or `compressed-input` feature contain ruzstd; the default build does not. diff --git a/Cargo.toml b/Cargo.toml index f92ff2b8..3d70e555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" rust-version = "1.89" authors = ["James Ferguson"] description = "A Rust reimplementation of STAR (Spliced Transcripts Alignment to a Reference), the RNA-seq aligner" -license = "MIT" +license = "MIT AND BSD-2-Clause" repository = "https://github.com/scverse/rustar-aligner" readme = "README.md" keywords = ["bioinformatics", "rna-seq", "aligner", "sequencing", "star"] diff --git a/Dockerfile b/Dockerfile index ce3b7d2d..73f3f83f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,12 @@ RUN HOST_TRIPLE=$(rustc -vV | awk '/^host:/ {print $2}') && \ && strip "target/$HOST_TRIPLE/release/rustar-aligner" \ && cp "target/$HOST_TRIPLE/release/rustar-aligner" /rustar-aligner +# Licence notices of every crate linked into the binary (see about.toml). +COPY scripts/third-party-licenses.sh scripts/ +COPY about.toml about.hbs LICENSE ./ +COPY LICENSES/ LICENSES/ +RUN scripts/third-party-licenses.sh /THIRD_PARTY_LICENSES.md + # ---- Runtime stage ---- FROM debian:bookworm-slim @@ -29,5 +35,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY --from=builder /rustar-aligner /usr/local/bin/rustar-aligner COPY --from=builder /rustar-aligner /usr/local/bin/STAR +# rustar-aligner's licence and the third-party notices required in binary +# distributions: ported code (LICENSES/) and linked crates. +COPY LICENSE /usr/share/doc/rustar-aligner/LICENSE +COPY LICENSES/ /usr/share/doc/rustar-aligner/LICENSES/ +COPY --from=builder /THIRD_PARTY_LICENSES.md /usr/share/doc/rustar-aligner/THIRD_PARTY_LICENSES.md CMD ["rustar-aligner"] diff --git a/LICENSES/DEGNORM_LICENSE b/LICENSES/DEGNORM_LICENSE new file mode 100644 index 00000000..cbca36de --- /dev/null +++ b/LICENSES/DEGNORM_LICENSE @@ -0,0 +1,10 @@ +MIT +Copyright (c) 2018 Northwestern Statistical Bioinformatics Lab + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/LIBCXX_LICENSE b/LICENSES/LIBCXX_LICENSE new file mode 100644 index 00000000..e159d283 --- /dev/null +++ b/LICENSES/LIBCXX_LICENSE @@ -0,0 +1,311 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libc++ library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/LICENSES/README.md b/LICENSES/README.md index 8afa7ce3..1ee3011e 100644 --- a/LICENSES/README.md +++ b/LICENSES/README.md @@ -6,4 +6,26 @@ The LICENSE of this repo has been chosen to also be MIT to match that of the STA (Copyright (c) 2026 Benjamin Demaille), included for attribution of modules ported from STAR-rs into rustar-aligner. STAR-rs is dual-licensed `MIT OR Apache-2.0`; the ported code is taken under its MIT option, which is compatible with this repo's MIT -license. See `docs-old/dev/porting-from-star-rs.md` for the porting conventions. \ No newline at end of file +license. See `docs-old/dev/porting-from-star-rs.md` for the porting conventions. + +Other third-party code ported into rustar-aligner, each under a licence compatible with MIT: + +- `DEGNORM_LICENSE`: [DegNorm](https://github.com/NUStatBioinfo/DegNorm) (MIT, + Copyright (c) 2018 Northwestern Statistical Bioinformatics Lab). `src/degnorm/` is a Rust + port of its `degnorm/nmf.py` and the gene selection in `degnorm/__main__.py`. +- `SGT_LICENSE`: David Elworthy's Simple Good-Turing estimator `sgt.h` (BSD 2-clause, + Copyright (c) David Elworthy 2004), which STAR vendors in `source/SimpleGoodTuring/`. + `src/solo/sgt.rs` is a Rust port of it. Elworthy's code adapts Geoffrey Sampson's + Simple Good-Turing program (University of Sussex), which Sampson issued for any use; + it is acknowledged here as he asks. +- `LIBCXX_LICENSE`: libc++ from the [LLVM Project](https://llvm.org) (Apache License 2.0 + with LLVM Exceptions). `src/solo/libcxx_rng.rs` reimplements in Rust the behaviour of + libc++'s `std::mt19937`, `std::generate_canonical` and `std::discrete_distribution`, which + STAR's EmptyDrops_CR draws from, so that the Monte-Carlo draws match STAR's bit for bit. + Included for attribution. + + +These cover code ported into rustar-aligner's own source. The licences of the Rust crates +linked into the binaries (and the C libraries some of them compile in) are collected at +build time into `THIRD_PARTY_LICENSES.md`, shipped in the release archives and the Docker +image; generate it locally with `scripts/third-party-licenses.sh`. diff --git a/LICENSES/SGT_LICENSE b/LICENSES/SGT_LICENSE new file mode 100644 index 00000000..59050491 --- /dev/null +++ b/LICENSES/SGT_LICENSE @@ -0,0 +1,41 @@ +Simple Good-Turing estimation (sgt.h), as vendored in STAR 2.7.11b at +source/SimpleGoodTuring/sgt.h. Notice reproduced verbatim: + +Simple Good-Turing estimation + +Copyright (c) David Elworthy 2004. + +A class for implementing simple Good-Turing re-estimation, as described by +Geoff Sampson in the book Empirical Linguistics (2001), and on the web at +http://www.grsampson.net/RGoodTur.html. The code here is a C++ adaptation +of the published code by Sampson and Gale, with the bug fix issued in +2000. It is encapsulated as a class to allow it to be incorporated into +other programs. An additional coding change is that the data can be +presented in any order, whereas the original code required the data to be +in ascending order. + +Copyright (c) David Elworthy 2004. +All rights reserved. + +Redistribution and use in source and binary forms for any purpose, with or +without modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 8b2e0703..d7788a5d 100644 --- a/README.md +++ b/README.md @@ -265,4 +265,8 @@ The majority of rustar-aligner's code was written by [Claude Code](https://claud ## License -MIT (matching the original STAR license) +MIT (matching the original STAR license). Code ported from STAR, STAR-rs, DegNorm and +David Elworthy's `sgt.h` stays under its own licence, and libc++ is credited for the +random-number behaviour STARsolo's EmptyDrops_CR depends on; all of these notices are in +[`LICENSES/`](LICENSES/). The licences of the crates linked into the binaries ship with +them as `THIRD_PARTY_LICENSES.md` (`scripts/third-party-licenses.sh`). diff --git a/about.hbs b/about.hbs new file mode 100644 index 00000000..fe4b1438 --- /dev/null +++ b/about.hbs @@ -0,0 +1,30 @@ +# Third-party licences + +rustar-aligner's binaries are built from the Rust crates listed below. Each +crate's licence text follows, as those licences require. Code ported into +rustar-aligner's own source tree (from STAR, STAR-rs, DegNorm and `sgt.h`) is +covered separately, in `LICENSES/`. + +Generated by cargo-about from `Cargo.lock`; do not edit by hand. + +## Overview + +{{#each overview}} +- {{{name}}}: {{count}} +{{/each}} + +{{#each licenses}} +--- + +## {{{name}}} + +Used by: +{{#each used_by}} +- {{crate.name}} {{crate.version}}{{#if crate.repository}} ({{crate.repository}}){{/if}} +{{/each}} + +``` +{{{text}}} +``` + +{{/each}} diff --git a/about.toml b/about.toml new file mode 100644 index 00000000..b1bd2943 --- /dev/null +++ b/about.toml @@ -0,0 +1,76 @@ +# cargo-about configuration: generates THIRD_PARTY_LICENSES.md, the licence +# notices of every crate linked into rustar-aligner, for the release archives +# and the Docker image (`.github/workflows/release.yml`, `Dockerfile`). +# +# Only these licences are accepted; a dependency under any other licence makes +# the generation (and so the release) fail until it is reviewed. +accepted = [ + "MIT", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "ISC", + "Unicode-3.0", + "Unicode-DFS-2016", + "Unlicense", + "Zlib", +] +# Build scripts, proc-macro helpers' build deps and test-only crates are not +# linked into the binary. +ignore-build-dependencies = true +ignore-dev-dependencies = true + +# Crates whose full licence terms cargo-about cannot find on its own. Each +# entry pins the file by checksum: if a dependency bump changes it, generation +# fails, so the new text is reviewed rather than silently dropped. + +# rustar-aligner itself: MIT, plus David Elworthy's BSD 2-clause notice for +# `src/solo/sgt.rs` (the rest of `LICENSES/` ships alongside this file). +[rustar-aligner.clarify] +license = "MIT AND BSD-2-Clause" + +[[rustar-aligner.clarify.files]] +path = "LICENSE" +license = "MIT" +checksum = "f9dc772e78386b6f578f34855ca4a3d8e792fe929dd92eafe999ac92f143f138" + +[[rustar-aligner.clarify.files]] +path = "LICENSES/SGT_LICENSE" +license = "BSD-2-Clause" +checksum = "bdd557cd4f246cd0f562bdb6c5c69109bdb9c4f1cbdabb726393a40eb254caae" + +# libdeflate-sys compiles in the libdeflate C library, whose MIT notice +# (Eric Biggers, Google) is in `libdeflate/COPYING`, not the crate root. +[libdeflate-sys.clarify] +license = "Apache-2.0 AND MIT" + +[[libdeflate-sys.clarify.files]] +path = "LICENSE" +license = "Apache-2.0" +checksum = "a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2" + +[[libdeflate-sys.clarify.files]] +path = "libdeflate/COPYING" +license = "MIT" +checksum = "4ad69099cb4374836fd27583d9991e2838cd86b6e4666ab26b2d32582c91e73a" + +# regex-syntax embeds Unicode data tables under the Unicode data licence +# (`src/unicode_tables/LICENSE-UNICODE`). +[regex-syntax.clarify] +license = "(MIT OR Apache-2.0) AND Unicode-DFS-2016" + +[[regex-syntax.clarify.files]] +path = "LICENSE-MIT" +license = "MIT" +checksum = "6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb" + +[[regex-syntax.clarify.files]] +path = "LICENSE-APACHE" +license = "Apache-2.0" +checksum = "a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2" + +[[regex-syntax.clarify.files]] +path = "src/unicode_tables/LICENSE-UNICODE" +license = "Unicode-DFS-2016" +checksum = "74db5baf44a41b1000312c673544b3374e4198af5605c7f9080a402cec42cfa3" diff --git a/scripts/third-party-licenses.sh b/scripts/third-party-licenses.sh new file mode 100755 index 00000000..5162aed0 --- /dev/null +++ b/scripts/third-party-licenses.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# Generate THIRD_PARTY_LICENSES.md: the licence notices of every crate linked +# into rustar-aligner, which the release archives and the Docker image ship +# (their licences require the notices in binary copies too). +# +# Usage: scripts/third-party-licenses.sh [OUTPUT] (default THIRD_PARTY_LICENSES.md) +# +# Downloads a pinned cargo-about release, checks its SHA-256, and runs it with +# the repo's about.toml / about.hbs. Linux x86_64 and aarch64 only (the CI, +# release and Docker builders). Fails if a dependency's licence is not in +# about.toml's accepted list, or a clarified licence file has changed. +set -euo pipefail + +VERSION="0.9.2" +OUTPUT="${1:-THIRD_PARTY_LICENSES.md}" + +case "$(uname -m)" in + x86_64) + ARCH="x86_64" + SHA256="9099a59e820c38a68b9d65f300662a567d56562f9a10f6aa4c7e86c17c2566af" + ;; + aarch64 | arm64) + ARCH="aarch64" + SHA256="af5169282fb6f84e13471493f405437e43ac517744c9ae12fbe2cdf0a6f0e5a8" + ;; + *) + echo "third-party-licenses: unsupported architecture $(uname -m)" >&2 + exit 1 + ;; +esac + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +TMP="$(mktemp -d)" +trap 'rm -r "$TMP"' EXIT + +NAME="cargo-about-${VERSION}-${ARCH}-unknown-linux-musl" +curl -sSfL -o "$TMP/$NAME.tar.gz" \ + "https://github.com/EmbarkStudios/cargo-about/releases/download/${VERSION}/${NAME}.tar.gz" +echo "${SHA256} $TMP/$NAME.tar.gz" | sha256sum -c --quiet - +tar xzf "$TMP/$NAME.tar.gz" -C "$TMP" + +cd "$ROOT" +# cargo-about only warns when a clarified licence file no longer matches its +# checksum, and then drops that clarification (and with it the notice) from +# the output. A clean run logs nothing, so treat any warning as a failure. +"$TMP/$NAME/cargo-about" generate --locked --fail about.hbs -o "$OUTPUT" 2> "$TMP/log" || { + cat "$TMP/log" >&2 + exit 1 +} +if grep -qiE "warn|error" "$TMP/log"; then + cat "$TMP/log" >&2 + echo "third-party-licenses: cargo-about warned; refusing an incomplete notice file" >&2 + rm -f "$OUTPUT" + exit 1 +fi +echo "third-party-licenses: wrote $OUTPUT" diff --git a/src/solo/libcxx_rng.rs b/src/solo/libcxx_rng.rs index f6c0a155..a028a376 100644 --- a/src/solo/libcxx_rng.rs +++ b/src/solo/libcxx_rng.rs @@ -1,6 +1,11 @@ //! Bit-exact ports of the three libc++ random facilities STARsolo's //! `EmptyDrops_CR` depends on. //! +//! This file reimplements in Rust the behaviour of libc++'s `std::mt19937`, +//! `std::generate_canonical` and `std::discrete_distribution`. libc++ is part of +//! the LLVM Project, under the Apache License v2.0 with LLVM Exceptions; its +//! licence is reproduced in `LICENSES/LIBCXX_LICENSE` for attribution. +//! //! STAR's Monte-Carlo rescue draws from `std::mt19937`, converts to doubles //! with `std::generate_canonical`, and samples categories with //! `std::discrete_distribution`. All three are implementation-defined in the diff --git a/src/solo/sgt.rs b/src/solo/sgt.rs index d8f3f140..a0a3d3a5 100644 --- a/src/solo/sgt.rs +++ b/src/solo/sgt.rs @@ -1,8 +1,36 @@ -//! Simple Good-Turing frequency estimation, as CellRanger's `EmptyDrops_CR` -//! and STAR's port of it use for the ambient profile. +//! Simple Good-Turing frequency estimation, as STARsolo's `EmptyDrops_CR` +//! uses for the ambient profile. //! -//! Gadsby & Sampson's method by way of David Elworthy's C implementation -//! (`SimpleGoodTuring/sgt.h`), which is what STAR vendors. +//! Sampson and Gale's method by way of David Elworthy's C++ implementation +//! (`SimpleGoodTuring/sgt.h`), which is what STAR vendors. This module is a +//! Rust port of that file, used under its licence (also in +//! `LICENSES/SGT_LICENSE`): +//! +//! > Copyright (c) David Elworthy 2004. +//! > All rights reserved. +//! > +//! > Redistribution and use in source and binary forms for any purpose, with or +//! > without modification, are permitted provided that the following conditions +//! > are met: +//! > +//! > 1. Redistributions of source code must retain the above copyright notice, +//! > this list of conditions, and the following disclaimer. +//! > +//! > 2. Redistributions in binary form must reproduce the above copyright +//! > notice, this list of conditions, and the disclaimer that follows +//! > these conditions in the documentation and/or other materials +//! > provided with the distribution. +//! > +//! > THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +//! > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +//! > MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +//! > NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +//! > SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +//! > TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +//! > PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +//! > LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +//! > NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +//! > SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //! //! The problem it solves: the ambient profile is estimated from the counts in //! empty droplets, and a gene seen zero times there is not a gene with zero diff --git a/tests/data/cr4_opal_oracle.cpp b/tests/data/cr4_opal_oracle.cpp index 08c41cc4..ceac6226 100644 --- a/tests/data/cr4_opal_oracle.cpp +++ b/tests/data/cr4_opal_oracle.cpp @@ -6,7 +6,8 @@ // STAR's clip gate. The TSV it prints is the committed expected output for // rustar-aligner's `cr4_tso_matches_star_opal_oracle` test. // -// Regenerate (needs a STAR checkout for opal.cpp — MIT, (c) Alexander Dobin): +// Regenerate (needs a STAR checkout for its vendored Opal, source/opal/ — +// MIT, (c) 2014 Martin Sosic; not copied here, only linked at build time): // // OPAL=/path/to/STAR/source/opal // g++ -O2 -std=c++11 -I"$OPAL" tests/data/cr4_opal_oracle.cpp "$OPAL/opal.cpp" \