]> The Tcpdump Group git mirrors - tcpdump/commitdiff
CI: Synchronize scripts with the master branch.
authorDenis Ovsienko <[email protected]>
Thu, 4 Apr 2024 07:07:25 +0000 (08:07 +0100)
committerDenis Ovsienko <[email protected]>
Thu, 4 Apr 2024 07:07:25 +0000 (08:07 +0100)
build.sh
build_common.sh
build_matrix.sh

index a900115f50cc7b186d7f717283a06d329abc85b8..ed3f20094ae9730a7d898e9a79d73d8f8c8b3c3a 100755 (executable)
--- a/build.sh
+++ b/build.sh
 : "${TCPDUMP_TAINTED:=no}"
 : "${TCPDUMP_CMAKE_TAINTED:=no}"
 : "${MAKE_BIN:=make}"
+# At least one OS (AIX 7) where this software can build does not have at least
+# one command (mktemp) required for a successful run of "make releasetar".
+: "${TEST_RELEASETAR:=yes}"
 
 . ./build_common.sh
 # Install directory prefix
 if [ -z "$PREFIX" ]; then
     PREFIX=`mktempdir tcpdump_build`
     echo "PREFIX set to '$PREFIX'"
+    DELETE_PREFIX=yes
 fi
 TCPDUMP_BIN="$PREFIX/bin/tcpdump"
 # For TESTrun
@@ -39,10 +43,19 @@ clang-*/SunOS-5.11)
     #   [-Wstrict-prototypes]
     [ "`uname -o`" = illumos ] && TCPDUMP_TAINTED=yes
     ;;
+*)
+    ;;
 esac
 
 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
 
+case `cc_id`/`os_id` in
+clang-*/SunOS-5.11)
+    # Work around https://www.illumos.org/issues/16369
+    [ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}"
+    ;;
+esac
+
 # If necessary, set TCPDUMP_CMAKE_TAINTED here to exempt particular cmake from
 # warnings. Use as specific terms as possible (e.g. some specific version and
 # some specific OS).
@@ -68,14 +81,14 @@ else
     run_after_echo mkdir build
     run_after_echo cd build
     if [ "$BUILD_LIBPCAP" = yes ]; then
-        run_after_echo cmake "$CMAKE_OPTIONS" \
+        run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
             -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
             ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
             -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
         LD_LIBRARY_PATH="$PREFIX/lib"
         export LD_LIBRARY_PATH
     else
-        run_after_echo cmake "$CMAKE_OPTIONS" \
+        run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
             -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
              ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
             -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
@@ -111,7 +124,7 @@ if [ "$BUILD_LIBPCAP" = yes ]; then
     run_after_echo "$MAKE_BIN" check
 fi
 if [ "$CMAKE" = no ]; then
-    run_after_echo "$MAKE_BIN" releasetar
+    [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
 fi
 if [ "$CIRRUS_CI" = true ]; then
     run_after_echo sudo \
index a512f2840375fe84479d48112bb606a5890dd6d9..516c90cc6130f66c156f2f669b3ac56ca2fa9ac0 100644 (file)
@@ -45,6 +45,7 @@ mktempdir() {
     *)
         # At least Haiku, Linux and OpenBSD implementations require explicit
         # trailing X'es in the template, so make it the same suffix as above.
+        # XXX - is MSYS2 GNU-based, so that it would be like Linux?
         mktemp -d -t "${mktempdir_prefix}.XXXXXXXX"
         ;;
     esac
@@ -94,6 +95,16 @@ cc_version_nocache() {
             ;;
         esac
         ;;
+    cl)
+        # Visual Studio's compiler doesn't have a "print the compiler
+        # version" option, but we can get version information by
+        # running it with no options, sending its standard error to
+        # the standard output, and throwing out the usage message;
+        # as we have MSYS2, we can just "head" it out.
+        #
+        # XXX - does it exit with an error?
+        "$CC" 2>&1 | head -2
+        ;;
     *)
         "$CC" --version || "$CC" -V || :
         ;;
@@ -134,6 +145,12 @@ cc_id_nocache() {
         return
     fi
 
+    cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^Microsoft (R) C\/C++ Optimizing Compiler Version \([0-9\.]*\) .*$/msvc-\1/'`
+    if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+        echo "$cc_id_guessed"
+        return
+    fi
+
     # OpenBSD default GCC:
     # "gcc (GCC) 4.2.1 20070719"
     # RedHat GCC:
@@ -184,6 +201,10 @@ cc_werr_cflags() {
         # by default, but an additional option makes the style more consistent.
         echo '-errwarn=%all -errtags=yes'
         ;;
+    msvc-*)
+        # XXX - what?
+        echo ''
+        ;;
     esac
 }
 
@@ -208,19 +229,34 @@ os_id() {
         : "${os_id_version:=`uname -v`}"
         echo "${os_id_version}.${os_id_release}"
         ;;
-    Darwin|NetBSD|OpenBSD|SunOS)
+    Darwin|GNU|OpenBSD|SunOS)
         echo "$os_id_release"
         ;;
-    FreeBSD|Linux)
+    FreeBSD|NetBSD|Linux)
         # Meaningful version is usually the substring before the first dash.
+        # Or the first underscore.
         echo "$os_id_release" | sed 's/^\([0-9\.]*\).*$/\1/'
         ;;
     Haiku)
-        # Meaningful version is the substring before the plus sign.
-        # "hrev55181" stands for "R1/beta3".
-        # "hrev54154" stands for "R1/beta2".
+        # The complete version is a substring before the first space, e.g.:
+        # * "hrevNNNNN" for a release without updates, e.g. hrev56578 for
+        #   R1/beta4, also for a clean build of master branch;
+        # * "hrevNNNNN+MM" for a release with updates;
+        # * "hrevNNNNN-MM" for a build of a branch that is ahead of the master
+        #   branch;
+        # * "hrevNNNNN_MMMM_KK" for a CI build of a Gerrit review;
+        # * something else for a build of a working copy with the changes not
+        #   yet committed.
+        # With this system it is not clear which version components would be
+        # meaningful to relate with the build result, so let's return the
+        # complete version and leave any interpretation to the user.
         : "${os_id_version:=`uname -v`}"
-        echo "$os_id_version" | sed 's/^\(hrev.*\)+.*$/\1/'
+        echo "$os_id_version" | sed -E 's/^(hrev[^ ]+).+$/\1/'
+        ;;
+    MSYS*)
+        # uname -s produces "MSYS_NT-{NT version?}-{build?}
+        # uname -r produces MSYS2 version?
+        echo "$os_id_version", MSYS "$os_id_release"
         ;;
     *)
         echo 'UNKNOWN'
@@ -230,7 +266,8 @@ os_id() {
 
 increment() {
     # No arithmetic expansion in Solaris /bin/sh before 11.
-    echo "${1:?} + 1" | bc
+    # shellcheck disable=SC2003
+    expr "${1:?}" + 1
 }
 
 # Display text in magenta.
@@ -254,6 +291,9 @@ print_so_deps() {
     Haiku-*)
         run_after_echo objdump -p "${1:?}"
         ;;
+    MSYS*)
+        run_after_echo dumpbin /dependents "${1:?}"
+        ;;
     *)
         run_after_echo ldd "${1:?}"
         ;;
index f37589fac71877683e364711ee4d13b4f49f6670..b78ceb56f55e07d5bcb57dcd9c710d997a724fd1 100755 (executable)
@@ -50,7 +50,7 @@ build_tcpdump() {
             for SMB in $MATRIX_SMB; do
                 export SMB
                 COUNT=`increment "$COUNT"`
-                echo_magenta "===== SETUP $COUNT: BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CC=$CC CMAKE=$CMAKE CRYPTO=$CRYPTO SMB=$SMB =====" >&2
+                echo_magenta "===== SETUP $COUNT: CC=$CC BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CMAKE=$CMAKE CRYPTO=$CRYPTO SMB=$SMB =====" >&2
                 # Run one build with setup environment variables:
                 # BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
                 run_after_echo ./build.sh