From patchwork Fri Jul 10 14:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 40017 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 319B73870924; Fri, 10 Jul 2020 14:08:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 319B73870924 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594390103; bh=p4cKw89ZEPEFe0i7Gyc3fGiMQnjeotvgx7klEEcj6uM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=JipltKxF/MxYXkaXyVdQiwFK6/YqNKnD18msqk1D4BgKCRH3bVtkpWwsLDzHtxBik nYUbL4ijpLfkVrc6MsHz+0jPb+mUYr2SxYc1+gVVTdWmXZcH5GVHLnlmrzWEPHDaR9 jORWDZ23SM1F/CdBstSKsZbldSCRfqUPPN1qWTsI= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 893F43870924 for ; Fri, 10 Jul 2020 14:08:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 893F43870924 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-KtRvWF5pPOKq1Gi-QUmr3A-1; Fri, 10 Jul 2020 10:08:13 -0400 X-MC-Unique: KtRvWF5pPOKq1Gi-QUmr3A-1 Received: by mail-wr1-f72.google.com with SMTP id c6so6155669wru.7 for ; Fri, 10 Jul 2020 07:08:12 -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:date:message-id :user-agent:mime-version; bh=p4cKw89ZEPEFe0i7Gyc3fGiMQnjeotvgx7klEEcj6uM=; b=PQb6uUqw0QS/0cYGCSi8LXE9PAJTqtEbiz68KaC2IfONhBnUGMcydqHAyNnu/NWu9g bWbALQQVqGCnr+Vn2Ttgmp2z3KJh47glbZxrrWDOIlCjJnQ72lubRCuUNZ5c7BykpDFX H9v8iKdQR87eTBVDDMCJlNwSU3Fq9D9oeIeIIcYobR2RHiXFj7PTNmH9x9ybgTMP2a+p X+YqVqkzW1arrt/XxZ3UAMMDkF9nDgtuzoTOGC0I/hehHs4AoeT+h4IsaiK8zVDkPkwl w3tuZeQ/m9TkR76WA58NKoIM+I1yyRzkkhSLlCK+KPm4pELCobt7eQbW949lp60+XMow 9gfQ== X-Gm-Message-State: AOAM533RkkcS6rul/ir9lKNSYcL8pHOQC7FFYJvqVhq8DjY/WlW06HFO ZD9xpxHuiYJ/DugGDTrDrhQ1+wJHvig9IM5mXsXZXd/pkw/jwtS8Kzk4Yl2G3KBXS5CAgrIlw6q +BjncE2jJXzxyuzqP8sx2 X-Received: by 2002:a5d:4710:: with SMTP id y16mr70588806wrq.189.1594390091890; Fri, 10 Jul 2020 07:08:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQzi06uJyJ1ihRCB27gyvVaatShTV3WwWy1kI5Eze8RX9gQ2eF2AzMboCNFHFPqO6LAfmVZQ== X-Received: by 2002:a5d:4710:: with SMTP id y16mr70588780wrq.189.1594390091588; Fri, 10 Jul 2020 07:08:11 -0700 (PDT) Received: from localhost (91-166-131-130.subs.proxad.net. [91.166.131.130]) by smtp.gmail.com with ESMTPSA id 190sm10479921wmb.15.2020.07.10.07.08.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jul 2020 07:08:10 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 9EB3A180097F; Fri, 10 Jul 2020 16:08:09 +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] Add replace-spdx-license.sh script Organization: Red Hat / France X-Operating-System: Red Hat Enterprise Linux Workstation 7.8 Beta X-URL: http://www.redhat.com Date: Fri, 10 Jul 2020 16:08:09 +0200 Message-ID: <87o8ono43a.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.4 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: Dodji Seketeli Signed-off-by: Matthias Maennich --- 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..5fdbc91 --- /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 + display_usage + exit 1 +fi + +# Parse parameters +while test $# -gt 1; do + case "$1" in + -h|--h) + display_usage + exit 1 + ;; + + -f|--from) + from_license_id=$2 + shift + ;; + + -t|--to) + to_license_id=$2 + shift + ;; + + -*) + display_usage + exit 1 + ;; + + *) + input_file="$1" + ;; + esac + shift +done + +if test $# -lt 1; then + display_usage + exit 1 +fi + +input_file=$1 + +main