rpmrebuild/backport-bugfix-the-comment-missing-option-was-not-working-on.patch
2024-11-21 17:01:36 +08:00

262 lines
7.5 KiB
Diff
Raw Permalink 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 197325d..535f46d 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 e72cb71..a991a27 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 663f8f1..1a02194 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 4785f9c..a7016cc 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 ] || [ -z "$1" ]
then
@@ -302,6 +304,7 @@ function processing_spec_change
function processing_fini
{
+ Debug "(processing_fini)"
local cmd
if [ "$spec_concatenated" = "yes" ]; then
case "$RPMREBUILD_specfile" in
@@ -343,6 +346,7 @@ function processing_fini
function CreateProcessing
{
+ Debug "(CreateProcessing)"
if [ $# -ne 1 ] || [ -z "$1" ]
then
Error "(CreateProcessing) <operation>"
@@ -390,3 +394,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 [ "$RPMREBUILD_COMMENT_MISSING" = "yes" ]; 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 \*
+ *\**) line=${line//\*/\\*} ;;
+ # replace \ by \\
+ *\\*) line=${line//\\/\\\\} ;;
+ *) ;;
+ esac
+
+ if [ -n "$is_ghost" ]
+ then
+ # ghost file may be missing
+ echo $line
+ elif [ -n "$RPMREBUILD_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 545b348..cdba61d 100755
--- a/rpmrebuild.sh
+++ b/rpmrebuild.sh
@@ -639,11 +639,13 @@ function Main
if [ "$RPMREBUILD_spec_only" = "yes" ]; then
BUILDROOT="/"
SpecGeneration || Error "SpecGeneration" || return
+ CheckMissing || Error "CheckMissing" || return
Processing || Error "Processing" || return
Echo "specfile: $RPMREBUILD_specfile"
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 af9c3f3..71274d8 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 "$file" in
# replace * by \*
*\**) file=${file//\*/\\*} ;;
@@ -108,15 +109,8 @@ while :; do
*) ;;
esac
- # COMMENT_MISSING only applies on installed rpm
- miss_str=""
- if [ "$RPMREBUILD_COMMENT_MISSING" = "yes" ]; 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
[ "$file_lang" = "(none)" ] && file_lang=""
@@ -259,6 +253,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 5cbd026..811acac 100755
--- a/rpmrebuild_lib.src
+++ b/rpmrebuild_lib.src
@@ -136,3 +136,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 3357840..c6b162c 100755
--- a/rpmrebuild_parser.src
+++ b/rpmrebuild_parser.src
@@ -1484,16 +1484,6 @@ function CheckOptions
RPMREBUILD_NOTESTINSTALL="1"
fi
- # RPMREBUILD_COMMENT_MISSING can not apply on rpm files
- if [ -n "$RPMREBUILD_package_flag" ]
- then
- if [ "$RPMREBUILD_COMMENT_MISSING" = 'yes' ]
- then
- RPMREBUILD_COMMENT_MISSING='no'
- Warning '(CheckOptions) COMMENT_MISSING can not be used on rpm file'
- fi
- fi
-
return 0
}
###############################################################################
--
2.46.0