Due to the rootless feature, original pkg installation would be incomplete.
Of course, homebrew users should use brew
, but this is not an option for MacPorts (or Fink) users.
Using darwin-x86_64.tar.gz
- Extract tar.gz into /opt/crystal
- Link /opt/crystal/bin/crystal and /opt/crystal/embedded/bin/shards to /usr/local/bin.
Using pkg
- You need to modify the pkg to symlink safely.
- Prepare updatepkgscripts.rb.
- Paste following to crystal-update.rb.
- Call
crystal-update.rb updatepkgscripts.rb crystal.pkg
. - Now you can install the pkg safely.
crystal-update.rb
#!/usr/bin/ruby
#usage: crystal-update.rb updatepkgscripts.rb crystal.pkg
require 'tmpdir'
Dir.mktmpdir{|tmp|
system('"'+ARGV[0]+'" -x "'+ARGV[1]+'" crystal-core.pkg/Scripts "'+tmp+'"')
File.open(tmp+'/postinstall','wb'){|f|
f.write DATA.read
}
system('"'+ARGV[0]+'" -u "'+ARGV[1]+'" crystal-core.pkg/Scripts "'+tmp+'"')
}
__END__
#!/bin/bash
#
# Perform necessary crystal setup steps
# after package is installed.
#
PROGNAME=$(basename $0)
function error_exit
{
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}
INSTALL_PATH=/usr
if [ `uname` = "Darwin" -a `uname -r|cut -f1 -d.` -ge 15 ]; then
INSTALL_PATH=/usr/local
fi
ln -nfs /opt/crystal/bin/crystal ${INSTALL_PATH}/bin/crystal
ln -nfs /opt/crystal/embedded/bin/shards ${INSTALL_PATH}/bin/shards
exit 0