From: Dodji Seketeli <dodji@redhat.com>
To: Dodji Seketeli <dodji@redhat.com>
Cc: libabigail@sourceware.org,
Benjamin Kosnik <b.dekosnik@gmail.com>,
Ben Woodard <woodard@redhat.com>, Chenxiong Qi <cqi@redhat.com>,
Giuliano Procida <gprocida@google.com>,
Jan Engelhardt <jengelh@inai.de>, Jessica Yu <jeyu@kernel.org>,
Jonathan Wakely <jwakely@redhat.com>,
Mark Wielaard <mark@klomp.org>,
Matthias Klose <doko@debian.org>,
Matthias Maennich <maennich@google.com>,
Ondrej Oprala <ondrej.oprala@gmail.com>,
Roland McGrath <roland@hack.frob.com>,
Sinny Kumari <skumari@redhat.com>,
Slava Barinov <v.barinov@samsung.com>
Subject: [PATCH 4/9, final act] Add replace-spdx-license.sh script
Date: Wed, 02 Dec 2020 13:25:50 +0100 [thread overview]
Message-ID: <877dq04coh.fsf@redhat.com> (raw)
In-Reply-To: <87o8jc4cv8.fsf@redhat.com> (Dodji Seketeli's message of "Wed, 02 Dec 2020 13:21:47 +0100")
This script is to replace an SPDX license ID by another one.
I.e, it's to perform an actual re-licensing of a given file.
A way to use the script is this:
replace-spdx-license.sh --from LGPL-3.0-or-later \
--to "Apache-2.0 WITH LLVM-exception" \
some-file-to-relicense.cc
* relicensing-scripts/replace-spdx-license.sh: New script.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Applied to the master branch.
---
relicensing-scripts/replace-spdx-license.sh | 75 +++++++++++++++++++++
1 file changed, 75 insertions(+)
create mode 100755 relicensing-scripts/replace-spdx-license.sh
diff --git a/relicensing-scripts/replace-spdx-license.sh b/relicensing-scripts/replace-spdx-license.sh
new file mode 100755
index 00000000..f6345283
--- /dev/null
+++ b/relicensing-scripts/replace-spdx-license.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+# Author: Dodji Seketeli <dodji@redhat.com>
+
+from_license_id=
+to_license_id=
+input_file=
+prog=$0
+
+display_usage()
+{
+ echo "$prog: [options] --from <from-spdx-license-id> --to <to-spdx-license-id> <file>"
+ echo " where options can be:"
+ echo " -h|--h display this help"
+}
+
+main()
+{
+ header=$(head --lines=5 $input_file | grep "SPDX-License-Identifier:")
+ if test "x$header" != x; then
+ license=$(echo "$header" | sed -r "s/^.*(SPDX-License-Identifier:)[ ]*([^*/]+).*$/\2/")
+ fi
+
+ if test "x$license" != x -a "$license" = "$from_license_id"; then
+ sed -i -r "s/$from_license_id/$to_license_id/" $input_file
+ exit 0
+ fi
+
+ exit 1
+}
+
+# This program takes at least 5 arguments
+if test $# -lt 5; then
+ >&2 display_usage
+ exit 1
+fi
+
+# Parse parameters
+while test $# -gt 1; do
+ case "$1" in
+ -h|--h)
+ display_usage
+ exit 0
+ ;;
+
+ -f|--from)
+ from_license_id=$2
+ shift
+ ;;
+
+ -t|--to)
+ to_license_id=$2
+ shift
+ ;;
+
+ -*)
+ >&2 display_usage
+ exit 1
+ ;;
+
+ *)
+ input_file="$1"
+ ;;
+ esac
+ shift
+done
+
+if test $# -lt 1; then
+ >&2 display_usage
+ exit 1
+fi
+
+input_file=$1
+
+main
--
2.29.2
--
Dodji
next prev parent reply other threads:[~2020-12-02 12:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 12:21 [PATCH 0/9, final act] Relicensing Libabigail to Apache 2.0 + LLVM Exception Dodji Seketeli
2020-12-02 12:23 ` [PATCH 1/9, final act] Replace individual license references with SPDX Identifiers Dodji Seketeli
2020-12-02 12:24 ` [PATCH 2/9, final act] Add missing SPDX headers to source files not specifying any license Dodji Seketeli
2020-12-02 12:25 ` [PATCH 3/9, final act] Add has-spdx-header.sh script Dodji Seketeli
2020-12-02 12:25 ` Dodji Seketeli [this message]
2020-12-02 12:26 ` [PATCH 5/9, final act] Add helper files to perform the re-licensing Dodji Seketeli
2020-12-02 12:27 ` [PATCH 6/9, final act] Re-license the project to Apache v2 With LLVM Exception Dodji Seketeli
2020-12-02 12:27 ` [PATCH 7/9, final act] Add the LICENSE.txt file Dodji Seketeli
2020-12-02 12:28 ` [PATCH 8/9, final act] Delete COPYING* files Dodji Seketeli
2020-12-02 12:29 ` [PATCH 9/9, final act] Add a license-change-2020.txt file Dodji Seketeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877dq04coh.fsf@redhat.com \
--to=dodji@redhat.com \
--cc=b.dekosnik@gmail.com \
--cc=cqi@redhat.com \
--cc=doko@debian.org \
--cc=gprocida@google.com \
--cc=jengelh@inai.de \
--cc=jeyu@kernel.org \
--cc=jwakely@redhat.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
--cc=mark@klomp.org \
--cc=ondrej.oprala@gmail.com \
--cc=roland@hack.frob.com \
--cc=skumari@redhat.com \
--cc=v.barinov@samsung.com \
--cc=woodard@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).