From ff88803f6d94fc2839e16e3874f22f945aa05a50 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 08:39:42 +0000 Subject: [PATCH 01/27] Use one common file for the version number in both build systems --- CMakeLists.txt | 6 +++++- VERSION | 1 + autogen.sh | 7 +------ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 VERSION diff --git a/CMakeLists.txt b/CMakeLists.txt index 4619524..cba8781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # N2n release information -set(N2N_VERSION "3.1.0") +execute_process( + COMMAND cat VERSION + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE N2N_VERSION +) set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( COMMAND git status diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..fd2a018 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.1.0 diff --git a/autogen.sh b/autogen.sh index 89e9846..81ba943 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,11 +1,6 @@ #!/usr/bin/env bash -# NOTE: update version in CMakeLists.txt after changing these -N2N_MAJOR="3" -N2N_MINOR="1" -N2N_PATCH="0" - -N2N_VERSION_SHORT="$N2N_MAJOR.$N2N_MINOR.$N2N_PATCH" +N2N_VERSION_SHORT=$(cat VERSION) cat configure.seed | sed \ -e "s/@N2N_VERSION_SHORT@/$N2N_VERSION_SHORT/g" \ From 430b0cb77de8ddbe3882e0ab6d409967d69ecd4c Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 09:07:28 +0000 Subject: [PATCH 02/27] Fix CMakeFile version number embedded NL --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cba8781..c105f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ execute_process( WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE N2N_VERSION ) +string(STRIP "${N2N_VERSION}" N2N_VERSION) set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( COMMAND git status From a9216f1097b01e3e28044d80519ae4bcd9cf3337 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 09:10:14 +0000 Subject: [PATCH 03/27] Remove GIT_RELEASE variable and use the semantically identical N2N_VERSION instead --- CMakeLists.txt | 2 +- configure.seed | 5 ----- scripts/hack_fakeautoconf.sh | 1 - src/n2n.c | 2 +- src/sn_utils.c | 2 +- win32/winconfig.h | 4 ---- 6 files changed, 3 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c105f1c..afa7e76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ MESSAGE(STATUS "Build from git rev: ${N2N_VERSION}") endif (GIT_ERROR_CODE EQUAL 0) add_definitions(-DCMAKE_BUILD) -add_definitions(-DGIT_RELEASE="${N2N_VERSION}" -DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${N2N_OSNAME}") add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") diff --git a/configure.seed b/configure.seed index 0226d3d..f4558cc 100644 --- a/configure.seed +++ b/configure.seed @@ -8,9 +8,6 @@ if test -d ".git"; then # NOTE: keep in sync with the definitions for configure.in files under the packages folder GIT_COMMITS=`git rev-list --count HEAD` GIT_REVISION=`git rev-parse --short HEAD` -GIT_RELEASE="${N2N_VERSION_SHORT}.r${GIT_COMMITS}.${GIT_REVISION}" -else -GIT_RELEASE=${N2N_VERSION_SHORT} fi if test "${CC+set}" != set; then @@ -108,7 +105,6 @@ dnl> wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=bl OSNAME=`./config.guess` fi AC_DEFINE_UNQUOTED(PACKAGE_OSNAME, "${OSNAME}", [OS name]) -AC_DEFINE_UNQUOTED(GIT_RELEASE, "${GIT_RELEASE}", [GIT release]) if test $MACHINE = "x86_64"; then EXTN="amd64" @@ -127,7 +123,6 @@ AC_SUBST(LDFLAGS) AC_SUBST(N2N_VERSION_SHORT) AC_SUBST(GIT_COMMITS) AC_SUBST(GIT_REVISION) -AC_SUBST(GIT_RELEASE) AC_SUBST(N2N_DEFINES) AC_SUBST(N2N_LIBS) AC_SUBST(ADDITIONAL_TOOLS) diff --git a/scripts/hack_fakeautoconf.sh b/scripts/hack_fakeautoconf.sh index 8ec8c82..321c9e1 100755 --- a/scripts/hack_fakeautoconf.sh +++ b/scripts/hack_fakeautoconf.sh @@ -20,5 +20,4 @@ sed \ cat <include/config.h #define PACKAGE_VERSION "FIXME" #define PACKAGE_OSNAME "FIXME" -#define GIT_RELEASE "FIXME" EOF diff --git a/src/n2n.c b/src/n2n.c index a3fa959..902b218 100644 --- a/src/n2n.c +++ b/src/n2n.c @@ -590,7 +590,7 @@ void print_n2n_version () { printf("Welcome to n2n v.%s for %s\n" "Built on %s\n" "Copyright 2007-2021 - ntop.org and contributors\n\n", - GIT_RELEASE, PACKAGE_OSNAME, PACKAGE_BUILDDATE); + N2N_VERSION, PACKAGE_OSNAME, PACKAGE_BUILDDATE); } /* *********************************************** */ diff --git a/src/sn_utils.c b/src/sn_utils.c index 40d6746..6148b48 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -741,7 +741,7 @@ int sn_init_defaults (n2n_sn_t *sss) { memset(sss, 0, sizeof(n2n_sn_t)); - strncpy(sss->version, GIT_RELEASE, sizeof(n2n_version_t)); + strncpy(sss->version, N2N_VERSION, sizeof(n2n_version_t)); sss->version[sizeof(n2n_version_t) - 1] = '\0'; sss->daemon = 1; /* By defult run as a daemon. */ sss->lport = N2N_SN_LPORT_DEFAULT; diff --git a/win32/winconfig.h b/win32/winconfig.h index c206f13..8bfcb49 100644 --- a/win32/winconfig.h +++ b/win32/winconfig.h @@ -9,7 +9,3 @@ #ifndef PACKAGE_VERSION #define PACKAGE_VERSION N2N_VERSION #endif -#ifndef GIT_RELEASE -#define GIT_RELEASE N2N_VERSION -#endif - From 4575154e1bf867c0c9691c57e508f777c4cd4226 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 09:39:13 +0000 Subject: [PATCH 04/27] Shrink autogen by reading VERSION file directly in configure.ac --- .gitignore | 1 - autogen.sh | 6 ------ configure.seed => configure.ac | 2 +- scripts/hack_fakeautoconf.sh | 4 +++- 4 files changed, 4 insertions(+), 9 deletions(-) rename configure.seed => configure.ac (98%) diff --git a/.gitignore b/.gitignore index ae2b142..17d6441 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ *.a *.gz configure -configure.ac config.* /Makefile tools/Makefile diff --git a/autogen.sh b/autogen.sh index 81ba943..b717abd 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,11 +1,5 @@ #!/usr/bin/env bash -N2N_VERSION_SHORT=$(cat VERSION) - -cat configure.seed | sed \ - -e "s/@N2N_VERSION_SHORT@/$N2N_VERSION_SHORT/g" \ - > configure.ac - rm -f config.h config.h.in *~ Makefile configure #* echo "Wait please..." diff --git a/configure.seed b/configure.ac similarity index 98% rename from configure.seed rename to configure.ac index f4558cc..f7ca2f5 100644 --- a/configure.seed +++ b/configure.ac @@ -1,5 +1,5 @@ odnl> Do not add anything above -AC_INIT([edge],@N2N_VERSION_SHORT@) +AC_INIT([edge], m4_esyscmd([cat VERSION | tr -d '\n'])) dnl> Do not add anything above N2N_VERSION_SHORT=${PACKAGE_VERSION} diff --git a/scripts/hack_fakeautoconf.sh b/scripts/hack_fakeautoconf.sh index 321c9e1..e6163de 100755 --- a/scripts/hack_fakeautoconf.sh +++ b/scripts/hack_fakeautoconf.sh @@ -3,8 +3,10 @@ # Specifically for windows, where installing autoconf looks suspiciously # like boiling the ocean. +VERSION=$(cat VERSION) + sed \ - -e "s%@N2N_VERSION_SHORT@%FIXME%g" \ + -e "s%@N2N_VERSION_SHORT@%$VERSION%g" \ -e "s%@GIT_COMMITS@%FIXME%g" \ -e "s%@CC@%gcc%g" \ -e "s%@AR@%ar%g" \ From 00a2bdc307df1284ed592abdef396c05d6019c54 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 09:40:37 +0000 Subject: [PATCH 05/27] Remove all use of N2N_VERSION_SHORT in favor of PACKAGE_VERSION --- CMakeLists.txt | 8 ++++---- src/n2n.c | 2 +- src/sn_utils.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afa7e76..3252dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) execute_process( COMMAND cat VERSION WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE N2N_VERSION + OUTPUT_VARIABLE PACKAGE_VERSION ) -string(STRIP "${N2N_VERSION}" N2N_VERSION) +string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( COMMAND git status @@ -37,8 +37,8 @@ MESSAGE(STATUS "Build from git rev: ${N2N_VERSION}") endif (GIT_ERROR_CODE EQUAL 0) add_definitions(-DCMAKE_BUILD) -add_definitions(-DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${N2N_OSNAME}") -add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") # Build information diff --git a/src/n2n.c b/src/n2n.c index 902b218..d48e182 100644 --- a/src/n2n.c +++ b/src/n2n.c @@ -590,7 +590,7 @@ void print_n2n_version () { printf("Welcome to n2n v.%s for %s\n" "Built on %s\n" "Copyright 2007-2021 - ntop.org and contributors\n\n", - N2N_VERSION, PACKAGE_OSNAME, PACKAGE_BUILDDATE); + PACKAGE_VERSION, PACKAGE_OSNAME, PACKAGE_BUILDDATE); } /* *********************************************** */ diff --git a/src/sn_utils.c b/src/sn_utils.c index 6148b48..464eb9e 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -741,7 +741,7 @@ int sn_init_defaults (n2n_sn_t *sss) { memset(sss, 0, sizeof(n2n_sn_t)); - strncpy(sss->version, N2N_VERSION, sizeof(n2n_version_t)); + strncpy(sss->version, PACKAGE_VERSION, sizeof(n2n_version_t)); sss->version[sizeof(n2n_version_t) - 1] = '\0'; sss->daemon = 1; /* By defult run as a daemon. */ sss->lport = N2N_SN_LPORT_DEFAULT; From 0d04b4092659b72f08d8cf55f9880b2e8aa0405a Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:17:08 +0000 Subject: [PATCH 06/27] Make distclean more clean --- Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.in b/Makefile.in index 61d1627..10b81e5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -235,6 +235,9 @@ distclean: rm -rf autom4te.cache/ rm -f config.log config.status configure configure.ac Makefile tools/Makefile include/config.h include/config.h.in rm -f doc/edge.8.gz doc/n2n.7.gz doc/supernode.1.gz + rm -f packages/debian/config.log packages/debian/config.status + rm -rf packages/debian/autom4te.cache/ + rm -f packages/rpm/config.log packages/rpm/config.status rm -f $(addprefix src/,$(APPS)) install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz From d57ac3c6a1e36d37b689a0d3edd02cc0c47bdecf Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:30:38 +0000 Subject: [PATCH 07/27] Clearly separate documented scripts into user and build categories --- doc/Scripts.md | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/doc/Scripts.md b/doc/Scripts.md index f2ac2eb..b946ca1 100644 --- a/doc/Scripts.md +++ b/doc/Scripts.md @@ -5,25 +5,13 @@ Some of these scripts are only useful during build and development, but other scripts are intended for end users to be able to use. These scripts may be installed with n2n as part of your operating system package. -Short descriptions of these scripts are below. - -## `scripts/hack_fakeautoconf.sh` - -This shell script is used during development to help build on Windows -systems. An example of how to use it is shown in -the [Building document](Building.md) - -## `scripts/indent.sh` +All scripts can be found in the `scripts` directory. -This shell script is a wrapper for the `uncrustify` C code style checker -which checks or applies a set of rules to the code. It is used during -the automated lint checks. - -## `scripts/test_harness.sh` +Short descriptions of these scripts are below. -This shell script is used to run automated tests during development. +## End user scripts -## `scripts/n2n-ctl` +### `n2n-ctl` This python script provides an easy command line interface to the running n2n processes. It uses UDP communications to talk to the Management API. @@ -34,7 +22,7 @@ Example: - `scripts/n2n-ctl --help` - `scripts/n2n-ctl help` -## `scripts/n2n-httpd` +### `n2n-httpd` This python script is a simple http gateway to the running edge. It provides a proxy for REST-like HTTP requests to talk to the Management API. @@ -49,7 +37,25 @@ Example: - `scripts/n2n-httpd --help` - `scripts/n2n-httpd 8087` -## `scripts/n2n-gateway.sh` +## Build and Development scripts + +### `hack_fakeautoconf.sh` + +This shell script is used during development to help build on Windows +systems. An example of how to use it is shown in +the [Building document](Building.md) + +### `indent.sh` + +This shell script is a wrapper for the `uncrustify` C code style checker +which checks or applies a set of rules to the code. It is used during +the automated lint checks. + +### `test_harness.sh` + +This shell script is used to run automated tests during development. + +### `n2n-gateway.sh` A sample script to route all the host traffic towards a remote gateway, which is reachable via the n2n virtual interface. From aafca3813aa62ed7c83ec9e824a4515d81c0d39d Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:39:25 +0000 Subject: [PATCH 08/27] Use script to calculate the build version --- CMakeLists.txt | 31 +++++-------------------------- configure.ac | 4 ++-- doc/Scripts.md | 8 ++++++++ scripts/version.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 28 deletions(-) create mode 100755 scripts/version.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 3252dd6..ea6ab36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,39 +6,18 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # N2n release information +set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( - COMMAND cat VERSION + COMMAND scripts/version.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE PACKAGE_VERSION ) string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) -set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) -execute_process( - COMMAND git status - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_OUTPUT - RESULT_VARIABLE GIT_ERROR_CODE -) -if (GIT_ERROR_CODE EQUAL 0) -execute_process( - COMMAND git rev-list --count HEAD - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_REV -) -execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_ID -) -string(REGEX REPLACE "\n$" "" GIT_REV "${GIT_REV}") -string(REGEX REPLACE "\n$" "" GIT_ID "${GIT_ID}") -set(N2N_VERSION "${N2N_VERSION}.r${GIT_REV}.${GIT_ID}") -MESSAGE(STATUS "Build from git rev: ${N2N_VERSION}") -endif (GIT_ERROR_CODE EQUAL 0) +MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") add_definitions(-DCMAKE_BUILD) -add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}") -add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}" -DN2N_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}") # Build information diff --git a/configure.ac b/configure.ac index f7ca2f5..2d267ca 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ odnl> Do not add anything above -AC_INIT([edge], m4_esyscmd([cat VERSION | tr -d '\n'])) +AC_INIT([edge], m4_esyscmd([scripts/version.sh | tr -d '\n'])) dnl> Do not add anything above -N2N_VERSION_SHORT=${PACKAGE_VERSION} +N2N_VERSION_SHORT=$(scripts/version.sh short) if test -d ".git"; then # NOTE: keep in sync with the definitions for configure.in files under the packages folder diff --git a/doc/Scripts.md b/doc/Scripts.md index b946ca1..0f2f2cd 100644 --- a/doc/Scripts.md +++ b/doc/Scripts.md @@ -59,3 +59,11 @@ This shell script is used to run automated tests during development. A sample script to route all the host traffic towards a remote gateway, which is reachable via the n2n virtual interface. + +### `version.sh` + +This script is used to determine the current version number during the +build process. + +It looks at both the VERSION file and the GIT tags and outputs the +version number to use. diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..5713c0a --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Output the current version number +# + +usage() { + echo "Usage: $0 [short]" + echo + echo "Determine the correct version number for the current build" + exit 0 +} + +# TODO: search for the top dir that contains the VERSION file? +VER_FILE_SHORT=$(cat VERSION) + +if git status >/dev/null; then + VER_GIT_SHORT=$(git describe --abbrev=0) + VER_GIT=$(git describe --abbrev=7 --dirty) + + if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then + echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)" + exit 1 + fi + + VER_SHORT="$VER_GIT_SHORT" + VER="$VER_GIT" +else + VER_SHORT="$VER_FILE_SHORT" + VER="$VER_FILE_SHORT" +fi + +case "$1" in + short) + echo "$VER_SHORT" + ;; + "") + echo "$VER" + ;; + *) + usage + ;; +esac From 5b06254a8b60940ca51371e0f6f0dad2688a2d5c Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:42:30 +0000 Subject: [PATCH 09/27] Remove unused makefile variable --- Makefile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 10b81e5..10298ab 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,6 @@ # NOTE: these are needed by the configure.in inside the packages folder N2N_VERSION_SHORT=@N2N_VERSION_SHORT@ GIT_COMMITS=@GIT_COMMITS@ -GIT_DESCRIBE=$(shell git describe --always --dirty) ######## From e538e55ed73e624bab6423dd93486bb0f0631651 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:42:51 +0000 Subject: [PATCH 10/27] The cmake github action is clearly not just for linux --- .github/workflows/{cmake-linux.yml => cmake.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cmake-linux.yml => cmake.yml} (100%) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake.yml similarity index 100% rename from .github/workflows/cmake-linux.yml rename to .github/workflows/cmake.yml From 06cc8ae64b62f4833c2fb7049815c17d3e05f814 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:43:53 +0000 Subject: [PATCH 11/27] Apply tags fix from https://github.com/actions/checkout/issues/290 --- .github/workflows/cmake.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a018a58..c8c8579 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -26,6 +26,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: Create Build Environment # Some projects don't allow in-source building, so create a separate # build directory. We'll use this as our working directory for all From 142f23bd500a1c0f0ee5dd8c5a9b57a4b2f13a08 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 10:48:20 +0000 Subject: [PATCH 12/27] Apply tags fix from https://github.com/actions/checkout/issues/290 to all checkouts --- .github/workflows/tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b8e8e0..7310f67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: Run minimal test set run: | ./autogen.sh @@ -25,6 +29,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: Make the makefiles run: | @@ -52,6 +60,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: Install essential run: | @@ -118,6 +130,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: Install packages run: | @@ -191,6 +207,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + - name: generate a makefile and use it to install more packages run: | From d22f74bf697e0b1016b7cbe8800dc32f4dd00b7f Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 11:11:46 +0000 Subject: [PATCH 13/27] Add a build job to dump details about the repository --- .github/workflows/debug.yml | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..460dd7b --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,53 @@ +--- +name: Debug + +# yamllint disable-line rule:truthy +on: + push: + pull_request: + +jobs: + + # Oh, github, for a company that is built around the git VCS, how is it + # that you have managed to break the repositories so much? + # + debug_github_repo: + name: Debug Github Repo + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Fix Checkout + run: | + git fetch --force --tags + + - name: Debug data output + run: | + echo ========== + echo git status + git status + echo ========== + echo git tag + git tag + echo ========== + echo git describe + git describe || true + echo ========== + echo git for-each-ref refs/heads + git for-each-ref refs/heads + echo ========== + echo git for-each-ref refs/tags + git for-each-ref refs/tags + echo ========== + echo ls .git/refs/heads + ls .git/refs/heads + echo ========== + echo ls .git/refs/tags + ls .git/refs/tags + echo ========== + TYPE=$(git cat-file -t $GITHUB_REF) + echo REF=$GITHUB_REF + echo TAGTYPE=$TYPE + echo ========== + echo git cat-file $TYPE $GITHUB_REF + git cat-file $TYPE $GITHUB_REF From dfc1c85bcedc2643298a3083cb5cf6327182d8dd Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 11:23:42 +0000 Subject: [PATCH 14/27] Get the repo history --- .github/workflows/debug.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 460dd7b..6719428 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -17,6 +17,9 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Fix Checkout run: | git fetch --force --tags From 6c3ccadde16adcfb881c4cbc142e723ff3e04723 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 11:28:13 +0000 Subject: [PATCH 15/27] Try to make debug workflow demand triggerable The docs claim that by adding the right `on:` event, the job can be manually triggered from the github UI. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch Tests show that it doesnt work, but I can leave it here for reference. --- .github/workflows/debug.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 6719428..238e62f 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -1,10 +1,8 @@ --- name: Debug -# yamllint disable-line rule:truthy on: - push: - pull_request: + workflow_dispatch: jobs: From c0cfe937266479cdd9c778f358084727de183829 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 11:39:50 +0000 Subject: [PATCH 16/27] How many commits to fetch? Github says 'meh' The right number of commits to fetch is enough to be able to create a `git describe` result - basically back until the most recent parent annotated tag. However, the github action/checkout@v2 only allows a simple number, which is basically the answer to "how long is a piece of string" --- .github/workflows/cmake.yml | 2 ++ .github/workflows/tests.yml | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c8c8579..4896272 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -25,6 +25,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7310f67..b638a3f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | git fetch --force --tags @@ -29,6 +31,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | git fetch --force --tags @@ -60,6 +64,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | git fetch --force --tags @@ -130,6 +136,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | git fetch --force --tags @@ -207,6 +215,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | git fetch --force --tags @@ -355,6 +365,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | @@ -391,6 +403,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | @@ -438,6 +452,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | @@ -491,6 +507,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | @@ -548,6 +566,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Fix Checkout run: | From 8dc9437870a33ba446941dd3402905cd8b719039 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:02:00 +0000 Subject: [PATCH 17/27] Remove configure.ac from the distclean list --- Makefile.in | 2 +- packages/openwrt/patches/001-fix-cc.patch | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 packages/openwrt/patches/001-fix-cc.patch diff --git a/Makefile.in b/Makefile.in index 10298ab..7abe64d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -232,7 +232,7 @@ clean: distclean: rm -f tests/*.out src/*.gcno src/*.gcda src/*.indent src/*.unc-backup* rm -rf autom4te.cache/ - rm -f config.log config.status configure configure.ac Makefile tools/Makefile include/config.h include/config.h.in + rm -f config.log config.status configure Makefile tools/Makefile include/config.h include/config.h.in rm -f doc/edge.8.gz doc/n2n.7.gz doc/supernode.1.gz rm -f packages/debian/config.log packages/debian/config.status rm -rf packages/debian/autom4te.cache/ diff --git a/packages/openwrt/patches/001-fix-cc.patch b/packages/openwrt/patches/001-fix-cc.patch deleted file mode 100644 index c0d1073..0000000 --- a/packages/openwrt/patches/001-fix-cc.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/configure.seed -+++ b/configure.seed -@@ -13,8 +13,6 @@ - GIT_RELEASE=${N2N_VERSION_SHORT} - fi - --CC=gcc --AR=ar - N2N_LIBS= - - AC_PROG_CC From 72a53325c59a8d90ce7728e392141e043d6d510a Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:02:19 +0000 Subject: [PATCH 18/27] The docker build steps are bitrotted since 2019 The `DOCKER_IMAGE_VERSION=` line was modified in commit 4d36f9f6135a1 in 2019 and has been wrong ever since. It is using the shell variable syntax, which does not work in Makefiles. Add a warning message for anyone trying to use it. --- Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.in b/Makefile.in index 7abe64d..ac3e3fb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -257,6 +257,7 @@ N2N_COMMIT_HASH=@GIT_REVISION@ default: steps steps: + $(info This code appears to have been bitrotted since 2019 - please let us know if you are using it) if [ "$(TARGET_ARCHITECTURE)" = "arm32v7" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.arm32v7" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-arm32v7 make build; fi if [ "$(TARGET_ARCHITECTURE)" = "x86_64" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.x86_64" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-x86_64 make build; fi From f7d6be51cf9e01eb21061e26a078dd5ad921e7ce Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:06:08 +0000 Subject: [PATCH 19/27] Remove the correct files during autogen --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index b717abd..0ff6b12 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -rm -f config.h config.h.in *~ Makefile configure #* +rm -f include/config.h include/config.h.in include/config.h.in~ Makefile configure echo "Wait please..." autoreconf -if From a0cdda6fa9be17963a1fb2be436b23213a635891 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:08:05 +0000 Subject: [PATCH 20/27] Add more features to the version script --- scripts/version.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/version.sh b/scripts/version.sh index 5713c0a..efd1929 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -4,18 +4,17 @@ # usage() { - echo "Usage: $0 [short]" + echo "Usage: $0 [short|hash]" echo echo "Determine the correct version number for the current build" exit 0 } -# TODO: search for the top dir that contains the VERSION file? -VER_FILE_SHORT=$(cat VERSION) +VER_FILE_DIR=$(dirname "$0")/.. +VER_FILE_SHORT=$(cat "${VER_FILE_DIR}/VERSION") if git status >/dev/null; then VER_GIT_SHORT=$(git describe --abbrev=0) - VER_GIT=$(git describe --abbrev=7 --dirty) if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)" @@ -23,13 +22,18 @@ if git status >/dev/null; then fi VER_SHORT="$VER_GIT_SHORT" - VER="$VER_GIT" + VER_HASH=$(git rev-parse --short HEAD) + VER=$(git describe --abbrev=7 --dirty) else VER_SHORT="$VER_FILE_SHORT" + VER_HASH="HEAD" VER="$VER_FILE_SHORT" fi case "$1" in + hash) + echo "$VER_HASH" + ;; short) echo "$VER_SHORT" ;; From 9cbf4ca80a6eb992e546ee7d9a750c759e778ff9 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:10:03 +0000 Subject: [PATCH 21/27] RPM Release variable is the number of patches applied to the upstream source, since we are the upstream source, there are no patches --- packages/rpm/n2n.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rpm/n2n.spec.in b/packages/rpm/n2n.spec.in index 8448ab4..0a7a847 100644 --- a/packages/rpm/n2n.spec.in +++ b/packages/rpm/n2n.spec.in @@ -1,7 +1,7 @@ Summary: n2n peer-to-peer VPN Name: n2n Version: @N2N_VERSION_SHORT@ -Release: @GIT_COMMITS@ +Release: 1 License: GPL Group: Networking/Utilities URL: http://www.ntop.org/ From a4910ddc77e5b917573e105dbba90d946f4d9d98 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:11:03 +0000 Subject: [PATCH 22/27] Debian Standards-Version variable is the packaging standard, nothing to do with our version --- packages/debian/debian/control.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/debian/debian/control.in b/packages/debian/debian/control.in index 9fe4aad..7303119 100644 --- a/packages/debian/debian/control.in +++ b/packages/debian/debian/control.in @@ -2,7 +2,7 @@ Source: n2n Section: net Priority: extra Maintainer: Luca Deri -Standards-Version: @N2N_VERSION_SHORT@ +Standards-Version: 4.6.0 Build-Depends: Package: n2n From ff72ed8190495cbf2f96657375bf4431e32a8139 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 1 Nov 2021 19:13:32 +0000 Subject: [PATCH 23/27] Make all version calculations come from scripts/version.sh and remove resulting redundant substitutions --- Makefile.in | 5 ++--- configure.ac | 12 ++---------- packages/debian/configure | 7 ++----- packages/debian/configure.in | 6 ++---- packages/debian/debian/changelog.in | 2 +- packages/debian/debian/files.in | 2 +- packages/rpm/Makefile.in | 2 +- packages/rpm/configure | 21 +++++++++++++++------ packages/rpm/configure.in | 6 ++---- packages/rpm/n2n.spec.in | 2 +- scripts/hack_fakeautoconf.sh | 4 ---- 11 files changed, 29 insertions(+), 40 deletions(-) diff --git a/Makefile.in b/Makefile.in index ac3e3fb..de86f47 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,6 @@ # NOTE: these are needed by the configure.in inside the packages folder -N2N_VERSION_SHORT=@N2N_VERSION_SHORT@ -GIT_COMMITS=@GIT_COMMITS@ +N2N_VERSION=@N2N_VERSION@ ######## @@ -252,7 +251,7 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz # Docker builder section DOCKER_IMAGE_NAME=ntop/supernode DOCKER_IMAGE_VERSION=$N2N_VERSION_SHORT -N2N_COMMIT_HASH=@GIT_REVISION@ +N2N_COMMIT_HASH=$(shell scripts/version.sh hash) default: steps diff --git a/configure.ac b/configure.ac index 2d267ca..75107ec 100644 --- a/configure.ac +++ b/configure.ac @@ -2,13 +2,7 @@ odnl> Do not add anything above AC_INIT([edge], m4_esyscmd([scripts/version.sh | tr -d '\n'])) dnl> Do not add anything above -N2N_VERSION_SHORT=$(scripts/version.sh short) - -if test -d ".git"; then -# NOTE: keep in sync with the definitions for configure.in files under the packages folder -GIT_COMMITS=`git rev-list --count HEAD` -GIT_REVISION=`git rev-parse --short HEAD` -fi +N2N_VERSION=${PACKAGE_VERSION} if test "${CC+set}" != set; then CC=gcc @@ -120,9 +114,7 @@ AC_SUBST(CC) AC_SUBST(AR) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) -AC_SUBST(N2N_VERSION_SHORT) -AC_SUBST(GIT_COMMITS) -AC_SUBST(GIT_REVISION) +AC_SUBST(N2N_VERSION) AC_SUBST(N2N_DEFINES) AC_SUBST(N2N_LIBS) AC_SUBST(ADDITIONAL_TOOLS) diff --git a/packages/debian/configure b/packages/debian/configure index 7554d8e..b1048d9 100755 --- a/packages/debian/configure +++ b/packages/debian/configure @@ -586,8 +586,7 @@ LIBOBJS EXTRA_DEP DATE EXTN -GIT_COMMITS -N2N_VERSION_SHORT +N2N_VERSION APP target_alias host_alias @@ -1694,8 +1693,7 @@ fi # NOTE: this file is not actually used. You need to edit configure as well! -N2N_VERSION_SHORT=`grep N2N_VERSION_SHORT ../../Makefile | head -1| cut -d "=" -f 2` -GIT_COMMITS=`grep GIT_COMMITS ../../Makefile | head -1| cut -d "=" -f 2` +N2N_VERSION=$(../../scripts/version.sh) DEBIAN_VERSION=`cat /etc/debian_version | grep "^8" | wc -l` @@ -1740,7 +1738,6 @@ DATE=`date -R` - ac_config_files="$ac_config_files debian/changelog" ac_config_files="$ac_config_files debian/files" diff --git a/packages/debian/configure.in b/packages/debian/configure.in index 21ed5af..e01e987 100644 --- a/packages/debian/configure.in +++ b/packages/debian/configure.in @@ -3,8 +3,7 @@ AC_INIT([Makefile.in], 1.0) AC_ARG_WITH(edgex, [ --with-edgex Build for Ubiquity-X]) # NOTE: this file is not actually used. You need to edit configure as well! -N2N_VERSION_SHORT=`grep N2N_VERSION_SHORT ../../Makefile | head -1| cut -d "=" -f 2` -GIT_COMMITS=`grep GIT_COMMITS ../../Makefile | head -1| cut -d "=" -f 2` +N2N_VERSION=$(../../scripts/version.sh) DEBIAN_VERSION=`cat /etc/debian_version | grep "^8" | wc -l` @@ -44,8 +43,7 @@ APP=n2n DATE=`date -R` AC_SUBST(APP) -AC_SUBST(N2N_VERSION_SHORT) -AC_SUBST(GIT_COMMITS) +AC_SUBST(N2N_VERSION) AC_SUBST(EXTN) AC_SUBST(DATE) AC_SUBST(EXTRA_DEP) diff --git a/packages/debian/debian/changelog.in b/packages/debian/debian/changelog.in index 6d4e3dc..5669566 100644 --- a/packages/debian/debian/changelog.in +++ b/packages/debian/debian/changelog.in @@ -1,4 +1,4 @@ -@APP@ (@N2N_VERSION_SHORT@-@GIT_COMMITS@) table; urgency=high +@APP@ (@N2N_VERSION@) table; urgency=high * Last packaged version -- Luca Deri @DATE@ diff --git a/packages/debian/debian/files.in b/packages/debian/debian/files.in index 6128dce..510512c 100644 --- a/packages/debian/debian/files.in +++ b/packages/debian/debian/files.in @@ -1 +1 @@ -n2n_@N2N_VERSION_SHORT@_@EXTN@.deb free optional +n2n_@N2N_VERSION@_@EXTN@.deb free optional diff --git a/packages/rpm/Makefile.in b/packages/rpm/Makefile.in index 68585a5..a37c3d1 100644 --- a/packages/rpm/Makefile.in +++ b/packages/rpm/Makefile.in @@ -4,7 +4,7 @@ N2N_HOME=$(PWD)/../.. N2N_BUILD=${N2N_HOME}/packages/debian/n2n PLATFORM=@MACHINE@ -RPM_PKG=n2n-@N2N_VERSION_SHORT@-@GIT_COMMITS@.$(PLATFORM).rpm +RPM_PKG=n2n-@N2N_VERSION_RPM@-1.$(PLATFORM).rpm all: clean pkg diff --git a/packages/rpm/configure b/packages/rpm/configure index cd797dd..dc8a37d 100755 --- a/packages/rpm/configure +++ b/packages/rpm/configure @@ -586,8 +586,7 @@ LIBOBJS RPM_SIGN_CMD DATE EXTN -GIT_COMMITS -N2N_VERSION_SHORT +N2N_VERSION_RPM MACHINE APP target_alias @@ -609,6 +608,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -673,6 +673,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -925,6 +926,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1062,7 +1072,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1215,6 +1225,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1670,8 +1681,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # NOTE: this file is not actually used. You need to edit configure as well! -N2N_VERSION_SHORT=`grep N2N_VERSION_SHORT ../../Makefile | head -1| cut -d "=" -f 2` -GIT_COMMITS=`grep GIT_COMMITS ../../Makefile | head -1| cut -d "=" -f 2` +N2N_VERSION_RPM=$(../../scripts/version.sh |tr - _) MACHINE=`uname -m` SHORT_MACHINE=`uname -m | cut -b1-3` @@ -1717,7 +1727,6 @@ fi - ac_config_files="$ac_config_files n2n.spec" ac_config_files="$ac_config_files ../etc/systemd/system/edge.service" diff --git a/packages/rpm/configure.in b/packages/rpm/configure.in index cce9205..e65d3c0 100644 --- a/packages/rpm/configure.in +++ b/packages/rpm/configure.in @@ -1,8 +1,7 @@ AC_INIT([Makefile.in], 1.0) # NOTE: this file is not actually used. You need to edit configure as well! -N2N_VERSION_SHORT=`grep N2N_VERSION_SHORT ../../Makefile | head -1| cut -d "=" -f 2` -GIT_COMMITS=`grep GIT_COMMITS ../../Makefile | head -1| cut -d "=" -f 2` +N2N_VERSION_RPM=$(../../scripts/version.sh |tr - _) MACHINE=`uname -m` SHORT_MACHINE=`uname -m | cut -b1-3` @@ -43,8 +42,7 @@ fi AC_SUBST(APP) AC_SUBST(MACHINE) -AC_SUBST(N2N_VERSION_SHORT) -AC_SUBST(GIT_COMMITS) +AC_SUBST(N2N_VERSION_RPM) AC_SUBST(EXTN) AC_SUBST(DATE) AC_SUBST(RPM_SIGN_CMD) diff --git a/packages/rpm/n2n.spec.in b/packages/rpm/n2n.spec.in index 0a7a847..7f4b847 100644 --- a/packages/rpm/n2n.spec.in +++ b/packages/rpm/n2n.spec.in @@ -1,6 +1,6 @@ Summary: n2n peer-to-peer VPN Name: n2n -Version: @N2N_VERSION_SHORT@ +Version: @N2N_VERSION_RPM@ Release: 1 License: GPL Group: Networking/Utilities diff --git a/scripts/hack_fakeautoconf.sh b/scripts/hack_fakeautoconf.sh index e6163de..a7f9203 100755 --- a/scripts/hack_fakeautoconf.sh +++ b/scripts/hack_fakeautoconf.sh @@ -3,11 +3,7 @@ # Specifically for windows, where installing autoconf looks suspiciously # like boiling the ocean. -VERSION=$(cat VERSION) - sed \ - -e "s%@N2N_VERSION_SHORT@%$VERSION%g" \ - -e "s%@GIT_COMMITS@%FIXME%g" \ -e "s%@CC@%gcc%g" \ -e "s%@AR@%ar%g" \ -e "s%@CFLAGS@%$CFLAGS%g" \ From a38ec0f033fe85c1b51ab967c1956f7c993e2ff1 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Tue, 2 Nov 2021 09:13:12 +0000 Subject: [PATCH 24/27] Update windows cmake build docs to match current process --- doc/Building.md | 73 ++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/doc/Building.md b/doc/Building.md index 3b5e2a1..92a5c1c 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -21,30 +21,22 @@ In order to build on Windows the following tools should be installed: - Visual Studio. For a minimal install, the command line only build tools can be downloaded and installed from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017. -- CMake +- CMake (From https://cmake.org/download/) -- (optional) The OpenSSL library. Prebuild binaries can be downloaded from https://slproweb.com/products/Win32OpenSSL.html. - The full version is required, i.e. not the "Light" version. The Win32 version of it is usually required for a standard build. + NOTE: You should always use the official cmake stable release as otherwise + you may have issues finding libraries (e.g: the installed OpenSSL library). + If you still have problems, you can try invoking it with `C:\Program Files\CMake\bin\cmake`. -> NOTE: In order to skip OpenSSL compilation, edit `CMakeLists.txt` and replace **– is this still valid?** -> -> ```plaintext -> OPTION(N2N_OPTION_AES "USE AES" ON) -> with -> OPTION(N2N_OPTION_AES "USE AES" OFF) -> ``` +- (optional) The OpenSSL library. Pre-built binaries can be downloaded from + https://slproweb.com/products/Win32OpenSSL.html. + The full version is required, i.e. not the "Light" version. The Win32 + version of it is usually required for a standard build. - NOTE: To statically link OpenSSL, add the `-DOPENSSL_USE_STATIC_LIBS=true` option to the `cmake` command below. + NOTE: In order to enable OpenSSL compilation, add the option + `-DN2N_OPTION_USE_OPENSSL=ON` to the `cmake ..` command below. -- If compilation throws a "config.h: No such file or directory" error, an `include/config.h` file needs to be obtained from an already configured Linux compilation and put into the `include/` directory as discussed [here](https://github.com/ntop/n2n/issues/366). - -In order to run n2n, you will need the following: - -- The TAP drivers should be installed into the system. They can be installed from - http://build.openvpn.net/downloads/releases, search for "tap-windows". - -- If OpenSSL has been linked dynamically, the corresponding `.dll` file should be available - onto the target computer. + NOTE: To statically link OpenSSL, add the option + `-DOPENSSL_USE_STATIC_LIBS=true` to the `cmake ..` command below. NOTE: Sticking to this tool chain has historically meant that resulting executables are more likely to be able to communicate with Linux or other @@ -52,49 +44,38 @@ OS builds, however efforts are being made to address this concern. ## Build (CLI) -In order to build from the command line, open a terminal window and run the following commands: +In order to build from the command line, open a terminal window change to +the directory where the git checkout of this repository is and run the +following commands: ```batch -md build +cmake -E make_directory build cd build + +rem Append any options to the next line cmake .. -MSBuild.exe edge.vcxproj /t:Build /p:Configuration=Release -MSBuild.exe supernode.vcxproj /t:Build /p:Configuration=Release -MSBuild.exe n2n-benchmark.vcxproj /t:Build /p:Configuration=Release +cmake --build . --config Release ``` -NOTE: If CMake has problems finding the installed OpenSSL library, try to download the official cmake and invoke it with -`C:\Program Files\CMake\bin\cmake`. - -NOTE: Visual Studio might not add `MSBuild.exe`'s path to the environment variable %PATH% so you might have difficulties finding and executing it without giving the full path. Regular installations seem to have it reside at `"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe"` - The compiled `.exe` files should now be available in the `build\Release` directory. ## Run -The `edge.exe` program reads the `edge.conf` file located into the current directory if no option is provided. - -Here is an example `edge.conf` file: +In order to run n2n, you will need the following: -```plaintext --c=mycommunity --k=mysecretpass +- The TAP drivers should be installed into the system. They can be installed from + http://build.openvpn.net/downloads/releases, search for "tap-windows". -# supernode IP address --l=1.2.3.4:5678 +- If OpenSSL has been linked dynamically, the corresponding `.dll` file should be available + onto the target computer. -# edge IP address --a=192.168.100.1 -``` +The `edge.exe` program reads the `edge.conf` file located into the current directory if no option is provided. The `supernode.exe` program reads the `supernode.conf` file located into the current directory if no option is provided. -Here is an example `supernode.conf` file: - -```plaintext --p=5678 -``` +Example [edge.conf](../packages/etc/n2n/edge.conf.sample) +and [supernode.conf](../packages/etc/n2n/supernode.conf.sample) are available. See `edge.exe --help` and `supernode.exe --help` for a full list of supported options. From 108c9436d5b31f255bc5e05181c3c8a3f1975f26 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Tue, 2 Nov 2021 09:28:48 +0000 Subject: [PATCH 25/27] Add robustness to the version calculations --- CMakeLists.txt | 18 +++++++++++++++--- Makefile.in | 9 ++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea6ab36..a1f286d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,22 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # N2n release information set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( - COMMAND scripts/version.sh - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE PACKAGE_VERSION + COMMAND scripts/version.sh + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE PACKAGE_VERSION + RESULT_VARIABLE GIT_ERROR_CODE ) +if (NOT GIT_ERROR_CODE EQUAL 0) + # - if we can run version.sh and it exits with an error that is signaling + # a build failure. + # - if we are on windows with no MSYS or Cygwin, we cannot run version.sh + # which is the fallback case handled below + # TODO: Distinguish between these two cases + + # Fallback to just using the non dynamic short version string + file(STRINGS VERSION PACKAGE_VERSION) +endif (NOT GIT_ERROR_CODE EQUAL 0) + string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") diff --git a/Makefile.in b/Makefile.in index de86f47..ae6e68b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -148,7 +148,14 @@ COVERAGEDIR?=coverage .PHONY: steps build push all clean distclean install test cover gcov build-dep .PHONY: lint lint.python lint.ccode lint.shell lint.yaml -all: $(APPS) $(DOCS) $(SUBDIRS) +all: version $(APPS) $(DOCS) $(SUBDIRS) + +# This allows breaking the build if the version.sh script discovers +# any inconsistancies +.PHONY: version +version: + @echo -n "Build for version: " + @scripts/version.sh tools: $(N2N_LIB) $(MAKE) -C $@ From 8504b7c2685901f55efd34a1692b4873a1030f9d Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Tue, 2 Nov 2021 09:29:01 +0000 Subject: [PATCH 26/27] Minor lint cleanup --- .github/workflows/debug.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 238e62f..4365177 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -1,6 +1,7 @@ --- name: Debug +# yamllint disable-line rule:truthy on: workflow_dispatch: From 109b6e2fa5b17014f612aea2297fe8f982a10d93 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Tue, 2 Nov 2021 09:35:03 +0000 Subject: [PATCH 27/27] Remove one remaining use of N2N_OSNAME and cleanup --- CMakeLists.txt | 3 +-- win32/winconfig.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1f286d..ddec7ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # N2n release information -set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( COMMAND scripts/version.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -28,7 +27,7 @@ string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") add_definitions(-DCMAKE_BUILD) -add_definitions(-DPACKAGE_OSNAME="${N2N_OSNAME}" -DN2N_OSNAME="${N2N_OSNAME}") +add_definitions(-DPACKAGE_OSNAME="${CMAKE_SYSTEM_NAME}") add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}") diff --git a/win32/winconfig.h b/win32/winconfig.h index 8bfcb49..aa9794a 100644 --- a/win32/winconfig.h +++ b/win32/winconfig.h @@ -2,7 +2,7 @@ /* OS name */ #ifndef PACKAGE_OSNAME -#define PACKAGE_OSNAME N2N_OSNAME +#define PACKAGE_OSNAME "windows" #endif /* Define to the version of this package. */