Skip to content

Commit 98b0228

Browse files
authored
Merge branch 'master' into debug-logging
2 parents 7e67332 + 6e987b3 commit 98b0228

File tree

5 files changed

+97
-10
lines changed

5 files changed

+97
-10
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ void handlePatchFiles(FmwInstallerType installerType, String previousInventory,
326326
if (patchLocation != null && !Utils.isEmptyString(patchLocation)) {
327327
File cacheFile = new File(patchLocation);
328328
try {
329+
if (patch.fileName() == null) {
330+
patch.fileName(cacheFile.getName());
331+
}
329332
Files.copy(Paths.get(patchLocation), Paths.get(patchesFolderName, cacheFile.getName()));
330333
} catch (FileAlreadyExistsException ee) {
331334
logger.warning("IMG-0077", patchFile.getKey());
@@ -335,7 +338,10 @@ void handlePatchFiles(FmwInstallerType installerType, String previousInventory,
335338
}
336339
}
337340
if (!aruPatches.isEmpty()) {
338-
dockerfileOptions.setPatchingEnabled();
341+
dockerfileOptions
342+
.setPatchingEnabled()
343+
.setStrictPatchOrdering(strictPatchOrdering)
344+
.setPatchList(aruPatches);
339345
}
340346
logger.exiting();
341347
}
@@ -522,6 +528,12 @@ String getPassword() {
522528
)
523529
boolean recommendedPatches = false;
524530

531+
@Option(
532+
names = {"--strictPatchOrdering"},
533+
description = "Use OPatch to apply patches one at a time."
534+
)
535+
boolean strictPatchOrdering = false;
536+
525537
@Option(
526538
names = {"--patches"},
527539
paramLabel = "patchId",

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/DockerfileOptions.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import java.util.List;
1010
import java.util.Map;
1111
import java.util.StringJoiner;
12+
import java.util.stream.Collectors;
1213

14+
import com.oracle.weblogic.imagetool.aru.AruPatch;
1315
import com.oracle.weblogic.imagetool.cli.menu.PackageManagerType;
1416
import com.oracle.weblogic.imagetool.installer.MiddlewareInstall;
1517
import com.oracle.weblogic.imagetool.installer.MiddlewareInstallPackage;
@@ -36,6 +38,7 @@ public class DockerfileOptions {
3638
private boolean skipJavaInstall;
3739
private boolean isRebaseToTarget;
3840
private boolean isRebaseToNew;
41+
private boolean strictPatchOrdering;
3942

4043
private String javaInstaller;
4144
private String username;
@@ -51,6 +54,7 @@ public class DockerfileOptions {
5154
private String sourceImage;
5255
private String targetImage;
5356
private PackageManagerType pkgMgr;
57+
private List<String> patchFilenames;
5458

5559
// WDT values
5660
private String wdtHome;
@@ -794,6 +798,44 @@ private List<String> getAdditionalCommandsForSection(String sectionName) {
794798
return additionalBuildCommands.get(sectionName);
795799
}
796800

801+
@SuppressWarnings("unused")
802+
public boolean strictPatchOrdering() {
803+
return strictPatchOrdering;
804+
}
805+
806+
/**
807+
* Set strict patch ordering to apply each patch one at a time, instead of
808+
* in a single pass with OPatch. This will slow down the patching process but
809+
* is necessary for some patches.
810+
*
811+
* @param value true to enable strict ordering
812+
* @return this
813+
*/
814+
public DockerfileOptions setStrictPatchOrdering(boolean value) {
815+
strictPatchOrdering = value;
816+
return this;
817+
}
818+
819+
/**
820+
* Set patch file names to be used for OPatch.
821+
* This list is only used when using strictPatchOrdering.
822+
*
823+
* @param patchList list of ARU Patches
824+
* @return this
825+
*/
826+
public DockerfileOptions setPatchList(List<AruPatch> patchList) {
827+
patchFilenames = patchList.stream()
828+
.map(AruPatch::fileName)
829+
.collect(Collectors.toList());
830+
831+
return this;
832+
}
833+
834+
@SuppressWarnings("unused")
835+
public List<String> patches() {
836+
return patchFilenames;
837+
}
838+
797839
/**
798840
* Referenced by Dockerfile template, provides additional OS packages supplied by the user.
799841
*

imagetool/src/main/resources/docker-files/Create_Image.mustache

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,20 @@ RUN cd {{{tempDir}}}/opatch \
125125
{{/isOpatchPatchingEnabled}}
126126

127127
{{#isPatchingEnabled}}
128-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
129-
&& test $? -eq 0 \
130-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
131-
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
128+
{{^strictPatchOrdering}}
129+
# Apply all patches provided at the same time
130+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
131+
&& test $? -eq 0 \
132+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
133+
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
134+
{{/strictPatchOrdering}}
135+
{{#strictPatchOrdering}}
136+
# Apply one patch at a time in the order they were specified
137+
{{#patches}}
138+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} {{{tempDir}}}/patches/{{{.}}}
139+
{{/patches}}
140+
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
141+
{{/strictPatchOrdering}}
132142
{{/isPatchingEnabled}}
133143

134144
{{#afterFmwInstall}}

imagetool/src/main/resources/docker-files/Rebase_Image.mustache

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,20 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
147147
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}}
148148
{{/isOpatchPatchingEnabled}}
149149
{{#isPatchingEnabled}}
150-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
151-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
150+
{{^strictPatchOrdering}}
151+
# Apply all patches provided at the same time
152+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
153+
&& test $? -eq 0 \
154+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
155+
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
156+
{{/strictPatchOrdering}}
157+
{{#strictPatchOrdering}}
158+
# Apply one patch at a time in the order they were specified
159+
{{#patches}}
160+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} {{{tempDir}}}/patches/{{{.}}}
161+
{{/patches}}
162+
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
163+
{{/strictPatchOrdering}}
152164
{{/isPatchingEnabled}}
153165

154166
{{#afterFmwInstall}}

imagetool/src/main/resources/docker-files/Update_Image.mustache

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,20 @@ USER {{userid}}
110110
{{#isPatchingEnabled}}
111111
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
112112

113-
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
114-
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
115-
&& rm -rf {{{tempDir}}}
113+
{{^strictPatchOrdering}}
114+
# Apply all patches provided at the same time
115+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
116+
&& test $? -eq 0 \
117+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
118+
|| (cat {{{oracle_home}}}/cfgtoollogs/opatch/opatch*.log && exit 1)
119+
{{/strictPatchOrdering}}
120+
{{#strictPatchOrdering}}
121+
# Apply one patch at a time in the order they were specified
122+
{{#patches}}
123+
RUN {{{oracle_home}}}/OPatch/opatch apply -silent -oh {{{oracle_home}}} {{{tempDir}}}/patches/{{{.}}}
124+
{{/patches}}
125+
RUN {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}}
126+
{{/strictPatchOrdering}}
116127
{{/isPatchingEnabled}}
117128

118129
{{#isWdtEnabled}}

0 commit comments

Comments
 (0)