Skip to contentSkip to conversation

tools/perf: fix use of alternatives to find JDIR

PATCH In review Jarod Wilson 4 participants 5 messages Sep 6, 2018 – Oct 18, 2018 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf: fix use of alternatives to find JDIR

When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...

/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.

The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.

CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
CC Alexander Shishkin <[email protected]>
CC Jiri Olsa <[email protected]>
CC Namhyung Kim <[email protected]>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
index f6d1a03c7523..e30d20fb482d 100644
@@ -833,7 +833,7 @@ ifndef NO_JVMTI
     JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
   else
     ifneq (,$(wildcard /usr/sbin/alternatives))
-      JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
     endif
   endif
   ifndef JDIR
Signature · 1 line
2.16.1
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Jarod Wilson

When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...

/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.

The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.

Quoted 7 lines
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
CC Alexander Shishkin <[email protected]>
CC Jiri Olsa <[email protected]>
CC Namhyung Kim <[email protected]>

thanks,
jirka

#2 lore raw
Quoted 28 lines · Jiri Olsa
Quoted 19 lines · Jarod Wilson

When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...

/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.

The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.

Quoted 7 lines
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
CC Alexander Shishkin <[email protected]>
CC Jiri Olsa <[email protected]>
CC Namhyung Kim <[email protected]>
Quoted 1 line

Arnaldo,
could you please pull in this one?

thanks,
jirka

#3 lore raw

Em Tue, Oct 16, 2018 at 03:09:59PM +0200, Jiri Olsa escreveu:

Quoted 29 lines · Jiri Olsa
Quoted 28 lines · Jarod Wilson
Quoted 26 lines

When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...

/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.

The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.

CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
CC Alexander Shishkin <[email protected]>
CC Jiri Olsa <[email protected]>
CC Namhyung Kim <[email protected]>
Quoted 4 lines
Quoted 1 line

Arnaldo,
could you please pull in this one?

Sure, I thought I had already, will now.

- Arnaldo

#4 lore raw

[tip:perf/urgent] perf tools: Fix use of alternatives to find JDIR

In reply to Jarod Wilson
perf tools: Fix use of alternatives to find JDIR
Commit-ID:  36b8d4628d3cc8f5a748e508cce8673bc00fc63c
Gitweb:     https://git.kernel.org/tip/36b8d4628d3cc8f5a748e508cce8673bc00fc63c
Author:     Jarod Wilson <[email protected]>
AuthorDate: Thu, 6 Sep 2018 18:18:12 -0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 16 Oct 2018 12:06:47 -0300

perf tools: Fix use of alternatives to find JDIR

When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...

/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.

The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.

Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc William Cohen <[email protected]>
Fixes d4dfdf00d43e ("perf jvmti: Plug compilation into perf build")
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
index f6d1a03c7523..e30d20fb482d 100644
@@ -833,7 +833,7 @@ ifndef NO_JVMTI
     JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
   else
     ifneq (,$(wildcard /usr/sbin/alternatives))
-      JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
     endif
   endif
   ifndef JDIR