From patchwork Wed Dec 2 12:25:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41260 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 2C7B6395B059; Wed, 2 Dec 2020 12:25:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C7B6395B059 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606911947; bh=KAnMeJ/UbPxQgUUzV7EBHpDsy/mb/Ov/Bn/pZyKWsww=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gog6RQ5DUY/Kn5hufknhsssTh71siuNEUmX6Ic8xWZX2nDZN+FcTUNdl7SRH5hKIf DBpT+Ii0dpMkN4tEWZ3S3MlwnjIYsb09HvHX+7Uy7daVMOkn+ayqhAFM/Y8oYgLKXb KQYp/VUFxVwhuB4zFDqRkuxMk7z/s15J37XYqTJI= 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 38665395B059 for ; Wed, 2 Dec 2020 12:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 38665395B059 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-m4w3Yh3RPUWBlC_X1D58LA-1; Wed, 02 Dec 2020 07:25:24 -0500 X-MC-Unique: m4w3Yh3RPUWBlC_X1D58LA-1 Received: by mail-wm1-f72.google.com with SMTP id q1so3645975wmq.2 for ; Wed, 02 Dec 2020 04:25:24 -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=KAnMeJ/UbPxQgUUzV7EBHpDsy/mb/Ov/Bn/pZyKWsww=; b=n+37RdwPgmXF0i55s0XWM7IscuqM8QRAfBkjdTIAp25yZnLheCJQSOa//1Ak4SqgCd V0uIxfyeBdnXo0uzOFhIA7Kt0y7quknVC6yheiSWvnEqQEo9y5b61+wy/4Ru/rqxHNMN DdgnWVKJI/tO5r7lxuWgmjZC9Tf4I6c5S/dKISlUZU0WLlvO+LIVrwaM273wqTolPv9k lQkdJIaUURAYMldtduxqT9N/mrO9soBfH8Q/JAIXhMgGvdZoB/BHyw6xherCNnTCVcGg oVbTPMJ8RRKXRollOQjNp+YC1em04X59leobS2x/WhN7/y7MWOX9UyQWY6Ftb0OI8u0C eLsQ== X-Gm-Message-State: AOAM53043WB6G2AGF1B/96l8gWI5TX3ZxDd4Wl7D7/AmK5x8ZH0kaTCh EjG1y6I5tkPB3c7+Xwcomt2h9xaAVTGx0T37qLEvLtZSP+yTsMIMWQeekMJeiY12VgM5tQAZ5gr vpDYJG0xzx7vW9TQeuwbY X-Received: by 2002:a1c:7318:: with SMTP id d24mr2928472wmb.39.1606911923252; Wed, 02 Dec 2020 04:25:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbDfDph+NGe4ZxyQVGDnSPlGF7intXP73b76zxCLjeatt9nn2n9erTlYq9GU9xvU7U6DllYg== X-Received: by 2002:a1c:7318:: with SMTP id d24mr2928450wmb.39.1606911922953; Wed, 02 Dec 2020 04:25:22 -0800 (PST) Received: from localhost ([2a01:e0a:1a0:d060:5246:5dff:feab:d19c]) by smtp.gmail.com with ESMTPSA id h2sm1879053wme.45.2020.12.02.04.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 04:25:22 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 6A79D581CE5; Wed, 2 Dec 2020 13:25:21 +0100 (CET) To: Dodji Seketeli Subject: [PATCH 3/9, final act] Add has-spdx-header.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:21 +0100 In-Reply-To: <87o8jc4cv8.fsf@redhat.com> (Dodji Seketeli's message of "Wed, 02 Dec 2020 13:21:47 +0100") Message-ID: <87blfc4cpa.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.9 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" 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: 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/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 00000000..d4b7e08a --- /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