diff options
author | Mihai Moldovan <ionic@ionic.de> | 2015-04-01 05:00:05 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2015-04-01 05:00:05 +0200 |
commit | 3c9f2cb4c63388d66903c448fd4b6769787918b4 (patch) | |
tree | 4dbe683a29ea670ee66638de07974120599ae132 /bin | |
parent | 893c96a40430d0eb7868019a4d55110f8bd5b1e1 (diff) | |
download | buildscripts-3c9f2cb4c63388d66903c448fd4b6769787918b4.tar.gz buildscripts-3c9f2cb4c63388d66903c448fd4b6769787918b4.tar.bz2 buildscripts-3c9f2cb4c63388d66903c448fd4b6769787918b4.zip |
bin/build-rpm-package: add the easy part of create_mock_config().
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/build-rpm-package | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/build-rpm-package b/bin/build-rpm-package index ca88489..5b60fa5 100755 --- a/bin/build-rpm-package +++ b/bin/build-rpm-package @@ -182,6 +182,45 @@ repeat_str() { # INPUT COUNT printf "${ret}" } +# Creates a custom mock config file given a base config (taken from +# /etc/mock/), a custom repository file (also taken from /etc/mock/), +# the build component and the target specification ("full" or "base"). +# Base refers to adding x2go-extras only, while full means also +# adding the full X2Go upstream repository with all published files. +# The created config file path is returned. +create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET + typeset MOCK_BASE="${1:?"Error: no mock base config passed to ${FUNCNAME}()."}" + typeset CUSTOM_REPO="${2:?"Error: no mock custom repository file passed to ${FUNCNAME}()."}" + typeset COMPONENT="${3:?"Error: no component (X2Go release group) passed to ${FUNCNAME}()."}" + typeset TARGET="${4:?"Error: no target (full or base) passed to ${FUNCNAME}()."}" + + typeset ret="" + + # Check argument sanity. + typeset i="" + for i in MOCK_BASE CUSTOM_REPO; do + # Must be plain file. + grep -q -s "/" <<< "${!i}" && { + echo "Error: ${i} parameter must not be a path but a simple file name." >&2 + exit -1 + } + + # Must exist. + if [ ! -f "/etc/mock/${!i}" ]; then + echo "Error: ${i} parameter must exist and be a regular file." >&2 + exit -1 + fi + done + + # Note: there is no way to check for the component's validity, + # as LTS releases have "random" names assigned to them. + + if [ "${TARGET}" != "base" ] && [ "${TARGET}" != "full" ]; then + echo "Error: TARGET parameter must be either full or base." >&2 + exit -1 + fi +} + get_extra_repository () { typeset TYPE="${1:?"Error: no type passed to ${FUNCNAME}()."}" typeset DIST="${2:?"Error: no distribution passed to ${FUNCNAME}()."}" |