Skip to content

Commit f5da8af

Browse files
committed
Introduce FreeBSD build scripts
1 parent 2e836cf commit f5da8af

File tree

9 files changed

+34
-6
lines changed

9 files changed

+34
-6
lines changed

.ci/scripts/run-gradle.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ if [ -z "$MAX_WORKER_ENV" ]; then
1818
else
1919
if [[ "$OSTYPE" == "darwin"* ]]; then
2020
MAX_WORKERS=`sysctl -n hw.physicalcpu | sed 's/\s\+//g'`
21+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
22+
MAX_WORKERS=`sysctl -n hw.ncpu | sed 's/\s\+//g'`
2123
else
2224
echo "Unsupported OS Type: $OSTYPE"
2325
exit 1

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class Jdk implements Buildable, Iterable<File> {
2727

2828
private static final List<String> ALLOWED_ARCHITECTURES = List.of("aarch64", "x64");
2929
private static final List<String> ALLOWED_VENDORS = List.of("adoptium", "openjdk", "zulu");
30-
private static final List<String> ALLOWED_PLATFORMS = List.of("darwin", "linux", "windows", "mac");
30+
private static final List<String> ALLOWED_PLATFORMS = List.of("darwin", "linux", "windows", "mac", "freebsd");
3131
private static final Pattern VERSION_PATTERN = Pattern.compile(
3232
"(\\d+)(\\.\\d+\\.\\d+(?:\\.\\d+)?)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?"
3333
);

build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public class ElasticsearchDistribution implements Buildable, Iterable<File> {
2727
public enum Platform {
2828
LINUX,
2929
WINDOWS,
30-
DARWIN;
30+
DARWIN,
31+
FREEBSD;
3132

3233
@Override
3334
public String toString() {
@@ -40,6 +41,7 @@ public String toString() {
4041
.onLinux(() -> Platform.LINUX)
4142
.onWindows(() -> Platform.WINDOWS)
4243
.onMac(() -> Platform.DARWIN)
44+
.onFreeBSD(() -> Platform.FREEBSD)
4345
.supply();
4446

4547
private final String name;

build-tools/src/main/java/org/elasticsearch/gradle/OS.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
public enum OS {
1818
WINDOWS,
1919
MAC,
20-
LINUX;
20+
LINUX,
21+
FREEBSD;
2122

2223
public static OS current() {
2324
String os = System.getProperty("os.name", "");
@@ -30,6 +31,9 @@ public static OS current() {
3031
if (os.startsWith("Mac")) {
3132
return OS.MAC;
3233
}
34+
if (os.startsWith("FreeBSD")) {
35+
return OS.FREEBSD;
36+
}
3337
throw new IllegalStateException("Can't determine OS from: " + os);
3438
}
3539

@@ -52,9 +56,15 @@ public Conditional<T> onMac(Supplier<T> supplier) {
5256
return this;
5357
}
5458

59+
public Conditional<T> onFreeBSD(Supplier<T> supplier) {
60+
conditions.put(FREEBSD, supplier);
61+
return this;
62+
}
63+
5564
public Conditional<T> onUnix(Supplier<T> supplier) {
5665
conditions.put(MAC, supplier);
5766
conditions.put(LINUX, supplier);
67+
conditions.put(FREEBSD, supplier);
5868
return this;
5969
}
6070

distribution/archives/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CopySpec archiveFiles(String distributionType, String os, String architecture, b
3737
with binFiles(distributionType, isTestDistro)
3838
}
3939
into("darwin".equals(os) ? 'jdk.app' : 'jdk') {
40-
if (isTestDistro == false) {
40+
if (isTestDistro == false && !"freebsd".equals(os)) {
4141
with jdkFiles(project, os, architecture)
4242
}
4343
}
@@ -111,6 +111,13 @@ distribution_archives {
111111
}
112112
}
113113

114+
freebsdTar {
115+
archiveClassifier = 'freebsd-x86_64'
116+
content {
117+
archiveFiles('tar', 'freebsd', 'x64', false)
118+
}
119+
}
120+
114121
linuxAarch64Tar {
115122
archiveClassifier = 'linux-aarch64'
116123
content {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is intentionally blank. All configuration of the
2+
// distribution is done in the parent project.

distribution/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
244244

245245
// Setup all required JDKs
246246
project.jdks {
247-
['darwin', 'windows', 'linux'].each { platform ->
247+
['darwin', 'windows', 'linux', 'freebsd'].each { platform ->
248248
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
249249
"bundled_${platform}_${architecture}" {
250250
it.platform = platform
@@ -357,7 +357,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
357357
it.permissions.unix(0644)
358358
}
359359
}
360-
List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64', 'darwin-aarch64']
360+
List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64', 'darwin-aarch64', 'freebsd-x86_64']
361361
if (os != null) {
362362
String platform = os + '-' + architecture
363363
if (architecture == 'x64') {
@@ -632,6 +632,7 @@ subprojects {
632632
'archives:darwin-aarch64-tar',
633633
'archives:linux-aarch64-tar',
634634
'archives:linux-tar',
635+
'archives:freebsd-tar',
635636
'archives:integ-test-zip',
636637
'packages:rpm', 'packages:deb',
637638
'packages:aarch64-rpm', 'packages:aarch64-deb',
@@ -650,6 +651,7 @@ artifacts.add('log4jConfig', file("${defaultOutputs}/log4j2.properties")) {
650651
type = 'file'
651652
name = 'log4j2.properties'
652653
builtBy 'buildDefaultLog4jConfig'
654+
builtBy 'buildDefaultLog4jConfig'
653655
}
654656

655657
tasks.named('resolveAllDependencies') {

plugins/examples/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static def getDefaultDistroProjectName() {
7575
return isArm ? 'linux-aarch64-tar' : 'linux-tar'
7676
} else if (os.startsWith("Mac")) {
7777
return isArm ? 'darwin-aarch64-tar' : 'darwin-tar'
78+
} else if (os.startsWith("FreeBSD")) {
79+
return 'freebsd-tar'
7880
} else {
7981
throw new GradleException("Unable to determine system platform type.")
8082
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ List projects = [
6161
'distribution:archives:darwin-aarch64-tar',
6262
'distribution:archives:linux-aarch64-tar',
6363
'distribution:archives:linux-tar',
64+
'distribution:archives:freebsd-tar',
6465
'distribution:docker',
6566
'distribution:docker:cloud-ess-docker-export',
6667
'distribution:docker:cloud-ess-docker-aarch64-export',

0 commit comments

Comments
 (0)