Bug 184170 - [bsd.destdir.mk] fix ports DESTDIR support with FreeBSD 10 make
Summary: [bsd.destdir.mk] fix ports DESTDIR support with FreeBSD 10 make
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
Depends on:
Reported: 2013-11-22 13:00 UTC by kamikaze
Modified: 2016-04-13 04:32 UTC (History)
1 user (show)

See Also:

file.diff (548 bytes, patch)
2013-11-22 13:00 UTC, kamikaze
no flags Details | Diff
patch-ports-Mk-bsd.destdir.mk.txt (843 bytes, patch)
2013-11-25 09:58 UTC, kamikaze
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kamikaze 2013-11-22 13:00:00 UTC
# make DESTDIR=/root/tmpdest install
===>  Creating some important subdirectories
realpath: /root/tmpdest/___temp___: No such file or directory

*** Error code 1
make: stopped in /usr/ports/ports-mgmt/pkg

The cause for this problem is that bsd.destdir.mk gets a list of mount directories, containing of triplets:
<path variable>:<path>:<mountdir in the chroot>

The list is usually just PORTSDIR and DISTDIR, which is then automatically
completed to a triplet. If the triplet is not predefined ___temp___ is used
as the mount dir, which is handled later in the code to call "mktemp -d"
(line 147).

However before it is handled, the path is accessed by realpath (line 143),
which causes make to fail, because the new BSD make in FreeBSD 10 invokes
/bin/sh with the -e argument by default (see the .SHELL target in the manual

The attached patch prevents shell failure by silencing the error and appending
||: to the realpath call (in case of failure call :, which simply returns 0).

This allows proper handling of the ___temp___ case later in the code.

Fix: Patch attached with submission follows:
How-To-Repeat: Create a FreeBSD environment:
# cd /usr/src
# make installworld distdribution DESTDIR=/root/tmpdest
# chroot /root/tmpdest
# /etc/rc.d/ldconfig start
# exit

Afterwards try installing something from ports.
# cd /usr/ports/ports-mgmt/pkg
# make DESTDIR=/root/tmpdest install
Comment 1 Antoine Brodin freebsd_committer 2013-11-23 19:12:59 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

Over to maintainer
Comment 2 kamikaze 2013-11-25 09:58:50 UTC
I found that using DESTDIR litters my ports tree with work directories,
because WRKDIRPREFIX is not used within the chroot.

So I added a fix for that.

A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? 
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2014-06-02 01:58:44 UTC
Infrastructure PR.
Comment 4 Steve Wills freebsd_committer 2016-04-13 04:32:36 UTC
The issue was fixed in r367700 and I wasn't able to reproduce the leftover work directory issue mentioned, so closing. Re-open if there is still an issue.