From patchwork Wed Jul 15 15:13:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 40106 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 A373C386F457; Wed, 15 Jul 2020 15:13:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A373C386F457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594825993; bh=RgEaDVpTck33KoFi/pOW5bC6Oz22d/7daAcdg1Tda3Q=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=UxI0rqbZPrOBozTo3KguSy6T9zQ8G6/92y/XXS/KHiOPAzn56XMr2KEEkVvfJoQGs 7UJkkbzNtqNbn9kWWD4mHdeGEYGbphTpRMyxt7ngT1ISmA44w/W7K8DpNlrfPJgc7D zoteL3Tpvh8UhUR4iB34WEa0MNpzBDyxXCd7tCvQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id A8858386F457 for ; Wed, 15 Jul 2020 15:13:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A8858386F457 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-245-QqTVp8BpPHGhMTPAUrPtmw-1; Wed, 15 Jul 2020 11:13:08 -0400 X-MC-Unique: QqTVp8BpPHGhMTPAUrPtmw-1 Received: by mail-wr1-f70.google.com with SMTP id y16so1492675wrr.20 for ; Wed, 15 Jul 2020 08:13:08 -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=RgEaDVpTck33KoFi/pOW5bC6Oz22d/7daAcdg1Tda3Q=; b=QC4oWXBR5HxG5G7b0YMXk0WIuR5I/dWx3JUh6JS7sdf6JCmzi24eHn8BGmZPjgNmj0 ZEZRW+faVHUVPEeos+Ky6gYL4xBb+skT46C3uyRiuq40qWnDY8sKAiDU/lnw5hzWlkqI OsyEZu7OSw6m+UA5iA9MXcGvHP0UtnEqJZQg3J/7CZpr1izUkPDiECOsHzYthGi59IsY GDxmcEOaBrD6DCihUGVbcwQWjVp8gHYZugRuKd6qgVgbFeLq54UZsEHkKo4SxBN1h+Zm v0CIbZOuRXvx1sBuUca3L8M3eDR9Wa6k+C0P3Z2/9qjzGi9t5Gz7lBO2lsmBZnD6vYpQ EBqg== X-Gm-Message-State: AOAM531dQ20I6SCjux/VXMyasN2wK5endvoK9WwvQHfDPBCYweHE6UTB qEl5ux+eFJidyHC7DS65w7/MwFeWbQ181X66SI7H0EwHLR+TSguTLG1M+qyH+Nj5I8d3Djlbj8h /5rHh4ekfm7NzaNM6R0IX X-Received: by 2002:a1c:1b0d:: with SMTP id b13mr8823869wmb.169.1594825987430; Wed, 15 Jul 2020 08:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjJewocTbvUD0R7LOPT8PNsWuj8/uLppEAu5K812w1mcbkovHsYPTB/cz1sPk/6P8DsVkQAA== X-Received: by 2002:a1c:1b0d:: with SMTP id b13mr8823844wmb.169.1594825987175; Wed, 15 Jul 2020 08:13:07 -0700 (PDT) Received: from localhost (91-166-131-130.subs.proxad.net. [91.166.131.130]) by smtp.gmail.com with ESMTPSA id q5sm3945963wrp.60.2020.07.15.08.13.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2020 08:13:06 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 4A8FB18008A5; Wed, 15 Jul 2020 17:13:05 +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 3/9 v2] Add has-spdx-header.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:05 +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: <87h7u8lsla.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.5 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_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: libabigail@sourceware.org Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Add a script to detect if a file has a SPDX header and what the advertised license is. * relicensing-scripts/has-spdx-header.sh: New script. Signed-off-by: Dodji Seketeli Signed-off-by: Giuliano Procida Signed-off-by: Matthias Maennich Signed-off-by: Jonathan Wakely --- relicensing-scripts/has-spdx-header.sh | 105 +++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 relicensing-scripts/has-spdx-header.sh diff --git a/relicensing-scripts/has-spdx-header.sh b/relicensing-scripts/has-spdx-header.sh new file mode 100755 index 0000000..d4b7e08 --- /dev/null +++ b/relicensing-scripts/has-spdx-header.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Author: Dodji Seketeli + +file= +prog=$0 +display_file_name= +be_quiet= +show_no_spdx= + +display_usage() +{ + echo "$prog: [options] file" + echo " where options can be:" + echo " -h|--help display this help" + echo " -f|--file prefix output with file name" + echo " -q|--quiet emit no output if no license was found" + echo " --show-no-spdx show file name if it has no spdx header" +} + +emit_output_no_license() +{ + if test x$show_no_spdx != x; then + echo $display_file_name + elif test x$be_quiet = x; then + if test "x$display_file_name" = x; then + echo "NO-LICENSE" + else + echo "$display_file_name: NO-LICENSE" + fi + fi + + exit 1 +} + +emit_output_with_license() +{ + license=$1 + if test x$show_no_spdx != x; then + : + elif test "x$display_file_name" = x; then + echo "$license" + else + echo "$display_file_name: $license" + fi + exit 0 +} + +main() +{ + license=$(head --lines=5 $file | sed -n -E "s/^.*(SPDX-License-Identifier:)[ ]*([^*/]+).*$/\2/p") + + if test "x$license" = x; then + emit_output_no_license + else + emit_output_with_license "$license" + fi +} + +while test $# -ge 1 +do + case "$1" in + -h|--help) + display_usage + exit 0 + ;; + + -f|--file) + if test x$2 = x; then + >&2 display_usage + exit 1 + fi + display_file_name=$2 + shift + ;; + + -q|--quiet) + be_quiet=yes + shift + ;; + + --show-no-spdx) + if test x$2 = x; then + >&2 display_usage + exit 1 + fi + show_no_spdx=yes + display_file_name=$2 + shift + ;; + + *) + break + ;; + esac +done + +if test $# -lt 1; then + >&2 display_usage + exit 1 +fi + +file=$1 + +main