From d746fed82003b740680434c09655d7d5e7108994 Mon Sep 17 00:00:00 2001
From: Donald Dugger <n0ano@n0ano.com>
Date: Mon, 6 Jun 2016 15:30:38 +0000
Subject: [PATCH] Move quirks out of build script

Due to expediencyh concerns some quirk code was placed in the build
script in order to get the Brahmaputra release out on time.  These
quirks don't belong in the script itself and, now that there is a
mechanisms to applly arbitrary patch files during the build script,
this patch moves that quirk code out to the separate patch file
area.

Upstream status - NA

Change-Id: Ib8100eef00009bbaf0e16b28849821ef5878f9f5
Signed-off-by: Donald Dugger <n0ano@n0ano.com>
---
 fuel-plugin/build_kvm.sh                           | 64 +++++++---------------
 .../kernel/0001-Restore-deprecated-XFS-API.patch   | 25 +++++++++
 2 files changed, 44 insertions(+), 45 deletions(-)
 create mode 100644 patches/kernel/0001-Restore-deprecated-XFS-API.patch

diff --git a/fuel-plugin/build_kvm.sh b/fuel-plugin/build_kvm.sh
index a26532d69..0ea75a0e4 100755
--- a/fuel-plugin/build_kvm.sh
+++ b/fuel-plugin/build_kvm.sh
@@ -5,40 +5,18 @@ OVS_COMMIT="4ff6642f3c1dd8949c2f42b3310ee2523ee970a6"
 KEEP=no
 
 quirks() {
-	# Workaround build bug on Ubuntu 14.04
-	cat <<EOF > arch/x86/boot/install.sh
-#!/bin/sh
-cp -a -- "\$2" "\$4/vmlinuz-\$1"
-EOF
 
-	# Add deprecated XFS delaylog option back in
-	cat <<EOF | patch -p2
-diff --git a/kernel/fs/xfs/xfs_super.c b/kernel/fs/xfs/xfs_super.c
-index 65a4537..b73ca67 100644
---- a/kernel/fs/xfs/xfs_super.c
-+++ b/kernel/fs/xfs/xfs_super.c
-@@ -109,6 +109,7 @@ static struct xfs_kobj xfs_dbg_kobj;	/* global debug sysfs attrs */
- #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
- #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
- #define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-+#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
- #define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
- #define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
- 
-@@ -359,6 +360,9 @@ xfs_parseargs(
- 		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
- 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
- 			mp->m_qflags &= ~XFS_GQUOTA_ENFD;
-+		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
-+			xfs_warn(mp,
-+		"delaylog is the default now, option is deprecated.");
- 		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
- 			mp->m_flags |= XFS_MOUNT_DISCARD;
- 		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
--- 
-1.9.1
-
-EOF
+	#
+	# Apply out of tree patches
+	#
+	for i in $SRC/kvmfornfv/patches/$1/*.patch
+	do
+		if [ -f "$i" ]
+		then
+			echo "Applying: $i"
+			patch -p1 <$i
+		fi
+	done
 }
 
 for i
@@ -106,7 +84,13 @@ fi
 	fi
 	cd kernel
 
-	quirks
+	# Workaround build bug on Ubuntu 14.04
+	cat <<EOF > arch/x86/boot/install.sh
+#!/bin/sh
+cp -a -- "\$2" "\$4/vmlinuz-\$1"
+EOF
+
+	quirks kernel
 
 	# Configure the kernel
 	cp $CONFIG .config
@@ -131,17 +115,7 @@ fi
 		git reset --hard
 	fi
 
-	#
-	# Apply out of tree patches
-	#
-	for i in $SRC/kvmfornfv/patches/ovs/*.patch
-	do
-		if [ -f "$i" ]
-		then
-			echo "Applying: $i"
-			patch -p1 <$i
-		fi
-	done
+	quirks ovs
 
 	./boot.sh
 	./configure --with-linux=$SRC/kvmfornfv/kernel
diff --git a/patches/kernel/0001-Restore-deprecated-XFS-API.patch b/patches/kernel/0001-Restore-deprecated-XFS-API.patch
new file mode 100644
index 000000000..3275b7b4b
--- /dev/null
+++ b/patches/kernel/0001-Restore-deprecated-XFS-API.patch
@@ -0,0 +1,25 @@
+diff --git a/kernel/fs/xfs/xfs_super.c b/kernel/fs/xfs/xfs_super.c
+index 65a4537..b73ca67 100644
+--- a/kernel/fs/xfs/xfs_super.c
++++ b/kernel/fs/xfs/xfs_super.c
+@@ -109,6 +109,7 @@ static struct xfs_kobj xfs_dbg_kobj;	/* global debug sysfs attrs */
+ #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
+ #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
+ #define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
++#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
+ #define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
+ #define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+ 
+@@ -359,6 +360,9 @@ xfs_parseargs(
+ 		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+ 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
+ 			mp->m_qflags &= ~XFS_GQUOTA_ENFD;
++		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
++			xfs_warn(mp,
++		"delaylog is the default now, option is deprecated.");
+ 		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+ 			mp->m_flags |= XFS_MOUNT_DISCARD;
+ 		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+-- 
+1.9.1
+
-- 
2.16.6