-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
singularity-tools: miscellaneous fixes (2nd round) #333843
singularity-tools: miscellaneous fixes (2nd round) #333843
Conversation
I found some issues inside this PR and will hold it back until they are resolved. |
Place the VM disk image in a local directory "disk-image" instead of "$out", so that we don't have to delete it to reserve "$out" for the container image.
c58e32b
to
90eb773
Compare
Problem solved. It's now ready for review. |
cp -ar $f ./$f | ||
done | ||
while IFS= read -r f; do | ||
cp -r "$f" "./$f" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why -a
is not necessary. I'm seeing that if I do
$ touch a
$ chmod +x a
$ cp a b
$ stat b
...b
s still has the +x bit, but I don't know why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing that if I do
$ touch a $ chmod +x a $ cp a b $ stat b...
b
s still has the +x bit, but I don't know why
For cp
, -a
(--archive
) implies --preserve all
, which means preserving all attributes, including mode
, ownership
, timestamps
, links
(hard links), context
(SELinux or SMACK security context), xattr
. cp
preserves the file mode by default but not the file ownership.
It requires root privileges to create a file owned by root:root
, which is why it requires root privileges to cp -ra
from a store object.
I wonder why
-a
is not necessary.
The initial purpose of preserving ownership might be to please Nix when using Nix inside the container. However, the container Nix store is inherently broken from Nix's perspective, as it doesn't include the database.
Cc: @jbedo, the original author of singularity-tools
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires root privileges to create a file owned by root:root
It doesn't? In particular, this works:
with import <nixpkgs> { };
runCommand "abc" { } ''
cp -ar ${hello}/ $out/
''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires root privileges to create a file owned by root:root
It doesn't? In particular, this works:
with import <nixpkgs> { }; runCommand "abc" { } '' cp -ar ${hello}/ $out/ ''
Oops! I remember that it wasn't when I first worked on it.
for c in ${lib.escapeShellArgs contents} ; do | ||
for f in "$c"/bin/* ; do | ||
if [ ! -e "bin/$(basename "$f")" ] ; then | ||
ln -s "$f" bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be in scope for the PR but it's maybe worth linking
- Avoid symlinking to /bin when building singularity containers (or warn on clashes) #93122
- singularity-tools: Check for /bin/sh existence before symlink #93082
...from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with using PATH
instead of /bin
symlinking. I used it in the definition-based build provided by #224636. Here is our previous discussion on this topic: https://github.com/NixOS/nixpkgs/pull/224636/files#r1160279847
May not be in scope for the PR
I'm unsure if people (we) have reached a consensus about this change, so I didn't include it in this PR.
String-interpolation converts path objects inside `contents` into store paths to ensure they are properly included in the result image. See tests.trivial-builders.references for the necessity of string-interpolation. Quote each string-interpolated content member to accomodates spaces inside.
90eb773
to
37ce47c
Compare
Don't preserve store content ownership to prepare for unprivileged-build workflow.
37ce47c
to
c2eb0aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why the "Check pkgs/by-name pkgs-by-name-check" CI check fails.
Not sure, I restarted the job and it seems fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's GitHub; they had a widespread outage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I thought that was a day ago
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.githubstatus.com/incidents/mrpx4trfk45z they had another one in this area
Description of changes
When rebasing #268199, I found some more minor issues. Here's what I do in this round of fixes:
bashInteractive
andrunScriptFile
intoclosureInfo
and the resulting container image.singularity-tools
extensible instead of usingrec
. This will be useful for singularity-tools: refactor and addrunImageInLinuxVM
; apptainer.passthru.tests.exec-image-in-linux-vm: init #268199.contents
before copying (instead oftoString
) to ensure that path objects get appropriately included in the resulting image.Thank you, @SomeoneSerge, for being so patient in reviewing everything.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.