Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.kernel > #60812 > unrolled thread
| Started by | riku.voipio@linaro.org |
|---|---|
| First post | 2018-05-03 14:10 +0200 |
| Last post | 2018-05-05 12:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.debian.kernel
[PATCH] kbuild: deb-pkg improve maintainer address generation riku.voipio@linaro.org - 2018-05-03 14:10 +0200
Re: [PATCH] kbuild: deb-pkg improve maintainer address generation Mathieu Malaterre <malat@debian.org> - 2018-05-03 19:10 +0200
Re: [PATCH] kbuild: deb-pkg improve maintainer address generation Masahiro Yamada <yamada.masahiro@socionext.com> - 2018-05-05 12:10 +0200
| From | riku.voipio@linaro.org |
|---|---|
| Date | 2018-05-03 14:10 +0200 |
| Subject | [PATCH] kbuild: deb-pkg improve maintainer address generation |
| Message-ID | <vLldJ-yZ-23@gated-at.bofh.it> |
From: Riku Voipio <riku.voipio@linaro.org>
There is multiple issues with the genaration of maintainer string
It uses DEBEMAIL and EMAIL enviroment variables, which may contain angle brackets,
creating invalid maintainer strings. The documented KBUILD_BUILD_USER and
KBUILD_BUILD_HOST variables are not used. Undocumented and uncommon NAME
variable is used. Refactor the Maintainer string to:
- use EMAIL or DEBEMAIL directly if they are in form "name <user@host>"
- use KBUILD_BUILD_USER and KBUILD_BUILD_HOST if set before falling
back to autodetection
- no longer use NAME variable or the useless Anonymous string
The logic is switched from multiline if/then/fi statements to compact
shell variable substition commands.
Reported-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
scripts/package/mkdebian | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index 6adb3a16ba3b..a70f20eb877a 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -71,22 +71,23 @@ if [ "$ARCH" = "um" ] ; then
packagename=user-mode-linux-$version
fi
-# Try to determine maintainer and email values
-if [ -n "$DEBEMAIL" ]; then
- email=$DEBEMAIL
-elif [ -n "$EMAIL" ]; then
- email=$EMAIL
-else
- email=$(id -nu)@$(hostname -f 2>/dev/null || hostname)
-fi
-if [ -n "$DEBFULLNAME" ]; then
- name=$DEBFULLNAME
-elif [ -n "$NAME" ]; then
- name=$NAME
+email=${DEBEMAIL-$EMAIL}
+
+# use email string directly if it contains <email>
+if echo $email|grep -q '<.*>';
+then
+ maintainer=$email
else
- name="Anonymous"
+ # or construct the maintainer string
+ user=${KBUILD_BUILD_USER-$(id -nu)}
+ name=${DEBFULLNAME-$user}
+ if [ -n "$email" ]; then
+ maintainer="$name <$email>"
+ else
+ buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
+ maintainer="$name <$user@$buildhost>"
+ fi
fi
-maintainer="$name <$email>"
# Try to determine distribution
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
--
2.14.2
[toc] | [next] | [standalone]
| From | Mathieu Malaterre <malat@debian.org> |
|---|---|
| Date | 2018-05-03 19:10 +0200 |
| Message-ID | <vLpTY-3KM-15@gated-at.bofh.it> |
| In reply to | #60812 |
Hi,
On Thu, May 3, 2018 at 1:46 PM, <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> There is multiple issues with the genaration of maintainer string
>
> It uses DEBEMAIL and EMAIL enviroment variables, which may contain angle brackets,
> creating invalid maintainer strings. The documented KBUILD_BUILD_USER and
> KBUILD_BUILD_HOST variables are not used. Undocumented and uncommon NAME
> variable is used. Refactor the Maintainer string to:
>
> - use EMAIL or DEBEMAIL directly if they are in form "name <user@host>"
> - use KBUILD_BUILD_USER and KBUILD_BUILD_HOST if set before falling
> back to autodetection
> - no longer use NAME variable or the useless Anonymous string
>
> The logic is switched from multiline if/then/fi statements to compact
> shell variable substition commands.
Much more elegant indeed.
Acked-by: Mathieu Malaterre <malat@debian.org>
> Reported-by: Mathieu Malaterre <malat@debian.org>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---
> scripts/package/mkdebian | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index 6adb3a16ba3b..a70f20eb877a 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -71,22 +71,23 @@ if [ "$ARCH" = "um" ] ; then
> packagename=user-mode-linux-$version
> fi
>
> -# Try to determine maintainer and email values
> -if [ -n "$DEBEMAIL" ]; then
> - email=$DEBEMAIL
> -elif [ -n "$EMAIL" ]; then
> - email=$EMAIL
> -else
> - email=$(id -nu)@$(hostname -f 2>/dev/null || hostname)
> -fi
> -if [ -n "$DEBFULLNAME" ]; then
> - name=$DEBFULLNAME
> -elif [ -n "$NAME" ]; then
> - name=$NAME
> +email=${DEBEMAIL-$EMAIL}
> +
> +# use email string directly if it contains <email>
> +if echo $email|grep -q '<.*>';
> +then
> + maintainer=$email
> else
> - name="Anonymous"
> + # or construct the maintainer string
> + user=${KBUILD_BUILD_USER-$(id -nu)}
> + name=${DEBFULLNAME-$user}
> + if [ -n "$email" ]; then
> + maintainer="$name <$email>"
> + else
> + buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
> + maintainer="$name <$user@$buildhost>"
> + fi
> fi
> -maintainer="$name <$email>"
>
> # Try to determine distribution
> if [ -n "$KDEB_CHANGELOG_DIST" ]; then
> --
> 2.14.2
>
[toc] | [prev] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2018-05-05 12:10 +0200 |
| Message-ID | <vM2iB-40k-5@gated-at.bofh.it> |
| In reply to | #60812 |
Hi Riku,
2018-05-03 20:46 GMT+09:00 <riku.voipio@linaro.org>:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> There is multiple issues with the genaration of maintainer string
>
> It uses DEBEMAIL and EMAIL enviroment variables, which may contain angle brackets,
> creating invalid maintainer strings. The documented KBUILD_BUILD_USER and
> KBUILD_BUILD_HOST variables are not used. Undocumented and uncommon NAME
> variable is used. Refactor the Maintainer string to:
>
> - use EMAIL or DEBEMAIL directly if they are in form "name <user@host>"
> - use KBUILD_BUILD_USER and KBUILD_BUILD_HOST if set before falling
> back to autodetection
> - no longer use NAME variable or the useless Anonymous string
>
> The logic is switched from multiline if/then/fi statements to compact
> shell variable substition commands.
>
> Reported-by: Mathieu Malaterre <malat@debian.org>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---
Almost looks good to me.
Just small nits.
> scripts/package/mkdebian | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index 6adb3a16ba3b..a70f20eb877a 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -71,22 +71,23 @@ if [ "$ARCH" = "um" ] ; then
> packagename=user-mode-linux-$version
> fi
>
> -# Try to determine maintainer and email values
> -if [ -n "$DEBEMAIL" ]; then
> - email=$DEBEMAIL
> -elif [ -n "$EMAIL" ]; then
> - email=$EMAIL
> -else
> - email=$(id -nu)@$(hostname -f 2>/dev/null || hostname)
> -fi
> -if [ -n "$DEBFULLNAME" ]; then
> - name=$DEBFULLNAME
> -elif [ -n "$NAME" ]; then
> - name=$NAME
> +email=${DEBEMAIL-$EMAIL}
> +
> +# use email string directly if it contains <email>
> +if echo $email|grep -q '<.*>';
> +then
May I ask two coding style changes?
- Please add spaces around the pipe operator '|'
- Move 'then' to the end of the previous line, for style consistency
i.e. like follows:
if echo $email | grep -q '<.*>'; then
> + maintainer=$email
> else
> - name="Anonymous"
> + # or construct the maintainer string
> + user=${KBUILD_BUILD_USER-$(id -nu)}
> + name=${DEBFULLNAME-$user}
> + if [ -n "$email" ]; then
> + maintainer="$name <$email>"
> + else
> + buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
> + maintainer="$name <$user@$buildhost>"
> + fi
> fi
I think the else-block can be a bit shorter
if you write like follows:
# or construct the maintainer string
user=${KBUILD_BUILD_USER-$(id -nu)}
name=${DEBFULLNAME-$user}
if [ -z "$email" ]; then
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null ||
hostname)}
email=$user@$buildhost
fi
maintainer="$name <$email>"
--
Best Regards
Masahiro Yamada
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.kernel
csiph-web