summaryrefslogtreecommitdiffstats
path: root/.travis
diff options
context:
space:
mode:
authorPaul Emm. Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com>2019-09-13 10:27:54 +0300
committerChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-09-13 09:27:54 +0200
commitdd6703219a99ff44842f1460503afbad64cb73f9 (patch)
tree7713cb8601028c6dd61d7a9c4820c5100192dbbb /.travis
parent09e05ed989d8c6c43e5aaaf8098782cf8bdf941b (diff)
netdata/packaging: Ensure that we do not mess with CI tooling, when building stable (#6838)
* netdata/packaging: Dont mess with the CI code when playing with the repo Sadly, we need to run consistently the same code for the CI side. When doing checkouts to build stable code, we move the whole repo thus resulting on changing the ci code too. This is usually fine when building nightlies, on stable though is a completely different story. To mitigate this, copy the repo into a temporary folder. Then do whatever you need to prepare and copy the tarball. Once you are done, just go back to the original repo folder and remove the temp. That should work fine for both nightlies and stable, with a little overhead of copying over the repository, but we have to. We want to be able to run with latest CI code, when trying to build a stable release. * [Package amd64 DEB] Package build stable test * netdata/packaging: allow me to test on my repo the build process (dont care for deploy) * [Package amd64 DEB] Package build stable test * netdata/packaging: [ci skip] copy under tmp * [Package amd64 DEB] Package build stable test * netdata/packaging:[ci skip] play with CWD of the command, thats cleaner and well, the right thing * [Package amd64 DEB] Package build stable test * netdata/packaging: [ci skip] cd did not fall for cwd, provide full path and move on * netdata/packaging: a few nits like dont use cwd for some commands, import sys, simplify some variable usage * netdata/packaging: [ci skip] focus, missed a reference to the tarballen * netdata/packaging: [ci skip] remove test branch * netdata/packaging: Thanks for taking note Codacy, here's a better temp file for the job
Diffstat (limited to '.travis')
-rwxr-xr-x.travis/package_management/common.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/.travis/package_management/common.py b/.travis/package_management/common.py
index a72fe48376..cbe1fa77e8 100755
--- a/.travis/package_management/common.py
+++ b/.travis/package_management/common.py
@@ -7,6 +7,9 @@
import lxc
import subprocess
import os
+import sys
+import tempfile
+import shutil
def fetch_version(orig_build_version):
tag = None
@@ -53,10 +56,10 @@ def run_command(container, command):
if command_result != 0:
raise Exception("Command failed with exit code %d" % command_result)
-def run_command_in_host(cmd):
- print("Issue command in host: %s" % str(cmd))
+def run_command_in_host(cmd, cwd=None):
+ print("Issue command in host: %s, cwd:%s" % (str(cmd), str(cwd)))
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
o, e = proc.communicate()
print('Output: ' + o.decode('ascii'))
print('Error: ' + e.decode('ascii'))
@@ -133,31 +136,40 @@ def prepare_version_source(dest_archive, pkg_friendly_version, tag=None):
print(".0 Preparing local implementation tarball for version %s" % pkg_friendly_version)
tar_file = os.environ['LXC_CONTAINER_ROOT'] + dest_archive
+ print(".0 Copy repo to prepare it for tarball generation")
+ tmp_src = tempfile.mkdtemp(prefix='netdata-source-')
+ run_command_in_host(['cp', '-r', '.', tmp_src])
+
if tag is not None:
print(".1 Checking out tag %s" % tag)
- run_command_in_host(['git', 'fetch', '--all'])
+ run_command_in_host(['git', 'fetch', '--all'], tmp_src)
# TODO: Keep in mind that tricky 'v' there, needs to be removed once we clear our versioning scheme
- run_command_in_host(['git', 'checkout', 'v%s' % pkg_friendly_version])
+ run_command_in_host(['git', 'checkout', 'v%s' % pkg_friendly_version], tmp_src)
print(".2 Tagging the code with version: %s" % pkg_friendly_version)
- run_command_in_host(['git', 'tag', '-a', pkg_friendly_version, '-m', 'Tagging while packaging on %s' % os.environ["CONTAINER_NAME"]])
+ run_command_in_host(['git', 'tag', '-a', pkg_friendly_version, '-m', 'Tagging while packaging on %s' % os.environ["CONTAINER_NAME"]], tmp_src)
print(".3 Run autoreconf -ivf")
- run_command_in_host(['autoreconf', '-ivf'])
+ run_command_in_host(['autoreconf', '-ivf'], tmp_src)
print(".4 Run configure")
- run_command_in_host(['./configure', '--prefix=/usr', '--sysconfdir=/etc', '--localstatedir=/var', '--libdir=/usr/lib', '--libexecdir=/usr/libexec', '--with-math', '--with-zlib', '--with-user=netdata'])
+ run_command_in_host(['./configure', '--prefix=/usr', '--sysconfdir=/etc', '--localstatedir=/var', '--libdir=/usr/lib', '--libexecdir=/usr/libexec', '--with-math', '--with-zlib', '--with-user=netdata'], tmp_src)
print(".5 Run make dist")
- run_command_in_host(['make', 'dist'])
+ run_command_in_host(['make', 'dist'], tmp_src)
print(".6 Copy generated tarbal to desired path")
- if os.path.exists('netdata-%s.tar.gz' % pkg_friendly_version):
- run_command_in_host(['sudo', 'cp', 'netdata-%s.tar.gz' % pkg_friendly_version, tar_file])
+ generated_tarball = '%snetdata-%s.tar.gz' % (tmp_src, pkg_friendly_version)
+
+ if os.path.exists(generated_tarball):
+ run_command_in_host(['sudo', 'cp', generated_tarball, tar_file])
print(".7 Fixing permissions on tarball")
run_command_in_host(['sudo', 'chmod', '777', tar_file])
+
+ print(".8 Returning to original directory, removing temp");
+ shutil.rmtree(tmp_src)
else:
- print("I could not find (%s) on the disk, stopping the build. Kindly check the logs and try again" % 'netdata-%s.tar.gz' % pkg_friendly_version)
+ print("I could not find (%s) on the disk, stopping the build. Kindly check the logs and try again" % generated_tarball)
sys.exit(1)