Package: python-central
Version: 0.6.8
Severity: normal
Tags: patch
I have added support for reporting pycentral-managed files to cruft.
This incidentaly adds two commands to pycentral: pkglist and list.
-- System Information:
Debian Release: lenny/sid
APT prefers hardy-updates
APT policy: (500, 'hardy-updates'), (500, 'hardy-security'), (500,
'hardy-proposed'), (500, 'hardy-backports'), (500, 'hardy')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.24-20-generic (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages python-central depends on:
ii python 2.5.2-0ubuntu1 An interactive high-level object-o
python-central recommends no packages.
-- no debconf information
>From c4d70217dd90c628e59422c59b50c9d47c28e0ef Mon Sep 17 00:00:00 2001
From: Gabriel de Perthuis <[EMAIL PROTECTED]>
Date: Wed, 6 Aug 2008 18:01:54 +0200
Subject: [PATCH] Add pkglist command, to list pycentral-managed files for a specific package.
---
pycentral.1 | 3 ++
pycentral.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/pycentral.1 b/pycentral.1
index 36088c2..216b7d7 100644
--- a/pycentral.1
+++ b/pycentral.1
@@ -37,6 +37,9 @@ Prepare a package for all supported runtimes.
.I pkgremove
Remove a package installed for all supported runtimes.
.TP
+.I pkglist
+List pycentral-managed files of a package for all supported runtimes.
+.TP
.I rtinstall
Make installed packages available for this runtime.
.TP
diff --git a/pycentral.py b/pycentral.py
index c10c587..6ddb610 100755
--- a/pycentral.py
+++ b/pycentral.py
@@ -197,6 +197,13 @@ class PythonRuntime:
if errors:
raise PyCentralError, 'error removing the byte-code files'
+ def list_byte_code(self, files):
+ logging.debug('\tremove byte-code files (%d)' % (len(files)))
+ for ext in ('c', 'o'):
+ for fn in files:
+ fnc = fn + ext
+ yield fnc
+
installed_runtimes = None
default_runtime = None
@@ -869,6 +876,15 @@ class DebPackage:
if os.path.exists(fn2):
os.unlink(fn2)
+ def list_shared_files(self, rt):
+ logging.debug('\tlist_shared_files %s/%s' % (rt.name, self.name))
+ if not self.shared_files:
+ return
+ ppos = len(self.shared_prefix)
+ for fn in self.shared_files:
+ fn2 = rt.prefix + fn[ppos:]
+ yield fn2
+
def install(self, runtimes, bc_option, exclude_regex,
byte_compile_default=True, ignore_errors=False):
@@ -1074,6 +1090,32 @@ class DebPackage:
if self.private_files:
default_runtime.remove_byte_code(self.private_files)
+ def list(self, runtimes, list_script_files=True):
+ logging.debug('\tlist package %s' % self.name)
+ # list shared .py files
+ if self.shared_files:
+ ppos = len(self.shared_prefix)
+ for rt in runtimes:
+ linked_files = [ rt.prefix + fn[ppos:]
+ for fn in self.shared_files
+ if fn[-3:] == '.py']
+ for f in default_runtime.list_byte_code(linked_files):
+ yield f
+ for f in self.list_shared_files(rt):
+ yield f
+ # list byte compiled files inside prefix
+ if self.pylib_files:
+ for pyver, files in self.pylib_files.items():
+ rt = get_runtime_for_version(pyver)
+ if rt in runtimes:
+ for f in default_runtime.list_byte_code(files):
+ yield f
+ # list byte code for script files
+ if list_script_files:
+ if self.private_files:
+ for f in default_runtime.list_byte_code(self.private_files):
+ yield f
+
def update_bytecode_files(self, runtimes, rt_default, bc_option):
# byte-compile with default python version
logging.debug('\tupdate byte-code for %s' % self.name)
@@ -1414,6 +1456,37 @@ class ActionPkgRemove(Action):
register_action(ActionPkgRemove)
+class ActionPkgList(Action):
+ name = 'pkglist'
+ help = 'list all pycentral-managed files for <package>'
+ usage = '<package>'
+
+ def check_args(self, global_options):
+ if len(self.args) != 1:
+ self._option_parser.print_help()
+ sys.exit(1)
+ self.pkgname = self.args[0]
+ if not os.path.exists('/var/lib/dpkg/info/%s.list' % self.pkgname):
+ self.error("package %s is not installed" % self.pkgname)
+ return self.errors_occured
+
+ def run(self, global_options):
+ runtimes = get_installed_runtimes(with_unsupported=True)
+ pkg = DebPackage('package', self.args[0], oldstyle=False)
+ pkg.read_version_info()
+ try:
+ pkg.set_default_runtime_from_version_info()
+ except ValueError:
+ # original runtime may be removed, use the default
+ pkg.default_runtime = get_default_runtime()
+ try:
+ for f in pkg.list(runtimes, list_script_files=True):
+ print f
+ except PyCentralError, msg:
+ self.error(msg)
+
+register_action(ActionPkgList)
+
class ActionRuntimeInstall(Action):
name = 'rtinstall'
--
1.6.0.rc1.64.g61192
>From 40d63992837c30378de9620941c969add3be1e0e Mon Sep 17 00:00:00 2001
From: Gabriel de Perthuis <[EMAIL PROTECTED]>
Date: Wed, 6 Aug 2008 18:20:33 +0200
Subject: [PATCH] Add 'list' action.
---
pycentral.1 | 3 +++
pycentral.py | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/pycentral.1 b/pycentral.1
index 216b7d7..9f825d9 100644
--- a/pycentral.1
+++ b/pycentral.1
@@ -28,6 +28,9 @@ Byte compile .py files in a package.
.I bcremove
Remove the byte compiled .py files.
.TP
+.I list
+List all managed files.
+.TP
.I pkginstall
Make a package available for all supported runtimes.
.TP
diff --git a/pycentral.py b/pycentral.py
index 6ddb610..a1a63aa 100755
--- a/pycentral.py
+++ b/pycentral.py
@@ -1666,6 +1666,27 @@ class ActionUpdateDefault(Action):
register_action(ActionUpdateDefault)
+class ActionList(Action):
+ name = 'list'
+ help = 'List all pycentral-managed files'
+
+ def check_args(self, global_options):
+ if len(self.args) != 0:
+ self._option_parser.print_help()
+ sys.exit(1)
+ return self.errors_occured
+
+ def run(self, global_options):
+ runtimes = get_installed_runtimes(with_unsupported=True)
+ for (p, v) in read_dpkg_status():
+ pkg = DebPackage('package', p)
+ pkg.read_version_info()
+ for f in pkg.list(runtimes, list_script_files=True):
+ print f
+
+register_action(ActionList)
+
+
class ActionShowDefault(Action):
name = 'showdefault'
help = 'Show default python version number'
--
1.6.0.rc1.64.g61192
>From ce217de42b52d7f85ad5ecd9d10fa808b4a6fef4 Mon Sep 17 00:00:00 2001
From: Gabriel de Perthuis <[EMAIL PROTECTED]>
Date: Wed, 6 Aug 2008 18:39:41 +0200
Subject: [PATCH] Add a cruft explain script.
Cruft will pick up this script automatically.
The script tells cruft that pycentral-managed files
have a valid reason for being on the system.
---
debian/dirs | 1 +
debian/rules | 2 ++
python-central.explain | 2 ++
3 files changed, 5 insertions(+), 0 deletions(-)
create mode 100755 python-central.explain
diff --git a/debian/dirs b/debian/dirs
index 891bf2f..2d3cebc 100644
--- a/debian/dirs
+++ b/debian/dirs
@@ -1,4 +1,5 @@
usr/bin
+usr/lib/cruft/explain
usr/share/pycentral-data
usr/share/debhelper/autoscripts
usr/share/python/runtime.d
diff --git a/debian/rules b/debian/rules
index abf54ef..3730124 100755
--- a/debian/rules
+++ b/debian/rules
@@ -39,6 +39,8 @@ install: build
debian/$(PACKAGE)/usr/share/python/runtime.d/
install -m644 python_central.pm \
debian/$(PACKAGE)/usr/share/perl5/Debian/Debhelper/Sequence/
+ install -m755 python-central.explain \
+ debian/$(PACKAGE)/usr/lib/cruft/explain/python-central
# Build architecture-independent files here.
binary-indep: build install
diff --git a/python-central.explain b/python-central.explain
new file mode 100755
index 0000000..c62be42
--- /dev/null
+++ b/python-central.explain
@@ -0,0 +1,2 @@
+#!/bin/sh
+pycentral list >&3
--
1.6.0.rc1.64.g61192