From aa18231110eed8d85f82886eeec6ca9199e1fcab Mon Sep 17 00:00:00 2001 From: xujing Date: Mon, 20 Nov 2023 11:34:41 +0800 Subject: [PATCH] add brp script to delete rpath By the way, fix the ELF file cannot be found due to escape of '\'. (cherry picked from commit f8143a113a4ced9610dcf06675152db2cc78613a) --- add-brp-scripts-to-delete-rpath.patch | 146 ++++++++++++++++++ ...ile-cannot-be-found-due-to-escape-of.patch | 25 +++ openEuler-rpm-config.spec | 13 +- 3 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 add-brp-scripts-to-delete-rpath.patch create mode 100644 fix-the-ELF-file-cannot-be-found-due-to-escape-of.patch diff --git a/add-brp-scripts-to-delete-rpath.patch b/add-brp-scripts-to-delete-rpath.patch new file mode 100644 index 0000000..56a5d8e --- /dev/null +++ b/add-brp-scripts-to-delete-rpath.patch @@ -0,0 +1,146 @@ +From 3247ab3820c98cee1b47f1c0bf5f0714c3324fde Mon Sep 17 00:00:00 2001 +From: gaoyi +Date: Fri, 6 Mar 2020 06:04:41 -0500 +Subject: [PATCH] add brp scripts to delete rpath + +Signed-off-by: gaoyi +Signed-off-by: xujing +--- + brp-chrpath | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + macros | 2 + + 2 files changed, 106 insertions(+) + create mode 100755 brp-chrpath + +diff --git a/brp-chrpath b/brp-chrpath +new file mode 100755 +index 0000000..dc48351 +--- /dev/null ++++ b/brp-chrpath +@@ -0,0 +1,104 @@ ++#!/usr/bin/sh ++# remove rpath specified ++ ++rpathSuffix=( ++ "/home/abuild/rpmbuild/BUILD", ++ "/home/lkp/rpmbuild/BUILD" ++) ++ ++rpath=( ++ "/usr/lib64", ++ "/lib64", ++ "/usr/lib", ++ "/lib", ++ "/usr/lib/../lib64" ++) ++ ++buildroot=$1 ++ ++function rpathChange() ++{ ++ localSrcPath=$1 ++ localDstPath="" ++ ++ rpathArr=(`echo $localSrcPath | tr ':' ' '`) ++ ++ for path in ${rpathArr[*]} ++ do ++ localflag=0 ++ for suffix in ${rpathSuffix[*]} ++ do ++ if echo "$path" | grep $suffix &> /dev/null; then ++ localflag=1 ++ break ++ fi ++ done ++ ++ # Is the suffix path, delete ++ if [ $localflag -eq 1 ]; then ++ continue; ++ fi ++ ++ #Is the standard path, delete ++ if echo "${rpath[@]}" | grep -w $path &> /dev/null; then ++ continue ++ fi ++ ++ if [ x"$localDstPath" == x"" ]; then ++ localDstPath=$path ++ else ++ localDstPath=$localDstPath:$path ++ fi ++ done ++ ++ echo $localDstPath ++} ++ ++function removeRpathOrRunpath() ++{ ++ localfile=$1 ++ ++ rpathInfo=$(chrpath -l $localfile | grep "RPATH=") ++ runpathInfo=$(chrpath -l $localfile | grep "RUNPATH=") ++ ++ currPath="" ++ realPath="" ++ needCh=0 ++ if [ x"$rpathInfo" != x"" ]; then ++ needCh=1 ++ currPath=$(echo $rpathInfo | awk -F "RPATH=" '{print $2}') ++ realPath=$(rpathChange $currPath) ++ fi ++ ++ if [ x"$runpathInfo" != x"" ]; then ++ needCh=1 ++ currPath=$(echo $runpathInfo | awk -F "RUNPATH=" '{print $2}') ++ realPath=$(rpathChange $currPath) ++ fi ++ ++ if [ $needCh -eq 0 ]; then ++ return 0 ++ fi ++ ++ if [ x"$realPath" == x"" ]; then ++ chrpath -d $localfile ++ else ++ chrpath -r $realPath $localfile ++ fi ++ ++ return 0 ++} ++ ++for file in $(find $buildroot/ -executable -type f -exec file {} ';' | grep "\" | awk -F ':' '{print $1}') ++do ++ test -u $file ++ if [ $? -eq 0 ]; then ++ continue ++ fi ++ ++ if [ -w "$file" ]; then ++ removeRpathOrRunpath $file ++ fi ++done ++ ++exit 0 +diff --git a/macros b/macros +index 36621df..a316be9 100644 +--- a/macros ++++ b/macros +@@ -89,6 +89,7 @@ + + # Build root policy macros. Standard naming: + # convert all '-' in basename to '_', add two leading underscores. ++%__brp_chrpath /usr/lib/rpm/brp-chrpath %{buildroot} + %__brp_ldconfig /usr/lib/rpm/brp-ldconfig + %__brp_compress /usr/lib/rpm/brp-compress + %__brp_strip /usr/lib/rpm/brp-strip %{__strip} +@@ -111,6 +112,7 @@ + + %__spec_install_post\ + %{?__debug_package:%{__debug_install_post}}\ ++ %{?__vendor_delete_rpath:%{?__brp_chrpath}} \ + %{__arch_install_post}\ + %{__os_install_post}\ + %{nil} +-- +2.33.0 + diff --git a/fix-the-ELF-file-cannot-be-found-due-to-escape-of.patch b/fix-the-ELF-file-cannot-be-found-due-to-escape-of.patch new file mode 100644 index 0000000..ae85c22 --- /dev/null +++ b/fix-the-ELF-file-cannot-be-found-due-to-escape-of.patch @@ -0,0 +1,25 @@ +From 4e1adcc36b0c2e379d6080ceb874f2413644c535 Mon Sep 17 00:00:00 2001 +From: xujing +Date: Wed, 15 Nov 2023 17:16:22 +0800 +Subject: [PATCH] fix the ELF file cannot be found due to escape of '\' + +--- + macros | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/macros b/macros +index 7cde63f..36621df 100644 +--- a/macros ++++ b/macros +@@ -275,7 +275,7 @@ find $RPM_BUILD_ROOT -type f -name "*.a" -delete + + %delete_la find $RPM_BUILD_ROOT -type f -name "*.la" -delete + +-%chrpath_delete find $RPM_BUILD_ROOT/ -type f -exec file {} ';' | grep "\" | awk -F ':' '{print $1}' | xargs -i chrpath --delete {} ++%chrpath_delete find $RPM_BUILD_ROOT/ -type f -exec file {} ';' | grep "\\" | awk -F ':' '{print $1}' | xargs -i chrpath --delete {} + + %package_help \ + %package help \ +-- +2.33.0 + diff --git a/openEuler-rpm-config.spec b/openEuler-rpm-config.spec index e05b95b..3280ae3 100644 --- a/openEuler-rpm-config.spec +++ b/openEuler-rpm-config.spec @@ -3,7 +3,7 @@ Name: %{vendor}-rpm-config Version: 30 -Release: 19 +Release: 20 License: GPL+ Summary: specific rpm configuration files URL: https://gitee.com/openeuler/openEuler-rpm-config @@ -15,7 +15,9 @@ Patch2: Fix-a-typo-in-brp-digest-list.patch Patch3: backport-kmp-feature.patch Patch4: check-if-the-file-is-a-symbolic-link-in-brp-digest-list.patch -Patch9002: openEuler-remove-fexceptions.patch +Patch9000: openEuler-remove-fexceptions.patch +Patch9001: fix-the-ELF-file-cannot-be-found-due-to-escape-of.patch +Patch9002: add-brp-scripts-to-delete-rpath.patch Provides: python-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} Provides: python2-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} @@ -90,6 +92,9 @@ install -p -m 644 -t %{buildroot}%{_rpmconfigdir}/macros.d/ macros.perl macros.p mkdir -p %{buildroot}%{_fileattrsdir} +# Adaptive according to vendor +sed -i "s/__vendor/%{vendor}/g" `grep "__vendor" -rl %{buildroot}%{_rpmconfigdir}` + %files %dir %{rpmvdir} %{rpmvdir}/macros @@ -107,6 +112,10 @@ mkdir -p %{buildroot}%{_fileattrsdir} %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Tue Nov 21 2023 xujing - 30-20 +- add brp script to delete rpath + fix the ELF file cannot be found due to escape of '\' + * Fri Nov 03 2023 fuanan - 30-19 - check if the file is a symbolic link in brp-digest-list -- Gitee