Skip to content

Commit 11e3f3c

Browse files
authored
make path-mapping-hardcoded.hook on the spot instead of downloading
saves a network request which github is being very stingy about lately
1 parent 6836b5c commit 11e3f3c

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

useful-tools/quick-sharun.sh

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,43 @@ _add_bwrap_wrapper() {
11361136
chmod +x "$APPDIR"/bin/bwrap
11371137
}
11381138

1139+
_add_path_mapping_hardcoded() {
1140+
f="$APPDIR"/bin/path-mapping-hardcoded.hook
1141+
if [ ! -x "$f" ]; then
1142+
mkdir -p "${f%/*}"
1143+
cat <<-'EOF' > "$f"
1144+
#!/bin/sh
1145+
1146+
# this script makes symnlinks to hardcoded random dirs that
1147+
# were patched away by quick-sharun when hardcoded paths are
1148+
# detected or when 'PATH_MAPPING_HARDCODED' is used
1149+
1150+
# make sure the _tmp_* vars come directly from the APPDIR .env file
1151+
unset _tmp_bin _tmp_lib _tmp_share
1152+
1153+
if ! command -v ln 1>/dev/null; then
1154+
>&2 echo "path-mapping-hardcoded: ERROR we cannot make symlinks"
1155+
>&2 echo "because command 'ln' is missing from the system! Aborting..."
1156+
exit 1
1157+
fi
1158+
1159+
if [ -f "$APPDIR"/.env ]; then
1160+
. "$APPDIR"/.env
1161+
if [ -n "$_tmp_bin" ]; then
1162+
ln -sfn "$APPDIR"/bin /tmp/"$_tmp_bin"
1163+
fi
1164+
if [ -n "$_tmp_lib" ]; then
1165+
ln -sfn "$APPDIR"/lib /tmp/"$_tmp_lib"
1166+
fi
1167+
if [ -n "$_tmp_share" ]; then
1168+
ln -sfn "$APPDIR"/share /tmp/"$_tmp_share"
1169+
fi
1170+
fi
1171+
EOF
1172+
chmod +x "$f"
1173+
fi
1174+
}
1175+
11391176
_patch_away_usr_bin_dir() {
11401177
if ! grep -Eaoq -m 1 "/usr/bin" "$1"; then
11411178
return 1
@@ -1147,7 +1184,7 @@ _patch_away_usr_bin_dir() {
11471184
fi
11481185

11491186
_echo "* patched away /usr/bin from $1"
1150-
ADD_HOOKS="${ADD_HOOKS:+$ADD_HOOKS:}path-mapping-hardcoded.hook"
1187+
_add_path_mapping_hardcoded
11511188
}
11521189

11531190
_patch_away_usr_lib_dir() {
@@ -1161,7 +1198,7 @@ _patch_away_usr_lib_dir() {
11611198
fi
11621199

11631200
_echo "* patched away /usr/lib from $1"
1164-
ADD_HOOKS="${ADD_HOOKS:+$ADD_HOOKS:}path-mapping-hardcoded.hook"
1201+
_add_path_mapping_hardcoded
11651202
}
11661203

11671204
_patch_away_usr_share_dir() {
@@ -1175,7 +1212,7 @@ _patch_away_usr_share_dir() {
11751212
fi
11761213

11771214
_echo "* patched away /usr/share from $1"
1178-
ADD_HOOKS="${ADD_HOOKS:+$ADD_HOOKS:}path-mapping-hardcoded.hook"
1215+
_add_path_mapping_hardcoded
11791216
}
11801217

11811218
_make_static_bin() (

0 commit comments

Comments
 (0)