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: 63161 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp895885lbc; Sun, 28 Feb 2016 11:31:14 -0800 (PST) X-Received: by 10.98.80.10 with SMTP id e10mr17167284pfb.141.1456687874408; Sun, 28 Feb 2016 11:31:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si20440541pfi.140.2016.02.28.11.31.14; Sun, 28 Feb 2016 11:31:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754958AbcB1TbM (ORCPT + 30 others); Sun, 28 Feb 2016 14:31:12 -0500 Received: from mail-qg0-f53.google.com ([209.85.192.53]:33921 "EHLO mail-qg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754572AbcB1TbL (ORCPT ); Sun, 28 Feb 2016 14:31:11 -0500 Received: by mail-qg0-f53.google.com with SMTP id b67so101639831qgb.1 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=L7ffHBP+M/bmY7NaAkII4rme6qmzLqEfFa7rco80D2hkNaWiuNF2bjRKYA/Ko/+SEx pzQiZDNsDRNGa5Vupoui22fRdp4EeDQL0uQIDdxNbgUfRZ8+1o/MDtnvWoQgkMnr9vI+ h7XiNhmF2mmRJ32vJptMxP/T5prtD9LnVKematZdazqWb5iJgb7bvXyBCBfB4xhZmovr /FaIrxTeZQb9oBm8d9dOwPrVwRP8DA26KDrg2h3c/Z/VJjLWxlon5ZhWJ5vnVdjvyMmV ZdSej9M7oDs9dMm5D8RJsuYs80POW11CJ0s5difxc2DEknLJ0ZqwBCu58UOYJ8OoB64y XM9Q== X-Gm-Message-State: AD7BkJJ6SJ6oiRS9iYIH2IVf3X3DRlmggtJYlhGO4EsabDpauAGa59xCUWf+lzPnKhfiTbb+ 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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