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

Add preliminary RPM support #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions bin/brew2deb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ if ARGV.include? 'clean'
end

$:.unshift File.expand_path('../../lib', __FILE__)
require 'common_formula'
require 'debian_formula'
require 'redhat_formula'

Object.__send__ :remove_const, :HOMEBREW_CACHE
HOMEBREW_WORKDIR = Pathname.new(Dir.pwd)
Expand Down
45 changes: 45 additions & 0 deletions lib/common_formula.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$:.unshift File.expand_path('../../homebrew/Library/Homebrew', __FILE__)
require 'tempfile'
require 'global'
require 'formula'

class String
# Useful for writing indented String and unindent on demand, based on the
# first line with indentation.
def unindent
find_indent = proc{ |l| l.find{|l| !l.strip.empty?}.to_s[/^(\s+)/, 1] }

lines = self.split("\n")
space = find_indent[lines]
space = find_indent[lines.reverse] unless space

strip.gsub(/^#{space}/, '')
end
alias ui unindent

# Destructive variant of undindent, replacing the String
def unindent!
self.replace unindent
end
alias ui! unindent!
end

class Formula
def self.attr_rw_list(*attrs)
attrs.each do |attr|
instance_variable_set("@#{attr}", [])
class_eval %Q{
def self.#{attr}(*list)
@#{attr} ||= superclass.respond_to?(:#{attr}) ? superclass.#{attr} : []
list.empty? ? @#{attr} : @#{attr} += list
@#{attr}.uniq!
@#{attr}
end
def self.#{attr}!(*list)
@#{attr} = []
#{attr}(*list)
end
}
end
end
end
46 changes: 1 addition & 45 deletions lib/debian_formula.rb
Original file line number Diff line number Diff line change
@@ -1,48 +1,4 @@
$:.unshift File.expand_path('../../homebrew/Library/Homebrew', __FILE__)
require 'tempfile'
require 'global'
require 'formula'

class String
# Useful for writing indented String and unindent on demand, based on the
# first line with indentation.
def unindent
find_indent = proc{ |l| l.find{|l| !l.strip.empty?}.to_s[/^(\s+)/, 1] }

lines = self.split("\n")
space = find_indent[lines]
space = find_indent[lines.reverse] unless space

strip.gsub(/^#{space}/, '')
end
alias ui unindent

# Destructive variant of undindent, replacing the String
def unindent!
self.replace unindent
end
alias ui! unindent!
end

class Formula
def self.attr_rw_list(*attrs)
attrs.each do |attr|
instance_variable_set("@#{attr}", [])
class_eval %Q{
def self.#{attr}(*list)
@#{attr} ||= superclass.respond_to?(:#{attr}) ? superclass.#{attr} : []
list.empty? ? @#{attr} : @#{attr} += list
@#{attr}.uniq!
@#{attr}
end
def self.#{attr}!(*list)
@#{attr} = []
#{attr}(*list)
end
}
end
end
end
require 'common_formula'

class DebianFormula < Formula
attr_rw :name, :description
Expand Down
Loading