From c28f40953dfa1c8fb615de7ab43a615136ddebd2 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Thu, 8 Feb 2024 17:23:04 +0100 Subject: [PATCH] fix(CDEPS/tor): allow compiling under ArchLinux Closes https://github.com/ooni/probe/issues/2651 --- CDEPS/tor/004.patch | 19 +++++++++ internal/cmd/buildtool/android_test.go | 48 +++++++++++++++++++++++ internal/cmd/buildtool/cdepstor.go | 4 ++ internal/cmd/buildtool/ios_test.go | 36 +++++++++++++++++ internal/cmd/buildtool/linuxcdeps_test.go | 12 ++++++ 5 files changed, 119 insertions(+) create mode 100644 CDEPS/tor/004.patch diff --git a/CDEPS/tor/004.patch b/CDEPS/tor/004.patch new file mode 100644 index 0000000000..8ccf94bd5a --- /dev/null +++ b/CDEPS/tor/004.patch @@ -0,0 +1,19 @@ +diff --git a/configure.ac b/configure.ac +index b218a59ce2..b87adec9fc 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1294,10 +1294,10 @@ tor_cap_pkg_redhat="libcap" + tor_cap_devpkg_debian="libcap-dev" + tor_cap_devpkg_redhat="libcap-devel" + +-AC_CHECK_LIB([cap], [cap_init], [], +- AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.]) +-) +-AC_CHECK_FUNCS(cap_set_proc) ++dnl AC_CHECK_LIB([cap], [cap_init], [], ++dnl AC_MSG_NOTICE([Libcap was not found. Capabilities will not be usable.]) ++dnl ) ++dnl AC_CHECK_FUNCS(cap_set_proc) + + dnl --------------------------------------------------------------------- + dnl Now that we know about our major libraries, we can check for compiler diff --git a/internal/cmd/buildtool/android_test.go b/internal/cmd/buildtool/android_test.go index a053bf3d8f..8b4a921148 100644 --- a/internal/cmd/buildtool/android_test.go +++ b/internal/cmd/buildtool/android_test.go @@ -1765,6 +1765,16 @@ func TestAndroidBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=" + fakeBinPath + "/armv7a-linux-androideabi21-clang", @@ -1794,6 +1804,8 @@ func TestAndroidBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, @@ -1842,6 +1854,16 @@ func TestAndroidBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=" + fakeBinPath + "/aarch64-linux-android21-clang", @@ -1871,6 +1893,8 @@ func TestAndroidBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, @@ -1919,6 +1943,16 @@ func TestAndroidBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=" + fakeBinPath + "/i686-linux-android21-clang", @@ -1948,6 +1982,8 @@ func TestAndroidBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, @@ -1996,6 +2032,16 @@ func TestAndroidBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=" + fakeBinPath + "/x86_64-linux-android21-clang", @@ -2025,6 +2071,8 @@ func TestAndroidBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, diff --git a/internal/cmd/buildtool/cdepstor.go b/internal/cmd/buildtool/cdepstor.go index 6a181fb6dd..c03f9e5695 100644 --- a/internal/cmd/buildtool/cdepstor.go +++ b/internal/cmd/buildtool/cdepstor.go @@ -40,6 +40,8 @@ func cdepsTorBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependencies) { must.Run(log.Log, "git", "apply", patch) } + must.Run(log.Log, "autoreconf", "-vif") + envp := cBuildExportAutotools(globalEnv) argv := runtimex.Try1(shellx.NewArgv("./configure")) @@ -57,6 +59,8 @@ func cdepsTorBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependencies) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", ) runtimex.Try0(shellx.RunEx(defaultShellxConfig(), argv, envp)) diff --git a/internal/cmd/buildtool/ios_test.go b/internal/cmd/buildtool/ios_test.go index 1377704d09..609983ad06 100644 --- a/internal/cmd/buildtool/ios_test.go +++ b/internal/cmd/buildtool/ios_test.go @@ -1169,6 +1169,16 @@ func TestIOSBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=/Developer/SDKs/iphoneos/bin/as", @@ -1199,6 +1209,8 @@ func TestIOSBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, @@ -1247,6 +1259,16 @@ func TestIOSBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=/Developer/SDKs/iphonesimulator/bin/as", @@ -1277,6 +1299,8 @@ func TestIOSBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, @@ -1325,6 +1349,16 @@ func TestIOSBuildCdepsTor(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "AS=/Developer/SDKs/iphonesimulator/bin/as", @@ -1355,6 +1389,8 @@ func TestIOSBuildCdepsTor(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{}, diff --git a/internal/cmd/buildtool/linuxcdeps_test.go b/internal/cmd/buildtool/linuxcdeps_test.go index e46f5fcd5a..785c93d713 100644 --- a/internal/cmd/buildtool/linuxcdeps_test.go +++ b/internal/cmd/buildtool/linuxcdeps_test.go @@ -349,6 +349,16 @@ func TestLinuxCdepsBuildMain(t *testing.T) { Argv: []string{ "git", "apply", faketopdir + "/CDEPS/tor/003.patch", }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/004.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "autoreconf", "-vif", + }, }, { Env: []string{ "CFLAGS=-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -fPIC -fsanitize=bounds -fsanitize-undefined-trap-on-error -O2", @@ -370,6 +380,8 @@ func TestLinuxCdepsBuildMain(t *testing.T) { "--disable-systemd", "--prefix=/", "--disable-unittests", + "--disable-system-torrc", + "--disable-seccomp", }, }, { Env: []string{},