From bc0353857ec527930c1b3da55089189482cd5073 Mon Sep 17 00:00:00 2001 From: Neizvestnyj <40869738+Neizvestnyj@users.noreply.github.com> Date: Sun, 1 May 2022 11:23:34 +0300 Subject: [PATCH 1/2] Added py3dns recipe --- pythonforandroid/recipes/py3dns/__init__.py | 13 ++++++++++++ .../recipes/py3dns/patches/android.patch | 21 +++++++++++++++++++ 2 files changed, 34 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..e28f22e673 --- /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://github.com/Neizvestnyj/py3dns/archive/{version}.zip' + 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..266f234d58 --- /dev/null +++ b/pythonforandroid/recipes/py3dns/patches/android.patch @@ -0,0 +1,21 @@ +diff --git a/DNS/Base.py b/DNS/Base.py +index 34a6da7..15f83a2 100644 +--- a/DNS/Base.py ++++ b/DNS/Base.py +@@ -49,9 +49,13 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY, + 'server': [] } + + 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) ++ try: ++ "parses the /etc/resolv.conf file and sets defaults for name servers" ++ with open(resolv_path, 'r') as stream: ++ return ParseResolvConfFromIterable(stream) ++ except FileNotFoundError: ++ defaults['server'].append('127.0.0.1') ++ return + + def ParseResolvConfFromIterable(lines): + "parses a resolv.conf formatted stream and sets defaults for name servers" From 625ecbd9573cf9f4395f12f34c08314bd3cc017c Mon Sep 17 00:00:00 2001 From: Neizvestnyj <40869738+Neizvestnyj@users.noreply.github.com> Date: Sun, 1 May 2022 11:57:11 +0300 Subject: [PATCH 2/2] Update py3dns recipe --- pythonforandroid/recipes/py3dns/__init__.py | 2 +- .../recipes/py3dns/patches/android.patch | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pythonforandroid/recipes/py3dns/__init__.py b/pythonforandroid/recipes/py3dns/__init__.py index e28f22e673..bccb39fc72 100644 --- a/pythonforandroid/recipes/py3dns/__init__.py +++ b/pythonforandroid/recipes/py3dns/__init__.py @@ -4,7 +4,7 @@ class Py3DNSRecipe(PythonRecipe): site_packages_name = 'DNS' version = '3.2.1' - url = 'https://github.com/Neizvestnyj/py3dns/archive/{version}.zip' + url = 'https://launchpad.net/py3dns/trunk/{version}/+download/py3dns-{version}.tar.gz' depends = ['setuptools'] patches = ['patches/android.patch'] call_hostpython_via_targetpython = False diff --git a/pythonforandroid/recipes/py3dns/patches/android.patch b/pythonforandroid/recipes/py3dns/patches/android.patch index 266f234d58..f9ab78f07f 100644 --- a/pythonforandroid/recipes/py3dns/patches/android.patch +++ b/pythonforandroid/recipes/py3dns/patches/android.patch @@ -1,19 +1,25 @@ diff --git a/DNS/Base.py b/DNS/Base.py -index 34a6da7..15f83a2 100644 +index 34a6da7..a558889 100644 --- a/DNS/Base.py +++ b/DNS/Base.py -@@ -49,9 +49,13 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY, - 'server': [] } +@@ -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" + "parses the /etc/resolv.conf file and sets defaults for name servers" - with open(resolv_path, 'r') as stream: - return ParseResolvConfFromIterable(stream) -+ try: -+ "parses the /etc/resolv.conf file and sets defaults for name servers" ++ if os.path.exists(resolv_path): + with open(resolv_path, 'r') as stream: + return ParseResolvConfFromIterable(stream) -+ except FileNotFoundError: ++ else: + defaults['server'].append('127.0.0.1') + return