Skip to content

Commit

Permalink
Fix removing directories for macos uninstall_pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Jun 25, 2022
1 parent 46dede3 commit 25e21ee
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src_assets/macos/misc/uninstall_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
package_name=org.macports.Sunshine

echo "Removing files now..."
FILES=$(pkgutil --files --only-files $package_name)
FILES=$(pkgutil --files $package_name --only-files)

remove_config=True
remove_apps=True
Expand Down Expand Up @@ -44,12 +44,22 @@ for file in ${FILES}; do
done

echo "Removing directories now..."
DIRECTORIES=$(pkgutil --files --only-dirs org.macports.Sunshine)
DIRECTORIES=$(pkgutil --files org.macports.Sunshine --only-dirs)

for dir in ${DIRECTORIES}; do
dir="/$dir"
echo "Checking if empty directory: $dir"
find "$dir" -type d -empty -exec rm -f -d {} \;

# check if directory is empty... could just use ${DIRECTORIES} here if pkgutils added the `/` prefix
empty_dir=$(find "$dir" -depth 0 -type d -empty)

# remove the directory if it is empty
if [[ $empty_dir != "" ]]; then # prevent the loop from running and failing if no directories found
for i in "${empty_dir}"; do # don't split words as we already know this will be a single directory
echo "Removing empty directory: ${i}"
rmdir "${i}"
done
fi
done

echo "Forgetting Sunshine..."
Expand Down

0 comments on commit 25e21ee

Please sign in to comment.