From ef6cd59b612d7f814ff6dd8fc932f87c95f0ced4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 16 Sep 2011 00:10:15 +0200 Subject: [PATCH] Add better uname replacement. Supports faking kernel release and supports ARM. --- lfs/coreutils | 6 ++---- src/scripts/uname | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/scripts/uname diff --git a/lfs/coreutils b/lfs/coreutils index 6e78e3af49..c4aa9db02b 100644 --- a/lfs/coreutils +++ b/lfs/coreutils @@ -107,15 +107,13 @@ ifeq "$(ROOT)" "" ln -sf test /bin/[ #ln -sf ../../bin/install /usr/bin mv -f /bin/uname /bin/uname.bak - echo '#!/bin/bash' > /bin/uname - echo '/bin/uname.bak $$* | sed 's/i.86/$(MACHINE)/g'' >> /bin/uname + cp -vf $(DIR_SRC)/src/scripts/uname /bin/uname chmod 755 /bin/uname dircolors -p > /etc/dircolors else rm /tools/bin/hostname mv -f /tools/bin/uname /tools/bin/uname.bak - echo '#!/bin/bash' > /tools/bin/uname - echo '/tools/bin/uname.bak $$* | sed 's/i.86/$(MACHINE)/g'' >> /tools/bin/uname + cp -vf $(DIR_SRC)/src/scripts/uname /tools/bin/uname chmod 755 /tools/bin/uname endif @rm -rf $(DIR_APP) diff --git a/src/scripts/uname b/src/scripts/uname new file mode 100644 index 0000000000..b76b530433 --- /dev/null +++ b/src/scripts/uname @@ -0,0 +1,32 @@ +#!/bin/sh + +uname= +for i in /bin/uname.bak /tools/bin/uname.bak; do + if [ -x "$i" ]; then + uname=${i} + break + fi +done + +if [ -z "${uname}" ]; then + exit 127 +fi + +machine=$(${uname} -m) +kernel=$(${uname} -r) +output=$(${uname} $@) + +# Overwrite kernel version to hack kernel 3.x versions. +output=$(sed -e "s/${kernel}/${KVER}/g" <<<${output}) + +case "${machine}" in + arm*) + echo "${output}" | \ + sed -e "s/armv.tej?l?/${MACHINE}/g" + ;; + + i?86) + echo "${output}" | \ + sed -e "s/i.86/${MACHINE}/g" + ;; +esac -- 2.39.5