Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move fonts instead of hardlinking them #23728

Merged
merged 1 commit into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/hbc/artifact/font.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "hbc/artifact/hardlinked"
require "hbc/artifact/moved"

class Hbc::Artifact::Font < Hbc::Artifact::Hardlinked
class Hbc::Artifact::Font < Hbc::Artifact::Moved
end
24 changes: 0 additions & 24 deletions lib/hbc/artifact/hardlinked.rb

This file was deleted.

43 changes: 0 additions & 43 deletions lib/hbc/artifact/linked.rb

This file was deleted.

44 changes: 42 additions & 2 deletions lib/hbc/artifact/symlinked.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "hbc/artifact/linked"
require "hbc/artifact/relocated"

class Hbc::Artifact::Symlinked < Hbc::Artifact::Linked
class Hbc::Artifact::Symlinked < Hbc::Artifact::Relocated
def self.islink?(path)
path.symlink?
end
Expand All @@ -9,6 +9,46 @@ def self.link_type_english_name
"Symlink"
end

def summary
{
english_description: "#{self.class.artifact_english_name} #{self.class.link_type_english_name}s managed by brew-cask:",
contents: @cask.artifacts[self.class.artifact_dsl_key].map(&method(:summarize_one_link)) - [nil],
}
end

def link(artifact_spec)
load_specification artifact_spec
return unless preflight_checks(source, target)
ohai "#{self.class.link_type_english_name}ing #{self.class.artifact_english_name} '#{source.basename}' to '#{target}'"
create_filesystem_link(source, target)
end

def unlink(artifact_spec)
load_specification artifact_spec
return unless self.class.islink?(target)
ohai "Removing #{self.class.artifact_english_name} #{self.class.link_type_english_name.downcase}: '#{target}'"
target.delete
end

def install_phase
@cask.artifacts[self.class.artifact_dsl_key].each { |artifact| link(artifact) }
end

def uninstall_phase
@cask.artifacts[self.class.artifact_dsl_key].each { |artifact| unlink(artifact) }
end

def preflight_checks(source, target)
if target.exist? && !self.class.islink?(target)
ohai "It seems there is already #{self.class.artifact_english_article} #{self.class.artifact_english_name} at '#{target}'; not linking."
return false
end
unless source.exist?
raise Hbc::CaskError, "It seems the #{self.class.link_type_english_name.downcase} source is not there: '#{source}'"
end
true
end

def create_filesystem_link(source, target)
Pathname.new(target).dirname.mkpath
@command.run!("/bin/ln", args: ["-hfs", "--", source, target])
Expand Down