Subject: Code review wanted: ftp wildcard depends
To: None <tech-pkg@netbsd.org>
From: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
List: tech-pkg
Date: 01/08/2000 03:41:08
The diffs implement the last piece missing from the NetBSD package tools
to fully implement wildcard handling, the proper handling of wildcards via
FTP, esp. WRT to wildcard dependencies.

A few test cases:

 * pkg_add /usr/pkgsrc/packages/All/xsnow-\*
 * pkg_add /usr/pkgsrc/packages/All/xsnow
 * pkg_add ftp://smaug.fh-regensburg.de/pub/NetBSD/packages/i386/All/xsnow-\*
 * pkg_add ftp://smaug.fh-regensburg.de/pub/NetBSD/packages/i386/All/xsnow
 * setenv PKG_PATH ftp://smaug.fh-regensburg.de/pub/NetBSD/packages/i386/All
   pkg_add xsnow

In addition to wildcard handling on the command line (both local and
remote), installation of any depending packages has been changed to expand
any wildcards, where present. Right now, the build system doesn't create
packages that contain wildcard dependencies, you'll have to set
PACKAGE_DEPENDS_WITH_PATTERNS=true in all places in bsd.pkg.mk to build
binary packages with wildcards - this will be done when this code will be
committed.

Some notes on implementation: The ftp handling has been moved (once more -
this is the second time since we took the pkg_* tools from FreeBSD) to a
coprocess doing all FTP. This coprocess saves opening several connections
when installing depending packages of several levels. Wildcard
dependencies via FTP are implemented by recognizing a pkg name that
contains a (package) wildcard, and getting a list of all the versions of
that package available on the FTP server. From that list, the best
matching package is chosen to fulfil the wildcard. Best matching in the
context of expanding a package wildcard (both when choosing from a local
or remote package list) means to use the highest package version that
still matches the wildcard. So e.g. if a wildcard like foo<3.0 is used,
then the biggest package <3.0 will be chosen. This is what we're already
using in the bsd.pkg.mk dependency checking and conflicts system for over
a year now - it's just implemented consistendly now. :)

Right now, there's still quite a number of debug output in there, most of it
turned on with the pkg_add -v flag. This code will be reduced when the code
will be committed, together with the old code that's still left in with #if 0.

The diffs can be found at:
  http://rfhs8012.fh-regensburg.de/~feyrer/Misc/ftp-wildcard-depends.patchV1

Please test and review this code, and let me know of any problems. Thanks!


 - Hubert

-- 
NetBSD - Better for your uptime than Viagra