Page MenuHomeFreeBSD

xinstall: add -P/-F to create parent directories.
Needs ReviewPublic

Authored by will on Feb 3 2018, 1:32 AM.



This takes the form of two separate arguments, which differ in usage,
but have the same effect.

-P: Similar to GNU install -D, except the last argument is treated as a
full directory path, and is created (including any parent directories)
if it does not already exist. This is most similar to cp a b c dir
usage, which is different than GNU install -D's usage.

-F: Same as -P, but only takes two arguments, both of which are files.
In effect, it performs mkdir -p $(dirname arg2); cp $arg1 $arg2.
This is required in addition to -P, because install(1) is unable
to disambiguate between these usages:

install ... -P file1 file2
install ... -P file1 ... fileN directory

...where, in the second case, only one file is specified. In FreeBSD's
source build system, both of these use cases are used in many areas.
xinstall itself uses the first use case, to rename itself as install.

Include man page and test updates to validate these changes.

This change allows tracking, in the metalog, on a per package basis, which
directories are required for which package. It also removes the need to
run mtree in a target DESTDIR to install just one directory.

Test Plan

Run ATF tests.
Build using the etc branch at

Diff Detail

Lint OK
No Unit Test Coverage
Build Status
Buildable 14752
Build 14873: arc lint + arc unit

Event Timeline

will created this revision.Feb 3 2018, 1:32 AM
imp added a subscriber: imp.Feb 15 2018, 12:26 AM
imp added inline comments.

strlcpy here is safer, shorter and less cumbersome.