Subject: pkg/35340: pkgsrc OWN_DIRS bug where empty directories are pruned too earnestly
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <truist-netbsd-sendpr@truist.com>
List: pkgsrc-bugs
Date: 12/30/2006 04:35:00
>Number:         35340
>Category:       pkg
>Synopsis:       pkgsrc OWN_DIRS bug where empty directories are pruned too earnestly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 30 04:35:00 +0000 2006
>Originator:     Nathan Arthur
>Release:        3.0_STABLE on i386
>Organization:
truist.com
>Environment:
NetBSD home.truist.com 3.0_STABLE NetBSD 3.0_STABLE (TRUIST) #1: Fri Aug 18 08:01:55 EDT 2006  root@home.truist.com:/usr/obj/sys/arch/i386/compile/TRUIST i386

>Description:
I use pkgsrc's bulk build scripts to do bulk rebuilds of all the packages I use on my NetBSD 3.0 machine.  I don't build all packages - just the subset that I need.  I do the builds in a chroot sandbox (via mk/bulk/mksandbox) and I've discovered a problem where the build of the qmail-qfilter package is deleting the sandbox's /var/tmp directory (which then causes later package builds the fail).  Per the email thread below, it seems to be deleted during pkg_delete because of something to do with OWN_DIRS_PERMS.  I've dug as far as I can into the scripts to try to understand what's going wrong, and I don't know enough to go further.  Amitai (below) asked that I send-pr.

This only seems to happen if /var/tmp is empty at the time that qmail-qfilter is pkg_delete'd, which explains why this doesn't show up for regular package builds.   It also doesn't seem to be affecting the regular netbsd bulk rebuilds, presumably because there is something in /var/tmp at the time that this happens.

I can happily give more detail about the process here, but I think all the salient details are above and below.  For now, I've worked around this by just putting a file in /var/tmp, but it seems like an issue that should probably be fixed.

-------- Original Message --------
Subject:     Re: You broke my bulk build!
Date:     Sun, 22 Oct 2006 19:29:40 -0400 (EDT)
From:     Amitai Schlair <schmonz@schmonz.com>
To:     Nathan Arthur <truist@truist.com>
References:     <453BED63.4090205@truist.com>


Nathan Arthur wrote:

> 1) Create the sandbox (which creates an appropriate /var/tmp)
> 2) chroot into it
> 3) Manually build qmail-qfilter, into a package
> 4) Install the qmail-qfilter package
> 5) At this point, /var/tmp is still there, and has an empty qmail-qfilter directory in it.
> 6) pkg_delete qmail-qfilter
> 7) /var/tmp is gone!

Wacky. At a glance, that shouldn't happen. The relevant line of
pkgsrc/mail/qmail-qfilter/Makefile is:

   OWN_DIRS_PERMS+=    ${QMAIL_QFILTER_TMPDIR} qmaild ${ROOT_GROUP} 700

And the relevant lines in pkgsrc/mk/defaults/mk.conf are:

   QMAIL_QFILTER_TMPDIR?= ${VARBASE}/tmp/qmail-qfilter
   # The temporary directory for qmail-qfilter.
   # Possible: a directory writable only by qmail-qfilter's UID
   # Default: ${VARBASE}/tmp/qmail-qfilter

OWN_DIRS is handled somewhere in pkgsrc/mk/install or pkgsrc/mk/pkginstall (I forget which), which are standard shell scripts that get executed by pkg_add and pkg_delete. What's supposed to happen is, package defines OWN_DIRS, it gets created at install time, if it's empty at deinstall time it's removed (there's a related variable that instead instructs the user to remove it). So it sounds like this logic is pruning empty directories a little too earnestly up the filesystem.

>How-To-Repeat:
1) Create the sandbox (which creates an appropriate /var/tmp)
2) chroot into it
3) Manually build qmail-qfilter, into a package
4) Install the qmail-qfilter package
5) At this point, /var/tmp is still there, and has an empty qmail-qfilter directory in it.
6) pkg_delete qmail-qfilter
7) /var/tmp is gone!

>Fix:
Unknown