Leave permissions of installed files in sensible state

No write permission for files, executable when required etc.
This commit is contained in:
Max Howell 2009-06-26 13:05:48 +01:00
parent 9f9d95c134
commit a648e46d8a
3 changed files with 27 additions and 15 deletions

View File

@ -98,7 +98,10 @@ class Pathname
end end
def install src def install src
FileUtils.mv src, to_s if File.exist? src
mkpath
FileUtils.mv src, to_s
end
end end
def cp dst def cp dst
@ -166,12 +169,6 @@ class AbstractFormula
# end ruby is weird section # end ruby is weird section
end end
private
def maybe_mkpath path
path.mkpath unless path.exist?
return path
end
public public
def prefix def prefix
raise "@name.nil!" if @name.nil? raise "@name.nil!" if @name.nil?
@ -179,22 +176,22 @@ public
$cellar+@name+@version $cellar+@name+@version
end end
def bin def bin
maybe_mkpath prefix+'bin' prefix+'bin'
end end
def doc def doc
maybe_mkpath prefix+'share'+'doc'+name prefix+'share'+'doc'+name
end end
def man def man
maybe_mkpath prefix+'share'+'man' prefix+'share'+'man'
end end
def man1 def man1
maybe_mkpath prefix+'share'+'man'+'man1' prefix+'share'+'man'+'man1'
end end
def lib def lib
maybe_mkpath prefix+'lib' prefix+'lib'
end end
def include def include
maybe_mkpath prefix+'include' prefix+'include'
end end
def caveats def caveats
@ -247,14 +244,23 @@ public
else else
fo=`file -h #{path}` fo=`file -h #{path}`
args=nil args=nil
chmod=0444
args='-SxX' if fo =~ /Mach-O dynamically linked shared library/ args='-SxX' if fo =~ /Mach-O dynamically linked shared library/
args='' if fo =~ /Mach-O executable/ #defaults strip everything if fo =~ /Mach-O executable/ #defaults strip everything
args='' # still do the strip
chmod=0544
end
if args if args
puts "Stripping: #{path}" if ARGV.include? '--verbose' puts "Stripping: #{path}" if ARGV.include? '--verbose'
path.chmod 0644 # so we can strip
`strip #{args} #{path}` `strip #{args} #{path}`
end end
path.chmod chmod
end end
end} end}
# remove empty directories
`perl -MFile::Find -e"finddepth(sub{rmdir},'#{prefix}')"`
end end
protected protected
@ -328,7 +334,7 @@ end
class Formula <UnidentifiedFormula class Formula <UnidentifiedFormula
def initialize name def initialize name
super name super name
@version=extract_version Pathname.new(File.basename(@url)).stem @version=extract_version Pathname.new(File.basename(@url)).stem unless @version
end end
end end

View File

@ -42,6 +42,11 @@ class BeerTasting <Test::Unit::TestCase
assert_equal 'R13B', r.version assert_equal 'R13B', r.version
end end
def test_p7zip_version_style
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2"
assert_equal '9.04', r.version
end
def test_astyle_verson_style def test_astyle_verson_style
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz" r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
assert_equal '1.23', r.version assert_equal '1.23', r.version

View File

@ -82,6 +82,7 @@ end
def rm keg def rm keg
#TODO if multiple versions don't rm all unless --force #TODO if multiple versions don't rm all unless --force
path=$cellar+keg path=$cellar+keg
`chmod -R u+rw #{path}` # we leave things read only
path.rmtree path.rmtree
puts "#{path} removed (#{prune} files)" puts "#{path} removed (#{prune} files)"
end end