Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Properly identify uncompressed POSIX tar and rar #10226

Closed
wants to merge 1 commit into from

3 participants

@RuiPereira

The first 6 bytes are not enough to identify POSIX
uncompressed tars (257 bytes offset), so changed
the magic_bytes to read the first 262 bytes, and
also fixed rar archive identification.

@RuiPereira RuiPereira Properly identify uncompressed POSIX tar and rar
The first 6 bytes are not enough to identify POSIX
uncompressed tars (257 bytes offset), so changed 
the magic_bytes to read the first 262 bytes, and
also fixed rar archive identification.
cde8cdc
@mikemcquaid
Owner

Does this actually break on any formulae as-is? We'll need to heavily test this before adding.

@RuiPereira

I'm writing a formula which uses an uncompressed tar (http://www.sdsc.edu/srb/tarfiles/SRB3_4_2client.tar) so it broke for me. The only formula with a .rar is net-nuclear.rb so it will break there also.

@adamv
Owner

Though oddly net-nuclear downloads and builds fine.

@RuiPereira

Hi. Sorry for the delay, but only with the recently commited autotools I was able to install libmikmod (on which net-nuclear depends). net-nuclear does not install for me:

$ brew install -v net-nuclear
==> Downloading http://studiostok.se/files/netnuclear4-source.rar
/usr/bin/curl -qf#LA Homebrew 0.8.1 (Ruby 1.8.7-249; Mac OS X 10.7.3) http://studiostok.se/files/netnuclear4-source.rar -o /Users/rui/Library/Caches/Homebrew/net-nuclear-4.rar
######################################################################## 100.0%
Error: No such file or directory - Makefile

It installs with my patch, even though it explodes while launching.

@adamv
Owner

This seems to be fixed in 439aa84

@adamv adamv closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. @RuiPereira

    Properly identify uncompressed POSIX tar and rar

    RuiPereira authored
    The first 6 bytes are not enough to identify POSIX
    uncompressed tars (257 bytes offset), so changed 
    the magic_bytes to read the first 262 bytes, and
    also fixed rar archive identification.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 Library/Homebrew/download_strategy.rb
View
9 Library/Homebrew/download_strategy.rb
@@ -76,8 +76,9 @@ def stage
# Use more than 4 characters to not clash with magicbytes
magic_bytes = "____pkg"
else
- # get the first six bytes
- File.open(@tarball_path) { |f| magic_bytes = f.read(6) }
+ # get 6 bytes magic number
+ # (POSIX tar magic has a 257 bytes offset)
+ File.open(@tarball_path) { |f| magic_bytes = f.read(262) }
end
# magic numbers stolen from /usr/share/file/magic/
@@ -85,7 +86,7 @@ def stage
when /^PK\003\004/ # .zip archive
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path
chdir
- when /^\037\213/, /^BZh/, /^\037\235/ # gzip/bz2/compress compressed
+ when /ustar$/, /^\037\213/, /^BZh/, /^\037\235/ # uncompressed/gzip/bz2/compress
# TODO check if it's really a tar archive
safe_system '/usr/bin/tar', 'xf', @tarball_path
chdir
@@ -96,7 +97,7 @@ def stage
when '____pkg'
safe_system '/usr/sbin/pkgutil', '--expand', @tarball_path, File.basename(@url)
chdir
- when 'Rar!'
+ when /^Rar!/
quiet_safe_system 'unrar', 'x', {:quiet_flag => '-inul'}, @tarball_path
else
# we are assuming it is not an archive, use original filename
Something went wrong with that request. Please try again.