Forgot one change from the previous patch. In the process_changes() method, I changed from using a print statement to using logging.warn() when a changes file that was passed in isn't readable.
-- Regards, Andres
diff -urN piuparts-0.33/debian/changelog piuparts-0.33.01/debian/changelog --- piuparts-0.33/debian/changelog 2008-11-08 12:07:41.000000000 -0500 +++ piuparts-0.33.01/debian/changelog 2008-12-07 22:52:26.000000000 -0500 @@ -1,3 +1,9 @@ +piuparts (0.33.01) unstable; urgency=low + + * Allow piuparts to scan packages in a changes file. + + -- Andres Mejia <[EMAIL PROTECTED]> Sun, 07 Dec 2008 21:43:55 -0500 + piuparts (0.33) unstable; urgency=low * Added --bindmount option, thanks to AnĂbal Monsalve Salaza for the patch. diff -urN piuparts-0.33/piuparts.docbook piuparts-0.33.01/piuparts.docbook --- piuparts-0.33/piuparts.docbook 2008-11-08 12:05:59.000000000 -0500 +++ piuparts-0.33.01/piuparts.docbook 2008-12-07 23:05:42.000000000 -0500 @@ -58,6 +58,7 @@ <arg><option>-l</option> <replaceable>logfile</replaceable></arg> <arg><option>-m</option> <replaceable>url</replaceable></arg> <arg><option>--bindmount</option> <replaceable>dir</replaceable></arg> + <arg><replaceable>changes_file</replaceable></arg> <arg><replaceable>package</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> @@ -123,11 +124,18 @@ </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 changes files + (e.g., <filename>piuparts_1.0-1_i386.changes</filename>), + paths to package files + (e.g., <filename>piuparts_1.0-1_all.deb</filename>), or + names of packages, if the <option>--apt</option> option is + given. When processing changes files, by default, every package in a + changes file will be processed together per each individual changes file + 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 is processed together along with any individual packages + that was 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 +511,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 +578,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 diff -urN piuparts-0.33/piuparts.py piuparts-0.33.01/piuparts.py --- piuparts-0.33/piuparts.py 2008-11-08 12:05:35.000000000 -0500 +++ piuparts-0.33.01/piuparts.py 2008-12-08 20:17:59.000000000 -0500 @@ -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 = [] @@ -309,12 +310,12 @@ 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.""" @@ -1336,6 +1337,46 @@ 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'. @@ -1398,7 +1439,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'.""" @@ -1407,11 +1448,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) @@ -1449,8 +1490,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"]) @@ -1470,7 +1511,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.""" @@ -1483,7 +1524,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() @@ -1737,7 +1778,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.") @@ -1745,6 +1790,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() @@ -1756,6 +1802,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 @@ -1830,26 +1877,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() @@ -1868,7 +1903,7 @@ shutil.copy(os.path.join((settings.scriptsdir), file), dest) 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.") @@ -1878,7 +1913,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: @@ -1888,7 +1923,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.") @@ -1896,6 +1931,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.")
signature.asc
Description: This is a digitally signed message part.