jjb: Support s3cmd 2.3 in lttng-modules build
[lttng-ci.git] / scripts / lttng-modules / param-build.sh
index f414ca982ebb09687a95e1b60144181a364773c6..b5c8b8f8b598a855a1fd56d342c333d06808ed92 100644 (file)
@@ -1,6 +1,6 @@
-#!/bin/bash -exu
+#!/bin/bash
 #
-# Copyright (C) 2016-2019 Michael Jeanson <mjeanson@efficios.com>
+# Copyright (C) 2016-2019 Michael Jeanson <mjeanson@efficios.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+set -exu
+
 # Parameters
-arch=${arch:-}
+arch=${arch:-amd64}
 cross_arch=${cross_arch:-}
 ktag=${ktag:-}
 kgitrepo=${kgitrepo:-}
@@ -92,6 +94,16 @@ tar_archive_obj() {
     cd -
 }
 
+list_gccs() {
+    local gccs
+    gccs=()
+    IFS=: read -r -a path_array <<< "$PATH"
+    while read -r gcc ; do
+        gccs+=("$gcc")
+    done < <(find "${path_array[@]}" -maxdepth 1 -regex '.*/gcc-[0-9\.]+$' -printf '%f\n' | sort -t- -k2 -V -r)
+    echo "${gccs[@]}"
+}
+
 # Find the most recent GCC version supported by the kernel sources
 select_compiler() {
     local selected_cc
@@ -102,7 +114,7 @@ select_compiler() {
 
     set +e
 
-    for cc in gcc-5 gcc-4.8; do
+    for cc in $(list_gccs) ; do
       if "${CROSS_COMPILE:-}${cc}" -I include/ -D__LINUX_COMPILER_H -D__LINUX_COMPILER_TYPES_H -E include/linux/compiler-gcc.h; then
         selected_cc="$cc"
         break
@@ -154,6 +166,11 @@ build_linux_kernel() {
         # Disable riscv64 config generation, we don't have a toolchain on bionic
         sed -i 's/riscv64 //' debian.master/etc/kernelconfig
 
+        # Hack for kernel Ubuntu-hwe-5.8
+        if [ ! -f "debian/compat" ]; then
+            echo "10" > "debian/compat"
+        fi
+
         fakeroot debian/rules clean KW_DEFCONFIG_DIR=.
         fakeroot debian/rules genconfigs KW_DEFCONFIG_DIR=.
         cp CONFIGS/"${ubuntu_config}" .config
@@ -260,6 +277,9 @@ build_linux_kernel() {
       scripts/config --disable CONFIG_IGBVF
     fi
 
+    # Don't fail the build on warnings
+    scripts/config --disable CONFIG_WERROR
+
     # Set required options
     scripts/config --enable CONFIG_TRACEPOINTS
     scripts/config --enable CONFIG_KALLSYMS
@@ -273,6 +293,14 @@ build_linux_kernel() {
     scripts/config --enable CONFIG_EVENT_TRACING
     scripts/config --enable CONFIG_KRETPROBES
 
+    # FIXME: disable objtool on vmlinux, it OOMs on allyesconfig
+    sed -i 's/objtool_link vmlinux.o//' scripts/link-vmlinux.sh || true
+    # Starting with v6.1-rc6
+    sed -i 's/^objtool-enabled := .*/objtool-enabled := /' scripts/Makefile.vmlinux_o || true
+
+    # Disable SORTTAB
+    sed -i 's/is_enabled CONFIG_BUILDTIME_TABLE_SORT/is_enabled CONFIG_NONEXISTANT/' scripts/link-vmlinux.sh || true
+
     # Debug
     #cat .config
 
@@ -284,7 +312,7 @@ build_linux_kernel() {
     # Save the kernel and modules
     mkdir -p "$LINUX_INSTOBJ_DIR/boot"
     make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install CC="$CC"
-    make INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install CC="$CC"
+    make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install CC="$CC"
     rm -f "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/build"
     ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
     ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
@@ -380,7 +408,9 @@ extract_distro_headers() {
     touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h"
 
     # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
-    cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
+    if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then
+        cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
+    fi
 
     # Finally clean the object files from the full source tree
     make clean
@@ -424,6 +454,10 @@ build_modules() {
 
     kversion=$(make -C "$LINUX_HDROBJ_DIR" -s kernelversion)
 
+    # Try to catch some compatibility problems by turning some
+    # warnings into errors.
+    #export KCFLAGS="$KCFLAGS -Wall -Werror"
+
     # Enter lttng-modules source dir
     cd "${MODULES_GIT_DIR}"
 
@@ -614,12 +648,16 @@ fi
 obj_url="$obj_url_prefix/$obj_name"
 
 set +e
-s3cmd -c "$WORKSPACE/.s3cfg" get "$obj_url"
+# In s3cmd 2.3, the return code of get when an object does not exist (64)
+# is different than in 2.2 (12). The return codes of 's3cmd info' are
+# consistent between 2.2 and 2.3.
+s3cmd -c "$WORKSPACE/.s3cfg" info "$obj_url"
 ret=$?
 set -e
 
 case "$ret" in
     "0")
+      s3cmd -c "$WORKSPACE/.s3cfg" get "$obj_url"
       extract_archive_obj
       ;;
 
This page took 0.040978 seconds and 4 git commands to generate.