libdnf: allow reproducible binary builds
PATCH 1/1 libdnf: allow reproducible binary builds
Use a static TESTDATADIR if tests are disabled. Allow override of TESTDATADIR if tests are enabled since the default will be wrong for target builds.
--- .../libdnf/libdnf/enable_test_data_dir_set.patch | 26 ++++++++++++++++++++++ meta/recipes-devtools/libdnf/libdnf_0.48.0.bb | 1 + 2 files changed, 27 insertions(+) create mode 100644 meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch new file +26 -0
@@ -0,0 +1,26 @@ +libdnf: allow reproducible binary builds + +Use a dummy directory for test data if not built WITH_TESTS. Allow for overriding +TESTDATADIR, since the default is guaranteed to be wrong for target builds. + +Upstream-Status: Pending + +Signed-off-by: Joe Slater <[email protected]> + + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -133,7 +133,12 @@ add_definitions(-DG_LOG_DOMAIN=\\"libdnf + add_definitions(-D_FILE_OFFSET_BITS=64) + + # tests +-add_definitions(-DTESTDATADIR=\\"${CMAKE_SOURCE_DIR}/data/tests\\") ++if(NOT WITH_TESTS) ++ set(TEST_DATA_DIR "/notests") ++elseif(NOT DEFINED TEST_DATA_DIR) ++ set(TEST_DATA_DIR "${CMAKE_SOURCE_DIR}/data/tests") ++endif() ++add_definitions(-DTESTDATADIR=\\"${TEST_DATA_DIR}\\") + + # librhsm + if(ENABLE_RHSM_SUPPORT)
meta/recipes-devtools/libdnf/libdnf_0.48.0.bb +1 -0
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/rpm-software-management/libdnf;branch=dnf-4-master \ file://0001-Get-parameters-for-both-libsolv-and-libsolvext-libdn.patch \ file://0001-Add-WITH_TESTS-option.patch \ file://0001-Look-fo-sphinx-only-if-documentation-is-actually-ena.patch \ + file://enable_test_data_dir_set.patch \ " SRCREV = "46a28d0cf09277fffc11392e5e362a2eda0d53a8"
Signature · 1 line
2.7.4
Quoted 30 lines · Joe Slater
Use a static TESTDATADIR if tests are disabled. Allow override of TESTDATADIR if tests are enabled since the default will be wrong for target builds.
Signed-off-by Joe Slater <[email protected]>--- .../libdnf/libdnf/enable_test_data_dir_set.patch | 26 ++++++++++++++++++++++ meta/recipes-devtools/libdnf/libdnf_0.48.0.bb | 1 + 2 files changed, 27 insertions(+) create mode 100644 meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patchmeta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch new file +13
-0@@ -0,0 +1,26 @@ +libdnf: allow reproducible binary builds + +Use a dummy directory for test data if not built WITH_TESTS. Allow for overriding +TESTDATADIR, since the default is guaranteed to be wrong for target builds. + +Upstream-Status: Pending + +Signed-off-by: Joe Slater <[email protected]> + + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -133,7 +133,12 @@ add_definitions(-DG_LOG_DOMAIN=\\"libdnf
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch line 23
Quoted 10 lines
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch new file +10
-0+ add_definitions(-D_FILE_OFFSET_BITS=64) + + # tests +-add_definitions(-DTESTDATADIR=\\"${CMAKE_SOURCE_DIR}/data/tests\\") ++if(NOT WITH_TESTS) ++ set(TEST_DATA_DIR "/notests") ++elseif(NOT DEFINED TEST_DATA_DIR) ++ set(TEST_DATA_DIR "${CMAKE_SOURCE_DIR}/data/tests") ++endif() ++add_definitions(-DTESTDATADIR=\\"${TEST_DATA_DIR}\\")
Do we need to set a value in the build or do we never enable the tests?
Cheers,
Richard
We never enable the tests, however the "directory" is processed, perhaps by code that is never executed, but the code is built into the library. Since it is already dealing with a directory that will not exist on the target, I felt it safer just to feed it a "safe" name and let upstream deal with not building the code in the first place.
Joe
-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: Wednesday, July 22, 2020 3:01 PM
To: Slater, Joseph <[email protected]>; [email protected]
Cc: MacLeod, Randy <[email protected]>
Subject: Re: [oe-core][PATCH 1/1] libdnf: allow reproducible binary builds
Quoted 34 lines · Joe Slater
Use a static TESTDATADIR if tests are disabled. Allow override of TESTDATADIR if tests are enabled since the default will be wrong for target builds.
Signed-off-by Joe Slater <[email protected]>--- .../libdnf/libdnf/enable_test_data_dir_set.patch | 26 ++++++++++++++++++++++ meta/recipes-devtools/libdnf/libdnf_0.48.0.bb | 1 + 2 files changed, 27 insertions(+) create mode 100644
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patch(quoted diff) +0
-0
a/meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patchb/meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.patchnew file mode 100644
index 0000000..e3784ccmeta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.pat new file +14
-0+++ ch@@ -0,0 +1,26 @@ +libdnf: allow reproducible binary builds + +Use a dummy directory for test data if not built WITH_TESTS. Allow +for overriding TESTDATADIR, since the default is guaranteed to be wrong for target builds. + +Upstream-Status: Pending + +Signed-off-by: Joe Slater <[email protected]> + + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -133,7 +133,12 @@ add_definitions(-DG_LOG_DOMAIN=\\"libdnf
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.pat line 23
Quoted 10 lines
meta/recipes-devtools/libdnf/libdnf/enable_test_data_dir_set.pat new file +10
-0+ add_definitions(-D_FILE_OFFSET_BITS=64) + + # tests +-add_definitions(-DTESTDATADIR=\\"${CMAKE_SOURCE_DIR}/data/tests\\") ++if(NOT WITH_TESTS) ++ set(TEST_DATA_DIR "/notests") ++elseif(NOT DEFINED TEST_DATA_DIR) ++ set(TEST_DATA_DIR "${CMAKE_SOURCE_DIR}/data/tests") ++endif() ++add_definitions(-DTESTDATADIR=\\"${TEST_DATA_DIR}\\")
Do we need to set a value in the build or do we never enable the tests?
Cheers,
Richard