Skip to content

Commit

Permalink
Merge pull request #543 from zarvox/remove-file-dependency
Browse files Browse the repository at this point in the history
rustup-init: remove dependency on `file` command
  • Loading branch information
brson authored Jun 23, 2016
2 parents 48b7e53 + 7032684 commit ddb0d1b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ get_architecture() {

# Detect 64-bit linux with 32-bit userland
if [ $_ostype = unknown-linux-gnu -a $_cputype = x86_64 ]; then
local _bin_to_probe="/usr/bin/env"
if [ -e "$_bin_to_probe" ]; then
need_cmd file
file -L "$_bin_to_probe" | grep -q "x86[_-]64"
if [ $? != 0 ]; then
local _cputype=i686
fi
need_cmd head
# Architecture detection without dependencies beyond coreutils.
# ELF files start out "\x7fELF", and the following byte is
# 0x01 for 32-bit and
# 0x02 for 64-bit.
# The printf builtin on some shells like dash only supports octal
# escape sequences, so we use those.
local _current_exe_head=$(head -c 5 /proc/self/exe )
if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then
local _cputype=i686
fi
fi

Expand Down

0 comments on commit ddb0d1b

Please sign in to comment.