builddeb: Try to determine distribution
RFC v3 1/1 builddeb: Try to determine distribution
Like in my initial patch [1] lsb_release is a good choice to determine the distribution name for debian/changelog. Its installation is no precondition.
Ben gave some helpful and detailed information in [2]. There he also suggested to have an option to explicitly set the distribution name (see $KDEB_CHANGELOG_DIST variable).
I have hardcoded the script-name into the outputs when we fallback to the default distribution name. This is a bit ugly.
Based on the snippet of Ben (see [2]).
Tested against Linux v3.19-rc2.
Thanks goes to Thorsten and Alexander for the vital help in 2012. Equally thanks to maximilian and Ben for the comments on my patches.
[1] https://lkml.org/lkml/2012/4/23/516
[2] http://marc.info/?l=linux-kbuild&m=142022188322321&w=2
---
v3: Massaged the commit-message
v2: Suppress error messages when lsb_release is not installed.
(Thanks maximilian and Ben.)
scripts/package/builddeb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
scripts/package/builddeb +13 -1
@@ -217,9 +217,21 @@ else fi maintainer="$name <$email>" +# Try to determine distribution +codename=$(lsb_release --codename --short 2> /dev/null) +if [ -n "$KDEB_CHANGELOG_DIST" ]; then + distribution=$KDEB_CHANGELOG_DIST +elif [ -n "$codename" ]; then + distribution=$codename +else + distribution="unstable" + echo "builddeb: Using default distribution of 'unstable' in the changelog" + echo "builddeb: Install lsb-release or set \$KDEB_CHANGELOG_DIST to change this" +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
Sedat Dilek dixit:
scripts/package/builddeb else · line 224
Quoted 5 lines
scripts/package/builddeb +5
-0+# Try to determine distribution +codename=$(lsb_release --codename --short 2> /dev/null) +if [ -n "$KDEB_CHANGELOG_DIST" ]; then + distribution=$KDEB_CHANGELOG_DIST +elif [ -n "$codename" ]; then
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:
if test -n "$KDEB_CHANGELOG_DIST"; then
distribution=$KDEB_CHANGELOG_DIST
elif distribution=$(lsb_release -cs 2>/dev/null) && test -n "$distribution"; then
:
else
distribution=unstable
echo "builddeb: Using default distribution of 'unstable' in the changelog" echo "builddeb: Set \$KDEB_CHANGELOG_DIST or install lsb-release to change this"
fi
bye,
//mirabilos
Signature · 4 lines
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund, mksh auf jedem System zu installieren.“ -- XTaran auf der OpenRheinRuhr, ganz begeistert (EN: “[…]uhr.gz is a reason to install mksh on every system.”)
Quoted 16 lines · Thorsten Glaser
Sedat Dilek dixit:
scripts/package/builddeb else · line 224
Quoted 5 lines
scripts/package/builddeb +5
-0+# Try to determine distribution +codename=$(lsb_release --codename --short 2> /dev/null) +if [ -n "$KDEB_CHANGELOG_DIST" ]; then + distribution=$KDEB_CHANGELOG_DIST +elif [ -n "$codename" ]; thenThis is suboptimal: if
KDEB_CHANGELOG_DISTis defined,lsb_releaseis not necessary. The following snippet also omits using its output if it fails but still produces any:if test -n "$KDEB_CHANGELOG_DIST"; then
distribution=$KDEB_CHANGELOG_DIST
elif distribution=$(lsb_release -cs 2>/dev/null) && test -n "$distribution"; then
Quoted 7 lines
:else
distribution=unstable
echo "builddeb: Using default distribution of 'unstable' in the changelog" echo "builddeb: Set \$KDEB_CHANGELOG_DIST or install lsb-release to change this"
fi
Happy 2015 mira!
Ben suggested originally...
So how about something like:
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
distribution="$KDEB_CHANGELOG_DIST"
elif ! distribution="$(lsb_release --codename --short 2>/dev/null)"; then
distribution=unstable
echo "I: Using default distribution of 'unstable' in the changelog" echo "I: Install lsb-release or set \$KDEB_CHANGELOG_DIST to
change this"
fi
Is that "inversion" doing the same?
I hoped to do it a bit more "human-readable" (for me) and made it worse.
How can I embed the name of the script "builddeb" into the outputs in case we fall back to default distro-name?
BTW, builddeb is the script invoked via 'make deb-pkg'.
- Sedat -