Skip to content

Commit a53e325

Browse files
committed
Add LIBVA_DRIVERS_PATH env var (sharun)
Fix the creation of symlinks with a relative path (lib4bin) Fix creation of nested directories for libraries (lib4bin)
1 parent 22c3e35 commit a53e325

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sharun"
3-
version = "0.7.2"
3+
version = "0.7.3"
44
readme = "README.md"
55
license = "MIT"
66
repository = "https://github.com/VHSgunzo/sharun"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ This can be useful, for example, to use [ld-preload-open](https://github.com/fri
181181
|`LIBDECOR_PLUGIN_DIR` | `${SHARUN_DIR}/shared/$LIB/libdecor/plugins-1`|
182182
|`GTK_IM_MODULE_FILE` | `${SHARUN_DIR}/shared/$LIB/gtk-*/*/immodules.cache`|
183183
|`LIBGL_DRIVERS_PATH` | `${SHARUN_DIR}/shared/$LIB/dri`|
184+
|`LIBVA_DRIVERS_PATH` | `${SHARUN_DIR}/shared/$LIB/dri`|
184185
|`SPA_PLUGIN_DIR` | `${SHARUN_DIR}/shared/$LIB/spa-*`|
185186
|`PIPEWIRE_MODULE_DIR` | `${SHARUN_DIR}/shared/$LIB/pipewire-*`|
186187
|`GI_TYPELIB_PATH` | `${SHARUN_DIR}/shared/$LIB/girepository-*`|

lib4bin

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ try_cd() {
301301
cd "$1"||exit 1
302302
}
303303
304+
get_lib_dst_dir_pth() {
305+
local dst_dir_pth="$1" lib_dir="$2" lib_src_dirname_pth="$3"
306+
echo "${dst_dir_pth}/${lib_dir}$(sed -E \
307+
"s|$dst_dir||;s|/shared||;s|^/usr||;s|^/opt||;s|^/lib(64\|32)?||;s|^/[^/]*-linux-gnu||"\
308+
<<<"$lib_src_dirname_pth")"
309+
}
310+
304311
get_relative_path() {
305312
local start_dir="$1"
306313
local target_dir="$2"
@@ -843,8 +850,7 @@ if [[ ! -d "$WRAPPE_DIR" || "$WITH_PYTHON" == 1 ]]
843850
lib_src_name="$(basename "$lib_src_pth")"
844851
grep -qE '/lib32|/i386-linux-gnu|/arm-linux-gnu'<<<"$lib_src_dirname_pth" && \
845852
lib_dir="lib32"||lib_dir="lib"
846-
lib_dst_dir_pth="${dst_dir_pth}/${lib_dir}$(sed \
847-
"s|$dst_dir||;s|/shared||;s|^/usr||;s|^/opt||;s|^/lib64||;s|^/lib32||;s|^/lib||;s|^/.*-linux-gnu||"<<<"$lib_src_dirname_pth")"
853+
lib_dst_dir_pth="$(get_lib_dst_dir_pth "$dst_dir_pth" "$lib_dir" "$lib_src_dirname_pth")"
848854
[ -n "$lib_src_real_name" ] && \
849855
lib_dst_pth="$lib_dst_dir_pth/$lib_src_real_name"||\
850856
lib_dst_pth="$lib_dst_dir_pth/$lib_src_name"
@@ -866,8 +872,19 @@ if [[ ! -d "$WRAPPE_DIR" || "$WITH_PYTHON" == 1 ]]
866872
try_cp_exe "$lib_src_pth" "$lib_dst_pth"
867873
if [[ -n "$lib_src_real_name" && "$lib_src_name" != "$lib_src_real_name" ]]
868874
then
869-
(try_cd "$lib_dst_dir_pth"
870-
try_ln "$lib_src_real_name" "$lib_src_name")||exit 1
875+
lib_src_rel_pth="$(readlink "$lib_src_pth")"
876+
(if [[ "$(dirname "$lib_src_rel_pth")" =~ ^\. ]]
877+
then
878+
lib_dst_dir_rel_pth="$(get_lib_dst_dir_pth "$dst_dir_pth" "$lib_dir" \
879+
"$(readlink -f "$(dirname "$lib_src_pth")")")"
880+
try_mkdir "$lib_dst_dir_rel_pth"
881+
try_cd "$lib_dst_dir_rel_pth"
882+
try_ln "$lib_src_rel_pth" "$lib_src_name"
883+
else
884+
try_cd "$lib_dst_dir_pth"
885+
try_ln "$lib_src_real_name" "$lib_src_name"
886+
fi)||exit 1
887+
871888
fi
872889
if [[ "${LIBRARIES["$lib_dst_pth"]}" != 1 ]]
873890
then

src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,14 @@ fn main() {
692692
}
693693
}
694694
if dir == "dri" {
695-
env::set_var("LIBGL_DRIVERS_PATH", dir_path)
695+
env::set_var("LIBGL_DRIVERS_PATH", dir_path);
696+
add_to_env("LIBVA_DRIVERS_PATH", "/usr/lib/dri");
697+
add_to_env("LIBVA_DRIVERS_PATH", "/usr/lib64/dri");
698+
#[cfg(target_arch = "x86_64")]
699+
add_to_env("LIBVA_DRIVERS_PATH", "/usr/lib/x86_64-linux-gnu/dri");
700+
#[cfg(target_arch = "aarch64")]
701+
add_to_env("LIBVA_DRIVERS_PATH", "/usr/lib/aarch64-linux-gnu/dri");
702+
add_to_env("LIBVA_DRIVERS_PATH", dir_path)
696703
}
697704
if dir == "gbm" {
698705
env::set_var("GBM_BACKENDS_PATH", dir_path)

0 commit comments

Comments
 (0)