Commit 6777ac35 by 袁津

[chg]VVAS-JNI:增加对Ubuntu的支持,主要是lib库的重编译

1 parent eca18a6b
Showing 33 changed files with 38 additions and 0 deletions
......@@ -9,8 +9,10 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import sun.security.action.GetPropertyAction;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
......@@ -43,8 +45,17 @@ public class JNIApp implements CommandLineRunner {
Resource[] resources = null;
Resource[] preResources = null;
if (System.getProperty("os.name").toLowerCase().contains("linux")) {
// 获取操作系统版本(仅针对Ubuntu)
String osVersion = getOSVersion();
if (osVersion.equals("16.04")) {
log.info("操作系统版本为[16.04],加载[preso、so]");
resources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/so/*");
preResources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/preso/*");
} else if (osVersion.contains("18.04")) {
log.info("操作系统版本为[18.04],加载[preso1804、so1804]");
resources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/so1804/*");
preResources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/preso1804/*");
}
} else if (System.getProperty("os.name").toLowerCase().contains("windows")) {
resources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/dll/*");
preResources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/predll/*");
......@@ -95,4 +106,31 @@ public class JNIApp implements CommandLineRunner {
log.error("", e);
}
}
/**
* 获取操作系统版本
*
* @return
*/
private String getOSVersion() {
String osVersion = "";
String[] cmd = {"/bin/sh", "-c", "cat /etc/*-release"};
try {
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = bri.readLine()) != null) {
if (line.contains("DISTRIB_RELEASE")) {
osVersion = line.split("=")[1];
}
log.info(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return osVersion;
}
}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!