not sure I'm going to use it yet, but allow an "indexing cache" of
packages built to create a quirks flavor.
This commit is contained in:
parent
fb36b1690b
commit
76662a8b58
|
@ -6,6 +6,8 @@ DISTFILES =
|
|||
PKGNAME = quirks-4.109
|
||||
PKG_ARCH = *
|
||||
MAINTAINER = Marc Espie <espie@openbsd.org>
|
||||
FLAVORS = index
|
||||
FLAVOR ?=
|
||||
|
||||
# BSD
|
||||
PERMIT_PACKAGE = Yes
|
||||
|
@ -14,12 +16,21 @@ PERLDIR = ${PREFIX}/libdata/perl5/site_perl
|
|||
|
||||
NO_TEST = Yes
|
||||
|
||||
LIST = ${WRKDIR}/update.list
|
||||
|
||||
do-build:
|
||||
perl -Mlib=${FILESDIR} ${FILESDIR}/t >${WRKDIR}/result
|
||||
cmp ${WRKDIR}/result ${FILESDIR}/reference
|
||||
.if ${FLAVOR:Mindex}
|
||||
perl ${FILESDIR}/list_update_info -o ${LIST} \
|
||||
${PACKAGE_REPOSITORY}/${MACHINE_ARCH}/all
|
||||
.endif
|
||||
|
||||
do-install:
|
||||
${INSTALL_DATA_DIR} ${PERLDIR}/OpenBSD/Quirks
|
||||
${INSTALL_DATA} ${FILESDIR}/Quirks.pm ${PERLDIR}/OpenBSD/Quirks.pm
|
||||
.if ${FLAVOR:Mindex}
|
||||
/usr/libexec/locate.mklocatedb <${LIST} >${PREFIX}/share/update.db
|
||||
.endif
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
108
devel/quirks/files/list_update_info
Executable file
108
devel/quirks/files/list_update_info
Executable file
|
@ -0,0 +1,108 @@
|
|||
#! /usr/bin/perl
|
||||
# $OpenBSD: list_update_info,v 1.1 2022/03/08 14:11:14 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2022 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use OpenBSD::AddCreateDelete;
|
||||
|
||||
package OpenBSD::PackingElement;
|
||||
|
||||
sub write_for_locate
|
||||
{
|
||||
my ($self, $pkgname, $output) = @_;
|
||||
print {$output} "$pkgname:";
|
||||
$self->write($output);
|
||||
}
|
||||
|
||||
package OpenBSD::PackingElement::SpecialFile;
|
||||
sub write_for_locate
|
||||
{}
|
||||
package Scanner;
|
||||
use OpenBSD::PackageInfo;
|
||||
use OpenBSD::AddCreateDelete;
|
||||
use OpenBSD::PackingList;
|
||||
use OpenBSD::PackageRepository;
|
||||
use File::Path;
|
||||
|
||||
sub handle_file
|
||||
{
|
||||
my ($self, $f) = @_;
|
||||
my $plist = OpenBSD::PackingList->fromfile($f,
|
||||
\&OpenBSD::PackingList::UpdateInfoOnly);
|
||||
$plist->write_for_locate($plist->pkgname, $self->{output});
|
||||
}
|
||||
|
||||
sub handle_options
|
||||
{
|
||||
my $self = shift;
|
||||
$self->ui->handle_options('o:', "[-o outputfile] pkgdir");
|
||||
my $filename = $self->ui->opt('o');
|
||||
if (defined $filename) {
|
||||
open($self->{output}, '>', $self->ui->opt('o')) or die;
|
||||
} else {
|
||||
$self->{output} = \*STDOUT;
|
||||
}
|
||||
}
|
||||
|
||||
sub new
|
||||
{
|
||||
my ($class, $cmd) = @_;
|
||||
my $ui = OpenBSD::AddCreateDelete::State->new($cmd);
|
||||
$ui->{signature_style} = 'unsigned';
|
||||
my $o = bless { ui => $ui }, $class;
|
||||
$o->handle_options;
|
||||
return $o;
|
||||
}
|
||||
|
||||
sub progress
|
||||
{
|
||||
return shift->ui->progress;
|
||||
}
|
||||
|
||||
sub ui
|
||||
{
|
||||
return shift->{ui};
|
||||
}
|
||||
|
||||
sub scan
|
||||
{
|
||||
my ($self, $d) = @_;
|
||||
$self->progress->set_header("Scanning");
|
||||
my $d = '/usr/ports/packages/amd64/all';
|
||||
opendir(my $dir, $d);
|
||||
my @l = readdir $dir;
|
||||
closedir($dir);
|
||||
my $repo = OpenBSD::PackageRepository->new($d, $self->ui);
|
||||
$self->progress->for_list("Scanning", \@l,
|
||||
sub {
|
||||
my $pkgname = shift;
|
||||
return if $pkgname eq '.' or $pkgname eq '..';
|
||||
my $true_package = $repo->find($pkgname);
|
||||
return unless $true_package;
|
||||
my $dir = $true_package->info;
|
||||
$true_package->close;
|
||||
#print $pkgname, "\n";
|
||||
$self->handle_file($dir.CONTENTS);
|
||||
rmtree($dir);
|
||||
});
|
||||
}
|
||||
|
||||
package main;
|
||||
|
||||
my $o = Scanner->new('list-update-info');
|
||||
$o->scan($ARGV[0]);
|
1
devel/quirks/pkg/PFRAG.index
Normal file
1
devel/quirks/pkg/PFRAG.index
Normal file
|
@ -0,0 +1 @@
|
|||
share/update.db
|
|
@ -1,5 +1,5 @@
|
|||
@comment $OpenBSD: PLIST,v 1.5 2021/03/08 11:04:59 pvk Exp $
|
||||
@option always-update
|
||||
libdata/perl5/site_perl/OpenBSD/
|
||||
libdata/perl5/site_perl/OpenBSD/Quirks/
|
||||
libdata/perl5/site_perl/OpenBSD/Quirks.pm
|
||||
%%index%%
|
||||
|
|
Loading…
Reference in New Issue
Block a user