From 362b527470f5332085d38490879f9671af65b7e9 Mon Sep 17 00:00:00 2001 From: Emanuele Aina <emanuele.aina@collabora.com> Date: Wed, 20 Mar 2019 16:51:32 +0100 Subject: [PATCH] ostree-prepare-local-repo: Split ostree repo creation out of Jenkinsfile Move the shell commands to prepare the local ostree repository out of the Jenkinsfile to a script for easier usage when building locally. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com> --- Jenkinsfile | 16 +-------------- scripts/ostree-prepare-local-repo.sh | 29 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) create mode 100755 scripts/ostree-prepare-local-repo.sh diff --git a/Jenkinsfile b/Jenkinsfile index 91c02a5d..956d55da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -227,21 +227,7 @@ def buildOStree(architecture, type, board, debosarguments = "", repo = "repo") { sh(script: """ cd ${PIPELINE_VERSION}/${architecture}/${type} rm -rf ${repo} - mkdir ${repo} - ostree init --repo=${repo} --mode archive-z2 - ostree remote --repo=${repo} add --no-gpg-verify origin ${ostree_pull_url} - http_code=\$(curl --location --silent -o /dev/null --head -w "%{http_code}" ${ostree_pull_url}/refs/heads/${branch}) - case \$http_code in - 200) - ostree pull --repo=${repo} --depth=-1 --mirror --disable-fsync origin ${branch} - ;; - 404) - ;; - *) - echo "Error: Got HTTP \$http_code trying to fetch ${ostree_pull_url}/refs/heads/${branch}" - exit 1 - ;; - esac + ${WORKSPACE}/scripts/ostree-prepare-local-repo.sh ${repo} ${ostree_pull_url} ${branch} """) sh(script: """ diff --git a/scripts/ostree-prepare-local-repo.sh b/scripts/ostree-prepare-local-repo.sh new file mode 100755 index 00000000..5fafe921 --- /dev/null +++ b/scripts/ostree-prepare-local-repo.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -eu + +if [ $# -ne 3 ] +then + echo "Usage: $0 REPO PULL_URL BRANCH" >&2 + exit 1 +fi + +repo=$1 +ostree_pull_url=$2 +branch=$3 + +mkdir -p "${repo}" +ostree init --repo="${repo}" --mode archive-z2 +ostree remote --repo="${repo}" add --no-gpg-verify origin "${ostree_pull_url}" +http_code=$(curl --location --silent -o /dev/null --head -w "%{http_code}" "${ostree_pull_url}/refs/heads/${branch}") +case "$http_code" in + 200) + ostree pull --repo="${repo}" --depth=-1 --mirror --disable-fsync origin "${branch}" + ;; + 404) + ;; + *) + echo "Error: Got HTTP '$http_code' trying to fetch '${ostree_pull_url}/refs/heads/${branch}'" + exit 1 + ;; +esac -- GitLab