diff --git a/Library/Homebrew/hw.model.c b/Library/Homebrew/hw.model.c deleted file mode 100644 index c2507daeee..0000000000 --- a/Library/Homebrew/hw.model.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - This software is in the public domain, furnished "as is", without technical - support, and with no warranty, express or implied, as to its usefulness for - any purpose. -*/ -#include -#include - -int main() -{ - char buf[32]; - size_t sz = sizeof(buf); - int r = sysctlbyname("hw.model", buf, &sz, NULL, 0); - if (r == 0) - printf("%.*s", sz, buf); - return r; -} diff --git a/Library/Homebrew/hw.model.rb b/Library/Homebrew/hw.model.rb index 86deebd476..9edcdd03fd 100644 --- a/Library/Homebrew/hw.model.rb +++ b/Library/Homebrew/hw.model.rb @@ -21,13 +21,12 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # + +# The output of the command is in the form of: `MacBook2,1' +# This yields: "MacBook", 2, 1 def hw_model_output - require 'fileutils' - HOMEBREW_CACHE.mkpath - exe=HOMEBREW_CACHE+'hw.model' - Kernel.system "gcc -Os #{File.dirname __FILE__}/hw.model.c -o #{exe}" unless exe.file? - /(.*)(\d+),(\d+)/ =~ `#{exe}` - yield $1, $2.to_i, $3.to_i + model=`/usr/sbin/sysctl hw.model`.match /hw.model: (\w+)(\d+),(\d+)/ + yield model[1], model[2].to_i, model[3].to_i end # http://support.apple.com/kb/HT3696 @@ -35,11 +34,11 @@ end def hw_model hw_model_output do |model, major, minor| case model - when "iMac" - if major <=4 + when "iMac" + if major <= 4 :core1 else - $unknown_hw_model=true if major >8 + $unknown_hw_model=true if major > 8 :core2 end