Not all C libraries implement the new resolver APIs e.g. musl, therefore
keep the old interfaces around and choose using __RES version macro
which is meant for this kind of work.

Signed-off-by: Khem Raj <[email protected]>
Cc: Alexander Kanavin <[email protected]>
---
 ...vrec-Keep-support-for-older-resolver.patch | 44 +++++++++++++++++++
 meta/recipes-devtools/apt/apt_2.2.2.bb        |  3 +-
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 
meta/recipes-devtools/apt/apt/0001-srvrec-Keep-support-for-older-resolver.patch

diff --git 
a/meta/recipes-devtools/apt/apt/0001-srvrec-Keep-support-for-older-resolver.patch
 
b/meta/recipes-devtools/apt/apt/0001-srvrec-Keep-support-for-older-resolver.patch
new file mode 100644
index 0000000000..94d67a87ac
--- /dev/null
+++ 
b/meta/recipes-devtools/apt/apt/0001-srvrec-Keep-support-for-older-resolver.patch
@@ -0,0 +1,44 @@
+From f98c12b9f04ef3a9daec822c210044095b41a0ac Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 20 Mar 2021 12:33:34 -0700
+Subject: [PATCH] srvrec: Keep support for older resolver
+
+Some C libraries e.g. musl do not implement the new res_n* APIs
+therefore keep the old implementation as fallback and check __RES
+version macro to determine the API level
+
+Upstream-Status: Submitted [https://github.com/Debian/apt/pull/129]
+Signed-off-by: Khem Raj <[email protected]>
+Cc: Julian Andres Klode <[email protected]>
+---
+ apt-pkg/contrib/srvrec.cc | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc
+index 4ca208273..3eb5f1d4c 100644
+--- a/apt-pkg/contrib/srvrec.cc
++++ b/apt-pkg/contrib/srvrec.cc
+@@ -62,6 +62,7 @@ bool GetSrvRecords(std::string name, std::vector<SrvRec> 
&Result)
+    unsigned char answer[PACKETSZ];
+    int answer_len, compressed_name_len;
+    int answer_count;
++#if __RES >= 19991006
+    struct __res_state res;
+ 
+    if (res_ninit(&res) != 0)
+@@ -71,6 +72,12 @@ bool GetSrvRecords(std::string name, std::vector<SrvRec> 
&Result)
+    std::shared_ptr<void> guard(&res, res_nclose);
+ 
+    answer_len = res_nquery(&res, name.c_str(), C_IN, T_SRV, answer, 
sizeof(answer));
++#else
++   if (res_init() != 0)
++      return _error->Errno("res_init", "Failed to init resolver");
++
++   answer_len = res_query(name.c_str(), C_IN, T_SRV, answer, sizeof(answer));
++#endif //__RES >= 19991006
+    if (answer_len == -1)
+       return false;
+    if (answer_len < (int)sizeof(HEADER))
+-- 
+2.31.0
+
diff --git a/meta/recipes-devtools/apt/apt_2.2.2.bb 
b/meta/recipes-devtools/apt/apt_2.2.2.bb
index b838495da8..7ee661d4c8 100644
--- a/meta/recipes-devtools/apt/apt_2.2.2.bb
+++ b/meta/recipes-devtools/apt/apt_2.2.2.bb
@@ -10,8 +10,9 @@ SRC_URI = "${DEBIAN_MIRROR}/main/a/apt/${BPN}_${PV}.tar.xz \
            file://0001-Disable-documentation-directory-altogether.patch \
            file://0001-Fix-musl-build.patch \
            
file://0001-CMakeLists.txt-avoid-changing-install-paths-based-on.patch \
+           file://0001-srvrec-Keep-support-for-older-resolver.patch \
            "
-     
+
 SRC_URI_append_class-native = " \
            file://0001-Do-not-init-tables-from-dpkg-configuration.patch \
            
file://0001-Revert-always-run-dpkg-configure-a-at-the-end-of-our.patch \
-- 
2.31.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#149714): 
https://lists.openembedded.org/g/openembedded-core/message/149714
Mute This Topic: https://lists.openembedded.org/mt/81488334/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to