|
| 1 | +TERMUX_PKG_HOMEPAGE=https://github.com/mitmproxy/mitmproxy_rs |
| 2 | +TERMUX_PKG_DESCRIPTION="The Rust bits in mitmproxy" |
| 3 | +TERMUX_PKG_LICENSE="MIT" |
| 4 | +TERMUX_PKG_MAINTAINER="@termux-user-repository" |
| 5 | +TERMUX_PKG_VERSION="0.11.1" |
| 6 | +TERMUX_PKG_SRCURL=https://github.com/mitmproxy/mitmproxy_rs/archive/refs/tags/v$TERMUX_PKG_VERSION.tar.gz |
| 7 | +TERMUX_PKG_SHA256=f9604fcb4a3dcc7fff7cc962a2300f92b5cf77f31129626ee7aeefeb4eb45273 |
| 8 | +TERMUX_PKG_AUTO_UPDATE=true |
| 9 | +TERMUX_PKG_DEPENDS="libc++, openssl, python" |
| 10 | +TERMUX_PKG_PYTHON_COMMON_DEPS="wheel" |
| 11 | +TERMUX_PKG_PYTHON_BUILD_DEPS="maturin" |
| 12 | +TERMUX_PKG_BUILD_IN_SRC=true |
| 13 | +TERMUX_PKG_UPDATE_TAG_TYPE="newest-tag" |
| 14 | + |
| 15 | +TERMUX_PYTHON_VERSION=3.12 |
| 16 | +TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION} |
| 17 | +TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH |
| 18 | +TUR_AUTO_AUDIT_WHEEL=true |
| 19 | +TUR_AUDIT_WHEEL_NO_LIBS=true |
| 20 | +TUR_AUTO_BUILD_WHEEL=false |
| 21 | +TUR_WHEEL_DIR="target/wheels" |
| 22 | + |
| 23 | +source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh |
| 24 | + |
| 25 | +termux_step_pre_configure() { |
| 26 | + termux_setup_rust |
| 27 | + |
| 28 | + LDFLAGS+=" -Wl,--no-as-needed,-lpython${TERMUX_PYTHON_VERSION}" |
| 29 | +} |
| 30 | + |
| 31 | +termux_step_make() { |
| 32 | + : |
| 33 | +} |
| 34 | + |
| 35 | +termux_step_make_install() { |
| 36 | + export CARGO_BUILD_TARGET=${CARGO_TARGET_NAME} |
| 37 | + export PYO3_CROSS_LIB_DIR=$TERMUX_PREFIX/lib |
| 38 | + export PYTHONPATH=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}/site-packages |
| 39 | + |
| 40 | + cd mitmproxy-rs |
| 41 | + build-python -m maturin build --release --skip-auditwheel --target $CARGO_BUILD_TARGET |
| 42 | + |
| 43 | + local _pyver="${TERMUX_PYTHON_VERSION/./}" |
| 44 | + # Fix wheel name, although it it built with tag `cp310-abi3`, but it is linked against `python3.x.so` |
| 45 | + # so it will not work on other pythons. |
| 46 | + if [ "$TERMUX_ARCH" = "arm" ]; then |
| 47 | + mv ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-cp310-abi3-linux_armv7l.whl \ |
| 48 | + ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-py$_pyver-none-any.whl |
| 49 | + else |
| 50 | + mv ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-cp310-abi3-linux_$TERMUX_ARCH.whl \ |
| 51 | + ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-cp$_pyver-cp$_pyver-linux_$TERMUX_ARCH.whl |
| 52 | + fi |
| 53 | + |
| 54 | + pip install --no-deps ../target/wheels/*.whl --prefix $TERMUX_PREFIX |
| 55 | + |
| 56 | + # Fix wheel name for arm |
| 57 | + if [ "$TERMUX_ARCH" = "arm" ]; then |
| 58 | + mv ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-py$_pyver-none-any.whl \ |
| 59 | + ../target/wheels/mitmproxy_rs-$TERMUX_PKG_VERSION-cp$_pyver-cp$_pyver-linux_armv7l.whl |
| 60 | + fi |
| 61 | +} |
0 commit comments