Skip to content

Commit 74fd567

Browse files
authored
Merge pull request #51 from AdityaHirapara/LOC-1636_Alpine_binary
Detect Alpine linux and download specific binary
2 parents a33fabb + 7f2844f commit 74fd567

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

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

Lines changed: 5 additions & 0 deletions
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

@@ -139,6 +141,9 @@ private void makeCommand(Map<String, String> options, String opCode) {
139141
command.add("--key");
140142
command.add(options.get("key"));
141143

144+
command.add("--source");
145+
command.add("java-" + packageVersion);
146+
142147
for (Map.Entry<String, String> opt : options.entrySet()) {
143148
String parameter = opt.getKey().trim();
144149
if (IGNORE_KEYS.contains(parameter)) {

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)