+test_rails_package_presence() {
+ local pkgname="$1"; shift
+ local srcdir="$1"; shift
+
+ if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
+ return 1
+ fi
+
+ tmppwd=`pwd`
+
+ cd $srcdir
+
+ local version="$(version_from_git)"
+
+ cd $tmppwd
+
+ test_package_presence $pkgname $version rails "$RAILS_PACKAGE_ITERATION"
+}
+
+test_package_presence() {
+ local pkgname="$1"; shift
+ local version="$1"; shift
+ local pkgtype="$1"; shift
+ local iteration="$1"; shift
+ local arch="$1"; shift
+
+ if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
+ return 1
+ fi
+
+ if [[ "$iteration" == "" ]]; then
+ iteration="$(default_iteration "$pkgname" "$version" "$pkgtype")"
+ fi
+
+ if [[ "$arch" == "" ]]; then
+ rpm_architecture="x86_64"
+ deb_architecture="amd64"
+
+ if [[ "$pkgtype" =~ ^(python|python3)$ ]]; then
+ rpm_architecture="noarch"
+ deb_architecture="all"
+ fi
+
+ if [[ "$pkgtype" =~ ^(src)$ ]]; then
+ rpm_architecture="noarch"
+ deb_architecture="all"
+ fi
+
+ # These python packages have binary components
+ if [[ "$pkgname" =~ (ruamel|ciso|pycrypto|pyyaml) ]]; then
+ rpm_architecture="x86_64"
+ deb_architecture="amd64"
+ fi
+ else
+ rpm_architecture=$arch
+ deb_architecture=$arch
+ fi
+
+ if [[ "$FORMAT" == "deb" ]]; then
+ local complete_pkgname="${pkgname}_$version${iteration:+-$iteration}_$deb_architecture.deb"
+ else
+ # rpm packages get iteration 1 if we don't supply one
+ iteration=${iteration:-1}
+ local complete_pkgname="$pkgname-$version-${iteration}.$rpm_architecture.rpm"
+ fi
+
+ # See if we can skip building the package, only if it already exists in the
+ # processed/ directory. If so, move it back to the packages directory to make
+ # sure it gets picked up by the test and/or upload steps.
+ if [[ -e "processed/$complete_pkgname" ]]; then
+ echo "Package $complete_pkgname exists, not rebuilding!"
+ mv processed/$complete_pkgname .
+ return 1
+ else
+ echo "Package $complete_pkgname not found, building"
+ return 0
+ fi
+}
+