install.sh: Preserve directory symlinks
PATCH 1/1 install.sh: Preserve directory symlinks
In various distros (i.e. Debian) some folders like /lib or /var/run are symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.
--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
install.sh +1 -1
@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf - -(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf - rm -rf "$tmp" echo "All done."
Signature · 10 lines
2.51.0 -- Thierry Escande | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Quoted 5 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>
Coincidentally, I hit this last week. I think the commit message should be expanded because it resulted in a non-functioning system. I switched to make debball, but thanks for fixing this.
I saw Ubuntu's /lib -> /usr/lib symlink replaced with a directory for /lib/systemd/system/xen-watchdog-sleep.sh. With /lib broken, systemd (/sbin/init) could not start and boot fails.
The fix was easy - just restoring the /lib symlink.
So maybe add "Replacing the /lib symlink with a directory results in a non-functioning system."?
I thought /var/run was addressed by:
It hasn't been an issue for me since that change.
For /lib a fixes is either:
or
It might have only been the second one that defaulted to /lib causing the problem. Though the issue is more general.
I do think a fixes and backport are warranted. With the commit message updated:
Thanks,
Jason
Quoted 17 lines
--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +1
-1@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf - -(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf - rm -rf "$tmp" echo "All done."
Hi,
Quoted 15 lines · Jason Andryuk
Quoted 5 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>Coincidentally, I hit this last week. I think the commit message should be expanded because it resulted in a non-functioning system. I switched to make debball, but thanks for fixing this.
I saw Ubuntu's /lib ->
/usr/libsymlink replaced with a directory for / lib/systemd/system/xen-watchdog-sleep.sh. With /lib broken, systemd (/ sbin/init) could not start and boot fails.
Quoted 8 lines
The fix was easy - just restoring the /lib symlink.
So maybe add "Replacing the /lib symlink with a directory results in a non-functioning system."?
I thought
/var/runwas addressed by:Fixes 9d628ff6cc21 ("tools: Fix install.sh for systemd")It hasn't been an issue for me since that change.
I thought it was still the case but my current config does not install files in /var/run anymore, so I missed that fix. Thanks for pointing this out.
Quoted 7 lines
For /lib a fixes is either:
Fixes e54a6cd6a1f3 ("systemd: Add hooks to stop/start xen-watchdog onsuspend/resume")
or
Quoted 8 lines
Fixes b34bde262c8c ("systemd: fall back to default system-sleep dirwithout systemd-devel")
It might have only been the second one that defaulted to /lib causing the problem. Though the issue is more general.
I do think a fixes and backport are warranted. With the commit message updated:
After discussing with Jan, I will send a v2 that uses the more standard option -h instead of --keep-directory-symlink and updates the commit message.
Regards,
--
Thierry Escande | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 14 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0
install.sh tmp="`mktemp -d`" · line 30
Quoted 5 lines
install.sh +1
-1@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf - -(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -
How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
Jan
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf -
Quoted 5 lines
install.sh tmp="`mktemp -d`" · line 30
Quoted 2 lines
install.sh +1
-1-(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
It's supported by GNU tar since version 1.27 (from ~12 years ago) but it seems to be the only implementation that supports it. BSD and busybox don't support it. I didn't check for other implementations.
I can add a flavor/version check if that makes sense.
Regards,
--
| Vates
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 27 lines · Thierry Escande
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf -Quoted 5 lines
install.sh tmp="`mktemp -d`" · line 30
Quoted 2 lines
install.sh +1
-1-(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
Quoted 5 lines
It's supported by GNU tar since version 1.27 (from ~12 years ago) but it seems to be the only implementation that supports it. BSD and busybox don't support it. I didn't check for other implementations.
I can add a flavor/version check if that makes sense.
Possibly. One question then is what the behavior was prior to that option having been introduced.
Jan
Quoted 28 lines · Jan Beulich
Quoted 27 lines · Thierry Escande
Quoted 23 lines · Jan Beulich
Quoted 14 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0install.sh tmp="`mktemp -d`" · line 30
Quoted 5 lines
install.sh +1
-1@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf - -(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
Quoted 8 lines
Quoted 5 lines
It's supported by GNU tar since version 1.27 (from ~12 years ago) but it seems to be the only implementation that supports it. BSD and busybox don't support it. I didn't check for other implementations.
I can add a flavor/version check if that makes sense.
Possibly. One question then is what the behavior was prior to that option having been introduced.
From the patch at [1] introducing the option, and more precisely the test done at [2], directory symlinks were simply overwritten.
[1]
https://cgit.git.savannah.gnu.org/cgit/tar.git/commit/?id=2c06a80918019471876956eef4ef22f05c9e0571
[2]
https://cgit.git.savannah.gnu.org/cgit/tar.git/tree/src/extract.c?id=2c06a80918019471876956eef4ef22f05c9e0571#n934
Regards,
Thierry
--
Thierry Escande | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 31 lines · Thierry Escande
Quoted 30 lines · Jan Beulich
Quoted 29 lines · Thierry Escande
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf -Quoted 5 lines
install.sh tmp="`mktemp -d`" · line 30
Quoted 2 lines
install.sh +1
-1-(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
It's supported by GNU tar since version 1.27 (from ~12 years ago) but it seems to be the only implementation that supports it. BSD and busybox don't support it. I didn't check for other implementations.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I can add a flavor/version check if that makes sense.
Possibly. One question then is what the behavior was prior to that option having been introduced.
From the patch at [1] introducing the option, and more precisely the test done at [2], directory symlinks were simply overwritten.
Which makes it hard to suggest useful behavior when the option is unavailable:
Simply refusing to install isn't nice, but corrupting the installation is perhaps even worse.
I take it that the (presumably) more standard -h doesn't help here?
Jan
Quoted 16 lines
[1]
https://cgit.git.savannah.gnu.org/cgit/tar.git/commit/?id=2c06a80918019471876956eef4ef22f05c9e0571
[2]
https://cgit.git.savannah.gnu.org/cgit/tar.git/tree/src/extract.c?id=2c06a80918019471876956eef4ef22f05c9e0571#n934Regards,
Thierry--
Thierry Escande | Vates XCP-ng DeveloperXCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 37 lines · Jan Beulich
Quoted 36 lines · Thierry Escande
Quoted 34 lines · Jan Beulich
Quoted 25 lines · Thierry Escande
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Thierry Escande
In various distros (i.e. Debian) some folders like /lib or
/var/runare symlinks. Using the tar option --keep-directory-symlink preserves these symlinks.Signed-off-by Thierry Escande <[email protected]>--- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)install.sh +0
-0@@ -27,7 +27,7 @@ tmp="`mktemp -d`" echo "Installing Xen from '$src' to '$dst'..." (cd $src; tar -cf - * ) | tar -C "$tmp" -xf -Quoted 5 lines
install.sh tmp="`mktemp -d`" · line 30
Quoted 2 lines
install.sh +1
-1-(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf - +(cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" --keep-directory-symlink -xf -How compatible (between flavors of tar as well as between versions of GNU tar) is use of this option?
Quoted 5 lines
It's supported by GNU tar since version 1.27 (from ~12 years ago) but it seems to be the only implementation that supports it. BSD and busybox don't support it. I didn't check for other implementations.
I can add a flavor/version check if that makes sense.
Possibly. One question then is what the behavior was prior to that option having been introduced.
Quoted 8 lines
Quoted 2 lines
From the patch at [1] introducing the option, and more precisely the test done at [2], directory symlinks were simply overwritten.
Which makes it hard to suggest useful behavior when the option is unavailable:
Simply refusing to install isn't nice, but corrupting the installation is perhaps even worse.I take it that the (presumably) more standard -h doesn't help here?
-h definitely helps but it has the same behavior for files and folders. So if an already existing symlink is meant to be replaced by a file, then it won't. I chose to use the folder specific option.
That being said there is probably no usecase where a real file replaces a symlink in the dist archive. And anyway, that would also stand for folders.
I'll send a v2 with -h.
Regards,
--
Thierry Escande | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech