Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix machineInfo curl validation" #458

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/org/openj9/envInfo/CmdExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;

public class CmdExecutor {
private static CmdExecutor instance;
Expand All @@ -37,16 +36,9 @@ public String execute(String[] commands) {
String rt = null;
try {
ProcessBuilder builder = new ProcessBuilder(Arrays.asList(commands));
Map<String, String> env = builder.environment();
// clear env and copy from the parent shell environment
env.clear();
Map<String, String> shellEnv = System.getenv();
env.putAll(shellEnv);
System.out.println(String.join(" ",builder.command().toArray(new String[0])));
builder.redirectErrorStream(true);
Process proc = builder.start();
BufferedReader stdOutput = new BufferedReader(new InputStreamReader(proc.getInputStream()));

StringBuilder sb = new StringBuilder();
String line = null;
String newline = "";
Expand Down
27 changes: 12 additions & 15 deletions src/org/openj9/envInfo/MachineInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class MachineInfo {
public static final String[] ANT_VERSION_CMD = new String[] {"bash", "-c", "ant -version"};
public static final String[] MAKE_VERSION_CMD = new String[] {"bash", "-c", "make --version"};
public static final String[] PERL_VERSION_CMD = new String[] {"bash", "-c", "perl --version"};
public static final String[] CURL_VERSION_CMD = new String[] {"bash", "-c", "curl --version | head -n 1 | awk '{ print $2 }'"};
public static final String[] CURL_VERSION_CMD = new String[] {"bash", "-c", "curl --version"};


// Console
Expand Down Expand Up @@ -142,12 +142,11 @@ private void makeSameLength(ArrayList<Integer> list, int requiredLength){
}
}

private boolean validateVersion(Info info, String requriedVersionStr) {
private boolean validateVersion(String versionName, String actualVersionStr, String requriedVersionStr) {
boolean isValid = true;
String actualVersionStr = parseInfo(info.output);
ArrayList<Integer> accVer = versionStr2ArrList(actualVersionStr);
ArrayList<Integer> reqVer = versionStr2ArrList(requriedVersionStr);
try {
ArrayList<Integer> accVer = versionStr2ArrList(actualVersionStr);
ArrayList<Integer> reqVer = versionStr2ArrList(requriedVersionStr);
int accVerLen = accVer.size();
int reqVerLen = reqVer.size();
if (accVerLen > reqVerLen) {
Expand All @@ -163,11 +162,11 @@ private boolean validateVersion(Info info, String requriedVersionStr) {
}
}
if (!isValid) {
System.out.println("Warning: required " + info.name + ": " + requriedVersionStr + ". Output:\n" + info.output);
System.out.println("Error: required " + versionName + ": " + requriedVersionStr + ". Installed version: " + actualVersionStr);
}
} catch (NumberFormatException e){
System.out.println("Warning: "+ info.name + " information cannot be extracted.");
System.out.println(info.name + " output: " + actualVersionStr);
System.out.println("Warning: "+ versionName + " information cannot be extracted.");
System.out.println(versionName + " output: " + actualVersionStr);
}
return isValid;
}
Expand All @@ -176,15 +175,13 @@ private void validateInfo() {
boolean valid = true;
for (Info info : infoMap.values()) {
if (info.req != null) {
valid &= validateVersion(info, info.req);
String version = parseInfo(info.output);
valid &= validateVersion(info.name, version, info.req);
}
}

// Do not fail if the check not pass for the build environment.
// We need to add an option to toggle the failure or warning mode.
// if (!valid) {
// System.exit(1);
//}
if (!valid) {
System.exit(1);
}
}

private void getSysInfo() {
Expand Down