From 7233530d6e2ad367ef1b951b75dc0f103a91debc Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Fri, 14 Jun 2013 16:33:48 +0900 Subject: [PATCH] [Title] Applied changing GBS buildroot path --- .../nativeplatform/rootstrap/RootstrapManager.java | 100 ++++++++------------- .../views/model/PlatformRootstrap.java | 20 +++-- 2 files changed, 54 insertions(+), 66 deletions(-) diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java index 2eeebb7..9a5ce03 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java @@ -74,7 +74,7 @@ import org.w3c.dom.Element; public class RootstrapManager { - private static ArrayList rootstraps = new ArrayList(); + private static List rootstraps = new ArrayList(); private static PlatformRootstrap selectedRootstrap; public static Set changedListener = new HashSet(); @@ -102,6 +102,7 @@ public class RootstrapManager { String rootName = sbi.getRootstrapNameFromRootstrapID(id); String arch = sbi.getArchitectureFromRootstrapID(id); String path = sbi.getRootstrapPathFromRootstrapID(id); + boolean isDefault = sbi.getIsDefaultFromRootstrapID(id); HashMap reposURLs = new HashMap(); String rootstrapPath = sbi.getRootstrapPropertyValue(id, PlatformRootstrap.PROPERTY_REPO_URLS); @@ -118,7 +119,7 @@ public class RootstrapManager { } boolean initialized = new File(path).exists() ? true : false; addRootstrap(new PlatformRootstrap(id, rootName, arch, path, reposURLs, confFile, - initialized)); + initialized, isDefault)); } } catch (SBIException e) { logger.error("Failed to initialize rootstraps", e); @@ -162,28 +163,33 @@ public class RootstrapManager { String tempDirPath = makeTempDirectory(); try { - // zip file-system - String basePath = rootstrap.getPath().removeLastSegments(1).toOSString(); - File dir = new File(rootstrap.getPath().append("local").toOSString()); - String scratchName = ""; - String list[] = dir.list(); - for (String s : list) { - if (s.startsWith("scratch.")) { - scratchName = s; - } + // rootstrapPath = /home/sdk/tizen-sdk-data/user-rootstraps/latest + // workingPath = /home/sdk/tizen-sdk-data/user-rootstraps/ + // chrootPath = + // /home/sdk/tizen-sdk-data/user-rootstraps/latest/local/BUILD-ROOTS/scratch.i586.0 + String rootstrapPath = rootstrap.getPath().toOSString(); + String workingPath = rootstrap.getPath().removeLastSegments(1).toOSString(); + SmartBuildInterface sbi = SmartBuildInterface.getInstance(); + String chrootPath = sbi.getPlatformRootstrapPath(rootstrapPath); + if (chrootPath == null || chrootPath.isEmpty()) { + return false; + } + String scratchName = new Path(chrootPath).lastSegment(); + if (!scratchName.startsWith("scratch.")) { + return false; } String rootstrapID = rootstrap.getId(); if (!CommandLauncher.execute(String.format( - "tar cvzf %s/rootstrap1.tar.gz %s --exclude=local/%s", tempDirPath, - rootstrapID, scratchName), basePath, "Platform Internal", monitor)) { + "tar cvzf %s/rootstrap1.tar.gz %s --exclude=local/BUILD-ROOTS/%s", tempDirPath, + rootstrapID, scratchName), workingPath, "Platform Internal", monitor)) { return false; } if (!CommandLauncher .executeSudo( String.format( - "sudo -S tar cvzf %s/rootstrap2.tar.gz %s/local/%s --exclude=home/abuild --exclude=etc/passwd", - tempDirPath, rootstrapID, scratchName), basePath, + "sudo -S tar cvzf %s/rootstrap2.tar.gz %s/local/BUILD-ROOTS/%s --exclude=home/abuild --exclude=etc/passwd", + tempDirPath, rootstrapID, scratchName), workingPath, "Platform Internal", monitor)) { return false; } @@ -355,14 +361,16 @@ public class RootstrapManager { } public static PlatformRootstrap getDefaultRootstrap(String arch) { - String defaultRootstrapID = null; - if (PlatformConfigurationManager.isEmulatorArch(arch)) { - defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_I386_ID; - } else if (PlatformConfigurationManager.isDeviceArch(arch)) { - defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_ARM_ID; - } + return findDefaultRootstrap(arch); + } - return RootstrapManager.getRootstrap(defaultRootstrapID); + public static PlatformRootstrap findDefaultRootstrap(String arch) { + for (PlatformRootstrap r : rootstraps) { + if (r.getArch().equals(arch) && r.isDefault()) { + return r; + } + } + return null; } public static void reinitialize() { @@ -491,37 +499,7 @@ public class RootstrapManager { // generate SBI plugins if (generateSBIPluginXML(id, name, arch, null, reposURLs, confFile)) { return new PlatformRootstrap(id, name, arch, getUserRootstrapPath(id), reposURLs, - confFile, initialized); - } else { - if (immediateGen) { - removeBaseFileSystem(id, arch); - } - return null; - } - } - - public static PlatformRootstrap generate(PlatformRootstrap rootstrap, boolean immediateGen, - IProgressMonitor monitor) throws InterruptedException { - - boolean initialized = false; - String name = rootstrap.getName(); - String arch = rootstrap.getArch(); - ArrayList repos = rootstrap.getJustRepoURLs(); - IPath confFile = rootstrap.getConfFile(); - String id = name; - if (immediateGen) { - if (generateBaseFileSystem(getUserRootstrapPath(id), arch, repos, confFile, monitor)) { - initialized = true; - } else { - return null; - } - - } - - // generate SBI plugins - if (generateSBIPluginXML(id, name, arch, null, repos, confFile)) { - return new PlatformRootstrap(id, name, arch, getUserRootstrapPath(id), - rootstrap.getRepoMap(), confFile, initialized); + confFile, initialized, false); } else { if (immediateGen) { removeBaseFileSystem(id, arch); @@ -587,12 +565,13 @@ public class RootstrapManager { } finally { if (new File(tempDirPath).exists()) { // check sub-directory - String checkDir = String.format("%s/%s/local/scratch.%s.0/proc", tempDirPath, id, - arch); + String checkDir = String.format("%s/%s/local/BUILD-ROOTS/scratch.%s.0/proc", + tempDirPath, id, arch); if (new File(checkDir).exists()) { CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir)); } - checkDir = String.format("%s/%s/local/scratch.%s.0/dev/pts", tempDirPath, id, arch); + checkDir = String.format("%s/%s/local/BUILD-ROOTS/scratch.%s.0/dev/pts", + tempDirPath, id, arch); if (new File(checkDir).exists()) { CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir)); } @@ -621,11 +600,11 @@ public class RootstrapManager { private static void removeBaseFileSystem(String id, String arch) throws InterruptedException { String path = getUserRootstrapPath(id); // check sub-directory - String checkDir = String.format("%s/local/scratch.%s.0/proc", path, arch); + String checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/proc", path, arch); if (new File(checkDir).exists()) { CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir)); } - checkDir = String.format("%s/local/scratch.%s.0/dev/pts", path, arch); + checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/dev/pts", path, arch); if (new File(checkDir).exists()) { CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir)); } @@ -808,7 +787,7 @@ public class RootstrapManager { String confFile = rootstrap.getPropertyValue(PlatformRootstrap.PROPERTY_CONFIGURATION_FILE); return new PlatformRootstrap(id, rootstrap.getName(), rootstrap.getArch(), rootstrap - .getPath().toOSString(), reposURLs, confFile, true); + .getPath().toOSString(), reposURLs, confFile, true, rootstrap.isDefault()); } private static String getPluginXML(String id) { @@ -835,8 +814,7 @@ public class RootstrapManager { if (InstallerUtil.isSupportedMultipleSDK()) { return path.replaceAll(String.format("%s/", InstallPathConfig.getSDKPath()), "#{SDK_INSTALLED_PATH}/").replaceAll( - String.format("%s/", InstallPathConfig.getUserDataPath()), - "#{SDK_DATA_PATH}/"); + String.format("%s/", InstallPathConfig.getUserDataPath()), "#{SDK_DATA_PATH}/"); } else { return path.replaceAll(String.format("%s/", InstallPathConfig.getSDKPath()), "#{SBI_HOME}/../../").replaceAll( diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/model/PlatformRootstrap.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/model/PlatformRootstrap.java index eaec83e..6dcf438 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/model/PlatformRootstrap.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/model/PlatformRootstrap.java @@ -49,21 +49,31 @@ public class PlatformRootstrap extends Rootstrap implements ICheckTreeItem { public static final String PROPERTY_CONFIGURATION_FILE = "CONFIGURATION_FILE"; public static final String SUPPORTED_TOOLCHAIN_TYPE = "tizen.platform"; - public static final String DEFAULT_ROOTSTRAP_ARM_ID = "tizen-device-2.1.platform"; - public static final String DEFAULT_ROOTSTRAP_I386_ID = "tizen-emulator-2.1.platform"; private static final String VERSION = "1.0"; public PlatformRootstrap(String id, String name, String arch, String rootstrapPath, - HashMap reposURLs, IPath confFile, boolean initialized) { - super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath)); + HashMap reposURLs, IPath confFile, boolean initialized, + boolean isDefault) { + super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), isDefault); this.reposURLs = reposURLs; this.initialized = initialized; this.confFile = confFile; } public PlatformRootstrap(String id, String name, String arch, String rootstrapPath, + HashMap reposURLs, String confFile, boolean initialized, + boolean isDefault) { + super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), isDefault); + this.reposURLs = reposURLs; + this.initialized = initialized; + if (confFile != null && !confFile.isEmpty()) { + this.confFile = new Path(confFile); + } + } + + public PlatformRootstrap(String id, String name, String arch, String rootstrapPath, HashMap reposURLs, String confFile, boolean initialized) { - super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath)); + super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), false); this.reposURLs = reposURLs; this.initialized = initialized; if (confFile != null && !confFile.isEmpty()) { -- 2.7.4