From patchwork Wed Dec 2 12:25:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41261 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7857E395B059; Wed, 2 Dec 2020 12:25:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7857E395B059 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606911958; bh=jg9OfkEL4an7JsJ5bF6K+d9YUyZupVB/gR35mm97+Wg=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Hpbc0dt0o5ePmpJU1tCiKHVSICqSDozKcCf/iNDZ86Q8jYU+UYNLHccC8D5Oes/z/ 4i/ugpCs63+dOdQRitzkxCJmHl9kzfYfoHDupZrcBPKVKDlXqS0gIcguLHzqzp0rNn GwheMxSKoxKOecwz9uqqA01zt8t/CDcviwabburQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id D3527395B059 for ; Wed, 2 Dec 2020 12:25:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D3527395B059 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-UDBhVeSmNlGgDJgxIsGN-Q-1; Wed, 02 Dec 2020 07:25:53 -0500 X-MC-Unique: UDBhVeSmNlGgDJgxIsGN-Q-1 Received: by mail-wr1-f71.google.com with SMTP id z13so3776795wrm.19 for ; Wed, 02 Dec 2020 04:25:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version; bh=jg9OfkEL4an7JsJ5bF6K+d9YUyZupVB/gR35mm97+Wg=; b=FRYAoQmFXDhaEP6LcuILOUk17yVOf3I6kOj+APzuvdWbhLh/Jr3c9HmXRRa1pUly0h rYwychQ/nFrn2q6OZqbyTPLHxnTCQr4v/JrceLiIYAyoyA6YMazhNEgq/aBQMYie9dhD cHF3wgkESHmx47mKmEcCeJ283mr0GUp0XK8vAGbRDsiIr1ud1tLiKk/JqhRiP/RDL8Bo 5LneLRz8kopg0GmHyd+3xQg+NGrc5Ul9qCnjzcNCns+mUFJijb3FMLovoy7/wMLKiQ9f p8ts5YXGnfIQL4Tu4f7Lt0iZ4x0zVJEcBifGxLaeruNfFwqbFGstby+BDpechHm2r2v0 EtNw== X-Gm-Message-State: AOAM533Kf8BYWwD3Lh1BwCnXAa8El2Mq6FQdTICp4XAJIbwXiE/+Rqz7 Fvppwpb1l3clsS3GA74lWZbZ+qQu3jgkN6+e2SOosu9Ow6IRFPKC1YoezW9cvYxHJuu2Skwo2UN rw0NBwL6aM2xGZJnFWu/h X-Received: by 2002:adf:f607:: with SMTP id t7mr3120513wrp.169.1606911952513; Wed, 02 Dec 2020 04:25:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzBgfSdHsjJ5O8u1jI+4iZWnLS+jqxFIxukFJnG5L4jnnTRR9I5P1dOKKI5KvxgTIhwoXI8A== X-Received: by 2002:adf:f607:: with SMTP id t7mr3120488wrp.169.1606911952291; Wed, 02 Dec 2020 04:25:52 -0800 (PST) Received: from localhost (91-166-131-65.subs.proxad.net. [91.166.131.65]) by smtp.gmail.com with ESMTPSA id f17sm1896893wmh.10.2020.12.02.04.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 04:25:51 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id A70DE581CE5; Wed, 2 Dec 2020 13:25:50 +0100 (CET) To: Dodji Seketeli Subject: [PATCH 4/9, final act] Add replace-spdx-license.sh script Organization: Red Hat / France References: <87o8jc4cv8.fsf@redhat.com> X-Operating-System: Fedora 34 X-URL: http://www.redhat.com Date: Wed, 02 Dec 2020 13:25:50 +0100 In-Reply-To: <87o8jc4cv8.fsf@redhat.com> (Dodji Seketeli's message of "Wed, 02 Dec 2020 13:21:47 +0100") Message-ID: <877dq04coh.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Cc: Matthias Klose , Roland McGrath , Mark Wielaard , Matthias Maennich , Slava Barinov , Ondrej Oprala , Jan Engelhardt , Jonathan Wakely , libabigail@sourceware.org, Benjamin Kosnik Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" 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 Signed-off-by: Ben Woodard Signed-off-by: Chenxiong Qi Signed-off-by: Dodji Seketeli Signed-off-by: Giuliano Procida Signed-off-by: Jan Engelhardt Signed-off-by: Jessica Yu Signed-off-by: Jonathan Wakely Signed-off-by: Mark Wielaard Signed-off-by: Matthias Klose Signed-off-by: Matthias Maennich Signed-off-by: Ondrej Oprala Signed-off-by: Roland McGrath Signed-off-by: Sinny Kumari Signed-off-by: Slava Barinov 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 + +from_license_id= +to_license_id= +input_file= +prog=$0 + +display_usage() +{ + echo "$prog: [options] --from --to " + 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