]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/command/InstallWorkspace.java
47bd36fe0aacd9fa69673179a99ec6f6eb98e704
[mirror_edk2.git] / Tools / Source / CreateMdkPkg / src / org / tianocore / packaging / workspace / command / InstallWorkspace.java
1 /** @file
2
3 The file is used to override AbstractCellEditor to provides customized interfaces
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 package org.tianocore.packaging.workspace.command;
17
18 import java.io.File;
19 import java.io.IOException;
20
21 import org.tianocore.common.Log;
22 import org.tianocore.common.Tools;
23 import org.tianocore.packaging.MdkPkg;
24
25 /**
26 The class is used to override AbstractCellEditor to provides customized interfaces
27
28 @since CreateMdkPkg 1.0
29
30 **/
31 public class InstallWorkspace {
32 /**
33 Main class, reserved for test
34
35 @param args
36
37 **/
38 public static void main(String[] args) {
39 // TODO Auto-generated method stub
40
41 }
42
43 /**
44 This is the default constructor
45 Reserved
46
47 **/
48 public InstallWorkspace() {
49 // TODO
50 }
51
52 /**
53 Check if exist target dir
54
55 @param strInstallDir The install target dir
56 @retval true - The target exists
57 @retval false - The target doesn't exist
58
59 **/
60 public static boolean isExistInstallDir(String strInstallDir) {
61 File id = new File(strInstallDir);
62 return id.exists();
63 }
64
65 /**
66 Create install target dir
67
68 @param strInstallDir The install target dir
69 @retval true - Install success
70 @retval false - Install fail
71
72 **/
73 public static boolean createInstallDir(String strInstallDir) {
74 File id = new File(strInstallDir);
75 try {
76 return id.mkdir();
77 } catch (Exception e) {
78 System.out.print(e.getMessage());
79 return false;
80 }
81 }
82
83 /**
84 Reserved
85
86 @return boolean
87
88 **/
89 public static boolean setSystemEnvironment() {
90 return true;
91 }
92
93 /**
94 Reserved
95
96 @return boolean
97 **/
98 public static boolean setToolChainPath() {
99 return true;
100 }
101
102 /**
103 Reserved
104
105 @return boolean
106 **/
107 public static boolean setToolChain() {
108 return true;
109 }
110
111 /**
112 Reserved
113
114 @return boolean
115 **/
116 public static boolean setFrameworkDatabase() {
117 return true;
118 }
119
120 /**
121 Delete setup files and directory
122
123 @param strPath The delete target dir
124 @retval true - Delete success
125 @retval false - Delete fail
126
127 **/
128 public static boolean delSetupPackage(String strPath) {
129 File f = new File(strPath);
130 try {
131 Tools.deleteFolder(f);
132 } catch (Exception e) {
133 e.printStackTrace();
134 }
135 return true;
136 }
137
138 /**
139
140 @param strInstallDir The install target dir
141 @param strJarFile The install target file
142 @retval true - Install success
143 @retval false - Install fail
144 @throws IOException
145
146 **/
147 public static boolean installPackage(String strInstallDir, String strJarFile) throws IOException {
148 Log.log("Install Dir", strInstallDir);
149 Log.log("Jar File Path", strJarFile);
150
151 MdkPkg mp = new MdkPkg(strJarFile);
152 try {
153 mp.install(strInstallDir + System.getProperty("file.separator"));
154 return true;
155 } catch (Exception e) {
156 e.printStackTrace();
157 Log.log("Install Err", e.toString());
158 }
159 return false;
160 }
161 }