Modify support for change vendor with better method

This commit is contained in:
Yangyang Shen 2021-03-25 17:02:36 +08:00
parent 577a1dd0b0
commit 3467cf67da
3 changed files with 45 additions and 97 deletions

View File

@ -1,15 +1,38 @@
From 9ddbf9dcb6de021ad796876282796dc409cdb268 Mon Sep 17 00:00:00 2001
From e9f486a8d9af5b01dcadf8432a449e434cd6886b Mon Sep 17 00:00:00 2001
From: Yangyang Shen <shenyangyang4@huawei.com>
Date: Thu, 7 Jan 2021 21:19:58 +0800
Subject: [PATCH] replace openEuler with %{_vendor} macro
Date: Sat, 27 Mar 2021 14:18:56 +0800
Subject: [PATCH] change the openEuler to generic for common use
---
macros | 14 +++++++-------
macros.kmp | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
openEuler-hardened-cc1 => generic-hardened-cc1 | 0
openEuler-hardened-ld => generic-hardened-ld | 0
openEuler-pie-cc1 => generic-pie-cc1 | 0
openEuler-pie-ld => generic-pie-ld | 0
macros | 14 +++++++-------
5 files changed, 7 insertions(+), 7 deletions(-)
rename openEuler-hardened-cc1 => generic-hardened-cc1 (100%)
rename openEuler-hardened-ld => generic-hardened-ld (100%)
rename openEuler-pie-cc1 => generic-pie-cc1 (100%)
rename openEuler-pie-ld => generic-pie-ld (100%)
diff --git a/openEuler-hardened-cc1 b/generic-hardened-cc1
similarity index 100%
rename from openEuler-hardened-cc1
rename to generic-hardened-cc1
diff --git a/openEuler-hardened-ld b/generic-hardened-ld
similarity index 100%
rename from openEuler-hardened-ld
rename to generic-hardened-ld
diff --git a/openEuler-pie-cc1 b/generic-pie-cc1
similarity index 100%
rename from openEuler-pie-cc1
rename to generic-pie-cc1
diff --git a/openEuler-pie-ld b/generic-pie-ld
similarity index 100%
rename from openEuler-pie-ld
rename to generic-pie-ld
diff --git a/macros b/macros
index b06faea..678136a 100644
index b06faea..ce7cf5c 100644
--- a/macros
+++ b/macros
@@ -52,7 +52,7 @@
@ -26,7 +49,7 @@ index b06faea..678136a 100644
# Build root policy macros. Standard naming:
# convert all '-' in basename to '_', add two leading underscores.
-%__brp_ldconfig /usr/lib/rpm/openEuler/brp-ldconfig
+%__brp_ldconfig /usr/lib/rpm/%{_vendor}/brp-ldconfig
+%__brp_ldconfig /usr/lib/rpm/brp-ldconfig
%__brp_compress /usr/lib/rpm/brp-compress
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
@ -36,8 +59,8 @@ index b06faea..678136a 100644
# #hardened options
-%_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-cc1
-%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-ld
+%_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/%{_vendor}-hardened-cc1
+%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/%{_vendor}-hardened-ld
+%_hardening_cflags -specs=/usr/lib/rpm/generic-hardened-cc1
+%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld
# Use "%undefine _hardened_build" to disable.
%_hardened_build 1
%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
@ -47,31 +70,18 @@ index b06faea..678136a 100644
%_pie_build 1
-%_pie_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-cc1
-%_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-ld
+%_pie_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/%{_vendor}-pie-cc1
+%_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/%{_vendor}-pie-ld
+%_pie_pre_cflags -specs=/usr/lib/rpm/generic-pie-cc1
+%_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/generic-pie-ld
%_pie_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}}
%_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}}
#Use "%undefine _fs_build" to disable.
%_fs_build 1
-%_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-fs-cc1
+%_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/%{_vendor}-fs-cc1
+%_fs_pre_cflags -specs=/usr/lib/rpm/generic-fs-cc1
%_fs_cflags %{?_fs_build:%{_fs_pre_cflags}}
diff --git a/macros.kmp b/macros.kmp
index be66e64..2bf977c 100644
--- a/macros.kmp
+++ b/macros.kmp
@@ -12,7 +12,7 @@ kernel_module_package_release 1
kernel-devel
%kernel_module_package(n:v:r:f:) %{expand:%( \
- %define kmodtool /usr/lib/rpm/openEuler/kmodtool.py\
+ %define kmodtool /usr/lib/rpm/%{_vendor}/kmodtool.py\
%define latest_kernel $(rpm -q --qf '%{VERSION}-%{RELEASE}\\\\n' `rpm -q kernel-devel` | head -n 1) \
%{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \
%global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \
--
2.23.0

View File

@ -1,25 +0,0 @@
From 13fba7b02178c0196061965155c01061fce004fc Mon Sep 17 00:00:00 2001
From: orange-snn <songnannan2@huawei.com>
Date: Thu, 28 Jan 2021 16:35:20 +0800
Subject: [PATCH] fix brp ldconfig
---
macros | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/macros b/macros
index 678136a..7ef0539 100644
--- a/macros
+++ b/macros
@@ -89,7 +89,7 @@
# Build root policy macros. Standard naming:
# convert all '-' in basename to '_', add two leading underscores.
-%__brp_ldconfig /usr/lib/rpm/%{_vendor}/brp-ldconfig
+%__brp_ldconfig /usr/lib/rpm/euleros/brp-ldconfig
%__brp_compress /usr/lib/rpm/brp-compress
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
--
2.27.0

View File

@ -1,15 +1,9 @@
%global vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler}
%global rpmvdir /usr/lib/rpm/%{vendor}
# the _change_vendor macro should be defined in the project config of obs
# or just in this spec if you want to change openEuler to other vendor.
# If the _change_vendor is 1, it means that it is the first building round for all.
# rpm packages, so we need both openEuler and the vendor as an transistion.
# And the others value of _change_vendor indicates that we don't need openEuler anymore.
%global change_vendor %{?_change_vendor:%{_change_vendor}}%{!?_change_vendor:0}
Name: %{vendor}-rpm-config
Version: 30
Release: 18
Release: 19
License: GPL+
Summary: specific rpm configuration files
URL: https://gitee.com/openeuler/openEuler-rpm-config
@ -19,12 +13,7 @@ Source0: https://gitee.com/openeuler/openEuler-rpm-config/repository/arch
Patch0: fix-error-message-for-kmodtool.patch
Patch1: 0001-1-Add-riscv64-to-golang_arches.patch
Patch2: Fix-a-typo-in-brp-digest-list.patch
Patch9000: openEuler-replace-openEuler-with-_vendor-macro.patch
%if %{vendor} != openEuler && %{change_vendor} == 1
Patch9001: openEuler-fix-brp-ldconfig.patch
%endif
Patch9002: openEuler-remove-fexceptions.patch
Patch3: change-the-openEuler-to-generic-for-common-use.patch
Provides: python-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: python2-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release}
@ -95,8 +84,8 @@ Macros and scripts for building kernel module packages.
mkdir -p %{buildroot}%{rpmvdir}
install -p -m 644 -t %{buildroot}%{rpmvdir} macros rpmrc
install -p -m 755 -t %{buildroot}%{rpmvdir} config.*
install -p -m 755 -t %{buildroot}%{rpmvdir} brp-*
install -p -m 644 -t %{buildroot}%{rpmvdir} openEuler-*
install -p -m 755 -t %{buildroot}%{_rpmconfigdir} brp-*
install -p -m 644 -t %{buildroot}%{_rpmconfigdir} generic-*
install -p -m 755 -t %{buildroot}%{rpmvdir} kmodtool.py
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d
@ -104,39 +93,13 @@ install -p -m 644 -t %{buildroot}%{_rpmconfigdir}/macros.d/ macros.perl macros.p
mkdir -p %{buildroot}%{_fileattrsdir}
%if %{vendor} != openEuler
pushd %{buildroot}%{rpmvdir}
mv openEuler-hardened-cc1 %{vendor}-hardened-cc1
mv openEuler-hardened-ld %{vendor}-hardened-ld
mv openEuler-pie-cc1 %{vendor}-pie-cc1
mv openEuler-pie-ld %{vendor}-pie-ld
popd
%if %{change_vendor} == 1
pushd %{buildroot}%{rpmvdir}/../
cp -a %{vendor} openEuler
popd
pushd %{buildroot}/usr/lib/rpm/openEuler
mv %{vendor}-hardened-cc1 openEuler-hardened-cc1
mv %{vendor}-hardened-ld openEuler-hardened-ld
mv %{vendor}-pie-cc1 openEuler-pie-cc1
mv %{vendor}-pie-ld openEuler-pie-ld
popd
%endif
%endif
%files
%dir %{rpmvdir}
%{rpmvdir}/macros
%{rpmvdir}/rpmrc
%{rpmvdir}/brp-*
%{_rpmconfigdir}/brp-*
%{rpmvdir}/config.*
%if %{vendor} != openEuler && %{change_vendor} == 1
%exclude %{_prefix}/lib/rpm/openEuler/kmodtool.py
%{_prefix}/lib/rpm/openEuler/*
%endif
%{rpmvdir}/%{vendor}-*
%{_rpmconfigdir}/generic-*
%{_fileattrsdir}/
%{_rpmconfigdir}/macros.d/
%exclude %{_rpmconfigdir}/macros.d/macros.kmp
@ -144,12 +107,12 @@ popd
%files -n kernel-rpm-macros
%exclude %{_prefix}/lib/rpm/*/__pycache__/*
%{rpmvdir}/kmodtool.py
%if %{vendor} != openEuler && %{change_vendor} == 1
%{_prefix}/lib/rpm/openEuler/kmodtool.py
%endif
%{_rpmconfigdir}/macros.d/macros.kmp
%changelog
* Thu Mar 25 2021 shenyangyang <shenyangyang4@huawei.com> - 30-19
- Modify support for change vendor with better method
* Thu Mar 18 2021 shenyangyang <shenyangyang4@huawei.com> - 30-18
- Change the name of spec to openEuler-rpm-spec and fix few bugs