This helps in case then user doesn't have dmidecode in his PATH. For example, if user elevates his privileges with sudo, then he may not inherit some superuser's environmental variables ($PATH, contaning additional directories - /sbin, /usr/sbin and similar).
In case of failure to determine full path to dmidecode it just fallbacks to the default value.
Tested only on Linux.
Signed-off-by: Peter Lemenkov lemenkov@gmail.com --- Makefile | 5 ++++- dmi.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index e83fc0b..7919e10 100644 --- a/Makefile +++ b/Makefile @@ -169,6 +169,9 @@ CONFIG_DEDIPROG ?= no # Disable wiki printing by default. It is only useful if you have wiki access. CONFIG_PRINT_WIKI ?= no
+# Try to detect full path for dmidecode +CONFIG_DMIDECODE_PATH ?= $(shell LC_ALL=C type -p dmidecode 2>/dev/null || echo "dmidecode") + ifeq ($(CONFIG_INTERNAL), yes) FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o @@ -323,7 +326,7 @@ $(PROGRAM)$(EXEC_SUFFIX): $(OBJS) TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
%.o: %.c .features - $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $< + $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -DCONFIG_DMIDECODE_PATH="$(CONFIG_DMIDECODE_PATH)" -o $@ -c $<
# Make sure to add all names of generated binaries here. # This includes all frontends and libflashrom. diff --git a/dmi.c b/dmi.c index f18907f..d483acb 100644 --- a/dmi.c +++ b/dmi.c @@ -55,7 +55,7 @@ static const char *dmidecode_names[] = { };
#define DMI_COMMAND_LEN_MAX 260 -static const char *dmidecode_command = "dmidecode"; +static const char *dmidecode_command = CONFIG_DMIDECODE_PATH;
static char *dmistrings[ARRAY_SIZE(dmidecode_names)];
Hi Peter,
thanks for your patch. Unfortunately this breaks cross-compilation under Linux for DOS because "/usr/sbin/dmidecode" won't work in a DOS binary, whereas "dmidecode" works because of the implicit .exe extension.
On 12.09.2010 11:13, Peter Lemenkov wrote:
This helps in case then user doesn't have dmidecode in his PATH. For example, if user elevates his privileges with sudo, then he may not inherit some superuser's environmental variables ($PATH, contaning additional directories - /sbin, /usr/sbin and similar).
Your observation is correct, and I would love to get a cross-platform fix for it. One way to do this would be to keep the "dmidecode" string as is if we're doing cross compilation. Another way would be an additional internal programmer parameter like this: flashrom -p internal:dmidecode_path=/usr/sbin/dmidecode Yet another solution would be to finally integrate the internal dmi decoder patch into flashrom and kill the dmidecode dependency that way.
In case of failure to determine full path to dmidecode it just fallbacks to the default value.
Tested only on Linux.
What do you think of my suggestions above?
Regards, Carl-Daniel
Hello!
2010/9/14 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net:
One way to do this would be to keep the "dmidecode" string as is if we're doing cross compilation. Another way would be an additional internal programmer parameter like this: flashrom -p internal:dmidecode_path=/usr/sbin/dmidecode Yet another solution would be to finally integrate the internal dmi decoder patch into flashrom and kill the dmidecode dependency that way.
...
What do you think of my suggestions above?
I'm pretty sure that adding a small out-of-tree patch which just substitutes "dmidecode" string in dmi.c with full path to dmidecode would be a much simpler solution than trying to overcome all these difficulties, so please disregard this particular patch.