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 [ -f debian/APPLIED_all_lustre ] && exit 0
16 VERSION=$(grep ^VERSION Makefile 2>/dev/null | \
17 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
18 PATCHLEVEL=$( grep ^PATCHLEVEL Makefile 2>/dev/null | \
19 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
20 SUBLEVEL=$(grep ^SUBLEVEL Makefile 2>/dev/null | \
21 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
22 #EXTRAVERSION=$(grep ^EXTRAVERSION Makefile | head -1 2>/dev/null | \
23 # sed -e 's/EXTRAVERSION =[ ]*\([^ ]*\)$/\1/')
24 #KERNELBRANCHLET=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
25 #KERNELRELEASE=${KERNELBRANCHLET}${EXTRAVERSION}
26 KERNELRELEASE=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
30 if [ -e series ]; then
31 echo >&2 Removing series file
34 if [ -e debian/APLLIED_all_lustre_tmp/series.orig ]; then
35 echo >&1 Restoring orig series file
36 mv debian/APLLIED_all_lustre_tmp/series.orig series
39 echo >&2 Removing .pc dir
42 if [ -e debian/APPLIED_all_lustre_tmp/.pc.orig ]; then
43 echo >&2 Restoring orig .pc dir
44 mv debian/APPLIED_all_lustre_tmp/.pc.orig .pc
48 mkdir -p debian/APPLIED_all_lustre_tmp
49 if [ -e series ]; then
50 echo >&2 Preserving existing series file
51 mv series debian/APPLIED_all_lustre_tmp/series.orig
54 echo >&2 Preserving existing .pc dir
55 mv .pc debian/APPLIED_all_lustre_tmp/.pc.orig
60 echo >&2 Setting up quilt
61 $QUILT setup $TOPPATCHDIR/series/$KERNELRELEASE-vanilla.series 2>/dev/null
63 if ! [ $ERR = 0 ]; then
64 echo >&2 Quilt failed to initialize
69 echo >&2 Applying lustre patches
72 if ! [ $ERR = 0 ]; then
73 echo >&2 Lustre patched failed to apply
74 echo >&2 Reverting partialy applied patch
80 echo >&2 Finalizing lustre patch
81 mv series debian/APPLIED_all_lustre_tmp/series.lustre
82 mv .pc debian/APPLIED_all_lustre_tmp/.pc.lustre
86 echo >&2 "\"Lustre Filesystem patch for the Linux kernel\" patch for $KVERSION succeeded"
88 echo >&2 "Removing empty files:"
89 # make an exception for ./debian, or else the stamp files will go too.
90 find . -path ./debian -prune -o \
91 -type f -size 0 ! -name 'APPLIED*' -exec rm {} \; -print
95 cat > 'debian/APPLIED_all_lustre' <<EOF
96 SERIES=$KERNELRELEASE-vanilla.series
98 mkdir -p debian/image.d
99 PKGNAME=`dpkg -S $TOPPATCHDIR/series/$KERNELRELEASE-vanilla.series | cut -d: -f1`
100 PKGVERS=`grep-dctrl -n -P $PKGNAME -s Version -X /var/lib/dpkg/status`
101 cat > 'debian/image.d/register-lustre' <<EOF
104 # This scripts documents the "Lustre Filesystem patch for the Linux kernel" kernel patch into the
105 # kernel-image package, as being applied to the kernel.
107 docdir=\${IMAGE_TOP}/usr/share/doc/kernel-image-\${version}
112 printf 'Lustre Filesystem patch for the Linux kernel (lustre)${KPATCH_lustre:+ for kernel ${KPATCH_lustre}},'
113 echo ' from package $PKGNAME, version $PKGVERS'
114 ) >> \${docdir}/applied-patches
116 chmod +x 'debian/image.d/register-lustre'
118 echo >&2 "END applying lustre patch"