Thinking of making it possible to remove unneeded dependencies on the go,
as it would allow us to find more problems.
I'm thinking it won't be THAT slow, since at the end of a bulk, pkg_add
spends a lot of time just processing the full list of installed packages
(which amounts to ~2000), whereas adding/deleting as we go might even
be faster ? at least it would consume less space under /usr/local, and it
might even allow conflicting packages to build.
Some things have already been done, such as tweaking prepare a bit so that
it records the packages actually used as dependencies, and fixing the
semantics of pkg_delete -a to only delete automatically installed packages.
I'm also probably going to add a -X to pkg_delete, to exclude packages.
Say, pkg_delete -X kdelibs would remove everything from your machine to
the exception of kdelibs and dependencies.
(because it's simpler for me to know what packages to keep than to know
what packages to remove, and I believe the option would be useful for
other things).
(thus, dpb wouldn't interfere with manual use of a machine, since the
removal of packages would only remove dependencies, and not stuff manually
installed by a user).
So, the amended version of "building packages" would be:
- depend -> make sure wanted dependencies are available
- prepare -> control those dependencies
- show-prepare-results -> grab the actual list of dependencies used
- deinstall -> remove all dependencies no longer needed
- build/package/clean -> normal run of the package
This is a bit complicated, though, because we're talking of several builds
going on at once, so the deinstall stage has to consider all packages
currently needed by builds running on the same machine at that time.
There's also a race condition that dpb will have to handle: basically, if
some ports are in the depend/prepare/show-prepare-results stage, you
have to wait before you run the deinstall stage.
(on the bright side, the deinstall stage can regroup several ports that
did the depend/prepare/show-prepare-results stage).
And while you run the deinstall stage,
you can't enter the depend/prepare/show-prepare-results stage.
This is going to be fun, I will probably have to tweak the engine to achieve
proper results.
Unless you guys think of a simpler way to achieve this.
Untested patch for pkg_delete -X
Index: OpenBSD/PkgDelete.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm,v
retrieving revision 1.26
diff -u -p -r1.26 PkgDelete.pm
--- OpenBSD/PkgDelete.pm 25 Nov 2011 23:58:40 -0000 1.26
+++ OpenBSD/PkgDelete.pm 26 Nov 2011 11:29:29 -0000
@@ -100,7 +100,7 @@ sub handle_options
{
my $state = shift;
$state->SUPER::handle_options('',
- '[-acinqsvx] [-B pkg-destdir] [-D name[=value]] pkg-name [...]');
+ '[-acinqsvxX] [-B pkg-destdir] [-D name[=value]] pkg-name [...]');
my $base = $state->opt('B') // $ENV{'PKG_DESTDIR'} // '';
if ($base ne '') {
@@ -114,6 +114,7 @@ sub handle_options
} else {
$state->{destdirname} = '${PKG_DESTDIR}';
}
+ $state->{exclude} = $state->opt('X');
}
sub stem2location
@@ -211,7 +212,7 @@ sub process_parameters
my $inst = $state->repo->installed;
if (@ARGV == 0) {
- if (!$state->{automatic}) {
+ if (!$state->{automatic} || $state->{exclude}) {
$state->fatal("No packages to delete");
}
} else {
@@ -379,6 +380,19 @@ sub main
{
my ($self, $state) = @_;
+ if ($state->{exclude}) {
+ my $names = {};
+ for my $l (@{$state->{setlist}}) {
+ for my $n ($l->older_names) {
+ $names->{$n} = 1;
+ }
+ }
+ $state->{setlist} = [];
+ my $inst = $state->repo->installed;
+ for my $l (@{$inst->locations_list}) {
+ $self->add_location($state, $l) if !$names->{$l->name};
+ }
+ }
if ($state->{automatic}) {
if (!defined $state->{setlist}) {
my $inst = $state->repo->installed;