Binary files /tmp/8s_rqFSitQ/unattended-upgrades-0.79.3ubuntu3/__pycache__/unattended-upgrade.cpython-32.pyc and /tmp/z6zaiT7pU3/unattended-upgrades-0.79.3ubuntu4/__pycache__/unattended-upgrade.cpython-32.pyc differ diff -Nru unattended-upgrades-0.79.3ubuntu3/debian/changelog unattended-upgrades-0.79.3ubuntu4/debian/changelog --- unattended-upgrades-0.79.3ubuntu3/debian/changelog 2012-10-05 16:01:59.000000000 +0000 +++ unattended-upgrades-0.79.3ubuntu4/debian/changelog 2012-10-09 08:10:35.000000000 +0000 @@ -1,3 +1,11 @@ +unattended-upgrades (0.79.3ubuntu4) quantal; urgency=low + + * lp:~mvo/unattended-upgrades/minimal-step-paranonia-lp1020680: + - ensure the blacklist/origin constrains are never violated for + some corner cases in the minimal-upgrade mode (LP: #1020680) + + -- Michael Vogt Tue, 09 Oct 2012 10:08:01 +0200 + unattended-upgrades (0.79.3ubuntu3) quantal; urgency=low * lp:~mvo/unattended-upgrades/lp1061498: Binary files /tmp/8s_rqFSitQ/unattended-upgrades-0.79.3ubuntu3/test/.coverage and /tmp/z6zaiT7pU3/unattended-upgrades-0.79.3ubuntu4/test/.coverage differ diff -Nru unattended-upgrades-0.79.3ubuntu3/test/test_conffile.py unattended-upgrades-0.79.3ubuntu4/test/test_conffile.py --- unattended-upgrades-0.79.3ubuntu3/test/test_conffile.py 2012-10-05 14:58:58.000000000 +0000 +++ unattended-upgrades-0.79.3ubuntu4/test/test_conffile.py 2012-10-09 08:11:45.000000000 +0000 @@ -56,9 +56,10 @@ test_pkg = "./packages/conf-test-package-new-conffile_1.deb" self.assertTrue(conffile_prompt(test_pkg, prefix="./root.conffile"), "conffile prompt detection incorrect") - + + class DpkgConffileTestCase(unittest.TestCase): - """ + """ This tests that the detection if dpkg will prompt at all works, i.e. if the user has decided to use a --force-conf{old,new} option """ diff -Nru unattended-upgrades-0.79.3ubuntu3/test/test_minimal_partitions.py unattended-upgrades-0.79.3ubuntu4/test/test_minimal_partitions.py --- unattended-upgrades-0.79.3ubuntu3/test/test_minimal_partitions.py 2012-10-05 14:21:52.000000000 +0000 +++ unattended-upgrades-0.79.3ubuntu4/test/test_minimal_partitions.py 2012-10-09 07:59:03.000000000 +0000 @@ -43,7 +43,7 @@ "./aptroot/var/run/unatteded-upgrades.progress" unattended_upgrade.LogInstallProgress = LogInstallProgressMock unattended_upgrade.upgrade_in_minimal_steps( - self.cache, pkgs_to_upgrade) + self.cache, pkgs_to_upgrade, "", []) # ensure we count upwarts last_percent = -1 for (pkg, percent) in LogInstallProgressMock.DATA: diff -Nru unattended-upgrades-0.79.3ubuntu3/test/unattended_upgrade.py unattended-upgrades-0.79.3ubuntu4/test/unattended_upgrade.py --- unattended-upgrades-0.79.3ubuntu3/test/unattended_upgrade.py 2012-10-05 15:35:17.000000000 +0000 +++ unattended-upgrades-0.79.3ubuntu4/test/unattended_upgrade.py 2012-10-09 07:59:03.000000000 +0000 @@ -307,7 +307,7 @@ return res -def upgrade_in_minimal_steps(cache, pkgs_to_upgrade, logfile_dpkg=""): +def upgrade_in_minimal_steps(cache, pkgs_to_upgrade, logfile_dpkg, blacklist): install_log = LogInstallProgress() install_log.LOG += ".minimal-steps" @@ -315,6 +315,9 @@ # setup signal handler signal.signal(signal.SIGUSR1, signal_handler) + # double check any changes we do + allowed_origins = get_allowed_origins() + # to upgrade contains the package names to_upgrade = set(pkgs_to_upgrade) while True: @@ -331,6 +334,13 @@ pkg.mark_install() else: continue + # double check that we are not running into side effects like + # what could have been caused LP: #1020680 + if not check_changes_for_sanity(cache, allowed_origins, blacklist): + logging.error( + "Internal error while building a minimal partition." + "Cache has not allowed changes") + return False changes = [pkg.name for pkg in cache.get_changes()] if len(changes) == 1: logging.debug("found leaf package %s" % pkg.name) @@ -670,7 +680,8 @@ logging.debug("mail returned: %s" % ret) -def do_install(cache, pkgs_to_upgrade, options, logfile_dpkg): +def do_install(cache, pkgs_to_upgrade, blacklisted_pkgs, options, + logfile_dpkg): # set debconf to NON_INTERACTIVE, redirect output os.putenv("DEBIAN_FRONTEND", "noninteractive") setup_apt_listchanges() @@ -704,7 +715,8 @@ fp.write("%s" % os.getpid()) # try upgrade all "pkgs" in minimal steps pkg_install_success = upgrade_in_minimal_steps( - cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg) + cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg, + blacklisted_pkgs) else: pkg_install_success = upgrade_normal( cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg) @@ -775,6 +787,10 @@ return mem_log +def get_blacklisted_pkgs(): + return apt_pkg.config.value_list("Unattended-Upgrade::Package-Blacklist") + + def main(options, rootdir=""): # useful for testing @@ -788,8 +804,7 @@ allowed_origins = get_allowed_origins() # pkgs that are (for some reason) not save to install - blacklisted_pkgs = apt_pkg.config.value_list( - "Unattended-Upgrade::Package-Blacklist") + blacklisted_pkgs = get_blacklisted_pkgs() logging.info(_("Initial blacklisted packages: %s"), " ".join(blacklisted_pkgs)) logging.info(_("Starting unattended upgrades script")) @@ -1020,7 +1035,7 @@ shutdown_lock = apt_pkg.get_lock("/var/run/unattended-upgrades.lock") # do install pkg_install_success = do_install( - cache, pkgs_to_upgrade, options, logfile_dpkg) + cache, pkgs_to_upgrade, blacklisted_pkgs, options, logfile_dpkg) # send a mail (if needed) if not options.dry_run: Binary files /tmp/8s_rqFSitQ/unattended-upgrades-0.79.3ubuntu3/test/unattended_upgrade.pyc and /tmp/z6zaiT7pU3/unattended-upgrades-0.79.3ubuntu4/test/unattended_upgrade.pyc differ diff -Nru unattended-upgrades-0.79.3ubuntu3/unattended-upgrade unattended-upgrades-0.79.3ubuntu4/unattended-upgrade --- unattended-upgrades-0.79.3ubuntu3/unattended-upgrade 2012-10-05 15:35:17.000000000 +0000 +++ unattended-upgrades-0.79.3ubuntu4/unattended-upgrade 2012-10-09 07:59:03.000000000 +0000 @@ -307,7 +307,7 @@ return res -def upgrade_in_minimal_steps(cache, pkgs_to_upgrade, logfile_dpkg=""): +def upgrade_in_minimal_steps(cache, pkgs_to_upgrade, logfile_dpkg, blacklist): install_log = LogInstallProgress() install_log.LOG += ".minimal-steps" @@ -315,6 +315,9 @@ # setup signal handler signal.signal(signal.SIGUSR1, signal_handler) + # double check any changes we do + allowed_origins = get_allowed_origins() + # to upgrade contains the package names to_upgrade = set(pkgs_to_upgrade) while True: @@ -331,6 +334,13 @@ pkg.mark_install() else: continue + # double check that we are not running into side effects like + # what could have been caused LP: #1020680 + if not check_changes_for_sanity(cache, allowed_origins, blacklist): + logging.error( + "Internal error while building a minimal partition." + "Cache has not allowed changes") + return False changes = [pkg.name for pkg in cache.get_changes()] if len(changes) == 1: logging.debug("found leaf package %s" % pkg.name) @@ -670,7 +680,8 @@ logging.debug("mail returned: %s" % ret) -def do_install(cache, pkgs_to_upgrade, options, logfile_dpkg): +def do_install(cache, pkgs_to_upgrade, blacklisted_pkgs, options, + logfile_dpkg): # set debconf to NON_INTERACTIVE, redirect output os.putenv("DEBIAN_FRONTEND", "noninteractive") setup_apt_listchanges() @@ -704,7 +715,8 @@ fp.write("%s" % os.getpid()) # try upgrade all "pkgs" in minimal steps pkg_install_success = upgrade_in_minimal_steps( - cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg) + cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg, + blacklisted_pkgs) else: pkg_install_success = upgrade_normal( cache, [pkg.name for pkg in pkgs_to_upgrade], logfile_dpkg) @@ -775,6 +787,10 @@ return mem_log +def get_blacklisted_pkgs(): + return apt_pkg.config.value_list("Unattended-Upgrade::Package-Blacklist") + + def main(options, rootdir=""): # useful for testing @@ -788,8 +804,7 @@ allowed_origins = get_allowed_origins() # pkgs that are (for some reason) not save to install - blacklisted_pkgs = apt_pkg.config.value_list( - "Unattended-Upgrade::Package-Blacklist") + blacklisted_pkgs = get_blacklisted_pkgs() logging.info(_("Initial blacklisted packages: %s"), " ".join(blacklisted_pkgs)) logging.info(_("Starting unattended upgrades script")) @@ -1020,7 +1035,7 @@ shutdown_lock = apt_pkg.get_lock("/var/run/unattended-upgrades.lock") # do install pkg_install_success = do_install( - cache, pkgs_to_upgrade, options, logfile_dpkg) + cache, pkgs_to_upgrade, blacklisted_pkgs, options, logfile_dpkg) # send a mail (if needed) if not options.dry_run: