[X2Go-Commits] [buildscripts] 03/03: bin/build-rpm-package: fix a lot of shellcheck issues, there really have been a few that could have bitten us.

git-admin at x2go.org git-admin at x2go.org
Tue Feb 21 23:14:48 CET 2023


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository buildscripts.

commit 9a558fbd817122f549490c5e718db16496f0b083
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Feb 18 20:54:04 2023 +0100

    bin/build-rpm-package: fix a lot of shellcheck issues, there really have been a few that could have bitten us.
---
 bin/build-rpm-package | 125 +++++++++++++++++++++++++-------------------------
 1 file changed, 63 insertions(+), 62 deletions(-)

diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index 387fb9a..b61bbb8 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -62,10 +62,10 @@ test -f "${HOME}/.buildscripts/${PREFIX}.conf" && . "${HOME}/.buildscripts/${PRE
 	exit 1
 }
 
-: ${NO_DELAY:="no"}
-: ${FORCE_BUILD:="no"}
-: ${RPM_BUILD_FOR:="fedora:${FEDORA_DISTROS} epel:${EPEL_DISTROS} opensuse:${OPENSUSE_DISTROS} sle:${SLE_DISTROS}"}
-: ${PLATFORM:="x86"}
+: "${NO_DELAY:='no'}"
+: "${FORCE_BUILD:='no'}"
+: "${RPM_BUILD_FOR:="fedora:${FEDORA_DISTROS} epel:${EPEL_DISTROS} opensuse:${OPENSUSE_DISTROS} sle:${SLE_DISTROS}"}"
+: "${PLATFORM:='x86'}"
 
 # These parts are not user-serviceable.
 TMP_MOCK_CFG_DIR=""
@@ -148,16 +148,16 @@ set_vars() {
 	CODENAMES="${ARGV2_CODENAME:-${CODENAMES}}"
 	[ -n "${ARGV2_CODENAME}" ] && FORCE_BUILD="yes" || true
 	DATE="${DATE:-$(date -u '+%Y%m%d')}"
-	if [ "x${COMPONENT}" = "x${COMPONENT_RELEASE}" ] || [ "x${COMPONENT}" = "x${COMPONENT_RELEASE}-test" ] || grep -qs "$COMPONENT" <<< "${COMPONENT_RELEASES}"; then
+	if [ "${COMPONENT}" = "${COMPONENT_RELEASE}" ] || [ "${COMPONENT}" = "${COMPONENT_RELEASE}-test" ] || grep -qs "$COMPONENT" <<< "${COMPONENT_RELEASES}"; then
 		CHECKOUT="${3:-build-${COMPONENT}}"
-	elif [ "x${COMPONENT}" = "x${COMPONENT_NIGHTLY}" ]; then
+	elif [ "${COMPONENT}" = "${COMPONENT_NIGHTLY}" ]; then
 		CHECKOUT="${3:-master}"
 	else
 		echo "error: no such package component area for this Git project. Aborting..."
 		exit 1
 	fi
 	# the DATE might be given as ,,today'' from the command line
-	[ "x${DATE}" = "xtoday" ] && DATE="$(date -u '+%Y%m%d')"
+	[ 'today' = "${DATE}" ] && DATE="$(date -u '+%Y%m%d')"
 
 	# This should typically be part of Jenkins's environment, but if we're
 	# building packages manually, provide a sane default.'
@@ -189,9 +189,9 @@ set_vars() {
 # Returns 0 if the mock version is greater or equal the specified input,
 # 1 otherwise.
 check_mock_version_atleast () {
-	typeset MAJOR="${1:?"Error: no major version passed to ${FUNCNAME}()."}"
-	typeset MINOR="${2:?"Error: no minor version passed to ${FUNCNAME}()."}"
-	typeset PATCH="${3:?"Error: no patch version passed to ${FUNCNAME}()."}"
+	typeset MAJOR="${1:?"Error: no major version passed to ${FUNCNAME['0']}()."}"
+	typeset MINOR="${2:?"Error: no minor version passed to ${FUNCNAME['0']}()."}"
+	typeset PATCH="${3:?"Error: no patch version passed to ${FUNCNAME['0']}()."}"
 
 	# Check input parameters for sanity.
 	typeset SANITY_CHECK_MAJOR="$(sed -e 's/^\([0-9][0-9]*\)$//' <<< "${MAJOR}")"
@@ -199,7 +199,7 @@ check_mock_version_atleast () {
 	typeset SANITY_CHECK_PATCH="$(sed -e 's/^\([0-9][0-9]*\)$//' <<< "${PATCH}")"
 
 	if [ -n "${SANITY_CHECK_MAJOR}" ] || [ -n "${SANITY_CHECK_MINOR}" ] || [ -n "${SANITY_CHECK_PATCH}" ]; then
-		echo "Error: input parameters of ${FUNCNAME}() are not pure integers and failed sanity check." >&2
+		echo "Error: input parameters of ${FUNCNAME['0']}() are not pure integers and failed sanity check." >&2
 		exit 1
 	fi
 
@@ -213,7 +213,7 @@ check_mock_version_atleast () {
 	MOCK_VER="$(grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' <<< "${MOCK_VER}")"
 
 	if [ -z "${MOCK_VER}" ]; then
-		echo "Error: the reported mock version can not be handled by ${FUNCNAME}()." >&2
+		echo "Error: the reported mock version can not be handled by ${FUNCNAME['0']}()." >&2
 		exit 1
 	fi
 
@@ -226,7 +226,7 @@ check_mock_version_atleast () {
 	typeset MOCK_VER_PATCH="$(sed -e 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)/\1/' <<< "${MOCK_VER}")"
 
 	if [ -z "${MOCK_VER_MAJOR}" ] || [ -z "${MOCK_VER_MINOR}" ] || [ -z "${MOCK_VER_PATCH}" ]; then
-		echo "Error: unable to parse mock version in ${FUNCNAME}()." >&2
+		echo "Error: unable to parse mock version in ${FUNCNAME['0']}()." >&2
 		exit 1
 	else
 		typeset ret="1"
@@ -263,10 +263,10 @@ check_mock_version_atleast () {
 # Calling this function in a subshell is an error, as it NEEDS to modify
 # variables in global scope!
 create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET arch
-	typeset MOCK_BASE="${1:?"Error: no mock base config passed to ${FUNCNAME}()."}"
-	typeset COMPONENT="${2:?"Error: no component (X2Go release group) passed to ${FUNCNAME}()."}"
-	typeset TARGET="${3:?"Error: no target (full or base) passed to ${FUNCNAME}()."}"
-	typeset arch="${4:?"Error: no architecture passed to ${FUNCNAME}()."}"
+	typeset MOCK_BASE="${1:?"Error: no mock base config passed to ${FUNCNAME['0']}()."}"
+	typeset COMPONENT="${2:?"Error: no component (X2Go release group) passed to ${FUNCNAME['0']}()."}"
+	typeset TARGET="${3:?"Error: no target (full or base) passed to ${FUNCNAME['0']}()."}"
+	typeset arch="${4:?"Error: no architecture passed to ${FUNCNAME['0']}()."}"
 
 	# Check argument sanity.
 
@@ -351,7 +351,7 @@ create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET arch
 	typeset TMP_REGEX_OTHER='^[[:space:]]*\[.*\][[:space:]]*$'
 
 	typeset line=""
-	while read line; do
+	while read -r line; do
 		if [[ "${line}" =~ ${TMP_REGEX_EXTRA} ]]; then
 			FETCH_EXTRA_SECTION=1
 			FETCH_FULL_SECTION=0
@@ -375,6 +375,7 @@ create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET arch
 				line="${line/0/1}"
 			fi
 
+			# shellcheck disable=SC2016
 			case "${line}" in
 				(*'$releasever'*)	line="${line/'$releasever'/${VERSION}}"
 							;;&
@@ -395,7 +396,7 @@ create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET arch
 	TMP_REGEX='^[[:space:]]*config_opts\['"'"'(yum|dnf)\.conf'"'"'\][[:space:]]*=[[:space:]]*"""[[:space:]]*$'
 	typeset TMP_REGEX_END='^[[:space:]]*"""[[:space:]]*$'
 
-	while read line; do
+	while read -r line; do
 		if [[ "${line}" =~ ${TMP_REGEX} ]]; then
 			REPO_START=1
 
@@ -514,12 +515,12 @@ cache_mock_config () {
 # Edits either OTHERMIRROR for type == suse or MOCK_CHROOT_CONFIG for type == redhat.
 # It is an error to execute this function in a subshell, as it MUST edit global variables.
 get_extra_repository () {
-	typeset TYPE="${1:?"Error: no type passed to ${FUNCNAME}()."}"
-	typeset DIST="${2:?"Error: no distribution passed to ${FUNCNAME}()."}"
-	typeset CODENAME="${3:?"Error: no codename (distro 'version') passed to ${FUNCNAME}()."}"
-	typeset COMPONENT="${4:?"Error: no component (X2Go release group) passed to ${FUNCNAME}()."}"
-	typeset PACKAGE="${5:?"Error: no package passed to ${FUNCAME}()."}"
-	typeset ARCH="${6:?"Error: no architecture passed to ${FUNCNAME}()."}"
+	typeset TYPE="${1:?"Error: no type passed to ${FUNCNAME['0']}()."}"
+	typeset DIST="${2:?"Error: no distribution passed to ${FUNCNAME['0']}()."}"
+	typeset CODENAME="${3:?"Error: no codename (distro 'version') passed to ${FUNCNAME['0']}()."}"
+	typeset COMPONENT="${4:?"Error: no component (X2Go release group) passed to ${FUNCNAME['0']}()."}"
+	typeset PACKAGE="${5:?"Error: no package passed to ${FUNCAME['0']}()."}"
+	typeset ARCH="${6:?"Error: no architecture passed to ${FUNCNAME['0']}()."}"
 	typeset WANT_EXTRA="$(make_boolean "${7}")"
 
 	# Note: we always add the extras repo, because that's defined as "packages missing from the main repository",
@@ -567,7 +568,7 @@ get_extra_repository () {
 			[ "${MOCK_BUGGY}" -eq "0" ] && MOCK_CHROOT_CONFIG="${MOCK_CHROOT_CONFIG}.cfg"
 			;;
 		*)
-			echo "Error: unknown type passed to ${FUNCNAME}()" >&2
+			echo "Error: unknown type passed to ${FUNCNAME['0']}()" >&2
 			echo "Valid values: suse, redhat." >&2
 			exit 1
 			;;
@@ -580,9 +581,9 @@ get_extra_repository () {
 # Takes the distribution, its version (either a real number or a codename)
 # and the architecture.
 sign_packages () {
-	typeset dist="${1:?"Error: no distribution passed to ${FUNCNAME}()."}"
-	typeset codename="${2:?"Error: no codename (distro 'version') passed to ${FUNCNAME}()."}"
-	typeset arch="${3:?"Error: no architecture passed to ${FUNCNAME}()."}"
+	typeset dist="${1:?"Error: no distribution passed to ${FUNCNAME['0']}()."}"
+	typeset codename="${2:?"Error: no codename (distro 'version') passed to ${FUNCNAME['0']}()."}"
+	typeset arch="${3:?"Error: no architecture passed to ${FUNCNAME['0']}()."}"
 
 	typeset gpg_sign_with="${GPG_KEY}"
 
@@ -665,7 +666,7 @@ sign_packages () {
 # Takes the *SuSE major version number or a code name.
 # Outputs the mapped major version number or a code name.
 wrap_suse_major_version () {
-	typeset major_version="${1:?"Error: no *SuSE major version passed to ${FUNCNAME}()."}"
+	typeset major_version="${1:?"Error: no *SuSE major version passed to ${FUNCNAME['0']}()."}"
 
 	# tumbleweed has the fictive version number 9999 and should always be getting
 	# passed-through directly.
@@ -688,8 +689,8 @@ wrap_suse_major_version () {
 # Returns success if the passed major and minor OpenSuSE version number is a
 # legacy release, failure otherwise.
 opensuse_is_legacy () {
-	typeset major_version="${1:?"Error: no OpenSuSE major version passed to ${FUNCNAME}()."}"
-	typeset minor_version="${2:?"Error: no OpenSuSE minor version passed to ${FUNCNAME}()."}"
+	typeset major_version="${1:?"Error: no OpenSuSE major version passed to ${FUNCNAME['0']}()."}"
+	typeset minor_version="${2:?"Error: no OpenSuSE minor version passed to ${FUNCNAME['0']}()."}"
 
 	# We're not printing a boolean value, but use the exit code, so the
 	# value must be zero for success (i.e., legacy) and non-zero for
@@ -698,7 +699,7 @@ opensuse_is_legacy () {
 
 	if [[ "${major_version}" != "9999" ]]; then
 		if [ "${major_version}" -lt "15" ] ||
-		   ( [ "${major_version}" -eq "15" ] && [ "${minor_version}" -eq "0" ] ); then
+		   { [ "${major_version}" -eq "15" ] && [ "${minor_version}" -eq "0" ]; }; then
 			ret="0"
 		fi
 	fi
@@ -711,12 +712,12 @@ opensuse_is_legacy () {
 # minor version number.
 # Outputs the generated dist value.
 generate_suse_dist_value () {
-	typeset distname="${1:?"Error: no *SuSE distribution name passed to ${FUNCNAME}()."}"
-	typeset major_version="${2:?"Error: no *SuSE major version passed to ${FUNCNAME}()."}"
-	typeset minor_version="${3:?"Error: no *SuSE minor version passed to ${FUNCNAME}()."}"
+	typeset distname="${1:?"Error: no *SuSE distribution name passed to ${FUNCNAME['0']}()."}"
+	typeset major_version="${2:?"Error: no *SuSE major version passed to ${FUNCNAME['0']}()."}"
+	typeset minor_version="${3:?"Error: no *SuSE minor version passed to ${FUNCNAME['0']}()."}"
 
 	if [ 'sle' != "${distname}" ] && [ 'opensuse' != "${distname}" ]; then
-		printf 'Invalid distribution name '"'"'%s'"'"' passed to %s, only '"'"'sle'"'"' and '"'"'opensuse'"'"' are supported.' "${distname}" "${FUNCNAME}" >&2
+		printf 'Invalid distribution name '"'"'%s'"'"' passed to %s(), only '"'"'sle'"'"' and '"'"'opensuse'"'"' are supported.' "${distname}" "${FUNCNAME['0']}" >&2
 		return '1'
 	fi
 
@@ -727,7 +728,7 @@ generate_suse_dist_value () {
 
 	if [ '9999' = "${major_version}" ]; then
 		if [ 'opensuse' != "${distname}" ]; then
-			printf 'Invalid major version '"'"'%s'"'"' passed to %s for distribution name '"'"'%s'"'"', this is unsupported.' "${major_version}" "${FUNCNAME}" "${distname}" >&2
+			printf 'Invalid major version '"'"'%s'"'"' passed to %s() for distribution name '"'"'%s'"'"', this is unsupported.' "${major_version}" "${FUNCNAME['0']}" "${distname}" >&2
 			return '2'
 		fi
 
@@ -746,8 +747,8 @@ generate_suse_dist_value () {
 # obs-build configuration files.
 # Returns 0 on success or non-0 on failure.
 setup_opensuse_tumbleweed_config() {
-	typeset temp_dir="${1:?"Error: no temporary working directory passed to ${FUNCNAME}()."}"
-	typeset obs_config_dir="${2:?"Error: no obs-build configuration subdirectory passed to ${FUNCNAME}()."}"
+	typeset temp_dir="${1:?"Error: no temporary working directory passed to ${FUNCNAME['0']}()."}"
+	typeset obs_config_dir="${2:?"Error: no obs-build configuration subdirectory passed to ${FUNCNAME['0']}()."}"
 
 	typeset obs_factory_prjconf_url="https://api.opensuse.org/public/source/openSUSE:Factory/_config"
 	typeset obs_tumbleweed_prjconf_url="https://api.opensuse.org/public/source/openSUSE:Tumbleweed/_config"
@@ -783,7 +784,7 @@ setup_opensuse_tumbleweed_config() {
 # Takes a prefix string.
 # Returns 0 on success or non-0 on failure.
 map_prefix_to_vendor() {
-	typeset prefix="${1:?"Error: no prefix string passed to ${FUNCNAME}()."}"
+	typeset prefix="${1:?"Error: no prefix string passed to ${FUNCNAME['0']}()."}"
 
 	typeset out=''
 	typeset ret='1'
@@ -866,13 +867,13 @@ clear_pkgdist() {
 	typeset -a rpm_build_for_arr
 	typeset OLDIFS="${IFS}"
 	IFS=" "
-	read -a rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
+	read -ra rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
 	IFS="${OLDIFS}"
 
 	typeset line=""
 	for line in "${rpm_build_for_arr[@]}"; do
-		l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])"
-		l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}"
+		l_DIST="$(cut -d ':' -f '1' <<< "${line/: /:}" | tr '[:upper:]' '[:lower:]')"
+		l_CODENAMES="${CODENAMES:-$(cut -d ':' -f '2-' <<< "${line/: /:}" | sed -e 's/,/ /g' | tr '[:upper:]' '[:lower:]')}"
 		grep -qs "${l_DIST}" <<< "${RPM_DISTS_SUPPORTED}" && {
 			for l_CODENAME in ${l_CODENAMES}; do
 
@@ -921,13 +922,13 @@ build_packages() {
 	typeset -a rpm_build_for_arr
 	typeset OLDIFS="${IFS}"
 	IFS=" "
-	read -a rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
+	read -ra rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
 	IFS="${OLDIFS}"
 
 	typeset line=""
 	for line in "${rpm_build_for_arr[@]}"; do
-		l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])"
-		l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}"
+		l_DIST="$(cut -d ':' -f '1' <<< "${line/: /:}" | tr '[:upper:]' '[:lower:]')"
+		l_CODENAMES="${CODENAMES:-$(cut -d ':' -f '2-' <<< "${line/: /:}" | sed -e 's/,/ /g' | tr '[:upper:]' '[:lower:]')}"
 		grep -qs "${l_DIST}" <<< "${RPM_DISTS_SUPPORTED}" && {
 			for l_CODENAME in ${l_CODENAMES}; do
 				test -z "${CODENAMES}" || grep "${CODENAMES}" <<< "${line}" || break
@@ -994,7 +995,7 @@ build_packages() {
 					( cd "${PROJECT}" && QUILT_PATCHES="debian/patches" quilt push -a && rm -Rf -- ".pc/"; )
 				fi
 
-				grep -E "^Source[1-9]+:.*" "${PROJECT}.spec" | sed "s/%{name}/${PROJECT}/" | awk '{ print $2 }' | while read source_file; do
+				grep -E "^Source[1-9]+:.*" "${PROJECT}.spec" | sed "s/%{name}/${PROJECT}/" | awk '{ print $2 }' | while read -r source_file; do
 					find "${PROJECT}/rpm/${source_file}" -maxdepth 0 1> /dev/null && cp -- "${PROJECT}/rpm/${source_file}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SOURCES/" && continue
 					find "${PROJECT}/${source_file}" -maxdepth 0 1> /dev/null && cp -- "${PROJECT}/${source_file}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SOURCES/"
 				done
@@ -1005,12 +1006,12 @@ build_packages() {
 				cp -- "${PROJECT}.spec" "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SOURCES"
 
 				# clean up the Git clone from the temp folder
-				cd && rm -Rf -- "${TEMP_DIR}/${PROJECT}"
+				cd && rm -Rf -- "${TEMP_DIR:?}/${PROJECT:?}"
 
 				# modify changelog for this build
 				### TODO: add changelog entry for this automatic build
 
-				if [ "x${l_DIST}" = "xopensuse" ] || [ "x${l_DIST}" = "xsle" ]; then
+				if [ 'opensuse' = "${l_DIST}" ] || [ 'sle' = "${l_DIST}" ]; then
 					# Rename the i386 arch to i586 for OpenSuSE and SLE{S,D}.
 					typeset -a arches_copy
 					arches_copy=("${arches[@]}")
@@ -1083,7 +1084,7 @@ build_packages() {
 
 					extra_obs_build_args+=( '--dist' "${dist_value}" )
 
-					if [ "x${l_DIST}" = "xopensuse" ]; then
+					if [ 'opensuse' = "${l_DIST}" ]; then
 						typeset -i legacy_release="0"
 
 						tmp_suse_major_version="$(wrap_suse_major_version "${tmp_suse_major_version}")"
@@ -1137,7 +1138,7 @@ build_packages() {
 
 							extra_obs_build_args+=( "--configdir" "${TEMP_DIR}/${obs_config_dir}" )
 						fi
-					elif [ "x${l_DIST}" = "xsle" ]; then
+					elif [ 'sle' = "${l_DIST}" ]; then
 						for ((i = 0; i < ${#SLE_DOWNLOAD_URL[@]}; ++i)) do
 							download_url[i]="$(sed "s/#VERSION#/${l_CODENAME}/g" <<< "${SLE_DOWNLOAD_URL[i]}")"
 						done
@@ -1166,7 +1167,7 @@ build_packages() {
 							exit 1
 						fi
 
-						if [ "x${l_DIST}" = "xfedora" ] || [ "x${l_DIST}" = "xepel" ]; then
+						if [ 'fedora' = "${l_DIST}" ] || [ 'epel' = "${l_DIST}" ]; then
 							# Previously used ~mock here, but don't, since on typical systems
 							# (no matter whether Debian, CentOS or Fedora), a "mock" user does
 							# not exist - only a "mock" group.
@@ -1224,8 +1225,8 @@ build_packages() {
 							fi
 						fi
 					else
-						if [ -n "${l_ARCH}" ] && [ "x${SKIP_ARCH}" != "x${l_ARCH}" ]; then
-							if [ "x${l_DIST}" = "xopensuse" ] || [ "x${l_DIST}" = "xsle" ]; then
+						if [ -n "${l_ARCH}" ] && [ "${SKIP_ARCH}" != "${l_ARCH}" ]; then
+							if [ 'opensuse' = "${l_DIST}" ] || [ 'sle' = "${l_DIST}" ]; then
 								# Skip architecture-dependent build, if the package is noarch and we already have a binary package.
 								if [ "${IS_NOARCH}" = "yes" ] && [ "${noarch_built}" -ne "0" ]; then
 									continue
@@ -1318,13 +1319,13 @@ upload_packages() {
 	typeset -a rpm_build_for_arr
 	typeset OLDIFS="${IFS}"
 	IFS=" "
-	read -a rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
+	read -ra rpm_build_for_arr <<< "${RPM_BUILD_FOR}"
 	IFS="${OLDIFS}"
 
 	typeset line=""
 	for line in "${rpm_build_for_arr[@]}"; do
-		l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])"
-		l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}"
+		l_DIST="$(cut -d ':' -f '1' <<< "${line/: /:}" | tr '[:upper:]' '[:lower:]')"
+		l_CODENAMES="${CODENAMES:-$(cut -d ':' -f '2-' <<< "${line/: /:}" | sed -e 's/,/ /g' | tr '[:upper:]' '[:lower:]')}"
 		for l_CODENAME in ${l_CODENAMES}; do
 
 			test -z "${CODENAMES}" || grep "${CODENAMES}" <<< "${line}" || break
@@ -1365,7 +1366,7 @@ upload_packages() {
 					if [ "x${SKIP_ARCH}" != "x${l_ARCH}" ]; then
 						# Copy (s)rpms into repo.
 						cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/${real_arch}"
-						scp *.rpm "${REPOS_SERVER}:'${RPM_REPOS_BASE}/${l_DIST}/${l_CODENAME}/${COMPONENT}/${real_arch}/${PROJECT}/'" || true
+						scp ./*.rpm "${REPOS_SERVER}:'${RPM_REPOS_BASE}/${l_DIST}/${l_CODENAME}/${COMPONENT}/${real_arch}/${PROJECT}/'" || true
 					fi
 				else
 					if [ "x${SKIP_ARCH}" != "x${l_ARCH}" ]; then
@@ -1381,7 +1382,7 @@ upload_packages() {
 					# Copy (s)rpms into repo.
 					if [ "x${SKIP_ARCH}" != "x${l_ARCH}" ]; then
 						cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}"
-						scp *.rpm "${REPOS_SERVER}:'${RPM_REPOS_BASE}/${l_DIST}/${l_CODENAME}/${COMPONENT}/${l_ARCH}/rpms/${PROJECT}/'" || true
+						scp ./*.rpm "${REPOS_SERVER}:'${RPM_REPOS_BASE}/${l_DIST}/${l_CODENAME}/${COMPONENT}/${l_ARCH}/rpms/${PROJECT}/'" || true
 					fi
 
 					typeset createrepo_opts=""
@@ -1496,7 +1497,7 @@ upload_packages() {
 
 ### MAIN ###
 set_vars "${@}" && {
-	if [ "x$(basename "${0}")" = "x${PREFIX}-build-rpm-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-build+upload-rpm-package" ]; then
+	if [ "$(basename "${0}")" = "${PREFIX}-build-rpm-package" ] || [ "$(basename "${0}")" = "${PREFIX}-build+upload-rpm-package" ]; then
 		FORCE_BUILD="$(make_boolean "${FORCE_BUILD}")"
 		NO_DELAY="$(make_boolean "${NO_DELAY}")"
 
@@ -1517,7 +1518,7 @@ set_vars "${@}" && {
 			unlock_workspace "${LOCK_FILE}"
 		}
 	fi
-	if [ "x$(basename "${0}")" = "x${PREFIX}-upload-rpm-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-build+upload-rpm-package" ]; then
+	if [ "$(basename "${0}")" = "${PREFIX}-upload-rpm-package" ] || [ "$(basename "${0}")" = "${PREFIX}-build+upload-rpm-package" ]; then
 		upload_packages
 	fi
 }

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list