void-linux / xbps

The X Binary Package System (XBPS)
https://voidlinux.org/xbps/
Other
817 stars 124 forks source link

Some strange bug where xbps-rindex cant access a path #519

Closed MiloLug closed 1 year ago

MiloLug commented 2 years ago

So I just tried to rindex my xbps-src's hostdir and I got left in complete confusion:

xbps-rindex -r hostdir/    # OK (though it's not even a repo dir, but I wanted to try)
xbps-rindex -r hostdir/binpkgs/    # not OK
xbps-rindex: failed to open hostdir/binpkgs/: No such file or directory
xbps-rindex -r "hostdir/binpkgs/"    # not OK
xbps-rindex: failed to open hostdir/binpkgs/: No such file or directory

cd hostdir/binpkgs/
xbps-rindex -r .    # OK

And the most interesting part here, when it works even with unreal path:

xbps-rindex -r jadhfladjfhaldjfhlajfhad    # OK

I just assumed it's some permissions problem, but it just refuses to work with the given path.

hostdir stats:

drwxrwxrwt  5 liava liava  4096 Sep 24 18:43 hostdir

binpkgs stats:

drwxrwxrwt  3 liava liava  4096 Nov 18 06:20 binpkgs
classabbyamp commented 2 years ago

can you post a log for xbps-rindex -d -r hostdir/binpkgs?

MiloLug commented 2 years ago

Ohh my, sorry.. I forget it requires absolute paths. Here are the logs. But maybe I should close the issue

[DEBUG] XBPS: 0.59.1 API: 20200221 GIT: UNSET
[DEBUG] Processing configuration directory: /etc/xbps.d
[DEBUG] Parsing configuration file: /etc/xbps.d/10-ignore.conf
[DEBUG] Added ignored package: linux-firmware-amd
[DEBUG] Added ignored package: linux-firmware-broadcom
[DEBUG] Added ignored package: linux-firmware-network
[DEBUG] Added ignored package: ipw2100
[DEBUG] Added ignored package: ipw2200
[DEBUG] Processing system configuration directory: /usr/share/xbps.d
[DEBUG] Parsing configuration file: /usr/share/xbps.d/00-repository-main.conf
[DEBUG] [repo] `https://repo-default.voidlinux.org/current' stored successfully
[DEBUG] /usr/share/xbps.d/00-repository-main.conf: added repository https://repo-default.voidlinux.org/current
[DEBUG] Parsing configuration file: /usr/share/xbps.d/10-repository-nonfree.conf
[DEBUG] [repo] `https://repo-default.voidlinux.org/current/nonfree' stored successfully
[DEBUG] /usr/share/xbps.d/10-repository-nonfree.conf: added repository https://repo-default.voidlinux.org/current/nonfree
[DEBUG] Parsing configuration file: /usr/share/xbps.d/void-virtualpkgs.conf
[DEBUG] Parsing configuration file: /usr/share/xbps.d/xbps-arch.conf
[DEBUG] /usr/share/xbps.d/xbps-arch.conf: native architecture set to x86_64
[DEBUG] Parsing configuration file: /usr/share/xbps.d/xbps.conf
[DEBUG] rootdir=/
[DEBUG] metadir=/var/db/xbps
[DEBUG] cachedir=/var/cache/xbps
[DEBUG] confdir=/etc/xbps.d
[DEBUG] sysconfdir=/usr/share/xbps.d
[DEBUG] syslog=true
[DEBUG] bestmatching=false
[DEBUG] keepconf=false
[DEBUG] Architecture: x86_64
[DEBUG] Target Architecture: (null)
[DEBUG] Repository[0]=https://repo-default.voidlinux.org/current
[DEBUG] Repository[1]=https://repo-default.voidlinux.org/current/nonfree
[DEBUG] [repo] `hostdir/binpkgs/x86_64-stagedata' open stagedata No such file or directory
xbps-rindex: failed to open hostdir/binpkgs: No such file or directory
Duncaen commented 2 years ago

There is a bug, xbps-rindex -r will chdir(2) into the specified directory and then opendir(3) the same path, so it doesn't work if the path is relative unless its just ..

https://github.com/void-linux/xbps/blob/c7a88e5013ba1ab618557d39598700cd10815ac9/bin/xbps-rindex/remove-obsoletes.c#L131-L142

Duncaen commented 2 years ago

And the most interesting part here, when it works even with unreal path:

xbps-rindex -r jadhfladjfhaldjfhlajfhad    # OK

This "works" because xbps-rindex exits with 0 when the directory is not a repository (no *-repodata) for the current architecture. I don't think we should change this except maybe print a warning message, if we make this a non-zero exit status then scripts would have to start handle this different than real errors. Our scripts tend to run xbps-rindex -r on a number of directories for each architecture so we don't have to add special cases.