From 9670576b04037bc68430179e5ad5451292f0eaf1 Mon Sep 17 00:00:00 2001 From: Neizvestnyj Date: Sun, 1 May 2022 13:22:01 +0300 Subject: [PATCH] Added py3dns recipe (#2590) * Added py3dns recipe * Update py3dns recipe --- pythonforandroid/recipes/py3dns/__init__.py | 13 +++++++++ .../recipes/py3dns/patches/android.patch | 27 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 pythonforandroid/recipes/py3dns/__init__.py create mode 100644 pythonforandroid/recipes/py3dns/patches/android.patch diff --git a/pythonforandroid/recipes/py3dns/__init__.py b/pythonforandroid/recipes/py3dns/__init__.py new file mode 100644 index 0000000000..bccb39fc72 --- /dev/null +++ b/pythonforandroid/recipes/py3dns/__init__.py @@ -0,0 +1,13 @@ +from pythonforandroid.recipe import PythonRecipe + + +class Py3DNSRecipe(PythonRecipe): + site_packages_name = 'DNS' + version = '3.2.1' + url = 'https://launchpad.net/py3dns/trunk/{version}/+download/py3dns-{version}.tar.gz' + depends = ['setuptools'] + patches = ['patches/android.patch'] + call_hostpython_via_targetpython = False + + +recipe = Py3DNSRecipe() diff --git a/pythonforandroid/recipes/py3dns/patches/android.patch b/pythonforandroid/recipes/py3dns/patches/android.patch new file mode 100644 index 0000000000..f9ab78f07f --- /dev/null +++ b/pythonforandroid/recipes/py3dns/patches/android.patch @@ -0,0 +1,27 @@ +diff --git a/DNS/Base.py b/DNS/Base.py +index 34a6da7..a558889 100644 +--- a/DNS/Base.py ++++ b/DNS/Base.py +@@ -15,6 +15,7 @@ import socket, string, types, time, select + import errno + from . import Type,Class,Opcode + import asyncore ++import os + # + # This random generator is used for transaction ids and port selection. This + # is important to prevent spurious results from lost packets, and malicious +@@ -50,8 +51,12 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY, + + def ParseResolvConf(resolv_path="/etc/resolv.conf"): + "parses the /etc/resolv.conf file and sets defaults for name servers" +- with open(resolv_path, 'r') as stream: +- return ParseResolvConfFromIterable(stream) ++ if os.path.exists(resolv_path): ++ with open(resolv_path, 'r') as stream: ++ return ParseResolvConfFromIterable(stream) ++ else: ++ defaults['server'].append('127.0.0.1') ++ return + + def ParseResolvConfFromIterable(lines): + "parses a resolv.conf formatted stream and sets defaults for name servers"