rpmrebuild/backport-bugfix-the-comment-missing-option-was-not-working-on.patch
dongyuzhen 55f36a3bd5 backport some patches from upstream
(cherry picked from commit 68dbac9129a10702702016d5bdde7f0ec041e6df)
2024-12-10 11:34:15 +08:00

261 lines
7.5 KiB
Diff
Raw Blame History

From 2904311f19ca1299a0efcfcea80cd389f2b0f0d4 Mon Sep 17 00:00:00 2001
From: Eric Gerbier <gerbier@users.sourceforge.net>
Date: Sat, 19 Oct 2024 14:41:53 +0200
Subject: [PATCH] bugfix : the comment-missing option was not working on rpm
files
---
man/en/rpmrebuild.1.in | 1 -
man/fr_FR.UTF-8/rpmrebuild.1.in | 1 -
man/fr_FR/rpmrebuild.1.in | 1 -
processing_func.src | 63 +++++++++++++++++++++++++++++++++
rpmrebuild.sh | 2 ++
rpmrebuild_files.sh | 14 +++-----
rpmrebuild_lib.src | 21 +++++++++++
rpmrebuild_parser.src | 10 ------
8 files changed, 90 insertions(+), 23 deletions(-)
diff --git a/man/en/rpmrebuild.1.in b/man/en/rpmrebuild.1.in
index 8729d0e..3a590e6 100644
--- a/man/en/rpmrebuild.1.in
+++ b/man/en/rpmrebuild.1.in
@@ -31,7 +31,6 @@ set files posix capabilities as installed files
.TP
\fB\-c, \-\-comment\-missing\fP=<\fIyes\fP|\fIno\fP>
comment out in the specfile missing files. Default: \fBno\fP.
-only applies on installed rpm, not on package files
.TP
\fB\-D, \-\-define\fP=<\fIdefines\fP>
defines to be passed to rpmbuild.
diff --git a/man/fr_FR.UTF-8/rpmrebuild.1.in b/man/fr_FR.UTF-8/rpmrebuild.1.in
index a36585f..aeae281 100644
--- a/man/fr_FR.UTF-8/rpmrebuild.1.in
+++ b/man/fr_FR.UTF-8/rpmrebuild.1.in
@@ -29,7 +29,6 @@ utiliser les capacités posix des fichiers installés
.TP
\fB\-c, \-\-comment\-missing\fP=<\fIyes\fP|\fIno\fP>
commente les fichiers manquants dans le fichier specfile. Defaut: \fBno\fP (non).
-ne s'applique qu'aux packages installés, pas aux fichiers
.TP
\fB\-D, \-\-define\fP=<\fIdefines\fP>
définition(s) à passer au programme \fBrpmbuild\fP.
diff --git a/man/fr_FR/rpmrebuild.1.in b/man/fr_FR/rpmrebuild.1.in
index 0d30327..f8157ca 100644
--- a/man/fr_FR/rpmrebuild.1.in
+++ b/man/fr_FR/rpmrebuild.1.in
@@ -29,7 +29,6 @@ utiliser les capacit
.TP
\fB\-c, \-\-comment\-missing\fP=<\fIyes\fP|\fIno\fP>
commente les fichiers manquants dans le fichier specfile. Defaut: \fBno\fP (non).
-ne s'applique qu'aux packages install<6C>s, pas aux fichiers
.TP
\fB\-D, \-\-define\fP=<\fIdefines\fP>
d<>finition(s) <20> passer au programme \fBrpmbuild\fP.
diff --git a/processing_func.src b/processing_func.src
index 7a513f7..032c950 100755
--- a/processing_func.src
+++ b/processing_func.src
@@ -18,6 +18,7 @@
function processing_init
{
+ Debug "(processing_init)"
spec_concatenated="no"
local SPEC_DIR=$TMPDIR_WORK
@@ -74,6 +75,7 @@ function processing_init
function processing_spec_change
{
+ Debug "(processing_spec_change)"
local Func="processing_spec_change"
if [ $# -ne 1 ] || [ "x$1" = "x" ]
then
@@ -298,6 +300,7 @@ function processing_spec_change
function processing_fini
{
+ Debug "(processing_fini)"
local cmd
if [ "X$spec_concatenated" = "Xyes" ]; then
case "x$specfile" in
@@ -339,6 +342,7 @@ function processing_fini
function CreateProcessing
{
+ Debug "(CreateProcessing)"
if [ $# -ne 1 ] || [ "x$1" = "x" ]
then
Error "(CreateProcessing) <operation>"
@@ -386,3 +390,62 @@ function CreateProcessing
esac || Error "(CreateProcessing) esac" || return
return 0
}
+
+# used to comment missing files in file section
+# write a new files.x
+function CheckMissing {
+
+ Debug "(CheckMissing) BUILDROOT=$BUILDROOT"
+
+ if [ "X$RPMREBUILD_COMMENT_MISSING" = "Xyes" ]; then
+ local SPEC_IN=$SPEC_FILES.$si_files
+ si_files=$(( si_files + 1 ))
+ local SPEC_OUT=$SPEC_FILES.$si_files
+
+ # ex
+ # %attr(0555, root, root) "/usr/bin/rpmrebuild"
+ # %dir %attr(0755, root, root) "/usr/lib/rpmrebuild"
+
+ while :; do
+ read line
+ [ -z "$line" ] && break
+ file=$( echo $line | cut -d\" -f2 )
+ is_ghost=$( echo $line | grep '%ghost')
+
+ # quote meta characters
+ # see also in rpmrebuild_files.sh
+ case "$line" in
+ # replace * by \*
+ x*\**) line=${line//\*/\\*} ;;
+ # replace \ by \\
+ x*\\*) line=${line//\\/\\\\} ;;
+ x*) ;;
+ esac
+
+ if [ -n "$is_ghost" ]
+ then
+ # ghost file may be missing
+ echo $line
+ elif [ -n "$package_flag" ]
+ then
+ # work on rpm file
+ # check in buildroot tar expand
+ if [ -e "${BUILDROOT}/${file}" ]
+ then
+ echo $line
+ else
+ echo "# MISSING: $line"
+ fi
+ else
+ # work on installed package
+ if [ -e "${file}" ]
+ then
+ echo $line
+ else
+ echo "# MISSING: $line"
+ fi
+ fi
+ done < $SPEC_IN > $SPEC_OUT || return
+
+ fi
+}
diff --git a/rpmrebuild.sh b/rpmrebuild.sh
index 89af1ac..b4d1f0a 100755
--- a/rpmrebuild.sh
+++ b/rpmrebuild.sh
@@ -611,10 +611,12 @@ function Main
if [ "X$spec_only" = "Xyes" ]; then
BUILDROOT="/"
SpecGeneration || Error "SpecGeneration" || return
+ CheckMissing || Error "CheckMissing" || return
Processing || Error "Processing" || return
else
SpecGeneration || Error "SpecGeneration" || return
CreateBuildRoot || Error "CreateBuildRoot" || return
+ CheckMissing || Error "CheckMissing" || return
Processing || Error "Processing" || return
CheckArch || Error "CheckArch" || return
RpmBuild || Error "RpmBuild" || return
diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh
index f62a545..bb9032b 100755
--- a/rpmrebuild_files.sh
+++ b/rpmrebuild_files.sh
@@ -100,6 +100,7 @@ while :; do
#wild=$(echo $file | grep "\*")
#[ -n "$wild" ] && file=$(echo "$file"|sed 's/\*/\\*/')
# quick and portable
+ # quote metacharacters, see also CheckMissing (processing_func.src)
case "x$file" in
# replace * by \*
x*\**) file=${file//\*/\\*} ;;
@@ -108,15 +109,8 @@ while :; do
x*) ;;
esac
- # COMMENT_MISSING only applies on installed rpm
- miss_str=""
- if [ "X$RPMREBUILD_COMMENT_MISSING" = "Xyes" ]; then
- if [ -e "$file" ]; then
- miss_str=""
- else
- miss_str='# MISSING: '
- fi
- fi
+ # 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)
# language handling
[ "X$file_lang" = "X(none)" ] && file_lang=""
@@ -256,6 +250,6 @@ while :; do
esac
fi
- echo "${miss_str}${lang_str}${dir_str}${fflags_str}${attr_str}${caps_str}${verify_str}\"${file}\""
+ echo "${lang_str}${dir_str}${fflags_str}${attr_str}${caps_str}${verify_str}\"${file}\""
done || Critical "$MY_BASENAME done"
exit 0
diff --git a/rpmrebuild_lib.src b/rpmrebuild_lib.src
index f6c8c12..24a66a0 100755
--- a/rpmrebuild_lib.src
+++ b/rpmrebuild_lib.src
@@ -134,3 +134,24 @@ function TestAwk
fi
}
###############################################################################
+# todo : quote meta characters is used in 2 subs
+# rpmrebuild_files.sh
+# processing_func.src : CheckMissing
+# function Quote
+# {
+# local x
+# x="$1"
+# case "$x" in
+# # replace * by \*
+# *\**) x=${x//\*/\\*} ;;
+#
+# # replace \ by \\
+# *\\*) x=${x//\\/\\\\} ;;
+#
+# *) ;;
+# esac
+# echo "$x"
+#
+# return
+# }
+###############################################################################
diff --git a/rpmrebuild_parser.src b/rpmrebuild_parser.src
index 8b06f61..8843e30 100755
--- a/rpmrebuild_parser.src
+++ b/rpmrebuild_parser.src
@@ -1467,16 +1467,6 @@ function CheckOptions
NOTESTINSTALL="1"
fi
- # RPMREBUILD_COMMENT_MISSING can not apply on rpm files
- if [ -n "$package_flag" ]
- then
- if [ "X$RPMREBUILD_COMMENT_MISSING" = 'Xyes' ]
- then
- RPMREBUILD_COMMENT_MISSING='no'
- Warning '(CheckOptions) COMMENT_MISSING can not be used on rpm file'
- fi
- fi
-
return 0
}
###############################################################################
--
2.46.0