diff --git a/lib/parse-config b/lib/parse-config index 99786f3..c86b9ad 100644 --- a/lib/parse-config +++ b/lib/parse-config @@ -3,7 +3,7 @@ # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: lib/parse-config -# Copyright (C) 2006 The OpenSDE Project +# Copyright (C) 2006 - 2007 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # Copyright (C) 1998 - 2003 Clifford Wolf # @@ -119,6 +119,8 @@ export CMD_WRAPPER_MYPATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper" export CMD_WRAPPER_LOGFILE="" CMD_WRAPPER_DEBUG=0 CMD_WRAPPER_BYPASS=0 export CMD_WRAPPER_NOLOOP=0 ; unset CMD_WRAPPER_OTHERS_TMP +export UNAME_WRAPPER_LOGFILE="" + if [ -f $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config ] then . $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config ; fi diff --git a/scripts/Build-Pkg b/scripts/Build-Pkg index 633691b..24e935e 100755 --- a/scripts/Build-Pkg +++ b/scripts/Build-Pkg @@ -260,6 +260,7 @@ if [ "$SDECFG_FLIST" = "flwrapper" -a -z "$FLWRAPPER" ] ; then fi export INSTALL_WRAPPER_LOGFILE="$builddir/install_wrapper.log" export CMD_WRAPPER_LOGFILE="$builddir/cmd_wrapper.log" +export UNAME_WRAPPER_LOGFILE="$builddir/uname_wrapper.log" if [ $norebuild = 1 -a -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then echo_pkg_deny $stagelevel $pkg "already built" diff --git a/scripts/Build-Tools b/scripts/Build-Tools index 50a35ea..173d8a1 100755 --- a/scripts/Build-Tools +++ b/scripts/Build-Tools @@ -3,7 +3,7 @@ # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: scripts/Build-Tools -# Copyright (C) 2006 The OpenSDE Project +# Copyright (C) 2006 - 2007 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # Copyright (C) 1998 - 2003 Clifford Wolf # @@ -201,51 +201,13 @@ EOT done # echo_status "Building $toolsdir/wrapper/{uname,arch}." - cat << EOT > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/uname.$$ -#!/bin/sh -arch=\$(echo \${arch_machine//-*/} | sed -e 's/sparcv.*/sparc/' -e 's/powerpc/ppc/') - -echo "You should not call uname during the build!" >&2 -if [ -z "\$1" ]; then - echo "Linux" -else - # shorten long options - opts=" \$(echo \$* | sed 's/--all/-a/;s/--kernel-name/-s/;s/--nodename/-n/; - s/--kernel-release/-r/;s/--kernel-version/-v/; - s/--machine/-m/;s/--processor/-p/;')" - # expand combined options - opts=" \$(echo \$opts | sed 's/[^-]/ -&/g ; s/- //g ; s/-a/-m -n -r -s -v/')" - str= - newopts="\${opts// -s/}" - [ "\$newopts" != "\$opts" ] && str="\$str Linux" - opts="\$newopts"; newopts="\${opts// -n/}" - [ "\$newopts" != "\$opts" ] && str="\$str \$(hostname)" - opts="\$newopts"; newopts="\${opts// -r/}" - [ "\$newopts" != "\$opts" ] && str="\$str 2.6.18-inside-sandbox" - opts="\$newopts"; newopts="\${opts// -v/}" - [ "\$newopts" != "\$opts" ] && str="\$str #1: SMP $(date)" - opts="\$newopts"; newopts="\${opts// -m/}" - [ "\$newopts" != "\$opts" ] && str="\$str \$arch" - opts="\$newopts"; newopts="\${opts// -p/}" - [ "\$newopts" != "\$opts" ] && str="\$str unknown" - echo \${str:1} # skip the leading blank ,-) - if [ "\$newopts" ]; then - echo "Unknown option:\$newopts" >&2 - exit 1 - fi -fi -EOT - cat << EOT > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/arch.$$ -#!/bin/sh -echo "You should not call arch during the build!" >&2 -echo "$(echo $arch | arch2uname)" -EOT - chmod +x build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/{uname,arch}.$$ - mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/uname.$$ \ - build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/uname - mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/arch.$$ \ - build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/arch + sed -e "s,@@ARCH_MACHINE@@,$arch_machine,g" \ + src/tools-source/uname_wrapper.in.sh > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/uname + sed -e "s,@@ARCH@@,$( echo $arch | arch2uname ),g" \ + src/tools-source/arch_wrapper.in.sh > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/arch + + chmod +x build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/{uname,arch} wrappers="$wrappers uname arch" # echo_status "Building $toolsdir/wrapper/install_wrapper." diff --git a/src/tools-source/arch_wrapper.in.sh b/src/tools-source/arch_wrapper.in.sh new file mode 100644 index 0000000..6a275ea --- /dev/null +++ b/src/tools-source/arch_wrapper.in.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: src/tools-source/arch_wrapper.in.sh +# Copyright (C) 2007 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +echo @@ARCH@@ diff --git a/src/tools-source/uname_wrapper.in.sh b/src/tools-source/uname_wrapper.in.sh new file mode 100644 index 0000000..501f3c9 --- /dev/null +++ b/src/tools-source/uname_wrapper.in.sh @@ -0,0 +1,136 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: src/tools-source/uname_wrapper.in.sh +# Copyright (C) 2007 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +# command line arguments +opts=asnrvmpio +longopts=all,kernel-name,nodename,kernel-release,kernel-version,machine,processor,hardware-platform,operating-system + +# command line settings +os= +machine= +nodename= +processor= +hardware= +kernel_name= +kernel_release= +kernel_version= + +# validate arguments +[ $# -gt 0 ] || set -- -s + +output= +oldopts="$@" + +if [ -z "$UNAME_WRAPPER_LOGFILE" ]; then +cat >> /tmp/uname.log <> $UNAME_WRAPPER_LOGFILE <<-EOT + $$ uname $oldopts -> $newopts + failed to parse options. + -- + EOT + exit 1 +fi + +set -- $newopts +while [ $# -gt 0 ]; do + case "$1" in + -a|--all) + os=yes + machine=yes + nodename=yes + processor=yes + hardware=yes + kernel_name=yes + kernel_release=yes + kernel_version=yes + ;; + -o|--operating-system) os=yes ;; + -m|--machine) machine=yes ;; + -n|--nodename) nodename=yes ;; + -p|--processor) processor=yes ;; + -i|--hardware-platform) hardware=yes ;; + -s|--kernel-name) kernel_name=yes ;; + -r|--kernel-release) kernel_release=yes ;; + -v|--kernel-version) kernel_version=yes ;; + --) shift; break ;; + esac + shift +done + +# kernel name - Linux +[ -z "$kernel_name" ] || output="$output Linux" + +# network node hostname - `hostname` +[ -z "$nodename" ] || output="$output $( hostname )" + +# kernel release - TODO: try to guess something useful +if [ -n "$kernel_release" ]; then + ver= ver0= + + # do i have kernel sources? + if [ -L $root/usr/src/linux ]; then + ver=$( readlink $root/usr/src/linux | cut -d- -f2- ) + elif [ -r $root/var/adm/packages/linux26 ]; then + ver0=$( sed -n -e 's,^Package Name and Version: [^ ]\+ \([^ ]\+\) .*,\1,p' $root/var/adm/packages/linux26 ) + ver=$( ls -1t $root/boot/vmlinuz_${ver0}* | sed -e 's,.*/vmlinuz_\(.*\),\1,' | tail -n 1 ) + elif [ -r $root/var/adm/packages/linux-header ]; then + ver0=$( sed -n -e 's,^Package Name and Version: [^ ]\+ \([^ ]\+\) .*,\1,p' $root/var/adm/packages/linux-header ) + fi + + if [ -z "$ver" -a -n "$ver0" ]; then + ver="$ver0-inside-sandbox" + elif [ -z "$ver" -a -z "$ver0" ]; then + ver="2.6.18-wrapper-could-not-guess" + fi + + output="$output $ver" +fi + +# kernel version - #1 SMP Fri Nov 24 23:49:57 CLST 2006 +[ -z "$kernel_version" ] || output="$output #1 SMP $(date)" + +# machine hardware name - $arch_machine +[ -z "$machine" ] || output="$output @@ARCH_MACHINE@@" + +# processor type - FIXME: unknown +[ -z "$processor" ] || output="$output unknown" + +# hardware platform - FIXME: unknown +[ -z "$hardware" ] || output="$output unknown" + +# operating system - GNU/Linux +[ -z "$os" ] || output="$output GNU/Linux" + +# remove the heading space +output=$( echo $output ) + +cat >> $UNAME_WRAPPER_LOGFILE <