From fbdd8a985d10dda1713b96dfa346a5a19f58d522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Fri, 27 Sep 2024 12:04:29 +0200 Subject: [PATCH] make_srpm: fallback to tar if git archive fails All copr builds are currently failing due to: https://github.com/fedora-copr/copr/issues/3421 --- contrib/fedora/make_srpm.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/fedora/make_srpm.sh b/contrib/fedora/make_srpm.sh index f19b283e118..b82294970a4 100755 --- a/contrib/fedora/make_srpm.sh +++ b/contrib/fedora/make_srpm.sh @@ -166,10 +166,21 @@ sed -e "s/@PACKAGE_NAME@/$PACKAGE_NAME/" \ > "$RPMBUILD/SPECS/$PACKAGE_NAME.spec" NAME="$PACKAGE_NAME-$PACKAGE_VERSION" +TARBALL="$RPMBUILD/SOURCES/$NAME.tar.gz" + git archive --format=tar --prefix="$NAME"/ \ --remote="file://$SRC_DIR" \ - HEAD \ - | gzip > "$RPMBUILD/SOURCES/$NAME.tar.gz" + HEAD | gzip > "$TARBALL" + +# fallback to tar if git archive failed +# tar may include more files so git archive is preferred +tar -tzf "$TARBALL" &> /dev/null +if [ $? -ne 0 ]; then + rm -f "$TARBALL" + pushd "$SRC_DIR" + tar -cvzf "$TARBALL" --transform "s,^,$NAME/," * + popd +fi cp "$SRC_DIR"/contrib/*.patch "$RPMBUILD/SOURCES" 2>/dev/null add_patches "$RPMBUILD/SPECS/$PACKAGE_NAME.spec" \