Commit graph

7283 commits

Author SHA1 Message Date
Allan McRae
845dadf183 _cache_mtree_open: remove unused variable
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-04 07:56:00 +10:00
Allan McRae
dfee773364 clean_filename: use strdup instead of malloc and memcpy
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-04 07:56:00 +10:00
Allan McRae
c64f898c48 _alpm_pkg_load_internal: remove unneeded if statement
This statement is always true due to an earlier test.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-04 07:56:00 +10:00
Allan McRae
16a2a79728 libalpm/signing.c: prevent underflow in length_check
The length_check function could underflow if the provided buffer index
is greater than the signature buffer length, leading to an out of
bounds read.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-04 07:54:12 +10:00
Allan McRae
6711d10f96 pacman/conf.c: fix leak on error in setdefaults()
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-04 07:49:08 +10:00
Allan McRae
36fcff6e13 pacman/util.c: fix user after free in print_packages
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-01-26 18:13:11 +10:00
Allan McRae
3c28c30133 Fix typo in exporting RUSTFLAGS
Fixes #77

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-01-14 08:50:29 +10:00
Ronan Pigott
4c93e63ddf add.c: drop newline in permission and ownership log messages
These are the only log messages produced by pacman that include an
embedded newline, and it looks very incongruous in a typical pacman.log.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-01-10 08:52:35 +10:00
Allan McRae
f69d9b4475 makepkg: only check software once
Move the checks for software and gpg signing ability to after the
fakeroot section so that it is only executed once. This also fixes
gpg (lack of) interaction under fakeroot.

Fixes #69

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-01-09 22:42:45 +00:00
Andrew Gregory
42fa74e91a free handle resources before running scripts
The primary purpose of this is to allow cleanup of file descriptors
allocated by curl that were left open in the child.  I am not aware of
any issues caused by the open file descriptors, but think it better to
not leave random open fd's lying around.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2024-01-09 22:39:14 +00:00
Andrew Gregory
929bad61c0 _alpm_handle_free: free all in-memory resources
Freeing handle resources was previously split awkwardly between
_alpm_handle_free and alpm_release.  This consolidates the freeing of
all in-memory resources to _alpm_handle_free, leaving alpm_release as a
thin wrapper that provides safety checks and frees any external
resources, e.g. removing lock files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2024-01-09 22:39:14 +00:00
Morten Linderud
00d2b1f902
strip: don't create debug packages from .a files
.a files are not valid ELF files so we can't run objcopy nor debugedit
on them.

Rename STRIPLTO to STATICLIB to be more descriptive.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2023-12-17 16:04:45 +01:00
Morten Linderud
7a4fff3310
strip: split off file stripping and debug package creation
Some projects might duplicate the file in multiple locations for one
reason or another. When debug packages are enabled, `makepkg` will only
strip the first occurrence of the binary and abort early on all the
other binaries.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2023-12-17 16:04:45 +01:00
morganamilo
8d38746586
libalpm: fix check_pgp_signature docs
The function did have these return values a long time ago but now only
return 0 or -1.
2023-12-04 15:34:49 +00:00
Andrew Gregory
0df44c2e20 db.c: set pm_errno for server list modifications
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
dc91476555 pacman: add cache server support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
bad3e13eaa conf.c: remove unnecessary _add_mirror function
It does very little, is only used in one place, and can't easily be
reused for other server types due to the inclusion of an error message.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
45e94e2dae pmtest: return pkg from addpkg2db
Allows more compact syntax:

p1 = self.addpkg2db('sync', pmpkg("foo"))

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
3aa1975c1d alpm: add cache server support
Cache servers differ from regular servers in that they do not produce
warnings and are not removed from the server pool for "soft errors"
(i.e. the server was reachable, but the download failed) and they are
not used for databases.  If a host is used for both a cache server and a
regular server, it may still be removed from the server pool for soft
errors that occur when used as cache server and removal from the server
pool for soft errors will not affect future attempted use as a cache
server.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
56626816b6 dload: differentiate between hard and soft errors
Set error count to -1 to indicate a hard error to allow them to be
treated differently.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Allan McRae
0f512ae46e Do not increment on every database error to avoid overflow
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-12-02 04:55:29 +00:00
Allan McRae
d56e9ed083 Increment error count on filelist conflicts in local database
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-12-02 04:55:29 +00:00
Andrew Gregory
2d190d5a33 meson.build: add _FILE_OFFSET_BITS to pkgconfig
Meson automatically sets _FILE_OFFSET_BITS but that value was not
getting carried through to the libalpm pkgconfig file, breaking
downstream projects that relied on it.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-11-25 13:05:00 -08:00
Andrew Gregory
2e23126e2a remove unused pkgconfig template
libalpm uses meson's pkgconfig module which does not use the template
file.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-11-25 13:04:56 -08:00
Levente Polyak
18e49f2c97
debugflags: ensure to only append debug flags once when building
During a package build we call prepare_buildenv in multiple stages of
the process. For debug packages, one of the hooks is buildenv_debugflags
which populates the debug flags to the according variables.

The issue is that the behavior of the current implementation of
buildenv_debugflags is not idempotent, so consecutive calls will append
the same flags again. In certain cases this isn't an issue, however
for context aware build frontends like cargo any change of the build
inputs leads to a fresh build. This means that any invocation of such
a build ecosystem inside the package() function will trigger a full
rebuild, which is not desired.

To fix this issue, this commit makes buildenv_debugflags idempotent
by only appending flags once to the target variables.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-11-17 18:56:44 +01:00
Patrick Northon
0108e2c64e Omit trailing .git from url when comparing git remote urls. 2023-11-04 10:09:59 +10:00
Diego Viola
94d9c2affe doc/PKGBUILD: fix typo
Signed-off-by: Diego Viola <diego.viola@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-11-04 00:03:23 +00:00
morganamilo
6e9ab43451 Document MAKEPKG_LIBRARY in makepkg(8) 2023-11-04 00:02:17 +00:00
morganamilo
9af4033cad Rename LIBRARY to MAKEPKG_LIBRARY
Implements #59.
2023-11-04 00:02:17 +00:00
Vekhir
31ffbc94ca Delete entire $srcdir upon clean build
Currently, the file glob used to clean the $srcdir misses dotfiles.

This commit instead removes the directory entirely and recreates it.
Since the directory has to exist prior to deletion, the creation commands
are duplicated. Perhaps they could be moved to a function later on.

The directory cannot be removed while inside it, so the directory change
is moved down the line. One important insight here is that almost all functions
after it are actually independent of $pwd, allowing the optimization of just
not changing directory. They do however depend on the existence of $srcdir, so
it has to be recreated.
The only exception to this is `extract_sources` which depends on $pwd being $srcdir.

An alternative proposal wanted to extend the file matching for deletion, but it
was deemed impractical.
2023-11-04 00:01:22 +00:00
Jack Rosenthal
e9b385a636 alpm: Don't chroot() to "/"
chroot() requires CAP_SYS_CHROOT.  If the caller has put us in the
right root directory already, don't call chroot().  This allows
running pacman in a containerized environment without CAP_SYS_CHROOT.
2023-10-23 12:13:10 +00:00
morganamilo
917b67f5d1 Fix -D in package()
When entering fakeroot makepkg calls itself with it's original args
causing it to cd again and error
2023-10-20 22:40:44 +01:00
Morten Linderud
331b277eea makepkg: Implement the verify function
This patch implements a new verify function in makepkg. It allows us to
do arbitrary authentication on sources before extraction.

There are several new signing and validation methods being implemented
and it would be hard to have `makepkg` implement support for things such
as sequoia, cosign or minisign. This would allow us to distribute
generic validation functions.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2023-10-02 05:12:12 +00:00
Felix Yan
30f9a2e263 Correct typos in zsh_completion.in 2023-10-02 04:34:24 +00:00
morganamilo
aff12189d8 libalpm: check filecache_find return and log errors
Some user had erros while updating their system.

:: Proceed with installation? [Y/n]
:: Retrieving packages...
checking keyring...
checking package integrity...
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

The issue was filecache_find returning null and alpm passing that null
path to check validity. How this happened I have no idea. It may be
something to do with the user's cachedir being a network drive.

Also warn when the file exists but it is not a regular file or can not
be opened.
2023-09-30 13:28:31 +00:00
Allan McRae
332d2a1922 repo-add: clarify exit messages
Clarify if repo-add does not create a new database due to failures
or due to there being nothing to do.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-30 23:27:04 +10:00
Ivan Shapovalov
f91fa546f6 repo-add: do not recreate the database if nothing was changed
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-30 23:18:41 +10:00
morganamilo
b4f11d5496 alpm: test access of symlinks not where they point
On platforms that have AT_SYMLINK_NOFOLLOW

Fixes FS#69720
2023-09-26 03:37:49 +00:00
morganamilo
015cdb21bd
Fix unused variable warning 2023-09-20 04:32:21 +01:00
Xiretza
05f283b5ad tests: fix order of fakechroot + fakeroot nesting
As noted in the fakechroot(1) man page, fakeroot and fakechroot
might wrap the same C library functions. Arch Linux hit this
recently with calls to stat(). It is important to start the fake
environment in proper order - fakeroot should be started inside
fakechroot.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-19 17:55:24 +10:00
Finlay Maroney
34611a6643 Avoid double slash when explicitly passing --root or --rootdir
Passing a path with a trailing slash to --root or --rootdir can lead to a
double slash at the start of paths.  e.g.

$ pacman --root / -v 2>1  | grep " //"
Log File  : //var/log/pacman.log

In MSYS2, paths starting with // will hit the network and fail.

Avoid this be explicitly stripping the trailing / from paths passed to these
flags.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-12 14:22:36 +10:00
Robin Candau
76b140c72a Replace the bzr package by breezy for the bzr protocol in makepkg.conf 2023-09-11 19:11:40 +02:00
Matthew Sexton
5f43ac85f6 specify which files are updated by --refresh option
Ref: FS#77697

Signed-off-by: Matthew Sexton <mssxtn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-11 22:59:53 +10:00
morganamilo
0dfe5c96ae makepkg: add -D flag to change directory before building
This is similar to -C in git/make/nina. Sadly -C is already taken for
us.

This is useful for scripts where you for loop over packages, as well as
when I'm testing makepkg builds and I'm too lazy to cd.
2023-09-09 11:52:11 +10:00
InsanePrawn
36d70a93e2 pacman-key: allow overriding KEYRING_IMPORT_DIR with --populate-from
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-07 00:12:41 +10:00
Allan McRae
717e5e9157 Add PRINT_FORMAT_LIST define to remove repetitive code
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Allan McRae
e7d7433b4b Rename macro for print-format handling of strings
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
e210634982 util.c: extend --print-format with "%m"
Add md5sum as printable format string.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
6968f77026 util.c: extend --print-format with "%G"
Add a new print attribute "%G" which prints groups.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
06db927a1a util.c: extend --print-format with "%H"
Add a new print attribute "%H" which shows conflicts.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
2023-09-06 17:56:55 +10:00