From a4ae38494f0c12799b343eb521ca13123c0bb4e3 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 30 May 2023 02:22:30 +0800 Subject: [PATCH 1/6] micropython: Update to 1.20.0, refresh/rework patches Patches 000-Makefile-no-errors.patch and 020-mpy-cross-fix-flags.patch are no longer necessary. This also adds a Build/InstallDev recipe to install files necessary for micropython-lib. Signed-off-by: Jeffery To --- lang/python/micropython/Makefile | 67 ++++++++++++------- .../patches/000-Makefile-no-errors.patch | 11 --- .../patches/020-mpy-cross-fix-flags.patch | 20 ------ .../patches/030-target-no-darwin.patch | 2 +- .../040-extmod-use-external-mbedtls.patch | 13 ++-- .../unix/variants/standard/manifest-nossl.py | 1 + 6 files changed, 51 insertions(+), 63 deletions(-) delete mode 100644 lang/python/micropython/patches/000-Makefile-no-errors.patch delete mode 100644 lang/python/micropython/patches/020-mpy-cross-fix-flags.patch create mode 100644 lang/python/micropython/src/ports/unix/variants/standard/manifest-nossl.py diff --git a/lang/python/micropython/Makefile b/lang/python/micropython/Makefile index e63f93f4b..6e129c15d 100644 --- a/lang/python/micropython/Makefile +++ b/lang/python/micropython/Makefile @@ -8,23 +8,25 @@ include $(TOPDIR)/rules.mk PKG_NAME:=micropython -PKG_VERSION:=1.18 +PKG_VERSION:=1.20.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://github.com/micropython/micropython/releases/download/v$(PKG_VERSION) -PKG_HASH:=96fc71b42ed331c64e1adc5a830ec4f29f2975c23e8751109c03f32b80fa3eb4 +PKG_HASH:=098ef8e40abdc62551b5460d0ffe9489074240c0cb5589ca3c3a425551beb9bf PKG_MAINTAINER:=Jeffery To PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE +PKG_BUILD_DEPENDS:=python3/host +PKG_BUILD_FLAGS:=no-mips16 PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk -define Package/micropython/default +define Package/micropython/Default SUBMENU:=Python SECTION:=lang CATEGORY:=Languages @@ -35,36 +37,37 @@ define Package/micropython/default endef define Package/micropython-mbedtls -$(call Package/micropython/default) +$(call Package/micropython/Default) TITLE+= (mbedtls) - DEPENDS+= +libmbedtls + DEPENDS+= +PACKAGE_micropython-mbedtls:libmbedtls + CONFLICTS:=micropython-nossl VARIANT:=mbedtls DEFAULT_VARIANT:=1 endef define Package/micropython-nossl -$(call Package/micropython/default) +$(call Package/micropython/Default) TITLE+= (nossl) VARIANT:=nossl endef -define Package/micropython/default/description - MicroPython is a lean and efficient implementation of the Python 3 - programming language that includes a small subset of the Python - standard library and is optimised to run on microcontrollers and in - constrained environments. +define Package/micropython/Default/description +MicroPython is a lean and efficient implementation of the Python 3 +programming language that includes a small subset of the Python standard +library and is optimised to run on microcontrollers and in constrained +environments. endef define Package/micropython-mbedtls/description -$(call Package/micropython/default/description) +$(call Package/micropython/Default/description) - This version uses the Mbed TLS library. +This version uses the Mbed TLS library. endef define Package/micropython-nossl/description -$(call Package/micropython/default/description) +$(call Package/micropython/Default/description) - This version is built without TLS and upip. +This version is built without TLS and mip. endef MAKE_FLAGS += BUILD_VERBOSE=1 @@ -73,30 +76,42 @@ ifneq ($(CONFIG_DEBUG),) MAKE_FLAGS += DEBUG=1 endif -ifeq ($(BUILD_VARIANT),mbedtls) - MAKE_FLAGS += MICROPY_SSL_AXTLS=0 MICROPY_SSL_MBEDTLS=1 -endif - ifeq ($(BUILD_VARIANT),nossl) - MAKE_FLAGS += MICROPY_PY_USSL=0 FROZEN_MANIFEST= + MAKE_FLAGS += MICROPY_PY_USSL=0 FROZEN_MANIFEST=variants/standard/manifest-nossl.py endif MAKE_PATH = ports/unix -define Build/Compile +define Build/Configure +$(HOST_MAKE_VARS) \ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/mpy-cross \ $(HOST_MAKE_FLAGS) BUILD_VERBOSE=1 - $(call Build/Compile/Default) endef -define Package/micropython/default/install +define Build/InstallDev + $(INSTALL_DIR) $(2)/lib/micropython-$(PKG_VERSION)/mpy-cross + $(CP) \ + $(PKG_BUILD_DIR)/mpy-cross/mpy_cross \ + $(2)/lib/micropython-$(PKG_VERSION)/mpy-cross/ + + $(INSTALL_DIR) $(2)/lib/micropython-$(PKG_VERSION)/mpy-cross/build + $(INSTALL_BIN) \ + $(PKG_BUILD_DIR)/mpy-cross/build/mpy-cross \ + $(2)/lib/micropython-$(PKG_VERSION)/mpy-cross/build/ + + $(INSTALL_DIR) $(2)/lib/micropython-$(PKG_VERSION)/tools + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/tools/manifestfile.py \ + $(2)/lib/micropython-$(PKG_VERSION)/tools/ +endef + +define Package/micropython/Default/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/ports/unix/micropython $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ports/unix/build-standard/micropython $(1)/usr/bin/ endef -Package/micropython-mbedtls/install = $(Package/micropython/default/install) -Package/micropython-nossl/install = $(Package/micropython/default/install) +Package/micropython-mbedtls/install = $(Package/micropython/Default/install) +Package/micropython-nossl/install = $(Package/micropython/Default/install) $(eval $(call BuildPackage,micropython-mbedtls)) $(eval $(call BuildPackage,micropython-nossl)) diff --git a/lang/python/micropython/patches/000-Makefile-no-errors.patch b/lang/python/micropython/patches/000-Makefile-no-errors.patch deleted file mode 100644 index a32ee2903..000000000 --- a/lang/python/micropython/patches/000-Makefile-no-errors.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/ports/unix/Makefile -+++ b/ports/unix/Makefile -@@ -36,7 +36,7 @@ INC += -I$(TOP) - INC += -I$(BUILD) - - # compiler settings --CWARN = -Wall -Werror -+CWARN = -Wall - CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith -Wdouble-promotion -Wfloat-conversion - CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA) - diff --git a/lang/python/micropython/patches/020-mpy-cross-fix-flags.patch b/lang/python/micropython/patches/020-mpy-cross-fix-flags.patch deleted file mode 100644 index d035c7010..000000000 --- a/lang/python/micropython/patches/020-mpy-cross-fix-flags.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/mpy-cross/Makefile -+++ b/mpy-cross/Makefile -@@ -19,7 +19,7 @@ INC += -I$(TOP) - # compiler settings - CWARN = -Wall -Werror - CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith --CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -+CFLAGS += $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) - CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables - - # Debugging/Optimization -@@ -42,7 +42,7 @@ else - # Use gcc syntax for map file - LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections - endif --LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) -+LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) - - # source files - SRC_C = \ diff --git a/lang/python/micropython/patches/030-target-no-darwin.patch b/lang/python/micropython/patches/030-target-no-darwin.patch index b814c998e..a847e96b4 100644 --- a/lang/python/micropython/patches/030-target-no-darwin.patch +++ b/lang/python/micropython/patches/030-target-no-darwin.patch @@ -1,6 +1,6 @@ --- a/ports/unix/Makefile +++ b/ports/unix/Makefile -@@ -24,7 +24,7 @@ QSTR_DEFS = qstrdefsport.h +@@ -31,7 +31,7 @@ QSTR_DEFS = qstrdefsport.h QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h # OS name, for simple autoconfig diff --git a/lang/python/micropython/patches/040-extmod-use-external-mbedtls.patch b/lang/python/micropython/patches/040-extmod-use-external-mbedtls.patch index f5039741a..dccd5ba51 100644 --- a/lang/python/micropython/patches/040-extmod-use-external-mbedtls.patch +++ b/lang/python/micropython/patches/040-extmod-use-external-mbedtls.patch @@ -9,13 +9,17 @@ Subject: [PATCH 06/10] extmod: Use system mbedtls --- a/extmod/extmod.mk +++ b/extmod/extmod.mk -@@ -66,81 +66,8 @@ SRC_MOD += $(addprefix $(AXTLS_DIR)/,\ +@@ -131,84 +131,8 @@ SRC_THIRDPARTY_C += $(addprefix $(AXTLS_ crypto/sha1.c \ ) else ifeq ($(MICROPY_SSL_MBEDTLS),1) -MBEDTLS_DIR = lib/mbedtls --CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include --SRC_MOD += $(addprefix $(MBEDTLS_DIR)/library/,\ +-MBEDTLS_CONFIG_FILE ?= \"mbedtls/mbedtls_config.h\" +-GIT_SUBMODULES += $(MBEDTLS_DIR) +-CFLAGS_EXTMOD += -DMBEDTLS_CONFIG_FILE=$(MBEDTLS_CONFIG_FILE) +-CFLAGS_EXTMOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include +-SRC_THIRDPARTY_C += lib/mbedtls_errors/mp_mbedtls_errors.c +-SRC_THIRDPARTY_C += $(addprefix $(MBEDTLS_DIR)/library/,\ - aes.c \ - aesni.c \ - arc4.c \ @@ -43,7 +47,6 @@ Subject: [PATCH 06/10] extmod: Use system mbedtls - ecp_curves.c \ - entropy.c \ - entropy_poll.c \ -- error.c \ - gcm.c \ - havege.c \ - hmac_drbg.c \ @@ -88,7 +91,7 @@ Subject: [PATCH 06/10] extmod: Use system mbedtls - x509write_csr.c \ - xtea.c \ - ) -+CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 ++CFLAGS_EXTMOD += -DMICROPY_SSL_MBEDTLS=1 +LDFLAGS_MOD += -lmbedx509 -lmbedtls -lmbedcrypto endif endif diff --git a/lang/python/micropython/src/ports/unix/variants/standard/manifest-nossl.py b/lang/python/micropython/src/ports/unix/variants/standard/manifest-nossl.py new file mode 100644 index 000000000..21f53bddd --- /dev/null +++ b/lang/python/micropython/src/ports/unix/variants/standard/manifest-nossl.py @@ -0,0 +1 @@ +include("$(MPY_DIR)/extmod/uasyncio") From 9390bd0262ad9f0775b76984d1c8f29b9a35584e Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 30 May 2023 03:24:54 +0800 Subject: [PATCH 2/6] micropython-lib: Update to master, split target package The package has been reworked to install the same files that are available to be downloaded/installed by mip, the package manager new to MicroPython 1.20.0. This also splits the original target package into four: * micropython-lib * Includes packages common to all MicroPython ports (python-stdlib, python-ecosys, micropython) * Contains mpy bytecode files * micropython-lib-src * Includes packages common to all MicroPython ports (python-stdlib, python-ecosys, micropython) * Contains py source files * micropython-lib-unix * Includes packages specific to the MicroPython Unix port (unix-ffi) * Contains mpy bytecode files * Installs a specific launcher (micropython-unix) that adds the Unix package directory into MicroPython's library path * micropython-lib-unix-src * Includes packages specific to the MicroPython Unix port (unix-ffi) * Contains py source files This also updates the package license, title, and description. Patches: * 001-build-unix-ffi.patch This enables the repo build script to also build the Unix-specific packages. Not sure if upstream is open to accepting this since the Unix-specific packages don't fit well into the existing package distribution mechanism. * 002-add-unix-ffi-os-path.patch and 003-add-unix-ffi-uu.patch These fix instances where the unix-ffi version of the os package is overridden by the python-stdlib version. These have been submitted to upstream: https://github.com/micropython/micropython-lib/pull/672 Signed-off-by: Jeffery To --- lang/python/micropython-lib/Makefile | 117 +++++++++++++++--- .../micropython-lib/files/micropython-unix | 3 + lang/python/micropython-lib/install.py | 62 ++++++++++ .../patches/001-build-unix-ffi.patch | 37 ++++++ .../patches/002-add-unix-ffi-os-path.patch | 53 ++++++++ .../patches/003-add-unix-ffi-uu.patch | 37 ++++++ 6 files changed, 292 insertions(+), 17 deletions(-) create mode 100644 lang/python/micropython-lib/files/micropython-unix create mode 100644 lang/python/micropython-lib/install.py create mode 100644 lang/python/micropython-lib/patches/001-build-unix-ffi.patch create mode 100644 lang/python/micropython-lib/patches/002-add-unix-ffi-os-path.patch create mode 100644 lang/python/micropython-lib/patches/003-add-unix-ffi-uu.patch diff --git a/lang/python/micropython-lib/Makefile b/lang/python/micropython-lib/Makefile index 1eb2bea73..7bd167898 100644 --- a/lang/python/micropython-lib/Makefile +++ b/lang/python/micropython-lib/Makefile @@ -12,42 +12,125 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/micropython/micropython-lib.git -PKG_SOURCE_VERSION:=db4c739863e49fc874bdaae8aa8c316c7ed4276a -PKG_SOURCE_DATE:=20220506 -PKG_MIRROR_HASH:=ec4be91755fcd4d4fa61e1e7eadc748377ba63b82b7bb4254864473fafcd3173 +PKG_SOURCE_VERSION:=7128d423c2e7c0309ac17a1e6ba873b909b24fcc +PKG_SOURCE_DATE:=20230522 +PKG_MIRROR_HASH:=1f094aac257d2094ee91b457164f845f6461df1cf1d0ed7ee556c98f273f5afb PKG_MAINTAINER:=Jeffery To -PKG_LICENSE:=MIT PSF-2.0 +PKG_LICENSE:=MIT Python-2.0.1 PKG_LICENSE_FILES:=LICENSE +PKG_BUILD_DEPENDS:=python3/host PKG_BUILD_PARALLEL:=1 +# keep in sync with micropython +MP_VERSION:=1.20.0 +MP_MPY_FILE_VERSION:=6 + include $(INCLUDE_DIR)/package.mk -define Package/micropython-lib +define Package/micropython-lib/Default SUBMENU:=Python SECTION:=lang CATEGORY:=Languages - TITLE:=micropython-lib + TITLE:=MicroPython package repository URL:=https://github.com/micropython/micropython-lib +endef + +define Package/micropython-lib +$(call Package/micropython-lib/Default) DEPENDS:=+micropython endef -define Package/micropython-lib/description - This is a repository of libraries designed to be useful for writing - MicroPython applications. +define Package/micropython-lib-src +$(call Package/micropython-lib/Default) + TITLE+= (sources) endef -Build/Compile:=: +define Package/micropython-lib-unix +$(call Package/micropython-lib/Default) + TITLE+= - Unix port packages + DEPENDS:=+micropython +libpcre +librt +libsqlite3 +endef + +define Package/micropython-lib-unix-src +$(call Package/micropython-lib/Default) + TITLE+= - Unix port packages (sources) +endef + +define Package/micropython-lib/Default/description +This is a repository of packages designed to be useful for writing +MicroPython applications. +endef + +define Package/micropython-lib/description +$(call Package/micropython-lib/Default/description) + +This contains packages common to all MicroPython ports. +endef + +define Package/micropython-lib-src/description +$(call Package/micropython-lib/Default/description) + +This contains source files for packages common to all MicroPython ports. +endef + +define Package/micropython-lib-unix/description +$(call Package/micropython-lib/Default/description) + +This contains packages specific to the MicroPython Unix port. +endef + +define Package/micropython-lib-unix-src/description +$(call Package/micropython-lib/Default/description) + +This contains source files for packages specific to the MicroPython Unix +port. +endef + +MP_INSTALLDEV_PATH:=$(STAGING_DIR)/host/lib/micropython-$(MP_VERSION) + +define MicroPythonLib/Compile + cd "$(PKG_BUILD_DIR)" && python3 tools/build.py \ + --hash-prefix 64 \ + --micropython "$(MP_INSTALLDEV_PATH)" \ + --mpy-cross "$(MP_INSTALLDEV_PATH)/mpy-cross/build/mpy-cross" \ + --output "$(PKG_BUILD_DIR)/$(strip $(1))" \ + $(2) +endef + +define MicroPythonLib/Install + python3 install.py \ + --input "$(PKG_BUILD_DIR)/$(strip $(1))" \ + --output "$(strip $(3))" \ + --version "$(strip $(2))" +endef + +define Build/Compile + $(call MicroPythonLib/Compile) + $(call MicroPythonLib/Compile,unix-ffi-index,--unix-ffi) +endef define Package/micropython-lib/install - for dir in micropython python-ecosys python-stdlib unix-ffi; do \ - $(INSTALL_DIR) $(1)/usr/lib/micropython/$$$$dir ; \ - $(CP) $(PKG_BUILD_DIR)/$$$$dir/* $(1)/usr/lib/micropython/$$$$dir/ ; \ - done - $(FIND) $(1)/usr/lib/micropython \ - -not -type d \( -not -name '*.py' -o -name 'test_*' -o -name 'setup.py' \) -delete - $(FIND) $(1)/usr/lib/micropython -mindepth 1 -empty -type d -delete + $(call MicroPythonLib/Install,,$(MP_MPY_FILE_VERSION),$(1)/usr/lib/micropython) +endef + +define Package/micropython-lib-src/install + $(call MicroPythonLib/Install,,py,$(1)/usr/lib/micropython) +endef + +define Package/micropython-lib-unix/install + $(call MicroPythonLib/Install,unix-ffi-index,$(MP_MPY_FILE_VERSION),$(1)/usr/lib/micropython/unix) + + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/micropython-unix $(1)/usr/bin/ +endef + +define Package/micropython-lib-unix-src/install + $(call MicroPythonLib/Install,unix-ffi-index,py,$(1)/usr/lib/micropython/unix) endef $(eval $(call BuildPackage,micropython-lib)) +$(eval $(call BuildPackage,micropython-lib-src)) +$(eval $(call BuildPackage,micropython-lib-unix)) +$(eval $(call BuildPackage,micropython-lib-unix-src)) diff --git a/lang/python/micropython-lib/files/micropython-unix b/lang/python/micropython-lib/files/micropython-unix new file mode 100644 index 000000000..a0c372cf4 --- /dev/null +++ b/lang/python/micropython-lib/files/micropython-unix @@ -0,0 +1,3 @@ +#!/bin/sh +export MICROPYPATH=".frozen:~/.micropython/lib:/usr/lib/micropython/unix:/usr/lib/micropython" +exec micropython "$@" diff --git a/lang/python/micropython-lib/install.py b/lang/python/micropython-lib/install.py new file mode 100644 index 000000000..f10707232 --- /dev/null +++ b/lang/python/micropython-lib/install.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2023 Jeffery To +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +import json +import os +import re +import shutil +import sys + + +def install(input_path, mpy_version, output_path): + index_json_path = os.path.join(input_path, "index.json") + files = {} + + with open(index_json_path) as f: + index_json = json.load(f) + + for p in index_json["packages"]: + package_name = p["name"] + package_json_path = os.path.join(input_path, "package", mpy_version, package_name, "latest.json") + + with open(package_json_path) as f: + package_json = json.load(f) + + for file_name, file_hash in package_json["hashes"]: + if file_name in files: + if file_hash != files[file_name]: + print("File name/hash collision:", package_name, file=sys.stderr) + print(" File: ", file_name, file=sys.stderr) + print(" Curent hash: ", file_hash, file=sys.stderr) + print(" Previous hash: ", files[file_name], file=sys.stderr) + sys.exit(1) + else: + files[file_name] = file_hash + + for file_name, file_hash in files.items(): + in_file_path = os.path.join(input_path, "file", file_hash[:2], file_hash) + out_file_path = os.path.join(output_path, file_name) + + os.makedirs(os.path.dirname(out_file_path), exist_ok=True) + shutil.copy2(in_file_path, out_file_path) + + +def main(): + import argparse + + cmd_parser = argparse.ArgumentParser(description="Install compiled micropython-lib packages.") + cmd_parser.add_argument("--input", required=True, help="input directory") + cmd_parser.add_argument("--version", required=True, help="mpy version to install") + cmd_parser.add_argument("--output", required=True, help="output directory") + args = cmd_parser.parse_args() + + install(args.input, args.version, args.output) + + +if __name__ == "__main__": + main() diff --git a/lang/python/micropython-lib/patches/001-build-unix-ffi.patch b/lang/python/micropython-lib/patches/001-build-unix-ffi.patch new file mode 100644 index 000000000..4dfaca6f9 --- /dev/null +++ b/lang/python/micropython-lib/patches/001-build-unix-ffi.patch @@ -0,0 +1,37 @@ +--- a/tools/build.py ++++ b/tools/build.py +@@ -284,7 +284,7 @@ def _update_index_package_metadata(index + index_package_json["versions"][v].append(metadata.version) + + +-def build(output_path, hash_prefix_len, mpy_cross_path): ++def build(output_path, unix_ffi, hash_prefix_len, mpy_cross_path): + import manifestfile + import mpy_cross + +@@ -310,7 +310,7 @@ def build(output_path, hash_prefix_len, + + # For now, don't process unix-ffi. In the future this can be extended to + # allow a way to request unix-ffi packages via mip. +- lib_dirs = ["micropython", "python-stdlib", "python-ecosys"] ++ lib_dirs = ["unix-ffi"] if unix_ffi else ["micropython", "python-stdlib", "python-ecosys"] + + mpy_version, _mpy_sub_version = mpy_cross.mpy_version(mpy_cross=mpy_cross_path) + mpy_version = str(mpy_version) +@@ -438,6 +438,7 @@ def main(): + + cmd_parser = argparse.ArgumentParser(description="Compile micropython-lib for serving to mip.") + cmd_parser.add_argument("--output", required=True, help="output directory") ++ cmd_parser.add_argument("--unix-ffi", action="store_true", help="process unix-ffi packages") + cmd_parser.add_argument("--hash-prefix", default=8, type=int, help="hash prefix length") + cmd_parser.add_argument("--mpy-cross", default=None, help="optional path to mpy-cross binary") + cmd_parser.add_argument("--micropython", default=None, help="path to micropython repo") +@@ -447,7 +448,7 @@ def main(): + sys.path.append(os.path.join(args.micropython, "tools")) # for manifestfile + sys.path.append(os.path.join(args.micropython, "mpy-cross")) # for mpy_cross + +- build(args.output, hash_prefix_len=max(4, args.hash_prefix), mpy_cross_path=args.mpy_cross) ++ build(args.output, args.unix_ffi, hash_prefix_len=max(4, args.hash_prefix), mpy_cross_path=args.mpy_cross) + + + if __name__ == "__main__": diff --git a/lang/python/micropython-lib/patches/002-add-unix-ffi-os-path.patch b/lang/python/micropython-lib/patches/002-add-unix-ffi-os-path.patch new file mode 100644 index 000000000..5ebc6820e --- /dev/null +++ b/lang/python/micropython-lib/patches/002-add-unix-ffi-os-path.patch @@ -0,0 +1,53 @@ +From dcce62dd525cf0f8e572e56a8990aea7ec2f0ade Mon Sep 17 00:00:00 2001 +From: Jeffery To +Date: Tue, 30 May 2023 23:47:59 +0800 +Subject: [PATCH] unix-ffi/os-path: Add unix-ffi version of `os-path` package. + +This package reuses the code from the python-stdlib version of `os-path` +but requires the unix-ffi version of `os`. + +This also updates `glob` to require this version of `os-path`. + +Signed-off-by: Jeffery To +--- + unix-ffi/glob/manifest.py | 2 +- + unix-ffi/os-path/manifest.py | 6 ++++++ + unix-ffi/os/os/__init__.py | 6 ++++++ + 3 files changed, 13 insertions(+), 1 deletion(-) + create mode 100644 unix-ffi/os-path/manifest.py + +--- a/unix-ffi/glob/manifest.py ++++ b/unix-ffi/glob/manifest.py +@@ -1,7 +1,7 @@ + metadata(version="0.5.2") + + require("os", unix_ffi=True) +-require("os-path") ++require("os-path", unix_ffi=True) + require("re", unix_ffi=True) + require("fnmatch") + +--- /dev/null ++++ b/unix-ffi/os-path/manifest.py +@@ -0,0 +1,6 @@ ++metadata(version="0.1.4") ++ ++# Originally written by Paul Sokolovsky. ++ ++require("os", unix_ffi=True) ++package("os", base_path="../../python-stdlib/os-path") +--- a/unix-ffi/os/os/__init__.py ++++ b/unix-ffi/os/os/__init__.py +@@ -5,6 +5,12 @@ import stat as stat_ + import ffilib + import uos + ++# Provide optional dependencies (which may be installed separately). ++try: ++ from . import path ++except ImportError: ++ pass ++ + R_OK = const(4) + W_OK = const(2) + X_OK = const(1) diff --git a/lang/python/micropython-lib/patches/003-add-unix-ffi-uu.patch b/lang/python/micropython-lib/patches/003-add-unix-ffi-uu.patch new file mode 100644 index 000000000..363fae394 --- /dev/null +++ b/lang/python/micropython-lib/patches/003-add-unix-ffi-uu.patch @@ -0,0 +1,37 @@ +From 2e7bfd08a306bd9e80b22097ef8fe66e1dd85054 Mon Sep 17 00:00:00 2001 +From: Jeffery To +Date: Wed, 31 May 2023 00:00:11 +0800 +Subject: [PATCH] unix-ffi/uu: Add unix-ffi version of `uu` package. + +This package reuses the code from the python-stdlib version of `uu` but +requires the unix-ffi version of `os-path`. + +This also updates `email.message` to require this version of `uu`. + +Signed-off-by: Jeffery To +--- + unix-ffi/email.message/manifest.py | 2 +- + unix-ffi/uu/manifest.py | 6 ++++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + create mode 100644 unix-ffi/uu/manifest.py + +--- a/unix-ffi/email.message/manifest.py ++++ b/unix-ffi/email.message/manifest.py +@@ -1,7 +1,7 @@ + metadata(version="0.5.3") + + require("re", unix_ffi=True) +-require("uu") ++require("uu", unix_ffi=True) + require("base64") + require("binascii") + require("email.utils", unix_ffi=True) +--- /dev/null ++++ b/unix-ffi/uu/manifest.py +@@ -0,0 +1,6 @@ ++metadata(version="0.5.1") ++ ++require("binascii") ++require("os-path", unix_ffi=True) ++ ++module("uu.py", base_path="../../python-stdlib/uu") From 9071deb1c78ec251d2a25f178f37a1ab633b8de2 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 30 May 2023 02:19:56 +0800 Subject: [PATCH 3/6] python-hatch-requirements-txt: Add new host-only package From the README: Hatchling plugin to read project dependencies from requirements.txt Signed-off-by: Jeffery To --- .../python-hatch-requirements-txt/Makefile | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lang/python/python-hatch-requirements-txt/Makefile diff --git a/lang/python/python-hatch-requirements-txt/Makefile b/lang/python/python-hatch-requirements-txt/Makefile new file mode 100644 index 000000000..ae6cd13b9 --- /dev/null +++ b/lang/python/python-hatch-requirements-txt/Makefile @@ -0,0 +1,53 @@ +# +# Copyright (C) 2023 Jeffery To +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=python-hatch-requirements-txt +PKG_VERSION:=0.4.0 +PKG_RELEASE:=1 + +PYPI_NAME:=hatch-requirements-txt +PYPI_SOURCE_NAME:=hatch_requirements_txt +PKG_HASH:=800509946e85d9e56d73242fab223ec36db50372e870a04e2dd1fd9bad98455d + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=Jeffery To + +PKG_HOST_ONLY:=1 +HOST_BUILD_DEPENDS:= \ + python3/host \ + python-build/host \ + python-installer/host \ + python-hatchling/host \ + python-packaging/host + +include ../pypi.mk +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk +include ../python3-package.mk +include ../python3-host-build.mk + +define Package/python3-hatch-requirements-txt + SECTION:=lang + CATEGORY:=Languages + SUBMENU:=Python + TITLE:=Read project dependencies from requirements.txt + URL:=https://github.com/repo-helper/hatch-requirements-txt + DEPENDS:=+python3-light +python3-hatchling +python3-packaging + BUILDONLY:=1 +endef + +define Package/python3-hatch-requirements-txt/description +Hatchling plugin to read project dependencies from requirements.txt +endef + +$(eval $(call Py3Package,python3-hatch-requirements-txt)) +$(eval $(call BuildPackage,python3-hatch-requirements-txt)) +$(eval $(call BuildPackage,python3-hatch-requirements-txt-src)) +$(eval $(call HostBuild)) From a83dcf0d5cf20942db27e23e9aff80c7ae373822 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 30 May 2023 02:25:20 +0800 Subject: [PATCH 4/6] micropython-mpremote: Add new package From the README: This CLI tool provides an integrated set of utilities to remotely interact with and automate a MicroPython device over a serial connection. Signed-off-by: Jeffery To --- lang/python/micropython-mpremote/Makefile | 44 +++++++++++++++++++ .../patches/001-no-importlib_metadata.patch | 5 +++ 2 files changed, 49 insertions(+) create mode 100644 lang/python/micropython-mpremote/Makefile create mode 100644 lang/python/micropython-mpremote/patches/001-no-importlib_metadata.patch diff --git a/lang/python/micropython-mpremote/Makefile b/lang/python/micropython-mpremote/Makefile new file mode 100644 index 000000000..9beca0156 --- /dev/null +++ b/lang/python/micropython-mpremote/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2023 Jeffery To +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=micropython-mpremote +PKG_VERSION:=1.20.0 +PKG_RELEASE:=1 + +PYPI_NAME:=mpremote +PKG_HASH:=5c342762a04791309dd49bce63c70a075aa7c548b1c0076262b96f9ccc398ca2 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=Jeffery To + +PKG_BUILD_DEPENDS:=python-hatchling/host python-hatch-requirements-txt/host python-hatch-vcs/host + +include ../pypi.mk +include $(INCLUDE_DIR)/package.mk +include ../python3-package.mk + +define Package/micropython-mpremote + SECTION:=lang + CATEGORY:=Languages + SUBMENU:=Python + TITLE:=Interacting remotely with MicroPython devices + URL:=https://github.com/micropython/micropython + DEPENDS:=+python3-light +python3-urllib +python3-pyserial +endef + +define Package/micropython-mpremote/description +This CLI tool provides an integrated set of utilities to remotely +interact with and automate a MicroPython device over a serial +connection. +endef + +$(eval $(call Py3Package,micropython-mpremote)) +$(eval $(call BuildPackage,micropython-mpremote)) +$(eval $(call BuildPackage,micropython-mpremote-src)) diff --git a/lang/python/micropython-mpremote/patches/001-no-importlib_metadata.patch b/lang/python/micropython-mpremote/patches/001-no-importlib_metadata.patch new file mode 100644 index 000000000..6f5fc4921 --- /dev/null +++ b/lang/python/micropython-mpremote/patches/001-no-importlib_metadata.patch @@ -0,0 +1,5 @@ +--- a/requirements.txt ++++ b/requirements.txt +@@ -1,2 +1 @@ + pyserial >= 3.3 +-importlib_metadata >= 1.4 From 3906e54c086417b0812d0000835e0ac518097b5f Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sat, 3 Jun 2023 01:23:53 +0800 Subject: [PATCH 5/6] golang: Enable riscv64 for Go compiler and packages Signed-off-by: Jeffery To --- lang/golang/golang-values.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/golang/golang-values.mk b/lang/golang/golang-values.mk index 3c170f308..bf090af32 100644 --- a/lang/golang/golang-values.mk +++ b/lang/golang/golang-values.mk @@ -201,7 +201,7 @@ endif # Target Go -GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||x86_64) +GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64) # ASLR/PIE From fc8cc7aa8fd6dc40131821d49c6ad682fc3b534d Mon Sep 17 00:00:00 2001 From: Dengfeng Liu Date: Sat, 3 Jun 2023 10:07:44 +0800 Subject: [PATCH 6/6] xfrpc: update to 2.6.633 support socks5 Signed-off-by: Dengfeng Liu --- net/xfrpc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/xfrpc/Makefile b/net/xfrpc/Makefile index bb8d33827..d25c6b01c 100644 --- a/net/xfrpc/Makefile +++ b/net/xfrpc/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=xfrpc -PKG_VERSION:=2.1.606 +PKG_VERSION:=2.6.633 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/liudf0716/xfrpc.git PKG_SOURCE_VERSION:=$(PKG_VERSION) -PKG_MIRROR_HASH:=2f9f98fde54f66a6c562356f66d0abd3ec41fcd6833915831378a37398ff2cc5 +PKG_MIRROR_HASH:=b9d5c2f8dd0d323169a824bb59d65bcc27fe6e0564c6aede5b966220b99ccc7b PKG_MAINTAINER:=Dengfeng Liu PKG_LICENSE:=GPL-3.0-or-later