rpmrebuild/backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch
dongyuzhen 55f36a3bd5 backport some patches from upstream
(cherry picked from commit 68dbac9129a10702702016d5bdde7f0ec041e6df)
2024-12-10 11:34:15 +08:00

179 lines
4.5 KiB
Diff

From 0336b36fa5ae1620b7d490cbad1c1420749d5bb7 Mon Sep 17 00:00:00 2001
From: Eric Gerbier <gerbier@users.sourceforge.net>
Date: Sat, 2 Nov 2024 17:42:33 +0100
Subject: [PATCH] - bugfix comment missing with spec-only on rpm file - bugfix
file with space
---
processing_func.src | 42 ++++++++++++++++++++----------------------
rpmrebuild.sh | 2 +-
rpmrebuild_files.sh | 17 ++---------------
rpmrebuild_ghost.sh | 6 +++++-
rpmrebuild_lib.src | 9 ++-------
5 files changed, 30 insertions(+), 46 deletions(-)
diff --git a/processing_func.src b/processing_func.src
index 4e42f3d..9bc5cf5 100755
--- a/processing_func.src
+++ b/processing_func.src
@@ -407,47 +407,45 @@ function CheckMissing {
# %dir %attr(0755, root, root) "/usr/lib/rpmrebuild"
while :; do
- read line
+ local line
+ local OLD_IFS
+ OLD_IFS="$IFS"
+ IFS=""
+ read -r line
+ IFS="$OLD_IFS"
+ # test end of input
[ -z "$line" ] && break
+ local file
+ local is_ghost
file=$( echo $line | cut -d\" -f2 )
is_ghost=$( echo $line | grep '%ghost')
- # quote meta characters
- # see also in rpmrebuild_files.sh
- #file=$( quote $file )
- if [ -n "$RPMREBUILD_NOQUOTE" ]
- then
- # no quote
- echo
- else
- case "$line" in
- # replace * by \*
- x*\**) line=${line//\*/\\*} ;;
- # replace \ by \\
- x*\\*) line=${line//\\/\\\\} ;;
- x*) ;;
- esac
- fi
+ # test real file
+ tst_file=$( echo -e "$file" )
if [ -n "$is_ghost" ]
then
# ghost file may be missing
- echo $line
+ echo "$line"
elif [ -n "$package_flag" ]
then
# work on rpm file
# check in buildroot tar expand
- if [ -e "${BUILDROOT}/${file}" ]
+ if [ "X$spec_only" = "Xyes" ]
+ then
+ # no way to check because no buildroot, no file extracted
+ echo -E "$line"
+ elif [ -e "${BUILDROOT}/${tst_file}" ]
then
- echo $line
+ echo -E "$line"
else
echo "# MISSING: $line"
fi
else
# work on installed package
- if [ -e "${file}" ]
+ if [ -e "${tst_file}" ]
then
- echo $line
+ echo -E "$line"
else
echo "# MISSING: $line"
fi
diff --git a/rpmrebuild.sh b/rpmrebuild.sh
index b4d1f0a..ce359e9 100755
--- a/rpmrebuild.sh
+++ b/rpmrebuild.sh
@@ -134,7 +134,7 @@ function RpmUnpack
# create buildroot if necessary
function CreateBuildRoot
{
- Debug '(CreateBuildRoot)'
+ Debug "(CreateBuildRoot) $BUILDROOT"
if [ "x$package_flag" = "x" ]; then
# installed package
if [ "X$need_change_files" = "Xyes" ]; then
diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh
index 32e3198..3301ea9 100755
--- a/rpmrebuild_files.sh
+++ b/rpmrebuild_files.sh
@@ -101,20 +101,7 @@ while :; do
#[ -n "$wild" ] && file=$(echo "$file"|sed 's/\*/\\*/')
# quick and portable
# quote metacharacters, see also CheckMissing (processing_func.src)
-# file=$( quote $file )
- if [ -n "$RPMREBUILD_NOQUOTE" ]
- then
- # do not quote
- echo
- else
- case "$file" in
- # replace * by \*
- x*\**) file=${file//\*/\\*} ;;
- # replace \ by \\
- x*\\*) file=${file//\\/\\\\} ;;
- x*) ;;
- esac
- fi
+ file=$( Quote "$file" )
# comment missing files is now done after in CheckMissing func (processing_func.src)
# to be able to work also on rpm files (not expanded yet in this state)
@@ -257,6 +244,6 @@ while :; do
esac
fi
- echo "${lang_str}${dir_str}${fflags_str}${attr_str}${caps_str}${verify_str}\"${file}\""
+ echo -E "${lang_str}${dir_str}${fflags_str}${attr_str}${caps_str}${verify_str}\"${file}\""
done || Critical "$MY_BASENAME done"
exit 0
diff --git a/rpmrebuild_ghost.sh b/rpmrebuild_ghost.sh
index a6f03e3..d743369 100755
--- a/rpmrebuild_ghost.sh
+++ b/rpmrebuild_ghost.sh
@@ -59,7 +59,11 @@ while :; do
read file_verify
read file_lang
read file_cap
- read file
+ # Trailer space may be part of filename.
+ OLD_IFS="$IFS"
+ IFS=""
+ read -r file
+ IFS="$OLD_IFS"
case "X$file_flags" in
X*g*)
diff --git a/rpmrebuild_lib.src b/rpmrebuild_lib.src
index 70fe923..e0e02b4 100755
--- a/rpmrebuild_lib.src
+++ b/rpmrebuild_lib.src
@@ -134,18 +134,13 @@ function TestAwk
fi
}
###############################################################################
-# todo : quote meta characters is used in 2 subs
-# rpmrebuild_files.sh
-# processing_func.src : CheckMissing
+# quote meta characters is used in rpmrebuild_files.sh
function Quote
{
local x
x="$1"
- if [ -n "$RPMREBUILD_NOQUOTE" ]
+ if [ -z "$RPMREBUILD_NOQUOTE" ]
then
- # do not quote
- echo
- else
case "$x" in
# replace * by \*
x*\**) x=${x//\*/\\*} ;;
--
2.46.0