47
48
# Fetch package dependencies for the build
49
print("2. Installing package dependencies within LXC container")
50
-if str(os.environ["REPO_TOOL"]).count("zypper") == 1:
51
- common.run_command(container, [os.environ["REPO_TOOL"], "clean", "-a"])
52
- common.run_command(container, [os.environ["REPO_TOOL"], "--no-gpg-checks", "update", "-y"])
53
- common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "json-glib-devel"])
54
-
55
-elif str(os.environ["REPO_TOOL"]).count("yum") == 1:
56
- common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "json-c-devel"])
57
- common.run_command(container, [os.environ["REPO_TOOL"], "clean", "all"])
58
- common.run_command(container, [os.environ["REPO_TOOL"], "update", "-y"])
59
- common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "epel-release"])
60
-else:
61
- common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "json-c-devel"])
62
- common.run_command(container, [os.environ["REPO_TOOL"], "update", "-y"])
63
-
64
-common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "sudo"])
65
-common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "wget"])
66
-common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "bash"])
67
-common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "freeipmi-devel"])
68
-common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "cups-devel"])
50
+common.install_common_dependendencies()
51
52
# Exceptional cases, not available everywhere
53
#
72
-
54
# Not on Centos-7
55
if os.environ["BUILD_STRING"].count("el/7") <= 0:
56
common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "libnetfilter_acct-devel"])
78
dest_archive=""
79
download_url=""
80
spec_file="/home/%s/rpmbuild/SPECS/netdata.spec" % os.environ['BUILDER_NAME']
81
+tag = None
82
83
# TODO: Checksum validations
84
if str(os.environ['BUILD_VERSION']).count(".latest") == 1:
85
version_list=str(os.environ['BUILD_VERSION']).replace('v', '').split('.')
86
rpm_friendly_version='.'.join(version_list[0:3]) + "." + version_list[3]
105
-
106
- print("Building latest nightly version of netdata..(%s)" % os.environ['BUILD_VERSION'])
107
- dest_archive="/home/%s/rpmbuild/SOURCES/netdata-%s.tar.gz" % (os.environ['BUILDER_NAME'], rpm_friendly_version)
108
-
109
- print("5. Preparing local latest implementation tarball for version %s" % rpm_friendly_version)
110
- tar_file = os.environ['LXC_CONTAINER_ROOT'] + dest_archive
111
-
112
- print("5.1 Tagging the code with latest version: %s" % rpm_friendly_version)
113
- common.run_command_in_host(['git', 'tag', '-a', rpm_friendly_version, '-m', 'Tagging while packaging on %s' % os.environ["CONTAINER_NAME"]])
114
-
115
- print("5.2 Run autoreconf -ivf")
116
- common.run_command_in_host(['autoreconf', '-ivf'])
117
-
118
- print("5.3 Run configure")
119
- common.run_command_in_host(['./configure', '--with-math', '--with-zlib', '--with-user=netdata'])
120
-
121
- print("5.4 Run make dist")
122
- common.run_command_in_host(['make', 'dist'])
123
-
124
- print("5.5 Copy generated tarbal to desired path")
125
- if os.path.exists('netdata-%s.tar.gz' % rpm_friendly_version):
126
- common.run_command_in_host(['sudo', 'cp', 'netdata-%s.tar.gz' % rpm_friendly_version, tar_file])
127
-
128
- print("5.6 Fixing permissions on tarball")
129
- common.run_command_in_host(['sudo', 'chmod', '777', tar_file])
130
- else:
131
- print("I could not find (%s) on the disk, stopping the build. Kindly check the logs and try again" % 'netdata-%s.tar.gz' % rpm_friendly_version)
132
- sys.exit(1)
133
-
134
- # Extract the spec file in place
135
- print("6. Extract spec file from the source")
136
- common.run_command_in_host(['sudo', 'cp', 'netdata.spec', os.environ['LXC_CONTAINER_ROOT'] + spec_file])
137
- common.run_command_in_host(['sudo', 'chmod', '777', os.environ['LXC_CONTAINER_ROOT'] + spec_file])
138
-
139
- print("7. Temporary hack: Change Source0 to %s on spec file %s" % (dest_archive, spec_file))
140
- common.replace_tag("Source0", os.environ['LXC_CONTAINER_ROOT'] + spec_file, tar_file)
87
else:
142
- rpm_friendly_version = os.environ['BUILD_VERSION']
88
+ rpm_friendly_version = os.environ['BUILD_VERSION'].replace('v', '')
89
+ tag = rpm_friendly_version # Go to stable tag
90
+
91
+tar_file="%s/netdata-%s.tar.gz" % (os.path.dirname(dest_archive), rpm_friendly_version)
92
144
- print("Building latest stable version of netdata.. (%s)" % os.environ['BUILD_VERSION'])
145
- dest_archive="/home/%s/rpmbuild/SOURCES/netdata-%s.tar.gz" % (os.environ['BUILDER_NAME'],os.environ['BUILD_VERSION'])
146
- download_url="https://github.com/netdata/netdata/releases/download/%s/netdata-%s.tar.gz" % (os.environ['BUILD_VERSION'], os.environ['BUILD_VERSION'])
93
+print("5. I will be building version '%s' of netdata." % os.environ['BUILD_VERSION'])
94
+dest_archive="/home/%s/rpmbuild/SOURCES/netdata-%s.tar.gz" % (os.environ['BUILDER_NAME'], rpm_friendly_version)
95
148
- print("5. Fetch netdata source into the repo structure(%s -> %s)" % (download_url, dest_archive))
149
- tar_file="%s/netdata-%s.tar.gz" % (os.path.dirname(dest_archive), rpm_friendly_version)
150
- common.run_command(container, ["sudo", "-u", os.environ['BUILDER_NAME'], "wget", "-T", "15", "--output-document=" + dest_archive, download_url])
96
+common.prepare_version_source(dest_archive, rpm_friendly_version, tag=tag)
97
152
- print("6.Extract spec file from the source")
153
- common.run_command(container, ["sudo", "-u", os.environ['BUILDER_NAME'], "tar", "--to-command=cat > %s" % spec_file, "-xvf", dest_archive, "netdata-%s/netdata.spec" % os.environ['BUILD_VERSION']])
98
+# Extract the spec file in place
99
+print("6. Extract spec file from the source")
100
+common.run_command_in_host(['sudo', 'cp', 'netdata.spec', os.environ['LXC_CONTAINER_ROOT'] + spec_file])
101
+common.run_command_in_host(['sudo', 'chmod', '777', os.environ['LXC_CONTAINER_ROOT'] + spec_file])
102
155
- print("7. Temporary hack: Adjust version string on the spec file (%s) to %s and Source0 to %s" % (os.environ['LXC_CONTAINER_ROOT'] + spec_file, rpm_friendly_version, download_url))
156
- common.replace_tag("Version", os.environ['LXC_CONTAINER_ROOT'] + spec_file, rpm_friendly_version)
157
- common.replace_tag("Source0", os.environ['LXC_CONTAINER_ROOT'] + spec_file, tar_file)
103
+print("7. Temporary hack: Change Source0 to %s on spec file %s" % (dest_archive, spec_file))
104
+common.replace_tag("Source0", os.environ['LXC_CONTAINER_ROOT'] + spec_file, tar_file)
105
106
print('Done!')