diff --git a/generic-rpm-config.spec b/generic-rpm-config.spec index 069dc8da9b08ad329e982e9139f155ad98866580..8f83da3a798f201e3405345ee6ed9a2f9280e781 100644 --- a/generic-rpm-config.spec +++ b/generic-rpm-config.spec @@ -2,7 +2,7 @@ Name: %{vendor}-rpm-config Version: 30 -Release: 12 +Release: 13 License: GPL+ Summary: specific rpm configuration files URL: https://gitee.com/src-openeuler/openEuler-rpm-config @@ -12,7 +12,7 @@ Source2: rpmrc Source3: macros Source4: config.guess Source5: config.sub -Source6: kmodtool.py +Source6: kmodtool Source10: macros.perl Source11: macros.python @@ -38,7 +38,7 @@ Provides: openblas-srpm-macros Provides: perl-srpm-macros Provides: rust-srpm-macros Provides: go-srpm-macros -Provides: kernel-rpm-macros + Obsoletes: python-rpm-macros Obsoletes: python2-rpm-macros Obsoletes: python3-rpm-macros @@ -55,6 +55,7 @@ Obsoletes: go-srpm-macros Requires: efi-srpm-macros Requires: qt5-srpm-macros +Requires: kernel-rpm-macros Requires: rpm >= 4.11.0 Requires: zip @@ -79,6 +80,7 @@ specific rpm configuration files for %{vendor}. %package -n kernel-rpm-macros Summary: Macros and scripts for building kernel module packages +Provides: kernel-rpm-macros %description -n kernel-rpm-macros Macros and scripts for building kernel module packages. @@ -93,7 +95,7 @@ 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}%{rpmvdir} kmodtool.py +install -p -m 755 -t %{buildroot}%{rpmvdir} kmodtool mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d install -p -m 644 -t %{buildroot}%{_rpmconfigdir}/macros.d/ %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} @@ -110,12 +112,19 @@ mkdir -p %{buildroot}%{_fileattrsdir} %{_fileattrsdir}/ %{_rpmconfigdir}/macros.d/ %{_rpmconfigdir}/macros.d/* +%exclude %{_rpmconfigdir}/macros.d/macros.kmp %files -n kernel-rpm-macros -%{rpmvdir}/kmodtool.py +%{rpmvdir}/kmodtool %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Wed Sep 16 2020 zhangliuyan - 30-13 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:backport kmp feature + * Fri Aug 21 2020 Wang Shuo - 30-12 - fix error message for kmodtool diff --git a/kmodtool b/kmodtool new file mode 100644 index 0000000000000000000000000000000000000000..deea24552ba53724c2f0de3789c3c22747533e2f --- /dev/null +++ b/kmodtool @@ -0,0 +1,292 @@ +#!/usr/bin/bash + +# kmodtool - Helper script for building kernel module RPMs +# Copyright (c) 2003-2006 Ville Skyttä , +# Thorsten Leemhuis +# Jon Masters +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +shopt -s extglob + +myprog="kmodtool" +myver="0.10.10_kmp2" +knownvariants=@(BOOT|PAE|@(big|huge)mem|debug|enterprise|kdump|?(large)smp|uml|xen[0U]?(-PAE)|xen) +kmod_name= +kver= +verrel= +variant= +kmp= + +get_verrel () +{ + verrel=${1:-$(uname -r)} + verrel=${verrel%%$knownvariants} +} + +print_verrel () +{ + get_verrel $@ + echo "${verrel}" +} + +get_variant () +{ + get_verrel $@ + variant=${1:-$(uname -r)} + variant=${variant##$verrel} + variant=${variant:-'""'} +} + +print_variant () +{ + get_variant $@ + echo "${variant}" +} + +get_filelist() { + local IFS=$'\n' + filelist=($(cat)) + + if [ ${#filelist[@]} -gt 0 ]; + then + for ((n = 0; n < ${#filelist[@]}; n++)); + do + line="${filelist[n]}" + line=$(echo "$line" \ + | sed -e "s/%verrel/$verrel/g" \ + | sed -e "s/%variant/$variant/g" \ + | sed -e "s/%dashvariant/$dashvariant/g" \ + | sed -e "s/%dotvariant/$dotvariant/g" \ + | sed -e "s/\.%1/$dotvariant/g" \ + | sed -e "s/\-%1/$dotvariant/g" \ + | sed -e "s/%2/$verrel/g") + echo "$line" + done + else + echo "%defattr(644,root,root,755)" + echo "/lib/modules/${verrel}${dotvariant}" + fi +} + +get_rpmtemplate () +{ + local variant="${1}" + local dashvariant="${variant:+-${variant}}" + case "$verrel" in + *.el*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;; + *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;; + *) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;; + esac + + echo "%package -n kmod-${kmod_name}${dashvariant}" + + if [ -z "$kmp_provides_summary" ]; then + echo "Summary: ${kmod_name} kernel module(s)" + fi + + if [ -z "$kmp_provides_group" ]; then + echo "Group: System Environment/Kernel" + fi + + if [ ! -z "$kmp_version" ]; then + echo "Version: %{kmp_version}" + fi + + if [ ! -z "$kmp_release" ]; then + echo "Release: %{kmp_release}" + fi + + if [ ! -z "$kmp" ]; then + echo "%global _use_internal_dependency_generator 0" + fi + + cat <= %{?epoch:%{epoch}:}%{version} +# + + cat < /dev/null || : +fi +EOF + + if [ ! -z "$kmp" ]; then + cat < /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules +EOF + + fi + + cat < /dev/null || : +EOF + + if [ ! -z "$kmp" ]; then + cat <&2 + exit 2 + elif [ -z "${kver}" ] ; then + echo "Please provide the kver as second parameter." >&2 + exit 2 + elif [ -z "${verrel}" ] ; then + echo "Couldn't find out the verrel." >&2 + exit 2 + fi + + for variant in "$@" ; do + if [ "default" == "$variant" ]; + then + get_rpmtemplate "" + else + get_rpmtemplate "${variant}" + fi + done +} + +usage () +{ + cat <