Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Conversation

@bryteise
Copy link
Contributor

No description provided.

Variable doesn't need to be redefined each iteration, declare it
outside the loop.

Signed-off-by: William Douglas <[email protected]>
@bryteise bryteise requested review from bwarden and fenrus75 April 30, 2025 23:27
fullPath := filepath.Join(chrootDir, f)
if fi, err := os.Lstat(fullPath); err == nil {
if !fi.IsDir() {
usedDirs[filepath.Dir(f)] = struct{}{}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any special handling for a file f in the root dir, e.g. /foo? I assume Dir would return ./ in that case, but the only non-dirs in root should be the symlinks lib, lib64, bin, and sbin, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filepath.Dir("/file") will return "/" which is correct in my mind though won't come up as mixer doesn't put / in the manifests so it wouldn't be checked for removal.

}
for _, f := range bundleDirs {
isIncluded := false
for _, inc := range includes {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to fudge includes so os-core is always the first element?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Manifest files I believe os-core is already the first element but mixer shouldn't be impacted by include order. The subtraction should happen regardless if something is in os-core no matter if os-core is looked at first or last from that logic.

@bryteise bryteise force-pushed the improve-dir-subtraction branch from bb3b934 to 0f60955 Compare May 1, 2025 17:48
Instead of giving up on directory subtraction entirely, try to
subtract directories that are in an included manifest *and* do not
have a non-directory file somewhere in their path.

For example:

bundle1:
/dir/file

bundle2: includes bundle1
/dir

In this case /dir would be subtracted from bundle2.

Also add a special case for subtracting directories if they are in
os-core as this reduces a lot of unused content from a bundle's
manifest.

Signed-off-by: William Douglas <[email protected]>
@bryteise bryteise merged commit 3b5d8e0 into master May 1, 2025
48 checks passed
@bryteise bryteise deleted the improve-dir-subtraction branch May 1, 2025 18:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants