Skip to content

Commit d6de095

Browse files
committed
Change to use copy instead of links
1 parent 73e8143 commit d6de095

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/CreateImage.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public CommandResponse call() throws Exception {
6767
}
6868

6969
List<String> cmdBuilder = getInitialBuildCmd();
70-
7170
// create a tmp directory for user.
7271
tmpDir = Files.createTempDirectory(null);
7372
String tmpDirPath = tmpDir.toAbsolutePath().toString();
@@ -80,7 +79,6 @@ public CommandResponse call() throws Exception {
8079

8180
if (fromImage != null && !fromImage.isEmpty()) {
8281
cmdBuilder.add(BUILD_ARG);
83-
cmdBuilder.add("BASE_IMAGE=" + fromImage);
8482

8583
tmpDir2 = Files.createTempDirectory(Paths.get(System.getProperty("user.home")), null);
8684
logger.info("tmp directory in user.home for docker run: " + tmpDir2);
@@ -107,7 +105,6 @@ public CommandResponse call() throws Exception {
107105
} else {
108106
filterStartTags.add("_YUM");
109107
}
110-
111108
// build wdt args if user passes --wdtModelPath
112109
cmdBuilder.addAll(handleWDTArgsIfRequired(tmpDir));
113110

@@ -122,7 +119,6 @@ public CommandResponse call() throws Exception {
122119

123120
// add directory to pass the context
124121
cmdBuilder.add(tmpDirPath);
125-
126122
logger.info("docker cmd = " + String.join(" ", cmdBuilder));
127123
Utils.runDockerCommand(isCLIMode, cmdBuilder, dockerLog);
128124
} catch (Exception ex) {
@@ -154,9 +150,12 @@ private List<String> handleInstallerFiles(Path tmpDir) throws Exception {
154150
for (InstallerFile eachInstaller : requiredInstallers) {
155151
String targetFilePath = eachInstaller.resolve(cacheStore);
156152
File targetFile = new File(targetFilePath);
157-
Path targetLink = Files.createLink(Paths.get(tmpDirPath, targetFile.getName()),
158-
Paths.get(targetFilePath));
159-
retVal.addAll(eachInstaller.getBuildArg(tmpDir.relativize(targetLink).toString()));
153+
try {
154+
Path targetLink = Files.copy(Paths.get(targetFilePath), Paths.get(tmpDirPath, targetFile.getName()));
155+
retVal.addAll(eachInstaller.getBuildArg(tmpDir.relativize(targetLink).toString()));
156+
} catch (Exception ee ) {
157+
ee.printStackTrace();
158+
}
160159
}
161160
return retVal;
162161
}
@@ -186,18 +185,23 @@ private List<String> handleWDTArgsIfRequired(Path tmpDir) throws IOException {
186185
if (wdtModelPath != null) {
187186
if (Files.isRegularFile(wdtModelPath)) {
188187
filterStartTags.add("WDT_");
189-
Path targetLink = Files.createLink(Paths.get(tmpDirPath, wdtModelPath.getFileName().toString()), wdtModelPath);
188+
Path targetLink = Files.copy(wdtModelPath, Paths.get(tmpDirPath, wdtModelPath.getFileName().toString())
189+
);
190190
retVal.add(BUILD_ARG);
191191
retVal.add("WDT_MODEL=" + tmpDir.relativize(targetLink).toString());
192192

193193
if (wdtArchivePath != null && Files.isRegularFile(wdtArchivePath)) {
194-
targetLink = Files.createLink(Paths.get(tmpDirPath, wdtArchivePath.getFileName().toString()), wdtArchivePath);
194+
targetLink = Files.copy(wdtArchivePath, Paths.get(tmpDirPath,
195+
wdtArchivePath.getFileName().toString())
196+
);
195197
retVal.add(BUILD_ARG);
196198
retVal.add("WDT_ARCHIVE=" + tmpDir.relativize(targetLink).toString());
197199
}
198200

199201
if (wdtVariablesPath != null && Files.isRegularFile(wdtVariablesPath)) {
200-
targetLink = Files.createLink(Paths.get(tmpDirPath, wdtVariablesPath.getFileName().toString()), wdtVariablesPath);
202+
targetLink = Files.copy(wdtVariablesPath, Paths.get(tmpDirPath,
203+
wdtVariablesPath.getFileName().toString())
204+
);
201205
retVal.add(BUILD_ARG);
202206
retVal.add("WDT_VARIABLE=" + tmpDir.relativize(targetLink).toString());
203207
retVal.addAll(getWDTRequiredBuildArgs(wdtVariablesPath));

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/ImageOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception
106106
for (String patchLocation : patchLocations) {
107107
if (patchLocation != null) {
108108
File patch_file = new File(patchLocation);
109-
Files.createLink(Paths.get(toPatchesPath, patch_file.getName()), Paths.get(patchLocation));
109+
Files.copy(Paths.get(patchLocation), Paths.get(toPatchesPath, patch_file.getName()) );
110110
} else {
111111
logger.severe("null entry in patchLocations");
112112
}
@@ -162,8 +162,8 @@ void handleProxyUrls() throws IOException {
162162

163163
void addOPatch1394ToImage(Path tmpDir) throws Exception {
164164
String filePath = new PatchFile(useCache, "opatch", "13.9.4.0.0", "28186730", userId, password).resolve(cacheStore);
165-
Files.createLink(Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName()),
166-
Paths.get(filePath));
165+
Files.copy(Paths.get(filePath), Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName())
166+
);
167167
filterStartTags.add("OPATCH_1394");
168168
}
169169

0 commit comments

Comments
 (0)