@@ -51,12 +51,14 @@ DEPENDENCIES="
5151
5252# check if the _tmp_* vars have not be declared already
5353# likely to happen if this script run more than once
54- if [ -f " $APPENV " ]; then
54+ PATH_MAPPING_SCRIPT=" $APPDIR " /bin/path-mapping-hardcoded.src.hook
55+
56+ if [ -f " $PATH_MAPPING_SCRIPT " ]; then
5557 while IFS= read -r line; do
5658 case " $line " in
5759 _tmp_* ) eval " $line " ;;
5860 esac
59- done < " $APPENV "
61+ done < " $PATH_MAPPING_SCRIPT "
6062fi
6163
6264regex=' A-Za-z0-9_=-'
@@ -1137,40 +1139,39 @@ _add_bwrap_wrapper() {
11371139}
11381140
11391141_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
1142+ if [ -x " $PATH_MAPPING_SCRIPT " ]; then
1143+ return 0
1144+ fi
1145+ mkdir -p " ${PATH_MAPPING_SCRIPT%/* } "
1146+ cat << -'EOF ' > "$PATH_MAPPING_SCRIPT"
1147+ #!/bin/sh
11451148
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+ # this script makes symnlinks to hardcoded random dirs that
1150+ # were patched away by quick-sharun when hardcoded paths are
1151+ # detected or when 'PATH_MAPPING_HARDCODED' is used
11491152
1150- # make sure the _tmp_* vars come directly from the APPDIR .env file
1151- unset _tmp_bin _tmp_lib _tmp_share
1153+ _tmp_bin=""
1154+ _tmp_lib=""
1155+ _tmp_share=""
11521156
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
1157+ if ! command -v ln 1>/dev/null; then
1158+ >&2 echo "path-mapping-hardcoded: ERROR we cannot make symlinks"
1159+ >&2 echo "because command 'ln' is missing from the system! Aborting..."
1160+ exit 1
1161+ fi
11581162
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 "
1163+ if [ -n "$_tmp_bin" ]; then
1164+ ln -sfn "$APPDIR"/bin /tmp/"$_tmp_bin"
11731165 fi
1166+ if [ -n "$_tmp_lib" ]; then
1167+ ln -sfn "$APPDIR"/lib /tmp/"$_tmp_lib"
1168+ fi
1169+ if [ -n "$_tmp_share" ]; then
1170+ ln -sfn "$APPDIR"/share /tmp/"$_tmp_share"
1171+ fi
1172+ EOF
1173+ chmod +x " $f "
1174+ _echo " * Added $PATH_MAPPING_SCRIPT "
11741175}
11751176
11761177_patch_away_usr_bin_dir () {
@@ -1179,12 +1180,11 @@ _patch_away_usr_bin_dir() {
11791180 fi
11801181
11811182 sed -i -e " s|/usr/bin|/tmp/$_tmp_bin |g" " $1 "
1182- if ! grep -q " _tmp_bin='$_tmp_bin '" " $APPENV " 2> /dev/null; then
1183- echo " _tmp_bin='$_tmp_bin '" >> " $APPENV "
1184- fi
11851183
11861184 _echo " * patched away /usr/bin from $1 "
11871185 _add_path_mapping_hardcoded
1186+
1187+ sed -i -e " s|_tmp_bin=.*|_tmp_bin=$_tmp_bin |g" " $PATH_MAPPING_SCRIPT "
11881188}
11891189
11901190_patch_away_usr_lib_dir () {
@@ -1193,12 +1193,11 @@ _patch_away_usr_lib_dir() {
11931193 fi
11941194
11951195 sed -i -e " s|/usr/lib|/tmp/$_tmp_lib |g" " $1 "
1196- if ! grep -q " _tmp_lib='$_tmp_lib '" " $APPENV " 2> /dev/null; then
1197- echo " _tmp_lib='$_tmp_lib '" >> " $APPENV "
1198- fi
11991196
12001197 _echo " * patched away /usr/lib from $1 "
12011198 _add_path_mapping_hardcoded
1199+
1200+ sed -i -e " s|_tmp_lib=.*|_tmp_lib=$_tmp_lib |g" " $PATH_MAPPING_SCRIPT "
12021201}
12031202
12041203_patch_away_usr_share_dir () {
@@ -1207,12 +1206,11 @@ _patch_away_usr_share_dir() {
12071206 fi
12081207
12091208 sed -i -e " s|/usr/share|/tmp/$_tmp_share |g" " $1 "
1210- if ! grep -q " _tmp_share='$_tmp_share '" " $APPENV " 2> /dev/null; then
1211- echo " _tmp_share='$_tmp_share '" >> " $APPENV "
1212- fi
12131209
12141210 _echo " * patched away /usr/share from $1 "
12151211 _add_path_mapping_hardcoded
1212+
1213+ sed -i -e " s|_tmp_share=.*|_tmp_share=$_tmp_share |g" " $PATH_MAPPING_SCRIPT "
12161214}
12171215
12181216_make_static_bin () (
0 commit comments