Skip to content

Commit

Permalink
kbuild: deb-pkg improve maintainer address generation
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
  • Loading branch information
Riku Voipio authored and Masahiro Yamada committed May 17, 2018
1 parent b3aa58d commit d5940c6
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions scripts/package/mkdebian
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,21 @@ 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 [ -z "$email" ]; then
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
email="$user@$buildhost"
fi
maintainer="$name <$email>"
fi
maintainer="$name <$email>"

# Try to determine distribution
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
Expand Down

0 comments on commit d5940c6

Please sign in to comment.