Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Kernel Team (http://www.linux-archive.org/ubuntu-kernel-team/)
-   -   ktl: simplify and fix debian changelog detection (http://www.linux-archive.org/ubuntu-kernel-team/537939-ktl-simplify-fix-debian-changelog-detection.html)

Andy Whitcroft 06-10-2011 01:28 PM

ktl: simplify and fix debian changelog detection
 
The debian changelog is in one of three places. It is either in a branch
specific changelog, debian/changelog, or meta-source/debian/changelog.
Where a branch specific changelog is present it is always identified via
the debian/debian.env DEBIAN=<directory> stanza. Move to using this to
identify the correct debian changelog. Also move to using a loop over
the possible locations.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
ktl/debian.py | 54 ++++++++++++++++++------------------------------------
1 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/ktl/debian.py b/ktl/debian.py
index 002ecf4..789e795 100644
--- a/ktl/debian.py
+++ b/ktl/debian.py
@@ -41,52 +41,34 @@ class Debian:
#
current_branch = Git.current_branch()

- # The standard location for a changelog is in a directory named 'debian'.
- #
- cl_path = 'debian/changelog'
- debug("Trying '%s': " % cl_path, cls.debug)
+ # If we have a debian/debian.env then open and extract the DEBIAN=...
+ # location.
+ debug("Checking debian/debian.env", cls.debug)
+ cl_paths = []
try:
- retval = Git.show(cl_path, branch=current_branch)
+ debian_env = Git.show("debian/debian.env", branch=current_branch)
+ for line in debian_env:
+ (var, val) = line.split('=', 1)
+ val = val.rstrip()
+
+ if var == 'DEBIAN':
+ cl_paths.append(val + "/changelog")
debug("SUCCEEDED
", cls.debug, False)
except GitError:
debug("FAILED
", cls.debug, False)
- # If this is a kernel tree, the changelog is in a debian.<branch> directory.
- #
- cl_path = 'debian.' + current_branch + '/changelog'
+
+ # Try probabal paths.
+ cl_paths += [ 'debian/changelog', 'meta-source/debian/changelog' ]
+ for cl_path in cl_paths:
debug("Trying '%s': " % cl_path, cls.debug)
try:
retval = Git.show(cl_path, branch=current_branch)
- debug("SUCCEEDED
", cls.debug, False)
+ return retval, cl_path
except GitError:
debug("FAILED
", cls.debug, False)
- # If this is a 'backport' kernel then it could be in the debian.<series>
- # directory.
- #
- debug('Getting the series from the Makefile: ', cls.debug)
- try:
- series = Kernel.series_name()
- debug("SUCCEEDED
", cls.debug, False)
-
- cl_path = 'debian.' + series + '/changelog'
- debug("Trying '%s': " % cl_path, cls.debug)
- retval = Git.show(cl_path, branch=current_branch)
- debug("SUCCEEDED
", cls.debug, False)
- except GitError:
- debug("FAILED
", cls.debug, False)
-
- # If this is a kernel meta package, its in a sub-directory of meta-source.
- #
- if path.exists('meta-source'):
- cl_path = 'meta-source/debian/changelog'
- debug("Trying '%s': " % cl_path, cls.debug)
- try:
- retval = Git.show(cl_path, branch=current_branch)
- except GitError:
- debug("FAILED
", cls.debug, False)
- raise DebianError('Failed to find the changelog.')
- else:
- raise DebianError('Failed to find the changelog.')
- return retval, cl_path
+
+ # Not there anywhere, barf
+ raise DebianError('Failed to find the changelog.')

# changelog
#
--
1.7.4.1


--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team

Leann Ogasawara 06-10-2011 02:46 PM

ktl: simplify and fix debian changelog detection
 
On Fri, 2011-06-10 at 14:28 +0100, Andy Whitcroft wrote:
> The debian changelog is in one of three places. It is either in a branch
> specific changelog, debian/changelog, or meta-source/debian/changelog.
> Where a branch specific changelog is present it is always identified via
> the debian/debian.env DEBIAN=<directory> stanza. Move to using this to
> identify the correct debian changelog. Also move to using a loop over
> the possible locations.
>
> Signed-off-by: Andy Whitcroft <apw@canonical.com>

Acked-by: Leann Ogasawara <leann.ogasawara@canonical.com>

And just in case it's not obvious to everyone:

http://people.canonical.com/~kernel/reports/scripts/ktl/README

"ktl - kteam-tools library

A python module for use in any kteam-tools scripts. A module gives you
namespace separation and a cleaner design."

> ---
> ktl/debian.py | 54 ++++++++++++++++++------------------------------------
> 1 files changed, 18 insertions(+), 36 deletions(-)
>
> diff --git a/ktl/debian.py b/ktl/debian.py
> index 002ecf4..789e795 100644
> --- a/ktl/debian.py
> +++ b/ktl/debian.py
> @@ -41,52 +41,34 @@ class Debian:
> #
> current_branch = Git.current_branch()
>
> - # The standard location for a changelog is in a directory named 'debian'.
> - #
> - cl_path = 'debian/changelog'
> - debug("Trying '%s': " % cl_path, cls.debug)
> + # If we have a debian/debian.env then open and extract the DEBIAN=...
> + # location.
> + debug("Checking debian/debian.env", cls.debug)
> + cl_paths = []
> try:
> - retval = Git.show(cl_path, branch=current_branch)
> + debian_env = Git.show("debian/debian.env", branch=current_branch)
> + for line in debian_env:
> + (var, val) = line.split('=', 1)
> + val = val.rstrip()
> +
> + if var == 'DEBIAN':
> + cl_paths.append(val + "/changelog")
> debug("SUCCEEDED
", cls.debug, False)
> except GitError:
> debug("FAILED
", cls.debug, False)
> - # If this is a kernel tree, the changelog is in a debian.<branch> directory.
> - #
> - cl_path = 'debian.' + current_branch + '/changelog'
> +
> + # Try probabal paths.
> + cl_paths += [ 'debian/changelog', 'meta-source/debian/changelog' ]
> + for cl_path in cl_paths:
> debug("Trying '%s': " % cl_path, cls.debug)
> try:
> retval = Git.show(cl_path, branch=current_branch)
> - debug("SUCCEEDED
", cls.debug, False)
> + return retval, cl_path
> except GitError:
> debug("FAILED
", cls.debug, False)
> - # If this is a 'backport' kernel then it could be in the debian.<series>
> - # directory.
> - #
> - debug('Getting the series from the Makefile: ', cls.debug)
> - try:
> - series = Kernel.series_name()
> - debug("SUCCEEDED
", cls.debug, False)
> -
> - cl_path = 'debian.' + series + '/changelog'
> - debug("Trying '%s': " % cl_path, cls.debug)
> - retval = Git.show(cl_path, branch=current_branch)
> - debug("SUCCEEDED
", cls.debug, False)
> - except GitError:
> - debug("FAILED
", cls.debug, False)
> -
> - # If this is a kernel meta package, its in a sub-directory of meta-source.
> - #
> - if path.exists('meta-source'):
> - cl_path = 'meta-source/debian/changelog'
> - debug("Trying '%s': " % cl_path, cls.debug)
> - try:
> - retval = Git.show(cl_path, branch=current_branch)
> - except GitError:
> - debug("FAILED
", cls.debug, False)
> - raise DebianError('Failed to find the changelog.')
> - else:
> - raise DebianError('Failed to find the changelog.')
> - return retval, cl_path
> +
> + # Not there anywhere, barf
> + raise DebianError('Failed to find the changelog.')
>
> # changelog
> #
> --
> 1.7.4.1
>
>



--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team


All times are GMT. The time now is 10:54 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.