forked from facebookarchive/nailgun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
140 lines (116 loc) · 3.53 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
plugins {
id 'base'
id 'nebula.ospackage' version '9.1.1'
}
apply from: "${projectDir}/version-info.gradle"
group 'com.martiansoftware'
def appVersion, appRelease, appDescription
(appVersion, appRelease, appDescription) = getVersionInfo()
project.version = "$appVersion.$appRelease"
project.description = appDescription
tasks.register('installDist', Copy) {
final target = "$buildDir/install/nailgun"
dependsOn 'nailgun-server:installDist'
dependsOn 'nailgun-client:build'
group 'distribution'
into target
from(new File(project('nailgun-server').buildDir, 'install/nailgun-server')) {
into '.'
}
from(new File(project('nailgun-client').buildDir, 'exe/ng/ng')) {
into './bin'
fileMode 0755
}
from(new File(projectDir, 'pynailgun/ng.py')) {
into './bin'
fileMode 0755
}
outputs.dir(target)
}
tasks.register('distTar', Tar) {
group 'distribution'
from installDist
into 'nailgun'
compression Compression.GZIP
}
tasks.register('distZip', Zip) {
group 'distribution'
from installDist
into 'nailgun'
entryCompression ZipEntryCompression.DEFLATED
}
clean {
delete buildDir
}
ospackage {
packageName = 'nailgun'
version = appVersion
release = appRelease
description = appDescription
os = LINUX
user = 'root'
requires 'lsof'
into "/opt/nailgun"
from("$buildDir/install/nailgun/bin") {
into 'bin'
user project.name
fileMode 0755
}
from("$buildDir/install/nailgun/lib") {
into 'lib'
user project.name
fileMode 0644
}
from("$buildDir/install/nailgun/etc") {
into 'etc'
user project.name
fileType CONFIG | NOREPLACE
fileMode 0644
}
final systemdDir = "${project(':nailgun-server').buildDir}/resources/main/systemd"
from("$systemdDir/nailgun.service") {
into '/etc/systemd/system'
fileMode 0644
}
from("$systemdDir/nailgun.conf") {
into '/etc/sysconfig'
fileType CONFIG | NOREPLACE
fileMode 0644
}
preInstall """
#!/usr/bin/sh
if ! getent passwd nailgun >/dev/null; then
sudo useradd -d /opt/nailgun -s /sbin/nologin nailgun
fi
"""
// The conditions are reversed because of the RC that the whole command exits with if the condition fails
postInstall "/bin/systemctl daemon-reload"
}
buildRpm {
dependsOn installDist
arch = 'x86_64'
final onCleanInstall = '[ "$1" != 1 ] ||'
final onUpgradeInstall = '[ "$1" != 2 ] ||'
final onCleanRemove = '[ "$1" != 0 ] ||'
// Enable only after clean installing
postInstall "$onCleanInstall /bin/systemctl enable 'nailgun.service'"
// Start only after clean installing
postInstall "$onCleanInstall /bin/systemctl start 'nailgun.service'"
// Restart only after upgrade
postInstall "$onUpgradeInstall /bin/systemctl restart 'nailgun.service'"
// Stop only before complete uninstalling
preUninstall "$onCleanRemove /bin/systemctl stop 'nailgun.service'"
// Disable only before complete uninstalling
preUninstall "$onCleanRemove /bin/systemctl disable 'nailgun.service'"
}
buildDeb {
dependsOn installDist
arch = 'amd64'
postInstall "/bin/systemctl enable 'nailgun.service'"
postInstall "/bin/systemctl start 'nailgun.service'"
preUninstall "/bin/systemctl stop 'nailgun.service'"
preUninstall "/bin/systemctl disable 'nailgun.service'"
}
afterEvaluate {
println "\n#\n# Nailgun v${project.version}\n#"
}