summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
AgeCommit message (Collapse)AuthorFilesLines
2016-06-29if conf unset, don't read / as conf/pref/sources dirDavid Kalnischkies1-2/+2
Usually these config options are set to sensible values, but if init isn't run or the user interferes with configuration clearing or similar the options could indeed carry an empty value, which will result in FindDir returning a '/'. That feels kinda wrong, but as a public interface there isn't much we can do about it and instead make it so that we get the special file /dev/null back we know how to deal with in such cases.
2016-05-20fail instead of segfault on unreadable config filesDavid Kalnischkies1-0/+5
The report mentions "apt list --upgradable", but there are others which have inconsistent behavior ranging from segfaulting to doing something with the partial (and hence incomplete) data. We had a recent report about sources.list (#818628), this one mentions prefences, the obvious next step is conf files… so the testcase is adapted to check for all three in file and directory versions and run a bunch of commands each time which should all have more or less the same behavior in such a case (aka error out). Closes: 824503
2016-04-25policy: Remove TODO for replacing old GetCandidateVer()Julian Andres Klode1-1/+0
Gbp-Dch: ignore
2016-04-25policy: Get rid of old (pre-1.1) GetCandidateVer algorithmJulian Andres Klode1-97/+0
Bye bye old friend. You're in one Ubuntu LTS release for compat testing, now we do not need you anymore.
2016-04-25restore pinning to min/max value of shortDavid Kalnischkies1-2/+3
Broken in the previous commit (69cea1ef2cfda3c4da79fd756a8edaf2be26998e). Adding a test and a comment to avoid future embarrassment. Git-Dch: Ignore Reported-By: Julian Andres Klode on IRC
2016-04-25give rc-status packages a pin of -1David Kalnischkies1-7/+6
It would previously return a pin of 0, which is an invalid value, but the intend is that versions which are only in the dpkg/status file can't be selected for installation (= can't be a candidate) which is what a negative pin assures. This helps with the communication to EDSP solvers as they neither know about the rc-state (yet) nor that they shouldn't choose this version. Ideally they shouldn't be told about such versions at all as there is nothing to be solved here, but we will get there eventually.
2016-01-02properly parse comments in apt_preferences and deb822-style sourcesDavid Kalnischkies1-2/+2
apt_preferences and deb822-style sources used the specialized class pkgUserTagSection to deal with comments before/after a given stanza, but it couldn't deal with comments in the stanza at all. codesearch suggests that nobody else does and a vastely superior way of working with potentially commented files is implemented now, so we can officially discourage the use of the old incomplete hack class.
2015-11-05apply various suggestions made by cppcheckDavid Kalnischkies1-2/+2
Reported-By: cppcheck Git-Dch: Ignore
2015-11-04provide public interface to hold/unhold packagesDavid Kalnischkies1-2/+2
We had this code lying around in apt-mark for a while now, but other frontends need this (and similar) functionality as well, so its high time that we provide a public interface in libapt for this stuff.
2015-09-14avoid using global PendingError to avoid failing too often too soonDavid Kalnischkies1-3/+6
Our error reporting is historically grown into some kind of mess. A while ago I implemented stacking for the global error which is used in this commit now to wrap calls to functions which do not report (all) errors via return, so that only failures in those calls cause a failure to propergate down the chain rather than failing if anything (potentially totally unrelated) has failed at some point in the past. This way we can avoid stopping the entire acquire process just because a single source produced an error for example. It also means that after the acquire process the cache is generated – even if the acquire process had failures – as we still have the old good data around we can and should generate a cache for (again). There are probably more instances of this hiding, but all these looked like the easiest to work with and fix with reasonable (aka net-positive) effects.
2015-09-14implement autobit and pinning in EDSP solver 'apt'David Kalnischkies1-1/+2
The parser creates a preferences as well as an extended states file based on the EDSP scenario file, which isn't the most efficient way of dealing with this as thes text files have to be parsed again by another layer of the code, but it needs the least changes and works good enough for now. The 'apt' solver is in the end just a test solver like dump.
2015-08-20Re-indent GetCandidateVerNew() and make ConsiderFiles argument explicitJulian Andres Klode1-7/+7
Gbp-Dch: ignore
2015-08-17Fix all the wrong removals of includes that iwyu got wrongMichael Vogt1-0/+1
Git-Dch: ignore
2015-08-17Cleanup includes after running iwyuMichael Vogt1-2/+0
2015-08-15Add GetPriority(VerIterator) to pkgDepCache::PolicyJulian Andres Klode1-2/+2
Also unify the case of considerFiles and ConsiderFiles to be ConsiderFiles in all cases. Gbp-Dch: ignore
2015-08-13Deprecate SPtrArray<T> and convert everyone to unique_ptr<T[]>Julian Andres Klode1-2/+2
More standardization
2015-08-12policy: Be more strict about parsing pin files, and document prio 0Julian Andres Klode1-3/+10
Treat invalid pin priorities and overflows as an error. Closes: #429912
2015-08-12Add a parameter ConsiderFiles to GetPriority(VerIterator)Julian Andres Klode1-2/+3
This allows us to exclude files from being considered for the priority, so it will return only specific-version matches.
2015-08-11Simply ignore cruft in the status files, do not treat it as prio 0Julian Andres Klode1-2/+1
This was broken in case all other sources were < 0.
2015-08-11Replace INT_MIN with std::numeric_limits<int>::minJulian Andres Klode1-2/+2
This should fix travis compilation errors. Gbp-Dch: ignore
2015-08-10initialize PinVers to a nullptrDavid Kalnischkies1-1/+2
This makes test-bug-254770-segfault-if-cache-not-buildable happy. Git-Dch: Ignore
2015-08-10bring back deb822 sources.list entries as .sourcesDavid Kalnischkies1-17/+2
Having two different formats in the same file is very dirty and causes external tools to fail hard trying to parse them. It is probably not a good idea for them to parse them in the first place, but they do and we shouldn't break them if there is a better way. So we solve this issue for now by giving our deb822 format a new filename extension ".sources" which unsupporting applications are likely to ignore an can begin gradually moving forward rather than waiting for the unknown applications to catch up. Currently and for the forseeable future apt is going to support both with the same feature set as documented in the manpage, with the longtime plan of adopting the 'new' format as default, but that is a long way to go and might get going more from having an easier time setting options than from us pushing it explicitely.
2015-08-10make all d-pointer * const pointersDavid Kalnischkies1-1/+1
Doing this disables the implicit copy assignment operator (among others) which would cause hovac if used on the classes as it would just copy the pointer, not the data the d-pointer points to. For most of the classes we don't need a copy assignment operator anyway and in many classes it was broken before as many contain a pointer of some sort. Only for our Cacheset Container interfaces we define an explicit copy assignment operator which could later be implemented to copy the data from one d-pointer to the other if we need it. Git-Dch: Ignore
2015-08-10policy: Fix the handling of config-files statesJulian Andres Klode1-3/+12
Gbp-Dch: ignore
2015-08-10policy: Fix the new policy implementation to handle downgrades correctlyJulian Andres Klode1-9/+8
This was broken previously, as we'd choose a downgrade when it's pin was higher than the previously selected candidate.
2015-08-10Determine the candidate based on per-version pins, instead of old codeJulian Andres Klode1-0/+36
The new implementation assigns each version a pin, instead of assigning the pin to a package. This enables us to give each version of a package a different priority. Closes: #770017 Closes: #622237 Closes: #620249 Closes: #685215
2015-08-10policy: Return highest file pin if version pin == 0 in GetPriority()Julian Andres Klode1-1/+10
This makes sure that we display a useful value instead of 0 for versions that are pinned due to package files.
2015-08-10policy: Assign per-version pinsJulian Andres Klode1-0/+11
2015-08-10pkgPolicy: Introduce storage and helpers for per-version pinsJulian Andres Klode1-1/+10
Per-version pins should lead to more predictable results with /etc/apt/preferences uses like pinning one version with -1.
2015-06-16add d-pointer, virtual destructors and de-inline de/constructorsDavid Kalnischkies1-0/+2
To have a chance to keep the ABI for a while we need all three to team up. One of them missing and we might loose, so ensuring that they are available is a very tedious but needed task once in a while. Git-Dch: Ignore
2015-06-12store Release files data in the CacheDavid Kalnischkies1-8/+7
We used to read the Release file for each Packages file and store the data in the PackageFile struct even through potentially many Packages (and Translation-*) files could use the same data. The point of the exercise isn't the duplicated data through. Having the Release files as first-class citizens in the Cache allows us to properly track their state as well as allows us to use the information also for files which aren't in the cache, but where we know to which Release file they belong (Sources are an example for this). This modifies the pkgCache structs, especially the PackagesFile struct which depending on how libapt users access the data in these structs can mean huge breakage or no visible change. As a single data point: aptitude seems to be fine with this. Even if there is breakage it is trivial to fix in a backportable way while avoiding breakage for everyone would be a huge pain for us. Note that not all PackageFile structs have a corresponding ReleaseFile. In particular the dpkg/status file as well as *.deb files have not. As these have only a Archive property need, the Component property takes over this duty and the ReleaseFile remains zero. This is also the reason why it isn't needed nor particularily recommended to change from PackagesFile to ReleaseFile blindly. Sticking with the earlier is usually the better option.
2015-05-11remove unused and strange default-value for pinsDavid Kalnischkies1-24/+10
If the pin for a generic pin is 0, it get a value by strange looking rules, if the pin is specific the rules are at least not strange, but the value 989 is a magic number without any direct meaning… but both never happens in practice as the parsing skips such entries with a warning, so there always is a priority != 0 and the code therefore never used.
2015-05-11a pin of 1000 always means downgrade allowedDavid Kalnischkies1-22/+10
The documentation says this, but the code only agreed while evaluating specific packages, but not generics. These needed a pin above 1000 to have the same effect. The code causing this makes references to a 'second pesduo status file', but nowhere is explained what this might stand for and/or what it was, so we do the only reasonable thing: Remove all references and do as documented.
2014-03-13follow method attribute suggestions by gccDavid Kalnischkies1-2/+2
Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn}
2014-03-13cleanup headers and especially #includes everywhereDavid Kalnischkies1-1/+9
Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use)
2014-03-13warning: unused parameter ‘foo’ [-Wunused-parameter]David Kalnischkies1-1/+1
Reported-By: gcc -Wunused-parameter Git-Dch: Ignore
2013-12-21make /etc/apt/preferences parser deal with comment only sectionsMichael Vogt1-0/+4
2013-08-08specific pins below 1000 cause downgradesDavid Kalnischkies1-7/+18
We start your quest by using the version of a package applying to a specific pin, but that version could very well be below the current version, which causes APT to suggest a downgrade even if it is advertised that it never does this below 1000. Its of course questionable what use a specific pin on a package has which has a newer version already installed, but reacting with the suggestion of a downgrade is really not appropriated (even if its kinda likely that this is actually the intend the user has – it could just as well be an outdated pin) and as pinning is complicated enough we should atleast do what is described in the manpage. So we look out for the specific pin and if we haven't seen it at the moment we see the installed version, we ignore the specific pin. Closes: 543966
2012-10-13* apt-pkg/policy.cc:David Kalnischkies1-23/+26
- match pins with(out) an architecture as we do on the commandline (partly fixing #687255, b= support has to wait for jessie)
2011-10-30merge with my debian-sid branchDavid Kalnischkies1-1/+2
2011-10-04* apt-pkg/policy.cc:David Kalnischkies1-1/+2
- accept generic release pin expressions again in -t (Closes: #644166)
2011-09-13merge with debian/experimentalDavid Kalnischkies1-9/+23
2011-09-13reorder includes: add <config.h> if needed and include it at firstDavid Kalnischkies1-2/+4
2011-08-15merged from the debian-sid branchMichael Vogt1-7/+7
2011-08-11cppcheck complains about some possible speed improvements which could beDavid Kalnischkies1-7/+7
done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types.
2011-07-28* merged latest fixes from debian-sidMichael Vogt1-2/+16
* apt-pkg/contrib/sha1.cc: - fix illegally casts of on-stack buffer to a type requiring more alignment than it has resulting in segfaults on sparc (Closes: #634696) * apt-pkg/contrib/cdromutl.cc: - fix escape problem when looking for the mounted devices * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: - add new DeEscapeString() similar to DeQuoteString but unescape character escapes like \0XX and \xXX (plus added test) * refresh po/* * cmdline/apt-get.cc: - fix missing download progress in apt-get download - do not require unused partial dirs in 'source' (Closes: #633510) - buildconflicts effect all architectures - implement MultiarchCross for build-dep and source (Closes: #632221) * cmdline/apt-key: - use a tmpfile instead of /etc/apt/secring.gpg (Closes: #632596) * debian/apt.postinst: - remove /etc/apt/secring.gpg if it is an empty file * doc/apt-cache.8.xml: - apply madison typofix from John Feuerstein, thanks! (Closes: #633455) * apt-pkg/policy.cc: - emit an error on unknown APT::Default-Release value (Closes: #407511) * apt-pkg/aptconfiguration.cc: - ensure that native architecture is if not specified otherwise the first architecture in the Architectures vector * apt-pkg/deb/deblistparser.cc: - Strip only :any and :native if MultiArch should be stripped as it is save to ignore them in non-MultiArch contexts but if the dependency is a specific architecture (and not the native) do not strip
2011-07-16* apt-pkg/policy.cc:David Kalnischkies1-2/+16
- emit an error on unknown APT::Default-Release value (Closes: #407511)
2011-06-30merged from debian-sidMichael Vogt1-20/+44
2011-06-30* doc/makefile:Michael Vogt1-20/+44
- create doxygen directory to avoid depending on magic (Closes: #628799) * cmdline/apt-key: - explicitly state that net-update is not supported if no url is set - require to be root for add, rm, update and net-update - clarify update vs. net-update in different distros (Closes: #632043) * debian/apt.symbols: - forgot 'mips' in the list for all architecture dependent symbols - comment out gcc-4.5 specific symbols as gcc-4.6 is now default - the symbol for PrintStatus() is architecture dependent * apt-pkg/policy.cc: - do not segfault in pinning if a package with this name doesn't exist. Thanks to Ferdinand Thommes for the report! - Defaults is a vector of Pin not of PkgPin - ensure that only the first specific stanza for a package is used - save all stanzas which had no effect in Unmatched - allow package:architecure in Package:
2011-05-17* Implement EDSP in libapt-pkg so that all front-ends whichDavid Kalnischkies1-0/+4
use the internal resolver can now be used also with external ones as the usage is hidden in between the old API * provide two edsp solvers in apt-utils: - 'dump' to quickly output a complete scenario and - 'apt' to use the internal as an external resolver