4 if ! [ -d kernel -a -d Documentation ]
6 echo >&2 "Not in kernel top level directory. Exiting"
9 TOPPATCHDIR=/usr/src/kernel-patches/lustre
10 ARCHITECTURE=`dpkg --print-installation-architecture`
12 QUILT="quilt --quiltrc /dev/null"
13 export QUILT_PATCHES="$TOPPATCHDIR/patches"
15 if ! [ -f debian/APPLIED_all_lustre ]; then
16 echo >&2 "Lustre patch not applied."
19 VERSION=$(grep ^VERSION Makefile 2>/dev/null | \
20 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
21 PATCHLEVEL=$( grep ^PATCHLEVEL Makefile 2>/dev/null | \
22 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
23 SUBLEVEL=$(grep ^SUBLEVEL Makefile 2>/dev/null | \
24 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
25 #EXTRAVERSION=$(grep ^EXTRAVERSION Makefile | head -1 2>/dev/null | \
26 # sed -e 's/EXTRAVERSION =[ ]*\([^ ]*\)$/\1/')
27 #KERNELBRANCHLET=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
28 #KERNELRELEASE=${KERNELBRANCHLET}${EXTRAVERSION}
29 KERNELRELEASE=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
31 # Check for depends on lustre
32 if grep -l "^DEPENDS=.*[' ]all/unpatch/lustre[' ]" debian/APPLIED_* >/dev/null 2>/dev/null; then
33 # There are patches depending on this one, to be removed before.
34 # the dep will be removed by the last of those other patches.
35 echo >&2 "NOT unpatching \"Lustre Filesystem patch for the Linux kernel\" since other patches still rely on it"
39 if ! [ -d debian/APPLIED_all_lustre_tmp/.pc.lustre ]; then
41 ERROR: .pc directory missing for unpatching. I strongly suggest
42 you remove this kernel tree and unpack a clean one.
47 if ! [ -e debian/APPLIED_all_lustre_tmp/series.lustre ]; then
49 ERROR: series file missing for unpatching. I strongly suggest
50 you remove this kernel tree and unpack a clean one.
57 if [ -e series ]; then
58 echo >&2 Removing series file
61 if [ -e debian/APPLIED_all_lustre_tmp/series.orig ]; then
62 echo >&1 Restoring orig series file
63 mv debian/APPLIED_all_lustre_tmp/series.orig series
66 echo >&2 Removing .pc dir
69 if [ -e debian/APPLIED_all_lustre_tmp/.pc.orig ]; then
70 echo >&2 Restoring orig .pc dir
71 mv debian/APPLIED_all_lustre_tmp/.pc.orig .pc
75 if [ -e series ]; then
76 echo >&2 Preserving existing series file
77 mv series debian/APPLIED_all_lustre_tmp/series.orig
80 echo >&2 Preserving existing .pc dir
81 mv .pc debian/APPLIED_all_lustre_tmp/.pc.orig
86 echo >&2 Restoring lustre quilt
87 mv debian/APPLIED_all_lustre_tmp/series.lustre series
88 mv debian/APPLIED_all_lustre_tmp/.pc.lustre .pc
90 echo >&2 Unpatching lustre patches
93 if ! [ $ERR = 0 ]; then
95 ERROR: Lustre patches failed to unpatch. I strongly suggest
96 you remove this kernel tree and unpack a clean one.
102 echo >&2 Removing lustre quilt
105 rm debian/APPLIED_all_lustre debian/image.d/register-lustre
107 echo >&2 "\"Lustre Filesystem patch for the Linux kernel\" patch for $KVERSION removed successfully"
109 echo >&2 "Removing empty files:"
110 # make an exception for ./debian, or else the stamp files will go too.
111 find . -path ./debian -prune -o \
112 -type f -size 0 ! -name 'APPLIED*' -exec rm {} \; -print
115 rmdir debian/image.d debian/APPLIED_all_lustre_tmp || true
117 echo >&2 "END unpatching lustre patch"