diff options
Diffstat (limited to 'node-admin/src/main/java')
2 files changed, 9 insertions, 10 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumCommand.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumCommand.java index 1d105057e02..1530b3c72f0 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumCommand.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumCommand.java @@ -260,6 +260,8 @@ public abstract class YumCommand<T extends YumCommand<T>> { if (lines.size() > builders.size()) throw new IllegalArgumentException("Found multiple installed packages for '" + packageName + "'. Version is required to match package exactly"); IntStream.range(0, builders.size()).forEach(i -> lines.get(i).ifPresent(builders.get(i)::apply)); + if (builder.epoch().isEmpty()) builder.setEpoch("0"); + return Optional.of(builder.build()); } } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java index 5b32f50ad49..058836ac328 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java @@ -80,6 +80,12 @@ public class YumPackageName { public Builder setRelease(String release) { this.release = Optional.of(release); return this; } public Builder setArchitecture(String architecture) { this.architecture = Optional.of(architecture); return this; } + public Optional<String> epoch() { return epoch; } + public String name() { return name; } + public Optional<String> version() { return version; } + public Optional<String> release() { return release; } + public Optional<String> architecture() { return architecture; } + public YumPackageName build() { return new YumPackageName(epoch, name, version, release, architecture); } } @@ -162,11 +168,6 @@ public class YumPackageName { release = Optional.ofNullable(matcher.group(3)); } - // Set default epoch if we have a version - if (version.isPresent() && epoch.isEmpty()) { - epoch = Optional.of("0"); - } - if (!NAME_PATTERN.matcher(spec).find()) { throw new IllegalArgumentException("Bad package name in " + packageSpec + ": '" + spec + "'"); } @@ -211,11 +212,7 @@ public class YumPackageName { * @throws IllegalStateException if any field required for the version lock spec is missing */ public String toVersionLockName() { - Builder b = new Builder(this).setArchitecture("*"); - if (epoch.isEmpty()) { - b.setEpoch("0"); - } - YumPackageName lockSpec = b.build(); + YumPackageName lockSpec = new Builder(this).setArchitecture("*").build(); if (lockSpec.getVersion().isEmpty()) throw new IllegalStateException("Version is missing for YUM package " + name); if (lockSpec.getRelease().isEmpty()) throw new IllegalStateException("Release is missing for YUM package " + name); return lockSpec.toName(); |