0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-12 00:10:52 +00:00
termux-packages/packages/pypy/0005-fix-unavailable-functions.patch
2024-08-30 23:44:45 +08:00

196 lines
6.2 KiB
Diff

--- a/lib_pypy/_pwdgrp_build.py
+++ b/lib_pypy/_pwdgrp_build.py
@@ -35,9 +35,9 @@
struct passwd *getpwuid(uid_t uid);
struct passwd *getpwnam(const char *name);
-struct passwd *getpwent(void);
-void setpwent(void);
-void endpwent(void);
+// struct passwd *getpwent(void);
+// void setpwent(void);
+// void endpwent(void);
struct group *getgrgid(gid_t gid);
struct group *getgrnam(const char *name);
--- a/lib-python/2.7/smtpd.py
+++ b/lib-python/2.7/smtpd.py
@@ -9,7 +9,8 @@
-n
This program generally tries to setuid `nobody', unless this flag is
set. The setuid call will fail if this program is not run as root (in
- which case, use this flag).
+ which case, use this flag). Ignored in Termux as no setuid done on this
+ platform.
--version
-V
@@ -461,7 +462,7 @@
class Options:
- setuid = 1
+ setuid = 0
classname = 'PureProxy'
--- a/pypy/module/pwd/interp_pwd.py
+++ b/pypy/module/pwd/interp_pwd.py
@@ -19,18 +19,25 @@
uid_t = config['uid_t']
gid_t = config['gid_t']
-class CConfig:
- _compilation_info_ = eci
+# Android bionic libc has a different define for passwd.
+# On LP32, it defines pw_gecos to pw_passwd since they're both NULL.
+DEFINED__LP64__ = rffi_platform.getdefined('__LP64__', '')
- passwd = rffi_platform.Struct(
- 'struct passwd',
- [('pw_name', rffi.CCHARP),
+fields = [('pw_name', rffi.CCHARP),
('pw_passwd', rffi.CCHARP),
('pw_uid', uid_t),
('pw_gid', gid_t),
('pw_gecos', rffi.CCHARP),
('pw_dir', rffi.CCHARP),
- ('pw_shell', rffi.CCHARP)])
+ ('pw_shell', rffi.CCHARP)]
+
+if not DEFINED__LP64__:
+ fields.pop(4)
+
+class CConfig:
+ _compilation_info_ = eci
+
+ passwd = rffi_platform.Struct('struct passwd', fields)
config = rffi_platform.configure(CConfig)
@@ -42,9 +49,10 @@
c_getpwuid = external("getpwuid", [uid_t], passwd_p)
c_getpwnam = external("getpwnam", [rffi.CCHARP], passwd_p)
-c_setpwent = external("setpwent", [], lltype.Void)
-c_getpwent = external("getpwent", [], passwd_p)
-c_endpwent = external("endpwent", [], lltype.Void)
+# Android bionic libc doesn't have these functions until API 26, but termux compiles on API 23/24.
+# c_setpwent = external("setpwent", [], lltype.Void)
+# c_getpwent = external("getpwent", [], passwd_p)
+# c_endpwent = external("endpwent", [], lltype.Void)
def uid_converter(space, w_uid):
@@ -80,7 +88,7 @@
space.newtext(rffi.charp2str(pw.c_pw_passwd)),
space.int(space.newint(pw.c_pw_uid)),
space.int(space.newint(pw.c_pw_gid)),
- space.newtext(rffi.charp2str(pw.c_pw_gecos)),
+ space.newtext(rffi.charp2str(pw.c_pw_gecos if DEFINED__LP64__ else pw.c_pw_passwd)),
space.newtext(rffi.charp2str(pw.c_pw_dir)),
space.newtext(rffi.charp2str(pw.c_pw_shell)),
])
@@ -120,15 +128,15 @@
raise oefmt(space.w_KeyError, "getpwnam(): name not found: %s", name)
return make_struct_passwd(space, pw)
-def getpwall(space):
- users_w = []
- c_setpwent()
- try:
- while True:
- pw = c_getpwent()
- if not pw:
- break
- users_w.append(make_struct_passwd(space, pw))
- finally:
- c_endpwent()
- return space.newlist(users_w)
+# def getpwall(space):
+# users_w = []
+# c_setpwent()
+# try:
+# while True:
+# pw = c_getpwent()
+# if not pw:
+# break
+# users_w.append(make_struct_passwd(space, pw))
+# finally:
+# c_endpwent()
+# return space.newlist(users_w)
--- a/pypy/module/pwd/moduledef.py
+++ b/pypy/module/pwd/moduledef.py
@@ -15,11 +15,11 @@
interpleveldefs = {
'getpwuid': 'interp_pwd.getpwuid',
'getpwnam': 'interp_pwd.getpwnam',
- 'getpwall': 'interp_pwd.getpwall',
+ # 'getpwall': 'interp_pwd.getpwall',
}
appleveldefs = {
'struct_passwd': 'app_pwd.struct_passwd',
- 'struct_pwent': 'app_pwd.struct_passwd',
+ # 'struct_pwent': 'app_pwd.struct_passwd',
}
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -18,16 +18,16 @@
class VMProfPlatformUnsupported(Exception):
pass
-# vmprof works only on x86 for now
+# vmprof cannot compile on termux due to no dlinfo on Bionic Libc
IS_SUPPORTED = False
-if sys.platform in ('darwin', 'linux', 'linux2') or sys.platform.startswith('freebsd'):
- try:
- proc = detect_cpu.autodetect()
- IS_SUPPORTED = (proc.startswith('x86')
- or proc == 'aarch64'
- or proc == 'riscv64')
- except detect_cpu.ProcessorAutodetectError:
- print("PROCESSOR NOT DETECTED, SKIPPING VMPROF")
+# if sys.platform in ('darwin', 'linux', 'linux2') or sys.platform.startswith('freebsd'):
+# try:
+# proc = detect_cpu.autodetect()
+# IS_SUPPORTED = (proc.startswith('x86')
+# or proc == 'aarch64'
+# or proc == 'riscv64')
+# except detect_cpu.ProcessorAutodetectError:
+# print("PROCESSOR NOT DETECTED, SKIPPING VMPROF")
ROOT = py.path.local(rpythonroot).join('rpython', 'rlib', 'rvmprof')
SRC = ROOT.join('src')
--- a/pypy/module/posix/moduledef.py
+++ b/pypy/module/posix/moduledef.py
@@ -134,12 +134,12 @@
interpleveldefs['pathconf_names'] = 'space.wrap(os.pathconf_names)'
if hasattr(os, 'pathconf'):
interpleveldefs['pathconf'] = 'interp_posix.pathconf'
- if hasattr(os, 'confstr'):
+ if False:
interpleveldefs['confstr'] = 'interp_posix.confstr'
interpleveldefs['confstr_names'] = 'space.wrap(os.confstr_names)'
if hasattr(os, 'ttyname'):
interpleveldefs['ttyname'] = 'interp_posix.ttyname'
- if hasattr(os, 'getloadavg'):
+ if False:
interpleveldefs['getloadavg'] = 'interp_posix.getloadavg'
if hasattr(os, 'makedev'):
interpleveldefs['makedev'] = 'interp_posix.makedev'
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -3086,7 +3086,7 @@
# ____________________________________________________________
# Support for *xattr functions
-if sys.platform.startswith('linux'):
+if False:
class CConfig:
_compilation_info_ = ExternalCompilationInfo(