diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-07-20 18:58:42 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-07-20 18:58:42 +0000 |
commit | 2293af38b04a2de14fa3de145fda2821bcbcc105 (patch) | |
tree | 7d66ff430b59466dadc2f07a59caef26fb2c1c85 /usr.sbin/pkg_add | |
parent | a76bb0b2cfc88cd076be31dcc6aad7102686f557 (diff) |
support for gnu-info, with @info keyword.
- modify pkg_create so that it will look for info-[0-9]+ and add them
to the packing-list.
- deal with installing the info file/de-installing it at pkg_add/pkg_delete
time.
tested by naddy@
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 25 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 14 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 61 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 16 |
5 files changed, 95 insertions, 25 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index df427f770bf..41222ed8aaf 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackingElement.pm,v 1.11 2004/07/14 10:44:03 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.12 2004/07/20 18:58:41 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -150,6 +150,8 @@ sub expand } sub IsFile() { 0 } +sub NoDuplicateNames() { 0 } + sub fullname($) { return $_[0]->{fullname}; @@ -161,12 +163,18 @@ use File::Spec; use OpenBSD::PackageInfo qw(is_info_name); __PACKAGE__->setKeyword('file'); +sub needs_keyword +{ + my $self = shift; + return $self->stringize() =~ m/\^@/; +} + sub write { my ($self, $fh) = @_; print $fh "\@ignore\n" if defined $self->{ignore}; print $fh "\@comment no checksum\n" if defined $self->{nochecksum}; - if ($self->stringize() =~ m/^\@/) { + if ($self->needs_keyword()) { $self->SUPER::write($fh); } else { print $fh $self->stringize(), "\n"; @@ -245,6 +253,15 @@ sub make_hardlink sub IsFile() { 1 } +sub NoDuplicateNames() { 1 } + +package OpenBSD::PackingElement::InfoFile; +our @ISA=qw(OpenBSD::PackingElement::File); +__PACKAGE__->setKeyword('info'); +sub keyword() { "info" } + +sub needs_keyword { 1 } + package OpenBSD::PackingElement::Ignore; our @ISA=qw(OpenBSD::PackingElement); __PACKAGE__->setKeyword('ignore'); @@ -571,6 +588,8 @@ sub destate package OpenBSD::PackingElement::Dirs; +sub NoDuplicateNames() { 1 } + package OpenBSD::PackingElement::DirRm; our @ISA=qw(OpenBSD::PackingElement::Dirs OpenBSD::PackingElement); @@ -617,6 +636,8 @@ sub add_md5 $self->{md5} = $md5; } +sub needs_keyword { 0 } + sub write { &OpenBSD::PackingElement::File::write; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index d52b97dc449..60972e84aa1 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackingList.pm,v 1.11 2004/07/14 10:44:03 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.12 2004/07/20 18:58:41 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -83,7 +83,7 @@ sub FilesOnly my ($fh, $cont) = @_; local $_; while (<$fh>) { - next unless m/^\@cwd\b/ || m/^\@name\b/ || !m/^\@/; + next unless m/^\@cwd\b/ || m/^\@name\b/ || m/^\@info\b/ || !m/^\@/; &$cont($_); } } diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 00b5ffa66b3..e3f6983c4dd 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.34 2004/07/14 10:44:03 espie Exp $ +# $OpenBSD: pkg_add,v 1.35 2004/07/20 18:58:41 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -95,6 +95,18 @@ sub install $self->set_modes($destdir.$fullname); } +package OpenBSD::PackingElement::InfoFile; +use File::Basename; + +sub install +{ + my ($self, $archive, $destdir, $verbose, $not) = @_; + $self->SUPER::install($archive, $destdir, $verbose, $not); + return if $not; + my $fullname = $destdir.$self->fullname(); + system("install-info", "--info-dir=".dirname($fullname), $fullname); +} + package OpenBSD::PackingElement::Dir; sub install { diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index d9953187b20..6f11cf97b53 100644 --- a/usr.sbin/pkg_add/pkg_create +++ b/usr.sbin/pkg_add/pkg_create @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_create,v 1.12 2004/07/13 00:35:38 espie Exp $ +# $OpenBSD: pkg_create,v 1.13 2004/07/20 18:58:41 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -65,24 +65,18 @@ sub archive_cmd return (); } -package OpenBSD::PackingList; -use OpenBSD::md5; +package OpenBSD::PackingElement; -sub archive_cmd +sub compute_checksum { - my ($self, $dir, $base) = @_; - my $fh; - my @use_cwd = (); - my @cmd = (); - for my $item (@{$self->{items}}) { - push(@cmd, $item->archive_cmd(\$fh, \@use_cwd, $dir, $base)); - } - return @cmd; } +package OpenBSD::PackingElement::File; +use OpenBSD::md5; + sub compute_checksum { - my ($self, $base, $stash) = @_; + my ($self, $plist, $base, $stash) = @_; my $fname = $self->fullname(); if (-l "$base/$fname") { my $value = readlink "$base/$fname"; @@ -107,14 +101,45 @@ sub compute_checksum } } +package OpenBSD::PackingElement::InfoFile; +sub compute_checksum +{ + my ($self, $plist, $base, $stash) = @_; + $self->SUPER::compute_checksum($plist, $base, $stash); + my $fname = $self->fullname(); + for (my $i = 1; ; $i++) { + if (-e "$base/$fname-$i") { + my $file = OpenBSD::PackingElement::File->add($plist, $self->{name}."-".$i); + $file->compute_checksum($plist, $base, $stash); + } else { + last; + } + } +} + +package OpenBSD::PackingList; + +sub archive_cmd +{ + my ($self, $dir, $base) = @_; + my $fh; + my @use_cwd = (); + my @cmd = (); + for my $item (@{$self->{items}}) { + push(@cmd, $item->archive_cmd(\$fh, \@use_cwd, $dir, $base)); + } + return @cmd; +} + sub makesum { my ($self, $base) = @_; my $stash = {}; - for my $item (@{$self->{items}}) { - if ($item->IsFile()) { - compute_checksum($item, $base, $stash); - } + my $oldlist = $self->{items}; + $self->{items} = []; + for my $item (@$oldlist) { + push @{$self->{items}}, $item; + $item->compute_checksum($self, $base, $stash); } } @@ -123,7 +148,7 @@ sub avert_duplicates my ($self) = @_; my $allfiles = {}; for my $item (@{$self->{items}}) { - if ($item->IsFile() || $item->isa("OpenBSD::PackingElement::DirRm")) { + if ($item->NoDuplicateNames()) { my $n = $item->fullname(); if (defined $allfiles->{$n}) { print STDERR "Error in packing-list: duplicate file $n\n"; diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index 9ac3c9c4a75..e1d42b11723 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.26 2004/07/18 12:00:21 espie Exp $ +# $OpenBSD: pkg_delete,v 1.27 2004/07/20 18:58:41 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -65,7 +65,7 @@ sub remove_dirs next if defined $remaining->{$d}; my $realname = $state->{destdir}.$d; if (!rmdir $realname) { - print "Error deleting directory $realname\n"; + print "Error deleting directory $realname: $!\n"; } } } @@ -174,6 +174,18 @@ sub delete } } +package OpenBSD::PackingElement::InfoFile; +use File::Basename; +sub delete +{ + my ($self, $state) = @_; + unless ($state->{not}) { + my $fullname = $state->{destdir}.$self->fullname(); + system("install-info", "--delete", "--info-dir=".dirname($fullname), $fullname); + } + $self->SUPER::delete($state); +} + package OpenBSD::PackingElement::Extra; sub delete { |