[X2Go-Commits] [buildscripts] 01/01: bin/build-rpm-package: fix find calls. Use weird read -r -d '' trick to parse 0-delimited pseudo-arrays.

git-admin at x2go.org git-admin at x2go.org
Fri Apr 3 03:49:37 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 21f2262912ad73a48f8325eed32fb8622c05373b
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri Apr 3 03:49:25 2015 +0200

    bin/build-rpm-package: fix find calls. Use weird read -r -d '' trick to parse 0-delimited pseudo-arrays.
---
 bin/build-rpm-package |   31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index 4b8ccbf..c8158ce 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -704,13 +704,19 @@ build_packages() {
 						             --clean \
 						             "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SOURCES/${PROJECT}.spec"; then
 							mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/x86_64/"
-							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/x86_64/${BUILD_RESULT}/RPMS/" -type f | grep -E '.*\.rpm$' | grep -Ev '.*\.src\.rpm$' | while read rpmfile; do
+
+							# -r parameter to read: Backslashes may NOT escape any characters!
+							# -d '': specifies the delimiter to be used - as '' resolves to an empty string followed
+							#        by a NUL character, the delimiter is set to this very NUL (\000) character.
+							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/x86_64/${BUILD_RESULT}/RPMS/" -type f \( -iname '*.rpm' -and -not -iname '*.src.rpm' \) -print0 | while read -r -d '' rpmfile; do
 								cp "${rpmfile}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/x86_64/"
 							done
 							rpmsign-unattended -D "%_gpg_name debian at x2go.org" --addsign "${PKGDIST}/${l_DIST}/${l_CODENAME}/x86_64/"*.rpm
 
 							# also copy and sign source RPM's
-							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/x86_64/${BUILD_RESULT}/SRPMS/" -type f | grep -E '.*\.rpm$' | while read rpmfile; do
+							# For information on why this weird -print0 | read -r -d '' construction works,
+							# refer to the first instance of this in this script.
+							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/x86_64/${BUILD_RESULT}/SRPMS/" -type f -iname '*.rpm' -print0 | while read -r -d '' rpmfile; do
 								cp "${rpmfile}" "$PKGDIST/${l_DIST}/${l_CODENAME}/SRPM/"
 							done
 							rpmsign-unattended -D "%_gpg_name debian at x2go.org" --addsign "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM/"*.rpm
@@ -726,7 +732,10 @@ build_packages() {
 
 						# Obtain packages from our RPM repository.
 						get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "x86_64" "${RPM_WANT_EXTRA_REPOS}"
-						find "${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
+
+						# For information on why this weird -print0 | read -r -d '' construction works,
+						# refer to the first instance of this in this script.
+						find "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SRPMS/" -type 'f' -iname "${PROJECT}-${UPSTREAM_VERSION}-${PKG_SRCRELEASE}.${IS_RELEASE}.git${DATE}.${GITREV}.${COMPONENT}.*.src.rpm" -print0 | while read -r -d '' srpm; do
 							if mock ${MOCK_CHROOT_CONFIG} --resultdir="${PKGDIST}/${l_DIST}/${l_CODENAME}/x86_64" "${srpm}"; then
 								# copy and later sign source RPM
 								cp "${srpm}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM/"
@@ -779,15 +788,20 @@ build_packages() {
 						                    --clean \
 						                    "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SOURCES/${PROJECT}.spec"; then
 							mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/i386/"
-							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/i386/${BUILD_RESULT}/RPMS/" -type f | grep -E '.*\.rpm$' | grep -Ev '.*\.src\.rpm$' | while read rpmfile; do
+
+							# For information on why this weird -print0 | read -r -d '' construction works,
+							# refer to the first instance of this in this script.
+							find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/i386/${BUILD_RESULT}/RPMS/" -type 'f' \( -iname '*.rpm' -and -not -iname '*.src.rpm' \) -print0 | while read -r -d '' rpmfile; do
 								cp "${rpmfile}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/i386/"
 							done
 							rpmsign-unattended -D "%_gpg_name debian at x2go.org" --addsign "${PKGDIST}/${l_DIST}/${l_CODENAME}/i386/"*.rpm
 
 							# copy and later sign source RPM's, if needed (that is, not already generated by x86_64/noarch code above)
-							SEARCH_SRPM="$(find "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM" -type 'f' -name "*.src.rpm" -print)"
+							SEARCH_SRPM="$(find "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM" -type 'f' -iname "*.src.rpm" -print)"
 							if [ -z "${SEARCH_SRPM}" ]; then
-								find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/i386/${BUILD_RESULT}/SRPMS/" -type 'f' | grep -E '.*\.src\.rpm$' | while read rpmfile; do
+								# For information on why this weird -print0 | read -r -d '' construction works,
+								# refer to the first instance of this in this script.
+								find "/var/cache/obs-build/${l_DIST}/${l_CODENAME}/i386/${BUILD_RESULT}/SRPMS/" -type 'f' -iname '*.src.rpm' -print0 | while read -r -d '' rpmfile; do
 									cp "${rpmfile}" "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM/"
 								done
 								rpmsign-unattended -D "%_gpg_name debian at x2go.org" --addsign "${PKGDIST}/${l_DIST}/${l_CODENAME}/SRPM/"*.rpm
@@ -804,7 +818,10 @@ build_packages() {
 
 						# Obtain packages from our RPM repository.
 						get_extra_repository "redhat" "${l_DIST}" "${l_CODENAME}" "${COMPONENT}" "${PROJECT}" "i386" "${RPM_WANT_EXTRA_REPOS}"
-						find "${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
+
+						# For information on why this weird -print0 | read -r -d '' construction works,
+						# refer to the first instance of this in this script.
+						find "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/rpmbuild/SRPMS/" -type 'f' -iname "${PROJECT}-${UPSTREAM_VERSION}-${PKG_SRCRELEASE}.${IS_RELEASE}.git${DATE}.${GITREV}.${COMPONENT}.*.src.rpm" -print0 | while read -r -d '' 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
 								SIGN_SRPM="0"

--
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