From b1e002ecb342601ac12de913e246e1d6281dc667 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Fri, 29 Aug 2025 10:56:34 +0200
Subject: [PATCH] Skip signing when there are no files to sign (bsc#1248618).

Signed-off-by: Chun-Yi Lee <jlee@suse.com>
---
 brp-99-pesign | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Index: pesign-obs-integration-10.2+git20230612.4699910/brp-99-pesign
===================================================================
--- pesign-obs-integration-10.2+git20230612.4699910.orig/brp-99-pesign
+++ pesign-obs-integration-10.2+git20230612.4699910/brp-99-pesign
@@ -89,7 +89,7 @@ else
 	cert=/dev/null
 fi
 
-cd "$RPM_BUILD_ROOT"
+pushd "$RPM_BUILD_ROOT"
 args=()
 for pattern in $files; do
 	pattern=${pattern#/}
@@ -133,9 +133,18 @@ for f in "${files[@]}"; do
 	esac
 done
 cd "$archive_dir"
-find . -type f | cpio -H newc -o >"$archive"
+nfiles="$(find . -type f | wc -l)"
+if [ "$nfiles" != 0 ] ; then
+	find . -type f | cpio -H newc -o >"$archive"
+fi
 rm -rf "$archive_dir"
 
+if [ "$nfiles" = 0 ] ; then
+echo "No files in $archive, giving up"
+	exit 0
+fi
+popd
+
 if test -e $RPM_SOURCE_DIR/pesign-spec-macros; then
 	sed "
 		s:%{name}:$RPM_PACKAGE_NAME:g
