-
Notifications
You must be signed in to change notification settings - Fork 38
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
How do you handle libraries in /usr/lib/x86_64-linux-gnu/<subfolder>
#68
Comments
Some deb packages come with "postinst" scripts. eg: , eg, libopenblas0-pthread_0.3.21+ds-4_amd64.deb, postinst script create those symlinks
Since rules_distroless only takes the tar files, those libs aren't linked into /usr/lib/x86_64-linux-gnu, that's why your program can't find the shared libs in the standard directories. I am not sure if there is already a feature request for this, or we will just have to live it with it, and add separate rules to create those symlinks. |
Yeah, rules_distroless probably wont have a way of auto applying post-install scripts. You can maintain a custom rule to do it for you for the packages that need it. |
Thanks, makes sense! Do you think there is a path forward using these postinst scripts with a dummy For the short term solution, I would guess a similar approach to what you proposed previously should do it? def symlink_files(name, srcs, from_dir, to_dir, **kwargs):
"""Create relative symlinks for all files in from_dir pointing to to_dir.
For example, assume
from_dir = /usr/bin
to_dir = /usr/local/bin
touch /usr/bin/foo.
ls -al /usr/bin/foo
lrwxrwxrwx 1 root root 20 /usr/bin/foo -> ../local/bin/foo
"""
native.genrule(
name = name,
srcs = srcs,
outs = [name + ".tar"],
cmd = " ; ".join([
# create a temporary directory and untar the files
"SCRATCH=$$(mktemp -d )",
"REALOUT=$$(realpath $@)",
"mkdir -p $$SCRATCH/bundle",
'for i in $(SRCS); do tar -xmf "$$i" -C $$SCRATCH/bundle ;done',
"cd $$SCRATCH/bundle",
"FROM_DIR=" + from_dir,
"TO_DIR=" + to_dir,
# remove leading / from the directories
"FROM_DIR=$$(echo $$FROM_DIR | sed 's|^/||')",
"TO_DIR=$$(echo $$TO_DIR | sed 's|^/||')",
# find relative path from to_dir to from_dir
"RELATIVE_DIR=$$(realpath --relative-to=$$TO_DIR $$FROM_DIR)",
# create symlinks and tar the files
"find $$FROM_DIR -type f,l -exec sh -c \"basename {} | xargs -I % ln -s $$RELATIVE_DIR/% $$TO_DIR/%\" \\;",
"tar --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2019-01-01' -cf $$REALOUT .",
"rm -rf $$SCRATCH",
]),
**kwargs
) usage: symlink_files(
name = "symlink_files",
from_dir = "/usr/lib/x86_64-linux-gnu/openblas-pthread",
to_dir = "/usr/lib/x86_64-linux-gnu",
srcs = [
"@bookworm//libopenblas0-pthread/amd64",
],
) |
@loosebazooka should we close this then as |
Yeah probably won't fix. The post install and symlink stories aren't great. But for the purposes of this project I don't see us dealing with them any time soon. |
I am starting off with debian bookworm as a base image, and after utilizing this workaround (thanks @gfrankliu), I now have all required libraries installed.
One of them is
libopenblas0
, which is getting installed into/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblas.so.0
. My program fails withImportError: libopenblas.so.0: cannot open shared object file: No such file or directory
, and I can fix it with these two lines in the containersentrypoint.sh
:Another way is to set
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/openblas-pthread
, which is a bit more convinient withoci_image
.Is there a better way to tell
ld
about this additional location? How isdpkg
doing it?The text was updated successfully, but these errors were encountered: