Skip to contentSkip to conversation

builddeb: Try to determine distribution

RFC Superseded Sedat Dilek 3 participants 4 messages Jan 3, 2015 Kbuild

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

RFC v5 1/1 builddeb: Try to determine distribution

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 <[email protected]>
CC maximilian attems <[email protected]>
CC Thorsten Glaser <[email protected]>
CC Alexander Wirt <[email protected]>
CC Michal Marek <[email protected]>

---
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(-)
scripts/package/builddeb +12 -1
index 5972624..f631c77 100755
@@ -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.
 
Signature · 1 line
2.2.1
Reviewed-by on v5 1/1
#1 lore raw
Quoted 27 lines · Sedat Dilek

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.

Quoted 8 lines

[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 <[email protected]>
Quoted 44 lines

---
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(-)
scripts/package/builddeb +12 -1
index 5972624..f631c77 100755
@@ -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.
 
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
                                - John Levine, moderator of comp.compilers
#2 lore raw
Quoted 35 lines · Ben Hutchings
Quoted 34 lines · Sedat Dilek

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

Quoted 3 lines
Quoted 1 line
CC Ben Hutchings <[email protected]>
Quoted 50 lines
Quoted 45 lines

---
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(-)
scripts/package/builddeb +12 -1
index 5972624..f631c77 100755
@@ -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.
 
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
                                - John Levine, moderator of comp.compilers
#3 lore raw
Quoted 36 lines · maximilian attems
Quoted 35 lines · Ben Hutchings
Quoted 34 lines · Sedat Dilek

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

Quoted 4 lines
Quoted 3 lines
Quoted 1 line
CC Ben Hutchings <[email protected]>

Thanks Ben and maximilian.

I will send out a proper patch with your Reviewed-by and Acked-by, also add a R-b for the snippet of Thorsten.

- Sedat -

Quoted 52 lines
Quoted 50 lines
Quoted 35 lines

---
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(-)
scripts/package/builddeb +8 -0
index 5972624..f631c77 100755
@@ -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"

scripts/package/builddeb else · line 236

Quoted 10 lines
scripts/package/builddeb +4 -1
+        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.
 

--
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilers