From f882d6ddff0493b7965c6bdff66c2fc680847f45 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 18 Feb 2021 14:11:51 +0000 Subject: [PATCH] rust: Add SPDX-License-Identifier and validate it in ci/codestyle.sh It turns out we accidentally added GPL'd code into the Rust side, which wasn't intentional on my part and I think it's since been copied around. Honestly I think half of the problem is the gigantic "blah blah blah GNU General blah blah" just makes people's eyes glaze over. In contrast the `SPDX-License-Identifier` is short and obvious. So let's validate that in CI. This follows a similar change in ostree: https://github.com/ostreedev/ostree/pull/1439 If we merge this I'll do the C/C++ side too after that. --- build.rs | 1 + ci/codestyle.sh | 10 ++++++++++ rust/libdnf-sys/build.rs | 1 + rust/rpmostree-client/src/lib.rs | 1 + rust/rpmostree-client/tests/parse.rs | 1 + rust/src/client.rs | 1 + rust/src/cliwrap.rs | 20 ++------------------ rust/src/cliwrap/cliutil.rs | 1 + rust/src/cliwrap/dracut.rs | 1 + rust/src/cliwrap/grubby.rs | 1 + rust/src/cliwrap/rpm.rs | 1 + rust/src/core.rs | 1 + rust/src/countme.rs | 21 ++------------------- rust/src/countme/cookie.rs | 20 ++------------------ rust/src/countme/repo.rs | 19 ++----------------- rust/src/cxxrsutil.rs | 1 + rust/src/fedora_integration.rs | 1 + rust/src/history.rs | 20 ++------------------ rust/src/includes.rs | 1 + rust/src/initramfs.rs | 1 + rust/src/main.rs | 1 + rust/src/nameservice/group.rs | 1 + rust/src/nameservice/mod.rs | 2 +- rust/src/nameservice/passwd.rs | 1 + rust/src/ostree_utils.rs | 2 ++ rust/src/passwd.rs | 1 + 26 files changed, 41 insertions(+), 91 deletions(-) diff --git a/build.rs b/build.rs index 762a3b6b..404d0c6e 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; fn detect_fedora_feature() -> Result<()> { diff --git a/ci/codestyle.sh b/ci/codestyle.sh index 05574c83..ddc00898 100755 --- a/ci/codestyle.sh +++ b/ci/codestyle.sh @@ -21,3 +21,13 @@ for crate in $(find -iname Cargo.toml); do fi done echo "ok" + +ident='SPDX-License-Identifier:' +echo -n "checking \"$ident\"..." +git ls-files '*.rs' | while read f; do + if ! grep -qF "$ident" $f; then + echo "error: File $f: Missing $ident" 1>&2 + exit 1 + fi +done +echo "ok" diff --git a/rust/libdnf-sys/build.rs b/rust/libdnf-sys/build.rs index 3cc46121..43f61a35 100644 --- a/rust/libdnf-sys/build.rs +++ b/rust/libdnf-sys/build.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; fn main() -> Result<()> { diff --git a/rust/rpmostree-client/src/lib.rs b/rust/rpmostree-client/src/lib.rs index fdf678b7..f73e968f 100644 --- a/rust/rpmostree-client/src/lib.rs +++ b/rust/rpmostree-client/src/lib.rs @@ -1,4 +1,5 @@ //! APIs for interacting with rpm-ostree client side. +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Context; use serde_derive::Deserialize; diff --git a/rust/rpmostree-client/tests/parse.rs b/rust/rpmostree-client/tests/parse.rs index d6c70ffa..e4aa76e2 100644 --- a/rust/rpmostree-client/tests/parse.rs +++ b/rust/rpmostree-client/tests/parse.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; use rpmostree_client; diff --git a/rust/src/client.rs b/rust/src/client.rs index ee5276a2..8dabede4 100644 --- a/rust/src/client.rs +++ b/rust/src/client.rs @@ -1,5 +1,6 @@ //! Helpers for the client side binary that will speak DBus //! to rpm-ostreed.service. +// SPDX-License-Identifier: Apache-2.0 OR MIT use crate::cxxrsutil::*; use crate::utils; diff --git a/rust/src/cliwrap.rs b/rust/src/cliwrap.rs index 89f6c9dc..eafdea03 100644 --- a/rust/src/cliwrap.rs +++ b/rust/src/cliwrap.rs @@ -1,24 +1,8 @@ -/* - * Copyright (C) 2019 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - //! Implements the `cliwrap` treefile option which intercepts/proxies //! other binaries like `/usr/bin/rpm`. +// SPDX-License-Identifier: GPL-2.0-or-later +// (FIXME: I think I really meant this to be Apache-2.0 OR MIT) use anyhow::{anyhow, Result}; use std::io::prelude::*; use std::path; diff --git a/rust/src/cliwrap/cliutil.rs b/rust/src/cliwrap/cliutil.rs index 76adf9f2..5eefdfd6 100644 --- a/rust/src/cliwrap/cliutil.rs +++ b/rust/src/cliwrap/cliutil.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; use nix::sys::statvfs; use std::os::unix::process::CommandExt; diff --git a/rust/src/cliwrap/dracut.rs b/rust/src/cliwrap/dracut.rs index 2faa28cd..3604af0b 100644 --- a/rust/src/cliwrap/dracut.rs +++ b/rust/src/cliwrap/dracut.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; use crate::cliwrap::cliutil; diff --git a/rust/src/cliwrap/grubby.rs b/rust/src/cliwrap/grubby.rs index e88b5964..50d24456 100644 --- a/rust/src/cliwrap/grubby.rs +++ b/rust/src/cliwrap/grubby.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; /// Primary entrypoint to running our wrapped `grubby` handling. diff --git a/rust/src/cliwrap/rpm.rs b/rust/src/cliwrap/rpm.rs index f87730ec..189b9390 100644 --- a/rust/src/cliwrap/rpm.rs +++ b/rust/src/cliwrap/rpm.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; use clap::{App, Arg}; diff --git a/rust/src/core.rs b/rust/src/core.rs index e9f7d747..746d507b 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -1,6 +1,7 @@ //! Code mirroring rpmostree-core.cxx which is the shared "core" //! binding of rpm and ostree, used by both client-side layering/overrides //! and server side composes. +// SPDX-License-Identifier: Apache-2.0 OR MIT use crate::cxxrsutil::CxxResult; use crate::ffiutil; diff --git a/rust/src/countme.rs b/rust/src/countme.rs index afb837f0..a22bc1fc 100644 --- a/rust/src/countme.rs +++ b/rust/src/countme.rs @@ -1,23 +1,6 @@ -/* - * Copyright (C) 2020 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - //! Implementation of the "DNF Count Me" system. - +// SPDX-License-Identifier: GPL-2.0-or-later +// (FIXME: Convert to Apache-2.0 OR MIT for consistency?) use anyhow::{bail, Context, Result}; use curl::easy::Easy; use os_release::OsRelease; diff --git a/rust/src/countme/cookie.rs b/rust/src/countme/cookie.rs index 8f6e341c..03cc1ae1 100644 --- a/rust/src/countme/cookie.rs +++ b/rust/src/countme/cookie.rs @@ -1,21 +1,5 @@ -/* - * Copyright (C) 2020 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - +// SPDX-License-Identifier: GPL-2.0-or-later +// (FIXME: Convert to Apache-2.0 OR MIT for consistency?) use anyhow::{bail, Result}; use chrono::prelude::*; use openat_ext::OpenatDirExt; diff --git a/rust/src/countme/repo.rs b/rust/src/countme/repo.rs index 414c5b16..0f962290 100644 --- a/rust/src/countme/repo.rs +++ b/rust/src/countme/repo.rs @@ -1,20 +1,5 @@ -/* - * Copyright (C) 2020 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +// SPDX-License-Identifier: GPL-2.0-or-later +// (FIXME: Convert to Apache-2.0 OR MIT for consistency?) use anyhow::{Context, Result}; use std::fs; diff --git a/rust/src/cxxrsutil.rs b/rust/src/cxxrsutil.rs index 2c370dc9..17023e21 100644 --- a/rust/src/cxxrsutil.rs +++ b/rust/src/cxxrsutil.rs @@ -7,6 +7,7 @@ //! the *_sys type (e.g. ostree_sys::OstreeRepo) but the `ostree::Repo` type. //! So for now, we define a `FFIGObjectWrapper` trait that helps with this. //! In the future though hopefully cxx.rs improves this situation. +// SPDX-License-Identifier: Apache-2.0 OR MIT use cxx::{type_id, ExternType}; use glib::translate::ToGlibPtr; diff --git a/rust/src/fedora_integration.rs b/rust/src/fedora_integration.rs index ebbc34fc..36590d54 100644 --- a/rust/src/fedora_integration.rs +++ b/rust/src/fedora_integration.rs @@ -1,4 +1,5 @@ //! APIs used to talk to Fedora Infrastructure tooling (Koji, Bodhi). +// SPDX-License-Identifier: Apache-2.0 OR MIT use crate::cxxrsutil::CxxResult; use anyhow::{Context, Result}; diff --git a/rust/src/history.rs b/rust/src/history.rs index c301c3d0..a8c39585 100644 --- a/rust/src/history.rs +++ b/rust/src/history.rs @@ -1,21 +1,3 @@ -/* - * Copyright (C) 2019 Jonathan Lebon - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - //! High-level interface to retrieve host rpm-ostree history. //! //! The basic idea is that at deployment creation time, the upgrader does two @@ -49,6 +31,8 @@ //! than scanning the whole journal upfront. This can then be e.g. piped through //! a pager, stopped after N entries, etc... +// SPDX-License-Identifier: GPL-2.0-or-later +// (FIXME: Convert to Apache-2.0 OR MIT for consistency?) use crate::cxxrsutil::*; use crate::ffi::HistoryEntry; use anyhow::{anyhow, Context, Result}; diff --git a/rust/src/includes.rs b/rust/src/includes.rs index a52f5ead..49cf5b3e 100644 --- a/rust/src/includes.rs +++ b/rust/src/includes.rs @@ -7,6 +7,7 @@ strings more efficient). NOTICE: The C header definitions are canonical, please update those first then synchronize the entries here. !*/ +// SPDX-License-Identifier: Apache-2.0 OR MIT use libdnf_sys::DnfPackage; diff --git a/rust/src/initramfs.rs b/rust/src/initramfs.rs index 60420543..55a3aaf4 100644 --- a/rust/src/initramfs.rs +++ b/rust/src/initramfs.rs @@ -1,4 +1,5 @@ //! Generate an "overlay" initramfs image +// SPDX-License-Identifier: Apache-2.0 OR MIT use crate::cxxrsutil::*; use anyhow::{Context, Result}; diff --git a/rust/src/main.rs b/rust/src/main.rs index a40c6440..6e07636c 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,4 +1,5 @@ //! The main CLI logic. +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::Result; diff --git a/rust/src/nameservice/group.rs b/rust/src/nameservice/group.rs index 300a7690..d71e8203 100644 --- a/rust/src/nameservice/group.rs +++ b/rust/src/nameservice/group.rs @@ -1,4 +1,5 @@ //! Helpers for [user passwd file](https://man7.org/linux/man-pages/man5/passwd.5.html). +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::{anyhow, Context, Result}; use std::io::{BufRead, Write}; diff --git a/rust/src/nameservice/mod.rs b/rust/src/nameservice/mod.rs index ac91bcc2..65f6387f 100644 --- a/rust/src/nameservice/mod.rs +++ b/rust/src/nameservice/mod.rs @@ -1,5 +1,5 @@ //! Linux name-service information helpers. - +// SPDX-License-Identifier: Apache-2.0 OR MIT // TODO(lucab): consider moving this to its own crate. pub(crate) mod group; diff --git a/rust/src/nameservice/passwd.rs b/rust/src/nameservice/passwd.rs index 2f9bb285..e2628dff 100644 --- a/rust/src/nameservice/passwd.rs +++ b/rust/src/nameservice/passwd.rs @@ -1,4 +1,5 @@ //! Helpers for [user group file](https://man7.org/linux/man-pages/man5/group.5.html). +// SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow::{anyhow, Context, Result}; use std::io::{BufRead, Write}; diff --git a/rust/src/ostree_utils.rs b/rust/src/ostree_utils.rs index e16ee643..aaaf394a 100644 --- a/rust/src/ostree_utils.rs +++ b/rust/src/ostree_utils.rs @@ -1,4 +1,6 @@ //! Utility helpers or workarounds for incorrectly bound things in ostree-rs +// SPDX-License-Identifier: Apache-2.0 OR MIT + use glib::translate::*; use std::ptr; diff --git a/rust/src/passwd.rs b/rust/src/passwd.rs index 7ff27bd0..f8c3bb8c 100644 --- a/rust/src/passwd.rs +++ b/rust/src/passwd.rs @@ -1,5 +1,6 @@ //! APIs for interacting with `/etc/passwd` and `/etc/group`, including //! handling the "nss-altfiles" split into `/usr/lib/{passwd,group}`. +// SPDX-License-Identifier: Apache-2.0 OR MIT use crate::cxxrsutil::{self, FFIGObjectWrapper}; use crate::ffiutil;