From patchwork Tue Jan 6 13:35:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sedat Dilek X-Patchwork-Id: 5573661 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8A92C9F2ED for ; Tue, 6 Jan 2015 13:35:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B34C20114 for ; Tue, 6 Jan 2015 13:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 872BB200FE for ; Tue, 6 Jan 2015 13:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753908AbbAFNfe (ORCPT ); Tue, 6 Jan 2015 08:35:34 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:51545 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752885AbbAFNfd (ORCPT ); Tue, 6 Jan 2015 08:35:33 -0500 Received: by mail-wg0-f42.google.com with SMTP id k14so29578497wgh.15 for ; Tue, 06 Jan 2015 05:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=b6kAHu5u+pB+tCKh2xbsG95TeD30L9EpQUrdhHOY2/o=; b=gxGe8PaFVM4EKPpB7QVtLk7wchJPqyeMJY2ssKTCEMph367mrMr3eqMtupghUt08ZK 8bQwEYU3KEBYHuI8yWgJ/hL/PB12f00VqbU0vgtQ07v3ZJgwgQQKhWhPKMBAGW9wUuo5 ZMrNoI0UIHlwl8CaObUeq0xl6WitY0baBbuuuN6aiCCTVZGbDxNPMrgiZoTWXIrTkgCi ZaIxJ7NWY0sIX3zykliVo/AjJS7EpJFtMJ2mMHGdsXHpXuXk3vsnwQ1P6fN8KyBYmVUY hWI85vl6mNiknagfG5u+IBFJ4hjKmsum73HvJ0/BiS87lC3jbLNJchM8bTZF1vp0pMVj 5YdQ== X-Received: by 10.180.74.146 with SMTP id t18mr36404115wiv.62.1420551332293; Tue, 06 Jan 2015 05:35:32 -0800 (PST) Received: from fambox.fambox-domain ([46.115.149.32]) by mx.google.com with ESMTPSA id n3sm14004603wiw.5.2015.01.06.05.35.30 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Jan 2015 05:35:31 -0800 (PST) From: Sedat Dilek Cc: Sedat Dilek , Ben Hutchings , maximilian attems , Thorsten Glaser , Alexander Wirt , Michal Marek , linux-kbuild@vger.kernel.org Subject: [PATCH v7] builddeb: Try to determine distribution Date: Tue, 6 Jan 2015 14:35:19 +0100 Message-Id: <1420551319-12961-1-git-send-email-sedat.dilek@gmail.com> X-Mailer: git-send-email 2.2.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 [6]). 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 CC: maximilian attems CC: Thorsten Glaser CC: Alexander Wirt CC: Michal Marek CC: linux-kbuild@vger.kernel.org Suggested-by: Ben Hutchings Suggested-by: Thorsten Glaser Reviewed-by: Ben Hutchings [ dileks: Thorsten reviewed his suggested diff in RFC v4 ] Reviewed-by: Thorsten Glaser Acked-by: maximilian attems Signed-off-by: Sedat Dilek --- v7: Correct Thorsten's email-address in the Reviewed-by line Correct reference to URL [6] and fix some more typos 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 < debian/changelog -linux-upstream ($packageversion) unstable; urgency=low +linux-upstream ($packageversion) $distribution; urgency=low * Custom built Linux kernel.