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

[pkg update error: At least one invalid signature was encountered.] coreutils: cp: failed to clone, breaking apt update (was: mv does not work any more?)

Open angelog0 opened this issue 1 year ago • 47 comments

Description revised by moderator.

TL;DR

Try https://github.com/termux/termux-packages/issues/15706#issuecomment-1477819107 if your pkg update does not work.

Problem description

  • cp command fails with message "failed to clone ..."

  • apt-get update (pkg update) fails with message "At least one invalid signature was encountered."

What steps will reproduce the bug?

$ touch $PREFIX/tmp/issue15706-foo
$ cp $PREFIX/tmp/issue15706-foo $PREFIX/tmp/issue15706-bar
cp: failed to clone '/data/data/com.termux/files/usr/tmp/issue15706-bar' from '/data/data/com.termux/files/usr/tmp/issue15706-foo': Permission denied
$ pkg update
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[*] https://packages-cf.termux.dev/apt/termux-main/: ok
Get:1 https://packages-cf.termux.dev/apt/termux-main stable InRelease [14.0 kB]
Get:2 https://packages-cf.termux.dev/apt/termux-x11 x11 InRelease [14.0 kB]
Err:1 https://packages-cf.termux.dev/apt/termux-main stable InRelease
  At least one invalid signature was encountered.
Err:2 https://packages-cf.termux.dev/apt/termux-x11 x11 InRelease
  At least one invalid signature was encountered.
Fetched 28.0 kB in 3s (8889 B/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages-cf.termux.dev/apt/termux-main stable InRelease: At least one invalid signature was encountered.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages-cf.termux.dev/apt/termux-x11 x11 InRelease: At least one invalid signature was encountered.
W: Failed to fetch https://packages-cf.termux.dev/apt/termux-main/dists/stable/InRelease  At least one invalid signature was encountered.
W: Failed to fetch https://packages-cf.termux.dev/apt/termux-x11/dists/x11/InRelease  At least one invalid signature was encountered.
W: Some index files failed to download. They have been ignored, or old ones used instead.

Original description follows.


Problem description

After last update (with coreutils...) it seems that mv does not work

What steps will reproduce the bug?

cd
touch foo
mv foo storage/downloads/
mv: failed to clone 'storage/downloads/foo' from 'foo': Permission denied

I maintain Termux updated, daily..

The above, yesterday worked..

What is the expected behavior?

No response

System information

termux-info:

Termux Variables:
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=29073
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages.termux.dev/apt/termux-main stable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/21 termux extras
Updatable packages:
All packages up to date
termux-tools version:
1.37.0
Android version:
11
Kernel build information:
Linux localhost 4.9.227-22521289 #2 SMP PREEMPT Wed Jan 11 17:40:49 +07 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-T725
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so

angelog0 avatar Mar 20 '23 23:03 angelog0

Also cp now has the same defect...

angelog0 avatar Mar 20 '23 23:03 angelog0

Same error for me, I updated coreutils and now nothing works. Even apt update is not working now. But busybox utils seems to be working.

alexfarseer avatar Mar 21 '23 03:03 alexfarseer

It might be best to revert the last commit(s) to the coreutils package until the issue can be root caused.

Probably best to also go ahead and tag @landfillbaby.

TomJo2000 avatar Mar 21 '23 03:03 TomJo2000

Not reproducible for me.

Can anyone share the strace -f output of the failing command? Not sure but it is possible that the command in the new coreutils uses some syscalls that are not supported (or not allowed) in some environment.

[EDIT] I can reproduce this now.

xtkoba avatar Mar 21 '23 04:03 xtkoba

Excerpt from strace output:

openat(AT_FDCWD, "foo", O_WRONLY|O_TRUNC) = 4
ioctl(4, BTRFS_IOC_CLONE or FICLONE, 3) = -1 EACCES (Permission denied)

[EDIT] See below.

xtkoba avatar Mar 21 '23 04:03 xtkoba

The error shown in https://github.com/termux/termux-packages/issues/15706#issuecomment-1477266934 itself seems to occur also with coreutils 9.1. Seems like error handling has been changed.

xtkoba avatar Mar 21 '23 04:03 xtkoba

Reproducible for me with cp, but not with mv.

A workaround (until fix or revert) seems to be to replace $PREFIX/bin/cp with the following shell script:

#!/bin/sh
exec coreutils --coreutils-prog=cp --reflink=never "$@"

Alternatively cp from busybox can be used instead, as mentioned above.

xtkoba avatar Mar 21 '23 04:03 xtkoba

This should preferably be addressed quickly before most people update to the faulty version of coreutils, since if I'm interpreting your previous comment correctly, manual intervention may be needed to resolve the issue.

TomJo2000 avatar Mar 21 '23 04:03 TomJo2000

Yes, because this breaks apt functionality, as you mentioned in another issue.

xtkoba avatar Mar 21 '23 05:03 xtkoba

At the risk of causing myself a headache, I'll go do some testing on this issue in order to produce to detailed remediation procedure.

TomJo2000 avatar Mar 21 '23 05:03 TomJo2000

Fixed for me with coreutils version 9.2-1.

If you still see this type of failure, then please share the strace -f output of the failing command.

Keeping this open for now, as the impact of this issue is unmeasurable.

xtkoba avatar Mar 21 '23 05:03 xtkoba

curl -OLs https://packages-cf.termux.dev/apt/termux-main/pool/main/c/coreutils/coreutils_9.2-1_aarch64.deb
dpkg -i coreutils_9.2-1_aarch64.deb

To restore from a broken state without nuking the entire $PREFIX

truboxl avatar Mar 21 '23 06:03 truboxl

If pckg upgrade does not work as described in #15710, how can we fix it?

Which are, exactly, the steps we have to follow? TIA.

angelog0 avatar Mar 21 '23 08:03 angelog0

curl -OLs https://packages-cf.termux.dev/apt/termux-main/pool/main/c/coreutils/coreutils_9.2-1_aarch64.deb
dpkg -i coreutils_9.2-1_aarch64.deb

To restore from a broken state without nuking the entire $PREFIX

@angelog0 see turboxl's comment above. (also pckg upgrade would be a typo)

TomJo2000 avatar Mar 21 '23 08:03 TomJo2000

@xtkoba that is not what happened to me and it is not even remotely related also cp and mv are still working

yirod3721 avatar Mar 21 '23 09:03 yirod3721

also the solution is for aarch64 devices while my device is also arm

yirod3721 avatar Mar 21 '23 10:03 yirod3721

@yirod3721 If coreutils are broken, the package manager also won't work.

I guess you know that all Termux mirrors around the world just can't be down at same time.

For arm:

curl -OLs https://packages-cf.termux.dev/apt/termux-main/pool/main/c/coreutils/coreutils_9.2-1_arm.deb
dpkg -i coreutils_9.2-1_arm.deb

sylirre avatar Mar 21 '23 10:03 sylirre

The same goes for arm arch. Just get a working DEB from somewhere (preferably from our primary server) and install it with dpkg -i.

If you are a skilled user then you can alternatively do what I wrote in https://github.com/termux/termux-packages/issues/15706#issuecomment-1477277128, or

test -x /system/bin/cp && ln -sfT /system/bin/cp $PREFIX/bin/cp

xtkoba avatar Mar 21 '23 10:03 xtkoba

@sylirre @xtkoba i download the new coreutils but i keep getting the same error and i know that they cant be all be down at the same time but they still wont work

yirod3721 avatar Mar 21 '23 10:03 yirod3721

and what does it mean that they are not signed?

yirod3721 avatar Mar 21 '23 10:03 yirod3721

It means your Termux can't verify signature.

All Termux repositories functioning correctly and are signed properly. Still have doubts? See below:

Screenshot_20230321-122335

sylirre avatar Mar 21 '23 10:03 sylirre

how do i make my termux verify signature and i dont disagree with you on the fact that they arent signed

yirod3721 avatar Mar 21 '23 10:03 yirod3721

and i still believe this is a separate issue because the listed answers didnt help me nor was the same problem present

yirod3721 avatar Mar 21 '23 10:03 yirod3721

@yirod3721 Possibly due to clock skew? It is true that pkg up can be broken for various reasons. Please open a NEW issue, with your termux-info output.

xtkoba avatar Mar 21 '23 10:03 xtkoba

and what does it mean that they are not signed?

ordinarily packages have their cryptographic signature verified when being installed from a repository, this verification may fail if the keys don't match, or in this case, if apt isn't behaving as expected due to issues with coreutils

You can skip the verification step by installing a package from a local .deb files using dpkg -i /path/to/file.deb

You can download an updated version of the coreutils package from https://packages.termux.dev/apt/termux-main/pool/main/c/coreutils/ As turboxl said earlier, you can use:

curl -OLs https://packages-cf.termux.dev/apt/termux-main/pool/main/c/coreutils/coreutils_9.2-1_$(uname -m).deb
dpkg -i coreutils_9.2-1_$(uname -m).deb

To do this.

TomJo2000 avatar Mar 21 '23 10:03 TomJo2000

@TomJo2000 uname -m will output armv7l or armv8l for ARM 32 bit which is not correct for our packages (we use just arm as arch name).

sylirre avatar Mar 21 '23 10:03 sylirre

shoot did not consider that

TomJo2000 avatar Mar 21 '23 10:03 TomJo2000

Some mirrors still distribute coreutils that broken.

Fix posted above works:

Screenshot_20230321-123450

I'm in doubt that @yirod3721 has different issue.

sylirre avatar Mar 21 '23 10:03 sylirre

sorry as stated above, the following in bash or a failsafe shell will fix the problem i caused (other shells probably have different syntax)

(deb="coreutils_9.3_$(dpkg --print-architecture).deb"
curl -LO "https://packages-cf.termux.dev/apt/termux-main/pool/main/c/coreutils/$deb"
dpkg -i "$deb"
rm -v "$deb")

landfillbaby avatar Mar 21 '23 11:03 landfillbaby

Replace $(uname -m) with $(dpkg --print-architecture).

xtkoba avatar Mar 21 '23 11:03 xtkoba