summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_mklocatedb
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2013-01-27 11:39:23 +0000
committerMarc Espie <espie@cvs.openbsd.org>2013-01-27 11:39:23 +0000
commit06c80259664033fa613b1ed7a6cbee347edfd69f (patch)
tree75173c7f59cfd07088c0c80c04279f8888106729 /usr.sbin/pkg_add/pkg_mklocatedb
parent1935381376943206f0e12dc0315a9132cfb9df56 (diff)
add a -u option to make it possible to build on an existing database
Diffstat (limited to 'usr.sbin/pkg_add/pkg_mklocatedb')
-rw-r--r--usr.sbin/pkg_add/pkg_mklocatedb59
1 files changed, 47 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/pkg_mklocatedb b/usr.sbin/pkg_add/pkg_mklocatedb
index b7c295fdeb0..e6d72fe86cf 100644
--- a/usr.sbin/pkg_add/pkg_mklocatedb
+++ b/usr.sbin/pkg_add/pkg_mklocatedb
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org>
-# $OpenBSD: pkg_mklocatedb,v 1.38 2012/05/28 10:14:33 espie Exp $
+# $OpenBSD: pkg_mklocatedb,v 1.39 2013/01/27 11:39:22 espie Exp $
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -31,8 +31,8 @@ sub handle_options
{
my $state = shift;
$state->{no_exports} = 1;
- $state->SUPER::handle_options('aCd:nqs:x:r:p:P',
- '[-aCnPq] [-d repository] [-p portsdir] [-r release] [-s src] ',
+ $state->SUPER::handle_options('aCd:Knqs:x:r:p:Pu',
+ '[-aCKnPqu] [-d repository] [-p portsdir] [-r release] [-s src] ',
'[-x X11src] [pkg-name [...]]');
$state->{srcdir} = $state->opt('s');
$state->{xdir} = $state->opt('x');
@@ -44,6 +44,8 @@ sub handle_options
$state->{allinfo} = $state->opt('a');
$state->{nopipe} = $state->opt('n');
$state->{check} = $state->opt('C');
+ $state->{full} = $state->opt('K');
+ $state->{update} = $state->opt('u');
if ($state->{check}) {
unless ($state->{srcdir} or $state->{portsdir}) {
$state->usage("-C without -s dir or -x dir");
@@ -72,14 +74,27 @@ sub set_header
} elsif ($state->{pkgpath}) {
$state->{currentheader} = $self->{subdir}.':';
}
+ $state->{done}{$self->{subdir}} = 1;
$state->errsay($state->{currentheader}) unless $state->{quiet};
}
package OpenBSD::PackingElement::FileObject;
+sub object_name
+{
+ my ($self, $state) = @_;
+ if ($state->{full}) {
+ if ($self->needs_keyword) {
+ return "\@".$self->keyword." ".$self->fullname;
+ }
+ }
+ return $self->fullname;
+}
+
sub print_name
{
my ($self, $state) = @_;
- print {$state->{out}} $state->{currentheader}, $self->fullname, "\n";
+ print {$state->{out}} $state->{currentheader},
+ $self->object_name($state), "\n";
}
package OpenBSD::PackingElement::Action;
@@ -101,7 +116,8 @@ package OpenBSD::PackingElement::DirBase;
sub print_name
{
my ($self, $state) = @_;
- print {$state->{out}} $state->{currentheader}, $self->fullname, "/\n";
+ print {$state->{out}} $state->{currentheader},
+ $self->object_name($state), "/\n";
}
package main;
@@ -259,6 +275,19 @@ sub do_pkgdir
}, $state->{pkgdir});
}
+sub copy_stdin
+{
+ my $state = shift;
+ while (<STDIN>) {
+ # if we find something that looks like a pkgpath we've done
+ # assume we were updating it
+ if (m,([^:]*/[^:]*)\:,) {
+ next if defined $state->{done}{$1};
+ }
+ print {$state->{out}} $_;
+ }
+}
+
my $state = OpenBSD::Pkgmklocatedb::State->new("pkg_mklocatedb");
$state->handle_options;
@@ -281,13 +310,16 @@ if ($state->{portsdir}) {
} elsif ($state->{pkgdir}) {
do_pkgdir($state);
} elsif (@ARGV == 0) {
- $state->progress->for_list("Scanning installation",
- [installed_packages()], sub {
- my $pkgname = shift;
- my $plist = OpenBSD::PackingList->from_installation($pkgname);
- return unless defined $plist;
- print_out($plist, $state);
- });
+ if (!$state->{update}) {
+ $state->progress->for_list("Scanning installation",
+ [installed_packages()], sub {
+ my $pkgname = shift;
+ my $plist =
+ OpenBSD::PackingList->from_installation($pkgname);
+ return unless defined $plist;
+ print_out($plist, $state);
+ });
+ }
} else {
$state->progress->for_list("Scanning packages", \@ARGV,
sub {
@@ -297,3 +329,6 @@ if ($state->{portsdir}) {
print_out($plist, $state);
});
}
+if ($state->{update}) {
+ copy_stdin($state);
+}