From patchwork Wed Jul 15 15:13:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 40107 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 7FAF23870865; Wed, 15 Jul 2020 15:14:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FAF23870865 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594826046; bh=qS7PGBN7GA1MN85chphDll2oIotazGAhXFerfSs4e78=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=fV5U3rYNwbws4gMmPrZ9gO9ZSsTsF0wv8XfXv7BJg8pz3P8dPjhje0vVYFlf6w6La 6lQRP56FyOlGhzgrimATIeDxsRWt2M/1YqwiDodp9Uhj5BHbeTzu2WFRZIcDzxYIY8 Mo/2CpTjsk/EL4hPitFMYXCZrV4Dt4N2D9k2TfZ4= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id C556F386F457 for ; Wed, 15 Jul 2020 15:14:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C556F386F457 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-MjhO34xmOaC4LZTWPbYhUQ-1; Wed, 15 Jul 2020 11:13:47 -0400 X-MC-Unique: MjhO34xmOaC4LZTWPbYhUQ-1 Received: by mail-wr1-f70.google.com with SMTP id f5so1492818wrv.22 for ; Wed, 15 Jul 2020 08:13:47 -0700 (PDT) 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=qS7PGBN7GA1MN85chphDll2oIotazGAhXFerfSs4e78=; b=or2Kp9d30Vj8lvb9Fu1XXbq/c3C33UMBMrhiPJgyz5oRwuSMwogjMEOO0m90MMq9M7 v5JnMkvbt4FYnXDRYS02kI0KhCcT4EFbL4lViIQWmIahZOnJ63FpRg1Imr9Rx5LKpz7k RtaeSByDoaKchlCYZ1kX06XDksj6/kHycS50PaaHzMZLZ4G8l1bz3KzSvNcnAbhTYkeh 55BqFr0qGBnG6wg09KzQCTvSBCyfUjMD6ajEvjqB4tSDMNfR+0UJFq7K3OrZq67q7+jQ zAvqEf9Erk1wbAGpGb2lSyctl1MeIvbLYWqIyDew65N1gORAYod9duawcq6jdZ0JYbHz nNzQ== X-Gm-Message-State: AOAM533EFwsBZJXusy5a/fphWHYQ9l1kUtf5GmLFH/+8ha3Ap6ukRWPK RhWMGE5YX6SjXc9Lpz0ktzRfC7qCccDqWIqpvpR1sAn6IrY7qnaE7WQLYyj36ixw+DWMsuTvZCN orLOB/OPLDCdyUXkrUps/ X-Received: by 2002:a1c:804c:: with SMTP id b73mr8984215wmd.59.1594826026132; Wed, 15 Jul 2020 08:13:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKNEWiaHupSie74t6aXbX0+3mOs1p5HFTcFbm3vEARkH6WROcXifIjT05nrzytzO5Ou0zAZg== X-Received: by 2002:a1c:804c:: with SMTP id b73mr8984172wmd.59.1594826025859; Wed, 15 Jul 2020 08:13:45 -0700 (PDT) Received: from localhost (91-166-131-130.subs.proxad.net. [91.166.131.130]) by smtp.gmail.com with ESMTPSA id c194sm3760895wme.8.2020.07.15.08.13.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2020 08:13:45 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 03F2618008A5; Wed, 15 Jul 2020 17:13:44 +0200 (CEST) To: Benjamin Kosnik , Ben Woodard , Chenxiong Qi , Dodji Seketeli , Giuliano Procida , Jan Engelhardt , Jessica Yu , Jonathan Wakely , Mark Wielaard , Matthias Klose , Matthias Maennich , Ondrej Oprala , Roland McGrath , Sinny Kumari , Slava Barinov Subject: [PATCH 4/9 v2] Add replace-spdx-license.sh script Organization: Red Hat / France References: <87zh80lt38.fsf@redhat.com> X-Operating-System: Red Hat Enterprise Linux Workstation 7.8 Beta X-URL: http://www.redhat.com Date: Wed, 15 Jul 2020 17:13:43 +0200 In-Reply-To: <87zh80lt38.fsf@redhat.com> (Dodji Seketeli via Libabigail's message of "Wed, 15 Jul 2020 17:02:19 +0200") Message-ID: <87d04wlsk8.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: libabigail@sourceware.org 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: Dodji Seketeli Signed-off-by: Matthias Maennich Signed-off-by: Jonathan Wakely --- 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 0000000..f634528 --- /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