File: rebase-patches

package info (click to toggle)
kpatch 0.9.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,716 kB
  • sloc: ansic: 9,716; sh: 2,592; makefile: 260; asm: 35
file content (56 lines) | stat: -rwxr-xr-x 1,339 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# rebase a set of integration test patches
#
# Example:
#
# 1 - Extract kernel sources:
#
# % (rpm -ivh kernel-3.10.0-1127.el7.src.rpm; \
#    cd ~/rpmbuild/SPECS; \
#    rpmbuild --nodeps -bp kernel.spec)
#
#
# 2 - Rebase from previous release tests:
#
# % cd test/integration
# % SRCDIR="$HOME/rpmbuild/BUILD/kernel-3.10.0-1127.el7/linux-3.10.0-1127.el7.x86_64" \
#    ID=rhel VERSION_ID=7.8 ./rebase-patches rhel-7.7/*{.patch,.disabled}
# % cp rhel-7.7/*.test rhel-7.8/

OUTDIR=$(pwd)/${ID}-${VERSION_ID}
mkdir -p "$OUTDIR"

echo "* Making backup copy of kernel sources"
rm -rf "${SRCDIR}.orig"
cp -r "$SRCDIR" "${SRCDIR}.orig"

for P in "$@"; do

  echo
  echo "* Patch: $(basename "$P")"

  echo "** dry run..."
  if ! patch -d "$SRCDIR" --dry-run --quiet -p1 < "$P"; then
    echo "*** Skipping! ***" && continue
  fi

  echo "** patching..."
  patch -d "$SRCDIR" -p1 --no-backup-if-mismatch < "$P"

  echo "** generating new $(basename "$P")..."
  NEWP="$OUTDIR"/$(basename "$P")
  awk '/^Index|^diff|^patch/{exit} {print $LF}' "$P" > "$NEWP"
  diff -Nupr "$SRCDIR.orig" "${SRCDIR}" >> "$NEWP"
  sed -i "s#$SRCDIR#src#g" "$NEWP"

  echo "** reversing patch to restore tree..."
  patch -d "$SRCDIR" -p1 -R < "$NEWP"

done

echo "*** Removing backup copy of kernel sources"
rm -rf "${SRCDIR}.orig"

echo
echo "*** Done"