diff mbox

[2/3] Update to use a .config file

Message ID 1465556565-26403-2-git-send-email-ross.lagerwall@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ross Lagerwall June 10, 2016, 11:02 a.m. UTC
Remove the old --xen-debug option, and instead, require the user to pass
a .config file matching the original build's .config.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 livepatch-build | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Comments

Konrad Rzeszutek Wilk June 14, 2016, 3:35 p.m. UTC | #1
On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
> Remove the old --xen-debug option, and instead, require the user to pass
> a .config file matching the original build's .config.

Hm, that throws this off a bit for the older hypervisors (to which
I had backported livepatch). Perhaps we could add some logic to
check if common/Kconfig exist? 

And I also wonder if the --xen-debug option removal should be a seperate
patch?

> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  livepatch-build | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/livepatch-build b/livepatch-build
> index 8dc8889..e9d1e8d 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -66,7 +66,7 @@ function build_full()
>  {
>      cd "${SRCDIR}/xen" || die
>      make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die
> -    make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die
> +    make "-j$CPUS" &> "${OUTPUT}/build_full_compile.log" || die
>      cp xen-syms "$OUTPUT"
>  }
>  
> @@ -86,7 +86,7 @@ function build_special()
>      # Build with special GCC flags
>      cd "${SRCDIR}/xen" || die
>      sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk
> -    make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die
> +    make "-j$CPUS" &> "${OUTPUT}/build_${name}_compile.log" || die
>      sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
>  
>      unset LIVEPATCH_BUILD_DIR
> @@ -158,17 +158,17 @@ usage() {
>      echo "        -h, --help         Show this help message" >&2
>      echo "        -s, --srcdir       Xen source directory" >&2
>      echo "        -p, --patch        Patch file" >&2
> +    echo "        -c, --config       .config file" >&2
>      echo "        -o, --output       Output directory" >&2
>      echo "        -j, --cpus         Number of CPUs to use" >&2
>      echo "        -k, --skip         Skip build or diff phase" >&2
>      echo "        -d, --debug        Enable debug logging" >&2
> -    echo "        --xen-debug        Build debug Xen" >&2
>      echo "        --xen-syms         Build against a xen-syms" >&2
>      echo "        --depends          Required build-id" >&2
>      echo "        --prelink          Prelink" >&2
>  }
>  
> -options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
> +options=$(getopt -o hs:p:c:o:j:k:d -l "help,srcdir:patch:config:output:cpus:,skip:,debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
>  
>  eval set -- "$options"
>  
> @@ -192,10 +192,6 @@ while [[ $# -gt 0 ]]; do
>              DEBUG=1
>              shift
>              ;;
> -        --xen-debug)
> -            XEN_DEBUG=y
> -            shift
> -            ;;
>          -s|--srcdir)
>              shift
>              srcarg="$1"
> @@ -206,6 +202,11 @@ while [[ $# -gt 0 ]]; do
>              patcharg="$1"
>              shift
>              ;;
> +        -c|--config)
> +            shift
> +            configarg="$1"
> +            shift
> +            ;;
>          -o|--output)
>              shift
>              outputarg="$1"
> @@ -235,15 +236,18 @@ done
>  
>  [ -z "$srcarg" ] && die "Xen directory not given"
>  [ -z "$patcharg" ] && die "Patchfile not given"
> +[ -z "$configarg" ] && die ".config not given"
>  [ -z "$outputarg" ] && die "Output directory not given"
>  [ -z "$DEPENDS" ] && die "Build-id dependency not given"
>  
>  SRCDIR="$(readlink -m -- "$srcarg")"
>  PATCHFILE="$(readlink -m -- "$patcharg")"
> +CONFIGFILE="$(readlink -m -- "$configarg")"
>  OUTPUT="$(readlink -m -- "$outputarg")"
>  
>  [ -d "${SRCDIR}" ] || die "Xen directory does not exist"
>  [ -f "${PATCHFILE}" ] || die "Patchfile does not exist"
> +[ -f "${CONFIGFILE}" ] || die ".config does not exist"
>  
>  PATCHNAME=$(make_patch_name "${PATCHFILE}")
>  
> @@ -251,16 +255,20 @@ echo "Building LivePatch patch: ${PATCHNAME}"
>  echo
>  echo "Xen directory: ${SRCDIR}"
>  echo "Patch file: ${PATCHFILE}"
> +echo ".config file: ${CONFIGFILE}"
>  echo "Output directory: ${OUTPUT}"
>  echo "================================================"
>  echo
>  
>  if [ "${SKIP}" != "build" ]; then
>      [ -e "${OUTPUT}" ] && die "Output directory exists"
> +    grep -q 'CONFIG_LIVEPATCH=y' "${CONFIGFILE}" || die "CONFIG_LIVEPATCH must be enabled"
>      cd "$SRCDIR" || die
>      patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply"
>  
>      mkdir -p "${OUTPUT}" || die
> +    cp -f "${CONFIGFILE}" "${OUTPUT}/.config"
> +    cp -f "${OUTPUT}/.config" "xen/.config"
>  
>      echo "Perform full initial build with ${CPUS} CPU(s)..."
>      build_full
> -- 
> 2.4.11
>
Ross Lagerwall June 15, 2016, 8:08 a.m. UTC | #2
On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
> On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
>> Remove the old --xen-debug option, and instead, require the user to pass
>> a .config file matching the original build's .config.
>
> Hm, that throws this off a bit for the older hypervisors (to which
> I had backported livepatch). Perhaps we could add some logic to
> check if common/Kconfig exist?

At this point rather than adding extra logic to support different 
still-experimental versions, I'd rather just have a different branch. 
Maybe have a branch per Xen release?

>
> And I also wonder if the --xen-debug option removal should be a seperate
> patch?
>

Well the two are related -- the motivation to use the .config is because 
the debug flag is now controlled by the .config rather than the 
command-line argument.
Konrad Rzeszutek Wilk June 15, 2016, 2 p.m. UTC | #3
On Wed, Jun 15, 2016 at 09:08:46AM +0100, Ross Lagerwall wrote:
> On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
> >On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
> >>Remove the old --xen-debug option, and instead, require the user to pass
> >>a .config file matching the original build's .config.
> >
> >Hm, that throws this off a bit for the older hypervisors (to which
> >I had backported livepatch). Perhaps we could add some logic to
> >check if common/Kconfig exist?
> 
> At this point rather than adding extra logic to support different
> still-experimental versions, I'd rather just have a different branch. Maybe
> have a branch per Xen release?
> 
> >
> >And I also wonder if the --xen-debug option removal should be a seperate
> >patch?
> >
> 
> Well the two are related -- the motivation to use the .config is because the
> debug flag is now controlled by the .config rather than the command-line
> argument.

But not in the 4.7 that is going out - that 'debug=y' is non-Kconfig?
> 
> -- 
> Ross Lagerwall
Ross Lagerwall July 14, 2016, 8:05 a.m. UTC | #4
On 06/15/2016 03:00 PM, Konrad Rzeszutek Wilk wrote:
> On Wed, Jun 15, 2016 at 09:08:46AM +0100, Ross Lagerwall wrote:
>> On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
>>> On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
>>>> Remove the old --xen-debug option, and instead, require the user to pass
>>>> a .config file matching the original build's .config.
>>>
>>> Hm, that throws this off a bit for the older hypervisors (to which
>>> I had backported livepatch). Perhaps we could add some logic to
>>> check if common/Kconfig exist?
>>
>> At this point rather than adding extra logic to support different
>> still-experimental versions, I'd rather just have a different branch. Maybe
>> have a branch per Xen release?
>>
>>>
>>> And I also wonder if the --xen-debug option removal should be a seperate
>>> patch?
>>>
>>
>> Well the two are related -- the motivation to use the .config is because the
>> debug flag is now controlled by the .config rather than the command-line
>> argument.
>
> But not in the 4.7 that is going out - that 'debug=y' is non-Kconfig?
>>

OK, I'll split it into two. Feel free to create a stable-47 branch in 
livepatch-build-tools.git with only the .config patch. Personally, I'd 
rather not spend much time backporting stuff to support a tech preview 
feature on an older branch.
diff mbox

Patch

diff --git a/livepatch-build b/livepatch-build
index 8dc8889..e9d1e8d 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -66,7 +66,7 @@  function build_full()
 {
     cd "${SRCDIR}/xen" || die
     make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die
-    make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die
+    make "-j$CPUS" &> "${OUTPUT}/build_full_compile.log" || die
     cp xen-syms "$OUTPUT"
 }
 
@@ -86,7 +86,7 @@  function build_special()
     # Build with special GCC flags
     cd "${SRCDIR}/xen" || die
     sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk
-    make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die
+    make "-j$CPUS" &> "${OUTPUT}/build_${name}_compile.log" || die
     sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
 
     unset LIVEPATCH_BUILD_DIR
@@ -158,17 +158,17 @@  usage() {
     echo "        -h, --help         Show this help message" >&2
     echo "        -s, --srcdir       Xen source directory" >&2
     echo "        -p, --patch        Patch file" >&2
+    echo "        -c, --config       .config file" >&2
     echo "        -o, --output       Output directory" >&2
     echo "        -j, --cpus         Number of CPUs to use" >&2
     echo "        -k, --skip         Skip build or diff phase" >&2
     echo "        -d, --debug        Enable debug logging" >&2
-    echo "        --xen-debug        Build debug Xen" >&2
     echo "        --xen-syms         Build against a xen-syms" >&2
     echo "        --depends          Required build-id" >&2
     echo "        --prelink          Prelink" >&2
 }
 
-options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
+options=$(getopt -o hs:p:c:o:j:k:d -l "help,srcdir:patch:config:output:cpus:,skip:,debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
 
 eval set -- "$options"
 
@@ -192,10 +192,6 @@  while [[ $# -gt 0 ]]; do
             DEBUG=1
             shift
             ;;
-        --xen-debug)
-            XEN_DEBUG=y
-            shift
-            ;;
         -s|--srcdir)
             shift
             srcarg="$1"
@@ -206,6 +202,11 @@  while [[ $# -gt 0 ]]; do
             patcharg="$1"
             shift
             ;;
+        -c|--config)
+            shift
+            configarg="$1"
+            shift
+            ;;
         -o|--output)
             shift
             outputarg="$1"
@@ -235,15 +236,18 @@  done
 
 [ -z "$srcarg" ] && die "Xen directory not given"
 [ -z "$patcharg" ] && die "Patchfile not given"
+[ -z "$configarg" ] && die ".config not given"
 [ -z "$outputarg" ] && die "Output directory not given"
 [ -z "$DEPENDS" ] && die "Build-id dependency not given"
 
 SRCDIR="$(readlink -m -- "$srcarg")"
 PATCHFILE="$(readlink -m -- "$patcharg")"
+CONFIGFILE="$(readlink -m -- "$configarg")"
 OUTPUT="$(readlink -m -- "$outputarg")"
 
 [ -d "${SRCDIR}" ] || die "Xen directory does not exist"
 [ -f "${PATCHFILE}" ] || die "Patchfile does not exist"
+[ -f "${CONFIGFILE}" ] || die ".config does not exist"
 
 PATCHNAME=$(make_patch_name "${PATCHFILE}")
 
@@ -251,16 +255,20 @@  echo "Building LivePatch patch: ${PATCHNAME}"
 echo
 echo "Xen directory: ${SRCDIR}"
 echo "Patch file: ${PATCHFILE}"
+echo ".config file: ${CONFIGFILE}"
 echo "Output directory: ${OUTPUT}"
 echo "================================================"
 echo
 
 if [ "${SKIP}" != "build" ]; then
     [ -e "${OUTPUT}" ] && die "Output directory exists"
+    grep -q 'CONFIG_LIVEPATCH=y' "${CONFIGFILE}" || die "CONFIG_LIVEPATCH must be enabled"
     cd "$SRCDIR" || die
     patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply"
 
     mkdir -p "${OUTPUT}" || die
+    cp -f "${CONFIGFILE}" "${OUTPUT}/.config"
+    cp -f "${OUTPUT}/.config" "xen/.config"
 
     echo "Perform full initial build with ${CPUS} CPU(s)..."
     build_full