[X2Go-Commits] [buildscripts] 02/02: bin/build-rpm-package: make get_extra_repository() edit OTHERMIRROR or MOCK_CHROOT_CONFIG directly. Do not call it in a subshell. It needs to modify global variables.

git-admin at x2go.org git-admin at x2go.org
Wed Apr 1 11:32:58 CEST 2015


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

x2go pushed a commit to branch master
in repository buildscripts.

commit 0b2027f09ccba69f6aa12d57cd19495c4e2d677b
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Apr 1 11:32:47 2015 +0200

    bin/build-rpm-package: make get_extra_repository() edit OTHERMIRROR or MOCK_CHROOT_CONFIG directly. Do not call it in a subshell. It needs to modify global variables.
---
 bin/build-rpm-package |   32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index b439522..a5bc52b 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -401,7 +401,9 @@ create_mock_config () { # MOCK_BASE CUSTOM_REPO COMPONENT TARGET
 # the build component (X2Go release group), the package, the architecture
 # and an optional boolean value that determines whether to add any additional
 # repositories at all.
-# Returns a string that can be passed to obs-build or mock.
+#
+# 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}()."}"
@@ -411,22 +413,22 @@ get_extra_repository () {
 	typeset ARCH="${6:?"Error: no architecture passed to ${FUNCNAME}()."}"
 	typeset WANT_EXTRA="$(make_boolean "${7}")"
 
-	typeset ret=""
 	# Note: we always add the extras repo, because that's defined as "packages missing from the main repository",
 	# unless explicitly overridden via ${WANT_EXTRA}.
 	case "${TYPE}" in
 		"suse")
 			# FIXME: make this package repository consistent with our main ones.
+			OTHERMIRROR=""
 			if [ "${WANT_EXTRA}" -eq "1" ]; then
-				ret="--repo http://${REPOS_SERVER}/${DIST}/${CODENAME}/extras"
+				OTHERMIRROR="--repo http://${REPOS_SERVER}/${DIST}/${CODENAME}/extras"
 				if [ -z "${PACKAGE_WITHOUT_OTHERMIRROR}" ] || [ "${PACKAGE_WITHOUT_OTHERMIRROR}" != "${PACKAGE}" ]; then
-					ret="${ret} --repo http://${REPOS_SERVER}/${DIST}/${CODENAME}/${COMPONENT}/${ARCH}"
+					OTHERMIRROR="${OTHERMIRROR} --repo http://${REPOS_SERVER}/${DIST}/${CODENAME}/${COMPONENT}/${ARCH}"
 				fi
 			fi
 			;;
 		"redhat")
 			# Always use -r.
-			ret="-r "
+			MOCK_CHROOT_CONFIG="-r "
 
 			# Itsy-bitsy problem here: mock versions prior to 1.2.0 are buggy in the sense that
 			# they *always* prepend /etc/mock/ and append .cfg to any chroot file specified
@@ -436,7 +438,7 @@ get_extra_repository () {
 			# Find out if we're using a buggy version.
 			check_mock_version_atleast "1" "2" "0" && typeset MOCK_BUGGY="0" || typeset MOCK_BUGGY="1"
 
-			[ "${MOCK_BUGGY}" -eq "1" ] && ret="${ret}../../"
+			[ "${MOCK_BUGGY}" -eq "1" ] && MOCK_CHROOT_CONFIG="${MOCK_CHROOT_CONFIG}../../"
 
 			if [ "${WANT_EXTRA}" -eq "1" ]; then
 				typeset WANT="base"
@@ -447,14 +449,14 @@ get_extra_repository () {
 				create_mock_config "${DIST}-${CODENAME}-${ARCH}" "${COMPONENT}" "${WANT}"
 
 				# Remove the .cfg extension again... and maybe add it back later.
-				ret="${ret}${TMP_MOCK_CFG_FILE%.cfg}"
+				MOCK_CHROOT_CONFIG="${MOCK_CHROOT_CONFIG}${TMP_MOCK_CFG_FILE%.cfg}"
 
 			else
-				ret="${ret}${RPM_MOCK_CONFIG_DIR}/${DIST}-${CODENAME}-${ARCH}"
+				MOCK_CHROOT_CONFIG="${MOCK_CHROOT_CONFIG}${RPM_MOCK_CONFIG_DIR}/${DIST}-${CODENAME}-${ARCH}"
 			fi
 
 			# Add .cfg extension.
-			[ "${MOCK_BUGGY}" -eq "0" ] && ret="${ret}.cfg"
+			[ "${MOCK_BUGGY}" -eq "0" ] && MOCK_CHROOT_CONFIG="${MOCK_CHROOT_CONFIG}.cfg"
 			;;
 		*)
 			echo "Error: unknown type passed to ${FUNCNAME}()" >&2
@@ -462,8 +464,6 @@ get_extra_repository () {
 			exit -1
 			;;
 	esac
-
-	echo "${ret}"
 }
 
 prepare_workspace() {
@@ -590,7 +590,7 @@ build_packages() {
 					rm -f $PKGDIST/$l_DIST/$l_CODENAME/x86_64/build.log
 
 					# Obtain packages from our RPM repository.
-					MOCK_CHROOT_CONFIG="$(get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}")"
+					get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}"
 					if mock --buildsrpm \
 					          ${MOCK_CHROOT_CONFIG} \
 					          --resultdir="$PKGDIST/$l_DIST/$l_CODENAME/rpmbuild/SRPMS" \
@@ -630,7 +630,7 @@ build_packages() {
 						done
 
 						# Obtain packages from our RPM repository.
-						OTHERMIRROR="$(get_extra_repository "suse" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}")"
+						get_extra_repository "suse" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}"
 						if sudo obs-build \
 						             --nosignature \
 						             ${OTHERMIRROR} \
@@ -661,7 +661,7 @@ build_packages() {
 						done
 
 						# Obtain packages from our RPM repository.
-						MOCK_CHROOT_CONFIG="$(get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}")"
+						get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}"
 						ls $PKGDIST/$l_DIST/$l_CODENAME/$l_ARCH/rpmbuild/SRPMS/$PROJECT-$UPSTREAM_VERSION-$PKG_SRCRELEASE.$IS_RELEASE.git$DATE.$GITREV.$COMPONENT.*.src.rpm | while read srpm; do
 							if mock ${MOCK_CHROOT_CONFIG} --resultdir="$PKGDIST/$l_DIST/$l_CODENAME/x86_64" "$srpm"; then
 								# copy and later sign source RPM
@@ -707,7 +707,7 @@ build_packages() {
 						done
 
 						# Obtain packages from our RPM repository.
-						OTHERMIRROR="$(get_extra_repository "suse" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "i386" "${RPM_WANT_EXTRA_REPOS}")"
+						get_extra_repository "suse" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "i386" "${RPM_WANT_EXTRA_REPOS}"
 						if linux32 sudo obs-build \
 						                    --nosignature \
 						                    ${OTHERMIRROR} \
@@ -741,7 +741,7 @@ build_packages() {
 						rm -f $PKGDIST/$l_DIST/$l_CODENAME/i386/build.log
 
 						# Obtain packages from our RPM repository.
-						MOCK_CHROOT_CONFIG="$(get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "i386" "${RPM_WANT_EXTRA_REPOS}")"
+						get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "i386" "${RPM_WANT_EXTRA_REPOS}"
 						ls $PKGDIST/$l_DIST/$l_CODENAME/$l_ARCH/rpmbuild/SRPMS/$PROJECT-$UPSTREAM_VERSION-$PKG_SRCRELEASE.$IS_RELEASE.git$DATE.$GITREV.$COMPONENT.*.src.rpm | while read srpm; do
 							if nice mock ${MOCK_CHROOT_CONFIG} --resultdir="$PKGDIST/$l_DIST/$l_CODENAME/i386" "$srpm"; then
 								# only copy and sign source RPM if necessary

--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list