Skip to content

Instantly share code, notes, and snippets.

@adamshostack
Created August 31, 2024 19:17
Show Gist options
  • Save adamshostack/4fac61be8fff40a0ea9c597c7fd7d423 to your computer and use it in GitHub Desktop.
Save adamshostack/4fac61be8fff40a0ea9c597c7fd7d423 to your computer and use it in GitHub Desktop.
Installing Bricklink Studio without admin rights
pkgutil --expand-full Studio+2.0.pkg studio
cd studio/Studio_2.0.pkg/Payload/Applications
mv Studio\ 2.0/ /Applications/
@adamshostack
Copy link
Author

adamshostack commented Aug 31, 2024

The app seems to have no reasonable reason to run with admin privileges, and it has code (in scripts/preinstall) like this:

cachedNewPartsPath="$home/.local/share/Stud.io/NewParts"
unityPref="$home/Library/Preferences/com.BrickLink.Studio.plist"
array=("$cachedLibPath" "$unityPref" "$cachedMetaInfoPath" "$cachedNewPartsPath")
for path in ${array[@]}
do
if [ -f $path ] || [ -d $path ]
then
sudo rm -rf $path
fi
done

I don't like the unprotected $home (it should be ${home} and if there's an error, we end up with sudo rm -rf on the path? No thank you!!

@adamshostack
Copy link
Author

adamshostack commented Sep 1, 2024

Because I'm having a conversation on mastodon about enabling "strict mode" with -euo, here's the code:

#!/bin/bash

#
# delete application
#

studio_path="$DSTROOT/Applications/Studio 2.0"

home=$HOME
echo "applications path="$studio_path
echo "home path="$home

if [ -d "$studio_path" ]
then
  # delete all from studio path except "ldraw"
  sudo rm -rf "${studio_path}/" -mindepth 1 -maxdepth 1 ! -name "ldraw" -exec rm -rf {} +
  
  # delete all from studio/ldraw path except "Custom Parts"
  sudo find "${studio_path}/ldraw" -mindepth 1 -maxdepth 1 ! -name "Custom Parts" -exec rm -rf {} +
fi

#
# delete cached files
#

cachedLibPath="$home/.local/share/Stud.io/cachedLibraryPath.txt"
cachedMetaInfoPath="$home/.local/share/Stud.io/BLBrickMetaInfo"
cachedNewPartsPath="$home/.local/share/Stud.io/NewParts"
unityPref="$home/Library/Preferences/com.BrickLink.Studio.plist"
array=("$cachedLibPath" "$unityPref" "$cachedMetaInfoPath" "$cachedNewPartsPath")
for path in ${array[@]}
do
  if [ -f $path ] || [ -d $path ]
  then
    sudo rm -rf $path
  fi
done

exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment