Whamcloud - gitweb
LU-170 oscc_grow_count will never grow
[fs/lustre-release.git] / debian / linux-patch-lustre.apply
1 #! /bin/bash
2 set -x
3
4 if ! [ -d kernel -a -d Documentation ]
5 then
6     echo >&2 "Not in kernel top level directory. Exiting"
7     exit 1
8 fi
9 TOPPATCHDIR=/usr/src/kernel-patches/lustre
10 ARCHITECTURE=`dpkg --print-installation-architecture`
11
12 QUILT="quilt --quiltrc /dev/null"
13 export QUILT_PATCHES="$TOPPATCHDIR/patches"
14
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}
27
28 cleanup() {
29   echo >&2 Cleaning up
30   if [ -e series ]; then
31     echo >&2 Removing series file
32     rm series
33   fi
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
37   fi
38   if [ -e .pc ]; then
39     echo >&2 Removing .pc dir
40     rm -r .pc
41   fi
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
45   fi
46 }
47
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
52 fi
53 if [ -e .pc ]; then
54   echo >&2 Preserving existing .pc dir
55   mv .pc debian/APPLIED_all_lustre_tmp/.pc.orig
56 fi
57
58 trap cleanup EXIT
59
60 echo >&2 Setting up quilt
61 $QUILT setup $TOPPATCHDIR/series/$KERNELRELEASE-vanilla.series 2>/dev/null
62 ERR=$?
63 if ! [ $ERR = 0 ]; then
64   echo >&2 Quilt failed to initialize
65   cleanup
66   exit $ERR
67 fi
68
69 echo >&2 Applying lustre patches
70 $QUILT push -a
71 ERR=$?
72 if ! [ $ERR = 0 ]; then
73   echo >&2 Lustre patched failed to apply
74   echo >&2 Reverting partialy applied patch
75   $QUILT pop -a
76   cleanup
77   exit $ERR
78 fi
79
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
83 cleanup
84
85
86 echo >&2 "\"Lustre Filesystem patch for the Linux kernel\" patch for $KVERSION succeeded"
87
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
92 echo >&2 "Done."
93
94 mkdir -p debian
95 cat > 'debian/APPLIED_all_lustre' <<EOF
96 SERIES=$KERNELRELEASE-vanilla.series
97 EOF
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
102 #!/bin/sh
103
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.
106
107 docdir=\${IMAGE_TOP}/usr/share/doc/kernel-image-\${version}
108
109 mkdir -p \${docdir}
110
111 (
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
115 EOF
116 chmod +x 'debian/image.d/register-lustre'
117
118 echo >&2 "END applying lustre patch"