-
Notifications
You must be signed in to change notification settings - Fork 151
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
tests: fail when we cannot mv original os-release #373
Conversation
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.
Thanks for the fix - I just had one comment :)
trap osrelease_cleanup EXIT | ||
|
||
mv_osrelease() { | ||
if [ -f "$1" ]; then |
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.
if [ -f "$1" ]; then | |
if [ -f "$1" ] || [ -L "$1" ]; then |
Should we keep previous behavior of moving a broken symbolic link?
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.
Good point - forgot that many distros have /etc/os-release
as symlink.
The man page says "if it exists" where dkms code uses "-r". I'm inclined to change this + dkms code to "-e" which will stick to the man page + from brief test, it will skip if a broken symlink.
Maybe even throw in a test - both present but cannot be read, just for the fun of it.
What do you think?
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 think that sounds good - I like the idea of using -e
. From my testing as well, it seems there is no difference compared to -r
when dealing with broken symbolic links:
$ ls
$ ln -s a b
'b' -> 'a'
$ cat b
cat: b: No such file or directory
$ cat a
cat: a: No such file or directory
$ [ -e b ] && echo 'yes'
$ [ -r b ] && echo 'yes'
$ [ -f b ] && echo 'yes'
so the change should be compatible
The man page says "if it exists", so let's do that. In practical sense there should be no difference in behaviour since all Linux distros that I've seen use 0644 permissions for the file. Signed-off-by: Emil Velikov <[email protected]>
If we cannot move the os-release file(s) then the test should error out - fix that. While here adjust the trap location, so it does not trigger on cp failure or when there's no file to copy in the first place. v2: - check with -e, as per `man os-release` Signed-off-by: Emil Velikov <[email protected]>
... otherwise we may alter the permissions and/or dereference the symlink. Signed-off-by: Emil Velikov <[email protected]>
Added a prep commit updating dkms to use -e. Also added a follow-up commit to use |
The Gentoo CI is failing, which is pre-existing and unrelated to this PR. Merging |
If we cannot move the os-release file(s) then the test should error out - fix that.
While here adjust the trap location, so it does not trigger on cp failure or when there's no file to copy in the first place.
Minor fixup of #351
@hyperupcall can you give this a quick look? I should have drank more coffee before reviewing 😅