diff --git a/internal/cmd/buildtool/android_test.go b/internal/cmd/buildtool/android_test.go index b5f9ffc762..30169927bf 100644 --- a/internal/cmd/buildtool/android_test.go +++ b/internal/cmd/buildtool/android_test.go @@ -1054,8 +1054,36 @@ func TestAndroidBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "rm", - "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, @@ -1205,8 +1233,36 @@ func TestAndroidBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "rm", - "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/arm64/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, @@ -1356,8 +1412,36 @@ func TestAndroidBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "rm", - "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/386/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, @@ -1507,8 +1591,36 @@ func TestAndroidBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "rm", - "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/android/amd64/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, diff --git a/internal/cmd/buildtool/cdepslibevent.go b/internal/cmd/buildtool/cdepslibevent.go index f6b8504079..f9c6f6128d 100644 --- a/internal/cmd/buildtool/cdepslibevent.go +++ b/internal/cmd/buildtool/cdepslibevent.go @@ -63,7 +63,17 @@ func cdepsLibeventBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependenci must.Run(log.Log, "make", "V=1", "-j", strconv.Itoa(runtime.NumCPU())) must.Run(log.Log, "make", "DESTDIR="+globalEnv.DESTDIR, "install") must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "bin")) - must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig")) + + // We used to delete the whole pkgconfig directory but libevent's build needs OpenSSL's + // pkgconfig, so removing the whole directory means rebuilding libevent requires building + // OpenSSL because its pkgconfig is also removed. We discovered this need when working + // on the https://github.com/ooni/probe-cli/pull/1366 MVP. To keep the build idempotent, + // let's be more gentle and just remove libevent's pkgconfig files instead. + must.Run(log.Log, "rm", "-f", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig", "libevent.pc")) + must.Run(log.Log, "rm", "-f", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig", "libevent_core.pc")) + must.Run(log.Log, "rm", "-f", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig", "libevent_extra.pc")) + must.Run(log.Log, "rm", "-f", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig", "libevent_openssl.pc")) + must.Run(log.Log, "rm", "-f", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig", "libevent_pthreads.pc")) // we just need libevent.a must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "lib", "libevent.la")) diff --git a/internal/cmd/buildtool/linuxcdeps_test.go b/internal/cmd/buildtool/linuxcdeps_test.go index 549bb79ac3..40d4b5817e 100644 --- a/internal/cmd/buildtool/linuxcdeps_test.go +++ b/internal/cmd/buildtool/linuxcdeps_test.go @@ -221,8 +221,36 @@ func TestLinuxCdepsBuildMain(t *testing.T) { Env: []string{}, Argv: []string{ "rm", - "-rf", - faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig", + "-f", + faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/" + sysDepDestDir + "/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{},