pacman/lib/libalpm
Stephan Brunner 5882e21806
Use flocks to lock the database instead of purely relying on file existence.
With PackageKit or pacman itself, it sometimes occurs that the lock
file is left over erroneously. A manual administrative
    $ rm /var/lib/{pacman,PackageKit/alpm}/db.lck
is required.
This is also the preferred way to fix this issue as per the Wiki [1][2].

This is not really user-friendly when it happens, and has bothered me
personally about five or six times now to a point where I hacked this patch.

The lock file can now preexist when using libalpm, and libalpm now flock()s
the file exclusively. Linux ensures internally that no second exclusive lock
can be held. However, we still can't get rid of the unlink when unlocking
altogether, because existing bash scripts (e.g. makepkg.sh) depend on it.
Refactoring those to use flocks would be quite a mess, too. But because the
lock file should normally not exist without any lock on it, the scripts would
simply say that someone holds the lock. Refreshing the pacman database now fixes
the issue on it's own. This is now also user triggerable when using
PackageKit :)

[1] https://wiki.archlinux.org/title/Pacman
    3.3 "Failed to init transaction (unable to lock database)" error
[2] https://wiki.archlinux.org/title/KDE
    6.15 Discover stops showing updates from Arch repositories

Signed-off-by: Stephan Brunner <s.brunner@stephan-brunner.net>
2024-04-21 18:45:57 +02:00
..
po Update bug report URL in tranlsation configuration files 2024-03-19 12:02:44 +10:00
.gitignore libalpm: add pkg-config file 2012-04-25 20:02:36 -04:00
add.c Update copyright years 2024-02-24 18:40:44 +10:00
add.h Update copyright years 2024-02-24 18:40:44 +10:00
alpm.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
alpm.h Provide function for switching user in child processes 2024-04-01 20:52:55 +00:00
alpm_list.c Update copyright years 2024-02-24 18:40:44 +10:00
alpm_list.h Update copyright years 2024-02-24 18:40:44 +10:00
backup.c Update copyright years 2024-02-24 18:40:44 +10:00
backup.h Update copyright years 2024-02-24 18:40:44 +10:00
base64.c base64.c: comment out unused variable 2014-01-15 15:54:56 +10:00
base64.h Do not #define _RESERVED_IDENTIFIERS 2016-09-25 18:04:57 +10:00
be_local.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
be_package.c Update copyright years 2024-02-24 18:40:44 +10:00
be_sync.c Download to a temporary directory owned by the Download user 2024-04-01 20:52:55 +00:00
conflict.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
conflict.h Update copyright years 2024-02-24 18:40:44 +10:00
db.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
db.h Update copyright years 2024-02-24 18:40:44 +10:00
deps.c Update copyright years 2024-02-24 18:40:44 +10:00
deps.h Update copyright years 2024-02-24 18:40:44 +10:00
diskspace.c Update copyright years 2024-02-24 18:40:44 +10:00
diskspace.h Update copyright years 2024-02-24 18:40:44 +10:00
dload.c Restore partially downloaded files to the temporary directory 2024-04-01 20:52:55 +00:00
dload.h Download to a temporary directory owned by the Download user 2024-04-01 20:52:55 +00:00
error.c Update copyright years 2024-02-24 18:40:44 +10:00
filelist.c Do not pass NULL paramenter to bsearch with empty filelist 2024-04-05 00:35:08 +00:00
filelist.h Update copyright years 2024-02-24 18:40:44 +10:00
graph.c Update copyright years 2024-02-24 18:40:44 +10:00
graph.h Update copyright years 2024-02-24 18:40:44 +10:00
group.c Update copyright years 2024-02-24 18:40:44 +10:00
group.h Update copyright years 2024-02-24 18:40:44 +10:00
handle.c Use flocks to lock the database instead of purely relying on file existence. 2024-04-21 18:45:57 +02:00
handle.h Add DownloadUser configuration option 2024-04-01 20:52:55 +00:00
hook.c Update copyright years 2024-02-24 18:40:44 +10:00
hook.h Update copyright years 2024-02-24 18:40:44 +10:00
libarchive-compat.h Update copyright years 2024-02-24 18:40:44 +10:00
log.c Update copyright years 2024-02-24 18:40:44 +10:00
log.h Update copyright years 2024-02-24 18:40:44 +10:00
meson.build Add callbacks for sandboxed operations 2024-04-01 20:52:55 +00:00
package.c Update copyright years 2024-02-24 18:40:44 +10:00
package.h Update copyright years 2024-02-24 18:40:44 +10:00
pkghash.c Update copyright years 2024-02-24 18:40:44 +10:00
pkghash.h Update copyright years 2024-02-24 18:40:44 +10:00
rawstr.c Remove all modelines from the project 2018-05-14 09:59:15 +10:00
remove.c unlink_file: restore trailing slash on directory before checking mountpoint 2024-04-05 00:51:13 +00:00
remove.h Update copyright years 2024-02-24 18:40:44 +10:00
sandbox.c Add callbacks for sandboxed operations 2024-04-01 20:52:55 +00:00
sandbox.h Add callbacks for sandboxed operations 2024-04-01 20:52:55 +00:00
signing.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
signing.h Update copyright years 2024-02-24 18:40:44 +10:00
sync.c Download to a temporary directory owned by the Download user 2024-04-01 20:52:55 +00:00
sync.h Update copyright years 2024-02-24 18:40:44 +10:00
trans.c use snprintf instead of sprintf 2024-03-25 13:24:41 +10:00
trans.h Update copyright years 2024-02-24 18:40:44 +10:00
util.c _alpm_archive_fgets(): bail early if reached end of block 2024-04-08 10:34:10 +00:00
util.h Download to a temporary directory owned by the Download user 2024-04-01 20:52:55 +00:00
version.c Update copyright years 2024-02-24 18:40:44 +10:00