new package: nala

This commit is contained in:
Tee KOBAYASHI 2022-04-12 17:46:10 +09:00 committed by xtkoba
parent bf9aaecd58
commit def49df735
8 changed files with 194 additions and 0 deletions

73
packages/nala/build.sh Normal file
View File

@ -0,0 +1,73 @@
TERMUX_PKG_HOMEPAGE=https://gitlab.com/volian/nala
TERMUX_PKG_DESCRIPTION="Commandline frontend for the apt package manager"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.7.2
TERMUX_PKG_SRCURL=https://gitlab.com/volian/nala/-/archive/v${TERMUX_PKG_VERSION}/nala-v${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_SHA256=0ac394ab2bd924c28c513a8e8bfc9e899a21f2f8fa5e5d77366cb20e0be8676e
TERMUX_PKG_DEPENDS="python-apt"
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_BUILD_IN_SRC=true
_PYTHON_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python/build.sh; echo $_MAJOR_VERSION)
TERMUX_PKG_RM_AFTER_INSTALL="
lib/python${_PYTHON_VERSION}/site-packages/__pycache__
lib/python${_PYTHON_VERSION}/site-packages/easy-install.pth
lib/python${_PYTHON_VERSION}/site-packages/site.py
"
termux_step_post_get_source() {
sed 's:@TERMUX_PKG_VERSION@:'${TERMUX_PKG_VERSION##*:}':g' \
${TERMUX_PKG_BUILDER_DIR}/pyproject.toml.diff | \
patch --silent -p1
}
termux_step_pre_configure() {
termux_setup_python_crossenv
pushd $TERMUX_PYTHON_CROSSENV_SRCDIR
_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python-crossenv-prefix
python${_PYTHON_VERSION} -m crossenv \
$TERMUX_PREFIX/bin/python${_PYTHON_VERSION} \
${_CROSSENV_PREFIX}
popd
. ${_CROSSENV_PREFIX}/bin/activate
build-pip install tomli
}
termux_step_make_install() {
python setup.py install --force
export PYTHONPATH=$TERMUX_PREFIX/lib/python${_PYTHON_VERSION}/site-packages
python setup.py install --force --prefix $TERMUX_PREFIX
pushd $PYTHONPATH
_NALA_EGG=
for f in nala-${TERMUX_PKG_VERSION##*:}-py${_PYTHON_VERSION}.egg; do
if [ -e "$f" ]; then
_NALA_EGG="$f"
break
fi
done
test -n "${_NALA_EGG}"
popd
install -Dm600 -t $TERMUX_PREFIX/etc/nala debian/nala.conf
}
termux_step_create_debscripts() {
cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh
echo "./${_NALA_EGG}" >> $TERMUX_PREFIX/lib/python${_PYTHON_VERSION}/site-packages/easy-install.pth
mkdir -p $TERMUX_PREFIX/var/lib/nala
mkdir -p $TERMUX_PREFIX/var/log/nala
echo "Installing dependencies through pip..."
pip3 install anyio httpx jsbeautifier pexpect rich
EOF
cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh
sed -i "/\.\/${_NALA_EGG//./\\.}/d" $TERMUX_PREFIX/lib/python${_PYTHON_VERSION}/site-packages/easy-install.pth
EOF
}

View File

@ -0,0 +1,11 @@
--- a/nala/__init__.py
+++ b/nala/__init__.py
@@ -29,7 +29,7 @@
# Before we import anything else we need to make sure that this is in our path
# Else apt_pkg will give an import error. Conda is an example of this breaking
# pylint: disable=wrong-import-position
-PY_PATH = "/usr/lib/python3/dist-packages"
+PY_PATH = "@TERMUX_PREFIX@/lib/python3/dist-packages"
if PY_PATH not in sys.path:
sys.path.append(PY_PATH)

View File

@ -0,0 +1,11 @@
--- a/nala/config.py
+++ b/nala/config.py
@@ -33,7 +33,7 @@
from nala.options import arguments
from nala.utils import eprint
-CONF_FILE = "/etc/nala/nala.conf"
+CONF_FILE = "@TERMUX_PREFIX@/etc/nala/nala.conf"
try:
read_config_file(config, CONF_FILE)

View File

@ -0,0 +1,44 @@
--- a/nala/constants.py
+++ b/nala/constants.py
@@ -37,13 +37,13 @@
from nala import _, color
# File Constants
-LICENSE = Path("/usr/share/common-licenses/GPL-3")
+LICENSE = Path("@TERMUX_PREFIX@/share/LICENSES/GPL-3.0.txt")
"""/usr/share/common-licenses/GPL-3"""
-NALA_SOURCES = Path("/etc/apt/sources.list.d/nala-sources.list")
+NALA_SOURCES = Path("@TERMUX_PREFIX@/etc/apt/sources.list.d/nala-sources.list")
"""/etc/apt/sources.list.d/nala-sources.list"""
-NALA_DIR = Path("/var/lib/nala")
+NALA_DIR = Path("@TERMUX_PREFIX@/var/lib/nala")
"""/var/lib/nala"""
-NALA_LOGDIR = Path("/var/log/nala")
+NALA_LOGDIR = Path("@TERMUX_PREFIX@/var/log/nala")
"""/var/log/nala"""
NALA_DEBUGLOG = NALA_LOGDIR / "nala-debug.log"
"""/var/log/nala/nala.debug.log"""
@@ -51,17 +51,17 @@
"""/var/log/nala/dpkg-debug.log"""
DPKG_STATUS_LOG = NALA_LOGDIR / "dpkg-status.log"
"""/var/log/nala/dpkg-status.log"""
-NALA_TERM_LOG = Path("/var/log/nala/term.log")
+NALA_TERM_LOG = Path("@TERMUX_PREFIX@/var/log/nala/term.log")
"""/var/log/nala/term.log"""
-NALA_HISTORY = Path("/var/lib/nala/history.json")
+NALA_HISTORY = Path("@TERMUX_PREFIX@/var/lib/nala/history.json")
"""/var/lib/nala/history.json"""
-PACSTALL_METADATA = Path("/var/log/pacstall/metadata")
+PACSTALL_METADATA = Path("@TERMUX_PREFIX@/var/log/pacstall/metadata")
"""/var/log/pacstall/metadata"""
-REBOOT_REQUIRED = Path("/var/run/reboot-required")
+REBOOT_REQUIRED = Path("@TERMUX_PREFIX@/var/run/reboot-required")
"""/var/run/reboot-required"""
-REBOOT_PKGS = Path("/var/run/reboot-required.pkgs")
+REBOOT_PKGS = Path("@TERMUX_PREFIX@/var/run/reboot-required.pkgs")
"""'/var/run/reboot-required.pkgs'"""
-NEED_RESTART = Path("/var/run/needrestart")
+NEED_RESTART = Path("@TERMUX_PREFIX@/var/run/needrestart")
"""/var/run/needrestart"""
# Apt Directories

View File

@ -0,0 +1,11 @@
--- a/nala/error.py
+++ b/nala/error.py
@@ -58,7 +58,7 @@
INSTALL_FAILED = _(
"{error} Installation has failed.\n"
- "If you'd like to file a bug report please include '/var/log/nala/dpkg-debug.log'"
+ "If you'd like to file a bug report please include '@TERMUX_PREFIX@/var/log/nala/dpkg-debug.log'"
)
NO_PROPER_ERR = _(
"{error} python-apt gave us {apt_err} This isn't a proper error as it's empty"

View File

@ -0,0 +1,11 @@
--- a/nala/utils.py
+++ b/nala/utils.py
@@ -169,7 +169,7 @@
@staticmethod
def is_su() -> bool:
"""Return True if we're super user and False if we're not."""
- return os.geteuid() == 0
+ return True
class DelayedKeyboardInterrupt:

View File

@ -0,0 +1,10 @@
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nala"
-version = "0.7.1"
+version = "@TERMUX_PKG_VERSION@"
description = "Commandline frontend for the apt package manager"
authors = [
"Blake Lee <blake@volian.org>",

View File

@ -0,0 +1,23 @@
--- a/setup.py
+++ b/setup.py
@@ -3,8 +3,6 @@
from pathlib import Path
import tomli
-from DistUtilsExtra.auto import clean_build_tree
-from DistUtilsExtra.command import build_extra, build_i18n
from setuptools import setup
PYPROJECT = Path("./pyproject.toml")
@@ -16,11 +14,6 @@
version=POETRY["version"],
author=POETRY["authors"][0].split()[0],
author_email=POETRY["authors"][0].split()[1],
- cmdclass={
- "build": build_extra.build_extra,
- "build_i18n": build_i18n.build_i18n,
- "clean": clean_build_tree,
- },
license=POETRY["license"],
packages=["nala"],
entry_points={