summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-06-09 13:39:32 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-06-09 13:39:32 +0000
commit8c39d507ee7e0c3e06c96859e499f9390bea2ad7 (patch)
treeab721842c41bb57901d8bac07d54b87624a1905d /usr.sbin/pkg_add/OpenBSD
parentb0f04183f9686e32b7d65c440f335b9fd9a2b60f (diff)
tag user installed packages.
- record what's on the command line. - adjust option depending on -a / !-a - report `manual-install' status when replacing stuff.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm50
1 files changed, 49 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 6e77e89e917..99ca49ef26b 100644
--- a/usr.sbin/pkg_add/OpenBSD/Add.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Add.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.75 2007/06/06 15:35:20 espie Exp $
+# $OpenBSD: Add.pm,v 1.76 2007/06/09 13:39:31 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -105,6 +105,54 @@ sub perform_installation
$handle->{location}->finish_and_close;
}
+my $user_tagged = {};
+
+sub extract_pkgname
+{
+ my $pkgname = shift;
+ $pkgname =~ s/^.*\///;
+ $pkgname =~ s/\.tgz$//;
+ return $pkgname;
+}
+
+sub tweak_package_status
+{
+ my ($pkgname, $state) = @_;
+
+ $pkgname = extract_pkgname($pkgname);
+ return 0 unless is_installed($pkgname);
+ return 0 unless $user_tagged->{$pkgname};
+ my $plist = OpenBSD::PackingList->from_installation($pkgname);
+ if ($plist->has('manual-installation') && $state->{automatic}) {
+ delete $plist->{'manual-installation'};
+ $plist->to_installation;
+ return 1;
+ } elsif (!$plist->has('manual-installation') && !$state->{automatic}) {
+ OpenBSD::PackingElement::ManualInstallation->add($plist);
+ $plist->to_installation;
+ return 1;
+ }
+ return 0;
+}
+
+sub tweak_plist_status
+{
+ my ($plist, $state) = @_;
+
+ my $pkgname = $plist->pkgname;
+ return 0 unless $user_tagged->{$pkgname};
+ if (!$plist->has('manual-installation') && !$state->{automatic}) {
+ OpenBSD::PackingElement::ManualInstallation->add($plist);
+ }
+}
+
+sub tag_user_packages
+{
+ for my $pkgname (@_) {
+ $user_tagged->{extract_pkgname($pkgname)} = 1;
+ }
+}
+
# used by newuser/newgroup to deal with options.
package OpenBSD::PackingElement;
use OpenBSD::Error;