Morganamilo / paru

Feature packed AUR helper
GNU General Public License v3.0
5.7k stars 222 forks source link

Issues with local repo / chroot activation #927

Open RubenKelevra opened 1 year ago

RubenKelevra commented 1 year ago

Affected Version

paru v1.11.2 - libalpm v13.0.2

Description

I want to use the Chroot function by paru:

I've enabled the settings LocalRepo and Chroot in the settings, by adding the following:

LocalRepo
Chroot = /var/lib/paru/aur_chroot

Issue One

Calling paru afterwards gave me the following output:

$ paru -Qem
error: no local repos configured, add one to your pacman.conf:
    [options]
    CacheDir = /var/lib/repo/aur

    [aur]
    SigLevel = PackageOptional DatabaseOptional
    Server = file:///var/lib/repo/aur

So I added the CacheDir entry and [aur] repo as first repo in the list of repos.

A call of paru now fails:

$ paru
2023-01-13 PHP 8.2 update and introduction of legacy branch
    The php packages have been updated to the latest version 8.2. In
    addition to this, a new set of php-legacy packages have been
    introduced. These will follow the oldest but still actively supported
    PHP branch. This enables users to install the latest version but also
    introduces the option to use third party applications that might rely
    on an older version. Both branches will be kept up to date following
    our rolling release model. php and php-legacy can be installed at the
    same time as the latter uses a -legacy suffix for its binaries and
    configuration files.

    In addition to this, the php7 packages have been removed as they
    reached end of life. The imap extension will no longer be provided as
    it relies on the c-client library which has been abandoned for many
    years.

:: Proceed with installation? [Y/n]: 
:: Synchronizing package databases...
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)

So I fixed that by creating the folder structure manually and touched the aur.db file.

Now the empty file seems to be enough for pacman/aur to accept it.

The man page states that this shouldn't be necessary:

$ man paru.conf
[...]
       LocalRepo [= Repos...]
              Use a local repo to build and upgrade AUR packages.

              Paru will act on packages in the enabled repos instead of foreign packages.
              The repo must already be declared in pacman.conf but does not have to already
              exist on disk.

              Optionally a list of repos to use can be passed. By default paru will
              consider all local repos, building new packages into the fist listed repo
              and upgrading the packages in other enabled repos.

[...]

Issue Two

The man page for paru.conf also lists, that I can specify the Repo explicitly, so I have tried that:

LocalRepo = /var/lib/repo/aur

Doing so will lead to paru outputting the following, despite that those information is already added to the pacman.conf file:

$ paru -Syu
error: no local repos configured, add one to your pacman.conf:
    [options]
    CacheDir = /var/lib/repo/aur

    [aur]
    SigLevel = PackageOptional DatabaseOptional
    Server = file:///var/lib/repo/aur

Issue Three

Because of Issue Two, I haven't specified the LocalRepo explicitly, and created the folder and the db file, because of Issue One, manually on disk.

Now all packages installed by Paru from the AUR are no longer recognized by Paru, so they won't receive any updates:

$ paru -S wine-stable-next
:: Resolving dependencies...
:: Calculating conflicts...
:: Calculating inner conflicts...

Aur (1)               Old Version  New Version  Make Only
aur/wine-stable-next               8.0rc4-1     No

:: Proceed with installation? [Y/n]:

Notice the missing Old Version entry.

wine-stable-next however is installed on my system in an older version:

$ paru -Qi wine-stable-next
warning: database file for 'aur' does not exist (use '-Sy' to download)
Name            : wine-stable-next
Version         : 8.0rc3-1
Description     : A compatibility layer for running Windows programs
[...]

So there's a new version available, but paru -Syu does not show an update available. In the man-page I couldn't find a way to fix this or hint how to regenerate the database containing this information... only the --gendb function is explained, but won't help here.

Config files:

paru.conf

[options]
PgpFetch
Devel
Provides
DevelSuffixes = -git -cvs -svn -bzr -darcs -always -hg -fossil
BottomUp
SudoLoop
UseAsk
CombinedUpgrade
UpgradeMenu
NewsOnUpgrade
SkipReview
FailFast
LocalRepo
Chroot = /var/lib/paru/aur_chroot
[bin]
FileManager = nnn

pacman.conf

[options]
CacheDir     = /var/cache/pacman/pkg/
CacheDir     = /var/lib/repo/aur/
HoldPkg      = pacman glibc
Architecture = auto
IgnorePkg = jre python2 libva-intel-driver jre11-openjdk jdk11-openjdk jre8-adoptopenjdk jdk8-adoptopenjdk jre11-openjdk-headless jre8-adoptopenjdk-headless ttf-google-fonts-git polari mutter-performance chrome-gnome-shell
NoExtract   = usr/lib/firefox/fonts/TwemojiMozilla.ttf
Color
ILoveCandy
CheckSpace
VerbosePkgLists
ParallelDownloads = 1
SigLevel    = Required DatabaseOptional
LocalFileSigLevel = Optional
RemoteFileSigLevel = Required
[aur]
SigLevel = PackageOptional DatabaseOptional
Server = file:///var/lib/repo/aur
[endeavouros]
SigLevel = PackageRequired
Include = /etc/pacman.d/endeavouros-mirrorlist
[core-x86-64-v3]
Include = /etc/pacman.d/alhp-mirrorlist
[extra-x86-64-v3]
Include = /etc/pacman.d/alhp-mirrorlist
[community-x86-64-v3]
Include = /etc/pacman.d/alhp-mirrorlist
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
[multilib]
Include = /etc/pacman.d/mirrorlist
[heftig]
SigLevel = Optional
Server = https://pkgbuild.com/~heftig/repo/$arch
[chaotic-aur]
Include = /etc/pacman.d/chaotic-mirrorlist
[core-debug]
Include = /etc/pacman.d/mirrorlist_debug
[extra-debug]
Include = /etc/pacman.d/mirrorlist_debug
[community-debug]
Include = /etc/pacman.d/mirrorlist_debug
[multilib-debug]
Include = /etc/pacman.d/mirrorlist_debug
Morganamilo commented 1 year ago

The optional arg to --localrepo takes the repo name not path. Im guess putting the path causes is to match nothing and then trigger the "no repos configured" code.

Also, the local repo mode makes paru work on your local repo not on what's installed. So paru will only update stuff already in the repo and old version will be nothing if it wasn't in the repo previously.

Issue one though, I don't know what's up as I can't reproduce. You should probably try paru-git and if that fails send some debug logs with PARU_DEBUG=1.

Morganamilo commented 1 year ago

The optional arg to --localrepo takes the repo name not path. Im guess putting the path causes is to match nothing and then trigger the "no repos configured" code.

This errors out now instead of failing confusingly

RubenKelevra commented 1 year ago

Okay, so I got have a system where this issue occours.

I did now the following:

error: no local repos configured, add one to your pacman.conf:
    [options]
    CacheDir = /var/lib/repo/aur

    [aur]
    SigLevel = PackageOptional DatabaseOptional
    Server = file:///var/lib/repo/aur

Now paru gives me:

$ paru
no new news
:: Synchronizing package databases...
 endeavouros is up to date
 core-x86-64-v3 is up to date
 extra-x86-64-v3 is up to date
 community-x86-64-v3 is up to date
 core is up to date
 extra is up to date
 community is up to date
 multilib is up to date
 chaotic-aur is up to date
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)

With debug I get the following:

$ paru
debug: <reqwest::connect> starting new connection: https://archlinux.org/
debug: <reqwest::async_impl::client> redirecting 'https://archlinux.org/feeds/news' to 'https://archlinux.org/feeds/news/'
debug: <reqwest::async_impl::client> response '200 OK' for https://archlinux.org/feeds/news/
debug: <alpm> loading package cache for repository 'local'
debug: <alpm> added 3215 packages to package cache for db 'local'
no new news
:: Synchronizing package databases...
 endeavouros is up to date
 core-x86-64-v3 is up to date
 extra-x86-64-v3 is up to date
 community-x86-64-v3 is up to date
 core is up to date
 extra is up to date
 community is up to date
 multilib is up to date
 chaotic-aur is up to date
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)
debug: <alpm> unregistering database 'local'
debug: <alpm> freeing package cache for repository 'local'
debug: <alpm> unregistering database 'endeavouros'
debug: <alpm> unregistering database 'core-x86-64-v3'
debug: <alpm> unregistering database 'extra-x86-64-v3'
debug: <alpm> unregistering database 'community-x86-64-v3'
debug: <alpm> unregistering database 'core'
debug: <alpm> unregistering database 'extra'
debug: <alpm> unregistering database 'community'
debug: <alpm> unregistering database 'multilib'
debug: <alpm> unregistering database 'chaotic-aur'
debug: <alpm> unregistering database 'aur'
Morganamilo commented 1 year ago

It may be the cause that paru will only make the repo on install and not upgrade. Try install an aur package.

RubenKelevra commented 1 year ago

@Morganamilo that's the result:

$ paru -S aur/paru
warning: database file for 'aur' does not exist (use '-Sy' to download)
error: target not found: paru
$ paru -Sy aur/paru
:: Synchronizing package databases...
 endeavouros is up to date
 core-x86-64-v3 is up to date
 extra-x86-64-v3 is up to date
 community-x86-64-v3 is up to date
 core is up to date
 extra                                                                                                                                                            1738.0 KiB   387 KiB/s 00:04 [-----------------------------------------------------------------------------------------------------------------------] 100%
 community                                                                                                                                                           7.2 MiB   483 KiB/s 00:15 [-----------------------------------------------------------------------------------------------------------------------] 100%
 multilib is up to date
 chaotic-aur                                                                                                                                                         2.3 MiB   516 KiB/s 00:05 [-----------------------------------------------------------------------------------------------------------------------] 100%
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)
gui-don commented 1 year ago

Same problem as author.

It may be the cause that paru will only make the repo on install and not upgrade. Try install an aur package.

This fixed it for me ^

paru --chroot -Sy paru

Maybe a setup command or something like that would help?

RubenKelevra commented 9 months ago
Error: no local repos configured, add one to your pacman.conf:
    [options]
    CacheDir = /var/lib/repo/aur

    [aur]
    SigLevel = PackageOptional DatabaseOptional
    Server = file:///var/lib/repo/aur
:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)
RubenKelevra commented 9 months ago

Same problem as author.

It may be the cause that paru will only make the repo on install and not upgrade. Try install an aur package.

This fixed it for me ^

paru --chroot -Sy paru

Maybe a setup command or something like that would help?

This does not help:

[ruben@v ~]$ LANG=en_US.UTF-8 paru --chroot -Sy paru
:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
 aur.db failed to download
error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (download library error)
Sohex commented 3 months ago

I ran into this as well and I was able to resolve it by doing the following:

  1. Add the repo and CacheDir settings as specified by the paru output (as seen above).
  2. Ensure that the repo directory, i.e. /var/lib/repo/aur, exists and is writable by your user.
  3. In the repo directory touch aur.db
  4. Try to install an aur package, e.g. youtube-dl. This will fail with a readlink error, but only after building the package.
  5. In the repo directory rm aur.db and then repo-add aur.db.tar.gz youtube-dl...zst. This will create a proper package database including the previously built package. Presumably you could skip some of the above by jumping to this and just using a package you built with makepkg, but I haven't tried that.
  6. Run the install again and it will succeed.

At that point paru seems to be working correctly using the chroot as intended.

SuibianP commented 2 months ago

To avoid the readlink error, touch aur.db.tar.gz and soft link aur.db to it instead.

According to Arch wiki,

A package database is a tar file, optionally compressed. Valid extensions are .db or .files followed by an archive extension of .tar, .tar.gz, .tar.bz2, .tar.xz, .tar.zst, or .tar.Z.

https://github.com/Morganamilo/paru/blob/5355012aa3529014145b8940dd0c62b21e53095a/src/repo.rs#L31

Paru assumes that it is a symbolic link and calls std::fs::read_link which fails if it is not.

RubenKelevra commented 1 week ago

@Sohex & @SuibianP thanks! This solution combined works for me.

@Morganamilo can we get this automatically setup if the user configures chroot builds?

RubenKelevra commented 1 week ago

I found that paru -Sccd will actually break the setup.

Afterwards the aur.db and the aur.db.tar.gz are gone, so paru will report:

error: failed retrieving file 'aur.db' from disk : Couldn't open file /var/lib/repo/aur/aur.db
error: failed to synchronize all databases (unexpected error)
error: failed to run: sudo arch-nspawn -C /tmp/.tmpzCtIuZ -M /etc/makepkg.conf /var/lib/paru/aur_chroot/root --bind-ro /var/lib/repo/aur --bind /var/lib/repo/aur --bind /var/cache/pacman/pkg/ pacman -Syu --noconfirm: