1 /*
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
91 public static final BundlerParamInfo<String> LICENSE_TYPE =
92 new StandardBundlerParam<>(
93 Arguments.CLIOptions.LINUX_RPM_LICENSE_TYPE.getId(),
94 String.class,
95 params -> I18N.getString("param.license-type.default"),
96 (s, p) -> s
97 );
98
99 public static final BundlerParamInfo<String> GROUP =
100 new StandardBundlerParam<>(
101 Arguments.CLIOptions.LINUX_CATEGORY.getId(),
102 String.class,
103 params -> null,
104 (s, p) -> s);
105
106 private final static String DEFAULT_SPEC_TEMPLATE = "template.spec";
107
108 public final static String TOOL_RPM = "rpm";
109 public final static String TOOL_RPMBUILD = "rpmbuild";
110 public final static DottedVersion TOOL_RPMBUILD_MIN_VERSION = DottedVersion.lazy(
111 "4.0");
112
113 public LinuxRpmBundler() {
114 super(PACKAGE_NAME);
115 }
116
117 @Override
118 public void doValidate(Map<String, ? super Object> params)
119 throws ConfigException {
120 }
121
122 private static ToolValidator createRpmbuildToolValidator() {
123 Pattern pattern = Pattern.compile(" (\\d+\\.\\d+)");
124 return new ToolValidator(TOOL_RPMBUILD).setMinimalVersion(
125 TOOL_RPMBUILD_MIN_VERSION).setVersionParser(lines -> {
126 String versionString = lines.limit(1).collect(
127 Collectors.toList()).get(0);
128 Matcher matcher = pattern.matcher(versionString);
129 if (matcher.find()) {
130 return matcher.group(1);
131 }
|
1 /*
2 * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
91 public static final BundlerParamInfo<String> LICENSE_TYPE =
92 new StandardBundlerParam<>(
93 Arguments.CLIOptions.LINUX_RPM_LICENSE_TYPE.getId(),
94 String.class,
95 params -> I18N.getString("param.license-type.default"),
96 (s, p) -> s
97 );
98
99 public static final BundlerParamInfo<String> GROUP =
100 new StandardBundlerParam<>(
101 Arguments.CLIOptions.LINUX_CATEGORY.getId(),
102 String.class,
103 params -> null,
104 (s, p) -> s);
105
106 private final static String DEFAULT_SPEC_TEMPLATE = "template.spec";
107
108 public final static String TOOL_RPM = "rpm";
109 public final static String TOOL_RPMBUILD = "rpmbuild";
110 public final static DottedVersion TOOL_RPMBUILD_MIN_VERSION = DottedVersion.lazy(
111 "4.10");
112
113 public LinuxRpmBundler() {
114 super(PACKAGE_NAME);
115 }
116
117 @Override
118 public void doValidate(Map<String, ? super Object> params)
119 throws ConfigException {
120 }
121
122 private static ToolValidator createRpmbuildToolValidator() {
123 Pattern pattern = Pattern.compile(" (\\d+\\.\\d+)");
124 return new ToolValidator(TOOL_RPMBUILD).setMinimalVersion(
125 TOOL_RPMBUILD_MIN_VERSION).setVersionParser(lines -> {
126 String versionString = lines.limit(1).collect(
127 Collectors.toList()).get(0);
128 Matcher matcher = pattern.matcher(versionString);
129 if (matcher.find()) {
130 return matcher.group(1);
131 }
|