[Piuparts-commits] rev 235 - in trunk: . debian
Holger Levsen
holger at alioth.debian.org
Sun Mar 15 13:54:16 UTC 2009
Author: holger
Date: 2009-03-15 13:54:16 +0000 (Sun, 15 Mar 2009)
New Revision: 235
Modified:
trunk/debian/changelog
trunk/piuparts.docbook
trunk/piuparts.py
Log:
- add support for scanning for packages in changes files, thanks to Andres
Mejia for the patch. (Closes: #352940)
- change some methods from using 'args' to 'package_list'. This more
accurately represents what is being passed into these methods now.
- add an optional parameter to panic() method to specify what exit status
to use. Also thanks to Andres.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2009-03-15 12:30:38 UTC (rev 234)
+++ trunk/debian/changelog 2009-03-15 13:54:16 UTC (rev 235)
@@ -5,6 +5,12 @@
- copy scriptsdir to chroot also when doing upgrade tests.
- ignore modifications of /var/lib/dpkg/triggers/*
- configure apt in chroots to not install recommends and suggests.
+ - add support for scanning for packages in changes files, thanks to Andres
+ Mejia for the patch. (Closes: #352940)
+ - change some methods from using 'args' to 'package_list'. This more
+ accurately represents what is being passed into these methods now.
+ - add an optional parameter to panic() method to specify what exit status
+ to use. Also thanks to Andres.
* piupartslib/packagesdb.py:
- change the test whether a package is testable to check whether the
package is of priority "required", and not whether it's "Essential".
Modified: trunk/piuparts.docbook
===================================================================
--- trunk/piuparts.docbook 2009-03-15 12:30:38 UTC (rev 234)
+++ trunk/piuparts.docbook 2009-03-15 13:54:16 UTC (rev 235)
@@ -59,6 +59,7 @@
<arg><option>-m</option> <replaceable>url</replaceable></arg>
<arg><option>--bindmount</option> <replaceable>dir</replaceable></arg>
<arg><replaceable>package</replaceable></arg>
+ <arg><replaceable>changes_file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -123,11 +124,20 @@
</orderedlist>
- <para>Command line arguments are names of package files by
- default (e.g., <filename>piuparts_1.0-1_all.deb</filename>) or
- names of packages, if the <option>-a</option> option is
- given. All packages will be tested as a group, not one
- by one.</para>
+ <para>Command line arguments are the paths to package files
+ (e.g., <filename>piuparts_1.0-1_all.deb</filename>), paths to
+ changes files (e.g.,
+ <filename>piuparts_1.0-1_i386.changes</filename>),
+ or names of packages, if the <option>--apt</option> option is
+ given. </para>
+
+ <para>When processing changes files, by default, every package in a
+ changes file will be processed together with all individual packages
+ given on the command line. Then each package given on the command line
+ is processed in a single group. If the
+ <option>--single-changes-list</option> is used, the packages in every
+ changes file are processed together along with any individual packages
+ that were given on the command line.</para>
<para><command>piuparts</command> outputs to the standard output
some log messages to show what is going on. If a
@@ -503,6 +513,22 @@
<varlistentry>
+ <term><option>--single-changes-list</option></term>
+
+ <listitem>
+
+ <para>When processing changes files, piuparts will process
+ the packages in each individual changes file seperately.
+ This option will set piuparts to scan the packages of all
+ changes files together along with any individual package
+ files that may have been given on the command line.</para>
+
+ </listitem>
+
+ </varlistentry>
+
+ <varlistentry>
+
<term><option>-v</option></term>
<term><option>--verbose</option></term>
@@ -554,6 +580,17 @@
<programlisting
>piuparts -m 'http://gytha/debian main' ../foo_1.0-2_i386.deb</programlisting>
+ <para>If you want to do the same as above but for your changes
+ files, pass in your changes files when running piuparts, and
+ piuparts will process each package in the changes files as though
+ you had passed all those packages on the command line to piuparts
+ yourself. For example:</para>
+
+ <programlisting>piuparts ../foo_1.0-2_i386.changes</programlisting>
+ <programlisting
+ >piuparts -m 'http://gytha/debian main' ../foo_1.0-2_i386.changes</programlisting>
+
+
<para>If you want to test that a package installs properly
in the stable (etch) Debian release, then can be upgraded
to the testing (lenny) and unstable (sid) versions, and then
Modified: trunk/piuparts.py
===================================================================
--- trunk/piuparts.py 2009-03-15 12:30:38 UTC (rev 234)
+++ trunk/piuparts.py 2009-03-15 13:54:16 UTC (rev 235)
@@ -129,6 +129,7 @@
self.tmpdir = None
self.scriptsdir = None
self.keep_tmpdir = False
+ self.single_changes_list = False
self.max_command_output_size = 1024 * 1024
self.args_are_package_files = True
self.debian_mirrors = []
@@ -310,13 +311,13 @@
handler.flush()
-def panic():
+def panic(exit=1):
for i in range(counter):
if i in on_panic_hooks:
on_panic_hooks[i]()
- sys.exit(1)
-
+ sys.exit(exit)
+
def indent_string(str):
"""Indent all lines in a string with two spaces and return result."""
return "\n".join([" " + line for line in str.split("\n")])
@@ -1384,7 +1385,47 @@
list.append(line.split(":", 1)[1].strip())
return list
+# Method to process a changes file, returning a list of all the .deb packages
+# from the 'Files' stanza.
+def process_changes(changes):
+ # Determine the path to the changes file, then check if it's readable.
+ dir_path = ""
+ changes_path = ""
+ if not os.path.dirname(changes):
+ changes_path = os.path.basename(changes)
+ else:
+ dir_path = os.path.dirname(changes) + "/"
+ changes_path = os.path.abspath(changes)
+ if not os.access(changes_path, os.R_OK):
+ logging.warn(changes_path + " is not readable. Skipping.")
+ return
+ # Determine the packages in the changes file through the 'Files' stanza.
+ field = 'Files'
+ pattern = re.compile(\
+ r'^'+field+r':' + r''' # The field we want the contents from
+ (.*?) # The contents of the field
+ \n([^ ]|$) # Start of a new field or EOF
+ ''',
+ re.MULTILINE | re.DOTALL | re.VERBOSE)
+ f = open(changes_path)
+ file_text = f.read()
+ f.close()
+ matches = pattern.split(file_text)
+
+ # Append all the packages found in the changes file to a package list.
+ package_list = []
+ newline_p = re.compile('\n')
+ package_p = re.compile('.*?([^ ]+\.deb)$')
+ for line in newline_p.split(matches[1]):
+ if package_p.match(line):
+ package = dir_path + package_p.split(line)[1]
+ package_list.append(package)
+
+ # Return the list.
+ return package_list
+
+
def check_results(chroot, root_info, file_owners, deps_info=None):
"""Check that current chroot state matches 'root_info'.
@@ -1446,7 +1487,7 @@
return ok
-def install_purge_test(chroot, root_info, selections, args, packages):
+def install_purge_test(chroot, root_info, selections, package_list, packages):
"""Do an install-purge test. Return True if successful, False if not.
Assume 'root' is a directory already populated with a working
chroot, with packages in states given by 'selections'."""
@@ -1455,11 +1496,11 @@
if settings.warn_on_others:
# Create a metapackage with dependencies from the given packages
- if args:
+ if package_list:
control_infos = []
# We were given package files, so let's get the Depends and
# Conflicts directly from the .debs
- for deb in args:
+ for deb in package_list:
returncode, output = run(["dpkg", "-f", deb])
control = deb822.Deb822(output)
control_infos.append(control)
@@ -1497,8 +1538,8 @@
else:
deps_info = None
- if args:
- chroot.install_package_files(args)
+ if package_list:
+ chroot.install_package_files(package_list)
else:
chroot.install_packages_by_name(packages)
chroot.run(["apt-get", "clean"])
@@ -1518,7 +1559,7 @@
return check_results(chroot, root_info, file_owners, deps_info=deps_info)
-def install_upgrade_test(chroot, root_info, selections, args, package_names):
+def install_upgrade_test(chroot, root_info, selections, package_list, package_names):
"""Install package via apt-get, then upgrade from package files.
Return True if successful, False if not."""
@@ -1531,7 +1572,7 @@
chroot.check_for_broken_symlinks()
# Then from the package files.
- chroot.install_package_files(args)
+ chroot.install_package_files(package_list)
file_owners = chroot.get_files_owned_by_packages()
@@ -1785,7 +1826,11 @@
parser.add_option("-t", "--tmpdir", metavar="DIR",
help="Use DIR for temporary storage. Default is " +
"$TMPDIR or /tmp.")
-
+
+ parser.add_option("--single-changes-list", default=False,
+ action="store_true",
+ help="test all packages from all changes files together.")
+
parser.add_option("-v", "--verbose",
action="store_true", default=False,
help="No meaning anymore.")
@@ -1793,6 +1838,7 @@
parser.add_option("--debfoster-options",
default="-o MaxPriority=required -o UseRecommends=no -f -n apt debfoster",
help="Run debfoster with different parameters (default: -o MaxPriority=required -o UseRecommends=no -f -n apt debfoster).")
+
(opts, args) = parser.parse_args()
@@ -1804,6 +1850,7 @@
settings.ignored_files += opts.ignore
settings.ignored_patterns += opts.ignore_regex
settings.keep_tmpdir = opts.keep_tmpdir
+ settings.single_changes_list = opts.single_changes_list
settings.keep_sources_list = opts.keep_sources_list
settings.skip_minimize = opts.skip_minimize
settings.list_installed_files = opts.list_installed_files
@@ -1878,26 +1925,14 @@
if settings.adt_virt is None: return Chroot()
return settings.adt_virt
-def main():
- """Main program. But you knew that."""
-
- args = parse_command_line()
-
- logging.info("-" * 78)
- logging.info("piuparts version %s starting up." % VERSION)
- logging.info("Command line arguments: %s" % " ".join(sys.argv))
- logging.info("Running on: %s %s %s %s %s" % os.uname())
-
- # Make sure debconf does not ask questions and stop everything.
- # Packages that don't use debconf will lose.
- os.environ["DEBIAN_FRONTEND"] = "noninteractive"
-
+# Process the packages given in a list
+def process_packages(package_list):
# Find the names of packages.
if settings.args_are_package_files:
- packages = get_package_names_from_package_files(args)
+ packages = get_package_names_from_package_files(package_list)
else:
- packages = args
- args = []
+ packages = package_list
+ package_list = []
if len(settings.debian_distros) == 1:
chroot = get_chroot()
@@ -1908,7 +1943,7 @@
selections = chroot.get_selections()
if not install_purge_test(chroot, root_info, selections,
- args, packages):
+ package_list, packages):
logging.error("FAIL: Installation and purging test.")
panic()
logging.info("PASS: Installation and purging test.")
@@ -1918,7 +1953,7 @@
logging.info("Can't test upgrades: -a or --apt option used.")
elif not chroot.apt_get_knows(packages):
logging.info("Can't test upgrade: packages not known by apt-get.")
- elif install_upgrade_test(chroot, root_info, selections, args,
+ elif install_upgrade_test(chroot, root_info, selections, package_list,
packages):
logging.info("PASS: Installation, upgrade and purging tests.")
else:
@@ -1928,7 +1963,7 @@
chroot.remove()
dont_do_on_panic(id)
else:
- if install_and_upgrade_between_distros(args, packages):
+ if install_and_upgrade_between_distros(package_list, packages):
logging.info("PASS: Upgrading between Debian distributions.")
else:
logging.error("FAIL: Upgrading between Debian distributions.")
@@ -1936,6 +1971,42 @@
if settings.adt_virt is not None: settings.adt_virt.shutdown()
+def main():
+ """Main program. But you knew that."""
+
+ args = parse_command_line()
+
+ logging.info("-" * 78)
+ logging.info("piuparts version %s starting up." % VERSION)
+ logging.info("Command line arguments: %s" % " ".join(sys.argv))
+ logging.info("Running on: %s %s %s %s %s" % os.uname())
+
+ # Make sure debconf does not ask questions and stop everything.
+ # Packages that don't use debconf will lose.
+ os.environ["DEBIAN_FRONTEND"] = "noninteractive"
+
+
+ changes_packages_list = []
+ regular_packages_list = []
+ changes_p = re.compile('.*\.changes$')
+ for arg in args:
+ if changes_p.match(arg):
+ package_list = process_changes(arg)
+ if settings.single_changes_list:
+ for package in package_list:
+ regular_packages_list.append(package)
+ else:
+ changes_packages_list.append(package_list)
+ else:
+ regular_packages_list.append(arg)
+
+ if changes_packages_list:
+ for package_list in changes_packages_list:
+ process_packages(package_list)
+
+ if regular_packages_list:
+ process_packages(regular_packages_list)
+
logging.info("PASS: All tests.")
logging.info("piuparts run ends.")
More information about the Piuparts-commits
mailing list