APFS clone for Xcode cloning
andrebraga opened this issue · comments
The copy
option of install.sh
to clone Xcode currently uses:
sudo cp -Rp "/Applications/Xcode.app" "/Applications/XcodeWithPlugins.app"
It would be really nice to use the -c
flag on APFS volumes in order to perform a copy-on-write clone. It's faster and saves disk space.
According to man 1 cp
:
-c copy files using clonefile(2)
stat -f "%Sd" /Applications/Xcode.app
can be used to check the device name Xcode currently resides in. Skeletal test, probably not super efficient:
if [[ $(diskutil info $(stat -f "%Sd" /Applications/Xcode.app) | grep APFS | wc -l) -gt 0 ]]; then
# use '-c'
else
# use normal copy
fi
Thanks!