Re: [PATCH 2/24] ver_linux: path2bin_test.patch

From: Alexander Kapshuk
Date: Sun Oct 04 2015 - 08:24:51 EST


On Sat, Oct 3, 2015 at 4:10 PM, Alexander Kapshuk
<alexander.kapshuk@xxxxxxxxx> wrote:
> As suggested by Jim Davis <jim.epost@xxxxxxxxx>, this patch checks for
> binaries in the user's $PATH first by calling 'which name-of-binary'. If
> the binary is not found there, an attempt is made to find it elsewhere
> on the system. 'whereis name-of-binary' is used to that end.
>
> Below is Jim's reasoning behind the suggestion made:
> Though looking back at your patch, what might work is to look first
> for depmod in the user's $PATH and then try whereis only if that fails.
> I'm not convinced that's much better than just searching $PATH, but that
> at least would go with the user's preference first.
>
> Tested on:
> Gentoo Linux
> Debian 6.0.10
> Oracle Linux Server release 7.1
>
> Signed-off-by: Alexander Kapshuk <alexander.kapshuk@xxxxxxxxx>
> ---
> --- linux/scripts/ver_linux.orig 2015-10-03 13:41:57.118790241 +0300
> +++ linux/scripts/ver_linux 2015-10-03 13:46:25.879768460 +0300
> @@ -11,6 +11,166 @@
> uname -a
> echo ' '
>
> +gcc=`which gcc 2>/dev/null`
> +test -n "$gcc" ||
> +gcc=`whereis gcc |
> + sed '/\/gcc/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +make=`which make 2>/dev/null`
> +test -n "$make" ||
> +make=`whereis make |
> + sed '/\/make/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +ld=`which ld 2>/dev/null`
> +test -n "$ld" ||
> +ld=`whereis ld |
> + sed '/\/ld/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +mount=`which mount 2>/dev/null`
> +test -n "$mount" ||
> +mount=`whereis mount |
> + sed '/\/mount/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +depmod=`which depmod 2>/dev/null`
> +test -n "$depmod" ||
> +depmod=`whereis depmod |
> + sed '/\/depmod/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +tune2fs=`which tune2fs 2>/dev/null`
> +test -n "$tune2fs" ||
> +tune2fs=`whereis tune2fs |
> + sed '/\/tune2fs/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +fsckjfs=`which fsck.jfs 2>/dev/null`
> +test -n "$fsckjfs" ||
> +fsckjfs=`whereis fsck.jfs |
> + sed '/\/fsck.jfs/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +reiserfsck=`which reiserfsck 2>/dev/null`
> +test -n "$reiserfsck" ||
> +reiserfsck=`whereis reiserfsck |
> + sed '/\/reiserfsck/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +xfs_db=`which xfs_db 2>/dev/null`
> +test -n "$xfs_db" ||
> +xfs_db=`whereis xfs_db |
> + sed '/\/xfs_db/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +pccardctl=`which pccardctl 2>/dev/null`
> +test -n "$pccardctl" ||
> +pccardctl=`whereis pccardctl |
> + sed '/\/pccardctl/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +quota=`which quota 2>/dev/null`
> +test -n "$quota" ||
> +quota=`whereis quota |
> + sed '/\/quota/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +pppd=`which pppd 2>/dev/null`
> +test -n "$pppd" ||
> +pppd=`whereis pppd |
> + sed '/\/pppd/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +ldd=`which ldd 2>/dev/null`
> +test -n "$ldd" ||
> +ldd=`whereis ldd |
> + sed '/\/ldd/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +ldconfig=`which ldconfig 2>/dev/null`
> +test -n "$ldconfig" ||
> +ldconfig=`whereis ldconfig |
> + sed '/\/ldconfig/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +ps=`which ps 2>/dev/null`
> +test -n "$ps" ||
> +ps=`whereis ps |
> + sed '/\/ps/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +ifconfig=`which ifconfig 2>/dev/null`
> +test -n "$ifconfig" ||
> +ifconfig=`whereis ifconfig |
> + sed '/\/ifconfig/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +loadkeys=`which loadkeys 2>/dev/null`
> +test -n "$loadkeys" ||
> +loadkeys=`whereis loadkeys |
> + sed '/\/loadkeys/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +expr=`which expr 2>/dev/null`
> +test -n "$expr" ||
> +expr=`whereis expr |
> + sed '/\/expr/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +udev=`which udevadm 2>/dev/null`
> +test -n "$udev" ||
> +udev=`whereis udevadm |
> + sed '/\/udevadm/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> +iwconfig=`which iwconfig 2>/dev/null`
> +test -n "$iwconfig" ||
> +iwconfig=`whereis iwconfig |
> + sed '/\/iwconfig/!d
> + s/.*:[ \t]//
> + s/[ \t].*//'
> +`
> +
> gcc -dumpversion 2>&1| awk \
> 'NR==1{print "Gnu C ", $1}'


About this patch...

It is probably better to have the user set their $PATH appropriately
in their shell environment as suggested in the commentary found in
ver_linux, rather than have ver_linux guess where the binaries are.

So, please do not apply this patch, unless you think otherwise. Thanks.

As far as the other ver_linux patches I have sent in is concerned, if
you consider any, or all of them to be over-engineered, please do not
apply them.

Apologies for the confusion, or trouble caused.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/