From 068224b431aadee1d3f7891b0855fcf9ada43ebe Mon Sep 17 00:00:00 2001 From: Jens Steidl <Jens.Steidl@slub-dresden.de> Date: Thu, 21 Sep 2023 18:14:03 +0200 Subject: [PATCH] - init: debian packaging --- .gitlab-ci.yml | 37 ++++++++++++++++++++++++++-- gitlab-ci/validate_workflows.control | 8 ++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 gitlab-ci/validate_workflows.control diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3d1b238..cc3d4c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,13 +19,46 @@ image: sdvharbor.slub-dresden.de/replication/debian:bookworm-slim before_script: - - apt-get update - - apt-get -y install shellcheck + - apt-get update && \ + apt-get dist-upgrade -y && \ + apt-get autoremove -y && \ + apt-get install -y dpkg git sed shellcheck stages: # List of stages for jobs, and their order of execution - test + - packaging test-job: # This job runs in the test stage. stage: test # It only starts when the job in the build stage completes successfully. script: - shellcheck --color=always --shell=bash --enable=all --exclude=SC2317 "validate_workflow.sh" + +packaging-job: + stage: packaging + timeout: 5m + script: + # HINT: current working dir == '/builds/digital-preservation/validate_workflows' as root + # retrieve version infos + - REVISION="1" + - BRANCH="$(([ -z "${CI_COMMIT_BRANCH}" ] && echo ${CI_COMMIT_TAG} || echo ${CI_COMMIT_BRANCH}) | sed "s#[^A-Za-z0-9\.~+-]##g")" # use tag name in tag pipelines, filter characters based on https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version + - VERSION="$(git rev-list HEAD --count)-${BRANCH}" + - ARCHITECTURE="all" + # create build dir structure + - DEB_BUILD_DIR="slubarchiv-xml-catalog_${VERSION}-${REVISION}_${ARCHITECTURE}" + - mkdir -p ${DEB_BUILD_DIR}/DEBIAN + # copy project files to be packaged + - cp src/* ${DEB_BUILD_DIR}/ + # copy & rename deb control file template + - cp gitlab-ci/validate_workflows.control ${DEB_BUILD_DIR}/DEBIAN/control + # set package version + - sed -i "s#VERSION_PLACEHOLDER#$VERSION-$REVISION#g" ${DEB_BUILD_DIR}/DEBIAN/control + # add checksums + - pushd ${DEB_BUILD_DIR} + - md5sum $(find * -type f -not -path 'DEBIAN/*') > DEBIAN/md5sums + - popd + # build binary deb package + - dpkg-deb --build --root-owner-group ${DEB_BUILD_DIR}/ + artifacts: + paths: + # package name: validate-workflows_[VERSION]-[REVISION]_[ARCHITECTURE].deb + - "*.deb" \ No newline at end of file diff --git a/gitlab-ci/validate_workflows.control b/gitlab-ci/validate_workflows.control new file mode 100644 index 0000000..47433e1 --- /dev/null +++ b/gitlab-ci/validate_workflows.control @@ -0,0 +1,8 @@ +Package: validate_workflows +Version: VERSION_PLACEHOLDER +Architecture: all +Maintainer: SLUBArchiv.digital <langzeitarchiv@slub-dresden.de> +Description: This is a meta tool to validate files based on specified SLUBArchiv.digital recommendations. +Homepage: https://git.slub-dresden.de/digital-preservation/validate_workflows +Section: main +Priority: optional \ No newline at end of file -- GitLab