aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-06-26 13:05:48 +0100
committerMax Howell2009-06-26 13:05:48 +0100
commita648e46d8ae6aa6566da29492a1c27d675561115 (patch)
tree82c6afe891ca44586294afbad5878fbc5037eacb /Library
parent9f9d95c13466c7e90ff503b96190ece7abce510a (diff)
downloadbrew-a648e46d8ae6aa6566da29492a1c27d675561115.tar.bz2
Leave permissions of installed files in sensible state
No write permission for files, executable when required etc.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brewkit.rb36
-rwxr-xr-xLibrary/Homebrew/unittest.rb5
2 files changed, 26 insertions, 15 deletions
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index 678655274..70785fa1a 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -98,7 +98,10 @@ class Pathname
end
def install src
- FileUtils.mv src, to_s
+ if File.exist? src
+ mkpath
+ FileUtils.mv src, to_s
+ end
end
def cp dst
@@ -166,12 +169,6 @@ class AbstractFormula
# end ruby is weird section
end
-private
- def maybe_mkpath path
- path.mkpath unless path.exist?
- return path
- end
-
public
def prefix
raise "@name.nil!" if @name.nil?
@@ -179,22 +176,22 @@ public
$cellar+@name+@version
end
def bin
- maybe_mkpath prefix+'bin'
+ prefix+'bin'
end
def doc
- maybe_mkpath prefix+'share'+'doc'+name
+ prefix+'share'+'doc'+name
end
def man
- maybe_mkpath prefix+'share'+'man'
+ prefix+'share'+'man'
end
def man1
- maybe_mkpath prefix+'share'+'man'+'man1'
+ prefix+'share'+'man'+'man1'
end
def lib
- maybe_mkpath prefix+'lib'
+ prefix+'lib'
end
def include
- maybe_mkpath prefix+'include'
+ prefix+'include'
end
def caveats
@@ -247,14 +244,23 @@ public
else
fo=`file -h #{path}`
args=nil
+ chmod=0444
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
puts "Stripping: #{path}" if ARGV.include? '--verbose'
+ path.chmod 0644 # so we can strip
`strip #{args} #{path}`
end
+ path.chmod chmod
end
end}
+
+ # remove empty directories
+ `perl -MFile::Find -e"finddepth(sub{rmdir},'#{prefix}')"`
end
protected
@@ -328,7 +334,7 @@ end
class Formula <UnidentifiedFormula
def initialize 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
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index 68856baef..f3e24c407 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -42,6 +42,11 @@ class BeerTasting <Test::Unit::TestCase
assert_equal 'R13B', r.version
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
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
assert_equal '1.23', r.version