View Single Post
  #9   (View Single Post)  
Old 26th June 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

PKGDIR has different meanings for ports and packages.

From /usr/ports/Mk/bsd.port.mk

Code:
# PKGDIR        - A directory containing any package creation files.
#                 Default: ${MASTERDIR}
[...]
PATCHDIR?=      ${MASTERDIR}/files
FILESDIR?=      ${MASTERDIR}/files
SCRIPTDIR?=     ${MASTERDIR}/scripts
PKGDIR?=        ${MASTERDIR}
[...]
DESCR?=         ${PKGDIR}/pkg-descr
PLIST?=         ${PKGDIR}/pkg-plist
PKGINSTALL?=    ${PKGDIR}/pkg-install
PKGDEINSTALL?=  ${PKGDIR}/pkg-deinstall
PKGREQ?=        ${PKGDIR}/pkg-req
PKGMESSAGE?=    ${PKGDIR}/pkg-message
[...]
Those are ALL the appearances of PKGDIR in bsd.port.mk, so PKGDIR is the port directory (i.e. /usr/ports/www/opera).

If you want to use a different package directory for ports, use PACKAGES.
Code:
# PACKAGES      - A top level directory where all packages go (rather than
#                 going locally to each port).
#                 Default: ${PORTSDIR}/packages
So let's look at pkg_* source:
Code:
[/usr/src/usr.sbin/pkg_install]% find . -type f -exec grep -H PKGDIR {} \;
./add/pkg_add.1:.Ev PKGDIR
./add/pkg_add.1:.Ev PKGDIR
./info/pkg_info.1:.Ev PKGDIR
./info/pkg_info.1:.It Ev PKGDIR
./lib/url.c:    tmp = getenv("PKGDIR");
So, lets look at /usr/src/usr.sbin/pkg_install/lib/url.c (Other 4 files are manpages)
Code:
if (keep_package) {
  tmp = getenv("PKGDIR");
  strlcpy(pkg, tmp ? tmp : ".", sizeof(pkg));
  tmp = basename(fname);
  strlcat(pkg, "/", sizeof(pkg));
  strlcat(pkg, tmp, sizeof(pkg));
  if ((pkgfd = open(pkg, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
      printf("Error: Unable to open %s\n", pkg);
      perror("open");
      return NULL;
  }
    }
So for pkg_* it is indeed the directory/URL to find packages in ... Totally different meaning than for ports.

I know, this is not the best design choice ... And maybe renaming one of the variables might be a good idea...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote