From patchwork Sun Feb 28 19:31:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 8447741 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 640C49F314 for ; Sun, 28 Feb 2016 19:31:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 703262021B for ; Sun, 28 Feb 2016 19:31:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EC732010E for ; Sun, 28 Feb 2016 19:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754576AbcB1TbL (ORCPT ); Sun, 28 Feb 2016 14:31:11 -0500 Received: from mail-qg0-f46.google.com ([209.85.192.46]:36328 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754568AbcB1TbK (ORCPT ); Sun, 28 Feb 2016 14:31:10 -0500 Received: by mail-qg0-f46.google.com with SMTP id y9so102851023qgd.3 for ; Sun, 28 Feb 2016 11:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Zwol4B1po1OZaQPF4qt+t4BfNaQnLdmx0sWAJDvJAMs=; b=T37Dktf7nKLbiJaGaZaO/jnRt+lBaQPDjrLGB+/vioJWtZmOrZrAe12P5/zklWmCUt z83TUTlvQerEGQcm1ZFFsNkOk90Tub736wwYSbVIQ28TgDTyvRnjjSOJ5jORzWwqV4Kr /yW4HYrq/+6U+GOozcE31cUOLaWDpBkxVQZpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Zwol4B1po1OZaQPF4qt+t4BfNaQnLdmx0sWAJDvJAMs=; b=SlqAT7mkRPJqOLW6/I7zot048ofHchrdHt7LvrBuoGWKBtT/MWCH4GnCFo2ag5m9HR 1AjtsX0LECaybITWawYMcQo0Epoaf0x+F2gq1kbUV7Nxnvp78aH5qvGZtBPgYcE2SZPo WsjXk5QWAMDkldzn3hRxxgtmIY4izn0xh5TvBTfhDRF7+x4Lvtfhxu3AfJjXYPp+PAVQ k0aYVBztjL4htkCaL7KPYvgjwH+PnowPdjjj9sBqt+R427JJefzvxEXnbYL9uRn2t2Bu wMsvOP/ZlrqB/xWYRhxXkoMYG4SCb/8t+O0okA4smgcat1gbGui4FCqOK0kRFHWse9FV Ummg== X-Gm-Message-State: AD7BkJKf5ACa5k64DYWq0wYR/jiSdJUxJ5sv83PGeVG+YsY0JUKA1NA6DCQY0JMW99wEsXRZ X-Received: by 10.140.160.130 with SMTP id g124mr15869040qhg.88.1456687869883; Sun, 28 Feb 2016 11:31:09 -0800 (PST) Received: from xanadu.home ([2607:fa48:6e39:d410:feaa:14ff:fea7:ed77]) by smtp.gmail.com with ESMTPSA id i67sm9421047qhi.45.2016.02.28.11.31.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2016 11:31:08 -0800 (PST) Date: Sun, 28 Feb 2016 14:31:07 -0500 (EST) From: Nicolas Pitre To: Zev Weiss cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro , Rusty Russell Subject: Re: [PATCH v3 6/7] create/adjust generated/autoksyms.h In-Reply-To: <20160228121146.GK17422@hatter.bewilderbeest.net> Message-ID: References: <20160228121146.GK17422@hatter.bewilderbeest.net> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, 28 Feb 2016, Zev Weiss wrote: > On Thu, Feb 18, 2016 at 15:07:02 -0500, Nicolas Pitre wrote: > >diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh > >new file mode 100755 > >index 0000000000..898a3ca1b2 > >--- /dev/null > >+++ b/scripts/adjust_autoksyms.sh > > @@ -0,0 +1,97 @@ > >+#!/bin/sh > > Given the here-strings in this script, this should probably be /bin/bash or > breakage will ensue on Debian and suchlike where /bin/sh != bash. However... > > >+sed -ns -e '3s/ /\n/gp' "$MODVERDIR"/*.mod | sort -u | > >+while read sym; do > >+ if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then > >+ sym=$(sed 's/^_//' <<< "$sym") > > ...this one could (shell-portably and more efficiently) be a parameter > expansion (sym="${sym#_}"). Indeed. > >+ > >+# Extract changes between old and new list and touch corresponding > >+# dependency files. > >+# Note: sort -m doesn't work well with underscore prefixed symbols so we > >+# use 'cat ... | sort' instead. > >+changed=0 > >+while read sympath; do > >+ [ -z "$sympath" ] && continue > >+ depfile="include/config/ksym/${sympath}.h" > >+ mkdir -p "$(dirname "$depfile")" > >+ touch "$depfile" > >+ changed=$((changed + 1)) > >+done <<< "$( > >+ cat "$cur_ksyms_file" "$new_ksyms_file" | sort | uniq -u | > >+ sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" )" > > Nothing super-obvious springs to mind as a pure-sh equivalent for this one > though, so assuming the script remains bash-specific, a process substitution > like > > done < <(cat ...) > > might slightly cleaner than the here-string + command substitution (doesn't > need quoting, and just streams through a pipe rather than bash snarfing it all > up into a string). Right. Still, I decided to make it compatible with a simpler shell. I applied the following changes and tested it with dash. Nicolas --- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 898a3ca1b2..a145a24cd8 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh @@ -57,9 +57,7 @@ cat > "$new_ksyms_file" << EOT EOT sed -ns -e '3s/ /\n/gp' "$MODVERDIR"/*.mod | sort -u | while read sym; do - if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then - sym=$(sed 's/^_//' <<< "$sym") - fi + [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ] && sym="${sym#_}" echo "#define __KSYM_${sym} 1" done >> "$new_ksyms_file" @@ -72,16 +70,18 @@ fi # dependency files. # Note: sort -m doesn't work well with underscore prefixed symbols so we # use 'cat ... | sort' instead. -changed=0 +changed=$( +count=0 +cat "$cur_ksyms_file" "$new_ksyms_file" | sort | uniq -u | +sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | while read sympath; do [ -z "$sympath" ] && continue depfile="include/config/ksym/${sympath}.h" mkdir -p "$(dirname "$depfile")" touch "$depfile" - changed=$((changed + 1)) -done <<< "$( - cat "$cur_ksyms_file" "$new_ksyms_file" | sort | uniq -u | - sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" )" + echo $((count += 1)) +done | tail -1 ) +changed=${changed:-0} if [ $changed -gt 0 ]; then # Replace the old list with tne new one