diff mbox

[v6] builddeb: Try to determine distribution

Message ID 1420278619-6637-1-git-send-email-sedat.dilek@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sedat Dilek Jan. 3, 2015, 9:50 a.m. UTC
lsb_release command is a good choice to determine the distribution
name for the changelog file in the generated Debian packages [1].
Its installation is no precondition.
In Debian it is still not essential or build-essential.

Ben gave some helpful informations and detailed explanations in [2].
There he also suggested to have an option to explicitly set the
distribution name (see $KDEB_CHANGELOG_DIST variable).

Embedded the improvement as suggested by Thorsten (see [3]):

"This is suboptimal: if KDEB_CHANGELOG_DIST is defined,
lsb_release is not necessary. The following snippet
also omits using its output if it fails but still
produces any:"

Dealing with this issue I learned about "The Colon in the Shell." and
possible pitfalls in this area (see [4,5]). Furthermore, refreshed my
knowledge about redirecting outputs with the echo command (see [5]).
Special thanks to Thorsten, I enjoyed the IRC session with you.

Cooked together the snippets of Ben and Thorsten (see [2,3]).
Tested against Linux v3.19-rc2.

Thanks goes to Alexander, Ben, maximilian and Thorsten for the very
vital help.

[1] https://lkml.org/lkml/2012/4/23/516
[2] http://marc.info/?l=linux-kbuild&m=142022188322321&w=2
[3] http://marc.info/?l=linux-kbuild&m=142023476825460&w=2
[4] http://blog.brlink.eu/index.html#i70
[5] https://www.mirbsd.org/permalinks/wlog-10_e20141209-tg.htm
[6] http://stackoverflow.com/questions/23489934/echo-2-some-text-what-does-it-mean-in-shell-scripting

CC: Ben Hutchings <ben@decadent.org.uk>
CC: maximilian attems <max@stro.at>
CC: Thorsten Glaser <tg@mirbsd.org>
CC: Alexander Wirt <formorer@debian.org>
CC: Michal Marek <mmarek@suse.cz>
CC: linux-kbuild@vger.kernel.org
Suggested-by: Ben Hutchings <ben@decadent.org.uk>
Suggested-by: Thorsten Glaser <tg@mirbsd.org>
Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: maximilian attems <max@stro.at>
[ dileks: Reviewed his suggested diff in RFC v4 ]
Reviewed-by: Thorsten Glaser <tg@debian.org>
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
---
v6: Based on RFC v5 with added reviews and acks
v5: Improve commit-message and fix Thorsten's email-address
v4: Embed improvements suggested by Thorsten
v3: Massaged the commit-message
v2: Suppress error messages when lsb_release is not installed.
    (Thanks maximilian and Ben.)

 scripts/package/builddeb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Sedat Dilek Jan. 6, 2015, 11:39 a.m. UTC | #1
On Sat, Jan 3, 2015 at 10:50 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> lsb_release command is a good choice to determine the distribution
> name for the changelog file in the generated Debian packages [1].
> Its installation is no precondition.
> In Debian it is still not essential or build-essential.
>
> Ben gave some helpful informations and detailed explanations in [2].
> There he also suggested to have an option to explicitly set the
> distribution name (see $KDEB_CHANGELOG_DIST variable).
>
> Embedded the improvement as suggested by Thorsten (see [3]):
>
> "This is suboptimal: if KDEB_CHANGELOG_DIST is defined,
> lsb_release is not necessary. The following snippet
> also omits using its output if it fails but still
> produces any:"
>
> Dealing with this issue I learned about "The Colon in the Shell." and
> possible pitfalls in this area (see [4,5]). Furthermore, refreshed my
> knowledge about redirecting outputs with the echo command (see [5]).
> Special thanks to Thorsten, I enjoyed the IRC session with you.
>
> Cooked together the snippets of Ben and Thorsten (see [2,3]).
> Tested against Linux v3.19-rc2.
>
> Thanks goes to Alexander, Ben, maximilian and Thorsten for the very
> vital help.
>
> [1] https://lkml.org/lkml/2012/4/23/516
> [2] http://marc.info/?l=linux-kbuild&m=142022188322321&w=2
> [3] http://marc.info/?l=linux-kbuild&m=142023476825460&w=2
> [4] http://blog.brlink.eu/index.html#i70
> [5] https://www.mirbsd.org/permalinks/wlog-10_e20141209-tg.htm
> [6] http://stackoverflow.com/questions/23489934/echo-2-some-text-what-does-it-mean-in-shell-scripting
>
> CC: Ben Hutchings <ben@decadent.org.uk>
> CC: maximilian attems <max@stro.at>
> CC: Thorsten Glaser <tg@mirbsd.org>
> CC: Alexander Wirt <formorer@debian.org>
> CC: Michal Marek <mmarek@suse.cz>
> CC: linux-kbuild@vger.kernel.org
> Suggested-by: Ben Hutchings <ben@decadent.org.uk>
> Suggested-by: Thorsten Glaser <tg@mirbsd.org>
> Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
> Acked-by: maximilian attems <max@stro.at>
> [ dileks: Reviewed his suggested diff in RFC v4 ]
> Reviewed-by: Thorsten Glaser <tg@debian.org>
> Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
> ---
> v6: Based on RFC v5 with added reviews and acks
> v5: Improve commit-message and fix Thorsten's email-address
> v4: Embed improvements suggested by Thorsten
> v3: Massaged the commit-message
> v2: Suppress error messages when lsb_release is not installed.
>     (Thanks maximilian and Ben.)
>
>  scripts/package/builddeb | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 5972624..f631c77 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -217,9 +217,20 @@ else
>  fi
>  maintainer="$name <$email>"
>
> +# Try to determine distribution
> +if [ -n "$KDEB_CHANGELOG_DIST" ]; then
> +        distribution=$KDEB_CHANGELOG_DIST
> +elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ]; then
> +        : # nothing to do in this case
> +else
> +        distribution="unstable"
> +        echo >&2 "Using default distribution of 'unstable' in the changelog"
> +        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
> +fi
> +
>  # Generate a simple changelog template
>  cat <<EOF > debian/changelog
> -linux-upstream ($packageversion) unstable; urgency=low
> +linux-upstream ($packageversion) $distribution; urgency=low
>
>    * Custom built Linux kernel.
>
> --
> 2.2.1
>

According to your explanations about your development workflow and Git
trees this can go now to kbuild.git#misc.
Or is something wrong with that one (commit message, missing credits, etc.)?

Thanks.

- Sedat -
--
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
Sedat Dilek Jan. 6, 2015, 1:36 p.m. UTC | #2
On Tue, Jan 6, 2015 at 12:39 PM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> On Sat, Jan 3, 2015 at 10:50 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>> lsb_release command is a good choice to determine the distribution
>> name for the changelog file in the generated Debian packages [1].
>> Its installation is no precondition.
>> In Debian it is still not essential or build-essential.
>>
>> Ben gave some helpful informations and detailed explanations in [2].
>> There he also suggested to have an option to explicitly set the
>> distribution name (see $KDEB_CHANGELOG_DIST variable).
>>
>> Embedded the improvement as suggested by Thorsten (see [3]):
>>
>> "This is suboptimal: if KDEB_CHANGELOG_DIST is defined,
>> lsb_release is not necessary. The following snippet
>> also omits using its output if it fails but still
>> produces any:"
>>
>> Dealing with this issue I learned about "The Colon in the Shell." and
>> possible pitfalls in this area (see [4,5]). Furthermore, refreshed my
>> knowledge about redirecting outputs with the echo command (see [5]).
>> Special thanks to Thorsten, I enjoyed the IRC session with you.
>>
>> Cooked together the snippets of Ben and Thorsten (see [2,3]).
>> Tested against Linux v3.19-rc2.
>>
>> Thanks goes to Alexander, Ben, maximilian and Thorsten for the very
>> vital help.
>>
>> [1] https://lkml.org/lkml/2012/4/23/516
>> [2] http://marc.info/?l=linux-kbuild&m=142022188322321&w=2
>> [3] http://marc.info/?l=linux-kbuild&m=142023476825460&w=2
>> [4] http://blog.brlink.eu/index.html#i70
>> [5] https://www.mirbsd.org/permalinks/wlog-10_e20141209-tg.htm
>> [6] http://stackoverflow.com/questions/23489934/echo-2-some-text-what-does-it-mean-in-shell-scripting
>>
>> CC: Ben Hutchings <ben@decadent.org.uk>
>> CC: maximilian attems <max@stro.at>
>> CC: Thorsten Glaser <tg@mirbsd.org>
>> CC: Alexander Wirt <formorer@debian.org>
>> CC: Michal Marek <mmarek@suse.cz>
>> CC: linux-kbuild@vger.kernel.org
>> Suggested-by: Ben Hutchings <ben@decadent.org.uk>
>> Suggested-by: Thorsten Glaser <tg@mirbsd.org>
>> Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
>> Acked-by: maximilian attems <max@stro.at>
>> [ dileks: Reviewed his suggested diff in RFC v4 ]
>> Reviewed-by: Thorsten Glaser <tg@debian.org>
>> Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
>> ---
>> v6: Based on RFC v5 with added reviews and acks
>> v5: Improve commit-message and fix Thorsten's email-address
>> v4: Embed improvements suggested by Thorsten
>> v3: Massaged the commit-message
>> v2: Suppress error messages when lsb_release is not installed.
>>     (Thanks maximilian and Ben.)
>>
>>  scripts/package/builddeb | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
>> index 5972624..f631c77 100755
>> --- a/scripts/package/builddeb
>> +++ b/scripts/package/builddeb
>> @@ -217,9 +217,20 @@ else
>>  fi
>>  maintainer="$name <$email>"
>>
>> +# Try to determine distribution
>> +if [ -n "$KDEB_CHANGELOG_DIST" ]; then
>> +        distribution=$KDEB_CHANGELOG_DIST
>> +elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ]; then
>> +        : # nothing to do in this case
>> +else
>> +        distribution="unstable"
>> +        echo >&2 "Using default distribution of 'unstable' in the changelog"
>> +        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
>> +fi
>> +
>>  # Generate a simple changelog template
>>  cat <<EOF > debian/changelog
>> -linux-upstream ($packageversion) unstable; urgency=low
>> +linux-upstream ($packageversion) $distribution; urgency=low
>>
>>    * Custom built Linux kernel.
>>
>> --
>> 2.2.1
>>
>
> According to your explanations about your development workflow and Git
> trees this can go now to kbuild.git#misc.
> Or is something wrong with that one (commit message, missing credits, etc.)?
>
> Thanks.
>

Please, push v7.

Thanks.

- Sedat -
--
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
Michal Marek Jan. 6, 2015, 7:49 p.m. UTC | #3
Dne 6.1.2015 v 12:39 Sedat Dilek napsal(a):
> On Sat, Jan 3, 2015 at 10:50 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>> lsb_release command is a good choice to determine the distribution
>> name for the changelog file in the generated Debian packages [1].
>> Its installation is no precondition.
>> In Debian it is still not essential or build-essential.
[...]
> According to your explanations about your development workflow and Git
> trees this can go now to kbuild.git#misc.

I applied it to kbuild.git#misc now.

Michal

--
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
Sedat Dilek Jan. 7, 2015, 6:11 a.m. UTC | #4
On Tue, Jan 6, 2015 at 8:49 PM, Michal Marek <mmarek@suse.cz> wrote:
> Dne 6.1.2015 v 12:39 Sedat Dilek napsal(a):
>> On Sat, Jan 3, 2015 at 10:50 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>>> lsb_release command is a good choice to determine the distribution
>>> name for the changelog file in the generated Debian packages [1].
>>> Its installation is no precondition.
>>> In Debian it is still not essential or build-essential.
> [...]
>> According to your explanations about your development workflow and Git
>> trees this can go now to kbuild.git#misc.
>
> I applied it to kbuild.git#misc now.
>

Thanks.

- Sedat -
--
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
Michal Marek Jan. 7, 2015, 9:47 a.m. UTC | #5
On 2015-01-06 14:36, Sedat Dilek wrote:
> On Tue, Jan 6, 2015 at 12:39 PM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>> According to your explanations about your development workflow and Git
>> trees this can go now to kbuild.git#misc.
>> Or is something wrong with that one (commit message, missing credits, etc.)?
>>
>> Thanks.
>>
> 
> Please, push v7.

Sorry, too late. Our mailserver had some digestive problems yesterday
and needed several hours to process incomming emails ;). So I merged v6
without knowing that there was v7 in the queue.

Michal
--
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 mbox

Patch

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5972624..f631c77 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -217,9 +217,20 @@  else
 fi
 maintainer="$name <$email>"
 
+# Try to determine distribution
+if [ -n "$KDEB_CHANGELOG_DIST" ]; then
+        distribution=$KDEB_CHANGELOG_DIST
+elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ]; then
+        : # nothing to do in this case
+else
+        distribution="unstable"
+        echo >&2 "Using default distribution of 'unstable' in the changelog"
+        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
+fi
+
 # Generate a simple changelog template
 cat <<EOF > debian/changelog
-linux-upstream ($packageversion) unstable; urgency=low
+linux-upstream ($packageversion) $distribution; urgency=low
 
   * Custom built Linux kernel.