X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=autoconfig.functions;fp=autoconfig.functions;h=0da044d51955f548148af419b6e7ec2eb629037b;hp=4a8b167619407add5dd8098ffc9a07a8beafd9e6;hb=74eef776a281bca6f6d6f089b065cb01dc600196;hpb=bd414ee95f95b6c77d636aba947db0a16ab87618 diff --git a/autoconfig.functions b/autoconfig.functions index 4a8b167..0da044d 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -905,19 +905,23 @@ fi # -z $INSTALLED # {{{ CPU-detection config_cpu(){ -if checkbootparam 'nocpu'; then - ewarn "Skipping CPU detection as requested on boot commandline." ; eend 0 - return 0 -fi + if checkbootparam 'nocpu'; then + ewarn "Skipping CPU detection as requested on boot commandline." ; eend 0 + return 0 + fi -if [[ $(grep -c processor /proc/cpuinfo) -gt 1 ]] ; then - einfo "Found CPU:" - CPU=$(awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG) - echo $CPU | sed 's/ \{1,\}/ /g' - eend 0 -else - einfo "Found CPU: `awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG` " ; eend 0 -fi + if ! [ -x "$(which lscpu)" ] ; then + ewarn "Skipping CPU detection due to lack of lscpu."; eend 0 + return 0 + fi + + local cpu_info num_cpus + + cpu_info="$(lscpu | sed -n '/^Model name:/s/[^:]*:\s*//p')" + num_cpus=$(grep -c processor /proc/cpuinfo) + + einfo "Found ${num_cpus} CPU(s): ${cpu_info}" + eend 0 } # }}}