Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Stange <nstange@suse.de>2017-06-13 15:54:27 +0200
committermbenes <mbenes@pobox.suse.cz>2017-06-14 10:30:59 +0200
commit9eafc8ad4e5f2ca5905d0221e47d66bee3e851ef (patch)
treea029152d2180fd29e27ed69a62d42be4588a2342
parentba41416b4fcadf4df883a0c1657540f5043cb391 (diff)
scripts/register-patches.sh: register subpatch sources in rpm spec
In order to reduce the manual merging work upon addition of new (sub)patches, commit 4e8dc885be22 ("scripts: create kgr_patch_main.c dynamically") introduced the register-patches.sh helper. It discovers those and tweaks the main entry point, kgr_patch_main.c, as needed. However, a remaining manual merging task is to list a (sub)patch's source archive in rpm/kgraft-patch.spec and to %setup it. Make scripts/register-patches.sh do this. Namely, - introduce the @@KGR_PATCHES_SOURCES@@ and @@KGR_PATCHES_SETUP_SOURCES@@ placeholders in rpm/kgraft-patch.spec - and make scripts/register-patches.sh expand those within a spec file to be given as an additional command line argument. Finally, adjust scripts/tar-up.sh accordingly. Signed-off-by: Nicolai Stange <nstange@suse.de>
-rw-r--r--rpm/kgraft-patch.spec2
-rwxr-xr-xscripts/register-patches.sh39
-rwxr-xr-xscripts/tar-up.sh2
3 files changed, 41 insertions, 2 deletions
diff --git a/rpm/kgraft-patch.spec b/rpm/kgraft-patch.spec
index 6ee7443..ba8b0f6 100644
--- a/rpm/kgraft-patch.spec
+++ b/rpm/kgraft-patch.spec
@@ -30,6 +30,7 @@ Source2: kgr_patch_main.c
Source3: config.sh
Source4: source-timestamp
Source5: compat.h
+@@KGR_PATCHES_SOURCES@@
BuildRequires: kernel-syms kgraft-devel
ExclusiveArch: s390x x86_64
%kgraft_module_package
@@ -41,6 +42,7 @@ This is a live patch for SUSE Linux Enterprise Server kernel.
%prep
%setup -c
+@@KGR_PATCHES_SETUP_SOURCES@@
cp %_sourcedir/kgr_patch_main.c .
cp %_sourcedir/Makefile .
cp %_sourcedir/compat.h .
diff --git a/scripts/register-patches.sh b/scripts/register-patches.sh
index 9febd3e..126cbc4 100755
--- a/scripts/register-patches.sh
+++ b/scripts/register-patches.sh
@@ -32,12 +32,13 @@
# each corresponding to a function the subpatch wants to replace.
#
# Usage:
-# register-patches.sh kgr_patch_main.c
+# register-patches.sh kgr_patch_main.c kgraft-patch.spec
#
# This will properly substitute a number of placeholders in-place.
#
kgr_patch_main_file="$1"
+kgr_patch_spec_file="$2"
# Generate list of patches
@@ -120,3 +121,39 @@ s%\s*@@KGR_PATCHES_INIT_ERR_HANDLERS@@:\?%$KGR_PATCHES_INIT_ERR_HANDLERS%;
s%\s*@@KGR_PATCHES_CLEANUP_CALLS@@;\?%$KGR_PATCHES_CLEANUP_CALLS%;
s%\s*@@KGR_PATCHES_CLEANUP_CALLS@@;\?%$KGR_PATCHES_CLEANUP_CALLS%;
EOF
+
+
+# Finish kgraft-patch.spec:
+## Enumerate the per subpatch source *.tar.bz2.
+## Note: Start with Source6
+S=6
+## First check that none of the to be occupied Source<n> slots has
+## been used already.
+for i in "${!kgr_patches[@]}"; do
+ if grep -q "^\s*Source$((i+S))\s*:" "$kgr_patch_spec_file"; then
+ echo "error: Source$((i+S)) already used in $kgr_patch_spec_file" 1>&2
+ exit 1;
+ fi
+done
+
+KGR_PATCHES_SOURCES=$(
+ echo -n "# Auto expanded KGR_PATCHES_SOURCES:\n"
+ for i in "${!kgr_patches[@]}"; do
+ echo -n "Source$((i+S)):\t${kgr_patches[i]}.tar.bz2\n"
+ done | sed 's/\\n$//' # rm trailing extra newlines
+)
+
+## And extract them from %prep
+KGR_PATCHES_SETUP_SOURCES=$(
+ echo -n "# Auto expanded KGR_PATCHES_SETUP_SOURCES:\n"
+ if [ ${#kgr_patches[@]} -gt 0 ]; then
+ echo -n '%setup -T -D'
+ for i in "${!kgr_patches[@]}"; do
+ echo -n " -a $((i+S))"
+ done
+ fi)
+
+sed -i -f - "$kgr_patch_spec_file" <<EOF
+s%@@KGR_PATCHES_SOURCES@@%$KGR_PATCHES_SOURCES%;
+s,@@KGR_PATCHES_SETUP_SOURCES@@,$KGR_PATCHES_SETUP_SOURCES,;
+EOF
diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh
index 5622787..5cd9b1f 100755
--- a/scripts/tar-up.sh
+++ b/scripts/tar-up.sh
@@ -73,8 +73,8 @@ done
source $(dirname $0)/release-version.sh
install -m 644 kgr_patch_main.c $build_dir
-scripts/register-patches.sh $build_dir/kgr_patch_main.c
install -m 644 rpm/kgraft-patch.spec $build_dir/kgraft-patch-"$RELEASE".spec
+scripts/register-patches.sh $build_dir/kgr_patch_main.c $build_dir/kgraft-patch-"$RELEASE".spec
install -m 644 rpm/config.sh $build_dir/config.sh
install -m 644 compat.h $build_dir