--- /dev/null
+#!/bin/sh
+
+set -eux
+
+flags=$(./.ci/conf.sh "$@")
+
+# shellcheck disable=SC2086
+meson setup build $flags
+
+ninja -C build
#!/bin/sh
-set -eu
+set -eux
add_flag() {
printf ' %s ' "$@"
}
conf_linux() {
- . /etc/os-release
-
- if type rpm >&2; then
- # CentOS 7 has OpenSSL 1.1 installed in a non-default location.
- if [ -d /usr/include/openssl11 ]; then
- add_flag --with-openssl-include=/usr/include/openssl11
- fi
-
- if [ -d /usr/lib64/openssl11 ]; then
- add_flag --with-openssl-lib=/usr/lib64/openssl11
- fi
-
- # RHEL 8 does not ship miniupnpc.
- if rpm -q miniupnpc-devel >&2; then
- add_flag --enable-miniupnpc
- fi
+ HOST="${HOST:-nonexistent}"
+ if [ "$HOST" = mingw ]; then
+ cross=".ci/cross/windows/amd64"
else
- # vde2 is available everywhere except the RHEL family.
- add_flag --enable-vde
+ cross=".ci/cross/linux/$HOST"
fi
-
- # Cross-compilation.
- if [ -n "${HOST:-}" ]; then
- case "$HOST" in
- armhf) triplet=arm-linux-gnueabihf ;;
- mipsel) triplet=mipsel-linux-gnu ;;
- *) exit 1 ;;
- esac
-
- add_flag --host="$triplet"
+ if [ -f "$cross" ]; then
+ add_flag --cross-file "$cross"
fi
-
- add_flag --enable-uml "$@"
+ add_flag -Dminiupnpc=auto -Duml=true
}
conf_windows() {
- add_flag \
- --enable-miniupnpc \
- --disable-readline \
- --with-curses-include=/mingw64/include/ncurses \
- "$@"
+ add_flag -Dminiupnpc=auto
}
conf_macos() {
- add_flag \
- --with-openssl="$(brew --prefix openssl)" \
- --with-miniupnpc="$(brew --prefix miniupnpc)" \
- --enable-tunemu \
- --enable-miniupnpc \
- "$@"
+ openssl=$(brew --prefix openssl)
+ add_flag -Dminiupnpc=auto -Dpkg_config_path="$openssl/lib/pkgconfig"
}
+add_flag -Dbuildtype=release "$@"
+
case "$(uname -s)" in
-Linux) conf_linux "$@" ;;
-MINGW*) conf_windows "$@" ;;
-Darwin) conf_macos "$@" ;;
+Linux) conf_linux ;;
+MINGW*) conf_windows ;;
+Darwin) conf_macos ;;
*) exit 1 ;;
esac
--- /dev/null
+[binaries]
+c = 'arm-linux-gnueabihf-gcc'
+pkgconfig = 'arm-linux-gnueabihf-pkg-config'
+
--- /dev/null
+[binaries]
+c = 'mipsel-linux-gnu-gcc'
+pkgconfig = 'mipsel-linux-gnu-pkg-config'
+
--- /dev/null
+[properties]
+root = '/usr/x86_64-w64-mingw32'
+
+[binaries]
+c = 'x86_64-w64-mingw32-gcc'
+ar = 'x86_64-w64-mingw32-ar'
+as = 'x86_64-w64-mingw32-as'
+strip = 'x86_64-w64-mingw32-strip'
+windres = 'x86_64-w64-mingw32-windres'
+pkgconfig = 'x86_64-w64-mingw32-pkg-config'
+
+[host_machine]
+system = 'windows'
+endian = 'little'
+cpu = 'x86_64'
+cpu_family = 'x86_64'
+
apk upgrade
apk add \
- git binutils make autoconf automake gcc linux-headers diffutils \
- procps socat shadow sudo libgcrypt-dev texinfo texlive gzip \
+ git binutils meson pkgconf gcc linux-headers diffutils \
+ procps socat shadow sudo libgcrypt-dev texinfo gzip \
openssl-dev zlib-dev lzo-dev ncurses-dev readline-dev musl-dev lz4-dev vde2-dev
}
-deps_linux_debian() {
- export DEBIAN_FRONTEND=noninteractive
-
- HOST=${HOST:-}
+deps_linux_debian_mingw() {
+ apt-get install -y \
+ mingw-w64 mingw-w64-tools \
+ wine wine-binfmt \
+ libgcrypt-mingw-w64-dev \
+ "$@"
+}
+deps_linux_debian_linux() {
if [ -n "$HOST" ]; then
dpkg --add-architecture "$HOST"
fi
apt-get update
- apt-get upgrade -y
apt-get install -y \
- git binutils make autoconf automake gcc diffutils sudo texinfo texlive netcat-openbsd procps socat \
+ binutils make gcc \
zlib1g-dev:"$HOST" \
libssl-dev:"$HOST" \
liblzo2-dev:"$HOST" \
if [ -n "$HOST" ]; then
apt-get install -y crossbuild-essential-"$HOST" qemu-user
+ else
+ linux_openssl3
+ fi
+}
+
+deps_linux_debian() {
+ export DEBIAN_FRONTEND=noninteractive
+
+ apt-get update
+ apt-get upgrade -y
+ apt-get install -y git pkgconf diffutils sudo texinfo \
+ netcat-openbsd procps socat
+
+ HOST=${HOST:-}
+ if [ "$HOST" = mingw ]; then
+ deps_linux_debian_mingw "$@"
+ else
+ deps_linux_debian_linux "$@"
+ fi
+
+ . /etc/os-release
+
+ # Debian Buster ships an old version of meson (0.49).
+ # MinGW cross-compilation requires something newer than 0.55 that ships in Bullseye,
+ # or it fails when looking for dependencies in the OpenSSL wrap.
+ if [ "${ID:-}/${VERSION_CODENAME:-}" = debian/buster ] || [ "$HOST" = mingw ]; then
+ apt-get install -y python3 python3-pip ninja-build
+ pip3 install meson
+ else
+ apt-get install -y meson
fi
}
yum upgrade -y
yum install -y \
- git binutils make autoconf automake gcc diffutils sudo texinfo-tex netcat procps systemd perl-IPC-Cmd \
+ git binutils make meson pkgconf gcc diffutils sudo texinfo-tex netcat procps systemd perl-IPC-Cmd \
findutils socat lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@"
if yum info openssl11-devel; then
}
linux_openssl3() {
- if [ -n "${HOST:-}" ]; then
- echo >&2 "Not installing OpenSSL 3 to a cross-compilation job"
- return
- fi
-
src=/usr/local/src/openssl
ssl3=/opt/ssl3
make -j"$(nproc)"
make install_sw
- ldconfig -v $ssl3/lib64
+ if [ -f /etc/ld.so.conf ]; then
+ echo $ssl3/lib64 >>/etc/ld.so.conf
+ ldconfig -v
+ else
+ ldconfig -v $ssl3/lib64
+ fi
cd -
}
debian | ubuntu)
deps_linux_debian "$@"
- linux_openssl3
;;
centos | almalinux | fedora)
}
deps_macos() {
- brew install coreutils netcat automake lzo lz4 miniupnpc libgcrypt openssl "$@"
+ brew install coreutils netcat lzo lz4 miniupnpc libgcrypt openssl meson "$@"
pip3 install --user compiledb
}
#!/bin/bash
-set -euo pipefail
+set -euxo pipefail
. /etc/os-release
apt-get install -y devscripts git-buildpackage dh-make
export USER=${USER:-$(whoami)}
+export EMAIL=ci@tinc-vpn.org
-os="$ID-$VERSION_ID"
+os="$ID-${VERSION_ID:-unknown}"
templates=$(dirname "$0")/debian
git clean -dfx
# remove useless READMEs created by dh_make
rm -f debian/README.*
-dpkg-buildpackage -d -us -uc
+dpkg-buildpackage -rfakeroot -us -uc -b
mv ../*.deb .
+++ /dev/null
-doc/tinc.info
#!/usr/bin/make -f
%:
- dh $@
-
-override_dh_auto_configure:
- dh_auto_configure -- --enable-uml --enable-miniupnpc \
- --with-systemd=/lib/systemd/system/
- $(MAKE) clean
-
-override_dh_auto_install:
- dh_auto_install -- install-html
- # Remove info dir file
- rm -f debian/tinc/usr/share/info/dir
+ dh $@ --buildsystem=meson
override_dh_auto_test:
- # Don't run the tests, it involves starting tinc daemons and making network connections.
- # I don't think the autobuilders will like this.
-
-override_dh_installinit:
- dh_installinit -r
+ # Disable tests.
#!/bin/bash
-set -euo pipefail
+set -euxo pipefail
+
+if ! rpm -qi openssl-devel; then
+ exit 0
+fi
find_tag() {
git describe --always --tags --match='release-*' "$@"
}
-# CentOS 7 has OpenSSL 1.1 installed in a non-default location.
-if [ -d /usr/include/openssl11 ]; then
- set -- "$@" --with-openssl-include=/usr/include/openssl11
-fi
-
-if [ -d /usr/lib64/openssl11 ]; then
- set -- "$@" --with-openssl-lib=/usr/lib64/openssl11
-fi
-
spec=$HOME/rpmbuild/SPECS/tinc.spec
-configure=$(sh .ci/conf.sh)
-
version=$(find_tag HEAD | sed 's/-/_/g')
version=${version//release_/}
cp "$(dirname "$0")/tinc.spec" "$spec"
sed -i "s/__VERSION__/$version/" "$spec"
-sed -i "s#__CONFIGURE_ARGS__#$configure#" "$spec"
git clean -dfx
-autoreconf -fsi
cp -a . ~/rpmbuild/BUILD
rpmbuild -bb "$spec"
License: GPLv2+
URL: https://www.tinc-vpn.org/
+BuildRequires: gcc
+BuildRequires: meson
BuildRequires: systemd
+BuildRequires: openssl-devel
+BuildRequires: lzo-devel
+BuildRequires: zlib-devel
+BuildRequires: lz4-devel
+BuildRequires: ncurses-devel
+BuildRequires: readline-devel
Requires(post): systemd
Requires(preun): systemd
information to others.
%define debug_package %{nil}
+%define __meson_auto_features auto
%prep
%build
-%configure --with-systemd=%{_unitdir} __CONFIGURE_ARGS__
-%make_build
+%meson
+%meson_build
%install
-%make_install
-rm -f %{buildroot}%{_infodir}/dir
+%meson_install
%post
%systemd_post %{name}@.service
%systemd_postun_with_restart %{name}@.service
%files
-%doc AUTHORS COPYING.README NEWS README.md THANKS doc/sample* doc/*.tex
+%doc AUTHORS COPYING.README NEWS README.md THANKS doc/sample*
%license COPYING
%{_mandir}/man*/%{name}*.*
%{_infodir}/%{name}.info.*
#!/bin/bash
-set -euo pipefail
+set -euxo pipefail
curl -o wintap.exe -L 'https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe'
Section "Tinc"
SetOutPath $INSTDIR
- File ..\..\..\src\tinc.exe
- File ..\..\..\src\tincd.exe
+ File ..\..\..\build\src\tinc.exe
+ File ..\..\..\build\src\tincd.exe
File ..\..\..\wintap.exe
CreateDirectory "$SMPROGRAMS\Tinc"
-# plain make
-src:ed25519/*
-src:chacha-poly1305/*
-src:xoshiro.c
+# meson
+src:../src/ed25519/*
+src:../src/chacha-poly1305/*
+src:../src/xoshiro.c
-# make distcheck
-src:../../../src/ed25519/*
-src:../../../src/chacha-poly1305/*
-src:../../../src/xoshiro.c
#!/bin/sh
-set -eu
+set -eux
if [ "$(id -u)" != 0 ] && sudo --preserve-env --non-interactive true; then
echo >&2 "sudo already configured"
echo 'build ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/build
chmod 440 /etc/sudoers.d/build
visudo --check
+
+if [ -n "${HOST:-}" ]; then
+ update-binfmts --enable
+ rm -f /dev/net/tun
+fi
#!/bin/sh
-set -eu
+set -eux
bail() {
echo >&2 "@"
header "Running test flavor $flavor"
- autoreconf -fsi
+ ./.ci/build.sh "$@"
- DISTCHECK_CONFIGURE_FLAGS=$(sh .ci/conf.sh "$@")
- export DISTCHECK_CONFIGURE_FLAGS
-
- # shellcheck disable=SC2086
- ./configure $DISTCHECK_CONFIGURE_FLAGS
-
- make -j"$(nproc)" all extra
-
- if [ "$(uname -s)" = Linux ]; then
- cmd=distcheck
- else
- cmd=check
+ if [ "${HOST:-}" = mingw ]; then
+ echo >&2 "Integration tests cannot run under wine, skipping"
+ return 0
fi
code=0
- make $cmd -j2 VERBOSE=1 || code=$?
+ meson test -C build --verbose || code=$?
- sudo tar -c -z -f "/tmp/logs/tests.$flavor.tar.gz" test/ sanitizer/
+ sudo tar -c -z -f "/tmp/logs/tests.$flavor.tar.gz" build/ sanitizer/
return $code
}
case "$(uname -s)" in
-Linux)
- if [ -n "${HOST:-}" ]; then
- # Needed for cross-compilation for 32-bit targets.
- export CPPFLAGS="${CPPFLAGS:-} -D_FILE_OFFSET_BITS=64"
- fi
- ;;
-
-MINGW*)
- # No-op.
- sudo() { "$@"; }
- ;;
-
-Darwin)
- nproc() { sysctl -n hw.ncpu; }
- gcrypt=$(brew --prefix libgcrypt)
- openssl=$(brew --prefix openssl)
- export CPPFLAGS="${CPPFLAGS:-} -I/usr/local/include -I$gcrypt/include -I$openssl/include -I$gcrypt/include"
- ;;
+MINGW* | Darwin) sudo() { "$@"; } ;;
esac
-case "$1" in
+flavor=$1
+shift
+
+case "$flavor" in
default)
- run_tests default
+ run_tests default "$@"
;;
nolegacy)
- run_tests nolegacy --disable-legacy-protocol
+ run_tests nolegacy -Dcrypto=nolegacy "$@"
;;
gcrypt)
- run_tests gcrypt --with-libgcrypt
+ run_tests gcrypt -Dcrypto=gcrypt "$@"
;;
openssl3)
if [ -d /opt/ssl3 ]; then
- run_tests openssl3 --with-openssl=/opt/ssl3 --with-openssl-include=/opt/ssl3/include --with-openssl-lib=/opt/ssl3/lib64
+ run_tests openssl3 -Dpkg_config_path=/opt/ssl3/lib64/pkgconfig "$@"
else
echo >&2 "OpenSSL 3 not installed, skipping test"
fi
set -eu
+./.ci/build.sh "$@"
+
# Which paths to ignore.
paths='src/solaris src/mingw src/gcrypt'
path_filters=" $path_filters ! ( -path $path -prune ) "
done
-if ! [ -f compile_commands.json ]; then
- make clean
- compiledb make all extra
-fi
-
echo >&2 "Running clang-tidy without $paths"
# This is fine, our paths are relative and do not contain any whitespace.
find src \
$path_filters \
-name '*.c' \
- -exec clang-tidy --header-filter='.*' '{}' +
+ -exec clang-tidy -p build --header-filter='.*' '{}' +
set -euo pipefail
test -n "$CC"
-export CFLAGS="${CFLAGS:-} -Werror"
result=0
check_warnings() {
git clean -dfx
-
- autoreconf -fsi
- # shellcheck disable=SC2046
- ./configure $(sh .ci/conf.sh)
- make -j"$(nproc)" all extra || result=$?
+ ./.ci/build.sh -Dwerror=true "$@" || result=$?
}
check_warnings
-check_warnings --disable-legacy-protocol
+check_warnings -Dcrypto=nolegacy
exit $result
Checks: '-*,bugprone-narrowing-conversions'
+HeaderFilterRegex: '.*'
WarningsAsErrors: '*'
arch:
- armhf
- mipsel
+ - mingw
container:
image: debian:bullseye
run: HOST=${{ matrix.arch }} sh .ci/deps.sh
- name: Prepare the system
- run: |
- sh .ci/test/prepare.sh
- update-binfmts --enable
- rm -f /dev/net/tun
+ run: HOST=${{ matrix.arch }} sh .ci/test/prepare.sh
- name: Run tests with default settings
run: sudo -u build CI=1 HOST=${{ matrix.arch }} sh .ci/test/run.sh default
- name: Install deps
run: sudo sh .ci/deps.sh
- - name: Configure and compile
- run: |
- autoreconf -fsi
- ./configure $(sh .ci/conf.sh)
-
- name: Run clang-tidy
run: sh .ci/tidy/run.sh
if: always()
- name: Check code formatting
- run: "! astyle -r --options=.astylerc --dry-run --formatted '*.c' '*.h' | grep '^Formatted'"
+ run: "! astyle --exclude=build -r --options=.astylerc --dry-run --formatted '*.c' '*.h' | grep '^Formatted'"
if: always()
- name: Check scripts formatting
- name: Check warnings (gcc)
run: bash .ci/warn/run.sh
env:
- CC: gcc
+ CC: gcc-10
if: always()
- name: Check warnings (clang)
run: bash .ci/warn/run.sh
env:
- CC: clang
+ CC: clang-12
if: always()
sanitizer:
# https://packages.msys2.org/package/
install: >-
base-devel
- autoconf-wrapper
- automake-wrapper
+ mingw-w64-x86_64-meson
+ mingw-w64-x86_64-pkgconf
mingw-w64-x86_64-gcc
mingw-w64-x86_64-openssl
mingw-w64-x86_64-libgcrypt