Skip to content

Commit

Permalink
Fixed LSBash when the directory is empty and revert ls to lsbash
Browse files Browse the repository at this point in the history
  • Loading branch information
Htylol committed Feb 4, 2025
1 parent 6fd26a2 commit 8818ed3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
35 changes: 19 additions & 16 deletions data_from_portwine/scripts/functions_helper
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ lsbash () {
else
for find_file in "$directory"/* ; do
find_file=${find_file//*\//}
grep_find_file1 "$@"
if [[ -d "$directory"/* ]] \
|| [[ $find_file != "*" ]] ; then
grep_find_file1 "$@"
fi
done
fi
if [[ -n $1 ]] ; then continue ; else break ; fi
Expand Down Expand Up @@ -1625,15 +1628,15 @@ init_wine_ver () {
else
if [[ -d "${PORT_WINE_PATH}/data/dist" ]] ; then
IFS=$'\n'
for dist_dir in $(ls -1 "${PORT_WINE_PATH}/data/dist") ; do
for dist_dir in $(lsbash "${PORT_WINE_PATH}/data/dist") ; do
dist_dir_new=$(echo "${dist_dir}" | awk '$1=$1' | sed -e s/[[:blank:]]/_/g)
if [[ ! -d "${PORT_WINE_PATH}/data/dist/${dist_dir_new^^}" ]] ; then
mv -- "${PORT_WINE_PATH}/data/dist/$dist_dir" "${PORT_WINE_PATH}/data/dist/${dist_dir_new^^}"
fi
done
IFS="$orig_IFS"
fi
if [[ -z $(ls "${PORT_WINE_PATH}/data/dist/" | grep "${PW_WINE_USE}") ]] ; then
if [[ -z $(lsbash "${PORT_WINE_PATH}/data/dist/" --grep "${PW_WINE_USE}") ]] ; then
if [[ "$PW_WINE_USE" =~ PROTON_LG* ]]
then export PW_WINE_USE=PROTON_LG
else export PW_WINE_USE=WINE_LG
Expand All @@ -1650,20 +1653,20 @@ init_wine_ver () {
export WINELOADER="${WINEDIR}/bin/wine"
export WINESERVER="${WINEDIR}/bin/wineserver"
if [[ -d "${WINEDIR}/files" && ! -d "${WINEDIR}/dist" ]] ; then
for clear_dist_files in $(ls "${WINEDIR}" | sed -r "s/^(files|version)$//g") ; do
for clear_dist_files in $(lsbash "$WINEDIR" | sed -r "s/^(files|version)$//g") ; do
rm -fr "${WINEDIR}/$clear_dist_files"
done
mv -f "${WINEDIR}/files"/* "${WINEDIR}/"
rm -fr "${WINEDIR}/files"
elif [[ ! -d "${WINEDIR}/files" && -d "${WINEDIR}/dist" ]] ; then
for clear_dist_files in $(ls "${WINEDIR}" | sed -r "s/^(dist|version)$//g") ; do
for clear_dist_files in $(lsbash "$WINEDIR" | sed -r "s/^(dist|version)$//g") ; do
rm -fr "${WINEDIR}/$clear_dist_files"
done
mv -f "${WINEDIR}/dist"/* "${WINEDIR}/"
rm -fr "${WINEDIR}/dist"
elif [[ -f "${WINEDIR}/proton_dist.tar" ]] ; then
unpack "${WINEDIR}/proton_dist.tar" "${WINEDIR}/"
for clear_dist_files in $(ls "${WINEDIR}" | sed -r "s/^(bin|lib|lib64|share|version)$//g") ; do
for clear_dist_files in $(lsbash "$WINEDIR" | sed -r "s/^(bin|lib|lib64|share|version)$//g") ; do
rm -fr "${WINEDIR}/$clear_dist_files"
done
fi
Expand Down Expand Up @@ -1952,7 +1955,7 @@ pw_kill_autostart () {
fi
done

if [[ -n "$(ls "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}"/drive_c/ | grep -m 1 ".tmp")" ]] ; then
if [[ -n "$(lsbash "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}"/drive_c/ | grep -m 1 ".tmp")" ]] ; then
rm -f "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}"/drive_c/*.tmp
fi

Expand Down Expand Up @@ -2043,8 +2046,8 @@ pw_download_libs () {
"${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz" ; then
if unpack "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz" "${PORT_WINE_TMP_PATH}/" ; then
try_remove_file "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz"
if ls "${PORT_WINE_TMP_PATH}" | grep libs_v | grep -v libs"${PW_LIBS_VER}" ; then
for RM_LIBS in $(ls "${PORT_WINE_TMP_PATH}" | grep libs_v | grep -v libs"${PW_LIBS_VER}")
if lsbash "${PORT_WINE_TMP_PATH}" --grep libs_v --grep -v libs"${PW_LIBS_VER}" ; then
for RM_LIBS in $(lsbash "${PORT_WINE_TMP_PATH}" --grep libs_v --grep -v libs"${PW_LIBS_VER}")
do try_remove_dir "${PORT_WINE_TMP_PATH}/${RM_LIBS}"
done
fi
Expand Down Expand Up @@ -2194,9 +2197,9 @@ pw_check_and_download_plugins () {
try_remove_file "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz"
# TODO: drop clear prefix, and add update prefix from new plugins
pw_clear_pfx
if ls "${PORT_WINE_TMP_PATH}" | grep plugins_v | grep -v "plugins${PW_PLUGINS_VER}"
if lsbash "${PORT_WINE_TMP_PATH}" --grep plugins_v --grep -v "plugins${PW_PLUGINS_VER}"
then
for RM_PLUGINS in $(ls "${PORT_WINE_TMP_PATH}" | grep plugins_v | grep -v "plugins${PW_PLUGINS_VER}")
for RM_PLUGINS in $(lsbash "${PORT_WINE_TMP_PATH}" --grep plugins_v --grep -v "plugins${PW_PLUGINS_VER}")
do try_remove_dir "${PORT_WINE_TMP_PATH}/${RM_PLUGINS}"
done
fi
Expand Down Expand Up @@ -2227,9 +2230,9 @@ pw_check_and_download_plugins () {
try_remove_file "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz"
# TODO: drop clear prefix, and add update prefix from new plugins
pw_clear_pfx
if ls "${PORT_WINE_TMP_PATH}" | grep plugins_v | grep -v "plugins${PW_PLUGINS_VER}"
if lsbash "${PORT_WINE_TMP_PATH}" --grep plugins_v --grep -v "plugins${PW_PLUGINS_VER}"
then
for RM_PLUGINS in $(ls "${PORT_WINE_TMP_PATH}" | grep plugins_v | grep -v "plugins${PW_PLUGINS_VER}")
for RM_PLUGINS in $(lsbash "${PORT_WINE_TMP_PATH}" --grep plugins_v --grep -v "plugins${PW_PLUGINS_VER}")
do try_remove_dir "${PORT_WINE_TMP_PATH}/${RM_PLUGINS}"
done
fi
Expand Down Expand Up @@ -2356,7 +2359,7 @@ pw_init_db () {
# shellcheck source=/dev/null
source "${PORTWINE_DB_FILE}"
if echo "${portwine_exe}" | grep "/prefixes/" &>/dev/null ; then
if [[ -z $(ls "${PORT_WINE_PATH}/prefixes/" | grep -e ^"${PW_PREFIX_NAME}"$) ]] \
if [[ -z $(lsbash "${PORT_WINE_PATH}/prefixes/" --grep ^"${PW_PREFIX_NAME}"$) ]] \
|| [[ -z $(grep -e ^"export PW_PREFIX_NAME=" "${PORTWINE_DB_FILE}" 2>/dev/null) ]]
then
PW_PREFIX_NAME=$(echo "${portwine_exe}" | awk -F"/prefixes/" '{print $2}' | awk -F"/" '{print $1}')
Expand Down Expand Up @@ -2396,7 +2399,7 @@ pw_init_db () {
try_copy_file "${PW_FIND_DB_FILE}" "${portwine_exe}".ppdb
PORTWINE_DB_FILE="${portwine_exe}".ppdb
if echo "${portwine_exe}" | grep "/prefixes/" &>/dev/null ; then
if [[ -z $(ls "${PORT_WINE_PATH}/prefixes/" | grep -e ^"${PW_PREFIX_NAME}"$) ]] \
if [[ -z $(lsbash "${PORT_WINE_PATH}/prefixes/" --grep ^"${PW_PREFIX_NAME}"$) ]] \
|| [[ -z $(grep -e ^"export PW_PREFIX_NAME=" "${PORTWINE_DB_FILE}" 2>/dev/null) ]]
then
PW_PREFIX_NAME=$(echo "${portwine_exe}" | awk -F"/prefixes/" '{print $2}' | awk -F"/" '{print $1}')
Expand Down Expand Up @@ -2445,7 +2448,7 @@ pw_init_db () {
if [[ "${PW_WINE_CPU_TOPOLOGY}" == "disabled" ]] && [[ -n "${WINE_CPU_TOPOLOGY}" ]] ; then
export PW_WINE_CPU_TOPOLOGY="${WINE_CPU_TOPOLOGY}"
fi
if ls "${PATH_TO_GAME}"/*_Data/Resources/ 2>/dev/null | grep "unity" &>/dev/null \
if lsbash "${PATH_TO_GAME}"/*_Data/Resources/ --grep "unity" &>/dev/null \
&& [[ "${PW_WINE_CPU_TOPOLOGY}" == "disabled" ]] \
&& [[ $(grep -c ^"processor" /proc/cpuinfo) -gt "8" ]]
then
Expand Down
2 changes: 1 addition & 1 deletion data_from_portwine/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ echo "" > "${PW_TMPFS_PATH}/tmp_yad_form_vulkan"

create_new_dir "${PORT_WINE_PATH}/data/dist"
IFS=$'\n'
for dist_dir in $(ls -1 "${PORT_WINE_PATH}/data/dist") ; do
for dist_dir in $(lsbash "${PORT_WINE_PATH}/data/dist/") ; do
dist_dir_new=$(echo "${dist_dir}" | awk '$1=$1' | sed -e s/[[:blank:]]/_/g)
if [[ ! -d "${PORT_WINE_PATH}/data/dist/${dist_dir_new^^}" ]] ; then
mv -- "${PORT_WINE_PATH}/data/dist/$dist_dir" "${PORT_WINE_PATH}/data/dist/${dist_dir_new^^}"
Expand Down

0 comments on commit 8818ed3

Please sign in to comment.