summaryrefslogtreecommitdiff
path: root/pipelines
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-07-25 08:23:48 +0300
committerLars Wirzenius <liw@liw.fi>2018-07-25 08:23:48 +0300
commit1f0698635d2fbc848d6ac6f14c1b03caa57666f0 (patch)
tree9e6749541bc23926727fd83e610960384359e867 /pipelines
parentb4fd244faa883da8d67cc3a0d538ab1dc6fb47dc (diff)
downloadick2-1f0698635d2fbc848d6ac6f14c1b03caa57666f0.tar.gz
Add: some more proposd standard pipelines for ick
Diffstat (limited to 'pipelines')
-rw-r--r--pipelines/debian.ick111
-rw-r--r--pipelines/persist_workspace.ick31
-rw-r--r--pipelines/systrees.ick47
3 files changed, 189 insertions, 0 deletions
diff --git a/pipelines/debian.ick b/pipelines/debian.ick
new file mode 100644
index 0000000..c6fe573
--- /dev/null
+++ b/pipelines/debian.ick
@@ -0,0 +1,111 @@
+# Lars Wirzenius.
+#
+# Feel free to use this as you wish. It is simple enough that it is
+# probably not even copyrightable.
+
+pipelines:
+
+ # Install build-dependencies for a Debian build, by checking
+ # debian/control for what's missing. The sources parameter is used
+ # to find all the source trees: for each location, if debian/oontrol
+ # exists as the location, look for missing build-dependencies.
+
+ - pipeline: ick/install_debian_build_dependencies
+ parameters:
+ - sources
+ actions:
+ - python: |
+ import os, subprocess
+
+ def RUN(*args, **kwargs):
+ print('Executing:', args)
+ print('kwargs:', kwargs)
+ return subprocess.run(args, **kwargs)
+
+ def OUT(*args, **kwargs):
+ x = RUN(*args, stdout=subprocess.PIPE, **kwargs)
+ return x.stdout.decode('UTF-8')
+
+ def ERR(*args, **kwargs):
+ x = RUN(*args, stderr=subprocess.PIPE, **kwargs)
+ return x.stderr.decode('UTF-8')
+
+ def is_package_name(s):
+ ok = "abcdefghijklmnopqrstyvwxyz"
+ ok += ok.upper()
+ ok += "0123456789.-"
+ return all(c in ok for c in s)
+
+ sources = params['sources']
+ for source in sources:
+ dirname = source['location']
+ control = os.path.join(dirname, 'debian', 'control')
+ if os.path.exists(control):
+ err = ERR('dpkg-checkbuilddeps', cwd=dirname)
+ print('err', err)
+ pat = 'Unmet build dependencies: '
+ if pat in err:
+ parts = err.split(pat)
+ missing = [x for x in parts[1].split() if is_package_name(x)]
+ print('missing', missing)
+ for name in missing:
+ RUN('apt-get', 'install', '-y', name)
+ where: container
+
+
+ # Build Debian packages. This is a CI build, which means a new
+ # debian/changelog entry is created, with a version number that
+ # contains the build number. This way every build results in a new
+ # package version.
+ #
+ # The build will be done in each location in the sources parameter,
+ # where debian/control exists.
+
+ - pipeline: ick/build_deb_ci
+ parameters:
+ - sources
+ actions:
+ - python: |
+ import os, subprocess
+
+ def RUN(*args, **kwargs):
+ print('Executing:', args)
+ print('kwargs:', kwargs)
+ return subprocess.run(args, **kwargs)
+
+ def OUT(*args, **kwargs):
+ x = RUN(*args, stdout=subprocess.PIPE, **kwargs)
+ return x.stdout.decode('UTF-8')
+
+ sources = params['sources']
+ for source in sources:
+ dirname = source['location']
+ control = os.path.join(dirname, 'debian', 'control')
+ if os.path.exists(control):
+ src = OUT('dpkg-parsechangelog', '-S', 'Source')
+ print('src', src)
+
+ ver = OUT('dpkg-parsechangelog', '-S', 'Version')
+ print('ver', ver)
+
+ if '-' in ver:
+ parts = ver.split('-')
+ ver = '-'.join(ver_parts[:-1])
+ ver += '.0ci{}-1'.format(os.environ['BUILD_NUMBER'])
+ print('ver', ver)
+
+ tarball = '../{}_{}.orig.tar.xz'.format(src, ver)
+ print('tarball', tarball)
+
+ RUN('dch', '-v', ver, 'CI build')
+ RUN('dch', '-r', '')
+ RUN('sh', '-c', 'git archive HEAD | xz > {}'.format(tarball))
+ RUN('dpkg-buildpackage', '-us', '-uc')
+ where: container
+
+ # Upload all *.changes files at the root of the workspace.
+
+ - pipeline: ick/upload_debs
+ actions:
+ - action: dput
+ where: host
diff --git a/pipelines/persist_workspace.ick b/pipelines/persist_workspace.ick
new file mode 100644
index 0000000..3f9a903
--- /dev/null
+++ b/pipelines/persist_workspace.ick
@@ -0,0 +1,31 @@
+# Lars Wirzenius.
+#
+# Feel free to use this as you wish. It is simple enough that it is
+# probably not even copyrightable.
+
+pipelines:
+
+ # Save the current contents of the whole workspace, into an artifact
+ # named in the workspace_name parameter.
+
+ - pipeline: ick/save_workspace
+ parameters:
+ - workspace_name
+ actions:
+ - archive: workspace
+ where: host
+ name_from: workspace_name
+
+ # Restore a previously saved workspace from the artifact named in
+ # the workspace_name parameter. If no such artifact exists, do
+ # nothing. If the workspace already has content, it will not be
+ # touched, except that files that also exist in the artifact will be
+ # overwritten.
+
+ - pipeline: ick/restore_workspace
+ parameters:
+ - workspace_name
+ actions:
+ - action: populate_workspace
+ name_from: workspace_name
+ where: host
diff --git a/pipelines/systrees.ick b/pipelines/systrees.ick
new file mode 100644
index 0000000..d675a48
--- /dev/null
+++ b/pipelines/systrees.ick
@@ -0,0 +1,47 @@
+# Lars Wirzenius.
+#
+# Feel free to use this as you wish. It is simple enough that it is
+# probably not even copyrightable.
+
+pipelines:
+
+ # Build a Debian systree. Save it as an artifact named in the
+ # artifact_name parameter. The debian_codename parameter specifies
+ # the Debian release to be used. The packages parameter names
+ # addtional Debian packages to install into the systree. The systree
+ # will get the following packages added unconditionally: python3,
+ # jq, gnupg.
+
+ - pipeline: ick/build_debian_systree
+ parameters:
+ - debian_codename
+ - packages
+ - artifact_name
+ actions:
+ - debootstrap: auto
+ mirror: http://deb.debian.org/debian
+ where: host
+
+ - shell: |
+ apt-get install -y python3 jq gnupg
+ where: chroot
+
+ - python: |
+ import os, subprocess
+ def runcmd(argv, **kwargs):
+ subprocess.check_call(argv, **kwargs)
+ runcmd(['apt-get', 'install', '-y'] + params['packages'])
+ where: chroot
+
+ - archive: workspace
+ where: host
+
+ # Prepare container for building: use the artifact named in the
+ # artifact_name parameter.
+
+ - pipeline: ick/setup_container
+ parameters:
+ - artifact_name
+ actions:
+ - action: populate_systree
+ where: host