termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

nala: update to `0.11.1`

Open D-Brox opened this issue 2 years ago • 15 comments

I know this is a duplicate of 11337. I've already tried to make a PR with these updates on their fork, but it's been more than a month without new updates/commits. I've already discussed about updating the version with @volitank, the nala dev.

Please refer to #11337 for the original discussion around the patch improvements introduced in 0.11.0, aimed at termux.

D-Brox avatar Sep 07 '22 12:09 D-Brox

Feel free to take this, I have not had any time to work on this. I'm sorry, I shouldn't have committed to taking this on since I knew I'd have limited time with my new internship but I thought I'd be able to work on it.

TomJo2000 avatar Sep 07 '22 12:09 TomJo2000

Nala is building correctly, but I overlooked that installing from pyproject does not generate a .egg file. I'll update the script and squash the commits.

D-Brox avatar Sep 07 '22 15:09 D-Brox

I also noticed the old build script uses termux_setup_python_crossenv. I'd like to ask if this step is really needed, considering that nala doesn't compile anything arch dependent.

Some simple python packages in the repo don't use this, while more complex ones do.

D-Brox avatar Sep 07 '22 16:09 D-Brox

Could you also try to run this against nala 0.11.1? It'd be helpful to see if this script would continue to work in the future, and potentially be able to do auto-updates.

TomJo2000 avatar Sep 07 '22 17:09 TomJo2000

Nala 0.11.1 was a hot-fix for a debian-only issue, and has not been added to the volian apt repo, so I can't really test it.

But now the package should be updatable by changing only the version and hash, in theory.

D-Brox avatar Sep 07 '22 18:09 D-Brox

Ah, I hadn't looked into it that much.

LGTM. Thanks for your time.

TomJo2000 avatar Sep 07 '22 18:09 TomJo2000

@TomJo2000

0.11.1 was only a small change to how we generate the date for the manpages during build time so that it is reproducible in Debian. This hot-fix changes nothing else for 0.11.0, the only thing is that the manpages will have the date from when it is built.

Considering that the termux build doesn't use the Debian packaging and instead uses pip there will be no differences at all.

Come to think of it though, it may be worth considering adding in translations, manpages and shell-completions to the install script.

for man pages these can be generated with ./nala_build.py man --install and the translations with ./nala_build.py babel --compile --install.

I don't know if these will put them in the right place, but it does use the termux path variable I added to make things easier. If not you can build them only by ommiting the --install switch, and then place them in the filesystem accordingly. If y'all end up trying this and install doesn't work, let me know and I'll update the build script for the next release.

For shell completions the files are Zsh: debian/_nala, Bash: debian/bash-completion, Fish: debian/nala.fish

Goal is to make Termux updates as painless as possible for everyone involved.

Also @D-Brox since they are using the GitLab Release page instead of my repo, all you have to do is change the version to 0.11.1 and it'll grab the source for that release.

volitank avatar Sep 07 '22 18:09 volitank

Version 0.11.1 of nala has been released!

2096779623 avatar Sep 12 '22 12:09 2096779623

Version 0.11.1 of nala has been released!

As previously mentioned 0.11.1 is a hotfix release only concerning the man pages for Debian. Although if it builds fine I don't see why we wouldn't use it, as it is the current version.

TomJo2000 avatar Sep 12 '22 12:09 TomJo2000

Sorry for the git log mess, with the closing and reopening, it was a missclick. Anyway, I updated it to 0.11.1

D-Brox avatar Sep 12 '22 16:09 D-Brox

Also, could you answer https://github.com/termux/termux-packages/pull/11843#issuecomment-1239595889? Since it could simplify the build script even further if the function is not needed

D-Brox avatar Sep 12 '22 16:09 D-Brox

I just tested out the result from the latest CI run, it seems to work fine, but I had to manually create the $PREFIX/var/lock/ directory, otherwise it would crash with this message about being unable to create a lock file.

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/nala", line 8, in <module>
    sys.exit(main())
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/nala/__main__.py", line 50, in main
    raise error from error
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/nala/__main__.py", line 41, in main
    nala()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/typer/main.py", line 532, in wrapper
    return callback(**use_params)  # type: ignore
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/nala/nala.py", line 236, in _update
    sudo_check()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/nala/utils.py", line 368, in sudo_check
    NALA_LOCK_FILE.touch(exist_ok=True)
  File "/data/data/com.termux/files/usr/lib/python3.10/pathlib.py", line 1168, in touch
    self._accessor.touch(self, mode, exist_ok)
  File "/data/data/com.termux/files/usr/lib/python3.10/pathlib.py", line 331, in touch
    fd = os.open(path, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/usr/var/lock/nala.lock'

This might be a local issue on my end, but will need to be investigated before this can be merged

TomJo2000 avatar Sep 12 '22 23:09 TomJo2000

This might be a local issue on my end, but will need to be investigated before this can be merged

I guess the dir can be created in the postinst debscript, along with the other ones, of it doesn't exist. Tho that dir probably exists in most cases, since it's commonly used for lock files.

D-Brox avatar Sep 13 '22 02:09 D-Brox

I guess the dir can be created in the postinst debscript, along with the other ones, of it doesn't exist. Tho that dir probably exists in most cases, since it's commonly used for lock files.

Yeah, as I said, probably a local issue, it would still be best to create the directory if it is missing to prevent such an issue.

TomJo2000 avatar Sep 13 '22 05:09 TomJo2000

I was testing my patches directly on termux, seems like I need to add a pip dependency (python-debian) topyproject.toml, as it's not being installed by default.

D-Brox avatar Sep 20 '22 10:09 D-Brox

It's been almost a month, can someone review this please. At this rate Nala 0.12.0 will be released before this PR is merged. (To be fair, I also forgot about this PR)

Oh, and I'm still waiting for an answer about the use of termux_setup_python_crossenv

D-Brox avatar Oct 01 '22 19:10 D-Brox

I also noticed the old build script uses termux_setup_python_crossenv. I'd like to ask if this step is really needed, considering that nala doesn't compile anything arch dependent.

Python-crossenv is mainly used to allow cross-compilation of native libraries, so if nala doesn't have and native libraries it might not be needed. If it compiles and works fine without using python-crossenv then it can be dropped

Grimler91 avatar Oct 01 '22 20:10 Grimler91

With the current build recipe the files are installed to $TERMUX_PREFIX/local instead of $TERMUX_PREFIX for some reason.

I have no idea why pip is doing that. I could use pip install . --target=$PYTHONPATH and move the executable to $TERMUX_PREFIX/bin if you prefer.

The package should only contain nala's files. As it is right now it contains all the python dependencies as well (h11, httpcore, python-debian, ...) which will lead to issues later. Dependencies should either be separate packages, or be installed through pip

Ok, I will use pip install . --no-deps and install them with pip on the postinst script then.

D-Brox avatar Oct 05 '22 18:10 D-Brox

Ok, I found the issue with $TERMUX_PREFIX/local:

~~The solution is using the env variable $DEB_PYTHON_INSTALL_LAYOUT~~

D-Brox avatar Oct 06 '22 19:10 D-Brox

The solution is using the env variable $DEB_PYTHON_INSTALL_LAYOUT

Never mind, it installs on $TERMUX_PREFIX/lib/python3/dist-packages

Ok, so @Grimler91, the only way it can install on $TERMUX_PREFIX/lib/python${_PYTHON_VERSION}/site-packages is by using a virtualenv (so using termux_setup_python_crossenv like before), or patching sysconfig.py inside the termux builder.

I'd suggest doing the second option in the Dockerfile, so that this doesn't happen again in the future, but I can patch sysconfig.py on the build script or re-add the crossenv again just so we can finally merge this update.

A simple sed -i "s/prefix !=/prefix ==/g" /usr/lib/python*/sysconfig.py should do the trick

image image

D-Brox avatar Oct 07 '22 01:10 D-Brox

Using termux_setup_python_crossenv sounds like a better idea to me, a package shouldn't really modify the host files. If a user would abort the build then they would have a broken sysconfig.py file on their computer

Grimler91 avatar Oct 09 '22 10:10 Grimler91

Using termux_setup_python_crossenv sounds like a better idea to me, a package shouldn't really modify the host files. If a user would abort the build then they would have a broken sysconfig.py file on their computer

Yes, I noticed that. I ended up using a normal virtualenv instead of the crossenv, since it proved to be way faster while achieving that same desired result.

D-Brox avatar Oct 09 '22 13:10 D-Brox

@Grimler91 I think the update is now finally ready.

What's been done:

  • The patches were simplified following the modifications made by @volitank to increase termux compatibility.
  • Since nala now uses a pyproject.toml instead of a setup.py file, the installation method was simplified and doesn't use the deprecated python egg as before.
  • pip installs the deps from pyproject.toml packages by default, but those shouldn't be packaged inside the deb. The build script installs python deps with pip on the postinst script, as it was doing before.
  • To circunvent the distro dependent sysconfig.py issue, which makes pip install in /local/lib/python3.X/dist-packages, I used a dummy virtualenv to "trick" python into always installing in /lib/python3.X/site-packages. The venv from termux_setup_python_crossenv could also have been used, but it proved to be slower.
  • I also removed all unused variables, functions and patch files.

The next updates will probably not take this long, since they'll hopefully only change the version and hash (at least until the rust rewrite is released).

D-Brox avatar Oct 11 '22 15:10 D-Brox

@buttaface @Grimler91 @landfillbaby @2096779623 I'm taking the liberty to ping all termux reviewers as, for some reason, only Grimler91 is listed as a reviewer on this PR: image

D-Brox avatar Oct 30 '22 15:10 D-Brox

@xtkoba argued in https://github.com/termux/termux-packages/issues/12576#issuecomment-1291959034 that we should use termux_setup_python_crossenv for all python packages, so could you please add usage of that function again

Grimler91 avatar Oct 30 '22 19:10 Grimler91

@Grimler91 Anything else?

D-Brox avatar Oct 30 '22 19:10 D-Brox

@Grimler91 Anything else?

Otherwise it looks good to me, if CI build succeeds and files are installed to correct place. Will merge in ~12 h unless someone else has comments, thanks

Grimler91 avatar Oct 30 '22 20:10 Grimler91

Thanks!

Grimler91 avatar Oct 31 '22 07:10 Grimler91