mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-10 07:57:59 -05:00
39 lines
1.4 KiB
Ruby
39 lines
1.4 KiB
Ruby
require 'package'
|
|
|
|
class Composer < Package
|
|
description 'Dependency Manager for PHP'
|
|
homepage 'https://getcomposer.org/'
|
|
version '2.0.13'
|
|
license 'MIT'
|
|
compatibility 'all'
|
|
source_url 'SKIP'
|
|
|
|
depends_on 'php74' unless File.exists? "#{CREW_PREFIX}/bin/php"
|
|
depends_on 'xdg_base'
|
|
|
|
def self.preinstall
|
|
if Dir.exists?("#{HOME}/.config") && !File.symlink?("#{HOME}/.config")
|
|
# Save any existing configuration
|
|
FileUtils.cp_r "#{HOME}/.config", "#{CREW_PREFIX}", remove_destination: true unless Dir.empty? "#{HOME}/.config"
|
|
else
|
|
# Remove the symlink, if it exists
|
|
FileUtils.rm_f "#{HOME}/.config"
|
|
end
|
|
end
|
|
|
|
def self.install
|
|
system "curl -Ls -o composer https://github.com/composer/composer/releases/download/#{version}/composer.phar"
|
|
abort 'Checksum mismatch. :/ Try again.'.lightred unless Digest::SHA256.hexdigest( File.read('composer') ) == '116fdf07cc926af646635a6abc92d88aff7b02a5dc36538f81c50a7d27366dbf'
|
|
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin"
|
|
FileUtils.install 'composer', "#{CREW_DEST_PREFIX}/bin/composer", mode: 0o755
|
|
end
|
|
|
|
def self.postinstall
|
|
FileUtils.ln_sf "#{CREW_PREFIX}/.config", "#{HOME}/.config"
|
|
puts
|
|
puts "To finish the installation, execute the following:".lightblue
|
|
puts "echo 'export PATH=\$HOME/.config/composer/vendor/bin:\$PATH' >> ~/.bashrc && . ~/.bashrc".lightblue
|
|
puts
|
|
end
|
|
end
|