Created
November 25, 2019 18:13
-
-
Save anonymouse64/2b8b1d53ae205f2b67d749c7feed170d to your computer and use it in GitHub Desktop.
Chromium snap install hook to create private, correct /etc/ld.so.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
# make sure our fake ld.so.cache exists | |
if [ ! -f "$SNAP_DATA/etc/ld.so.cache" ]; then | |
echo "snap private ld.so.cache doesn't exist!" | |
exit 1 | |
fi | |
# copying the conf dir from real /etc into $SNAP_DATA | |
mkdir -p "$SNAP_DATA/etc/ld.so.conf.d" | |
cp -r /etc/ld.so.conf.d/* "$SNAP_DATA/etc/ld.so.conf.d" | |
cp /etc/ld.so.conf "$SNAP_DATA/etc/ld.so.conf" | |
# delete empty entries in the LD_LIBRARY_PATH | |
# i.e. change "/a/b/c:/1/2/3::/other" into "/a/b/c:/1/2/3:/other" | |
# if we don't do this, then ldconfig gets confused with "" as arguments of dirs | |
# to add to the cache | |
LD_LIBRARY_PATH="${LD_LIBRARY_PATH//::/:}" | |
# run ldconfig on our LD_LIBRARY_PATH lib dirs | |
IFS=':' read -ra PATHS <<< "$LD_LIBRARY_PATH" | |
mkdir -p "$SNAP_DATA/fake-etc" | |
ldconfig -v -C "$SNAP_DATA/fake-etc/ld.so.cache" -c "$SNAP_DATA/etc/ld.so.conf" "${PATHS[@]}" | |
# install the new ld.so.cache to the global location by just copying it | |
cp "$SNAP_DATA/fake-etc/ld.so.cache" "$SNAP_DATA/etc/ld.so.cache" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment