Skip to content

METALOG generation skips intermediate directory entries when directories contain files #2672

@jlduran

Description

@jlduran

Let's say I have the following file structure:

rootdir
└── foo
    ├── bar
    │   ├── baz
    │   │   └── qux.sh
    │   └── baz.sh
    └── bar.sh

And I want to make it a package:

pkg create -r rootdir -o packages/foo-bar-baz -p foo-bar-baz.plist -M foo-bar-baz.ucl

Where foo-bar-baz.plist:

@(root,wheel,0755,uarch) /foo/bar.sh
@(root,wheel,0755,uarch) /foo/bar/baz.sh
@(root,wheel,0755,uarch) /foo/bar/baz/qux.sh

And foo-bar-baz.ucl:

www = "https://www.FreeBSD.org";
desc = <<EOD
foo-bar-baz ucl file
EOD;
name = "foo-bar-baz";
origin = "base/foo-bar-baz";
prefix = "/";
comment = "foo, bar, baz";
version = "16.000";
licenses [
	"BSD2CLAUSE",
]
categories [
	"base",
]
maintainer = "foo@FreeBSD.org";

If we install the package with the option to write to a metalog (mtree) file:

pkg -o METALOG=/tmp/metalog add packages/foo-bar-baz/foo-bar-baz-16.000.pkg

And examine the metalog file:

./foo type=dir uname=root gname=wheel mode=755
./foo/bar.sh type=file uname=root gname=wheel mode=755
./foo/bar/baz.sh type=file uname=root gname=wheel mode=755
./foo/bar/baz/qux.sh type=file uname=root gname=wheel mode=755

Notice that neither the bar nor the baz directories have entries in the metalog.
Now, if we remove the bar.sh file from the plist, for example:

./foo/bar type=dir uname=root gname=wheel mode=755
./foo type=dir uname=root gname=wheel mode=755
./foo/bar/baz.sh type=file uname=root gname=wheel mode=755
./foo/bar/baz/qux.sh type=file uname=root gname=wheel mode=755

It generates the bar directory entry, although the order of the directories is inverted (it would be an invalid mtree specification).
Finally, if we remove the baz.sh file:

./foo/bar/baz type=dir uname=root gname=wheel mode=755
./foo/bar type=dir uname=root gname=wheel mode=755
./foo type=dir uname=root gname=wheel mode=755
./foo/bar/baz/qux.sh type=file uname=root gname=wheel mode=755

Which, if sorted, could be a valid mtree specification. For a real-life example, try the latest FreeBSD-clang-dev package.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions