From: Nicolas Pitre <nicolas.pitre@linaro.org>
To: Zev Weiss <zev@bewilderbeest.net>
Cc: Michal Marek <mmarek@suse.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Al Viro <viro@ZenIV.linux.org.uk>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH v3 6/7] create/adjust generated/autoksyms.h
Date: Sun, 28 Feb 2016 14:31:07 -0500 (EST) [thread overview]
Message-ID: <alpine.LFD.2.20.1602281419130.13632@knanqh.ubzr> (raw)
In-Reply-To: <20160228121146.GK17422@hatter.bewilderbeest.net>
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.
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
Nicolas
next prev parent reply other threads:[~2016-02-28 19:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 20:06 [PATCH v3 0/7] Trim unused exported kernel symbols Nicolas Pitre
2016-02-18 20:06 ` [PATCH v3 1/7] kbuild: record needed exported symbols for modules Nicolas Pitre
2016-02-18 20:06 ` [PATCH v3 2/7] allow for per-symbol configurable EXPORT_SYMBOL() Nicolas Pitre
2016-02-18 20:06 ` [PATCH v3 3/7] fixdep: accept extra dependencies on stdin Nicolas Pitre
2016-02-18 20:07 ` [PATCH v3 4/7] kbuild: de-duplicate fixdep usage Nicolas Pitre
2016-02-18 20:07 ` [PATCH v3 5/7] kbuild: add fine grained build dependencies for exported symbols Nicolas Pitre
2016-02-18 20:07 ` [PATCH v3 6/7] create/adjust generated/autoksyms.h Nicolas Pitre
2016-02-28 12:11 ` Zev Weiss
2016-02-28 19:31 ` Nicolas Pitre [this message]
2016-02-18 20:07 ` [PATCH v3 7/7] kconfig option for TRIM_UNUSED_KSYMS Nicolas Pitre
2016-02-24 15:19 ` [PATCH v3 0/7] Trim unused exported kernel symbols Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.20.1602281419130.13632@knanqh.ubzr \
--to=nicolas.pitre@linaro.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.com \
--cc=rusty@rustcorp.com.au \
--cc=viro@ZenIV.linux.org.uk \
--cc=zev@bewilderbeest.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®