From 55f36a3bd5501efa4e7cbf4dfc5604c184bec736 Mon Sep 17 00:00:00 2001 From: dongyuzhen Date: Mon, 9 Dec 2024 17:25:36 +0800 Subject: [PATCH] backport some patches from upstream (cherry picked from commit 68dbac9129a10702702016d5bdde7f0ec041e6df) --- ...-rpm-file-and-bugfix-file-with-space.patch | 178 ++++++++++ ...can-only-apply-on-installed-packages.patch | 110 ++++++ ...nt-missing-option-was-not-working-on.patch | 260 +++++++++++++++ backport-fix-backslash-in-filename.patch | 27 ++ backport-fix-trailing-space.patch | 29 ++ backport-support-filetrigger.patch | 313 ++++++++++++++++++ ...ution-if-filenames-contains-meta-car.patch | 128 +++++++ rpmrebuild.spec | 16 +- 8 files changed, 1060 insertions(+), 1 deletion(-) create mode 100644 backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch create mode 100644 backport-bugfix-the-comment-missing-option-can-only-apply-on-installed-packages.patch create mode 100644 backport-bugfix-the-comment-missing-option-was-not-working-on.patch create mode 100644 backport-fix-backslash-in-filename.patch create mode 100644 backport-fix-trailing-space.patch create mode 100644 backport-support-filetrigger.patch create mode 100644 backport-use-RPMREBUILD_NOQUOTE-on-some-distribution-if-filenames-contains-meta-car.patch diff --git a/backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch b/backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch new file mode 100644 index 0000000..55611e5 --- /dev/null +++ b/backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch @@ -0,0 +1,178 @@ +From 0336b36fa5ae1620b7d490cbad1c1420749d5bb7 Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +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 + diff --git a/backport-bugfix-the-comment-missing-option-can-only-apply-on-installed-packages.patch b/backport-bugfix-the-comment-missing-option-can-only-apply-on-installed-packages.patch new file mode 100644 index 0000000..85a2056 --- /dev/null +++ b/backport-bugfix-the-comment-missing-option-can-only-apply-on-installed-packages.patch @@ -0,0 +1,110 @@ +From 8559f43fe16789fd23e620fdf4c5c0ee9584cefa Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +Date: Sun, 13 Oct 2024 11:07:26 +0200 +Subject: [PATCH] bugfix : the comment-missing option can only apply on + installed packages + +--- + man/en/rpmrebuild.1.in | 1 + + man/fr_FR.UTF-8/rpmrebuild.1.in | 1 + + man/fr_FR/rpmrebuild.1.in | 1 + + rpmrebuild_files.sh | 9 ++------- + rpmrebuild_parser.src | 12 ++++++++++++ + 5 files changed, 17 insertions(+), 7 deletions(-) + +diff --git a/man/en/rpmrebuild.1.in b/man/en/rpmrebuild.1.in +index 3a590e6..8729d0e 100644 +--- a/man/en/rpmrebuild.1.in ++++ b/man/en/rpmrebuild.1.in +@@ -31,6 +31,7 @@ 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 aeae281..a36585f 100644 +--- a/man/fr_FR.UTF-8/rpmrebuild.1.in ++++ b/man/fr_FR.UTF-8/rpmrebuild.1.in +@@ -29,6 +29,7 @@ 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 f8157ca..0d30327 100644 +--- a/man/fr_FR/rpmrebuild.1.in ++++ b/man/fr_FR/rpmrebuild.1.in +@@ -29,6 +29,7 @@ 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Ús, pas aux fichiers + .TP + \fB\-D, \-\-define\fP=<\fIdefines\fP> + définition(s) à passer au programme \fBrpmbuild\fP. +diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh +index 4f42b44..f62a545 100755 +--- a/rpmrebuild_files.sh ++++ b/rpmrebuild_files.sh +@@ -107,6 +107,8 @@ while :; do + x*\\*) file=${file//\\/\\\\} ;; + x*) ;; + esac ++ ++ # COMMENT_MISSING only applies on installed rpm + miss_str="" + if [ "X$RPMREBUILD_COMMENT_MISSING" = "Xyes" ]; then + if [ -e "$file" ]; then +@@ -122,13 +124,6 @@ while :; do + lang_str="" + else + lang_str="%lang($file_lang) " +- if [ -e "$file" ]; then +- miss_str="" +- else +- if [ ! -h "$file" ]; then +- miss_str='# MISSING: ' +- fi +- fi + fi + + # %dir handling +diff --git a/rpmrebuild_parser.src b/rpmrebuild_parser.src +index b03fa14..8b06f61 100755 +--- a/rpmrebuild_parser.src ++++ b/rpmrebuild_parser.src +@@ -1456,6 +1456,7 @@ function CommandLineParsing + ############################################################################## + function CheckOptions + { ++ # NOTESTINSTALL + if [ -n "$package_install" ] + then + # force package test +@@ -1465,6 +1466,17 @@ function CheckOptions + # no test if work on files (not installed) + 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 + diff --git a/backport-bugfix-the-comment-missing-option-was-not-working-on.patch b/backport-bugfix-the-comment-missing-option-was-not-working-on.patch new file mode 100644 index 0000000..7877b8e --- /dev/null +++ b/backport-bugfix-the-comment-missing-option-was-not-working-on.patch @@ -0,0 +1,260 @@ +From 2904311f19ca1299a0efcfcea80cd389f2b0f0d4 Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +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Ús, pas aux fichiers + .TP + \fB\-D, \-\-define\fP=<\fIdefines\fP> + définition(s) à 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) " +@@ -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 + diff --git a/backport-fix-backslash-in-filename.patch b/backport-fix-backslash-in-filename.patch new file mode 100644 index 0000000..7f9a34e --- /dev/null +++ b/backport-fix-backslash-in-filename.patch @@ -0,0 +1,27 @@ +From 44f346694bbcce7769f014c91d4330b7103e7cb1 Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +Date: Mon, 9 Sep 2024 08:01:32 +0200 +Subject: [PATCH] fix backslash in filename + +--- + rpmrebuild_files.sh | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh +index c44eadc..4f42b44 100755 +--- a/rpmrebuild_files.sh ++++ b/rpmrebuild_files.sh +@@ -101,7 +101,10 @@ while :; do + #[ -n "$wild" ] && file=$(echo "$file"|sed 's/\*/\\*/') + # quick and portable + case "x$file" in ++ # replace * by \* + x*\**) file=${file//\*/\\*} ;; ++ # replace \ by \\ ++ x*\\*) file=${file//\\/\\\\} ;; + x*) ;; + esac + miss_str="" +-- +2.46.0 + diff --git a/backport-fix-trailing-space.patch b/backport-fix-trailing-space.patch new file mode 100644 index 0000000..460cb11 --- /dev/null +++ b/backport-fix-trailing-space.patch @@ -0,0 +1,29 @@ +From f628deaa9ef3e1b9933b937b7a66caebc0142c8f Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +Date: Sun, 8 Sep 2024 17:22:05 +0200 +Subject: [PATCH] fix trailing space (yixiangzhike) + +--- + rpmrebuild_files.sh | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh +index fb40709..c44eadc 100755 +--- a/rpmrebuild_files.sh ++++ b/rpmrebuild_files.sh +@@ -83,7 +83,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" + + # on fedora 33, centos 7, 8, the root directory "/" is owned by filesystem package + # but for rpmrebuild, BUILDROOT is juste a symlink, not a directory (cf RpmBuild in rpmrebuild.sh) +-- +2.46.0 + diff --git a/backport-support-filetrigger.patch b/backport-support-filetrigger.patch new file mode 100644 index 0000000..7e78de3 --- /dev/null +++ b/backport-support-filetrigger.patch @@ -0,0 +1,313 @@ +From 74a3d654ce30ec83453f12a5939a91fdb94e8bb0 Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +Date: Fri, 6 Sep 2024 16:42:29 +0200 +Subject: [PATCH] support filetrigger (merged from github repo) + +--- + optional_tags.cfg | 2 + + plugins/demo.plug | 2 + + processing_func.src | 18 +++++++++ + rpmrebuild_parser.src | 89 +++++++++++++++++++++++++++++++++++++++++-- + rpmrebuild_rpmqf.src | 10 +++++ + spec_func.src | 8 ++++ + 6 files changed, 125 insertions(+), 4 deletions(-) + +diff --git a/optional_tags.cfg b/optional_tags.cfg +index fe90209..fc69433 100644 +--- a/optional_tags.cfg ++++ b/optional_tags.cfg +@@ -33,3 +33,5 @@ SUPPLEMENTVERSION d_line + # only in rpm 5 + TRIGGERCONDS d_word + TRIGGERTYPE d_word ++FILETRIGGERCONDS d_line ++TRANSFILETRIGGERCONDS d_line +diff --git a/plugins/demo.plug b/plugins/demo.plug +index 8716d52..ac67b79 100644 +--- a/plugins/demo.plug ++++ b/plugins/demo.plug +@@ -30,6 +30,8 @@ change-spec-requires demo.sh + change-spec-description demo.sh + change-spec-files demo.sh + change-spec-triggers demo.sh ++change-spec-filetriggers demo.sh ++change-spec-transfiletriggers demo.sh + change-spec-pre demo.sh + change-spec-pretrans demo.sh + change-spec-post demo.sh +diff --git a/processing_func.src b/processing_func.src +index 392bc1e..7a513f7 100755 +--- a/processing_func.src ++++ b/processing_func.src +@@ -41,6 +41,8 @@ function processing_init + SPEC_RECOMMENDS=$SPEC_DIR/recommends + SPEC_SUPPLEMENTS=$SPEC_DIR/supplements + SPEC_TRIGGERS=$SPEC_DIR/triggers ++ SPEC_FILETRIGGERS=$SPEC_DIR/filetriggers ++ SPEC_TRANSFILETRIGGERS=$SPEC_DIR/transfiletriggers + SPEC_VERIFYSCRIPT=$SPEC_DIR/verifyscript + + spec_index=1 +@@ -64,6 +66,8 @@ function processing_init + si_recommends=1 + si_supplements=1 + si_triggers=1 ++ si_filetriggers=1 ++ si_transfiletriggers=1 + si_verifyscript=1 + si_rpmqf=1 + } +@@ -224,6 +228,20 @@ function processing_spec_change + SPEC_OUT=$SPEC_TRIGGERS.$si_triggers + ;; + ++ Xchange-spec-filetriggers | \ ++ Xedit-filetriggers) ++ SPEC_IN=$SPEC_FILETRIGGERS.$si_filetriggers ++ si_filetriggers=$(( si_filetriggers + 1 )) ++ SPEC_OUT=$SPEC_FILETRIGGERS.$si_filetriggers ++ ;; ++ ++ Xchange-spec-transfiletriggers | \ ++ Xedit-transfiletriggers) ++ SPEC_IN=$SPEC_TRANSFILETRIGGERS.$si_transfiletriggers ++ si_transfiletriggers=$(( si_transfiletriggers + 1 )) ++ SPEC_OUT=$SPEC_TRANSFILETRIGGERS.$si_transfiletriggers ++ ;; ++ + Xchange-spec-verifyscript | \ + Xedit-verifyscript) + SPEC_IN=$SPEC_VERIFYSCRIPT.$si_verifyscript +diff --git a/rpmrebuild_parser.src b/rpmrebuild_parser.src +index 2edab30..b03fa14 100755 +--- a/rpmrebuild_parser.src ++++ b/rpmrebuild_parser.src +@@ -81,6 +81,8 @@ options: + --change-spec-description= + --change-spec-files= + --change-spec-triggers= ++ --change-spec-filetriggers= ++ --change-spec-transfiletriggers= + --change-spec-pre= + --change-spec-pretrans= + --change-spec-post= +@@ -105,6 +107,8 @@ options: + --edit-description + --edit-files + --edit-triggers ++ --edit-filetriggers ++ --edit-transfiletriggers + --edit-pre + --edit-pretrans + --edit-post +@@ -354,11 +358,26 @@ function ProcessLongOptions + change-spec-f | \ + change-spec-fi | \ + change-spec-fil | \ +- change-spec-file | \ ++ change-spec-file) ++ AmbiguousOption ++ return 1 ++ ;; ++ + change-spec-files) + LONG_OPTION="change-spec-files" + ;; + ++ change-spec-filet | \ ++ change-spec-filetr | \ ++ change-spec-filetri | \ ++ change-spec-filetrig | \ ++ change-spec-filetrigg | \ ++ change-spec-filetrigge | \ ++ change-spec-filetrigger | \ ++ change-spec-filetriggers) ++ LONG_OPTION="change-spec-filetriggers" ++ ;; ++ + change-spec-o | \ + change-spec-ob | \ + change-spec-obs | \ +@@ -471,7 +490,28 @@ function ProcessLongOptions + ;; + + change-spec-t | \ +- change-spec-tr | \ ++ change-spec-tr) ++ AmbiguousOption ++ return 1 ++ ;; ++ ++ change-spec-tra | \ ++ change-spec-tran | \ ++ change-spec-trans | \ ++ change-spec-transf | \ ++ change-spec-transfi | \ ++ change-spec-transfile | \ ++ change-spec-transfilet | \ ++ change-spec-transfiletr | \ ++ change-spec-transfiletri | \ ++ change-spec-transfiletrig | \ ++ change-spec-transfiletrigg | \ ++ change-spec-transfiletrigge | \ ++ change-spec-transfiletrigger | \ ++ change-spec-transfiletriggers) ++ LONG_OPTION="change-spec-transfiletriggers" ++ ;; ++ + change-spec-tri | \ + change-spec-trig | \ + change-spec-trigg | \ +@@ -615,11 +655,27 @@ function ProcessLongOptions + edit-f | \ + edit-fi | \ + edit-fil | \ +- edit-file | \ ++ edit-file) ++ AmbiguousOption ++ return 1 ++ ;; ++ + edit-files) + LONG_OPTION='edit-files' + ;; + ++ edit-filet | \ ++ edit-filetr | \ ++ edit-filetri | \ ++ edit-filetri | \ ++ edit-filetrig | \ ++ edit-filetrigg | \ ++ edit-filetrigge | \ ++ edit-filetrigger | \ ++ edit-filetriggers) ++ LONG_OPTION='edit-filetriggers' ++ ;; ++ + edit-o | \ + edit-ob | \ + edit-obs | \ +@@ -745,7 +801,28 @@ function ProcessLongOptions + ;; + + edit-t | \ +- edit-tr | \ ++ edit-tr) ++ AmbiguousOption ++ return 1 ++ ;; ++ ++ edit-tra | \ ++ edit-tran | \ ++ edit-trans | \ ++ edit-transf | \ ++ edit-transfi | \ ++ edit-transfile | \ ++ edit-transfilet | \ ++ edit-transfiletr | \ ++ edit-transfiletri | \ ++ edit-transfiletrig | \ ++ edit-transfiletrigg | \ ++ edit-transfiletrigge | \ ++ edit-transfiletrigger | \ ++ edit-transfiletriggers) ++ LONG_OPTION='edit-transfiletriggers' ++ ;; ++ + edit-tri | \ + edit-trig | \ + edit-trigg | \ +@@ -1034,6 +1111,7 @@ function ProcessLongOptions + change-spec-description | \ + change-spec-enhances | \ + change-spec-files | \ ++ change-spec-filetriggers | \ + change-spec-obsoletes | \ + change-spec-pre | \ + change-spec-pretrans | \ +@@ -1047,6 +1125,7 @@ function ProcessLongOptions + change-spec-recommends | \ + change-spec-suggests | \ + change-spec-supplements | \ ++ change-spec-transfiletriggers | \ + change-spec-triggers | \ + change-spec-verifyscript | \ + change-spec-whole) +@@ -1088,6 +1167,7 @@ function ProcessLongOptions + edit-description | \ + edit-enhances | \ + edit-files | \ ++ edit-filetriggers | \ + edit-obsoletes | \ + edit-pre | \ + edit-pretrans | \ +@@ -1101,6 +1181,7 @@ function ProcessLongOptions + edit-suggests | \ + edit-recommends | \ + edit-supplements | \ ++ edit-transfiletriggers | \ + edit-triggers | \ + edit-verifyscript | \ + edit-whole) +diff --git a/rpmrebuild_rpmqf.src b/rpmrebuild_rpmqf.src +index fca0fe4..fe78377 100755 +--- a/rpmrebuild_rpmqf.src ++++ b/rpmrebuild_rpmqf.src +@@ -146,6 +146,16 @@ echo + echo '[%%trigger%{TRIGGERTYPE} -p %{TRIGGERSCRIPTPROG} -- %{TRIGGERCONDS}\n%|TRIGGERSCRIPTS?{%{TRIGGERSCRIPTS}\n}|]' + } + ++function qf_spec_filetriggers { ++echo ++echo '[%%filetrigger%{FILETRIGGERTYPE} -p %{FILETRIGGERSCRIPTPROG} -P %{FILETRIGGERPRIORITIES} -- %{FILETRIGGERCONDS}\n%|FILETRIGGERSCRIPTS?{%{FILETRIGGERSCRIPTS}\n}|]' ++} ++ ++function qf_spec_transfiletriggers { ++echo ++echo '[%%transfiletrigger%{TRANSFILETRIGGERTYPE} -p %{TRANSFILETRIGGERSCRIPTPROG} -P %{TRANSFILETRIGGERPRIORITIES} -- %{TRANSFILETRIGGERCONDS}\n%|TRANSFILETRIGGERSCRIPTS?{%{TRANSFILETRIGGERSCRIPTS}\n}|]' ++} ++ + function qf_spec_pre { + echo + echo '%|PREINPROG?{%%pre -p %{PREINPROG}\n%|PREIN?{[%{PREIN}\n]}|}:{%|PREIN?{\n%%pre\n[%{PREIN}\n]}|}|' +diff --git a/spec_func.src b/spec_func.src +index 6766be7..69fc2f6 100755 +--- a/spec_func.src ++++ b/spec_func.src +@@ -170,6 +170,8 @@ function SpecGeneration + spec_query qf_spec_description > "$SPEC_DESCRIPTION.$i" || Error "(SpecGeneration) qf_spec_description" || return + spec_files > "$SPEC_FILES.$i" || Error "(SpecGeneration) spec_files" || return + spec_query qf_spec_triggers > "$SPEC_TRIGGERS.$i" || Error "(SpecGeneration) qf_spec_triggers" || return ++ spec_query qf_spec_filetriggers > "$SPEC_FILETRIGGERS.$i" || Error "(SpecGeneration) qf_spec_filetriggers" || return ++ spec_query qf_spec_transfiletriggers > "$SPEC_TRANSFILETRIGGERS.$i" || Error "(SpecGeneration) qf_spec_transfiletriggers" || return + spec_query qf_spec_pre > "$SPEC_PRE.$i" || Error "(SpecGeneration) qf_spec_pre" || return + spec_query qf_spec_pretrans > "$SPEC_PRETRANS.$i" || Error "(SpecGeneration) qf_spec_pretrans" || return + spec_query qf_spec_post > "$SPEC_POST.$i" || Error "(SpecGeneration) qf_spec_post" || return +@@ -237,6 +239,8 @@ function spec_concatenate + + # %%triger -> %trigger (in begin of line) + local sed_trigger="/^%%trigger/s/^%%/%/1" ++ local sed_filetrigger="/^%%filetrigger/s/^%%/%/1" ++ local sed_transfiletrigger="/^%%transfiletrigger/s/^%%/%/1" + # %%pre -> %pre (in begin of line) It'll work for %%preun too. + local sed_pre="/^%%pre/s/^%%/%/1" + # %%post -> %post (in begin of line) It'll work for %%postun too. +@@ -248,11 +252,15 @@ function spec_concatenate + sed \ + -e "$sed_double_percent" \ + -e "$sed_trigger" \ ++ -e "$sed_filetrigger" \ ++ -e "$sed_transfiletrigger" \ + -e "$sed_pre" \ + -e "$sed_post" \ + -e "$sed_verifyscript" \ + -e "$sed_global" \ + "$SPEC_TRIGGERS.$si_triggers" \ ++ "$SPEC_FILETRIGGERS.$si_filetriggers" \ ++ "$SPEC_TRANSFILETRIGGERS.$si_transfiletriggers" \ + "$SPEC_PRE.$si_pre" \ + "$SPEC_PRETRANS.$si_pretrans" \ + "$SPEC_POST.$si_post" \ +-- +2.46.0 + diff --git a/backport-use-RPMREBUILD_NOQUOTE-on-some-distribution-if-filenames-contains-meta-car.patch b/backport-use-RPMREBUILD_NOQUOTE-on-some-distribution-if-filenames-contains-meta-car.patch new file mode 100644 index 0000000..39ea7a1 --- /dev/null +++ b/backport-use-RPMREBUILD_NOQUOTE-on-some-distribution-if-filenames-contains-meta-car.patch @@ -0,0 +1,128 @@ +From fb7fd3d6bbaf90c46240f156cc7e52111858a5cf Mon Sep 17 00:00:00 2001 +From: Eric Gerbier +Date: Sat, 2 Nov 2024 10:59:53 +0100 +Subject: [PATCH] you can use RPMREBUILD_NOQUOTE on some distribution if + filenames contains meta-car + +--- + processing_func.src | 21 ++++++++++++++------- + rpmrebuild_files.sh | 21 ++++++++++++++------- + rpmrebuild_lib.src | 40 +++++++++++++++++++++++----------------- + 3 files changed, 51 insertions(+), 31 deletions(-) + +diff --git a/processing_func.src b/processing_func.src +index 032c950..84a44b5 100755 +--- a/processing_func.src ++++ b/processing_func.src +@@ -414,13 +414,20 @@ function CheckMissing { + + # quote meta characters + # see also in rpmrebuild_files.sh +- case "$line" in +- # replace * by \* +- x*\**) line=${line//\*/\\*} ;; +- # replace \ by \\ +- x*\\*) line=${line//\\/\\\\} ;; +- x*) ;; +- esac ++ #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 + + if [ -n "$is_ghost" ] + then +diff --git a/rpmrebuild_files.sh b/rpmrebuild_files.sh +index bb9032b..32e3198 100755 +--- a/rpmrebuild_files.sh ++++ b/rpmrebuild_files.sh +@@ -101,13 +101,20 @@ while :; do + #[ -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//\*/\\*} ;; +- # replace \ by \\ +- x*\\*) file=${file//\\/\\\\} ;; +- x*) ;; +- esac ++# 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 + + # 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) +diff --git a/rpmrebuild_lib.src b/rpmrebuild_lib.src +index 24a66a0..70fe923 100755 +--- a/rpmrebuild_lib.src ++++ b/rpmrebuild_lib.src +@@ -137,21 +137,27 @@ function TestAwk + # 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 +-# } ++function Quote ++{ ++ local x ++ x="$1" ++ if [ -n "$RPMREBUILD_NOQUOTE" ] ++ then ++ # do not quote ++ echo ++ else ++ case "$x" in ++ # replace * by \* ++ x*\**) x=${x//\*/\\*} ;; ++ ++ # replace \ by \\ ++ x*\\*) x=${x//\\/\\\\} ;; ++ ++ x*) ;; ++ esac ++ fi ++ echo -E "$x" ++ ++ return ++} + ############################################################################### +-- +2.46.0 + diff --git a/rpmrebuild.spec b/rpmrebuild.spec index 99a459d..6c3f1a9 100644 --- a/rpmrebuild.spec +++ b/rpmrebuild.spec @@ -1,11 +1,19 @@ Name: rpmrebuild Version: 2.16 -Release: 14 +Release: 15 Summary: A tool to build a rpm file from the rpm database License: GPLv2+ URL: http://rpmrebuild.sourceforge.net Source0: https://downloads.sourceforge.net/rpmrebuild/%{name}-%{version}.tar.gz +Patch6000: backport-support-filetrigger.patch +Patch6001: backport-fix-trailing-space.patch +Patch6002: backport-fix-backslash-in-filename.patch +Patch6003: backport-bugfix-the-comment-missing-option-can-only-apply-on-installed-packages.patch +Patch6004: backport-bugfix-the-comment-missing-option-was-not-working-on.patch +Patch6005: backport-use-RPMREBUILD_NOQUOTE-on-some-distribution-if-filenames-contains-meta-car.patch +Patch6006: backport-bugfix-comment-missing-with-spec-only-on-rpm-file-and-bugfix-file-with-space.patch + Patch9000: bugfix-reset-defattr-when-users-want-to-keep-files-permissi.patch Patch9001: fix-the-CreateBuildRoot-error-when-using-rpmrebuild-command.patch Patch9002: fix-k-may-not-keep-uid-or-gid.patch @@ -66,6 +74,12 @@ rm -rf $RPM_BUILD_ROOT%{_mandir}/fr_FR.UTF-8/man1/ %{_mandir}/fr/man1/*.gz %changelog +* Mon Dec 9 2024 dongyuzhen - 2.16-15 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:backport some patches from upstream + * Thu Aug 1 2024 yixiangzhike - 2.16-14 - Type:bugfix - CVE:NA