Some packages conflict, so it's impossible to install all available packages at once. What's the maximum possible number of installable packages for a given system? A brute-force trial and error method would be:
- make a list of every possible of package name, i.e.
dglob -a > list
- from that, make sublists
slist1 slist2 slist3 ...
of every possible package combination. On my systemdglob -a | wc -l
returns 91327, which would require an unfeasibly large number (1.467×10^27492) of files. - run
apt-get install
on each list, andrm
those that produce conflicts. - sort remaining lists by number of lines, and show the longest one.
wc -l slist* | head -n -1 | sort -g | tail -1
.
Easy, but too heavy on resources, so maybe there's some more feasible method.
Various related questions follow from that, such as:
given a package 'foo', how to find the maximum number of installable packages that don't conflict with 'foo'?
For all possible packages, which has the smallest such maximum, (making it the most "quarrelsome" package)?
(Note: The question applies to Debian, Red Hat, and any distro or OS with a packaging system that maps out package conflicts. Answers for any applicable platform would be valid.)
Background:
Debian has tens of thousands of packages. dglob
(from the debian-goodies package) is handy for getting a quick count:
# show how many packages installed and available on the current system
echo $(dglob | wc -l) packages installed of \
$(dglob -a | wc -l) packages.
Example output, (both numbers may periodically fluctuate after updates and upgrades, and will vary between systems):
5107 packages installed of 91327 packages.
The number 5107's not a maximum of course, but there must be a maximum.
Depends
relationships:A
conflicts withB
, but 10 packages depend onA
and7
depend on B, but maybe eliminating those 10 packages solves some other conflicts too, while eliminating the 7 doesn't gain you much elsewhere... – IndeneDepends
, we can construct a completeConflicts
list. (OTOH starting with a package list and only a their respective individualConflicts
, inferring theirDepends
could be quite ambiguous.) For this question, it seems like theDepends
andConflicts
relationships are kind of the same thing. – Emptyhandedapt-get install
on each list, then sort for the longest conflict free list) -- if you insist, I could write actual code that does that, but it should be obvious that it'll virtually never finish, so the description alone seems sufficient. – Emptyhandedapt-get install
anything, just analyze the dependency graph as outlined in previous comments. Stack Overflow specifically isn't for "what if..." questions; apart from idle curiosity, is there a reason a developer would need to solve this problem? If graph analysis to find the largest subgraphs without conflicts is a problem you want to solve, you can remove all the package management stuff from the question (or, more realistically, ask a better-scoped new question). – Immigrate