History log of /openbsd-current/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.111 13-Jun-2023 espie

move to use v5.36;
tested by me over the last few weeks, and tb@
also fixed a "manual install" bug properly reported by tb@

aside that there should be *no functional change*.
If you see any message like "hey, the number of params is wrong"
it is a fringe case I didn't run into and should be easy to fix.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.110 29-May-2017 espie

Refactor locator code so it's a proper object.
allow fw_update to short-circuit entirely, thus the specific
treatment of paths is actually less of a special case,
and the code that reaches into /etc/installurl is no longer used
at all in that case.

problem noticed by mlarkin@


# 1.109 18-May-2017 espie

introduce new url "installpath" to mean "the contents of installurl"
use it to simplify logic.

have ./ always be silent, wherever it may come from.

zap NOINSTALLPATH since it's more intuitive to just define PKG_PATH=
(nothing) now.


Revision tags: OPENBSD_6_1_BASE
# 1.108 09-Mar-2017 espie

tweak installurl code to return a single string that gets parsed
so that we don't have to write the same thing twice later.


# 1.107 01-Mar-2017 espie

scrape most of the config framework
okay aja@, rpe@


# 1.106 03-Oct-2016 espie

add TRUSTED_PKG_PATH after discussing with aja@
use case is testing binary packages among developers, -Dunsigned means
everything is unsigned, which is bad for dependencies


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.105 30-Jan-2016 espie

redo sthen's idea deeper in pkg_add, so that *every* url can be abbreviated
the same way (e.g., PKG_PATH=ftp.openbsd.org will work)

okay sthen@


# 1.104 27-Jan-2016 sthen

Allow pkg.conf's installpath to be set to a bare hostname (no /), which
implies http://hostname/pub/OpenBSD/[snapshots-or-version]/packages/[arch].
This could be handled at a different location in the code to support PKG_PATH
but this approach is pretty simple and I have something else to make use of it.
ok espie@ for now.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.103 18-Mar-2014 espie

remove $_ usage that warns under perl 5.18


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.102 29-May-2013 espie

I had misgivings about that one, I was right. Missed an obvious testcases,
and my crash bunnies ARE a bunch of unreliable nitwits.

thanks kili@


# 1.101 29-May-2013 espie

allow installpath to use +=, requested by quite a few people,
but did require testing.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.100 13-Jul-2012 espie

temporary option until I come up with a nicer way: if -DNOINSTALLPATH
don't even look in pkg.conf for the installpath.


Revision tags: OPENBSD_5_1_BASE
# 1.99 26-Aug-2011 espie

zap fatpackages. nobody actually uses them.
accordingly, locations do not need to track architecture.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.98 24-Dec-2010 espie

handle failures from ports tree with more care.
this does avoid infinite loops in case of wrong plists.
necessary since print-plist-with-depends CAN fail...


# 1.97 27-Oct-2010 espie

initial scaffolding for @rcscript: for now, acts like normal files,
but allow absolute pathnames (treat that as an implicit @cwd).


Revision tags: OPENBSD_4_8_BASE
# 1.96 07-Aug-2010 espie

nasty inversion of parameters, so that state did not get propagated correctly.
ended up calling './'->errsay in ArcCheck, which of course doesn't work, so
a die() in the middle of a package install... compounded with file !existing,
so that adjust checksum would fail, and so not even a partial install...


# 1.95 02-Jul-2010 espie

parse pkg.conf and use it for default_path if PKG_PATH is not defined.


# 1.94 02-Jul-2010 espie

fix params so that state is state and not PackageLocator...


# 1.93 02-Jul-2010 espie

pass (and save) state around in Repository-related stuff.


# 1.92 30-Jun-2010 espie

allow say and errsay to work without parameters, as it's ways common.
create verbose_system up in state, because it makes sense without verbose.


# 1.91 30-Jun-2010 espie

whitespace cleanup


# 1.90 30-Jun-2010 espie

extra parameter to UpdateSet: use the factory to create extra object.
don't create updatesets directly, go through AddDelete::State.
Get all Locator/Repo access through state.


# 1.89 25-Jun-2010 espie

allow creation of a unique PackageLocator object, that stores state,
and thus can eventually be used to create repositories, print messages,
etc.


# 1.88 10-May-2010 espie

whitespace fixes


Revision tags: OPENBSD_4_7_BASE
# 1.87 10-Jan-2010 espie

bump copyright


# 1.86 09-Jan-2010 espie

zap unused


# 1.85 09-Jan-2010 espie

streamline interface


# 1.84 09-Jan-2010 espie

move signal catching up, so we can clean repos and temp files at once.
Fix main program try/catch: signal message should use standard form so
it gets caught.


# 1.83 09-Jan-2010 espie

kill cache, we don't really need it


# 1.82 09-Jan-2010 espie

fixed version, somehow I forgot that I use parse to do weird things with
PKG_PATH...


# 1.81 09-Jan-2010 espie

temporary revert until I figure this out


# 1.80 09-Jan-2010 espie

move the code that recognizes /var/db/pkg as inst: into Repo::Local


# 1.79 09-Jan-2010 espie

tweak path parsing to handle inst:pkgname and such as well...


# 1.78 09-Jan-2010 espie

move pipe handling into RepositoryList


# 1.77 09-Jan-2010 espie

repositories no longer need match


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.76 20-Oct-2008 espie

Say goodbye to local $_
lexical scoping is so much neater (courtesy of perl 5.10)


Revision tags: OPENBSD_4_4_BASE
# 1.75 18-Jun-2008 espie

better standards for inst: paths.


# 1.74 18-Jun-2008 espie

special-case parser so that /var/db/pkg becomes inst: during path_parse.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.73 04-Jun-2007 espie

I am on drugs, I don't know where I found split can take strings as
arguments. Repair...


# 1.72 04-Jun-2007 espie

some minor systematic changes.
- mark all regexps I can with /o if they can be compiled once.
- turn $o->method() into $o->method
- remove unneeded prototypes
- reduce split /re/ into split "string" where possible.


# 1.71 19-May-2007 espie

add match_locations/filter_locations methods to search stuff that returns
full pkg locations instead of package names.


# 1.70 19-May-2007 espie

don't pass srcpath around, since we don't use it.


# 1.69 14-May-2007 espie

kill "available" routine, which is no longer used.


# 1.68 13-May-2007 espie

remove some specialness of the Filtering stuff.


# 1.67 13-May-2007 espie

kill unused stuff


# 1.66 13-May-2007 espie

also create PartialStem objects, and create a generic
PackageLocator->match($o), where $o can be a spec, a stem, a partialstem.


# 1.65 13-May-2007 espie

have PackageLocator defer to PackageRepositoryList, so that package
availability uses normal linker rules.


# 1.64 13-May-2007 espie

allow filtering while calling the Locator.


# 1.63 12-May-2007 espie

kill old PkgSpec interface


# 1.62 12-May-2007 espie

use match_ref consistently


# 1.61 12-May-2007 espie

also allow Spec objects in Repository matches.


# 1.60 08-May-2007 espie

spec match works better with a list


# 1.59 07-May-2007 espie

remove dependency on available_stems(), make it go thru PackageLocator


# 1.58 07-May-2007 espie

we want to no longer expose PackageLocator::available(), lift interfaces
up there, starting with match_spec.


# 1.57 02-May-2007 espie

$o->method() becomes $o->method


# 1.56 29-Apr-2007 espie

replace $p->visit('method') calls with $p->method
now that it works.


# 1.55 15-Apr-2007 espie

update copyright years, standardize licence.
reword the introduction to the stuff originally from FreeBSD to clarify
slightly.


Revision tags: OPENBSD_4_1_BASE
# 1.54 06-Mar-2007 espie

get vfs size snapshotted and restored so that pkg_add -u has a harder
time overflowing the disk.

let stem work at the end of urls.

test sturm@ and bernd@,

okay deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.53 08-Mar-2006 espie

propagate stuff to be able to explicitly clean-up repositories.
(we can't use a normal destructor, since this will be called for
each fork()ed subprocess).


# 1.52 04-Mar-2006 espie

cut down the Locator code into maintainable chunks.


# 1.51 04-Mar-2006 espie

zap more success messages. Keep pid of distant location pipe, just in case.


Revision tags: OPENBSD_3_9_BASE
# 1.50 21-Feb-2006 espie

detect temporary connection errors, and retry with exponential timeout.


# 1.49 09-Feb-2006 espie

Add some nice interfaces instead of the hint() argument to close().
This allows the cache to finish properly even in some weird cases like
fat packages (calling finish_and_close).


# 1.48 03-Nov-2005 espie

kludge: avoid creating non-empty files.

I don't like the fix, but it works...


# 1.47 02-Nov-2005 espie

In case we are pretending, make sure we skip to the next archive member.
Otherwise, we might miss a truncated archive that's missing its last file,
and PKG_CACHE won't work, since it hits a SIGPIPE too soon.

Nice testcase from sturm@


# 1.46 25-Oct-2005 espie

zap 229 (frantisek holop)


# 1.45 22-Oct-2005 espie

add a hint to close that says how the fd got closed (real error, premature,
normal).

This will get used by parse_problems() to figure out what to report exactly,
e.g., short writes from prematurely closed fd are not real errors...
stuff that can't connect IPv6 and retries as v4 is not either, unless
there's a genuine `can't connect error'.


# 1.44 22-Oct-2005 espie

more non-errors from ftp.


# 1.43 22-Oct-2005 espie

I haven't received any feedback at all about this patch, so everyone
gets to test it.


# 1.42 10-Oct-2005 espie

Display an error message if no packages are available in the PKG_PATH.
Quote nlist command, if we invoke it accidentally in a directory with *.tgz
present.


# 1.41 24-Sep-2005 espie

Allows FETCH_CMD to replace ftp.
Note that, for simplicity, FETCH_CMD must be a single command with
a full path. Use a script if you must.


# 1.40 19-Sep-2005 espie

fix PackageRepository::Installed().
let grabPlist finish closing what it opened.


# 1.39 19-Sep-2005 espie

make package opening more efficient (and maybe more intuitive) by
delaying reading the full info directory to a temporary directory.

When we open a package, we just scan for the CONTENTS. If it's the
first file, we stash it into memory and STOP there, delaying grabbing
the rest of the special files to the first call to info().

Make sure the next() proxy shows only real file, by grabbing info files
if necessary.

Introduce handle->plist() method that can retrieve the plist from either
the version stored in memory, or in a file in the temp directory.


# 1.38 17-Sep-2005 espie

allows grabbing the packing-list directly from a PackageLocation,
in order to make further code more symetric and efficient.


# 1.37 17-Sep-2005 espie

beginning to a source path repository infrastructure, very likely to change
a lot yet.


# 1.36 17-Sep-2005 espie

minor nit


# 1.35 16-Sep-2005 espie

more clean-up:
- kill multiple inheritance;
- replace pipename() with open_pipe, and use explicit exec.
- add intermediate PackageRepository::Distant class.

- if PKG_CACHE is set, use an intermediate wedge that stores the
retrieved package in that directory.

- handle signals correctly in that case.


# 1.34 16-Sep-2005 espie

oops


# 1.33 16-Sep-2005 espie

move .tgz addition down to PackageRepositoryList.
re-add list, which returns a \@, whereas available returns a @.


# 1.32 14-Sep-2005 espie

filter names out first, as it's slightly faster


# 1.31 13-Sep-2005 espie

more Package/FatPackage common code: separate the proxy 'next' into two
parts: the one that gets (and renames) files from the archive (getNext)
that depends on Package/FatPackage, and the one that handles opening/
reopening/caching archives (true next);


# 1.30 13-Sep-2005 espie

typo, fix fat packages reading.


# 1.29 13-Sep-2005 espie

grabPlist shall behave like find.


# 1.28 13-Sep-2005 espie

Repository::Installed class, to provide uniform access to installed
packages compared to other `repositories'.


# 1.27 13-Sep-2005 espie

yet more uniform names.


# 1.26 13-Sep-2005 espie

don't actively avoid the Composite Pattern.
PackageRepositoryList can handle very close to PackageRepository


# 1.25 13-Sep-2005 espie

new class: PackageRepositoryList, of which pkgpath is one instance.
new method: wipe(), that removes the info directory, redirected to
the PackageRepository object which `knows' how to wipe stuff out.

(this allows us to eliminate special cases for installed/not installed
packages in the near future).


# 1.24 13-Sep-2005 espie

make grabPlist slightly smarter so that we can still open the package
afterwards.


# 1.23 13-Sep-2005 espie

allows grabbing a packing-list directly, without needing to go through
a temporary file, by using perl's new-fangled
open my $fh, '<', \$scalar


# 1.22 13-Sep-2005 espie

some long-delayed clean-up of this code.
- rename PackageLocation to PackageRepository.
- new class `PackageLocation' which symbolizes an actually opened package.
- rename quite a few things and reorg stuff to make lots more sense.
- put fat packages into a derived FatPackageLocation class.
- fix a bug that made sure fat packages could not be opened on stdin.

ways cleaner and easier to extend...


# 1.21 04-Sep-2005 espie

* New -i interactive option, that can ask obnoxious questions.
* move the signature code to a packing-list method, prepend the pkgname.
* depend on distant listings, cache these systematically.
* cut the PKG_PATH at :/ systematically, much simpler than parsing URLs.
People should get used to trailing /s.
* let pkg_add -u actually run the update.
* check for signature in more places, for instance, let pkg_add installed_stuff
be a void operation.
* grab enough stuff during updates to check signatures, so that pkg_add -u
can report updates that are not needed right away, instead of waiting
for the more confusing `trying to update'
* beginning of @module support.
* @pkgpath support, including updates.
* systematically expand stems when applicable.
* use visitors systematically in pkg_info.
* pkg_info -S reports signature.
* remove hardcoding of categories in PackingList, so that future modules
will be able to expand them.
* add @updateset and @incompatibility keywords.


Revision tags: OPENBSD_3_8_BASE
# 1.20 22-Aug-2005 espie

while scanning a potential package, process issues anyways:
if create() fails, we want to remove any stub file (and report the
problem), so that tools won't get confused in believing the packing-list
got created correctly.


# 1.19 19-Aug-2005 espie

remove tempdir right away if it turns out we're not dealing with a
package at all.


# 1.18 16-Aug-2005 espie

don't mix nlist with ls


# 1.17 16-Aug-2005 espie

support code for pkg_add -u:
- distant_available(), using the distant listing functions.
- stem compiler, to match lots of stems


# 1.16 16-Aug-2005 espie

make the code that enforces the connection limit a separate function, so
that the distant listing code can use it too. Since the distant listing code
creates transient connections, it does not actually need to be tracked,
just to ensure that it has a slot !


# 1.15 16-Aug-2005 espie

fix a few minor details: _list() needs to be called as a method.
use nlist *.tgz instead of ls to gain speed. http does not need
any command, it just retrieves the directory index.

(code not used yet, but so blatantly incorrect)


# 1.14 26-Jun-2005 espie

Handle hard links correctly: the names need to be aliased correctly for
pkg_merging, and the names need to lose the prefix path when getting
extracted.


# 1.13 26-Jun-2005 espie

select fat package based on name too.


# 1.12 26-Jun-2005 espie

handle fat packages based on architecture.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.11 06-Aug-2004 espie

block-scoped require is way simpler than weird AUTOLOAD hack.


# 1.10 06-Aug-2004 espie

unified headers, switch to smaller copyright notice.


Revision tags: OPENBSD_3_5_BASE
# 1.9 11-Mar-2004 espie

repair pkg_add -, by making sure `-' is a special object.


# 1.8 07-Mar-2004 espie

A few useful features:
- pkg_add -A arch, to make believe we are extracting on a given arch
(matches pkg_create).
- pkg_add -P cdrom/-P ftp, to enforce extracting only cdrom'able packages
or ftp'able packages. Helps a lot for checking cdrom lists.
- dependency look-up will look through local directory listings to solve
dependencies, so that non-default dependencies will work more seemlessly.
(doing the same thing for distant repository will happen after 3.5, but
this requires more apparatus: caching package lists, and killing/restoring
existing connections, plus more error handling).

okay pval


# 1.7 28-Jan-2004 espie

some code refactoring.
minor optimization: don't try to open pipe to local file that doesn't
exist anyways.

track connections per-host for ftp/http.
Don't allow more than maxcount() connections per-host (for now, one
connection).

tests by sturm@, fries@


# 1.6 19-Dec-2003 espie

Clean up PackageLocator so it looks somewhat more object-oriented.
Most importantly, put all the state information into the created object,
so that the actual archive can be closed, later reopened, and scanned
until the correct file is found.

This will be used to allow retrieving packages through ftp without keeping
loads of connections opened because of dependency resolving.

Approved by fries and naddy.


# 1.5 06-Nov-2003 espie

Handle pkg_add -
let pkg_add postpone conflict handling until it has the real name of
the package if necessary, and let PackageLocator deal correctly with a '-'
filename.


# 1.4 31-Oct-2003 espie

put pkgpath back in correct order.
automatically append package location specified on the command
line to pkgpath (reported by numerous people).

okay sturm@


# 1.3 23-Oct-2003 espie

Allows close() on already closed locator.
Fix second problem seen by krw@


# 1.2 19-Oct-2003 espie

pkgpath is . by default.


# 1.1 16-Oct-2003 espie

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.110 29-May-2017 espie

Refactor locator code so it's a proper object.
allow fw_update to short-circuit entirely, thus the specific
treatment of paths is actually less of a special case,
and the code that reaches into /etc/installurl is no longer used
at all in that case.

problem noticed by mlarkin@


# 1.109 18-May-2017 espie

introduce new url "installpath" to mean "the contents of installurl"
use it to simplify logic.

have ./ always be silent, wherever it may come from.

zap NOINSTALLPATH since it's more intuitive to just define PKG_PATH=
(nothing) now.


Revision tags: OPENBSD_6_1_BASE
# 1.108 09-Mar-2017 espie

tweak installurl code to return a single string that gets parsed
so that we don't have to write the same thing twice later.


# 1.107 01-Mar-2017 espie

scrape most of the config framework
okay aja@, rpe@


# 1.106 03-Oct-2016 espie

add TRUSTED_PKG_PATH after discussing with aja@
use case is testing binary packages among developers, -Dunsigned means
everything is unsigned, which is bad for dependencies


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.105 30-Jan-2016 espie

redo sthen's idea deeper in pkg_add, so that *every* url can be abbreviated
the same way (e.g., PKG_PATH=ftp.openbsd.org will work)

okay sthen@


# 1.104 27-Jan-2016 sthen

Allow pkg.conf's installpath to be set to a bare hostname (no /), which
implies http://hostname/pub/OpenBSD/[snapshots-or-version]/packages/[arch].
This could be handled at a different location in the code to support PKG_PATH
but this approach is pretty simple and I have something else to make use of it.
ok espie@ for now.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.103 18-Mar-2014 espie

remove $_ usage that warns under perl 5.18


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.102 29-May-2013 espie

I had misgivings about that one, I was right. Missed an obvious testcases,
and my crash bunnies ARE a bunch of unreliable nitwits.

thanks kili@


# 1.101 29-May-2013 espie

allow installpath to use +=, requested by quite a few people,
but did require testing.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.100 13-Jul-2012 espie

temporary option until I come up with a nicer way: if -DNOINSTALLPATH
don't even look in pkg.conf for the installpath.


Revision tags: OPENBSD_5_1_BASE
# 1.99 26-Aug-2011 espie

zap fatpackages. nobody actually uses them.
accordingly, locations do not need to track architecture.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.98 24-Dec-2010 espie

handle failures from ports tree with more care.
this does avoid infinite loops in case of wrong plists.
necessary since print-plist-with-depends CAN fail...


# 1.97 27-Oct-2010 espie

initial scaffolding for @rcscript: for now, acts like normal files,
but allow absolute pathnames (treat that as an implicit @cwd).


Revision tags: OPENBSD_4_8_BASE
# 1.96 07-Aug-2010 espie

nasty inversion of parameters, so that state did not get propagated correctly.
ended up calling './'->errsay in ArcCheck, which of course doesn't work, so
a die() in the middle of a package install... compounded with file !existing,
so that adjust checksum would fail, and so not even a partial install...


# 1.95 02-Jul-2010 espie

parse pkg.conf and use it for default_path if PKG_PATH is not defined.


# 1.94 02-Jul-2010 espie

fix params so that state is state and not PackageLocator...


# 1.93 02-Jul-2010 espie

pass (and save) state around in Repository-related stuff.


# 1.92 30-Jun-2010 espie

allow say and errsay to work without parameters, as it's ways common.
create verbose_system up in state, because it makes sense without verbose.


# 1.91 30-Jun-2010 espie

whitespace cleanup


# 1.90 30-Jun-2010 espie

extra parameter to UpdateSet: use the factory to create extra object.
don't create updatesets directly, go through AddDelete::State.
Get all Locator/Repo access through state.


# 1.89 25-Jun-2010 espie

allow creation of a unique PackageLocator object, that stores state,
and thus can eventually be used to create repositories, print messages,
etc.


# 1.88 10-May-2010 espie

whitespace fixes


Revision tags: OPENBSD_4_7_BASE
# 1.87 10-Jan-2010 espie

bump copyright


# 1.86 09-Jan-2010 espie

zap unused


# 1.85 09-Jan-2010 espie

streamline interface


# 1.84 09-Jan-2010 espie

move signal catching up, so we can clean repos and temp files at once.
Fix main program try/catch: signal message should use standard form so
it gets caught.


# 1.83 09-Jan-2010 espie

kill cache, we don't really need it


# 1.82 09-Jan-2010 espie

fixed version, somehow I forgot that I use parse to do weird things with
PKG_PATH...


# 1.81 09-Jan-2010 espie

temporary revert until I figure this out


# 1.80 09-Jan-2010 espie

move the code that recognizes /var/db/pkg as inst: into Repo::Local


# 1.79 09-Jan-2010 espie

tweak path parsing to handle inst:pkgname and such as well...


# 1.78 09-Jan-2010 espie

move pipe handling into RepositoryList


# 1.77 09-Jan-2010 espie

repositories no longer need match


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.76 20-Oct-2008 espie

Say goodbye to local $_
lexical scoping is so much neater (courtesy of perl 5.10)


Revision tags: OPENBSD_4_4_BASE
# 1.75 18-Jun-2008 espie

better standards for inst: paths.


# 1.74 18-Jun-2008 espie

special-case parser so that /var/db/pkg becomes inst: during path_parse.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.73 04-Jun-2007 espie

I am on drugs, I don't know where I found split can take strings as
arguments. Repair...


# 1.72 04-Jun-2007 espie

some minor systematic changes.
- mark all regexps I can with /o if they can be compiled once.
- turn $o->method() into $o->method
- remove unneeded prototypes
- reduce split /re/ into split "string" where possible.


# 1.71 19-May-2007 espie

add match_locations/filter_locations methods to search stuff that returns
full pkg locations instead of package names.


# 1.70 19-May-2007 espie

don't pass srcpath around, since we don't use it.


# 1.69 14-May-2007 espie

kill "available" routine, which is no longer used.


# 1.68 13-May-2007 espie

remove some specialness of the Filtering stuff.


# 1.67 13-May-2007 espie

kill unused stuff


# 1.66 13-May-2007 espie

also create PartialStem objects, and create a generic
PackageLocator->match($o), where $o can be a spec, a stem, a partialstem.


# 1.65 13-May-2007 espie

have PackageLocator defer to PackageRepositoryList, so that package
availability uses normal linker rules.


# 1.64 13-May-2007 espie

allow filtering while calling the Locator.


# 1.63 12-May-2007 espie

kill old PkgSpec interface


# 1.62 12-May-2007 espie

use match_ref consistently


# 1.61 12-May-2007 espie

also allow Spec objects in Repository matches.


# 1.60 08-May-2007 espie

spec match works better with a list


# 1.59 07-May-2007 espie

remove dependency on available_stems(), make it go thru PackageLocator


# 1.58 07-May-2007 espie

we want to no longer expose PackageLocator::available(), lift interfaces
up there, starting with match_spec.


# 1.57 02-May-2007 espie

$o->method() becomes $o->method


# 1.56 29-Apr-2007 espie

replace $p->visit('method') calls with $p->method
now that it works.


# 1.55 15-Apr-2007 espie

update copyright years, standardize licence.
reword the introduction to the stuff originally from FreeBSD to clarify
slightly.


Revision tags: OPENBSD_4_1_BASE
# 1.54 06-Mar-2007 espie

get vfs size snapshotted and restored so that pkg_add -u has a harder
time overflowing the disk.

let stem work at the end of urls.

test sturm@ and bernd@,

okay deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.53 08-Mar-2006 espie

propagate stuff to be able to explicitly clean-up repositories.
(we can't use a normal destructor, since this will be called for
each fork()ed subprocess).


# 1.52 04-Mar-2006 espie

cut down the Locator code into maintainable chunks.


# 1.51 04-Mar-2006 espie

zap more success messages. Keep pid of distant location pipe, just in case.


Revision tags: OPENBSD_3_9_BASE
# 1.50 21-Feb-2006 espie

detect temporary connection errors, and retry with exponential timeout.


# 1.49 09-Feb-2006 espie

Add some nice interfaces instead of the hint() argument to close().
This allows the cache to finish properly even in some weird cases like
fat packages (calling finish_and_close).


# 1.48 03-Nov-2005 espie

kludge: avoid creating non-empty files.

I don't like the fix, but it works...


# 1.47 02-Nov-2005 espie

In case we are pretending, make sure we skip to the next archive member.
Otherwise, we might miss a truncated archive that's missing its last file,
and PKG_CACHE won't work, since it hits a SIGPIPE too soon.

Nice testcase from sturm@


# 1.46 25-Oct-2005 espie

zap 229 (frantisek holop)


# 1.45 22-Oct-2005 espie

add a hint to close that says how the fd got closed (real error, premature,
normal).

This will get used by parse_problems() to figure out what to report exactly,
e.g., short writes from prematurely closed fd are not real errors...
stuff that can't connect IPv6 and retries as v4 is not either, unless
there's a genuine `can't connect error'.


# 1.44 22-Oct-2005 espie

more non-errors from ftp.


# 1.43 22-Oct-2005 espie

I haven't received any feedback at all about this patch, so everyone
gets to test it.


# 1.42 10-Oct-2005 espie

Display an error message if no packages are available in the PKG_PATH.
Quote nlist command, if we invoke it accidentally in a directory with *.tgz
present.


# 1.41 24-Sep-2005 espie

Allows FETCH_CMD to replace ftp.
Note that, for simplicity, FETCH_CMD must be a single command with
a full path. Use a script if you must.


# 1.40 19-Sep-2005 espie

fix PackageRepository::Installed().
let grabPlist finish closing what it opened.


# 1.39 19-Sep-2005 espie

make package opening more efficient (and maybe more intuitive) by
delaying reading the full info directory to a temporary directory.

When we open a package, we just scan for the CONTENTS. If it's the
first file, we stash it into memory and STOP there, delaying grabbing
the rest of the special files to the first call to info().

Make sure the next() proxy shows only real file, by grabbing info files
if necessary.

Introduce handle->plist() method that can retrieve the plist from either
the version stored in memory, or in a file in the temp directory.


# 1.38 17-Sep-2005 espie

allows grabbing the packing-list directly from a PackageLocation,
in order to make further code more symetric and efficient.


# 1.37 17-Sep-2005 espie

beginning to a source path repository infrastructure, very likely to change
a lot yet.


# 1.36 17-Sep-2005 espie

minor nit


# 1.35 16-Sep-2005 espie

more clean-up:
- kill multiple inheritance;
- replace pipename() with open_pipe, and use explicit exec.
- add intermediate PackageRepository::Distant class.

- if PKG_CACHE is set, use an intermediate wedge that stores the
retrieved package in that directory.

- handle signals correctly in that case.


# 1.34 16-Sep-2005 espie

oops


# 1.33 16-Sep-2005 espie

move .tgz addition down to PackageRepositoryList.
re-add list, which returns a \@, whereas available returns a @.


# 1.32 14-Sep-2005 espie

filter names out first, as it's slightly faster


# 1.31 13-Sep-2005 espie

more Package/FatPackage common code: separate the proxy 'next' into two
parts: the one that gets (and renames) files from the archive (getNext)
that depends on Package/FatPackage, and the one that handles opening/
reopening/caching archives (true next);


# 1.30 13-Sep-2005 espie

typo, fix fat packages reading.


# 1.29 13-Sep-2005 espie

grabPlist shall behave like find.


# 1.28 13-Sep-2005 espie

Repository::Installed class, to provide uniform access to installed
packages compared to other `repositories'.


# 1.27 13-Sep-2005 espie

yet more uniform names.


# 1.26 13-Sep-2005 espie

don't actively avoid the Composite Pattern.
PackageRepositoryList can handle very close to PackageRepository


# 1.25 13-Sep-2005 espie

new class: PackageRepositoryList, of which pkgpath is one instance.
new method: wipe(), that removes the info directory, redirected to
the PackageRepository object which `knows' how to wipe stuff out.

(this allows us to eliminate special cases for installed/not installed
packages in the near future).


# 1.24 13-Sep-2005 espie

make grabPlist slightly smarter so that we can still open the package
afterwards.


# 1.23 13-Sep-2005 espie

allows grabbing a packing-list directly, without needing to go through
a temporary file, by using perl's new-fangled
open my $fh, '<', \$scalar


# 1.22 13-Sep-2005 espie

some long-delayed clean-up of this code.
- rename PackageLocation to PackageRepository.
- new class `PackageLocation' which symbolizes an actually opened package.
- rename quite a few things and reorg stuff to make lots more sense.
- put fat packages into a derived FatPackageLocation class.
- fix a bug that made sure fat packages could not be opened on stdin.

ways cleaner and easier to extend...


# 1.21 04-Sep-2005 espie

* New -i interactive option, that can ask obnoxious questions.
* move the signature code to a packing-list method, prepend the pkgname.
* depend on distant listings, cache these systematically.
* cut the PKG_PATH at :/ systematically, much simpler than parsing URLs.
People should get used to trailing /s.
* let pkg_add -u actually run the update.
* check for signature in more places, for instance, let pkg_add installed_stuff
be a void operation.
* grab enough stuff during updates to check signatures, so that pkg_add -u
can report updates that are not needed right away, instead of waiting
for the more confusing `trying to update'
* beginning of @module support.
* @pkgpath support, including updates.
* systematically expand stems when applicable.
* use visitors systematically in pkg_info.
* pkg_info -S reports signature.
* remove hardcoding of categories in PackingList, so that future modules
will be able to expand them.
* add @updateset and @incompatibility keywords.


Revision tags: OPENBSD_3_8_BASE
# 1.20 22-Aug-2005 espie

while scanning a potential package, process issues anyways:
if create() fails, we want to remove any stub file (and report the
problem), so that tools won't get confused in believing the packing-list
got created correctly.


# 1.19 19-Aug-2005 espie

remove tempdir right away if it turns out we're not dealing with a
package at all.


# 1.18 16-Aug-2005 espie

don't mix nlist with ls


# 1.17 16-Aug-2005 espie

support code for pkg_add -u:
- distant_available(), using the distant listing functions.
- stem compiler, to match lots of stems


# 1.16 16-Aug-2005 espie

make the code that enforces the connection limit a separate function, so
that the distant listing code can use it too. Since the distant listing code
creates transient connections, it does not actually need to be tracked,
just to ensure that it has a slot !


# 1.15 16-Aug-2005 espie

fix a few minor details: _list() needs to be called as a method.
use nlist *.tgz instead of ls to gain speed. http does not need
any command, it just retrieves the directory index.

(code not used yet, but so blatantly incorrect)


# 1.14 26-Jun-2005 espie

Handle hard links correctly: the names need to be aliased correctly for
pkg_merging, and the names need to lose the prefix path when getting
extracted.


# 1.13 26-Jun-2005 espie

select fat package based on name too.


# 1.12 26-Jun-2005 espie

handle fat packages based on architecture.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.11 06-Aug-2004 espie

block-scoped require is way simpler than weird AUTOLOAD hack.


# 1.10 06-Aug-2004 espie

unified headers, switch to smaller copyright notice.


Revision tags: OPENBSD_3_5_BASE
# 1.9 11-Mar-2004 espie

repair pkg_add -, by making sure `-' is a special object.


# 1.8 07-Mar-2004 espie

A few useful features:
- pkg_add -A arch, to make believe we are extracting on a given arch
(matches pkg_create).
- pkg_add -P cdrom/-P ftp, to enforce extracting only cdrom'able packages
or ftp'able packages. Helps a lot for checking cdrom lists.
- dependency look-up will look through local directory listings to solve
dependencies, so that non-default dependencies will work more seemlessly.
(doing the same thing for distant repository will happen after 3.5, but
this requires more apparatus: caching package lists, and killing/restoring
existing connections, plus more error handling).

okay pval


# 1.7 28-Jan-2004 espie

some code refactoring.
minor optimization: don't try to open pipe to local file that doesn't
exist anyways.

track connections per-host for ftp/http.
Don't allow more than maxcount() connections per-host (for now, one
connection).

tests by sturm@, fries@


# 1.6 19-Dec-2003 espie

Clean up PackageLocator so it looks somewhat more object-oriented.
Most importantly, put all the state information into the created object,
so that the actual archive can be closed, later reopened, and scanned
until the correct file is found.

This will be used to allow retrieving packages through ftp without keeping
loads of connections opened because of dependency resolving.

Approved by fries and naddy.


# 1.5 06-Nov-2003 espie

Handle pkg_add -
let pkg_add postpone conflict handling until it has the real name of
the package if necessary, and let PackageLocator deal correctly with a '-'
filename.


# 1.4 31-Oct-2003 espie

put pkgpath back in correct order.
automatically append package location specified on the command
line to pkgpath (reported by numerous people).

okay sturm@


# 1.3 23-Oct-2003 espie

Allows close() on already closed locator.
Fix second problem seen by krw@


# 1.2 19-Oct-2003 espie

pkgpath is . by default.


# 1.1 16-Oct-2003 espie

branches: 1.1.1;
Initial revision