2015-04-26 18:20:10 +02:00
#!/usr/bin/python3 -u
2006-08-18 22:50:52 +00:00
# -*- coding: utf-8 -*-
2006-06-17 13:45:56 +00:00
2008-04-29 05:08:58 +00:00
# Copyright (C) 2001-2008 Anthony Towns <ajt@debian.org>
2006-06-17 13:45:56 +00:00
# Andreas Barth <aba@debian.org>
# Fabio Tranchitella <kobold@debian.org>
2013-09-07 18:21:00 +00:00
# Copyright (C) 2010-2013 Adam D. Barratt <adsb@debian.org>
2006-06-17 13:45:56 +00:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
2006-06-24 17:49:43 +00:00
"""
2015-04-26 18:20:09 +02:00
= Introduction =
2006-06-24 17:49:43 +00:00
This is the Debian testing updater script , also known as " Britney " .
Packages are usually installed into the ` testing ' distribution after
they have undergone some degree of testing in unstable . The goal of
this software is to do this task in a smart way , allowing testing
2013-09-18 20:40:00 +00:00
to always be fully installable and close to being a release candidate .
2006-06-25 10:05:35 +00:00
2010-02-28 14:44:37 +00:00
Britney ' s source code is split between two different but related tasks:
2006-06-25 10:05:35 +00:00
the first one is the generation of the update excuses , while the
2015-01-22 15:16:49 -02:00
second tries to update testing with the valid candidates ; first
2006-06-25 10:05:35 +00:00
each package alone , then larger and even larger sets of packages
together . Each try is accepted if testing is not more uninstallable
after the update than before .
= Data Loading =
In order to analyze the entire Debian distribution , Britney needs to
load in memory the whole archive : this means more than 10.000 packages
2010-02-28 14:44:37 +00:00
for twelve architectures , as well as the dependency interconnections
between them . For this reason , the memory requirements for running this
2006-06-25 10:05:35 +00:00
software are quite high and at least 1 gigabyte of RAM should be available .
Britney loads the source packages from the ` Sources ' file and the binary
packages from the ` Packages_ $ { arch } ' files, where $ {arch} is substituted
with the supported architectures . While loading the data , the software
2010-02-28 14:44:37 +00:00
analyzes the dependencies and builds a directed weighted graph in memory
2006-06-25 10:05:35 +00:00
with all the interconnections between the packages ( see Britney . read_sources
and Britney . read_binaries ) .
Other than source and binary packages , Britney loads the following data :
2010-02-28 14:44:36 +00:00
* BugsV , which contains the list of release - critical bugs for a given
version of a source or binary package ( see Britney . read_bugs ) .
2006-06-25 10:05:35 +00:00
2015-01-22 15:16:49 -02:00
* Dates , which contains the date of the upload of a given version
2006-06-25 10:05:35 +00:00
of a source package ( see Britney . read_dates ) .
* Urgencies , which contains the urgency of the upload of a given
version of a source package ( see Britney . read_urgencies ) .
* Hints , which contains lists of commands which modify the standard behaviour
of Britney ( see Britney . read_hints ) .
2013-10-31 10:33:04 -07:00
* Blocks , which contains user - supplied blocks read from Launchpad bugs
( see Britney . read_blocks ) .
2006-06-25 10:05:35 +00:00
For a more detailed explanation about the format of these files , please read
the documentation of the related methods . The exact meaning of them will be
instead explained in the chapter " Excuses Generation " .
= Excuses =
An excuse is a detailed explanation of why a package can or cannot
2015-01-22 15:16:49 -02:00
be updated in the testing distribution from a newer package in
2006-06-25 10:05:35 +00:00
another distribution ( like for example unstable ) . The main purpose
2015-01-22 15:16:49 -02:00
of the excuses is to be written in an HTML file which will be
2006-06-25 10:05:35 +00:00
published over HTTP . The maintainers will be able to parse it manually
or automatically to find the explanation of why their packages have
been updated or not .
== Excuses generation ==
These are the steps ( with references to method names ) that Britney
does for the generation of the update excuses .
* If a source package is available in testing but it is not
present in unstable and no binary packages in unstable are
built from it , then it is marked for removal .
* Every source package in unstable and testing - proposed - updates ,
if already present in testing , is checked for binary - NMUs , new
or dropped binary packages in all the supported architectures
( see Britney . should_upgrade_srcarch ) . The steps to detect if an
upgrade is needed are :
1. If there is a ` remove ' hint for the source package, the package
is ignored : it will be removed and not updated .
2010-02-28 14:44:37 +00:00
2. For every binary package built from the new source , it checks
2013-09-18 20:40:00 +00:00
for unsatisfied dependencies , new binary packages and updated
binary packages ( binNMU ) , excluding the architecture - independent
ones , and packages not built from the same source .
2006-06-25 10:05:35 +00:00
2010-02-28 14:44:37 +00:00
3. For every binary package built from the old source , it checks
2006-06-25 10:05:35 +00:00
if it is still built from the new source ; if this is not true
and the package is not architecture - independent , the script
removes it from testing .
4. Finally , if there is something worth doing ( eg . a new or updated
binary package ) and nothing wrong it marks the source package
as " Valid candidate " , or " Not considered " if there is something
wrong which prevented the update .
* Every source package in unstable and testing - proposed - updates is
checked for upgrade ( see Britney . should_upgrade_src ) . The steps
to detect if an upgrade is needed are :
1. If the source package in testing is more recent the new one
is ignored .
2. If the source package doesn ' t exist (is fake), which means that
a binary package refers to it but it is not present in the
` Sources ' file, the new one is ignored.
3. If the package doesn ' t exist in testing, the urgency of the
upload is ignored and set to the default ( actually ` low ' ).
4. If there is a ` remove ' hint for the source package, the package
is ignored : it will be removed and not updated .
5. If there is a ` block ' hint for the source package without an
` unblock ` hint or a ` block - all source ` , the package is ignored .
2009-08-15 16:39:00 +01:00
6. If there is a ` block - udeb ' hint for the source package, it will
have the same effect as ` block ' , but may only be cancelled by
a subsequent ` unblock - udeb ' hint.
2006-06-25 10:05:35 +00:00
7. If the suite is unstable , the update can go ahead only if the
2010-02-28 14:44:37 +00:00
upload happened more than the minimum days specified by the
2006-06-25 10:05:35 +00:00
urgency of the upload ; if this is not true , the package is
ignored as ` too - young ' . Note that the urgency is sticky, meaning
that the highest urgency uploaded since the previous testing
transition is taken into account .
2010-09-20 22:03:43 +00:00
8. If the suite is unstable , all the architecture - dependent binary
packages and the architecture - independent ones for the ` nobreakall '
architectures have to be built from the source we are considering .
If this is not true , then these are called ` out - of - date '
architectures and the package is ignored .
2006-06-25 10:05:35 +00:00
2013-09-18 20:40:00 +00:00
9. The source package must have at least one binary package , otherwise
2006-06-25 10:05:35 +00:00
it is ignored .
2010-02-28 14:44:36 +00:00
10. If the suite is unstable , the new source package must have no
release critical bugs which do not also apply to the testing
2006-06-25 10:05:35 +00:00
one . If this is not true , the package is ignored as ` buggy ' .
11. If there is a ` force ' hint for the source package, then it is
updated even if it is marked as ignored from the previous steps .
2011-08-28 21:25:38 +00:00
12. If the suite is { testing - , } proposed - updates , the source package can
2010-09-20 22:03:43 +00:00
be updated only if there is an explicit approval for it . Unless
a ` force ' hint exists, the new package must also be available
on all of the architectures for which it has binary packages in
testing .
2006-06-25 10:05:35 +00:00
13. If the package will be ignored , mark it as " Valid candidate " ,
otherwise mark it as " Not considered " .
* The list of ` remove ' hints is processed: if the requested source
package is not already being updated or removed and the version
actually in testing is the same specified with the ` remove ' hint,
it is marked for removal .
* The excuses are sorted by the number of days from the last upload
( days - old ) and by name .
* A list of unconsidered excuses ( for which the package is not upgraded )
2011-08-02 17:36:03 +00:00
is built . Using this list , all of the excuses depending on them are
marked as invalid " impossible dependencies " .
2006-06-25 10:05:35 +00:00
* The excuses are written in an HTML file .
2006-06-24 17:49:43 +00:00
"""
2015-04-26 18:20:09 +02:00
from __future__ import print_function
2006-06-24 17:49:43 +00:00
2006-06-17 13:45:56 +00:00
import os
import sys
import time
import optparse
import apt_pkg
2014-08-04 20:20:33 +02:00
from collections import defaultdict
2012-05-22 15:22:31 +02:00
from functools import reduce , partial
2015-04-26 18:20:10 +02:00
from itertools import chain , product
2012-01-04 12:02:12 +01:00
from operator import attrgetter
2015-04-26 18:20:10 +02:00
from urllib . parse import quote
2012-01-04 12:02:12 +01:00
2013-11-27 19:46:59 +01:00
from installability . builder import InstallabilityTesterBuilder
2006-06-17 13:45:56 +00:00
from excuse import Excuse
2013-09-07 17:01:58 +00:00
from migrationitem import MigrationItem
2011-10-29 14:31:38 +00:00
from hints import HintCollection
2013-07-10 20:01:04 +02:00
from britney_util import ( old_libraries_format , same_source , undo_changes ,
2013-07-10 20:01:04 +02:00
register_reverses , compute_reverse_tree ,
2013-07-10 20:01:04 +02:00
read_nuninst , write_nuninst , write_heidi ,
2013-12-11 21:21:15 +01:00
eval_uninst , newly_uninst , make_migrationitem ,
2014-03-10 18:48:04 +01:00
write_excuses , write_heidi_delta , write_controlfiles ,
2015-08-24 20:46:42 +02:00
old_libraries , is_nuninst_asgood_generous , ensuredir ,
2015-06-02 21:33:52 +02:00
clone_nuninst )
2013-07-10 20:01:03 +02:00
from consts import ( VERSION , SECTION , BINARIES , MAINTAINER , FAKESRC ,
SOURCE , SOURCEVER , ARCHITECTURE , DEPENDS , CONFLICTS ,
2013-11-27 19:46:59 +01:00
PROVIDES , RDEPENDS , RCONFLICTS , MULTIARCH , ESSENTIAL )
2015-08-25 12:21:51 +02:00
from autopkgtest import AutoPackageTest , srchash
2015-01-19 17:59:19 -02:00
from boottest import BootTest
2012-01-04 12:02:12 +01:00
2011-08-28 21:28:47 +00:00
__author__ = ' Fabio Tranchitella and the Debian Release Team '
__version__ = ' 2.0 '
2006-06-17 13:45:56 +00:00
2012-01-06 19:39:57 +01:00
class Britney ( object ) :
2010-02-28 14:44:37 +00:00
""" Britney, the Debian testing updater script
2015-01-22 15:16:49 -02:00
2010-02-28 14:44:37 +00:00
This is the script that updates the testing distribution . It is executed
2015-01-22 15:16:49 -02:00
each day after the installation of the updated packages . It generates the
2006-06-24 17:49:43 +00:00
` Packages ' files for the testing distribution, but it does so in an
2010-02-28 14:44:37 +00:00
intelligent manner ; it tries to avoid any inconsistency and to use only
2006-06-24 17:49:43 +00:00
non - buggy packages .
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
For more documentation on this script , please read the Developers Reference .
"""
2006-06-17 13:45:56 +00:00
2009-08-15 16:39:00 +01:00
HINTS_HELPERS = ( " easy " , " hint " , " remove " , " block " , " block-udeb " , " unblock " , " unblock-udeb " , " approve " )
2008-01-19 17:24:06 +00:00
HINTS_STANDARD = ( " urgent " , " age-days " ) + HINTS_HELPERS
2013-06-27 08:18:04 +01:00
HINTS_ALL = ( " force " , " force-hint " , " force-badtest " , " force-skiptest " , " block-all " ) + HINTS_STANDARD
2006-06-17 13:45:56 +00:00
def __init__ ( self ) :
2006-06-24 17:49:43 +00:00
""" Class constructor
This method initializes and populates the data lists , which contain all
the information needed by the other methods of the class .
"""
2013-09-25 14:09:34 +01:00
self . date_now = int ( time . time ( ) )
2006-06-24 17:49:43 +00:00
# parse the command line arguments
2006-06-17 13:45:56 +00:00
self . __parse_arguments ( )
2011-11-11 13:30:53 +00:00
MigrationItem . set_architectures ( self . options . architectures )
2006-06-24 17:49:43 +00:00
# initialize the apt_pkg back-end
2006-06-17 13:45:56 +00:00
apt_pkg . init ( )
2012-01-04 22:03:06 +01:00
self . sources = { }
self . binaries = { }
2014-01-11 09:03:16 +01:00
self . all_selected = [ ]
2013-12-06 22:45:01 +01:00
try :
self . hints = self . read_hints ( self . options . hintsdir )
except AttributeError :
self . hints = self . read_hints ( self . options . unstable )
2006-06-24 17:49:43 +00:00
2013-11-27 19:46:59 +01:00
if self . options . nuninst_cache :
2011-05-20 20:40:48 +00:00
self . __log ( " Not building the list of non-installable packages, as requested " , type = " I " )
2013-11-27 19:46:59 +01:00
if self . options . print_uninst :
2015-04-26 18:20:09 +02:00
print ( ' * summary ' )
print ( ' \n ' . join ( ' %4d %s ' % ( len ( nuninst [ x ] ) , x ) for x in self . options . architectures ) )
2013-11-27 19:46:59 +01:00
return
2006-08-18 22:50:52 +00:00
2006-06-24 17:49:43 +00:00
# read the source and binary packages for the involved distributions
2012-01-04 22:03:06 +01:00
if ' testing ' not in self . sources :
self . sources [ ' testing ' ] = self . read_sources ( self . options . testing )
self . sources [ ' unstable ' ] = self . read_sources ( self . options . unstable )
2012-11-04 00:03:26 +00:00
if hasattr ( self . options , ' partial_unstable ' ) :
self . merge_sources ( ' testing ' , ' unstable ' )
2012-10-22 14:35:49 +01:00
if hasattr ( self . options , ' tpu ' ) :
self . sources [ ' tpu ' ] = self . read_sources ( self . options . tpu )
else :
self . sources [ ' tpu ' ] = { }
2012-01-04 22:03:06 +01:00
2011-07-27 16:14:52 +00:00
if hasattr ( self . options , ' pu ' ) :
2011-07-27 09:42:40 +00:00
self . sources [ ' pu ' ] = self . read_sources ( self . options . pu )
else :
self . sources [ ' pu ' ] = { }
2012-01-04 22:03:06 +01:00
if ' testing ' not in self . binaries :
self . binaries [ ' testing ' ] = { }
self . binaries [ ' unstable ' ] = { }
self . binaries [ ' tpu ' ] = { }
self . binaries [ ' pu ' ] = { }
2006-06-19 19:54:21 +00:00
for arch in self . options . architectures :
2012-01-04 22:03:06 +01:00
if arch not in self . binaries [ ' testing ' ] :
self . binaries [ ' testing ' ] [ arch ] = self . read_binaries ( self . options . testing , " testing " , arch )
2006-06-17 13:45:56 +00:00
self . binaries [ ' unstable ' ] [ arch ] = self . read_binaries ( self . options . unstable , " unstable " , arch )
2012-11-04 00:03:26 +00:00
if hasattr ( self . options , ' partial_unstable ' ) :
self . merge_binaries ( ' testing ' , ' unstable ' , arch )
2012-10-22 14:35:49 +01:00
if hasattr ( self . options , ' tpu ' ) :
self . binaries [ ' tpu ' ] [ arch ] = self . read_binaries ( self . options . tpu , " tpu " , arch )
2014-12-09 15:36:09 +00:00
else :
# _build_installability_tester relies it being
# properly initialised, so insert two empty dicts
# here.
self . binaries [ ' tpu ' ] [ arch ] = ( { } , { } )
2011-07-27 16:14:52 +00:00
if hasattr ( self . options , ' pu ' ) :
2011-07-27 09:42:40 +00:00
self . binaries [ ' pu ' ] [ arch ] = self . read_binaries ( self . options . pu , " pu " , arch )
2013-11-27 19:46:59 +01:00
else :
2015-04-27 19:14:08 +00:00
# _build_installability_tester relies on it being
2013-11-27 19:46:59 +01:00
# properly initialised, so insert two empty dicts
# here.
self . binaries [ ' pu ' ] [ arch ] = ( { } , { } )
2015-04-26 18:20:11 +02:00
self . _check_mismatches ( arch )
2013-11-27 19:46:59 +01:00
self . _build_installability_tester ( self . options . architectures )
2006-06-24 17:49:43 +00:00
2013-11-27 19:46:59 +01:00
if not self . options . nuninst_cache :
self . __log ( " Building the list of non-installable packages for the full archive " , type = " I " )
nuninst = { }
2013-11-27 19:46:59 +01:00
self . _inst_tester . compute_testing_installability ( )
2013-11-27 19:46:59 +01:00
for arch in self . options . architectures :
self . __log ( " > Checking for non-installable packages for architecture %s " % arch , type = " I " )
result = self . get_nuninst ( arch , build = True )
nuninst . update ( result )
self . __log ( " > Found %d non-installable packages " % len ( nuninst [ arch ] ) , type = " I " )
if self . options . print_uninst :
self . nuninst_arch_report ( nuninst , arch )
if self . options . print_uninst :
2015-04-26 18:20:09 +02:00
print ( ' * summary ' )
print ( ' \n ' . join ( map ( lambda x : ' %4d %s ' % ( len ( nuninst [ x ] ) , x ) , self . options . architectures ) ) )
2013-11-27 19:46:59 +01:00
return
else :
write_nuninst ( self . options . noninst_status , nuninst )
2015-04-26 18:20:11 +02:00
stats = self . _inst_tester . compute_stats ( )
self . __log ( " > Installability tester statistics (per architecture) " , type = " I " )
for arch in self . options . architectures :
arch_stat = stats [ arch ]
self . __log ( " > %s " % arch , type = " I " )
for stat in arch_stat . stat_summary ( ) :
self . __log ( " > - %s " % stat , type = " I " )
2006-06-24 17:49:43 +00:00
# read the release-critical bug summaries for testing and unstable
2006-06-17 13:45:56 +00:00
self . bugs = { ' unstable ' : self . read_bugs ( self . options . unstable ) ,
' testing ' : self . read_bugs ( self . options . testing ) , }
self . normalize_bugs ( )
2006-06-24 17:49:43 +00:00
# read additional data
2006-06-17 13:45:56 +00:00
self . dates = self . read_dates ( self . options . testing )
self . urgencies = self . read_urgencies ( self . options . testing )
2013-10-31 10:33:04 -07:00
self . blocks = self . read_blocks ( self . options . unstable )
2006-06-17 13:45:56 +00:00
self . excuses = [ ]
2006-08-01 13:33:06 +00:00
self . dependencies = { }
2006-06-17 13:45:56 +00:00
2015-04-26 18:20:11 +02:00
def _check_mismatches ( self , arch ) :
suites = [ s for s in self . binaries if arch in self . binaries [ s ] ]
2015-04-26 18:20:11 +02:00
# NB: ESSENTIAL deliberately skipped as the 2011 and 2012
2015-04-27 19:14:08 +00:00
# parts of the live-data tests require it (britney merges
2015-04-26 18:20:11 +02:00
# this field correctly from the unstable version where
# available)
2015-04-26 18:20:11 +02:00
check_field_name = dict ( ( globals ( ) [ fn ] , fn ) for fn in
( " SOURCE SOURCEVER ARCHITECTURE MULTIARCH "
2015-04-26 18:20:11 +02:00
+ " DEPENDS CONFLICTS PROVIDES " ) . split ( ) )
2015-04-26 18:20:11 +02:00
check_fields = check_field_name . keys ( )
any_mismatch = False
for s1 , s2 in product ( suites , suites ) :
if s1 > = s2 : continue
s1_pkgs = self . binaries [ s1 ] [ arch ] [ 0 ]
s2_pkgs = self . binaries [ s2 ] [ arch ] [ 0 ]
pkgs = set ( s1_pkgs ) & set ( s2_pkgs )
for p in pkgs :
if s1_pkgs [ p ] [ VERSION ] != s2_pkgs [ p ] [ VERSION ] : continue
bad = [ ]
for f in check_fields :
if s1_pkgs [ p ] [ f ] != s2_pkgs [ p ] [ f ] :
bad . append ( ( f , s1_pkgs [ p ] [ f ] , s2_pkgs [ p ] [ f ] ) )
if bad :
any_mismatch = True
self . __log ( " Mismatch found %s %s %s differs in %s vs %s " % (
p , s1_pkgs [ p ] [ VERSION ] , arch , s1 , s2 ) , type = " E " )
for f , v1 , v2 in bad :
self . __log ( " ... %s %s != %s " % ( check_field_name [ f ] , v1 , v2 ) )
# test suite doesn't appreciate aborts of this nature
2015-04-26 18:20:11 +02:00
if any_mismatch :
self . __log ( " Mismatches found, exiting. " , type = " I " )
sys . exit ( 1 )
2015-04-26 18:20:11 +02:00
return
2006-06-17 13:45:56 +00:00
def __parse_arguments ( self ) :
2006-06-24 17:49:43 +00:00
""" Parse the command line arguments
This method parses and initializes the command line arguments .
While doing so , it preprocesses some of the options to be converted
in a suitable form for the other methods of the class .
"""
# initialize the parser
2011-10-19 12:14:02 +02:00
parser = optparse . OptionParser ( version = " % prog " )
parser . add_option ( " -v " , " " , action = " count " , dest = " verbose " , help = " enable verbose output " )
parser . add_option ( " -c " , " --config " , action = " store " , dest = " config " , default = " /etc/britney.conf " ,
2006-07-28 13:21:44 +00:00
help = " path for the configuration file " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --architectures " , action = " store " , dest = " architectures " , default = None ,
2006-07-28 13:21:44 +00:00
help = " override architectures from configuration file " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --actions " , action = " store " , dest = " actions " , default = None ,
2006-07-28 13:21:44 +00:00
help = " override the list of actions to be performed " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --hints " , action = " store " , dest = " hints " , default = None ,
2008-01-17 14:27:36 +00:00
help = " additional hints, separated by semicolons " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --hint-tester " , action = " store_true " , dest = " hint_tester " , default = None ,
2008-01-15 16:09:51 +00:00
help = " provide a command line interface to test hints " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --dry-run " , action = " store_true " , dest = " dry_run " , default = False ,
2006-08-06 09:29:32 +00:00
help = " disable all outputs to the testing directory " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --control-files " , action = " store_true " , dest = " control_files " , default = False ,
2006-08-03 11:41:39 +00:00
help = " enable control files generation " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --nuninst-cache " , action = " store_true " , dest = " nuninst_cache " , default = False ,
2006-08-07 14:38:13 +00:00
help = " do not build the non-installability status, use the cache from file " )
2011-10-19 12:14:02 +02:00
parser . add_option ( " " , " --print-uninst " , action = " store_true " , dest = " print_uninst " , default = False ,
2008-05-02 13:57:37 +00:00
help = " just print a summary of uninstallable packages " )
2014-07-24 15:28:12 +01:00
parser . add_option ( " " , " --distribution " , action = " store " , dest = " distribution " , default = " ubuntu " ,
help = " set distribution name " )
2014-07-24 15:20:09 +01:00
parser . add_option ( " " , " --series " , action = " store " , dest = " series " , default = None ,
2014-07-24 15:18:26 +01:00
help = " set distribution series name " )
2011-10-19 12:14:02 +02:00
( self . options , self . args ) = parser . parse_args ( )
2015-01-22 15:16:49 -02:00
2008-04-29 05:08:58 +00:00
# integrity checks
2008-05-02 13:57:37 +00:00
if self . options . nuninst_cache and self . options . print_uninst :
2011-10-27 20:50:12 +00:00
self . __log ( " nuninst_cache and print_uninst are mutually exclusive! " , type = " E " )
2008-04-29 05:08:58 +00:00
sys . exit ( 1 )
2015-04-27 19:14:08 +00:00
# if the configuration file exists, then read it and set the additional options
2008-04-29 05:08:58 +00:00
elif not os . path . isfile ( self . options . config ) :
2006-06-17 13:45:56 +00:00
self . __log ( " Unable to read the configuration file ( %s ), exiting! " % self . options . config , type = " E " )
sys . exit ( 1 )
2006-06-24 17:49:43 +00:00
# minimum days for unstable-testing transition and the list of hints
# are handled as an ad-hoc case
2006-06-17 13:45:56 +00:00
self . MINDAYS = { }
2008-01-17 14:27:36 +00:00
self . HINTS = { ' command-line ' : self . HINTS_ALL }
2015-04-26 18:20:10 +02:00
with open ( self . options . config , encoding = ' utf-8 ' ) as config :
2015-04-26 18:20:09 +02:00
for line in config :
if ' = ' in line and not line . strip ( ) . startswith ( ' # ' ) :
k , v = line . split ( ' = ' , 1 )
k = k . strip ( )
v = v . strip ( )
2015-08-24 20:46:42 +02:00
if self . options . series is not None :
v = v . replace ( " % (SERIES) " , self . options . series )
2015-04-26 18:20:09 +02:00
if k . startswith ( " MINDAYS_ " ) :
self . MINDAYS [ k . split ( " _ " ) [ 1 ] . lower ( ) ] = int ( v )
elif k . startswith ( " HINTS_ " ) :
self . HINTS [ k . split ( " _ " ) [ 1 ] . lower ( ) ] = \
reduce ( lambda x , y : x + y , [ hasattr ( self , " HINTS_ " + i ) and getattr ( self , " HINTS_ " + i ) or ( i , ) for i in v . split ( ) ] )
elif not hasattr ( self . options , k . lower ( ) ) or \
not getattr ( self . options , k . lower ( ) ) :
setattr ( self . options , k . lower ( ) , v )
2006-06-24 17:49:43 +00:00
2014-01-11 09:03:16 +01:00
if not hasattr ( self . options , " heidi_delta_output " ) :
self . options . heidi_delta_output = self . options . heidi_output + " Delta "
2015-06-02 21:33:52 +02:00
self . options . nobreakall_arches = self . options . nobreakall_arches . split ( )
2015-08-24 20:46:42 +02:00
self . options . outofsync_arches = self . options . outofsync_arches . split ( )
2015-06-02 21:33:52 +02:00
self . options . break_arches = self . options . break_arches . split ( )
self . options . new_arches = self . options . new_arches . split ( )
2006-06-24 17:49:43 +00:00
# Sort the architecture list
2006-06-19 19:54:21 +00:00
allarches = sorted ( self . options . architectures . split ( ) )
2015-06-02 21:33:52 +02:00
arches = [ x for x in allarches if x in self . options . nobreakall_arches ]
2015-08-24 20:46:42 +02:00
arches + = [ x for x in allarches if x not in arches and x not in self . options . outofsync_arches ]
2015-06-02 21:33:52 +02:00
arches + = [ x for x in allarches if x not in arches and x not in self . options . break_arches ]
arches + = [ x for x in allarches if x not in arches and x not in self . options . new_arches ]
2006-06-19 19:54:21 +00:00
arches + = [ x for x in allarches if x not in arches ]
2015-04-26 18:20:10 +02:00
self . options . architectures = [ sys . intern ( arch ) for arch in arches ]
2006-08-06 09:29:32 +00:00
self . options . smooth_updates = self . options . smooth_updates . split ( )
2006-06-17 13:45:56 +00:00
2015-06-02 21:33:52 +02:00
2006-06-17 13:45:56 +00:00
def __log ( self , msg , type = " I " ) :
2006-06-24 17:49:43 +00:00
""" Print info messages according to verbosity level
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
An easy - and - simple log method which prints messages to the standard
output . The type parameter controls the urgency of the message , and
can be equal to ` I ' for `Information ' , ` W ' for `Warning ' and ` E ' for
2010-02-28 14:44:37 +00:00
` Error ' . Warnings and errors are always printed, and information is
2013-09-18 20:40:00 +00:00
printed only if verbose logging is enabled .
2006-06-24 17:49:43 +00:00
"""
2006-06-17 13:45:56 +00:00
if self . options . verbose or type in ( " E " , " W " ) :
2015-04-26 18:20:09 +02:00
print ( " %s : [ %s ] - %s " % ( type , time . asctime ( ) , msg ) )
2006-06-17 13:45:56 +00:00
2013-11-27 19:46:59 +01:00
def _build_installability_tester ( self , archs ) :
""" Create the installability tester """
solvers = self . get_dependency_solvers
binaries = self . binaries
builder = InstallabilityTesterBuilder ( )
for ( dist , arch ) in product ( binaries , archs ) :
testing = ( dist == ' testing ' )
for pkgname in binaries [ dist ] [ arch ] [ 0 ] :
pkgdata = binaries [ dist ] [ arch ] [ 0 ] [ pkgname ]
version = pkgdata [ VERSION ]
t = ( pkgname , version , arch )
essential = pkgdata [ ESSENTIAL ]
if not builder . add_binary ( t , essential = essential ,
in_testing = testing ) :
continue
depends = [ ]
conflicts = [ ]
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
possible_dep_ranges = { }
2013-11-27 19:46:59 +01:00
2015-04-27 19:14:08 +00:00
# We do not differentiate between depends and pre-depends
2013-11-27 19:46:59 +01:00
if pkgdata [ DEPENDS ] :
depends . extend ( apt_pkg . parse_depends ( pkgdata [ DEPENDS ] , False ) )
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
2013-11-27 19:46:59 +01:00
if pkgdata [ CONFLICTS ] :
conflicts = apt_pkg . parse_depends ( pkgdata [ CONFLICTS ] , False )
with builder . relation_builder ( t ) as relations :
for ( al , dep ) in [ ( depends , True ) , \
( conflicts , False ) ] :
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
2013-11-27 19:46:59 +01:00
for block in al :
sat = set ( )
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
2013-11-27 19:46:59 +01:00
for dep_dist in binaries :
2015-04-26 18:20:10 +02:00
pkgs = solvers ( block , arch , dep_dist )
2013-11-27 19:46:59 +01:00
for p in pkgs :
# version and arch is already interned, but solvers use
2015-04-27 19:14:08 +00:00
# the package name extracted from the field and it is therefore
2013-11-27 19:46:59 +01:00
# not interned.
pdata = binaries [ dep_dist ] [ arch ] [ 0 ] [ p ]
2015-04-26 18:20:10 +02:00
pt = ( sys . intern ( p ) , pdata [ VERSION ] , arch )
2013-11-27 19:46:59 +01:00
if dep :
sat . add ( pt )
elif t != pt :
# if t satisfies its own
# conflicts relation, then it
# is using §7.6.2
relations . add_breaks ( pt )
if dep :
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
if len ( block ) != 1 :
relations . add_dependency_clause ( sat )
else :
# This dependency might be a part
# of a version-range a la:
#
# Depends: pkg-a (>= 1),
# pkg-a (<< 2~)
#
# In such a case we want to reduce
# that to a single clause for
# efficiency.
#
# In theory, it could also happen
# with "non-minimal" dependencies
# a la:
#
# Depends: pkg-a, pkg-a (>= 1)
#
# But dpkg is known to fix that up
# at build time, so we will
# probably only see "ranges" here.
key = block [ 0 ] [ 0 ]
if key in possible_dep_ranges :
possible_dep_ranges [ key ] & = sat
else :
possible_dep_ranges [ key ] = sat
if dep :
2015-04-26 18:20:09 +02:00
for clause in possible_dep_ranges . values ( ) :
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a
"version range" a la:
Depends: pkg-a (>= 2), pkg-a (<< 3~)
Previously this would create two clauses a la:
- (pkg-a, 2, arch), (pkg-a, 3, arch)
- (pkg-a, 1, arch), (pkg-a, 2, arch)
However, it is plain to see that only (pkg-a, 2, arch) is a valid
solution and the other options are just noise. This patch makes
Britney merge these two claues into a single clause containing exactly
(pkg-a, 2, arch).
Signed-off-by: Niels Thykier <niels@thykier.net>
2014-08-04 20:19:49 +02:00
relations . add_dependency_clause ( clause )
2013-11-27 19:46:59 +01:00
self . _inst_tester = builder . build ( )
2006-06-24 17:49:43 +00:00
# Data reading/writing methods
# ----------------------------
2006-06-17 13:45:56 +00:00
2015-04-26 18:20:10 +02:00
def read_sources ( self , basedir , intern = sys . intern ) :
2006-06-24 17:49:43 +00:00
""" Read the list of source packages from the specified directory
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
The source packages are read from the ` Sources ' file within the
directory specified as ` basedir ' parameter. Considering the
large amount of memory needed , not all the fields are loaded
in memory . The available fields are Version , Maintainer and Section .
The method returns a list where every item represents a source
package as a dictionary .
"""
2006-06-17 13:45:56 +00:00
sources = { }
filename = os . path . join ( basedir , " Sources " )
self . __log ( " Loading source packages from %s " % filename )
2011-12-18 21:42:14 +01:00
2015-08-24 20:46:52 +02:00
f = open ( filename , encoding = ' utf-8 ' )
Packages = apt_pkg . TagFile ( f )
2011-12-18 21:42:14 +01:00
get_field = Packages . section . get
step = Packages . step
2011-03-06 20:52:05 +00:00
while step ( ) :
2013-01-12 12:31:17 +01:00
if get_field ( ' Extra-Source-Only ' , ' no ' ) == ' yes ' :
# Ignore sources only referenced by Built-Using
continue
2006-07-26 19:26:38 +00:00
pkg = get_field ( ' Package ' )
2010-02-28 14:44:36 +00:00
ver = get_field ( ' Version ' )
# There may be multiple versions of the source package
# (in unstable) if some architectures have out-of-date
# binaries. We only ever consider the source with the
# largest version for migration.
2011-12-18 21:42:14 +01:00
if pkg in sources and apt_pkg . version_compare ( sources [ pkg ] [ 0 ] , ver ) > 0 :
2010-02-28 14:44:36 +00:00
continue
2013-11-27 19:46:59 +01:00
sources [ intern ( pkg ) ] = [ intern ( ver ) ,
intern ( get_field ( ' Section ' ) ) ,
2006-08-18 13:47:20 +00:00
[ ] ,
get_field ( ' Maintainer ' ) ,
False ,
2015-07-01 15:49:06 +02:00
get_field ( ' Testsuite ' , ' ' ) . startswith ( ' autopkgtest ' ) ,
2006-08-18 13:47:20 +00:00
]
2015-08-24 20:46:52 +02:00
f . close ( )
2006-06-17 13:45:56 +00:00
return sources
2015-04-26 18:20:10 +02:00
def read_binaries ( self , basedir , distribution , arch , intern = sys . intern ) :
2006-06-24 17:49:43 +00:00
""" Read the list of binary packages from the specified directory
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
The binary packages are read from the ` Packages_ $ { arch } ' files
within the directory specified as ` basedir ' parameter, replacing
$ { arch } with the value of the arch parameter . Considering the
large amount of memory needed , not all the fields are loaded
2013-09-18 20:40:00 +00:00
in memory . The available fields are Version , Source , Multi - Arch ,
2006-06-24 17:49:43 +00:00
Depends , Conflicts , Provides and Architecture .
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
After reading the packages , reverse dependencies are computed
and saved in the ` rdepends ' keys, and the `Provides ' field is
used to populate the virtual packages list .
2012-04-11 21:45:31 +00:00
The dependencies are parsed with the apt_pkg . parse_depends method ,
2006-06-24 17:49:43 +00:00
and they are stored both as the format of its return value and
text .
The method returns a tuple . The first element is a list where
every item represents a binary package as a dictionary ; the second
element is a dictionary which maps virtual packages to real
2010-02-28 14:44:37 +00:00
packages that provide them .
2006-06-24 17:49:43 +00:00
"""
packages = { }
provides = { }
2006-07-26 19:26:38 +00:00
sources = self . sources
2006-07-26 20:07:59 +00:00
2006-06-24 17:49:43 +00:00
filename = os . path . join ( basedir , " Packages_ %s " % arch )
self . __log ( " Loading binary packages from %s " % filename )
2011-12-18 21:42:14 +01:00
2015-08-24 20:46:52 +02:00
f = open ( filename , encoding = ' utf-8 ' )
Packages = apt_pkg . TagFile ( f )
2011-12-18 21:42:14 +01:00
get_field = Packages . section . get
step = Packages . step
2011-03-06 20:52:05 +00:00
while step ( ) :
2006-07-26 19:26:38 +00:00
pkg = get_field ( ' Package ' )
version = get_field ( ' Version ' )
2010-02-28 14:44:36 +00:00
# There may be multiple versions of any arch:all packages
# (in unstable) if some architectures have out-of-date
# binaries. We only ever consider the package with the
# largest version for migration.
2011-12-18 21:42:14 +01:00
if pkg in packages and apt_pkg . version_compare ( packages [ pkg ] [ 0 ] , version ) > 0 :
2010-02-28 14:44:36 +00:00
continue
2013-11-27 19:46:59 +01:00
pkg = intern ( pkg )
version = intern ( version )
2010-02-28 14:44:36 +00:00
2012-04-12 00:07:22 +02:00
# Merge Pre-Depends with Depends and Conflicts with
# Breaks. Britney is not interested in the "finer
2015-04-27 19:14:08 +00:00
# semantic differences" of these fields anyway.
2012-04-12 00:07:22 +02:00
pdeps = get_field ( ' Pre-Depends ' )
deps = get_field ( ' Depends ' )
if deps and pdeps :
deps = pdeps + ' , ' + deps
elif pdeps :
deps = pdeps
2013-11-27 19:46:59 +01:00
ess = False
if get_field ( ' Essential ' , ' no ' ) == ' yes ' :
ess = True
2009-09-06 18:00:56 +01:00
final_conflicts_list = [ ]
conflicts = get_field ( ' Conflicts ' )
if conflicts :
final_conflicts_list . append ( conflicts )
breaks = get_field ( ' Breaks ' )
if breaks :
final_conflicts_list . append ( breaks )
2006-08-18 13:47:20 +00:00
dpkg = [ version ,
2013-11-27 19:46:59 +01:00
intern ( get_field ( ' Section ' ) ) ,
pkg ,
2006-08-18 13:47:20 +00:00
version ,
2013-11-27 19:46:59 +01:00
intern ( get_field ( ' Architecture ' ) ) ,
2013-09-16 15:02:45 +01:00
get_field ( ' Multi-Arch ' ) ,
2012-04-12 00:07:22 +02:00
deps ,
2009-09-06 18:00:56 +01:00
' , ' . join ( final_conflicts_list ) or None ,
2006-08-18 13:47:20 +00:00
get_field ( ' Provides ' ) ,
[ ] ,
[ ] ,
2013-11-27 19:46:59 +01:00
ess ,
2006-08-18 13:47:20 +00:00
]
2006-06-24 17:49:43 +00:00
# retrieve the name and the version of the source package
2006-07-26 19:26:38 +00:00
source = get_field ( ' Source ' )
2006-06-24 17:49:43 +00:00
if source :
2013-11-27 19:46:59 +01:00
dpkg [ SOURCE ] = intern ( source . split ( " " ) [ 0 ] )
2006-06-24 17:49:43 +00:00
if " ( " in source :
2013-11-27 19:46:59 +01:00
dpkg [ SOURCEVER ] = intern ( source [ source . find ( " ( " ) + 1 : source . find ( " ) " ) ] )
2006-06-24 17:49:43 +00:00
2013-07-01 18:13:51 +00:00
pkgarch = " %s / %s " % ( pkg , arch )
2006-06-24 17:49:43 +00:00
# if the source package is available in the distribution, then register this binary package
2006-08-18 13:47:20 +00:00
if dpkg [ SOURCE ] in sources [ distribution ] :
2013-07-01 18:13:51 +00:00
# There may be multiple versions of any arch:all packages
# (in unstable) if some architectures have out-of-date
# binaries. We only want to include the package in the
# source -> binary mapping once. It doesn't matter which
# of the versions we include as only the package name and
# architecture are recorded.
if pkgarch not in sources [ distribution ] [ dpkg [ SOURCE ] ] [ BINARIES ] :
sources [ distribution ] [ dpkg [ SOURCE ] ] [ BINARIES ] . append ( pkgarch )
2006-06-24 17:49:43 +00:00
# if the source package doesn't exist, create a fake one
else :
2015-08-18 23:36:24 +02:00
sources [ distribution ] [ dpkg [ SOURCE ] ] = [ dpkg [ SOURCEVER ] , ' faux ' , [ pkgarch ] , None , True , False ]
2006-06-24 17:49:43 +00:00
# register virtual packages and real packages that provide them
2006-08-18 13:47:20 +00:00
if dpkg [ PROVIDES ] :
2015-04-26 18:20:09 +02:00
parts = [ p . strip ( ) for p in dpkg [ PROVIDES ] . split ( " , " ) ]
2006-06-24 17:49:43 +00:00
for p in parts :
2006-07-26 19:48:54 +00:00
if p not in provides :
provides [ p ] = [ ]
provides [ p ] . append ( pkg )
2006-08-18 13:47:20 +00:00
dpkg [ PROVIDES ] = parts
else : dpkg [ PROVIDES ] = [ ]
2006-06-24 17:49:43 +00:00
2006-07-28 13:21:44 +00:00
# add the resulting dictionary to the package list
2006-06-24 17:49:43 +00:00
packages [ pkg ] = dpkg
2015-08-24 20:46:52 +02:00
f . close ( )
2006-07-30 11:15:27 +00:00
# loop again on the list of packages to register reverse dependencies and conflicts
2013-07-10 20:01:04 +02:00
register_reverses ( packages , provides , check_doubles = False )
2006-07-29 19:13:23 +00:00
2006-06-24 17:49:43 +00:00
# return a tuple with the list of real and virtual packages
return ( packages , provides )
2012-11-04 00:03:26 +00:00
def merge_sources ( self , source , target ) :
""" Merge sources from `source ' into partial suite `target ' . """
source_sources = self . sources [ source ]
target_sources = self . sources [ target ]
for pkg , value in source_sources . items ( ) :
if pkg in target_sources :
continue
2012-11-07 18:49:18 +00:00
target_sources [ pkg ] = list ( value )
2012-11-04 00:03:26 +00:00
target_sources [ pkg ] [ BINARIES ] = list (
target_sources [ pkg ] [ BINARIES ] )
def merge_binaries ( self , source , target , arch ) :
""" Merge `arch ' binaries from `source ' into partial suite `target ' . """
source_sources = self . sources [ source ]
source_binaries , _ = self . binaries [ source ] [ arch ]
target_sources = self . sources [ target ]
target_binaries , target_provides = self . binaries [ target ] [ arch ]
oodsrcs = set ( )
for pkg , value in source_binaries . items ( ) :
if pkg in target_binaries :
continue
# Don't merge binaries rendered stale by new sources in target
# that have built on this architecture.
if value [ SOURCE ] not in oodsrcs :
source_version = source_sources [ value [ SOURCE ] ] [ VERSION ]
target_version = target_sources [ value [ SOURCE ] ] [ VERSION ]
if source_version != target_version :
current_arch = value [ ARCHITECTURE ]
built = False
for b in target_sources [ value [ SOURCE ] ] [ BINARIES ] :
binpkg , binarch = b . split ( ' / ' )
if binarch == arch :
target_value = target_binaries [ binpkg ]
2014-11-12 12:36:53 +00:00
if current_arch in (
target_value [ ARCHITECTURE ] , " all " ) :
2012-11-04 00:03:26 +00:00
built = True
break
if built :
continue
oodsrcs . add ( value [ SOURCE ] )
if pkg in target_binaries :
for p in target_binaries [ pkg ] [ PROVIDES ] :
target_provides [ p ] . remove ( pkg )
if not target_provides [ p ] :
del target_provides [ p ]
target_binaries [ pkg ] = value
pkg_arch = pkg + " / " + arch
if pkg_arch not in target_sources [ value [ SOURCE ] ] [ BINARIES ] :
target_sources [ value [ SOURCE ] ] [ BINARIES ] . append ( pkg_arch )
for p in value [ PROVIDES ] :
if p not in target_provides :
target_provides [ p ] = [ ]
target_provides [ p ] . append ( pkg )
for pkg , value in target_binaries . items ( ) :
value [ RDEPENDS ] = [ ]
value [ RCONFLICTS ] = [ ]
2013-09-24 14:53:54 +01:00
register_reverses (
target_binaries , target_provides , check_doubles = False )
2012-11-04 00:03:26 +00:00
2006-06-17 13:45:56 +00:00
def read_bugs ( self , basedir ) :
2006-06-24 17:49:43 +00:00
""" Read the release critial bug summary from the specified directory
2015-01-22 15:16:49 -02:00
2010-02-28 14:44:36 +00:00
The RC bug summaries are read from the ` BugsV ' file within the
2011-08-28 21:45:14 +00:00
directory specified in the ` basedir ' parameter. The file contains
2006-06-24 17:49:43 +00:00
rows with the format :
2010-02-28 14:44:36 +00:00
< package - name > < bug number > [ , < bug number > . . . ]
2006-06-24 17:49:43 +00:00
The method returns a dictionary where the key is the binary package
2010-02-28 14:44:36 +00:00
name and the value is the list of open RC bugs for it .
2006-06-24 17:49:43 +00:00
"""
2014-08-04 20:20:33 +02:00
bugs = defaultdict ( list )
2008-01-12 18:41:03 +00:00
filename = os . path . join ( basedir , " BugsV " )
2011-05-20 20:40:06 +00:00
self . __log ( " Loading RC bugs data from %s " % filename )
2012-10-22 13:52:14 +01:00
try :
2015-08-24 20:46:42 +02:00
for line in open ( filename , encoding = ' ascii ' ) :
2012-10-22 13:52:14 +01:00
l = line . split ( )
if len ( l ) != 2 :
2015-08-24 20:46:42 +02:00
self . __log ( " Malformed line found in line %s " % ( line ) , type = ' W ' )
2012-10-22 13:52:14 +01:00
continue
pkg = l [ 0 ]
bugs [ pkg ] + = l [ 1 ] . split ( " , " )
except IOError :
self . __log ( " %s missing; skipping bug-based processing " % filename )
2006-06-17 13:45:56 +00:00
return bugs
2006-06-24 17:49:43 +00:00
def __maxver ( self , pkg , dist ) :
""" Return the maximum version for a given package name
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
This method returns None if the specified source package
is not available in the ` dist ' distribution. If the package
exists , then it returns the maximum version between the
source package and its binary packages .
"""
2006-06-17 13:45:56 +00:00
maxver = None
2006-07-26 19:26:38 +00:00
if pkg in self . sources [ dist ] :
2006-08-18 13:47:20 +00:00
maxver = self . sources [ dist ] [ pkg ] [ VERSION ]
2006-06-19 19:54:21 +00:00
for arch in self . options . architectures :
2006-07-26 19:26:38 +00:00
if pkg not in self . binaries [ dist ] [ arch ] [ 0 ] : continue
2006-08-18 13:47:20 +00:00
pkgv = self . binaries [ dist ] [ arch ] [ 0 ] [ pkg ] [ VERSION ]
2011-12-18 21:42:14 +01:00
if maxver == None or apt_pkg . version_compare ( pkgv , maxver ) > 0 :
2006-06-17 13:45:56 +00:00
maxver = pkgv
return maxver
def normalize_bugs ( self ) :
2006-06-24 17:49:43 +00:00
""" Normalize the release critical bug summaries for testing and unstable
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
The method doesn ' t return any value: it directly modifies the
object attribute ` bugs ' .
"""
# loop on all the package names from testing and unstable bug summaries
2013-08-11 15:23:45 +02:00
for pkg in set ( chain ( self . bugs [ ' testing ' ] , self . bugs [ ' unstable ' ] ) ) :
2006-06-24 17:49:43 +00:00
# make sure that the key is present in both dictionaries
2006-07-26 19:26:38 +00:00
if pkg not in self . bugs [ ' testing ' ] :
2008-01-12 18:41:03 +00:00
self . bugs [ ' testing ' ] [ pkg ] = [ ]
2006-07-26 19:26:38 +00:00
elif pkg not in self . bugs [ ' unstable ' ] :
2008-01-12 18:41:03 +00:00
self . bugs [ ' unstable ' ] [ pkg ] = [ ]
2006-06-17 13:45:56 +00:00
2011-05-14 16:42:49 +00:00
if pkg . startswith ( " src: " ) :
pkg = pkg [ 4 : ]
2008-01-13 12:16:31 +00:00
# retrieve the maximum version of the package in testing:
maxvert = self . __maxver ( pkg , ' testing ' )
# if the package is not available in testing, then reset
# the list of RC bugs
if maxvert == None :
self . bugs [ ' testing ' ] [ pkg ] = [ ]
2006-06-17 13:45:56 +00:00
def read_dates ( self , basedir ) :
2006-06-24 17:49:43 +00:00
""" Read the upload date for the packages from the specified directory
2015-01-22 15:16:49 -02:00
2011-05-31 20:57:59 +00:00
The upload dates are read from the ` Dates ' file within the directory
2006-06-24 17:49:43 +00:00
specified as ` basedir ' parameter. The file contains rows with the
format :
< package - name > < version > < date - of - upload >
2013-09-25 14:09:34 +01:00
The dates are expressed as the number of seconds from the Unix epoch
( 1970 - 01 - 01 00 : 00 : 00 UTC ) .
2006-06-24 17:49:43 +00:00
The method returns a dictionary where the key is the binary package
2011-05-31 20:57:59 +00:00
name and the value is a tuple with two items , the version and the date .
2006-06-24 17:49:43 +00:00
"""
2006-06-17 13:45:56 +00:00
dates = { }
filename = os . path . join ( basedir , " Dates " )
self . __log ( " Loading upload data from %s " % filename )
2014-07-24 17:35:47 +01:00
try :
2015-08-24 20:46:42 +02:00
for line in open ( filename , encoding = ' ascii ' ) :
2014-07-24 17:35:47 +01:00
l = line . split ( )
if len ( l ) != 3 : continue
try :
dates [ l [ 0 ] ] = ( l [ 1 ] , int ( l [ 2 ] ) )
except ValueError :
self . __log ( " Dates, unable to parse \" %s \" " % line , type = " E " )
except IOError :
2014-10-23 18:28:42 -04:00
self . __log ( " %s missing; initialising upload data from scratch " %
filename )
2006-06-17 13:45:56 +00:00
return dates
2006-08-01 18:59:29 +00:00
def write_dates ( self , basedir , dates ) :
""" Write the upload date for the packages to the specified directory
For a more detailed explanation of the format , please check the method
read_dates .
"""
filename = os . path . join ( basedir , " Dates " )
self . __log ( " Writing upload data to %s " % filename )
2014-06-06 14:45:55 +01:00
ensuredir ( os . path . dirname ( filename ) )
2015-04-26 18:20:10 +02:00
with open ( filename , ' w ' , encoding = ' utf-8 ' ) as f :
2015-04-26 18:20:10 +02:00
for pkg in sorted ( dates ) :
f . write ( " %s %s %d \n " % ( ( pkg , ) + dates [ pkg ] ) )
2006-08-01 18:59:29 +00:00
2006-06-17 13:45:56 +00:00
def read_urgencies ( self , basedir ) :
2006-06-24 17:49:43 +00:00
""" Read the upload urgency of the packages from the specified directory
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
The upload urgencies are read from the ` Urgency ' file within the
directory specified as ` basedir ' parameter. The file contains rows
with the format :
< package - name > < version > < urgency >
The method returns a dictionary where the key is the binary package
name and the value is the greatest urgency from the versions of the
package that are higher then the testing one .
"""
2006-06-17 13:45:56 +00:00
urgencies = { }
filename = os . path . join ( basedir , " Urgency " )
self . __log ( " Loading upload urgencies from %s " % filename )
2012-10-22 13:50:07 +01:00
try :
2015-08-24 20:46:42 +02:00
for line in open ( filename , errors = ' surrogateescape ' , encoding = ' ascii ' ) :
2012-10-22 13:50:07 +01:00
l = line . split ( )
if len ( l ) != 3 : continue
2006-06-17 13:45:56 +00:00
2012-10-22 13:50:07 +01:00
# read the minimum days associated with the urgencies
2014-12-09 16:02:16 +00:00
urgency_old = urgencies . get ( l [ 0 ] , None )
2015-08-24 20:46:42 +02:00
mindays_old = self . MINDAYS . get ( urgency_old , 1000 )
2012-10-22 13:50:07 +01:00
mindays_new = self . MINDAYS . get ( l [ 2 ] , self . MINDAYS [ self . options . default_urgency ] )
2006-06-24 17:49:43 +00:00
2012-10-22 13:50:07 +01:00
# if the new urgency is lower (so the min days are higher), do nothing
if mindays_old < = mindays_new :
continue
2006-06-24 17:49:43 +00:00
2012-10-22 13:50:07 +01:00
# if the package exists in testing and it is more recent, do nothing
tsrcv = self . sources [ ' testing ' ] . get ( l [ 0 ] , None )
if tsrcv and apt_pkg . version_compare ( tsrcv [ VERSION ] , l [ 1 ] ) > = 0 :
continue
2006-06-24 17:49:43 +00:00
2012-10-22 13:50:07 +01:00
# if the package doesn't exist in unstable or it is older, do nothing
usrcv = self . sources [ ' unstable ' ] . get ( l [ 0 ] , None )
if not usrcv or apt_pkg . version_compare ( usrcv [ VERSION ] , l [ 1 ] ) < 0 :
continue
2006-06-24 17:49:43 +00:00
2012-10-22 13:50:07 +01:00
# update the urgency for the package
urgencies [ l [ 0 ] ] = l [ 2 ]
except IOError :
self . __log ( " %s missing; using default for all packages " % filename )
2006-06-17 13:45:56 +00:00
return urgencies
def read_hints ( self , basedir ) :
2006-06-24 17:49:43 +00:00
""" Read the hint commands from the specified directory
2015-01-22 15:16:49 -02:00
2010-02-28 14:44:37 +00:00
The hint commands are read from the files contained in the ` Hints '
2015-01-22 15:16:49 -02:00
directory within the directory specified as ` basedir ' parameter.
2010-02-28 14:44:37 +00:00
The names of the files have to be the same as the authorized users
2006-06-24 17:49:43 +00:00
for the hints .
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
The file contains rows with the format :
< command > < package - name > [ / < version > ]
The method returns a dictionary where the key is the command , and
the value is the list of affected packages .
"""
2011-09-04 16:41:33 +00:00
hints = HintCollection ( )
2006-06-17 13:45:56 +00:00
for who in self . HINTS . keys ( ) :
2008-01-17 14:27:36 +00:00
if who == ' command-line ' :
lines = self . options . hints and self . options . hints . split ( ' ; ' ) or ( )
2015-04-26 18:20:10 +02:00
filename = ' <cmd-line> '
2008-01-17 14:27:36 +00:00
else :
filename = os . path . join ( basedir , " Hints " , who )
if not os . path . isfile ( filename ) :
self . __log ( " Cannot read hints list from %s , no such file! " % filename , type = " E " )
continue
self . __log ( " Loading hints list from %s " % filename )
2015-04-26 18:20:10 +02:00
with open ( filename , encoding = ' utf-8 ' ) as f :
lines = f . readlines ( )
2008-01-17 14:27:36 +00:00
for line in lines :
2006-06-17 13:45:56 +00:00
line = line . strip ( )
if line == " " : continue
l = line . split ( )
if l [ 0 ] == ' finished ' :
break
2014-11-23 19:19:33 +01:00
if l [ 0 ] == ' remark ' :
2015-04-27 19:14:08 +00:00
# Ignore "no-op" hint, the sole purpose of which is to be
2014-11-23 19:19:33 +01:00
# found by hint grep (and show up in "d"'s
# output).
continue
2006-06-17 13:45:56 +00:00
elif l [ 0 ] not in self . HINTS [ who ] :
continue
2012-04-01 22:46:05 +00:00
elif len ( l ) == 1 :
# All current hints require at least one argument
self . __log ( " Malformed hint found in %s : ' %s ' " % ( filename , line ) , type = " W " )
2013-06-27 08:18:04 +01:00
elif l [ 0 ] in [ " approve " , " block " , " block-all " , " block-udeb " , " unblock " , " unblock-udeb " , " force " , " force-badtest " , " force-skiptest " , " urgent " , " remove " ] :
2013-01-18 18:42:10 +00:00
if l [ 0 ] == ' approve ' : l [ 0 ] = ' unblock '
2011-09-04 16:41:33 +00:00
for package in l [ 1 : ] :
2011-09-04 18:24:54 +00:00
hints . add_hint ( ' %s %s ' % ( l [ 0 ] , package ) , who )
2011-09-04 16:41:33 +00:00
elif l [ 0 ] in [ " age-days " ] :
for package in l [ 2 : ] :
hints . add_hint ( ' %s %s %s ' % ( l [ 0 ] , l [ 1 ] , package ) , who )
else :
hints . add_hint ( l , who )
2006-06-17 13:45:56 +00:00
2013-09-24 13:58:05 +01:00
for x in [ " block " , " block-all " , " block-udeb " , " unblock " , " unblock-udeb " , " force " , " force-badtest " , " force-skiptest " , " urgent " , " remove " , " age-days " ] :
2006-06-17 13:45:56 +00:00
z = { }
2011-09-04 16:41:33 +00:00
for hint in hints [ x ] :
2011-09-04 19:46:38 +00:00
package = hint . package
2011-11-14 19:52:42 +00:00
key = ( hint , hint . user )
2011-12-18 14:53:04 +01:00
if package in z and z [ package ] != key :
2011-11-14 19:52:42 +00:00
hint2 = z [ package ] [ 0 ]
2010-02-28 14:44:37 +00:00
if x in [ ' unblock ' , ' unblock-udeb ' ] :
2011-12-18 21:42:14 +01:00
if apt_pkg . version_compare ( hint2 . version , hint . version ) < 0 :
2010-02-28 14:44:37 +00:00
# This hint is for a newer version, so discard the old one
2011-11-14 19:15:25 +00:00
self . __log ( " Overriding %s [ %s ] = ( ' %s ' , ' %s ' ) with ( ' %s ' , ' %s ' ) " %
2011-11-14 19:52:42 +00:00
( x , package , hint2 . version , hint2 . user , hint . version , hint . user ) , type = " W " )
hint2 . set_active ( False )
2010-02-28 14:44:37 +00:00
else :
2011-08-28 21:45:14 +00:00
# This hint is for an older version, so ignore it in favour of the new one
2011-11-14 19:15:25 +00:00
self . __log ( " Ignoring %s [ %s ] = ( ' %s ' , ' %s ' ), ( ' %s ' , ' %s ' ) is higher or equal " %
2011-11-14 19:52:42 +00:00
( x , package , hint . version , hint . user , hint2 . version , hint2 . user ) , type = " W " )
2011-09-04 16:41:33 +00:00
hint . set_active ( False )
2010-02-28 14:44:37 +00:00
else :
2011-11-14 19:52:42 +00:00
self . __log ( " Overriding %s [ %s ] = ( ' %s ' , ' %s ' , ' %s ' ) with ( ' %s ' , ' %s ' , ' %s ' ) " %
( x , package , hint2 . version , hint2 . user , hint2 . days ,
2011-11-14 19:15:25 +00:00
hint . version , hint . user , hint . days ) , type = " W " )
2011-11-14 19:52:42 +00:00
hint2 . set_active ( False )
2011-11-10 10:30:13 +00:00
2011-11-14 19:52:42 +00:00
z [ package ] = key
2006-06-17 13:45:56 +00:00
2010-02-28 14:44:37 +00:00
# Sanity check the hints hash
if len ( hints [ " block " ] ) == 0 and len ( hints [ " block-udeb " ] ) == 0 :
self . __log ( " WARNING: No block hints at all, not even udeb ones! " , type = " W " )
2006-06-17 13:45:56 +00:00
return hints
2013-10-31 10:33:04 -07:00
def read_blocks ( self , basedir ) :
""" Read user-supplied blocks from the specified directory.
The file contains rows with the format :
< source - name > < bug > < date >
The dates are expressed as the number of seconds from the Unix epoch
( 1970 - 01 - 01 00 : 00 : 00 UTC ) .
The method returns a dictionary where the key is the source package
name and the value is a list of ( bug , date ) tuples .
"""
blocks = { }
filename = os . path . join ( basedir , " Blocks " )
self . __log ( " Loading user-supplied block data from %s " % filename )
for line in open ( filename ) :
l = line . split ( )
if len ( l ) != 3 : continue
try :
2013-10-31 11:31:21 -07:00
blocks . setdefault ( l [ 0 ] , [ ] )
blocks [ l [ 0 ] ] . append ( ( l [ 1 ] , int ( l [ 2 ] ) ) )
2013-10-31 10:33:04 -07:00
except ValueError :
self . __log ( " Blocks, unable to parse \" %s \" " % line , type = " E " )
return blocks
2006-08-01 18:59:29 +00:00
2011-10-19 20:02:29 +00:00
# Utility methods for package analysis
2006-06-24 17:49:43 +00:00
# ------------------------------------
2006-06-17 13:45:56 +00:00
2011-12-29 13:54:43 +01:00
def get_dependency_solvers ( self , block , arch , distribution ) :
2006-06-24 17:49:43 +00:00
""" Find the packages which satisfy a dependency block
This method returns the list of packages which satisfy a dependency
2011-12-18 21:42:14 +01:00
block ( as returned by apt_pkg . parse_depends ) for the given architecture
2006-06-24 17:49:43 +00:00
and distribution .
It returns a tuple with two items : the first is a boolean which is
True if the dependency is satisfied , the second is the list of the
solving packages .
"""
2006-06-17 13:45:56 +00:00
packages = [ ]
2015-04-27 19:14:08 +00:00
# local copies for better performance
2006-07-28 07:59:05 +00:00
binaries = self . binaries [ distribution ] [ arch ]
2006-06-24 17:49:43 +00:00
# for every package, version and operation in the block
2006-06-17 13:45:56 +00:00
for name , version , op in block :
2013-09-16 15:02:45 +01:00
if " : " in name :
name , archqual = name . split ( " : " , 1 )
else :
archqual = None
2006-06-24 17:49:43 +00:00
# look for the package in unstable
2011-12-11 22:59:35 +01:00
if name in binaries [ 0 ] :
2006-07-28 07:59:05 +00:00
package = binaries [ 0 ] [ name ]
2013-09-16 15:02:45 +01:00
# check the versioned dependency and architecture qualifier
# (if present)
2013-09-18 20:40:00 +00:00
if ( op == ' ' and version == ' ' ) or apt_pkg . check_dep ( package [ VERSION ] , op , version ) :
2013-09-16 15:02:45 +01:00
if archqual is None or ( archqual == ' any ' and package [ MULTIARCH ] == ' allowed ' ) :
packages . append ( name )
2006-06-17 13:45:56 +00:00
2006-07-29 20:29:19 +00:00
# look for the package in the virtual packages list and loop on them
for prov in binaries [ 1 ] . get ( name , [ ] ) :
2011-12-11 22:59:35 +01:00
if prov not in binaries [ 0 ] : continue
2013-09-18 20:40:00 +00:00
# A provides only satisfies:
# - an unversioned dependency (per Policy Manual §7.5)
# - a dependency without an architecture qualifier
# (per analysis of apt code)
2013-09-16 15:02:45 +01:00
if op == ' ' and version == ' ' and archqual is None :
2006-07-29 20:29:19 +00:00
packages . append ( prov )
2006-06-17 13:45:56 +00:00
2015-04-26 18:20:10 +02:00
return packages
2006-06-17 13:45:56 +00:00
2011-12-11 22:59:35 +01:00
def excuse_unsat_deps ( self , pkg , src , arch , suite , excuse ) :
2006-06-24 17:49:43 +00:00
""" Find unsatisfied dependencies for a binary package
This method analyzes the dependencies of the binary package specified
by the parameter ` pkg ' , built from the source package `src ' , for the
architecture ` arch ' within the suite `suite ' . If the dependency can ' t
be satisfied in testing and / or unstable , it updates the excuse passed
as parameter .
"""
# retrieve the binary package from the specified suite and arch
2006-06-17 13:45:56 +00:00
binary_u = self . binaries [ suite ] [ arch ] [ 0 ] [ pkg ]
2006-06-24 17:49:43 +00:00
2013-09-18 20:40:00 +00:00
# local copies for better performance
2011-12-18 21:42:14 +01:00
parse_depends = apt_pkg . parse_depends
2006-07-28 07:59:05 +00:00
get_dependency_solvers = self . get_dependency_solvers
2006-06-24 17:49:43 +00:00
# analyze the dependency fields (if present)
2012-04-12 00:07:22 +02:00
if not binary_u [ DEPENDS ] :
2014-03-05 16:14:48 +00:00
return True
2012-04-12 00:07:22 +02:00
deps = binary_u [ DEPENDS ]
2006-06-17 13:45:56 +00:00
2014-03-05 15:03:45 +00:00
all_satisfiable = True
2013-09-18 20:40:00 +00:00
# for every dependency block (formed as conjunction of disjunction)
2012-04-12 00:07:22 +02:00
for block , block_txt in zip ( parse_depends ( deps , False ) , deps . split ( ' , ' ) ) :
# if the block is satisfied in testing, then skip the block
2015-04-26 18:20:10 +02:00
packages = get_dependency_solvers ( block , arch , ' testing ' )
if packages :
2012-04-12 00:07:22 +02:00
for p in packages :
if p not in self . binaries [ suite ] [ arch ] [ 0 ] : continue
excuse . add_sane_dep ( self . binaries [ suite ] [ arch ] [ 0 ] [ p ] [ SOURCE ] )
continue
2006-06-17 13:45:56 +00:00
2012-04-12 00:07:22 +02:00
# check if the block can be satisfied in unstable, and list the solving packages
2015-04-26 18:20:10 +02:00
packages = get_dependency_solvers ( block , arch , suite )
2012-04-12 00:07:22 +02:00
packages = [ self . binaries [ suite ] [ arch ] [ 0 ] [ p ] [ SOURCE ] for p in packages ]
2006-06-24 17:49:43 +00:00
2012-04-12 00:07:22 +02:00
# if the dependency can be satisfied by the same source package, skip the block:
# obviously both binary packages will enter testing together
if src in packages : continue
2006-06-17 13:45:56 +00:00
2012-04-12 00:07:22 +02:00
# if no package can satisfy the dependency, add this information to the excuse
2015-04-26 18:20:10 +02:00
if not packages :
2012-04-12 00:07:22 +02:00
excuse . addhtml ( " %s / %s unsatisfiable Depends: %s " % ( pkg , arch , block_txt . strip ( ) ) )
2015-04-26 18:20:10 +02:00
excuse . addreason ( " depends " )
2014-03-05 15:03:45 +00:00
all_satisfiable = False
2012-04-12 00:07:22 +02:00
continue
2006-06-17 13:45:56 +00:00
2012-04-12 00:07:22 +02:00
# for the solving packages, update the excuse to add the dependencies
for p in packages :
2015-06-02 21:33:52 +02:00
if arch not in self . options . break_arches :
2012-12-25 18:28:14 +00:00
if p in self . sources [ ' testing ' ] and self . sources [ ' testing ' ] [ p ] [ VERSION ] == self . sources [ suite ] [ p ] [ VERSION ] :
excuse . add_dep ( " %s / %s " % ( p , arch ) , arch )
else :
excuse . add_dep ( p , arch )
2012-04-12 00:07:22 +02:00
else :
excuse . add_break_dep ( p , arch )
2006-06-17 13:45:56 +00:00
2014-03-05 15:03:45 +00:00
return all_satisfiable
2010-02-28 14:44:37 +00:00
# Package analysis methods
2006-06-24 17:49:43 +00:00
# ------------------------
def should_remove_source ( self , pkg ) :
""" Check if a source package should be removed from testing
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
This method checks if a source package should be removed from the
2010-02-28 14:44:37 +00:00
testing distribution ; this happens if the source package is not
2006-06-24 17:49:43 +00:00
present in the unstable distribution anymore .
It returns True if the package can be removed , False otherwise .
2013-07-06 12:42:52 +00:00
In the former case , a new excuse is appended to the object
2006-06-24 17:49:43 +00:00
attribute excuses .
"""
2010-02-28 14:44:37 +00:00
# if the source package is available in unstable, then do nothing
2006-07-26 19:26:38 +00:00
if pkg in self . sources [ ' unstable ' ] :
2006-06-24 17:49:43 +00:00
return False
2015-04-27 19:14:08 +00:00
# otherwise, add a new excuse for its removal
2006-06-24 17:49:43 +00:00
src = self . sources [ ' testing ' ] [ pkg ]
excuse = Excuse ( " - " + pkg )
2013-12-11 21:56:51 +01:00
excuse . addhtml ( " Package not in unstable, will try to remove " )
2013-12-11 21:21:13 +01:00
excuse . addreason ( " remove " )
2014-07-24 15:28:12 +01:00
excuse . set_distribution ( self . options . distribution )
2006-08-18 13:47:20 +00:00
excuse . set_vers ( src [ VERSION ] , None )
src [ MAINTAINER ] and excuse . set_maint ( src [ MAINTAINER ] . strip ( ) )
src [ SECTION ] and excuse . set_section ( src [ SECTION ] . strip ( ) )
2006-08-07 11:06:04 +00:00
# if the package is blocked, skip it
2011-09-04 20:26:36 +00:00
for hint in self . hints . search ( ' block ' , package = pkg , removal = True ) :
2014-11-07 15:21:22 +00:00
excuse . addhtml ( " Not touching package, as requested by %s "
2014-12-10 12:24:34 +00:00
" (contact #ubuntu-release if update is needed) " % hint . user )
2008-01-12 19:19:26 +00:00
excuse . addhtml ( " Not considered " )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " block " )
2008-01-12 19:19:26 +00:00
self . excuses . append ( excuse )
2006-08-07 11:06:04 +00:00
return False
2012-01-06 14:58:14 +01:00
excuse . is_valid = True
2006-06-24 17:49:43 +00:00
self . excuses . append ( excuse )
return True
2013-07-10 20:01:03 +02:00
def should_upgrade_srcarch ( self , src , arch , suite , same_source = same_source ) :
2013-07-06 11:21:53 +00:00
""" Check if a set of binary packages should be upgraded
2006-06-24 17:49:43 +00:00
2013-07-06 11:21:53 +00:00
This method checks if the binary packages produced by the source
package on the given architecture should be upgraded ; this can
happen also if the migration is a binary - NMU for the given arch .
2015-01-22 15:16:49 -02:00
2013-07-06 11:21:53 +00:00
It returns False if the given packages don ' t need to be upgraded,
2006-06-24 17:49:43 +00:00
True otherwise . In the former case , a new excuse is appended to
2013-07-06 12:42:52 +00:00
the object attribute excuses .
2013-07-10 20:01:03 +02:00
same_source is an optimization to avoid " load global " .
2006-06-24 17:49:43 +00:00
"""
# retrieve the source packages for testing and suite
2006-06-17 13:45:56 +00:00
source_t = self . sources [ ' testing ' ] [ src ]
source_u = self . sources [ suite ] [ src ]
2006-06-24 17:49:43 +00:00
# build the common part of the excuse, which will be filled by the code below
2006-06-17 13:45:56 +00:00
ref = " %s / %s %s " % ( src , arch , suite != ' unstable ' and " _ " + suite or " " )
excuse = Excuse ( ref )
2014-07-24 15:28:12 +01:00
excuse . set_distribution ( self . options . distribution )
2006-08-18 13:47:20 +00:00
excuse . set_vers ( source_t [ VERSION ] , source_t [ VERSION ] )
source_u [ MAINTAINER ] and excuse . set_maint ( source_u [ MAINTAINER ] . strip ( ) )
source_u [ SECTION ] and excuse . set_section ( source_u [ SECTION ] . strip ( ) )
2015-01-22 15:16:49 -02:00
2010-02-28 14:44:37 +00:00
# if there is a `remove' hint and the requested version is the same as the
2006-06-24 17:49:43 +00:00
# version in testing, then stop here and return False
2013-07-06 11:26:11 +00:00
# (as a side effect, a removal may generate such excuses for both the source
2013-07-06 11:21:53 +00:00
# package and its binary packages on each architecture)
2013-07-10 20:01:03 +02:00
for hint in [ x for x in self . hints . search ( ' remove ' , package = src ) if same_source ( source_t [ VERSION ] , x . version ) ] :
2011-09-04 16:41:33 +00:00
excuse . addhtml ( " Removal request by %s " % ( hint . user ) )
2006-06-17 13:45:56 +00:00
excuse . addhtml ( " Trying to remove package, not update it " )
excuse . addhtml ( " Not considered " )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " remove " )
2006-06-17 13:45:56 +00:00
self . excuses . append ( excuse )
return False
2006-06-24 17:49:43 +00:00
# the starting point is that there is nothing wrong and nothing worth doing
anywrongver = False
anyworthdoing = False
2014-03-05 15:03:45 +00:00
unsat_deps = False
2006-06-24 17:49:43 +00:00
# for every binary package produced by this source in unstable for this architecture
2015-04-26 18:20:10 +02:00
for pkg in sorted ( filter ( lambda x : x . endswith ( " / " + arch ) , source_u [ BINARIES ] ) , key = lambda x : x . split ( " / " ) [ 0 ] ) :
2006-06-17 13:45:56 +00:00
pkg_name = pkg . split ( " / " ) [ 0 ]
2006-06-24 17:49:43 +00:00
# retrieve the testing (if present) and unstable corresponding binary packages
2006-08-18 13:47:20 +00:00
binary_t = pkg in source_t [ BINARIES ] and self . binaries [ ' testing ' ] [ arch ] [ 0 ] [ pkg_name ] or None
2013-10-01 14:53:47 +01:00
if hasattr ( self . options , ' partial_unstable ' ) and binary_t is not None and binary_t [ ARCHITECTURE ] == ' all ' and pkg_name not in self . binaries [ suite ] [ arch ] [ 0 ] :
excuse . addhtml ( " Ignoring %s %s (from %s ) as it is arch: all and not yet built in unstable " % ( pkg_name , binary_t [ VERSION ] , binary_t [ SOURCEVER ] ) )
continue
2006-06-17 13:45:56 +00:00
binary_u = self . binaries [ suite ] [ arch ] [ 0 ] [ pkg_name ]
2006-06-24 17:49:43 +00:00
# this is the source version for the new binary package
2014-08-05 07:56:29 +02:00
pkgsv = binary_u [ SOURCEVER ]
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the new binary package is architecture-independent, then skip it
2006-08-18 13:47:20 +00:00
if binary_u [ ARCHITECTURE ] == ' all ' :
excuse . addhtml ( " Ignoring %s %s (from %s ) as it is arch: all " % ( pkg_name , binary_u [ VERSION ] , pkgsv ) )
2006-06-17 13:45:56 +00:00
continue
2006-06-24 17:49:43 +00:00
# if the new binary package is not from the same source as the testing one, then skip it
2013-07-06 11:21:53 +00:00
# this implies that this binary migration is part of a source migration
2013-07-10 20:01:03 +02:00
if not same_source ( source_t [ VERSION ] , pkgsv ) :
2013-06-26 17:57:37 +01:00
if binary_t is None or binary_t [ VERSION ] != binary_u [ VERSION ] :
anywrongver = True
excuse . addhtml ( " From wrong source: %s %s ( %s not %s ) " % ( pkg_name , binary_u [ VERSION ] , pkgsv , source_t [ VERSION ] ) )
break
2006-06-17 13:45:56 +00:00
2013-06-08 15:40:07 +00:00
# if the source package has been updated in unstable and this is a binary migration, skip it
2013-07-06 11:21:53 +00:00
# (the binaries are now out-of-date)
2013-07-10 20:01:03 +02:00
if same_source ( source_t [ VERSION ] , pkgsv ) and source_t [ VERSION ] != source_u [ VERSION ] :
2013-06-08 15:40:07 +00:00
anywrongver = True
excuse . addhtml ( " From wrong source: %s %s ( %s not %s ) " % ( pkg_name , binary_u [ VERSION ] , pkgsv , source_u [ VERSION ] ) )
break
2006-06-24 17:49:43 +00:00
# find unsatisfied dependencies for the new binary package
2014-03-05 15:03:45 +00:00
if not self . excuse_unsat_deps ( pkg_name , src , arch , suite , excuse ) :
2014-03-05 15:12:45 +00:00
unsat_deps = True
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the binary is not present in testing, then it is a new binary;
# in this case, there is something worth doing
2006-06-17 13:45:56 +00:00
if not binary_t :
2006-08-18 13:47:20 +00:00
excuse . addhtml ( " New binary: %s ( %s ) " % ( pkg_name , binary_u [ VERSION ] ) )
2006-06-17 13:45:56 +00:00
anyworthdoing = True
continue
2006-06-24 17:49:43 +00:00
# at this point, the binary package is present in testing, so we can compare
# the versions of the packages ...
2011-12-18 21:42:14 +01:00
vcompare = apt_pkg . version_compare ( binary_t [ VERSION ] , binary_u [ VERSION ] )
2006-06-24 17:49:43 +00:00
# ... if updating would mean downgrading, then stop here: there is something wrong
2006-06-17 13:45:56 +00:00
if vcompare > 0 :
anywrongver = True
2006-08-18 13:47:20 +00:00
excuse . addhtml ( " Not downgrading: %s ( %s to %s ) " % ( pkg_name , binary_t [ VERSION ] , binary_u [ VERSION ] ) )
2006-06-17 13:45:56 +00:00
break
2006-06-24 17:49:43 +00:00
# ... if updating would mean upgrading, then there is something worth doing
2006-06-17 13:45:56 +00:00
elif vcompare < 0 :
2006-08-18 13:47:20 +00:00
excuse . addhtml ( " Updated binary: %s ( %s to %s ) " % ( pkg_name , binary_t [ VERSION ] , binary_u [ VERSION ] ) )
2006-06-17 13:45:56 +00:00
anyworthdoing = True
2006-06-24 17:49:43 +00:00
# if there is nothing wrong and there is something worth doing or the source
2010-02-28 14:44:37 +00:00
# package is not fake, then check what packages should be removed
2008-05-17 15:57:12 +00:00
if not anywrongver and ( anyworthdoing or not self . sources [ suite ] [ src ] [ FAKESRC ] ) :
2006-08-18 13:47:20 +00:00
srcv = self . sources [ suite ] [ src ] [ VERSION ]
2013-07-10 20:01:03 +02:00
ssrc = same_source ( source_t [ VERSION ] , srcv )
2013-02-02 22:47:56 +00:00
# if this is a binary-only migration via *pu, we never want to try
# removing binary packages
if not ( ssrc and suite != ' unstable ' ) :
# for every binary package produced by this source in testing for this architecture
2013-07-09 18:11:22 +02:00
source_data = self . sources [ ' testing ' ] [ src ]
2014-06-08 17:05:23 +02:00
_ , _ , smoothbins = self . _compute_groups ( src ,
" unstable " ,
arch ,
False )
2013-07-09 18:11:22 +02:00
2013-08-11 15:23:45 +02:00
for pkg in sorted ( x . split ( " / " ) [ 0 ] for x in source_data [ BINARIES ] if x . endswith ( " / " + arch ) ) :
2013-02-02 22:47:56 +00:00
# if the package is architecture-independent, then ignore it
2013-07-09 18:11:22 +02:00
tpkg_data = self . binaries [ ' testing ' ] [ arch ] [ 0 ] [ pkg ]
if tpkg_data [ ARCHITECTURE ] == ' all ' :
2013-02-02 22:47:56 +00:00
excuse . addhtml ( " Ignoring removal of %s as it is arch: all " % ( pkg ) )
continue
# if the package is not produced by the new source package, then remove it from testing
if pkg not in self . binaries [ suite ] [ arch ] [ 0 ] :
2013-07-09 18:11:22 +02:00
excuse . addhtml ( " Removed binary: %s %s " % ( pkg , tpkg_data [ VERSION ] ) )
2013-07-06 11:21:53 +00:00
# the removed binary is only interesting if this is a binary-only migration,
# as otherwise the updated source will already cause the binary packages
# to be updated
2013-07-09 18:11:22 +02:00
if ssrc :
2013-09-18 20:40:00 +00:00
# Special-case, if the binary is a candidate for a smooth update, we do not consider
2013-07-09 18:11:22 +02:00
# it "interesting" on its own. This case happens quite often with smooth updatable
# packages, where the old binary "survives" a full run because it still has
# reverse dependencies.
2014-07-13 10:01:14 +02:00
name = ( pkg , tpkg_data [ VERSION ] , tpkg_data [ ARCHITECTURE ] )
2013-07-09 18:11:22 +02:00
if name not in smoothbins :
anyworthdoing = True
2006-06-17 13:45:56 +00:00
2010-02-28 14:44:37 +00:00
# if there is nothing wrong and there is something worth doing, this is a valid candidate
2014-03-05 15:03:45 +00:00
if not anywrongver and not unsat_deps and anyworthdoing :
2012-01-06 14:58:14 +01:00
excuse . is_valid = True
2006-06-17 13:45:56 +00:00
self . excuses . append ( excuse )
2006-07-22 07:31:22 +00:00
return True
2006-06-24 17:49:43 +00:00
# else if there is something worth doing (but something wrong, too) this package won't be considered
2006-06-17 13:45:56 +00:00
elif anyworthdoing :
excuse . addhtml ( " Not considered " )
self . excuses . append ( excuse )
2006-07-20 19:11:48 +00:00
# otherwise, return False
return False
2006-06-17 13:45:56 +00:00
2013-07-10 20:01:03 +02:00
def should_upgrade_src ( self , src , suite , same_source = same_source ) :
2006-06-24 17:49:43 +00:00
""" Check if source package should be upgraded
2010-02-28 14:44:37 +00:00
This method checks if a source package should be upgraded . The analysis
2015-01-22 15:16:49 -02:00
is performed for the source package specified by the ` src ' parameter,
2011-12-15 21:31:44 +00:00
for the distribution ` suite ' .
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
It returns False if the given package doesn ' t need to be upgraded,
True otherwise . In the former case , a new excuse is appended to
2011-05-31 20:57:59 +00:00
the object attribute excuses .
2013-07-10 20:01:03 +02:00
same_source is an opt to avoid " load global " .
2006-06-24 17:49:43 +00:00
"""
# retrieve the source packages for testing (if available) and suite
2006-06-17 13:45:56 +00:00
source_u = self . sources [ suite ] [ src ]
if src in self . sources [ ' testing ' ] :
source_t = self . sources [ ' testing ' ] [ src ]
2006-06-24 17:49:43 +00:00
# if testing and unstable have the same version, then this is a candidate for binary-NMUs only
2011-12-18 21:42:14 +01:00
if apt_pkg . version_compare ( source_t [ VERSION ] , source_u [ VERSION ] ) == 0 :
2006-06-17 13:45:56 +00:00
return False
else :
source_t = None
2006-06-24 17:49:43 +00:00
# build the common part of the excuse, which will be filled by the code below
2006-06-17 13:45:56 +00:00
ref = " %s %s " % ( src , suite != ' unstable ' and " _ " + suite or " " )
excuse = Excuse ( ref )
2014-07-24 15:28:12 +01:00
excuse . set_distribution ( self . options . distribution )
2006-08-18 13:47:20 +00:00
excuse . set_vers ( source_t and source_t [ VERSION ] or None , source_u [ VERSION ] )
source_u [ MAINTAINER ] and excuse . set_maint ( source_u [ MAINTAINER ] . strip ( ) )
source_u [ SECTION ] and excuse . set_section ( source_u [ SECTION ] . strip ( ) )
2006-06-24 17:49:43 +00:00
2013-06-25 18:15:43 +01:00
# the starting point is that we will update the candidate and run autopkgtests
2006-06-24 17:49:43 +00:00
update_candidate = True
2013-06-25 18:15:43 +01:00
run_autopkgtest = True
2015-01-30 17:51:44 -05:00
run_boottest = True
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
# if the version in unstable is older, then stop here with a warning in the excuse and return False
2011-12-18 21:42:14 +01:00
if source_t and apt_pkg . version_compare ( source_u [ VERSION ] , source_t [ VERSION ] ) < 0 :
2006-08-18 13:47:20 +00:00
excuse . addhtml ( " ALERT: %s is newer in testing ( %s %s ) " % ( src , source_t [ VERSION ] , source_u [ VERSION ] ) )
2006-06-17 13:45:56 +00:00
self . excuses . append ( excuse )
2015-04-26 18:20:10 +02:00
excuse . addreason ( " newerintesting " )
2006-06-17 13:45:56 +00:00
return False
2006-06-24 17:49:43 +00:00
# check if the source package really exists or if it is a fake one
2006-08-18 13:47:20 +00:00
if source_u [ FAKESRC ] :
2006-06-24 17:49:43 +00:00
excuse . addhtml ( " %s source package doesn ' t exist " % ( src ) )
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2006-06-24 17:49:43 +00:00
# retrieve the urgency for the upload, ignoring it if this is a NEW package (not present in testing)
2006-06-17 13:45:56 +00:00
urgency = self . urgencies . get ( src , self . options . default_urgency )
2013-12-01 19:01:19 +01:00
if not source_t :
if self . MINDAYS [ urgency ] < self . MINDAYS [ self . options . default_urgency ] :
excuse . addhtml ( " Ignoring %s urgency setting for NEW package " % ( urgency ) )
urgency = self . options . default_urgency
2006-06-17 13:45:56 +00:00
2010-02-28 14:44:37 +00:00
# if there is a `remove' hint and the requested version is the same as the
2006-06-24 17:49:43 +00:00
# version in testing, then stop here and return False
2011-09-04 20:26:36 +00:00
for item in self . hints . search ( ' remove ' , package = src ) :
2013-07-10 20:01:03 +02:00
if source_t and same_source ( source_t [ VERSION ] , item . version ) or \
same_source ( source_u [ VERSION ] , item . version ) :
2011-09-04 16:41:33 +00:00
excuse . addhtml ( " Removal request by %s " % ( item . user ) )
2006-06-17 13:45:56 +00:00
excuse . addhtml ( " Trying to remove package, not update it " )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " remove " )
2006-06-19 19:54:21 +00:00
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2006-06-17 13:45:56 +00:00
2009-08-15 16:39:00 +01:00
# check if there is a `block' or `block-udeb' hint for this package, or a `block-all source' hint
blocked = { }
2011-09-04 20:26:36 +00:00
for hint in self . hints . search ( package = src ) :
2012-04-03 21:44:32 +00:00
if hint . type == ' block ' :
2011-09-04 16:41:33 +00:00
blocked [ ' block ' ] = hint
if hint . type == ' block-udeb ' :
blocked [ ' block-udeb ' ] = hint
2012-04-03 21:44:32 +00:00
for hint in self . hints . search ( type = ' block-all ' , package = ' source ' ) :
blocked . setdefault ( ' block ' , hint )
2013-01-18 18:52:07 +00:00
if suite in [ ' pu ' , ' tpu ' ] :
blocked [ ' block ' ] = ' %s -block ' % ( suite )
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the source is blocked, then look for an `unblock' hint; the unblock request
2009-08-15 16:39:00 +01:00
# is processed only if the specified version is correct. If a package is blocked
# by `block-udeb', then `unblock-udeb' must be present to cancel it.
for block_cmd in blocked :
unblock_cmd = " un " + block_cmd
2011-09-04 20:26:36 +00:00
unblocks = self . hints . search ( unblock_cmd , package = src )
2011-11-10 10:30:13 +00:00
2013-07-10 20:01:03 +02:00
if unblocks and unblocks [ 0 ] . version is not None and same_source ( unblocks [ 0 ] . version , source_u [ VERSION ] ) :
2013-01-18 18:52:07 +00:00
if suite == ' unstable ' or block_cmd == ' block-udeb ' :
excuse . addhtml ( " Ignoring %s request by %s , due to %s request by %s " %
( block_cmd , blocked [ block_cmd ] . user , unblock_cmd , unblocks [ 0 ] . user ) )
else :
excuse . addhtml ( " Approved by %s " % ( unblocks [ 0 ] . user ) )
2006-06-24 17:49:43 +00:00
else :
2011-09-04 16:41:33 +00:00
if unblocks :
2013-06-25 11:54:53 +01:00
if unblocks [ 0 ] . version is None :
excuse . addhtml ( " %s request by %s ignored due to missing version " %
( unblock_cmd . capitalize ( ) , unblocks [ 0 ] . user ) )
else :
excuse . addhtml ( " %s request by %s ignored due to version mismatch: %s " %
( unblock_cmd . capitalize ( ) , unblocks [ 0 ] . user , unblocks [ 0 ] . version ) )
2013-01-18 18:52:07 +00:00
if suite == ' unstable ' or block_cmd == ' block-udeb ' :
2015-08-24 20:46:42 +02:00
tooltip = " contact #ubuntu-release if update is needed "
2015-08-11 22:26:57 +00:00
# redirect people to d-i RM for udeb things:
if block_cmd == ' block-udeb ' :
tooltip = " please contact the d-i release manager if an update is needed "
excuse . addhtml ( " Not touching package due to %s request by %s ( %s ) " %
( block_cmd , blocked [ block_cmd ] . user , tooltip ) )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " block " )
2013-01-18 18:52:07 +00:00
else :
excuse . addhtml ( " NEEDS APPROVAL BY RM " )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " block " )
2006-06-17 13:45:56 +00:00
update_candidate = False
2013-10-31 10:33:04 -07:00
if src in self . blocks :
for user_block in self . blocks [ src ] :
excuse . addhtml ( " Not touching package as requested in <a href= \" https://launchpad.net/bugs/ %s \" >bug %s </a> on %s " %
2013-10-31 11:34:24 -07:00
( user_block [ 0 ] , user_block [ 0 ] , time . asctime ( time . gmtime ( user_block [ 1 ] ) ) ) )
2014-12-10 10:36:01 +00:00
excuse . addreason ( " block " )
2013-10-31 10:33:04 -07:00
update_candidate = False
2006-06-24 17:49:43 +00:00
# if the suite is unstable, then we have to check the urgency and the minimum days of
# permanence in unstable before updating testing; if the source package is too young,
2008-01-12 18:41:03 +00:00
# the check fails and we set update_candidate to False to block the update; consider
# the age-days hint, if specified for the package
2013-09-25 15:00:17 +01:00
if suite == ' unstable ' :
2006-07-26 19:26:38 +00:00
if src not in self . dates :
2006-08-18 13:47:20 +00:00
self . dates [ src ] = ( source_u [ VERSION ] , self . date_now )
2013-07-10 20:01:03 +02:00
elif not same_source ( self . dates [ src ] [ 0 ] , source_u [ VERSION ] ) :
2006-08-18 13:47:20 +00:00
self . dates [ src ] = ( source_u [ VERSION ] , self . date_now )
2006-06-17 13:45:56 +00:00
2013-09-25 14:09:34 +01:00
days_old = ( self . date_now - self . dates [ src ] [ 1 ] ) / 60 / 60 / 24
2006-06-17 13:45:56 +00:00
min_days = self . MINDAYS [ urgency ]
2008-01-12 18:41:03 +00:00
2011-09-04 20:26:36 +00:00
for age_days_hint in [ x for x in self . hints . search ( ' age-days ' , package = src ) if \
2013-07-10 20:01:03 +02:00
same_source ( source_u [ VERSION ] , x . version ) ] :
2008-01-12 18:41:03 +00:00
excuse . addhtml ( " Overriding age needed from %d days to %d by %s " % ( min_days ,
2011-09-04 16:41:33 +00:00
int ( age_days_hint . days ) , age_days_hint . user ) )
min_days = int ( age_days_hint . days )
2008-01-12 18:41:03 +00:00
2006-06-17 13:45:56 +00:00
excuse . setdaysold ( days_old , min_days )
if days_old < min_days :
2011-09-04 20:26:36 +00:00
urgent_hints = [ x for x in self . hints . search ( ' urgent ' , package = src ) if \
2013-07-10 20:01:03 +02:00
same_source ( source_u [ VERSION ] , x . version ) ]
2011-09-04 16:41:33 +00:00
if urgent_hints :
excuse . addhtml ( " Too young, but urgency pushed by %s " % ( urgent_hints [ 0 ] . user ) )
2006-06-17 13:45:56 +00:00
else :
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2013-12-10 22:27:32 +01:00
excuse . addreason ( " age " )
2006-06-17 13:45:56 +00:00
2011-07-27 09:30:00 +00:00
if suite in [ ' pu ' , ' tpu ' ] :
# o-o-d(ish) checks for (t-)p-u
2010-09-20 22:03:43 +00:00
for arch in self . options . architectures :
2013-02-06 19:05:16 +00:00
if src not in self . sources [ " testing " ] :
continue
2015-01-22 15:16:49 -02:00
2013-02-06 19:05:16 +00:00
# if the package in testing has no binaries on this
# architecture, it can't be out-of-date
2013-02-06 19:09:04 +00:00
if not any ( x for x in self . sources [ " testing " ] [ src ] [ BINARIES ]
if x . endswith ( " / " + arch ) and self . binaries [ " testing " ] [ arch ] [ 0 ] [ x . split ( " / " ) [ 0 ] ] [ ARCHITECTURE ] != ' all ' ) :
2013-02-06 19:05:16 +00:00
continue
2015-01-22 15:16:49 -02:00
2013-02-06 19:05:16 +00:00
# if the (t-)p-u package has produced any binaries on
# this architecture then we assume it's ok. this allows for
# uploads to (t-)p-u which intentionally drop binary
# packages
2013-02-06 19:09:04 +00:00
if any ( x for x in self . binaries [ suite ] [ arch ] [ 0 ] . values ( ) \
if x [ SOURCE ] == src and x [ SOURCEVER ] == source_u [ VERSION ] and \
x [ ARCHITECTURE ] != ' all ' ) :
2010-09-20 22:03:43 +00:00
continue
2011-07-27 09:30:00 +00:00
if suite == ' tpu ' :
base = ' testing '
else :
base = ' stable '
2015-08-24 20:46:42 +02:00
text = " Not yet built on <a href= \" https://launchpad.net/ %s /+source/ %s / %s /+latestbuild/ %s \" target= \" _blank \" > %s </a> (relative to testing) " % ( self . options . distribution , quote ( src . split ( " / " ) [ 0 ] ) , quote ( source_u [ VERSION ] ) , quote ( arch ) , arch )
2010-09-20 22:03:43 +00:00
2015-08-24 20:46:42 +02:00
if arch in self . options . outofsync_arches :
2010-09-20 22:03:43 +00:00
text = text + " (but %s isn ' t keeping up, so never mind) " % ( arch )
else :
update_candidate = False
2013-07-02 11:59:29 +01:00
if arch in self . options . adt_arches . split ( ) :
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
if arch in self . options . boottest_arches . split ( ) :
run_boottest = False
2013-12-10 22:27:32 +01:00
excuse . addreason ( " arch " )
excuse . addreason ( " arch- %s " % arch )
2014-11-08 11:33:05 +00:00
excuse . addreason ( " build-arch " )
excuse . addreason ( " build-arch- %s " % arch )
2010-09-20 22:03:43 +00:00
excuse . addhtml ( text )
2010-02-28 14:44:37 +00:00
# at this point, we check the status of the builds on all the supported architectures
2006-06-24 17:49:43 +00:00
# to catch the out-of-date ones
2006-06-17 13:45:56 +00:00
pkgs = { src : [ " source " ] }
2012-12-03 18:01:09 +00:00
built_anywhere = False
2006-06-19 19:54:21 +00:00
for arch in self . options . architectures :
2006-06-17 13:45:56 +00:00
oodbins = { }
2014-11-08 11:33:05 +00:00
uptodatebins = False
2006-06-24 17:49:43 +00:00
# for every binary package produced by this source in the suite for this architecture
2013-08-11 15:23:45 +02:00
for pkg in sorted ( x . split ( " / " ) [ 0 ] for x in self . sources [ suite ] [ src ] [ BINARIES ] if x . endswith ( " / " + arch ) ) :
2006-07-26 19:26:38 +00:00
if pkg not in pkgs : pkgs [ pkg ] = [ ]
2006-06-17 13:45:56 +00:00
pkgs [ pkg ] . append ( arch )
2006-06-24 17:49:43 +00:00
# retrieve the binary package and its source version
2006-06-17 13:45:56 +00:00
binary_u = self . binaries [ suite ] [ arch ] [ 0 ] [ pkg ]
2006-08-18 13:47:20 +00:00
pkgsv = binary_u [ SOURCEVER ]
2006-06-24 17:49:43 +00:00
2011-05-19 07:56:17 +00:00
# if it wasn't built by the same source, it is out-of-date
2015-04-27 19:14:08 +00:00
# if there is at least one binary which is up-to-date, there
2014-11-08 11:33:05 +00:00
# is a build on this arch
2013-07-10 20:01:03 +02:00
if not same_source ( source_u [ VERSION ] , pkgsv ) :
2006-07-26 19:26:38 +00:00
if pkgsv not in oodbins :
2006-06-17 13:45:56 +00:00
oodbins [ pkgsv ] = [ ]
oodbins [ pkgsv ] . append ( pkg )
continue
2014-11-08 11:33:05 +00:00
else :
uptodatebins = True
2014-12-10 12:24:34 +00:00
built_anywhere = True
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the package is architecture-dependent or the current arch is `nobreakall'
# find unsatisfied dependencies for the binary package
2015-06-02 21:33:52 +02:00
if binary_u [ ARCHITECTURE ] != ' all ' or arch in self . options . nobreakall_arches :
2014-03-05 15:03:45 +00:00
if not self . excuse_unsat_deps ( pkg , src , arch , suite , excuse ) :
update_candidate = False
if arch in self . options . adt_arches . split ( ) :
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
if arch in self . options . boottest_arches . split ( ) :
run_boottest = False
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if there are out-of-date packages, warn about them in the excuse and set update_candidate
# to False to block the update; if the architecture where the package is out-of-date is
2013-09-09 12:37:52 +01:00
# in the `outofsync_arches' list, then do not block the update
2006-06-17 13:45:56 +00:00
if oodbins :
oodtxt = " "
for v in oodbins . keys ( ) :
if oodtxt : oodtxt = oodtxt + " ; "
2014-07-24 15:28:12 +01:00
oodtxt = oodtxt + " %s (from <a href= \" https://launchpad.net/ %s /+source/ " \
2015-01-09 11:57:33 +00:00
" %s / %s /+latestbuild/ %s \" target= \" _blank \" > %s </a>) " % \
2015-08-24 20:46:42 +02:00
( " , " . join ( sorted ( oodbins [ v ] ) ) , self . options . distribution , quote ( src . split ( " / " ) [ 0 ] ) , quote ( v ) , quote ( arch ) , v )
2014-11-08 11:33:05 +00:00
if uptodatebins :
2014-12-10 12:24:34 +00:00
text = " old binaries left on <a href= \" https://launchpad.net/ %s /+source/ " \
2015-01-09 11:57:33 +00:00
" %s / %s /+latestbuild/ %s \" target= \" _blank \" > %s </a>: %s " % \
2015-08-24 20:46:42 +02:00
( self . options . distribution , quote ( src . split ( " / " ) [ 0 ] ) , quote ( source_u [ VERSION ] ) , quote ( arch ) , arch , oodtxt )
2014-11-08 11:33:05 +00:00
else :
2014-12-10 12:24:34 +00:00
text = " missing build on <a href= \" https://launchpad.net/ %s /+source/ " \
2015-01-09 11:57:33 +00:00
" %s / %s /+latestbuild/ %s \" target= \" _blank \" > %s </a>: %s " % \
2015-08-24 20:46:42 +02:00
( self . options . distribution , quote ( src . split ( " / " ) [ 0 ] ) , quote ( source_u [ VERSION ] ) , quote ( arch ) , arch , oodtxt )
2006-06-17 13:45:56 +00:00
2015-08-24 20:46:42 +02:00
if arch in self . options . outofsync_arches :
2006-06-17 13:45:56 +00:00
text = text + " (but %s isn ' t keeping up, so nevermind) " % ( arch )
else :
update_candidate = False
2013-07-02 11:59:29 +01:00
if arch in self . options . adt_arches . split ( ) :
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
if arch in self . options . boottest_arches . split ( ) :
run_boottest = False
2013-12-10 22:27:32 +01:00
excuse . addreason ( " arch " )
excuse . addreason ( " arch- %s " % arch )
2014-11-08 11:33:05 +00:00
if uptodatebins :
excuse . addreason ( " cruft-arch " )
excuse . addreason ( " cruft-arch- %s " % arch )
else :
excuse . addreason ( " build-arch " )
excuse . addreason ( " build-arch- %s " % arch )
2006-06-17 13:45:56 +00:00
2013-09-25 14:12:27 +01:00
excuse . addhtml ( text )
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the source package has no binaries, set update_candidate to False to block the update
2006-08-18 13:47:20 +00:00
if len ( self . sources [ suite ] [ src ] [ BINARIES ] ) == 0 :
2006-06-17 13:45:56 +00:00
excuse . addhtml ( " %s has no binaries on any arch " % src )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " no-binaries " )
2006-06-17 13:45:56 +00:00
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2012-12-03 18:01:09 +00:00
elif not built_anywhere :
excuse . addhtml ( " %s has no up-to-date binaries on any arch " % src )
2014-12-10 10:36:01 +00:00
excuse . addreason ( " no-binaries " )
2012-12-03 18:01:09 +00:00
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2006-06-17 13:45:56 +00:00
2010-02-28 14:44:36 +00:00
# if the suite is unstable, then we have to check the release-critical bug lists before
# updating testing; if the unstable package has RC bugs that do not apply to the testing
2013-09-18 20:40:00 +00:00
# one, the check fails and we set update_candidate to False to block the update
2006-06-17 13:45:56 +00:00
if suite == ' unstable ' :
2013-08-11 15:23:45 +02:00
for pkg in pkgs :
2011-05-14 16:42:49 +00:00
bugs_t = [ ]
bugs_u = [ ]
2011-12-18 14:53:04 +01:00
if pkg in self . bugs [ ' testing ' ] :
2011-05-14 22:43:30 +00:00
bugs_t . extend ( self . bugs [ ' testing ' ] [ pkg ] )
2011-12-18 14:53:04 +01:00
if pkg in self . bugs [ ' unstable ' ] :
2011-05-14 22:43:30 +00:00
bugs_u . extend ( self . bugs [ ' unstable ' ] [ pkg ] )
2011-05-14 16:42:49 +00:00
if ' source ' in pkgs [ pkg ] :
spkg = " src: %s " % ( pkg )
2011-12-18 14:53:04 +01:00
if spkg in self . bugs [ ' testing ' ] :
2011-05-14 22:43:30 +00:00
bugs_t . extend ( self . bugs [ ' testing ' ] [ spkg ] )
2011-12-18 14:53:04 +01:00
if spkg in self . bugs [ ' unstable ' ] :
2011-05-14 22:43:30 +00:00
bugs_u . extend ( self . bugs [ ' unstable ' ] [ spkg ] )
2015-01-22 15:16:49 -02:00
2011-05-14 16:42:49 +00:00
new_bugs = sorted ( set ( bugs_u ) . difference ( bugs_t ) )
old_bugs = sorted ( set ( bugs_t ) . difference ( bugs_u ) )
2008-01-12 18:41:03 +00:00
2013-12-10 22:27:32 +01:00
excuse . setbugs ( old_bugs , new_bugs )
2008-01-12 18:41:03 +00:00
if len ( new_bugs ) > 0 :
excuse . addhtml ( " %s ( %s ) <a href= \" http://bugs.debian.org/cgi-bin/pkgreport.cgi? " \
" which=pkg&data= %s &sev-inc=critical&sev-inc=grave&sev-inc=serious \" " \
2015-04-26 18:20:10 +02:00
" target= \" _blank \" >has new bugs</a>! " % ( pkg , " , " . join ( pkgs [ pkg ] ) , quote ( pkg ) ) )
2008-01-12 18:41:03 +00:00
excuse . addhtml ( " Updating %s introduces new bugs: %s " % ( pkg , " , " . join (
2015-04-26 18:20:10 +02:00
[ " <a href= \" http://bugs.debian.org/ %s \" ># %s </a> " % ( quote ( a ) , a ) for a in new_bugs ] ) ) )
2006-06-17 13:45:56 +00:00
update_candidate = False
2013-06-25 18:15:43 +01:00
run_autopkgtest = False
2015-01-30 17:51:44 -05:00
run_boottest = False
2013-12-10 22:27:32 +01:00
excuse . addreason ( " buggy " )
2008-01-12 18:41:03 +00:00
if len ( old_bugs ) > 0 :
excuse . addhtml ( " Updating %s fixes old bugs: %s " % ( pkg , " , " . join (
2015-04-26 18:20:10 +02:00
[ " <a href= \" http://bugs.debian.org/ %s \" ># %s </a> " % ( quote ( a ) , a ) for a in old_bugs ] ) ) )
2008-01-12 19:19:26 +00:00
if len ( old_bugs ) > len ( new_bugs ) and len ( new_bugs ) > 0 :
2008-01-12 18:41:03 +00:00
excuse . addhtml ( " %s introduces new bugs, so still ignored (even "
" though it fixes more than it introduces, whine at debian-release) " % pkg )
2006-06-24 17:49:43 +00:00
# check if there is a `force' hint for this package, which allows it to go in even if it is not updateable
2013-07-10 20:01:03 +02:00
forces = [ x for x in self . hints . search ( ' force ' , package = src ) if same_source ( source_u [ VERSION ] , x . version ) ]
2011-09-04 16:41:33 +00:00
if forces :
2012-01-06 14:58:14 +01:00
excuse . dontinvalidate = True
2011-09-04 16:41:33 +00:00
if not update_candidate and forces :
excuse . addhtml ( " Should ignore, but forced by %s " % ( forces [ 0 ] . user ) )
2013-12-11 21:21:15 +01:00
excuse . force ( )
2006-06-17 13:45:56 +00:00
update_candidate = True
2013-06-25 18:15:43 +01:00
run_autopkgtest = True
2015-01-30 17:51:44 -05:00
run_boottest = True
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# if the package can be updated, it is a valid candidate
2006-06-17 13:45:56 +00:00
if update_candidate :
2012-01-06 14:58:14 +01:00
excuse . is_valid = True
2006-06-24 17:49:43 +00:00
# else it won't be considered
2006-06-17 13:45:56 +00:00
else :
2013-12-10 22:27:32 +01:00
# TODO
2006-06-17 13:45:56 +00:00
excuse . addhtml ( " Not considered " )
2013-06-25 18:15:43 +01:00
excuse . run_autopkgtest = run_autopkgtest
2015-01-30 17:51:44 -05:00
excuse . run_boottest = run_boottest
2006-06-17 13:45:56 +00:00
self . excuses . append ( excuse )
return update_candidate
def reversed_exc_deps ( self ) :
2006-06-24 17:49:43 +00:00
""" Reverse the excuses dependencies
This method returns a dictionary where the keys are the package names
and the values are the excuse names which depend on it .
"""
2006-06-17 13:45:56 +00:00
res = { }
for exc in self . excuses :
for d in exc . deps :
2006-07-26 19:26:38 +00:00
if d not in res : res [ d ] = [ ]
2006-06-17 13:45:56 +00:00
res [ d ] . append ( exc . name )
return res
def invalidate_excuses ( self , valid , invalid ) :
2006-06-24 17:49:43 +00:00
""" Invalidate impossible excuses
This method invalidates the impossible excuses , which depend
on invalid excuses . The two parameters contains the list of
` valid ' and `invalid ' excuses .
"""
# build a lookup-by-name map
2006-06-17 13:45:56 +00:00
exclookup = { }
for e in self . excuses :
exclookup [ e . name ] = e
2006-06-24 17:49:43 +00:00
# build the reverse dependencies
2006-06-17 13:45:56 +00:00
revdeps = self . reversed_exc_deps ( )
2006-06-24 17:49:43 +00:00
# loop on the invalid excuses
i = 0
2006-06-17 13:45:56 +00:00
while i < len ( invalid ) :
2006-06-24 17:49:43 +00:00
# if there is no reverse dependency, skip the item
2006-07-26 19:26:38 +00:00
if invalid [ i ] not in revdeps :
2006-06-17 13:45:56 +00:00
i + = 1
continue
2010-02-28 14:44:37 +00:00
# if the dependency can be satisfied by a testing-proposed-updates excuse, skip the item
2006-06-17 13:45:56 +00:00
if ( invalid [ i ] + " _tpu " ) in valid :
i + = 1
continue
2006-06-24 17:49:43 +00:00
# loop on the reverse dependencies
2006-06-17 13:45:56 +00:00
for x in revdeps [ invalid [ i ] ] :
2006-06-24 17:49:43 +00:00
# if the item is valid and it is marked as `dontinvalidate', skip the item
2006-06-17 13:45:56 +00:00
if x in valid and exclookup [ x ] . dontinvalidate :
continue
2006-06-24 17:49:43 +00:00
# otherwise, invalidate the dependency and mark as invalidated and
# remove the depending excuses
2006-06-17 13:45:56 +00:00
exclookup [ x ] . invalidate_dep ( invalid [ i ] )
if x in valid :
p = valid . index ( x )
invalid . append ( valid . pop ( p ) )
exclookup [ x ] . addhtml ( " Invalidated by dependency " )
exclookup [ x ] . addhtml ( " Not considered " )
2013-12-10 22:27:32 +01:00
exclookup [ x ] . addreason ( " depends " )
2012-01-06 14:58:14 +01:00
exclookup [ x ] . is_valid = False
2006-06-17 13:45:56 +00:00
i = i + 1
2015-01-22 15:16:49 -02:00
2013-07-10 20:01:03 +02:00
def write_excuses ( self , same_source = same_source ) :
2006-06-24 17:49:43 +00:00
""" Produce and write the update excuses
This method handles the update excuses generation : the packages are
2010-02-28 14:44:37 +00:00
looked at to determine whether they are valid candidates . For the details
2006-06-24 17:49:43 +00:00
of this procedure , please refer to the module docstring .
2013-07-10 20:01:03 +02:00
same_source is an opt to avoid " load global " .
2006-06-24 17:49:43 +00:00
"""
2006-06-17 13:45:56 +00:00
2006-06-25 13:51:53 +00:00
self . __log ( " Update Excuses generation started " , type = " I " )
2006-07-26 19:48:54 +00:00
# list of local methods and variables (for better performance)
sources = self . sources
architectures = self . options . architectures
should_remove_source = self . should_remove_source
should_upgrade_srcarch = self . should_upgrade_srcarch
should_upgrade_src = self . should_upgrade_src
2006-06-24 17:49:43 +00:00
# this list will contain the packages which are valid candidates;
# if a package is going to be removed, it will have a "-" prefix
2006-06-17 13:45:56 +00:00
upgrade_me = [ ]
2013-03-16 16:31:04 +00:00
self . excuses = [ ]
2006-06-24 17:49:43 +00:00
# for every source package in testing, check if it should be removed
2006-07-26 19:48:54 +00:00
for pkg in sources [ ' testing ' ] :
if should_remove_source ( pkg ) :
2006-06-17 13:45:56 +00:00
upgrade_me . append ( " - " + pkg )
2006-06-24 17:49:43 +00:00
# for every source package in unstable check if it should be upgraded
2006-07-26 19:48:54 +00:00
for pkg in sources [ ' unstable ' ] :
2006-08-18 13:47:20 +00:00
if sources [ ' unstable ' ] [ pkg ] [ FAKESRC ] : continue
2006-06-24 17:49:43 +00:00
# if the source package is already present in testing,
# check if it should be upgraded for every binary package
2006-08-18 13:47:20 +00:00
if pkg in sources [ ' testing ' ] and not sources [ ' testing ' ] [ pkg ] [ FAKESRC ] :
2006-07-26 19:48:54 +00:00
for arch in architectures :
if should_upgrade_srcarch ( pkg , arch , ' unstable ' ) :
2006-06-17 13:45:56 +00:00
upgrade_me . append ( " %s / %s " % ( pkg , arch ) )
2006-06-24 17:49:43 +00:00
# check if the source package should be upgraded
2006-07-26 19:48:54 +00:00
if should_upgrade_src ( pkg , ' unstable ' ) :
2006-06-17 13:45:56 +00:00
upgrade_me . append ( pkg )
2011-07-27 09:30:00 +00:00
# for every source package in *-proposed-updates, check if it should be upgraded
for suite in [ ' pu ' , ' tpu ' ] :
for pkg in sources [ suite ] :
# if the source package is already present in testing,
# check if it should be upgraded for every binary package
if pkg in sources [ ' testing ' ] :
for arch in architectures :
if should_upgrade_srcarch ( pkg , arch , suite ) :
upgrade_me . append ( " %s / %s _ %s " % ( pkg , arch , suite ) )
2006-06-17 13:45:56 +00:00
2011-07-27 09:30:00 +00:00
# check if the source package should be upgraded
if should_upgrade_src ( pkg , suite ) :
upgrade_me . append ( " %s _ %s " % ( pkg , suite ) )
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# process the `remove' hints, if the given package is not yet in upgrade_me
2011-09-04 16:41:33 +00:00
for item in self . hints [ ' remove ' ] :
2011-09-04 19:46:38 +00:00
src = item . package
2006-06-17 13:45:56 +00:00
if src in upgrade_me : continue
if ( " - " + src ) in upgrade_me : continue
2006-07-26 19:48:54 +00:00
if src not in sources [ ' testing ' ] : continue
2006-06-17 13:45:56 +00:00
2010-02-28 14:44:37 +00:00
# check if the version specified in the hint is the same as the considered package
2006-08-18 13:47:20 +00:00
tsrcv = sources [ ' testing ' ] [ src ] [ VERSION ]
2013-07-10 20:01:03 +02:00
if not same_source ( tsrcv , item . version ) : continue
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# add the removal of the package to upgrade_me and build a new excuse
2006-06-17 13:45:56 +00:00
upgrade_me . append ( " - %s " % ( src ) )
excuse = Excuse ( " - %s " % ( src ) )
2014-07-24 15:28:12 +01:00
excuse . set_distribution ( self . options . distribution )
2006-06-17 13:45:56 +00:00
excuse . set_vers ( tsrcv , None )
2011-09-04 18:24:54 +00:00
excuse . addhtml ( " Removal request by %s " % ( item . user ) )
2006-06-17 13:45:56 +00:00
excuse . addhtml ( " Package is broken, will try to remove " )
2013-12-10 22:27:32 +01:00
excuse . addreason ( " remove " )
2006-06-17 13:45:56 +00:00
self . excuses . append ( excuse )
2006-06-24 17:49:43 +00:00
# sort the excuses by daysold and name
2015-04-26 18:20:09 +02:00
self . excuses . sort ( key = lambda x : x . sortkey ( ) )
2006-06-17 13:45:56 +00:00
2006-06-24 17:49:43 +00:00
# extract the not considered packages, which are in the excuses but not in upgrade_me
2006-06-17 13:45:56 +00:00
unconsidered = [ e . name for e in self . excuses if e . name not in upgrade_me ]
2014-06-05 11:42:14 +01:00
if getattr ( self . options , " adt_enable " , " no " ) == " yes " and \
2014-07-24 15:18:26 +01:00
self . options . series :
2013-06-17 13:56:21 +01:00
# trigger autopkgtests for valid candidates
adt_debug = getattr ( self . options , " adt_debug " , " no " ) == " yes "
autopkgtest = AutoPackageTest (
2014-07-24 15:28:12 +01:00
self , self . options . distribution , self . options . series ,
debug = adt_debug )
2013-06-17 13:56:21 +01:00
autopkgtest_packages = [ ]
autopkgtest_excuses = [ ]
2013-10-29 18:09:21 +01:00
autopkgtest_excludes = [ ]
2013-06-17 13:56:21 +01:00
for e in self . excuses :
2013-06-25 18:15:43 +01:00
if not e . run_autopkgtest :
2013-10-29 18:09:21 +01:00
autopkgtest_excludes . append ( e . name )
2013-06-17 13:56:21 +01:00
continue
# skip removals, binary-only candidates, and proposed-updates
if e . name . startswith ( " - " ) or " / " in e . name or " _ " in e . name :
pass
if e . ver [ 1 ] == " - " :
continue
autopkgtest_excuses . append ( e )
autopkgtest_packages . append ( ( e . name , e . ver [ 1 ] ) )
2013-10-29 18:09:21 +01:00
autopkgtest . request ( autopkgtest_packages , autopkgtest_excludes )
2013-06-17 13:56:21 +01:00
if not self . options . dry_run :
autopkgtest . submit ( )
2015-07-15 08:22:37 +02:00
autopkgtest . collect ( autopkgtest_packages )
Add test results from swift
Until now, autopkgtest results were triggered via an external "adt-britney"
command from lp:auto-package-testing. This required a lot of state files and
duplicated effort, uses hardcoded absolute paths to these external tools, and
is quite hard to understand and maintain. We also want to move away from
Jenkins and rsyncing state files.
Directly retrieve autopkgtest results from a publicly readable and browsable
Swift container, with a debci-compatible layout
(https://wiki.debian.org/debci/DistributedSpec). This now tracks both requests
and results on a per-architecture granularity, so that we can track
per-architecture regressions/always-failed.
Introduce a new ADT_SWIFT_URL config option that sets the swift base URL. If
this key is not set, the behaviour does not change compared to previous
versions, and no results will be retrieved from the cloud.
This still keeps the old adt-britney requests/results as the authoritative
data and for now merely shows the swift results in addition. With that we can
compare the results and run the cloud testing in parallel to find/fix problems
until we switch over. Due to that, the code to britney.py is temporary, does
*not* use AutoPackageTest.results(), and instead just reads the internal
results map.
2015-07-10 06:21:46 +02:00
cloud_url = " http://autopkgtest.ubuntu.com/packages/ %(h)s / %(s)s / %(r)s / %(a)s "
2013-06-17 13:56:21 +01:00
for e in autopkgtest_excuses :
adtpass = True
2015-07-31 09:41:51 +02:00
for passed , adtsrc , adtver , arch_status in autopkgtest . results (
2013-06-17 13:56:21 +01:00
e . name , e . ver [ 1 ] ) :
2015-08-25 12:21:51 +02:00
for arch in arch_status :
2015-07-28 11:04:34 +02:00
url = cloud_url % { ' h ' : srchash ( adtsrc ) , ' s ' : adtsrc ,
' r ' : self . options . series , ' a ' : arch }
2015-08-25 12:21:51 +02:00
e . addtest ( ' autopkgtest ' , ' %s %s ' % ( adtsrc , adtver ) ,
arch , arch_status [ arch ] , url )
2015-07-28 11:04:34 +02:00
# hints can override failures
2015-07-31 09:41:51 +02:00
if not passed :
2013-06-25 11:14:26 +01:00
hints = self . hints . search (
2013-06-27 08:18:04 +01:00
' force-badtest ' , package = adtsrc )
2013-06-25 11:14:26 +01:00
hints . extend (
self . hints . search ( ' force ' , package = adtsrc ) )
2013-06-24 13:25:29 +01:00
forces = [
2013-06-25 11:14:26 +01:00
x for x in hints
2013-09-24 14:53:54 +01:00
if same_source ( adtver , x . version ) ]
2013-06-24 13:25:29 +01:00
if forces :
2015-08-25 13:34:41 +02:00
e . force ( )
e . addreason ( ' badtest %s %s ' % ( adtsrc , adtver ) )
2013-06-24 13:25:29 +01:00
e . addhtml (
2013-06-25 18:29:41 +01:00
" Should wait for %s %s test, but forced by "
" %s " % ( adtsrc , adtver , forces [ 0 ] . user ) )
2015-07-31 09:41:51 +02:00
passed = True
Add test results from swift
Until now, autopkgtest results were triggered via an external "adt-britney"
command from lp:auto-package-testing. This required a lot of state files and
duplicated effort, uses hardcoded absolute paths to these external tools, and
is quite hard to understand and maintain. We also want to move away from
Jenkins and rsyncing state files.
Directly retrieve autopkgtest results from a publicly readable and browsable
Swift container, with a debci-compatible layout
(https://wiki.debian.org/debci/DistributedSpec). This now tracks both requests
and results on a per-architecture granularity, so that we can track
per-architecture regressions/always-failed.
Introduce a new ADT_SWIFT_URL config option that sets the swift base URL. If
this key is not set, the behaviour does not change compared to previous
versions, and no results will be retrieved from the cloud.
This still keeps the old adt-britney requests/results as the authoritative
data and for now merely shows the swift results in addition. With that we can
compare the results and run the cloud testing in parallel to find/fix problems
until we switch over. Due to that, the code to britney.py is temporary, does
*not* use AutoPackageTest.results(), and instead just reads the internal
results map.
2015-07-10 06:21:46 +02:00
2015-07-31 09:41:51 +02:00
if not passed :
adtpass = False
Add test results from swift
Until now, autopkgtest results were triggered via an external "adt-britney"
command from lp:auto-package-testing. This required a lot of state files and
duplicated effort, uses hardcoded absolute paths to these external tools, and
is quite hard to understand and maintain. We also want to move away from
Jenkins and rsyncing state files.
Directly retrieve autopkgtest results from a publicly readable and browsable
Swift container, with a debci-compatible layout
(https://wiki.debian.org/debci/DistributedSpec). This now tracks both requests
and results on a per-architecture granularity, so that we can track
per-architecture regressions/always-failed.
Introduce a new ADT_SWIFT_URL config option that sets the swift base URL. If
this key is not set, the behaviour does not change compared to previous
versions, and no results will be retrieved from the cloud.
This still keeps the old adt-britney requests/results as the authoritative
data and for now merely shows the swift results in addition. With that we can
compare the results and run the cloud testing in parallel to find/fix problems
until we switch over. Due to that, the code to britney.py is temporary, does
*not* use AutoPackageTest.results(), and instead just reads the internal
results map.
2015-07-10 06:21:46 +02:00
2013-06-25 18:15:43 +01:00
if not adtpass and e . is_valid :
2013-06-27 08:18:04 +01:00
hints = self . hints . search ( ' force-skiptest ' , package = e . name )
hints . extend ( self . hints . search ( ' force ' , package = e . name ) )
forces = [
x for x in hints
2013-09-24 14:53:54 +01:00
if same_source ( e . ver [ 1 ] , x . version ) ]
2013-06-27 08:18:04 +01:00
if forces :
2015-08-25 13:34:41 +02:00
e . force ( )
e . addreason ( ' skiptest ' )
2013-06-27 08:18:04 +01:00
e . addhtml (
" Should wait for tests relating to %s %s , but "
" forced by %s " %
( e . name , e . ver [ 1 ] , forces [ 0 ] . user ) )
else :
upgrade_me . remove ( e . name )
unconsidered . append ( e . name )
e . addhtml ( " Not considered " )
2014-12-10 10:36:01 +00:00
e . addreason ( " autopkgtest " )
2013-06-27 08:18:04 +01:00
e . is_valid = False
2013-06-17 13:56:21 +01:00
2015-01-19 17:59:19 -02:00
if ( getattr ( self . options , " boottest_enable " , " no " ) == " yes " and
self . options . series ) :
2015-01-21 10:25:40 -02:00
# trigger 'boottest'ing for valid candidates.
2015-01-19 17:59:19 -02:00
boottest_debug = getattr (
self . options , " boottest_debug " , " no " ) == " yes "
boottest = BootTest (
self , self . options . distribution , self . options . series ,
debug = boottest_debug )
2015-02-04 08:54:00 -05:00
boottest_excuses = [ ]
2015-01-21 10:25:40 -02:00
for excuse in self . excuses :
# Skip already invalid excuses.
2015-01-30 17:51:44 -05:00
if not excuse . run_boottest :
2015-01-21 10:25:40 -02:00
continue
2015-01-22 21:30:03 -02:00
# Also skip removals, binary-only candidates, proposed-updates
# and unknown versions.
2015-01-26 15:09:50 -06:00
if ( excuse . name . startswith ( " - " ) or
" / " in excuse . name or
" _ " in excuse . name or
excuse . ver [ 1 ] == " - " ) :
2015-01-22 21:30:03 -02:00
continue
2015-02-04 08:54:00 -05:00
# Allows hints to skip boottest attempts
hints = self . hints . search (
' force-skiptest ' , package = excuse . name )
forces = [ x for x in hints
if same_source ( excuse . ver [ 1 ] , x . version ) ]
if forces :
excuse . addhtml (
" boottest skipped from hints by %s " % forces [ 0 ] . user )
continue
# Only sources whitelisted in the boottest context should
# be tested (currently only sources building phone binaries).
if not boottest . needs_test ( excuse . name , excuse . ver [ 1 ] ) :
2015-02-10 13:49:43 -05:00
# Silently skipping.
2015-02-04 08:54:00 -05:00
continue
# Okay, aggregate required boottests requests.
boottest_excuses . append ( excuse )
boottest . request ( [ ( e . name , e . ver [ 1 ] ) for e in boottest_excuses ] )
# Dry-run avoids data exchange with external systems.
if not self . options . dry_run :
boottest . submit ( )
boottest . collect ( )
2015-02-10 14:51:44 -05:00
# Boottest Jenkins views location.
jenkins_public = " https://jenkins.qa.ubuntu.com/job "
jenkins_private = (
" http://d-jenkins.ubuntu-ci:8080/view/ %s /view/BootTest/job " %
self . options . series . title ( ) )
2015-02-04 08:54:00 -05:00
# Update excuses from the boottest context.
for excuse in boottest_excuses :
status = boottest . get_status ( excuse . name , excuse . ver [ 1 ] )
2015-02-03 12:27:22 -05:00
label = BootTest . EXCUSE_LABELS . get ( status , ' UNKNOWN STATUS ' )
2015-02-10 14:51:44 -05:00
public_url = " %s / %s -boottest- %s /lastBuild " % (
jenkins_public , self . options . series ,
excuse . name . replace ( " + " , " - " ) )
private_url = " %s / %s -boottest- %s /lastBuild " % (
jenkins_private , self . options . series ,
excuse . name . replace ( " + " , " - " ) )
excuse . addhtml (
" Boottest result: %s (Jenkins: <a href= \" %s \" >public</a> "
" , <a href= \" %s \" >private</a>) " % (
label , public_url , private_url ) )
2015-02-03 12:27:22 -05:00
# Allows hints to force boottest failures/attempts
# to be ignored.
hints = self . hints . search ( ' force ' , package = excuse . name )
hints . extend (
2015-02-04 08:54:00 -05:00
self . hints . search ( ' force-badtest ' , package = excuse . name ) )
2015-02-03 12:27:22 -05:00
forces = [ x for x in hints
if same_source ( excuse . ver [ 1 ] , x . version ) ]
if forces :
excuse . addhtml (
" Should wait for %s %s boottest, but forced by "
" %s " % ( excuse . name , excuse . ver [ 1 ] ,
forces [ 0 ] . user ) )
2015-01-22 21:30:03 -02:00
continue
2015-02-20 14:12:51 -02:00
# Block promotion if the excuse is still valid (adt tests
# passed) but the boottests attempt has failed or still in
# progress.
2015-02-20 17:02:00 -02:00
if status not in BootTest . VALID_STATUSES :
2015-01-22 14:43:37 -02:00
excuse . addreason ( " boottest " )
2015-02-20 17:02:00 -02:00
if excuse . is_valid :
excuse . is_valid = False
excuse . addhtml ( " Not considered " )
upgrade_me . remove ( excuse . name )
unconsidered . append ( excuse . name )
2015-01-19 17:59:19 -02:00
2006-06-24 17:49:43 +00:00
# invalidate impossible excuses
2006-06-17 13:45:56 +00:00
for e in self . excuses :
2011-08-02 18:46:17 +00:00
# parts[0] == package name
# parts[1] == optional architecture
parts = e . name . split ( ' / ' )
2006-06-17 13:45:56 +00:00
for d in e . deps :
2011-08-02 18:46:17 +00:00
ok = False
2011-08-03 20:53:38 +00:00
# source -> source dependency; both packages must have
# valid excuses
2011-08-02 18:46:17 +00:00
if d in upgrade_me or d in unconsidered :
ok = True
# if the excuse is for a binNMU, also consider d/$arch as a
# valid excuse
2011-08-03 20:53:38 +00:00
elif len ( parts ) == 2 :
2011-08-02 18:46:17 +00:00
bd = ' %s / %s ' % ( d , parts [ 1 ] )
if bd in upgrade_me or bd in unconsidered :
ok = True
2011-08-03 20:53:38 +00:00
# if the excuse is for a source package, check each of the
# architectures on which the excuse lists a dependency on d,
# and consider the excuse valid if it is possible on each
# architecture
else :
arch_ok = True
for arch in e . deps [ d ] :
bd = ' %s / %s ' % ( d , arch )
if bd not in upgrade_me and bd not in unconsidered :
arch_ok = False
break
if arch_ok :
ok = True
2011-08-02 18:46:17 +00:00
if not ok :
2011-08-02 17:36:03 +00:00
e . addhtml ( " Impossible dependency: %s -> %s " % ( e . name , d ) )
2013-12-10 22:27:32 +01:00
e . addreason ( " depends " )
2006-06-17 13:45:56 +00:00
self . invalidate_excuses ( upgrade_me , unconsidered )
2006-07-26 22:12:09 +00:00
# sort the list of candidates
2013-09-07 18:19:17 +00:00
self . upgrade_me = sorted ( make_migrationitem ( x , self . sources ) for x in upgrade_me )
2006-06-25 13:51:53 +00:00
2006-06-24 17:49:43 +00:00
# write excuses to the output file
2008-01-15 16:09:51 +00:00
if not self . options . dry_run :
self . __log ( " > Writing Excuses to %s " % self . options . excuses_output , type = " I " )
2013-12-11 21:21:15 +01:00
write_excuses ( self . excuses , self . options . excuses_output ,
output_format = " legacy-html " )
2013-12-10 22:26:26 +01:00
if hasattr ( self . options , ' excuses_yaml_output ' ) :
self . __log ( " > Writing YAML Excuses to %s " % self . options . excuses_yaml_output , type = " I " )
2013-12-11 21:21:15 +01:00
write_excuses ( self . excuses , self . options . excuses_yaml_output ,
output_format = " yaml " )
2006-06-17 13:45:56 +00:00
2006-06-25 13:51:53 +00:00
self . __log ( " Update Excuses generation completed " , type = " I " )
2006-07-20 19:00:47 +00:00
# Upgrade run
# -----------
2006-07-22 19:14:44 +00:00
2006-08-07 14:38:13 +00:00
def get_nuninst ( self , requested_arch = None , build = False ) :
2006-07-30 11:15:27 +00:00
""" Return the uninstallability statistic for all the architectures
To calculate the uninstallability counters , the method checks the
installability of all the packages for all the architectures , and
2010-02-28 14:44:37 +00:00
tracks dependencies in a recursive way . The architecture
independent packages are checked only for the ` nobreakall `
2006-07-30 11:15:27 +00:00
architectures .
It returns a dictionary with the architectures as keys and the list
of uninstallable packages as values .
2013-07-10 20:01:04 +02:00
NB : If build is False , requested_arch is ignored .
2006-07-30 11:15:27 +00:00
"""
2006-08-07 14:38:13 +00:00
# if we are not asked to build the nuninst, read it from the cache
if not build :
2013-07-10 20:01:04 +02:00
return read_nuninst ( self . options . noninst_status ,
self . options . architectures )
2006-08-07 14:38:13 +00:00
2006-07-20 19:00:47 +00:00
nuninst = { }
2010-02-28 14:44:37 +00:00
# local copies for better performance
2006-07-28 07:59:05 +00:00
binaries = self . binaries [ ' testing ' ]
2013-11-27 19:46:59 +01:00
inst_tester = self . _inst_tester
2006-07-28 07:59:05 +00:00
2006-07-30 11:15:27 +00:00
# for all the architectures
2006-07-20 19:00:47 +00:00
for arch in self . options . architectures :
2006-08-07 14:38:13 +00:00
if requested_arch and arch != requested_arch : continue
2010-02-28 14:44:37 +00:00
# if it is in the nobreakall ones, check arch-independent packages too
2015-06-02 21:33:52 +02:00
check_archall = arch in self . options . nobreakall_arches
2006-07-20 19:00:47 +00:00
2015-04-27 18:50:48 +00:00
# check all the packages for this architecture
2008-02-28 17:23:37 +00:00
nuninst [ arch ] = set ( )
2006-07-28 07:59:05 +00:00
for pkg_name in binaries [ arch ] [ 0 ] :
2013-11-27 19:46:59 +01:00
pkgdata = binaries [ arch ] [ 0 ] [ pkg_name ]
r = inst_tester . is_installable ( pkg_name , pkgdata [ VERSION ] , arch )
2006-07-20 19:00:47 +00:00
if not r :
2008-02-28 17:23:37 +00:00
nuninst [ arch ] . add ( pkg_name )
2006-07-20 19:00:47 +00:00
2010-02-28 14:44:37 +00:00
# if they are not required, remove architecture-independent packages
2008-02-28 17:23:37 +00:00
nuninst [ arch + " +all " ] = nuninst [ arch ] . copy ( )
2015-04-27 19:43:54 +00:00
if not check_archall :
2006-08-16 17:56:38 +00:00
for pkg in nuninst [ arch + " +all " ] :
2006-08-08 10:26:32 +00:00
bpkg = binaries [ arch ] [ 0 ] [ pkg ]
2006-08-18 13:47:20 +00:00
if bpkg [ ARCHITECTURE ] == ' all ' :
2006-08-08 10:26:32 +00:00
nuninst [ arch ] . remove ( pkg )
2006-07-30 11:15:27 +00:00
# return the dictionary with the results
2006-07-20 19:00:47 +00:00
return nuninst
2006-07-22 09:54:27 +00:00
def eval_nuninst ( self , nuninst , original = None ) :
2006-07-30 11:15:27 +00:00
""" Return a string which represents the uninstallability counters
This method returns a string which represents the uninstallability
counters reading the uninstallability statistics ` nuninst ` and , if
present , merging the results with the ` original ` one .
An example of the output string is :
1 + 2 : i - 0 : a - 0 : a - 0 : h - 0 : i - 1 : m - 0 : m - 0 : p - 0 : a - 0 : m - 0 : s - 2 : s - 0
where the first part is the number of broken packages in non - break
architectures + the total number of broken packages for all the
architectures .
"""
2006-07-20 19:00:47 +00:00
res = [ ]
total = 0
totalbreak = 0
for arch in self . options . architectures :
2006-07-26 19:26:38 +00:00
if arch in nuninst :
2006-07-25 20:32:23 +00:00
n = len ( nuninst [ arch ] )
2006-07-26 19:26:38 +00:00
elif original and arch in original :
2006-07-25 20:32:23 +00:00
n = len ( original [ arch ] )
else : continue
2015-06-02 21:33:52 +02:00
if arch in self . options . break_arches :
2006-07-25 20:32:23 +00:00
totalbreak = totalbreak + n
else :
total = total + n
res . append ( " %s - %d " % ( arch [ 0 ] , n ) )
2006-07-20 19:00:47 +00:00
return " %d + %d : %s " % ( total , totalbreak , " : " . join ( res ) )
2014-06-08 17:05:23 +02:00
def _compute_groups ( self , source_name , suite , migration_architecture ,
2014-06-08 17:44:44 +02:00
is_removal , include_hijacked = False ,
allow_smooth_updates = True ,
removals = frozenset ( ) ) :
2014-06-08 17:05:23 +02:00
""" Compute the groups of binaries being migrated by item
2013-07-09 18:11:22 +02:00
2014-06-08 17:05:23 +02:00
This method will compute the binaries that will be added ,
replaced in testing and which of them are smooth updatable .
2013-07-09 18:11:22 +02:00
Parameters :
* " source_name " is the name of the source package , whose
binaries are migrating .
* " suite " is the suite from which the binaries are migrating .
2014-06-08 17:05:23 +02:00
[ Same as item . suite , where available ]
* " migration_architecture " is the architecture determines
architecture of the migrating binaries ( can be " source " for
a " source " - migration , meaning all binaries regardless of
architecture ) . [ Same as item . architecture , where available ]
* " is_removal " is a boolean determining if this is a removal
or not [ Same as item . is_removal , where available ]
* " include_hijacked " determines whether hijacked binaries should
be included in results or not . ( defaults : False )
2014-06-08 17:44:44 +02:00
* " allow_smooth_updates " is a boolean determing whether smooth -
updates are permitted in this migration . When set to False ,
the " smoothbins " return value will always be the empty set .
Any value that would have been there will now be in " rms "
instead . ( defaults : True )
* " removals " is a set of binaries that is assumed to be
removed at the same time as this migration ( e . g . in the same
" easy " - hint ) . This may affect what if some binaries are
smooth updated or not . ( defaults : empty - set )
- Binaries must be given as ( " package-name " , " version " ,
" architecture " ) tuples .
2014-06-08 17:05:23 +02:00
Returns a tuple ( adds , rms , smoothbins ) . " adds " is a set of
binaries that will updated in or appear after the migration .
" rms " is a set of binaries that are not smooth - updatable ( or
binaries that could be , but there is no reason to let them be
smooth updated ) . " smoothbins " is set of binaries that are to
be smooth - updated .
Each " binary " in " adds " , " rms " and " smoothbins " will be a
tuple of ( " package-name " , " version " , " architecture " ) and are
thus tuples suitable for passing on to the
InstallabilityTester .
2013-07-09 18:11:22 +02:00
2014-06-08 17:05:23 +02:00
Unlike doop_source , this will not modify any data structure .
"""
# local copies for better performances
sources = self . sources
2013-07-09 18:02:55 +02:00
binaries_t = self . binaries [ ' testing ' ]
2014-06-08 17:05:23 +02:00
adds = set ( )
rms = set ( )
smoothbins = { }
# remove all binary packages (if the source already exists)
if migration_architecture == ' source ' or not is_removal :
if source_name in sources [ ' testing ' ] :
source_data = sources [ ' testing ' ] [ source_name ]
bins = [ ]
check = { }
# remove all the binaries
# first, build a list of eligible binaries
for p in source_data [ BINARIES ] :
binary , parch = p . split ( " / " )
if ( migration_architecture != ' source '
and parch != migration_architecture ) :
continue
if ( not include_hijacked
and binaries_t [ parch ] [ 0 ] [ binary ] [ SOURCE ] != source_name ) :
continue
bins . append ( p )
for p in bins :
binary , parch = p . split ( " / " )
# if a smooth update is possible for the package, skip it
2014-06-08 17:44:44 +02:00
if allow_smooth_updates and suite == ' unstable ' and \
2014-06-08 17:05:23 +02:00
binary not in self . binaries [ suite ] [ parch ] [ 0 ] and \
( ' ALL ' in self . options . smooth_updates or \
binaries_t [ parch ] [ 0 ] [ binary ] [ SECTION ] in self . options . smooth_updates ) :
# if the package has reverse-dependencies which are
# built from other sources, it's a valid candidate for
# a smooth update. if not, it may still be a valid
# candidate if one if its r-deps is itself a candidate,
# so note it for checking later
bin_data = binaries_t [ parch ] [ 0 ] [ binary ]
rdeps = bin_data [ RDEPENDS ]
# the list of reverse-dependencies may be outdated
# if, for example, we're processing a hint and
# a new version of one of the apparent reverse-dependencies
# migrated earlier in the hint. walk the list to make
# sure that at least one of the entries is still
# valid
rrdeps = [ x for x in rdeps if x not in [ y . split ( " / " ) [ 0 ] for y in bins ] ]
if rrdeps :
for dep in rrdeps :
if dep in binaries_t [ parch ] [ 0 ] :
bin = binaries_t [ parch ] [ 0 ] [ dep ]
deps = [ ]
2014-06-08 17:44:44 +02:00
# If the package is being removed
# together with dep, then it is
# not a reason to smooth update
# the binary
t = ( dep , bin [ VERSION ] , parch )
if t in removals :
continue
2014-06-08 17:05:23 +02:00
if bin [ DEPENDS ] is not None :
deps . extend ( apt_pkg . parse_depends ( bin [ DEPENDS ] , False ) )
if any ( binary == entry [ 0 ] for deplist in deps for entry in deplist ) :
smoothbins [ p ] = ( binary , bin_data [ VERSION ] , parch )
break
else :
check [ p ] = ( binary , bin_data [ VERSION ] , parch )
# check whether we should perform a smooth update for
# packages which are candidates but do not have r-deps
# outside of the current source
for p in check :
2014-07-13 10:01:14 +02:00
ptuple = check [ p ]
binary , _ , parch = ptuple
2014-06-08 17:05:23 +02:00
rdeps = [ bin for bin in binaries_t [ parch ] [ 0 ] [ binary ] [ RDEPENDS ] \
2015-04-26 18:20:09 +02:00
if bin in [ y [ 0 ] for y in smoothbins . values ( ) ] ]
2014-06-08 17:05:23 +02:00
if rdeps :
2014-07-13 10:01:14 +02:00
smoothbins [ p ] = ptuple
2014-06-08 17:05:23 +02:00
# remove all the binaries which aren't being smooth updated
for p in ( bin for bin in bins if bin not in smoothbins ) :
binary , parch = p . split ( " / " )
version = binaries_t [ parch ] [ 0 ] [ binary ] [ VERSION ]
2014-09-21 15:50:50 +00:00
# if this is a binary migration from *pu, only the arch:any
# packages will be present. ideally dak would also populate
# the arch-indep packages, but as that's not the case we
# must keep them around; they will not be re-added by the
# migration so will end up missing from testing
if migration_architecture != ' source ' and \
suite != ' unstable ' and \
binaries_t [ parch ] [ 0 ] [ binary ] [ ARCHITECTURE ] == ' all ' :
continue
2015-04-26 18:20:11 +02:00
else :
2014-09-21 15:50:50 +00:00
rms . add ( ( binary , version , parch ) )
2014-06-08 17:05:23 +02:00
# single binary removal; used for clearing up after smooth
# updates but not supported as a manual hint
2014-06-15 21:57:24 +02:00
elif source_name in binaries_t [ migration_architecture ] [ 0 ] :
version = binaries_t [ migration_architecture ] [ 0 ] [ source_name ] [ VERSION ]
2014-06-08 17:05:23 +02:00
rms . add ( ( source_name , version , migration_architecture ) )
# add the new binary packages (if we are not removing)
if not is_removal :
source_data = sources [ suite ] [ source_name ]
for p in source_data [ BINARIES ] :
binary , parch = p . split ( " / " )
if migration_architecture not in [ ' source ' , parch ] :
2013-07-09 18:02:55 +02:00
continue
2014-06-08 17:05:23 +02:00
version = self . binaries [ suite ] [ parch ] [ 0 ] [ binary ] [ VERSION ]
2013-07-09 18:02:55 +02:00
2015-04-26 18:20:11 +02:00
if ( not include_hijacked
and self . binaries [ suite ] [ parch ] [ 0 ] [ binary ] [ SOURCE ] != source_name ) :
# This binary package has been hijacked by some other source.
# So don't add it as part of this update.
#
# Also, if this isn't a source update, don't remove
# the package that's been hijacked if it's present.
if migration_architecture != ' source ' :
for rm_b , rm_v , rm_p in list ( rms ) :
if ( rm_b , rm_p ) == ( binary , parch ) :
rms . remove ( ( rm_b , rm_v , rm_p ) )
continue
2013-07-09 18:02:55 +02:00
2014-06-08 17:05:23 +02:00
adds . add ( ( binary , version , parch ) )
2013-07-09 18:02:55 +02:00
2015-04-26 18:20:09 +02:00
return ( adds , rms , set ( smoothbins . values ( ) ) )
2013-07-09 18:02:55 +02:00
2014-08-06 20:57:38 +02:00
def doop_source ( self , item , hint_undo = None , removals = frozenset ( ) ) :
2006-07-30 11:15:27 +00:00
""" Apply a change to the testing distribution as requested by `pkg`
2011-05-30 19:15:54 +00:00
An optional list of undo actions related to packages processed earlier
in a hint may be passed in ` hint_undo ` .
2014-06-08 17:44:44 +02:00
An optional set of binaries may be passed in " removals " . Binaries listed
in this set will be assumined to be removed at the same time as the " item "
will migrate . This may change what binaries will be smooth - updated .
- Binaries in this set must be ( " package-name " , " version " , " architecture " )
tuples .
2011-08-31 19:55:22 +00:00
This method applies the changes required by the action ` item ` tracking
2006-07-30 11:15:27 +00:00
them so it will be possible to revert them .
2006-07-20 21:43:24 +00:00
2014-08-04 20:20:02 +02:00
The method returns a tuple containing a set of packages
affected by the change ( as ( name , arch ) - tuples ) and the
dictionary undo which can be used to rollback the changes .
2006-07-30 11:15:27 +00:00
"""
2006-07-29 19:13:23 +00:00
undo = { ' binaries ' : { } , ' sources ' : { } , ' virtual ' : { } , ' nvirtual ' : [ ] }
2006-07-20 21:43:24 +00:00
2011-12-29 14:30:51 +01:00
affected = set ( )
2006-07-20 21:43:24 +00:00
2015-04-27 19:14:08 +00:00
# local copies for better performance
2006-07-29 20:29:19 +00:00
sources = self . sources
2014-08-04 20:20:16 +02:00
packages_t = self . binaries [ ' testing ' ]
get_reverse_tree = partial ( compute_reverse_tree , packages_t )
2014-08-04 20:20:33 +02:00
inst_tester = self . _inst_tester
eqv_set = set ( )
2015-04-26 18:20:11 +02:00
updates , rms , _ = self . _compute_groups ( item . package ,
item . suite ,
item . architecture ,
item . is_removal ,
removals = removals )
#print("+++ %s" % (sorted(updates)))
#print("--- %s" % (sorted(rms)))
2006-07-22 09:54:27 +00:00
# remove all binary packages (if the source already exists)
2011-10-22 19:28:09 +00:00
if item . architecture == ' source ' or not item . is_removal :
2011-08-31 19:55:22 +00:00
if item . package in sources [ ' testing ' ] :
source = sources [ ' testing ' ] [ item . package ]
2011-11-02 19:32:30 +00:00
2014-08-04 20:20:33 +02:00
eqv_table = { }
for binary , version , parch in rms :
key = ( binary , parch )
eqv_table [ key ] = version
for p1 in updates :
binary , _ , parch = p1
key = ( binary , parch )
old_version = eqv_table . get ( key )
if old_version is not None :
p2 = ( binary , old_version , parch )
if inst_tester . are_equivalent ( p1 , p2 ) :
eqv_set . add ( key )
2011-11-02 19:32:30 +00:00
# remove all the binaries which aren't being smooth updated
2014-08-04 20:20:33 +02:00
for rm_tuple in rms :
2014-08-04 20:20:16 +02:00
binary , version , parch = rm_tuple
2014-06-08 17:05:23 +02:00
p = binary + " / " + parch
2014-08-04 20:20:16 +02:00
binaries_t_a , provides_t_a = packages_t [ parch ]
2014-08-04 20:20:33 +02:00
pkey = ( binary , parch )
2014-08-04 20:20:16 +02:00
pkg_data = binaries_t_a [ binary ]
2006-07-30 11:15:27 +00:00
# save the old binary for undo
2014-08-04 20:20:16 +02:00
undo [ ' binaries ' ] [ p ] = pkg_data
2014-08-04 20:20:33 +02:00
if pkey not in eqv_set :
# all the reverse dependencies are affected by
# the change
affected . update ( get_reverse_tree ( binary , parch ) )
2006-07-30 11:15:27 +00:00
# remove the provided virtual packages
2014-08-04 20:20:16 +02:00
for j in pkg_data [ PROVIDES ] :
2006-08-06 18:42:58 +00:00
key = j + " / " + parch
2006-07-30 11:15:27 +00:00
if key not in undo [ ' virtual ' ] :
2014-08-04 20:20:16 +02:00
undo [ ' virtual ' ] [ key ] = provides_t_a [ j ] [ : ]
provides_t_a [ j ] . remove ( binary )
if not provides_t_a [ j ] :
del provides_t_a [ j ]
2006-07-30 11:15:27 +00:00
# finally, remove the binary package
2014-08-04 20:20:16 +02:00
del binaries_t_a [ binary ]
2014-08-04 20:20:33 +02:00
inst_tester . remove_testing_binary ( binary , version , parch )
2006-07-30 11:15:27 +00:00
# remove the source package
2011-08-31 19:55:22 +00:00
if item . architecture == ' source ' :
undo [ ' sources ' ] [ item . package ] = source
del sources [ ' testing ' ] [ item . package ]
2006-07-22 17:06:55 +00:00
else :
2006-07-30 11:15:27 +00:00
# the package didn't exist, so we mark it as to-be-removed in case of undo
2011-08-31 19:55:22 +00:00
undo [ ' sources ' ] [ ' - ' + item . package ] = True
2006-07-22 17:06:55 +00:00
2011-11-06 13:18:52 +00:00
# single binary removal; used for clearing up after smooth
# updates but not supported as a manual hint
2014-08-04 20:20:16 +02:00
elif item . package in packages_t [ item . architecture ] [ 0 ] :
binaries_t_a = packages_t [ item . architecture ] [ 0 ]
undo [ ' binaries ' ] [ item . package + " / " + item . architecture ] = binaries_t_a [ item . package ]
2013-07-10 20:01:04 +02:00
affected . update ( get_reverse_tree ( item . package , item . architecture ) )
2014-08-04 20:20:16 +02:00
version = binaries_t_a [ item . package ] [ VERSION ]
del binaries_t_a [ item . package ]
2014-08-04 20:20:33 +02:00
inst_tester . remove_testing_binary ( item . package , version , item . architecture )
2013-11-27 19:46:59 +01:00
2006-07-22 09:54:27 +00:00
# add the new binary packages (if we are not removing)
2011-08-31 19:55:22 +00:00
if not item . is_removal :
source = sources [ item . suite ] [ item . package ]
2014-08-04 20:20:16 +02:00
packages_s = self . binaries [ item . suite ]
2015-04-26 18:20:11 +02:00
for binary , version , parch in updates :
p = " %s / %s " % ( binary , parch )
2006-08-06 18:42:58 +00:00
key = ( binary , parch )
2014-08-04 20:20:16 +02:00
binaries_t_a , provides_t_a = packages_t [ parch ]
2014-08-04 20:20:33 +02:00
equivalent_replacement = key in eqv_set
2006-07-30 11:15:27 +00:00
# obviously, added/modified packages are affected
2014-08-04 20:20:33 +02:00
if not equivalent_replacement and key not in affected :
affected . add ( key )
2012-12-25 22:16:05 +00:00
# if the binary already exists in testing, it is currently
# built by another source package. we therefore remove the
# version built by the other source package, after marking
# all of its reverse dependencies as affected
2014-08-04 20:20:16 +02:00
if binary in binaries_t_a :
old_pkg_data = binaries_t_a [ binary ]
2006-07-30 11:15:27 +00:00
# save the old binary package
2014-08-04 20:20:16 +02:00
undo [ ' binaries ' ] [ p ] = old_pkg_data
2014-08-04 20:20:33 +02:00
if not equivalent_replacement :
# all the reverse dependencies are affected by
# the change
affected . update ( get_reverse_tree ( binary , parch ) )
# all the reverse conflicts and their
# dependency tree are affected by the change
for j in old_pkg_data [ RCONFLICTS ] :
affected . update ( get_reverse_tree ( j , parch ) )
2014-08-04 20:20:16 +02:00
old_version = old_pkg_data [ VERSION ]
2014-08-04 20:20:33 +02:00
inst_tester . remove_testing_binary ( binary , old_version , parch )
2014-08-06 20:57:38 +02:00
elif hint_undo :
2012-12-25 22:16:05 +00:00
# the binary isn't in testing, but it may have been at
# the start of the current hint and have been removed
# by an earlier migration. if that's the case then we
# will have a record of the older instance of the binary
# in the undo information. we can use that to ensure
# that the reverse dependencies of the older binary
# package are also checked.
2011-05-30 19:15:54 +00:00
# reverse dependencies built from this source can be
# ignored as their reverse trees are already handled
# by this function
# XXX: and the reverse conflict tree?
2011-08-31 19:55:22 +00:00
for ( tundo , tpkg ) in hint_undo :
2011-05-30 19:15:54 +00:00
if p in tundo [ ' binaries ' ] :
for rdep in tundo [ ' binaries ' ] [ p ] [ RDEPENDS ] :
2014-08-04 20:20:16 +02:00
if rdep in binaries_t_a and rdep not in source [ BINARIES ] :
2013-07-10 20:01:04 +02:00
affected . update ( get_reverse_tree ( rdep , parch ) )
2014-08-04 20:20:33 +02:00
2014-08-04 20:20:16 +02:00
# add/update the binary package from the source suite
new_pkg_data = packages_s [ parch ] [ 0 ] [ binary ]
new_version = new_pkg_data [ VERSION ]
binaries_t_a [ binary ] = new_pkg_data
2014-08-04 20:20:33 +02:00
inst_tester . add_testing_binary ( binary , new_version , parch )
2006-07-30 11:15:27 +00:00
# register new provided packages
2014-08-04 20:20:16 +02:00
for j in new_pkg_data [ PROVIDES ] :
2006-08-06 18:42:58 +00:00
key = j + " / " + parch
2014-08-04 20:20:16 +02:00
if j not in provides_t_a :
2006-07-30 11:15:27 +00:00
undo [ ' nvirtual ' ] . append ( key )
2014-08-04 20:20:16 +02:00
provides_t_a [ j ] = [ ]
2006-07-30 11:15:27 +00:00
elif key not in undo [ ' virtual ' ] :
2014-08-04 20:20:16 +02:00
undo [ ' virtual ' ] [ key ] = provides_t_a [ j ] [ : ]
provides_t_a [ j ] . append ( binary )
2014-08-04 20:20:33 +02:00
if not equivalent_replacement :
# all the reverse dependencies are affected by the change
affected . update ( get_reverse_tree ( binary , parch ) )
2006-07-30 11:15:27 +00:00
# register reverse dependencies and conflicts for the new binary packages
2013-07-10 20:01:04 +02:00
if item . architecture == ' source ' :
pkg_iter = ( p . split ( " / " ) [ 0 ] for p in source [ BINARIES ] )
else :
ext = " / " + item . architecture
pkg_iter = ( p . split ( " / " ) [ 0 ] for p in source [ BINARIES ] if p . endswith ( ext ) )
2014-08-04 20:20:16 +02:00
register_reverses ( binaries_t_a , provides_t_a , iterator = pkg_iter )
2006-07-30 11:15:27 +00:00
# add/update the source package
2011-08-31 19:55:22 +00:00
if item . architecture == ' source ' :
sources [ ' testing ' ] [ item . package ] = sources [ item . suite ] [ item . package ]
2006-07-20 21:43:24 +00:00
2006-07-30 11:15:27 +00:00
# return the package name, the suite, the list of affected packages and the undo dictionary
2014-08-04 20:20:02 +02:00
return ( affected , undo )
2006-07-20 21:43:24 +00:00
2006-07-24 18:47:02 +00:00
2015-04-27 19:43:54 +00:00
def _check_packages ( self , binaries , arch , affected , check_archall , nuninst ) :
2012-05-22 15:22:31 +02:00
broken = nuninst [ arch + " +all " ]
to_check = [ ]
# broken packages (first round)
2013-08-11 15:23:45 +02:00
for p in ( x [ 0 ] for x in affected if x [ 1 ] == arch ) :
2012-05-22 15:22:31 +02:00
if p not in binaries [ arch ] [ 0 ] :
continue
2013-11-27 19:46:59 +01:00
pkgdata = binaries [ arch ] [ 0 ] [ p ]
version = pkgdata [ VERSION ]
parch = pkgdata [ ARCHITECTURE ]
2012-05-22 15:22:31 +02:00
nuninst_arch = None
2015-04-27 19:43:54 +00:00
# only check arch:all packages if requested
if check_archall or parch != ' all ' :
2012-05-22 15:22:31 +02:00
nuninst_arch = nuninst [ arch ]
2013-11-27 19:46:59 +01:00
self . _installability_test ( p , version , arch , broken , to_check , nuninst_arch )
2012-05-22 15:22:31 +02:00
# broken packages (second round, reverse dependencies of the first round)
while to_check :
j = to_check . pop ( 0 )
if j not in binaries [ arch ] [ 0 ] : continue
for p in binaries [ arch ] [ 0 ] [ j ] [ RDEPENDS ] :
if p in broken or p not in binaries [ arch ] [ 0 ] :
continue
2013-11-27 19:46:59 +01:00
pkgdata = binaries [ arch ] [ 0 ] [ p ]
version = pkgdata [ VERSION ]
parch = pkgdata [ ARCHITECTURE ]
2012-05-22 15:22:31 +02:00
nuninst_arch = None
2015-04-27 19:43:54 +00:00
# only check arch:all packages if requested
if check_archall or parch != ' all ' :
2012-05-22 15:22:31 +02:00
nuninst_arch = nuninst [ arch ]
2013-11-27 19:46:59 +01:00
self . _installability_test ( p , version , arch , broken , to_check , nuninst_arch )
2012-05-22 15:22:31 +02:00
2014-08-04 20:20:02 +02:00
def iter_packages_hint ( self , hinted_packages , lundo = None ) :
""" Iter on hinted list of actions and apply them in one go
This method applies the changes from " hinted_packages " to
testing and computes the uninstallability counters after te
actions are performed .
The method returns the new uninstallability counters .
"""
removals = set ( )
all_affected = set ( )
2015-06-02 21:33:52 +02:00
nobreakall_arches = self . options . nobreakall_arches
2014-08-23 10:56:20 +02:00
packages_t = self . binaries [ ' testing ' ]
check_packages = partial ( self . _check_packages , packages_t )
2014-08-04 20:20:02 +02:00
for item in hinted_packages :
_ , rms , _ = self . _compute_groups ( item . package , item . suite ,
item . architecture ,
item . is_removal ,
allow_smooth_updates = False )
removals . update ( rms )
for item in hinted_packages :
2014-08-04 20:20:02 +02:00
affected , undo = self . doop_source ( item ,
removals = removals )
2014-08-04 20:20:02 +02:00
all_affected . update ( affected )
if lundo is not None :
lundo . append ( ( undo , item ) )
2014-08-07 19:56:19 +02:00
# deep copy nuninst (in case the hint is undone)
2015-06-02 21:33:52 +02:00
# NB: We do this *after* updating testing as we have to filter out
2014-08-07 19:56:19 +02:00
# removed binaries. Otherwise, uninstallable binaries that were
# removed by the hint would still be counted.
2015-06-02 21:33:52 +02:00
nuninst = clone_nuninst ( self . nuninst_orig , packages_t ,
self . options . architectures )
2014-08-07 19:56:19 +02:00
2014-08-04 20:20:02 +02:00
for arch in self . options . architectures :
2015-04-27 19:43:54 +00:00
check_archall = arch in nobreakall_arches
2014-08-04 20:20:02 +02:00
2015-04-27 19:43:54 +00:00
check_packages ( arch , all_affected , check_archall , nuninst )
2014-08-04 20:20:02 +02:00
return nuninst
def iter_packages ( self , packages , selected , nuninst = None , lundo = None ) :
2006-07-30 11:15:27 +00:00
""" Iter on the list of actions and apply them one-by-one
2010-02-28 14:44:37 +00:00
This method applies the changes from ` packages ` to testing , checking the uninstallability
counters for every action performed . If the action does not improve them , it is reverted .
2006-07-30 11:15:27 +00:00
The method returns the new uninstallability counters and the remaining actions if the
final result is successful , otherwise ( None , None ) .
"""
2006-07-20 21:43:24 +00:00
extra = [ ]
2006-08-01 13:33:06 +00:00
deferred = [ ]
skipped = [ ]
mark_passed = False
position = len ( packages )
2006-08-15 21:23:36 +00:00
if nuninst :
2015-06-02 21:33:52 +02:00
nuninst_comp = nuninst
2006-08-15 21:23:36 +00:00
else :
2015-06-02 21:33:52 +02:00
nuninst_comp = self . nuninst_orig
2006-07-20 21:43:24 +00:00
2010-02-28 14:44:37 +00:00
# local copies for better performance
2006-07-28 16:47:46 +00:00
binaries = self . binaries [ ' testing ' ]
2006-07-28 07:59:05 +00:00
sources = self . sources
architectures = self . options . architectures
2015-06-02 21:33:52 +02:00
nobreakall_arches = self . options . nobreakall_arches
new_arches = self . options . new_arches
break_arches = self . options . break_arches
2006-08-01 13:33:06 +00:00
dependencies = self . dependencies
2013-11-27 19:46:59 +01:00
check_packages = partial ( self . _check_packages , binaries )
2006-07-28 07:59:05 +00:00
2015-06-02 21:33:51 +02:00
self . output_write ( " recur: [] %s %d / %d \n " % ( " , " . join ( x . uvname for x in selected ) , len ( packages ) , len ( extra ) ) )
2006-07-25 21:26:22 +00:00
2006-07-30 11:15:27 +00:00
# loop on the packages (or better, actions)
2006-07-20 21:43:24 +00:00
while packages :
2014-08-04 20:20:02 +02:00
item = packages . pop ( 0 )
2006-08-01 13:33:06 +00:00
# this is the marker for the first loop
2011-12-29 14:10:31 +01:00
if not mark_passed and position < 0 :
2006-08-01 13:33:06 +00:00
mark_passed = True
packages . extend ( deferred )
del deferred
else : position - = 1
# defer packages if their dependency has been already skipped
2011-12-29 14:10:31 +01:00
if not mark_passed :
2006-08-01 13:33:06 +00:00
defer = False
2014-08-04 20:20:02 +02:00
for p in dependencies . get ( item , [ ] ) :
2006-08-01 13:33:06 +00:00
if p in skipped :
2014-08-05 07:56:29 +02:00
deferred . append ( item )
skipped . append ( item )
2006-08-01 13:33:06 +00:00
defer = True
break
if defer : continue
2014-08-04 20:20:02 +02:00
self . output_write ( " trying: %s \n " % ( item . uvname ) )
2006-07-20 21:43:24 +00:00
better = True
2006-07-30 11:15:27 +00:00
# apply the changes
2014-08-04 20:20:02 +02:00
affected , undo = self . doop_source ( item , lundo )
2006-07-20 21:43:24 +00:00
2015-06-02 21:33:52 +02:00
# Copy nuninst_comp - we have to deep clone affected
# architectures.
2006-07-20 21:43:24 +00:00
2015-06-02 21:33:52 +02:00
# NB: We do this *after* updating testing as we have to filter out
2015-06-02 21:33:52 +02:00
# removed binaries. Otherwise, uninstallable binaries that were
# removed by the item would still be counted.
if item . architecture == ' source ' :
2015-06-02 21:33:52 +02:00
affected_architectures = architectures
2015-06-02 21:33:52 +02:00
else :
2015-06-02 21:33:52 +02:00
affected_architectures = [ item . architecture ]
nuninst = clone_nuninst ( nuninst_comp , binaries , affected_architectures )
2006-08-20 19:25:21 +00:00
2015-06-02 21:33:52 +02:00
# check the affected packages on all the architectures
2015-06-02 21:33:52 +02:00
for arch in affected_architectures :
2015-06-02 21:33:52 +02:00
check_archall = arch in nobreakall_arches
2015-04-27 19:43:54 +00:00
check_packages ( arch , affected , check_archall , nuninst )
2006-07-20 21:43:24 +00:00
2006-07-30 11:15:27 +00:00
# if the uninstallability counter is worse than before, break the loop
2011-08-31 19:55:22 +00:00
if ( ( item . architecture != ' source ' and arch not in new_arches ) or \
2006-07-28 07:59:05 +00:00
( arch not in break_arches ) ) and len ( nuninst [ arch ] ) > len ( nuninst_comp [ arch ] ) :
2006-07-20 21:43:24 +00:00
better = False
break
2006-08-01 20:27:48 +00:00
2006-07-30 11:15:27 +00:00
# check if the action improved the uninstallability counters
2006-07-20 21:43:24 +00:00
if better :
2014-08-06 20:57:38 +02:00
if lundo is not None :
lundo . append ( ( undo , item ) )
2014-08-04 20:20:02 +02:00
selected . append ( item )
2006-07-20 21:43:24 +00:00
packages . extend ( extra )
extra = [ ]
2014-08-04 20:20:02 +02:00
self . output_write ( " accepted: %s \n " % ( item . uvname ) )
2006-08-01 18:59:29 +00:00
self . output_write ( " ori: %s \n " % ( self . eval_nuninst ( self . nuninst_orig ) ) )
self . output_write ( " pre: %s \n " % ( self . eval_nuninst ( nuninst_comp ) ) )
2006-08-14 11:53:19 +00:00
self . output_write ( " now: %s \n " % ( self . eval_nuninst ( nuninst , nuninst_comp ) ) )
if len ( selected ) < = 20 :
2013-08-11 15:23:45 +02:00
self . output_write ( " all: %s \n " % ( " " . join ( x . uvname for x in selected ) ) )
2006-07-20 21:43:24 +00:00
else :
2013-08-11 15:23:45 +02:00
self . output_write ( " most: ( %d ) .. %s \n " % ( len ( selected ) , " " . join ( x . uvname for x in selected [ - 20 : ] ) ) )
2015-06-02 21:33:52 +02:00
nuninst_comp = nuninst
2006-07-20 19:00:47 +00:00
else :
2014-08-04 20:20:02 +02:00
self . output_write ( " skipped: %s ( %d <- %d ) \n " % ( item . uvname , len ( extra ) , len ( packages ) ) )
self . output_write ( " got: %s \n " % ( self . eval_nuninst ( nuninst , item . architecture != ' source ' and nuninst_comp or None ) ) )
2013-08-11 15:23:45 +02:00
self . output_write ( " * %s : %s \n " % ( arch , " , " . join ( sorted ( b for b in nuninst [ arch ] if b not in nuninst_comp [ arch ] ) ) ) )
2006-08-01 13:33:06 +00:00
2013-09-07 16:59:06 +00:00
extra . append ( item )
2006-08-01 13:33:06 +00:00
if not mark_passed :
2013-09-07 16:59:06 +00:00
skipped . append ( item )
2011-12-13 22:30:16 +01:00
single_undo = [ ( undo , item ) ]
# (local-scope) binaries is actually self.binaries["testing"] so we cannot use it here.
2013-11-27 19:46:59 +01:00
undo_changes ( single_undo , self . _inst_tester , sources , self . binaries )
2006-07-29 19:13:23 +00:00
2006-08-01 20:27:48 +00:00
2013-08-11 15:23:45 +02:00
self . output_write ( " finish: [ %s ] \n " % " , " . join ( x . uvname for x in selected ) )
2006-08-01 18:59:29 +00:00
self . output_write ( " endloop: %s \n " % ( self . eval_nuninst ( self . nuninst_orig ) ) )
self . output_write ( " now: %s \n " % ( self . eval_nuninst ( nuninst_comp ) ) )
2013-07-10 20:01:04 +02:00
self . output_write ( eval_uninst ( self . options . architectures ,
2013-07-10 20:01:04 +02:00
newly_uninst ( self . nuninst_orig , nuninst_comp ) ) )
2006-08-01 18:59:29 +00:00
self . output_write ( " \n " )
2006-07-22 19:14:44 +00:00
2012-05-22 15:22:31 +02:00
return ( nuninst_comp , extra )
2006-07-22 19:14:44 +00:00
2014-08-04 20:20:02 +02:00
2012-01-04 14:20:33 +01:00
def do_all ( self , hinttype = None , init = None , actions = None ) :
2006-07-30 11:15:27 +00:00
""" Testing update runner
This method tries to update testing checking the uninstallability
counters before and after the actions to decide if the update was
successful or not .
"""
2006-08-15 15:32:14 +00:00
selected = [ ]
2006-08-06 09:29:32 +00:00
if actions :
upgrade_me = actions [ : ]
else :
upgrade_me = self . upgrade_me [ : ]
2006-08-01 20:27:48 +00:00
nuninst_start = self . nuninst_orig
2006-07-25 20:32:23 +00:00
2006-08-01 18:59:29 +00:00
# these are special parameters for hints processing
force = False
2012-05-22 19:56:11 +00:00
recurse = True
2012-05-22 15:22:31 +02:00
lundo = None
nuninst_end = None
2014-08-05 07:56:29 +02:00
better = True
2014-08-06 20:57:38 +02:00
extra = [ ]
2012-05-22 15:22:31 +02:00
2012-01-04 14:20:33 +01:00
if hinttype == " easy " or hinttype == " force-hint " :
force = hinttype == " force-hint "
2012-05-22 19:56:11 +00:00
recurse = False
2006-08-01 18:59:29 +00:00
# if we have a list of initial packages, check them
if init :
2012-05-22 15:22:31 +02:00
if not force :
lundo = [ ]
2006-08-01 18:59:29 +00:00
for x in init :
2006-08-01 20:27:48 +00:00
if x not in upgrade_me :
2015-06-02 21:33:51 +02:00
self . output_write ( " failed: %s is not a valid candidate (or it already migrated) \n " % ( x . uvname ) )
2006-08-01 18:59:29 +00:00
return None
2006-08-06 09:29:32 +00:00
selected . append ( x )
2006-08-01 20:27:48 +00:00
upgrade_me . remove ( x )
2015-01-22 15:16:49 -02:00
2006-08-01 20:27:48 +00:00
self . output_write ( " start: %s \n " % self . eval_nuninst ( nuninst_start ) )
2006-09-05 08:15:04 +00:00
if not force :
self . output_write ( " orig: %s \n " % self . eval_nuninst ( nuninst_start ) )
2006-08-01 18:59:29 +00:00
2012-05-22 15:22:31 +02:00
2012-05-22 15:22:31 +02:00
if init :
# init => a hint (e.g. "easy") - so do the hint run
2014-08-04 20:20:02 +02:00
nuninst_end = self . iter_packages_hint ( selected , lundo = lundo )
if recurse :
# Ensure upgrade_me and selected do not overlap, if we
# follow-up with a recurse ("hint"-hint).
upgrade_me = [ x for x in upgrade_me if x not in set ( selected ) ]
2012-05-22 15:22:31 +02:00
2012-05-22 19:56:11 +00:00
if recurse :
# Either the main run or the recursive run of a "hint"-hint.
2012-05-22 15:22:31 +02:00
( nuninst_end , extra ) = self . iter_packages ( upgrade_me , selected , nuninst = nuninst_end , lundo = lundo )
nuninst_end_str = self . eval_nuninst ( nuninst_end )
2012-05-22 19:56:11 +00:00
if not recurse :
2012-05-22 15:22:31 +02:00
# easy or force-hint
2006-09-05 08:15:04 +00:00
if force :
2012-05-22 15:22:31 +02:00
self . output_write ( " orig: %s \n " % nuninst_end_str )
self . output_write ( " easy: %s \n " % nuninst_end_str )
2006-09-05 08:15:04 +00:00
if not force :
2013-07-10 20:01:04 +02:00
self . output_write ( eval_uninst ( self . options . architectures ,
2013-10-30 17:29:11 -07:00
newly_uninst ( nuninst_start , nuninst_end ) ) )
2012-05-22 15:22:31 +02:00
2014-08-05 07:56:29 +02:00
if not force :
2015-06-02 21:33:52 +02:00
break_arches = set ( self . options . break_arches )
2014-08-06 20:57:31 +02:00
if all ( x . architecture in break_arches for x in selected ) :
# If we only migrated items from break-arches, then we
# do not allow any regressions on these architectures.
# This usually only happens with hints
break_arches = set ( )
2014-08-05 07:56:29 +02:00
better = is_nuninst_asgood_generous ( self . options . architectures ,
self . nuninst_orig ,
nuninst_end ,
break_arches )
if better :
2012-05-22 15:22:31 +02:00
# Result accepted either by force or by being better than the original result.
2012-05-22 21:16:36 +00:00
if recurse :
2008-04-23 17:22:24 +00:00
self . output_write ( " Apparently successful \n " )
2013-08-11 15:23:45 +02:00
self . output_write ( " final: %s \n " % " , " . join ( sorted ( x . uvname for x in selected ) ) )
2006-08-01 18:59:29 +00:00
self . output_write ( " start: %s \n " % self . eval_nuninst ( nuninst_start ) )
2006-09-05 08:15:04 +00:00
if not force :
self . output_write ( " orig: %s \n " % self . eval_nuninst ( self . nuninst_orig ) )
else :
2012-05-22 15:22:31 +02:00
self . output_write ( " orig: %s \n " % nuninst_end_str )
self . output_write ( " end: %s \n " % nuninst_end_str )
2006-08-01 20:27:48 +00:00
if force :
self . output_write ( " force breaks: \n " )
2013-07-10 20:01:04 +02:00
self . output_write ( eval_uninst ( self . options . architectures ,
2013-10-30 17:29:11 -07:00
newly_uninst ( nuninst_start , nuninst_end ) ) )
2006-08-06 09:29:32 +00:00
self . output_write ( " SUCCESS ( %d / %d ) \n " % ( len ( actions or self . upgrade_me ) , len ( extra ) ) )
2006-08-11 21:12:27 +00:00
self . nuninst_orig = nuninst_end
2014-01-11 09:03:16 +01:00
self . all_selected + = selected
2006-09-05 08:15:04 +00:00
if not actions :
2012-05-22 19:56:11 +00:00
if recurse :
2014-08-06 20:57:38 +02:00
self . upgrade_me = extra
self . sort_actions ( )
2006-09-05 08:15:04 +00:00
else :
2014-08-04 20:20:02 +02:00
self . upgrade_me = [ x for x in self . upgrade_me if x not in set ( selected ) ]
2006-08-01 20:27:48 +00:00
else :
self . output_write ( " FAILED \n " )
2012-05-22 15:22:31 +02:00
if not lundo : return
2013-06-12 15:55:04 +01:00
lundo . reverse ( )
2006-08-03 11:10:40 +00:00
2013-11-27 19:46:59 +01:00
undo_changes ( lundo , self . _inst_tester , self . sources , self . binaries )
2013-10-30 17:29:11 -07:00
self . output_write ( " \n " )
2011-12-13 22:30:16 +01:00
2006-07-20 19:00:47 +00:00
def upgrade_testing ( self ) :
""" Upgrade testing using the unstable packages
This method tries to upgrade testing using the packages from unstable .
2006-08-01 18:59:29 +00:00
Before running the do_all method , it tries the easy and force - hint
commands .
2006-07-20 19:00:47 +00:00
"""
self . __log ( " Starting the upgrade test " , type = " I " )
2006-08-01 18:59:29 +00:00
self . output_write ( " Generated on: %s \n " % ( time . strftime ( " % Y. % m. %d % H: % M: % S % z " , time . gmtime ( time . time ( ) ) ) ) )
self . output_write ( " Arch order is: %s \n " % " , " . join ( self . options . architectures ) )
2006-08-01 20:27:48 +00:00
self . __log ( " > Calculating current uninstallability counters " , type = " I " )
self . nuninst_orig = self . get_nuninst ( )
2011-06-28 19:10:13 +00:00
# nuninst_orig may get updated during the upgrade process
self . nuninst_orig_save = self . get_nuninst ( )
2012-10-22 15:10:05 +01:00
self . all_selected = [ ]
2006-08-01 20:27:48 +00:00
2006-08-16 17:56:38 +00:00
if not self . options . actions :
# process `easy' hints
for x in self . hints [ ' easy ' ] :
2011-09-04 16:41:33 +00:00
self . do_hint ( " easy " , x . user , x . packages )
2006-08-01 18:59:29 +00:00
2006-08-16 17:56:38 +00:00
# process `force-hint' hints
for x in self . hints [ " force-hint " ] :
2011-09-04 16:41:33 +00:00
self . do_hint ( " force-hint " , x . user , x . packages )
2006-07-20 19:00:47 +00:00
2006-08-01 18:59:29 +00:00
# run the first round of the upgrade
2012-01-04 14:20:33 +01:00
# - do separate runs for break arches
2006-08-07 11:06:04 +00:00
allpackages = [ ]
normpackages = self . upgrade_me [ : ]
archpackages = { }
2015-06-02 21:33:52 +02:00
for a in self . options . break_arches :
2011-11-09 22:44:31 +00:00
archpackages [ a ] = [ p for p in normpackages if p . architecture == a ]
2010-11-03 19:05:46 +00:00
normpackages = [ p for p in normpackages if p not in archpackages [ a ] ]
2006-08-07 11:06:04 +00:00
self . upgrade_me = normpackages
self . output_write ( " info: main run \n " )
2006-08-01 20:27:48 +00:00
self . do_all ( )
2006-08-07 11:06:04 +00:00
allpackages + = self . upgrade_me
2015-06-02 21:33:52 +02:00
for a in self . options . break_arches :
2006-08-15 15:32:14 +00:00
backup = self . options . break_arches
2015-06-02 21:33:52 +02:00
self . options . break_arches = " " . join ( x for x in self . options . break_arches if x != a )
2006-08-07 11:06:04 +00:00
self . upgrade_me = archpackages [ a ]
self . output_write ( " info: broken arch run for %s \n " % ( a ) )
self . do_all ( )
allpackages + = self . upgrade_me
2006-08-15 15:32:14 +00:00
self . options . break_arches = backup
2006-08-07 11:06:04 +00:00
self . upgrade_me = allpackages
2006-07-20 19:00:47 +00:00
2006-08-16 17:56:38 +00:00
if self . options . actions :
2011-06-30 17:45:44 +00:00
self . printuninstchange ( )
2006-08-16 17:56:38 +00:00
return
2006-08-15 15:32:14 +00:00
# process `hint' hints
hintcnt = 0
for x in self . hints [ " hint " ] [ : 50 ] :
if hintcnt > 50 :
self . output_write ( " Skipping remaining hints... " )
break
2011-09-04 16:41:33 +00:00
if self . do_hint ( " hint " , x . user , x . packages ) :
2006-08-15 15:32:14 +00:00
hintcnt + = 1
2006-08-04 18:38:52 +00:00
# run the auto hinter
2011-12-29 14:10:31 +01:00
self . auto_hinter ( )
2006-08-04 18:38:52 +00:00
2012-12-15 18:07:06 +00:00
# obsolete source packages
# a package is obsolete if none of the binary packages in testing
# are built by it
2012-10-22 13:55:11 +01:00
if getattr ( self . options , " remove_obsolete " , " yes " ) == " yes " :
self . __log ( " > Removing obsolete source packages from testing " , type = " I " )
2012-12-28 05:00:22 +00:00
# local copies for performance
2012-10-22 13:55:11 +01:00
sources = self . sources [ ' testing ' ]
2012-12-28 05:00:22 +00:00
binaries = self . binaries [ ' testing ' ]
used = set ( binaries [ arch ] [ 0 ] [ binary ] [ SOURCE ]
for arch in binaries
for binary in binaries [ arch ] [ 0 ]
)
2013-09-25 12:54:05 +01:00
removals = [ MigrationItem ( " - %s / %s " % ( source , sources [ source ] [ VERSION ] ) )
2012-12-28 05:00:22 +00:00
for source in sources if source not in used
]
2012-10-22 13:55:11 +01:00
if len ( removals ) > 0 :
self . output_write ( " Removing obsolete source packages from testing ( %d ): \n " % ( len ( removals ) ) )
self . do_all ( actions = removals )
2015-01-22 15:16:49 -02:00
2006-08-06 09:29:32 +00:00
# smooth updates
2014-03-10 18:48:04 +01:00
if self . options . smooth_updates :
2006-08-06 09:29:32 +00:00
self . __log ( " > Removing old packages left in testing from smooth updates " , type = " I " )
2014-03-10 18:48:04 +01:00
removals = old_libraries ( self . sources , self . binaries )
if removals :
2006-08-06 09:29:32 +00:00
self . output_write ( " Removing packages left in testing for smooth updates ( %d ): \n %s " % \
2013-07-10 20:01:03 +02:00
( len ( removals ) , old_libraries_format ( removals ) ) )
2013-09-07 16:59:06 +00:00
self . do_all ( actions = removals )
2014-03-10 18:48:04 +01:00
removals = old_libraries ( self . sources , self . binaries )
2008-04-23 17:25:56 +00:00
else :
removals = ( )
2006-08-06 09:29:32 +00:00
2011-12-29 14:10:31 +01:00
self . output_write ( " List of old libraries in testing ( %d ): \n %s " % \
2013-07-10 20:01:03 +02:00
( len ( removals ) , old_libraries_format ( removals ) ) )
2006-08-06 09:29:32 +00:00
# output files
if not self . options . dry_run :
# re-write control files
if self . options . control_files :
2014-03-10 18:48:04 +01:00
self . __log ( " Writing new testing control files to %s " %
self . options . testing )
write_controlfiles ( self . sources , self . binaries ,
' testing ' , self . options . testing )
2006-08-03 11:41:39 +00:00
2011-06-28 19:13:11 +00:00
# write dates
2013-12-06 22:44:50 +01:00
try :
self . write_dates ( self . options . outputdir , self . dates )
except AttributeError :
self . write_dates ( self . options . testing , self . dates )
2006-08-01 18:59:29 +00:00
2006-08-06 09:29:32 +00:00
# write HeidiResult
2013-07-10 20:01:04 +02:00
self . __log ( " Writing Heidi results to %s " % self . options . heidi_output )
write_heidi ( self . options . heidi_output , self . sources [ " testing " ] ,
self . binaries [ " testing " ] )
2006-08-01 18:59:29 +00:00
2014-01-11 09:03:16 +01:00
self . __log ( " Writing delta to %s " % self . options . heidi_delta_output )
write_heidi_delta ( self . options . heidi_delta_output ,
self . all_selected )
2012-10-22 15:10:05 +01:00
2011-06-28 19:10:13 +00:00
self . printuninstchange ( )
2006-07-20 19:00:47 +00:00
self . __log ( " Test completed! " , type = " I " )
2011-06-28 19:10:13 +00:00
def printuninstchange ( self ) :
self . __log ( " Checking for newly uninstallable packages " , type = " I " )
2013-07-10 20:01:04 +02:00
text = eval_uninst ( self . options . architectures , newly_uninst (
2013-07-10 20:01:04 +02:00
self . nuninst_orig_save , self . nuninst_orig ) )
2011-06-28 19:10:13 +00:00
if text != ' ' :
self . output_write ( " \n Newly uninstallable packages in testing: \n %s " % \
( text ) )
2008-01-15 16:09:51 +00:00
def hint_tester ( self ) :
""" Run a command line interface to test hints
2010-02-28 14:44:37 +00:00
This method provides a command line interface for the release team to
2011-10-16 19:39:24 +02:00
try hints and evaluate the results .
2008-01-15 16:09:51 +00:00
"""
self . __log ( " > Calculating current uninstallability counters " , type = " I " )
self . nuninst_orig = self . get_nuninst ( )
2011-06-28 19:10:13 +00:00
self . nuninst_orig_save = self . get_nuninst ( )
2012-10-22 15:10:05 +01:00
self . all_selected = [ ]
2008-01-15 16:09:51 +00:00
2008-04-23 17:22:24 +00:00
import readline
2011-10-22 13:42:14 +02:00
from completer import Completer
2008-04-23 17:22:24 +00:00
histfile = os . path . expanduser ( ' ~/.britney2_history ' )
if os . path . exists ( histfile ) :
readline . read_history_file ( histfile )
2011-10-22 13:42:14 +02:00
readline . parse_and_bind ( ' tab: complete ' )
readline . set_completer ( Completer ( self ) . completer )
2011-10-22 14:09:35 +02:00
# Package names can contain "-" and we use "/" in our presentation of them as well,
# so ensure readline does not split on these characters.
readline . set_completer_delims ( readline . get_completer_delims ( ) . replace ( ' - ' , ' ' ) . replace ( ' / ' , ' ' ) )
2011-10-22 13:42:14 +02:00
2008-01-15 16:09:51 +00:00
while True :
# read the command from the command line
try :
input = raw_input ( ' britney> ' ) . lower ( ) . split ( )
except EOFError :
2015-04-26 18:20:09 +02:00
print ( " " )
2008-01-15 16:09:51 +00:00
break
2008-04-23 17:22:24 +00:00
except KeyboardInterrupt :
2015-04-26 18:20:09 +02:00
print ( " " )
2008-04-23 17:22:24 +00:00
continue
2008-01-15 16:09:51 +00:00
# quit the hint tester
2008-02-28 17:23:37 +00:00
if input and input [ 0 ] in ( ' quit ' , ' exit ' ) :
2008-01-15 16:09:51 +00:00
break
2013-03-16 16:30:18 +00:00
elif input and input [ 0 ] in ( ' remove ' , ' approve ' , ' urgent ' , ' age-days ' ,
' block ' , ' block-udeb ' , ' unblock ' , ' unblock-udeb ' ,
' block-all ' , ' force ' ) :
self . hints . add_hint ( ' ' . join ( input ) , ' hint-tester ' )
self . write_excuses ( )
2008-01-15 16:09:51 +00:00
# run a hint
2008-02-28 17:23:37 +00:00
elif input and input [ 0 ] in ( ' easy ' , ' hint ' , ' force-hint ' ) :
2008-04-23 17:22:24 +00:00
try :
self . do_hint ( input [ 0 ] , ' hint-tester ' ,
[ k . rsplit ( " / " , 1 ) for k in input [ 1 : ] if " / " in k ] )
2011-06-28 19:10:13 +00:00
self . printuninstchange ( )
2008-04-23 17:22:24 +00:00
except KeyboardInterrupt :
continue
2011-10-22 10:26:10 +02:00
try :
readline . write_history_file ( histfile )
2015-04-26 18:20:09 +02:00
except IOError as e :
2011-10-22 10:26:10 +02:00
self . __log ( " Could not write %s : %s " % ( histfile , e ) , type = " W " )
2008-01-15 16:09:51 +00:00
2012-01-04 14:20:33 +01:00
def do_hint ( self , hinttype , who , pkgvers ) :
2006-08-01 18:59:29 +00:00
""" Process hints
This method process ` easy ` , ` hint ` and ` force - hint ` hints . If the
2010-02-28 14:44:37 +00:00
requested version is not in unstable , then the hint is skipped .
2006-08-01 18:59:29 +00:00
"""
2011-10-22 19:30:00 +00:00
if isinstance ( pkgvers [ 0 ] , tuple ) or isinstance ( pkgvers [ 0 ] , list ) :
2013-09-07 17:01:58 +00:00
_pkgvers = [ MigrationItem ( ' %s / %s ' % ( p , v ) ) for ( p , v ) in pkgvers ]
2011-09-04 16:41:33 +00:00
else :
_pkgvers = pkgvers
2012-01-04 14:20:33 +01:00
self . __log ( " > Processing ' %s ' hint from %s " % ( hinttype , who ) , type = " I " )
self . output_write ( " Trying %s from %s : %s \n " % ( hinttype , who , " " . join ( [ " %s / %s " % ( x . uvname , x . version ) for x in _pkgvers ] ) ) )
2006-08-01 18:59:29 +00:00
ok = True
# loop on the requested packages and versions
2011-11-15 20:50:09 +00:00
for idx in range ( len ( _pkgvers ) ) :
pkg = _pkgvers [ idx ]
2006-08-01 18:59:29 +00:00
# skip removal requests
2011-09-04 16:41:33 +00:00
if pkg . is_removal :
2006-08-01 18:59:29 +00:00
continue
2011-11-15 20:50:09 +00:00
inunstable = pkg . package in self . sources [ ' unstable ' ]
2011-12-18 21:42:14 +01:00
rightversion = inunstable and ( apt_pkg . version_compare ( self . sources [ ' unstable ' ] [ pkg . package ] [ VERSION ] , pkg . version ) == 0 )
2011-11-15 20:50:09 +00:00
if pkg . suite == ' unstable ' and not rightversion :
for suite in [ ' pu ' , ' tpu ' ] :
2011-12-18 21:42:14 +01:00
if pkg . package in self . sources [ suite ] and apt_pkg . version_compare ( self . sources [ suite ] [ pkg . package ] [ VERSION ] , pkg . version ) == 0 :
2011-11-15 20:50:09 +00:00
pkg . suite = suite
_pkgvers [ idx ] = pkg
break
2011-07-27 09:38:27 +00:00
# handle *-proposed-updates
2011-11-15 20:50:09 +00:00
if pkg . suite in [ ' pu ' , ' tpu ' ] :
2011-09-04 16:41:33 +00:00
if pkg . package not in self . sources [ pkg . suite ] : continue
2011-12-18 21:42:14 +01:00
if apt_pkg . version_compare ( self . sources [ pkg . suite ] [ pkg . package ] [ VERSION ] , pkg . version ) != 0 :
2011-10-29 14:32:26 +00:00
self . output_write ( " Version mismatch, %s %s != %s \n " % ( pkg . package , pkg . version , self . sources [ pkg . suite ] [ pkg . package ] [ VERSION ] ) )
2011-07-27 09:30:00 +00:00
ok = False
2006-08-01 18:59:29 +00:00
# does the package exist in unstable?
2011-11-15 20:50:09 +00:00
elif not inunstable :
2011-09-04 16:41:33 +00:00
self . output_write ( " Source %s has no version in unstable \n " % pkg . package )
2006-08-01 18:59:29 +00:00
ok = False
2011-11-15 20:50:09 +00:00
elif not rightversion :
2011-09-04 16:41:33 +00:00
self . output_write ( " Version mismatch, %s %s != %s \n " % ( pkg . package , pkg . version , self . sources [ ' unstable ' ] [ pkg . package ] [ VERSION ] ) )
2006-08-01 18:59:29 +00:00
ok = False
if not ok :
self . output_write ( " Not using hint \n " )
return False
2012-01-04 14:20:33 +01:00
self . do_all ( hinttype , _pkgvers )
2006-08-01 18:59:29 +00:00
return True
2006-08-01 13:33:06 +00:00
def sort_actions ( self ) :
""" Sort actions in a smart way
2010-02-28 14:44:37 +00:00
This method sorts the list of actions in a smart way . In detail , it uses
as the base sort the number of days the excuse is old , then reorders packages
2006-08-01 13:33:06 +00:00
so the ones with most reverse dependencies are at the end of the loop .
If an action depends on another one , it is put after it .
"""
2015-06-02 21:33:52 +02:00
uvnames = frozenset ( y . uvname for y in self . upgrade_me )
excuses = [ e for e in self . excuses if e . name in uvnames ]
removals = [ ]
upgrade_me = [ ]
for e in excuses :
# We order removals and regular migrations differently, so
# split them out early.
if e . name [ 0 ] == ' - ' :
removals . append ( e . name )
2006-08-01 13:33:06 +00:00
else :
2015-06-02 21:33:52 +02:00
upgrade_me . append ( e . name )
for e in excuses :
# put the item (regular migration) in a good position
# checking its dependencies
pos = [ ]
udeps = [ upgrade_me . index ( x ) for x in e . deps if x in upgrade_me and x != e . name ]
if udeps :
pos . append ( max ( udeps ) )
sdeps = [ upgrade_me . index ( x ) for x in e . sane_deps if x in upgrade_me and x != e . name ]
if sdeps :
pos . append ( min ( sdeps ) )
if not pos :
continue
upgrade_me . remove ( e . name )
upgrade_me . insert ( max ( pos ) + 1 , e . name )
self . dependencies [ e . name ] = e . deps
2006-08-01 18:59:29 +00:00
2006-08-01 13:33:06 +00:00
# replace the list of actions with the new one
2013-09-07 18:19:17 +00:00
self . upgrade_me = [ make_migrationitem ( x , self . sources ) for x in upgrade_me ]
2015-06-02 21:33:52 +02:00
self . upgrade_me . extend ( make_migrationitem ( x , self . sources ) for x in removals )
2006-08-01 13:33:06 +00:00
2006-08-04 18:38:52 +00:00
def auto_hinter ( self ) :
2011-08-28 21:19:05 +00:00
""" Auto-generate " easy " hints.
2006-08-04 18:38:52 +00:00
2015-01-22 15:16:49 -02:00
This method attempts to generate " easy " hints for sets of packages which
2011-08-28 21:19:05 +00:00
must migrate together . Beginning with a package which does not depend on
any other package ( in terms of excuses ) , a list of dependencies and
reverse dependencies is recursively created .
Once all such lists have been generated , any which are subsets of other
lists are ignored in favour of the larger lists . The remaining lists are
then attempted in turn as " easy " hints .
We also try to auto hint circular dependencies analyzing the update
2006-08-06 09:29:32 +00:00
excuses relationships . If they build a circular dependency , which we already
know as not - working with the standard do_all algorithm , try to ` easy ` them .
2006-08-04 18:38:52 +00:00
"""
2014-06-08 17:51:50 +02:00
self . __log ( " > Processing hints from the auto hinter [Partial-ordering] " ,
type = " I " )
2006-08-04 18:38:52 +00:00
# consider only excuses which are valid candidates
2015-06-02 21:33:52 +02:00
valid_excuses = frozenset ( y . uvname for y in self . upgrade_me )
excuses = dict ( ( x . name , x ) for x in self . excuses if x . name in valid_excuses )
excuses_deps = dict ( ( name , set ( excuse . deps ) ) for name , excuse in excuses . items ( ) )
2014-06-08 17:51:50 +02:00
sources_t = self . sources [ ' testing ' ]
groups = set ( )
for y in sorted ( ( y for y in self . upgrade_me if y . uvname in excuses ) , key = attrgetter ( ' uvname ' ) ) :
2014-06-15 16:56:17 +02:00
if y . is_removal and y . package not in sources_t :
2014-06-08 17:51:50 +02:00
# Already removed
continue
if not y . is_removal :
excuse = excuses [ y . uvname ]
if y . architecture == ' source ' and y . uvname in sources_t and sources_t [ y . uvname ] [ VERSION ] == excuse . ver [ 1 ] :
# Already migrated
continue
adds , rms , _ = self . _compute_groups ( y . package , y . suite ,
y . architecture , y . is_removal ,
include_hijacked = True )
groups . add ( ( y , frozenset ( adds ) , frozenset ( rms ) ) )
for comp in self . _inst_tester . solve_groups ( groups ) :
if len ( comp ) > 1 :
2014-06-15 18:20:22 +02:00
self . do_hint ( " easy " , " autohinter " , comp )
2014-06-08 17:51:50 +02:00
self . __log ( " > Processing hints from the auto hinter [Original] " ,
type = " I " )
2006-08-04 18:38:52 +00:00
2011-07-27 08:43:02 +00:00
def find_related ( e , hint , circular_first = False ) :
2006-08-04 18:38:52 +00:00
if e not in excuses :
return False
excuse = excuses [ e ]
2015-04-26 18:20:10 +02:00
if e in sources_t and sources_t [ e ] [ VERSION ] == excuse . ver [ 1 ] :
2006-08-04 18:38:52 +00:00
return True
2011-07-27 08:43:02 +00:00
if not circular_first :
2006-08-04 18:38:52 +00:00
hint [ e ] = excuse . ver [ 1 ]
2015-04-26 18:20:10 +02:00
if not excuse . deps :
2006-08-04 18:38:52 +00:00
return hint
for p in excuse . deps :
if p in hint : continue
if not find_related ( p , hint ) :
return False
return hint
# loop on them
2011-08-27 08:50:14 +00:00
candidates = [ ]
2011-10-22 19:46:09 +00:00
mincands = [ ]
2015-06-02 21:33:52 +02:00
seen_hints = set ( )
2006-08-04 18:38:52 +00:00
for e in excuses :
excuse = excuses [ e ]
2015-04-26 18:20:10 +02:00
if e in sources_t and sources_t [ e ] [ VERSION ] == excuse . ver [ 1 ] :
2011-10-19 11:49:25 +02:00
continue
2015-04-26 18:20:10 +02:00
if excuse . deps :
2011-08-27 08:50:14 +00:00
hint = find_related ( e , { } , True )
2015-06-02 21:33:52 +02:00
if isinstance ( hint , dict ) and e in hint :
h = frozenset ( hint . items ( ) )
if h not in seen_hints :
candidates . append ( h )
seen_hints . add ( h )
2011-08-27 08:50:14 +00:00
else :
2015-06-02 21:33:52 +02:00
items = [ ( e , excuse . ver [ 1 ] ) ]
2015-06-02 21:33:52 +02:00
orig_size = 1
2011-10-22 19:46:09 +00:00
looped = False
2015-06-02 21:33:52 +02:00
seen_items = set ( )
seen_items . update ( items )
2011-08-27 08:50:14 +00:00
for item , ver in items :
# excuses which depend on "item" or are depended on by it
2015-06-02 21:33:52 +02:00
new_items = [ ( x , excuses [ x ] . ver [ 1 ] ) for x in excuses if \
2015-06-02 21:33:52 +02:00
( item in excuses_deps [ x ] or x in excuses_deps [ item ] ) \
2015-06-02 21:33:52 +02:00
and ( x , excuses [ x ] . ver [ 1 ] ) not in seen_items ]
items . extend ( new_items )
seen_items . update ( new_items )
2011-10-22 19:46:09 +00:00
if not looped and len ( items ) > 1 :
2015-06-02 21:33:52 +02:00
orig_size = len ( items )
2015-06-02 21:33:52 +02:00
h = frozenset ( seen_items )
2015-06-02 21:33:52 +02:00
if h not in seen_hints :
mincands . append ( h )
seen_hints . add ( h )
2011-10-22 19:46:09 +00:00
looped = True
2015-06-02 21:33:52 +02:00
if len ( items ) != orig_size :
2015-06-02 21:33:52 +02:00
h = frozenset ( seen_items )
2015-06-02 21:33:52 +02:00
if h != mincands [ - 1 ] and h not in seen_hints :
candidates . append ( h )
seen_hints . add ( h )
2011-08-27 08:50:14 +00:00
2011-10-22 19:46:09 +00:00
for l in [ candidates , mincands ] :
2015-06-02 21:33:52 +02:00
for hint in l :
self . do_hint ( " easy " , " autohinter " , [ MigrationItem ( " %s / %s " % ( x [ 0 ] , x [ 1 ] ) ) for x in sorted ( hint ) ] )
2006-08-06 09:29:32 +00:00
2008-05-02 13:57:37 +00:00
def nuninst_arch_report ( self , nuninst , arch ) :
""" Print a report of uninstallable packages for one architecture. """
2014-08-04 20:20:33 +02:00
all = defaultdict ( set )
2008-05-02 13:57:37 +00:00
for p in nuninst [ arch ] :
pkg = self . binaries [ ' testing ' ] [ arch ] [ 0 ] [ p ]
2014-08-05 07:54:53 +02:00
all [ ( pkg [ SOURCE ] , pkg [ SOURCEVER ] ) ] . add ( p )
2008-05-02 13:57:37 +00:00
2015-04-26 18:20:09 +02:00
print ( ' * %s ' % ( arch , ) )
2008-05-02 13:57:37 +00:00
2015-04-26 18:20:09 +02:00
for ( src , ver ) , pkgs in sorted ( all . items ( ) ) :
2015-04-26 18:20:09 +02:00
print ( ' %s ( %s ): %s ' % ( src , ver , ' ' . join ( sorted ( pkgs ) ) ) )
2008-05-02 13:57:37 +00:00
print
2006-08-01 18:59:29 +00:00
def output_write ( self , msg ) :
""" Simple wrapper for output writing """
2015-04-26 18:20:09 +02:00
print ( msg , end = ' ' )
2009-02-23 23:13:06 +01:00
self . __output . write ( msg )
2006-08-01 18:59:29 +00:00
2006-06-24 17:49:43 +00:00
def main ( self ) :
""" Main method
2015-01-22 15:16:49 -02:00
2006-06-24 17:49:43 +00:00
This is the entry point for the class : it includes the list of calls
for the member methods which will produce the output files .
"""
2008-05-02 13:57:37 +00:00
# if running in --print-uninst mode, quit
if self . options . print_uninst :
2008-04-29 05:08:58 +00:00
return
2006-08-07 14:38:13 +00:00
# if no actions are provided, build the excuses and sort them
2008-04-29 05:08:58 +00:00
elif not self . options . actions :
2006-07-28 13:21:44 +00:00
self . write_excuses ( )
2011-12-29 14:10:31 +01:00
self . sort_actions ( )
2006-08-07 14:38:13 +00:00
# otherwise, use the actions provided by the command line
2008-01-15 16:09:51 +00:00
else :
self . upgrade_me = self . options . actions . split ( )
2006-07-28 13:21:44 +00:00
2014-06-06 14:45:55 +01:00
ensuredir ( os . path . dirname ( self . options . upgrade_output ) )
2015-04-26 18:20:10 +02:00
with open ( self . options . upgrade_output , ' w ' , encoding = ' utf-8 ' ) as f :
self . __output = f
2009-02-23 23:13:06 +01:00
2015-04-26 18:20:10 +02:00
# run the hint tester
if self . options . hint_tester :
self . hint_tester ( )
# run the upgrade test
else :
self . upgrade_testing ( )
2006-06-17 13:45:56 +00:00
2015-04-26 18:20:11 +02:00
self . __log ( ' > Stats from the installability tester ' , type = " I " )
for stat in self . _inst_tester . stats . stats ( ) :
self . __log ( ' > %s ' % stat , type = " I " )
2009-02-23 23:13:06 +01:00
2013-11-27 19:46:59 +01:00
def _installability_test ( self , pkg_name , pkg_version , pkg_arch , broken , to_check , nuninst_arch ) :
2011-12-29 14:37:03 +01:00
""" Test for installability of a package on an architecture
2013-11-27 19:46:59 +01:00
( pkg_name , pkg_version , pkg_arch ) is the package to check .
2011-12-29 14:37:03 +01:00
broken is the set of broken packages . If p changes
installability ( e . g . goes from uninstallable to installable ) ,
broken will be updated accordingly . Furthermore , p will be
added to " to_check " for futher processing .
If nuninst_arch is not None then it also updated in the same
way as broken is .
"""
2013-11-27 19:46:59 +01:00
r = self . _inst_tester . is_installable ( pkg_name , pkg_version , pkg_arch )
if not r :
2011-12-29 14:37:03 +01:00
# not installable
2013-11-27 19:46:59 +01:00
if pkg_name not in broken :
broken . add ( pkg_name )
to_check . append ( pkg_name )
if nuninst_arch is not None and pkg_name not in nuninst_arch :
nuninst_arch . add ( pkg_name )
2011-12-29 14:37:03 +01:00
else :
2013-11-27 19:46:59 +01:00
if pkg_name in broken :
to_check . append ( pkg_name )
broken . remove ( pkg_name )
if nuninst_arch is not None and pkg_name in nuninst_arch :
nuninst_arch . remove ( pkg_name )
2011-12-29 14:37:03 +01:00
2006-06-17 13:45:56 +00:00
if __name__ == ' __main__ ' :
Britney ( ) . main ( )