-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
94 lines (84 loc) · 4.44 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import groovy.text.GStringTemplateEngine
import org.freecompany.redline.payload.*
import org.freecompany.redline.header.*
defaultTasks 'rpm'
buildscript {
ext {
env = System.getenv()
buildNumber = env.BUILD_NUMBER ? env.BUILD_NUMBER.toString() : ((int) (System.currentTimeMillis() / 1000)).toString()
BASE_REPO_URL = hasProperty('BASE_REPO_URL') ? BASE_REPO_URL : 'http://artifactory.asm.delllabs.net:8080/artifactory'
PLUGINS_REPO = hasProperty('PLUGINS_REPO') ? PLUGINS_REPO : 'plugins-release'
PLUGINS_REPO_URL = hasProperty('PLUGINS_REPO_URL') ? PLUGINS_REPO_URL : "${BASE_REPO_URL}/${PLUGINS_REPO}"
rpm_packageName = 'ipxe-devel'
rpm_description = env.RPM_DESCRIPTION ? env.RPM_DESCRIPTION : 'iPXE - Open Source Boot Firmware'
rpm_summary = 'iPXE is an open source network bootloader. It provides a direct\n' +
'replacement for proprietary PXE ROMs, with many extra features such as\n' +
'DNS, HTTP, iSCSI, etc.'
rpm_version = '20190510'
asm_version = env.RPM_VERSION ? env.RPM_VERSION.replaceAll('\\.', '') : '320'
rpm_release = "${asm_version}-${buildNumber}.asm.git1cdf56"
rpm_vendor = env.RPM_VENDOR ? env.RPM_VENDOR : 'Dell EMC, Inc.'
rpm_url = env.RPM_URL ? env.RPM_URL : 'http://ipxe.org/'
rpm_license = env.RPM_LICENSE ? env.RPM_LICENSE : 'GPLv2 with additional permissions and BSD'
rpm_packager = env.RPM_PACKAGER ? env.RPM_PACKAGER : 'vsd_buildmeisters'
}
repositories {
maven {
url PLUGINS_REPO_URL
}
}
dependencies {
classpath 'org.redline-rpm:redline:1.1.12'
}
}
task rpm << {
File rpmDestinationDirectory = new File("${buildDir}/distributions")
if (!rpmDestinationDirectory.isDirectory()) {
rpmDestinationDirectory.mkdirs()
}
org.freecompany.redline.Builder rpmBuilder = new org.freecompany.redline.Builder()
// Dependencies needed to build ipxe ISO
rpmBuilder.addDependencyMore('gcc', '4.4.7')
rpmBuilder.addDependencyMore('xz-devel', '4.999')
rpmBuilder.addDependencyMore('genisoimage', '1.1.9')
rpmBuilder.addDependencyMore('syslinux', '4.0.4')
// Add files copied from https://github.com/dell-asm/asm-deployer
fileTree(dir: '.', include: '**').visit {
rpmBuilder.addDirectory("/opt/src", 0755, Directive.NONE, 'root', 'root', false)
rpmBuilder.addDirectory("/opt/src/ipxe", 0755, Directive.NONE, 'root', 'root', false)
if (!it.path.startsWith(".git") && !it.path.startsWith(".gradle") && !it.path.startsWith("build")) {
if (it.file.isDirectory()) {
if (!it.path.startsWith("src")) {
rpmBuilder.addDirectory("/opt/src/ipxe/${it.path}", 0755, Directive.NONE, 'root', 'root', false)
} else {
// src directories need to be owned by razor so it can build the ISO
rpmBuilder.addDirectory("/opt/src/ipxe/${it.path}", 0755, Directive.NONE, 'razor', 'razor', false)
}
} else if (it.file.isFile()) {
if (it.path.endsWith("named.h") || it.path.endsWith("assert.h") || it.path.endsWith("ipxe/profile.h")) {
// needs to be able to touch config/named.h in order for razor to build ISO
rpmBuilder.addFile("/opt/src/ipxe/${it.path}", it.file, 0644, Directive.NONE, 'razor', 'razor')
} else {
rpmBuilder.addFile("/opt/src/ipxe/${it.path}", it.file, 0644, Directive.NONE, 'root', 'root')
}
}
}
}
// Instead of using project.buildNumber.toString(), use rpm_release value
rpmBuilder.setPackage(project.rpm_packageName, project.rpm_version, project.rpm_release)
rpmBuilder.setType(RpmType.BINARY)
rpmBuilder.setPlatform(Architecture.NOARCH, 'LINUX')
rpmBuilder.setSummary(project.rpm_summary)
rpmBuilder.setDescription(project.rpm_description)
rpmBuilder.setBuildHost('localhost')
rpmBuilder.setLicense(project.rpm_license)
rpmBuilder.setGroup('Enterprise Systems Management')
rpmBuilder.setDistribution('')
rpmBuilder.setVendor(project.rpm_vendor)
rpmBuilder.setPackager(project.rpm_packager)
rpmBuilder.setUrl(project.rpm_url)
println rpmBuilder.build(rpmDestinationDirectory)
}
task clean(type: Delete) {
delete buildDir
}