arch: Modified emulator directory structure.
authorminkee.lee <minkee.lee@samsung.com>
Mon, 27 Apr 2015 08:21:02 +0000 (17:21 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Mon, 27 Apr 2015 08:21:02 +0000 (17:21 +0900)
Change-Id: I70fb534bbb255d162ce17afa2612f4a989668f73
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
common-project/src/org/tizen/emulator/manager/platform/Platform.java
common-project/src/org/tizen/emulator/manager/platform/PlatformList.java
common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java
common-project/src/org/tizen/emulator/manager/vms/Creator.java
common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java

index dfc2666..f8fdf18 100644 (file)
@@ -67,8 +67,10 @@ public class Platform {
 
        public Platform(String name) {
                this.platformName = name;
-               this.platformPath = FilePathResources.getPlatformsPath()
-                               + File.separator + platformName;
+//             this.platformPath = FilePathResources.getPlatformsPath()
+//                             + File.separator + platformName;
+               this.platformPath = FilePathResources.getPlatformsPath() + File.separator
+                               + getPlatformPath(platformName);
 
                loadProperties();
                if (!imageList.isEmpty()) {
@@ -78,6 +80,17 @@ public class Platform {
                }
        }
 
+       public static String getPlatformPath(String platformName) {
+               String split[] = platformName.split("-");
+               if (split != null && split.length == 2) {
+                       String profile = split[0];
+                       String ver = split[1];
+                       return "tizen" + "-" + ver + File.separator + profile;
+               }
+               EMLogger.getLogger().warning("Failed to get platformpath from platform name : " + platformName);
+               return "";
+       }
+
        private void loadProperties() {
                if (platformPath == null) {
                        return;
index 72ed344..5b15143 100644 (file)
@@ -101,13 +101,31 @@ public class PlatformList {
 
                File platforms = new File(FilePathResources.getPlatformsPath());
                if (platforms.isDirectory() && platforms.exists()) {
+//                     for (File platform : platforms.listFiles()) {
+//                             if (platform.isDirectory()) {
+//                                     Platform p = new Platform(platform.getName());
+//                                     if (!p.getImageList().isEmpty()) {
+//                                             //platformList.add(p);
+//                                             addPlatform(p);
+//                                             //addProfile(p.getProfile());
+//                                     }
+//                             }
+//                     }
                        for (File platform : platforms.listFiles()) {
                                if (platform.isDirectory()) {
-                                       Platform p = new Platform(platform.getName());
-                                       if (!p.getImageList().isEmpty()) {
-                                               //platformList.add(p);
-                                               addPlatform(p);
-                                               //addProfile(p.getProfile());
+                                       for (File profile : platform.listFiles()) {
+                                               if (profile.isDirectory()) {
+                                                       String versionSplit[] = platform.getName().split("-");
+                                                       if (versionSplit != null && versionSplit.length == 2) {
+                                                               Platform p = new Platform(profile.getName() + "-" + versionSplit[1]);
+                                                               if (!p.getImageList().isEmpty()) {
+                                                                       //platformList.add(p);
+                                                                       addPlatform(p);
+                                                                       //addProfile(p.getProfile());
+                                                               }
+                                                       }
+
+                                               }
                                        }
                                }
                        }
index e932904..4a0bf10 100644 (file)
@@ -50,6 +50,8 @@ public class FilePathResources {
        private final static String em_images_suffix    = File.separator + "emulator-images";
        private final static String resource_suffix  = File.separator + "emulator-resources";
        private final static String old_default_suffix   = File.separator + "default";
+       private final static String common_suffix = File.separator + "common";
+       private final static String platform_prefix = File.separator + "tizen-";
 //     private final static String addons_suffix    = File.separator + "add-ons";
 //     private final static String x86_extension = ".x86";
 //     private final static String arm_extension = ".arm";
@@ -78,6 +80,8 @@ public class FilePathResources {
        private final static String sdkdata_new_emulator_suffix = File.separator + "emulator";
        private final static String vms_suffix = File.separator + "vms";
 
+       private final static String qemuImg_suffic = File.separator + "qemu-img";
+
        private static String currentPath;
        private static String sdkPath = null;
        private static String platformsPath;
@@ -347,6 +351,38 @@ public class FilePathResources {
        public static String getBinPath(){
                return binPath;
        }
+
+       public static String getEmulatorBinPath(String platformVersion) {
+               return getEmulatorPath(platformVersion) + bin_suffix;
+       }
+
+       public static String getEmulatorKernelPath(String platformVersion) {
+               return getEmulatorDataPath(platformVersion) + kernel_suffix;
+       }
+
+       public static String getEmulatorBiosPath(String platformVersion) {
+               return getEmulatorDataPath(platformVersion) + bios_suffix;
+       }
+
+       public static String getEmulatorQemuImgPath(String platformVersion) {
+               return getEmulatorBinPath(platformVersion) + qemuImg_suffic;
+       }
+
+       public static String getEmulatorDataPath(String platformVersion) {
+               return getEmulatorPath(platformVersion) + data_suffix;
+       }
+
+       public static String getEmulatorPath(String platformVersion) {
+               String emulatorPath;
+               try {
+                       emulatorPath = new File(platformsPath + platform_prefix
+                                       + platformVersion + common_suffix + emulator_suffix).getCanonicalPath();
+               } catch (IOException e) {
+                       emulatorPath = platformsPath + platform_prefix
+                                       + platformVersion + common_suffix + emulator_suffix;
+               }
+               return emulatorPath;
+       }
 /*
        public String getArchPath(){
                return arcPath;
index 88b2669..1ba0f17 100644 (file)
@@ -173,7 +173,7 @@ public class Creator {
        }
 
        private void createSwapImageInternal(String basePath, String targetPath) throws VMCreatorException {
-               String exe_path         = FilePathResources.getBinPath() + File.separator + "qemu-img";
+               String exe_path         = getQemuImgPath();
 
                List<String> cmd = new ArrayList<String>();
                cmd.add(exe_path);
@@ -193,7 +193,7 @@ public class Creator {
        }
 
        private void checkCustomBaseImage(final String path) throws VMCreatorException {
-               String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img";
+               String exe_path = getQemuImgPath();
 
                List<String> cmd = new ArrayList<String>();
                cmd.add(exe_path);
@@ -207,7 +207,7 @@ public class Creator {
        }
 
        public void createInitialVMImageInternal(String baseImagePath, String targetImagePath) throws VMCreatorException {
-               String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img";
+               String exe_path = getQemuImgPath();
 
                List<String> cmd = new ArrayList<String>();
                cmd.add(exe_path);
@@ -397,4 +397,9 @@ public class Creator {
                new Creator().createSwapImageInternal(basePath, targetPath);
        }
 
+       private String getQemuImgPath() {
+//             return FilePathResources.getBinPath() + File.separator + "qemu-img";
+               return FilePathResources.getEmulatorQemuImgPath(newVM.version);
+       }
+
 }
index 131a5cd..57c0c40 100644 (file)
@@ -255,7 +255,7 @@ public class VMWorkerCommon {
                                throw new VMWorkerException("File does not exist :" + baseImage.getAbsolutePath());
                        }
 
-                       String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img";
+                       String exe_path = FilePathResources.getEmulatorQemuImgPath(property.getPropertyValue().version);
 
                        List<String> cmd = new ArrayList<String>();
                        cmd.add(exe_path);