Skip to content

Commit fb5843e

Browse files
Add alpine support with fix and --source option
1 parent 1de4e8f commit fb5843e

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/main/java/com/browserstack/local/Local.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class Local {
2222

2323
private LocalProcess proc = null;
2424

25+
// Current version of binding package, used for --source option of binary
26+
private final String packageVersion = "1.0.5";
2527
private final Map<String, String> parameters;
2628
private final Map<String, String> avoidValueParameters;
2729

@@ -138,6 +140,8 @@ private void makeCommand(Map<String, String> options, String opCode) {
138140
command.add(opCode);
139141
command.add("--key");
140142
command.add(options.get("key"));
143+
command.add("--source");
144+
command.add("java-" + packageVersion);
141145

142146
for (Map.Entry<String, String> opt : options.entrySet()) {
143147
String parameter = opt.getKey().trim();
@@ -176,8 +180,14 @@ private boolean isProcessRunning(int pid) throws Exception {
176180
}
177181
else {
178182
//ps exit code 0 if process exists, 1 if it doesn't
183+
cmd.add("/bin/sh");
184+
cmd.add("-c");
179185
cmd.add("ps");
180-
cmd.add("-p");
186+
cmd.add("-o");
187+
cmd.add("pid=");
188+
cmd.add("|");
189+
cmd.add("grep");
190+
cmd.add("-w");
181191
cmd.add(String.valueOf(pid));
182192
}
183193

src/main/java/com/browserstack/local/LocalBinary.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class LocalBinary {
1212

13-
private static final String BIN_URL = "https://s3.amazonaws.com/browserStack/browserstack-local/";
13+
private static final String BIN_URL = "https://bstack-local-prod.s3.amazonaws.com/";
1414

1515
private String httpPath;
1616

@@ -40,15 +40,33 @@ private void initialize() throws LocalException {
4040
} else if (osname.contains("mac") || osname.contains("darwin")) {
4141
binFileName = "BrowserStackLocal-darwin-x64";
4242
} else if (osname.contains("linux")) {
43-
String arch = System.getProperty("os.arch");
44-
binFileName = "BrowserStackLocal-linux-" + (arch.contains("64") ? "x64" : "ia32");
43+
if (isAlpine()) {
44+
binFileName = "BrowserStackLocal-alpine";
45+
} else {
46+
String arch = System.getProperty("os.arch");
47+
binFileName = "BrowserStackLocal-linux-" + (arch.contains("64") ? "x64" : "ia32");
48+
}
4549
} else {
4650
throw new LocalException("Failed to detect OS type");
4751
}
4852

4953
httpPath = BIN_URL + binFileName;
5054
}
5155

56+
private boolean isAlpine() {
57+
String[] cmd = { "/bin/sh", "-c", "grep -w \"NAME\" /etc/os-release" };
58+
boolean flag = false;
59+
60+
try {
61+
Process os = Runtime.getRuntime().exec(cmd);
62+
BufferedReader stdout = new BufferedReader(new InputStreamReader(os.getInputStream()));
63+
64+
flag = stdout.readLine().contains("Alpine");
65+
} finally {
66+
return flag;
67+
}
68+
}
69+
5270
private void checkBinary() throws LocalException{
5371
boolean binaryWorking = validateBinary();
5472

0 commit comments

Comments
 (0)