Commit graph

7209 commits

Author SHA1 Message Date
Jelle van der Waa
00bc386d5a util.c: extend --print-format with %b for builddate
Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-07-21 19:56:18 +10:00
Allan McRae
7bcc2d9b23 Correctly handle failure in getting build or install dates
alpm_pkg_get_builddate() and alpm_pkg_get_installdate() both return -1 on
error. Correctly handle the error condition in pacman.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-07-21 19:50:10 +10:00
Jelle van der Waa
819a0c2986 util.c: extend --print-format with expac options
Extend --print-format with all expac format strings which can be easily
added without conversions and through a simple C macro.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-07-21 19:09:59 +10:00
Andrew Gregory
6dcd4b5383 makepkg: store pkgtype in xdata
Package type is not relevant to alpm or even exposed to front-ends in
any way.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2022-07-21 19:01:45 +10:00
Andrew Gregory
fe028c7f6a query: print extended data when extra info is requested
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2022-07-21 19:01:38 +10:00
Andrew Gregory
3405709b46 add extended data field for arbitrary package data
This adds a mechanism for package builders to add arbitrary data to
packages that is not necessarily relevant enough to the package
installation process to gain first-class support in alpm.  Currently
these fields have to be added to parsers with a "not actually used"
comment and can't be retrieved through the API.

Extended data is stored in "name=value" format in the xdata field
(%XDATA% in desc files):

xdata = pkgtype=debug

or

%XDATA%
pkgtype=debug

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2022-07-21 19:01:27 +10:00
Allan McRae
2bf67416c1 Fix remaining email list address
One instance was missed in b0a2fd75b2.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-06-25 22:59:20 +10:00
Jean Raby
6daeb37fe8 pacman: silence "info" msg when using --print
This allows for parsing the output of:
    pacman --upgrade --print-format '<format>' pkg.zst

without having to remove info messages from it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-06-25 22:45:00 +10:00
Morten Linderud
776b7c1e75 debugflags: Ensure we have unique source paths
In some cases packages are built outside of a directory which contains
pkgname-pkgver, this results in source listing in debug packages having
a conflicting path like `/usr/src/debug/build/` which is not ideal.

This patch ensures we always include the pkgbase to ensure the paths are
unique.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-06-25 10:45:04 +10:00
Levente Polyak
0031cd1e46 doc/BUILDINFO.5: document buildtool and buildtoolver properties
The feature has been introduced in commit a33cdac10b
The buildinfo version has been bumped in commit 0428f6213b

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2022-06-25 10:25:36 +10:00
Allan McRae
d1e95c4e54 Gitlab CI: Install glibc-debug valgrind test
Currently our gitlab CI is failing due to valgrind breakage. With
Arch stripping glibc, valgrind now requires debuginfod to be active.
However the gitlab CI system combined without our testsuite does not
retrieve these symbols, even when the appropriate environmental
variable is set.

Work around this by installing the glibc-debug package directly
using a slight kludge...  All blame for this approach is assigned
to foutrelis!

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-06-16 09:00:18 +10:00
Allan McRae
84dc662d65 makepkg: add source signing PGP keys to source package if available
Arch Linux is adding source signing PGP keys to their package source
tree alongside PKGBUILDs in the form keys/pgp/$fingerprint.asc. As the
PGP keyserver infrastructure is a mess, this helps other people validate
sources in a PKGBUILD.

Add the keys to source packages if found alongside the PKGBUILD.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-05-31 20:13:14 +10:00
Allan McRae
fdf04cdac5 doc/PKGBUILD: remove Arch Linux specific advise
The documentation for the license array was specific to Arch Linux.
Remove it and some minor other Arch Linux specific references.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-05-18 22:06:07 +10:00
Allan McRae
18152a211a libmakepkg: Do not "strip" files when the format is not recognised
We use a multi step process during stripping to ensure permissions do
not get changed.  However, if the initial objcopy fails, the subsequent cat
results in a blank file.  Abandon early if objcopy fails.

Fixes FS#74486

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-05-12 09:45:12 +10:00
Jonas Witschel
f5f9e0f4ea makepkg: use bsdtar --no-read-sparse for archive creation if available
bsdtar uses the "pax" TAR archive format by default, which has support for
storing sparse file information in the archive. Unfortunately this is a source
of unreproducibility because the sparse encoding is taken from the file system
and different file systems handle sparse files differently: some file systems
have no support for sparsely encoded files at all, and even file systems with
sparse file support can report different file information for identical files
due to differing implementations.

As a real world example where this happens, consider the Arch Linux package
"brotli-testdata 1.0.9-7", which contains a sparsely encoded all-zeros file
"usr/share/brotli/testdata/zeros". Building this package on a btrfs file system
yields a different package than building it on tmpfs or ext4 solely due to
different sparse file information that gets recorded in the package tarball.

To improve the reproducibility of archives containing sparsely encoded files,
libarchive version 3.6.0 introduces a new --no-read-sparse option. This skips
reading sparse file information from disk entirely and therefore stores files
"expanded" in the archive, which is the only way to make them reliably
reproducible across file systems.

makepkg will use this option if libarchive is recent enough to support it,
which is detected at build time.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-11 09:43:59 +10:00
morganamilo
bddfcc3f40 libalpm: add getter for handle on db and pkg
db and pkg store a pointer to the handle for internal use but don't
actually provide a way for a user to get it.

Making this accessible is more convenient for front ends and FFI
wrappers.

For example, in other languages it's common to return the error value
directly. To achieve this the python and rust wrappers also store their
own pointer to the handle inside their own pkg/db wrappers.

Exposing this would allow the wrappers to forgo the extra pointer and
just return `pkg.get_handle().last_error()`.
2022-03-08 09:56:53 +10:00
Andrew Gregory
221905b5ae query: allow querying extra info for package files
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-07 20:37:45 +10:00
Andrew Gregory
293762ea8b query: only strip leading local/ for db packages
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-07 20:37:01 +10:00
Allan McRae
40583ebe89 Avoid information leakage with badly formed download header
Parsing of Content-Disposition relies on well formed headers.
A malformed header such as:

Content-Disposition="";

will result in a strnduppayload->content_disp_name, -1, ptr),
which will copy memory until it hits a \0.

Prevent this by only copying the value if it exists.

Fixes FS#73704.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 21:49:56 +10:00
Allan McRae
632eb9739d Do not use WKD to import keys for package installs from a file
In order to use WKD in pacman -U/--upgrade operations, we need to
get the packager information from the .PKGINFO within the package.
That has obvious security implications. e.g. something like this
could convince a user to download a different key to what they
expect:

packager = foo bar <>^[[2K^[[0G:: Import PGP key DEADBEEF, "foo <bar>

While downloading an untrusted key has little impact due to the
web-of-trust model used by pacman, this could be bad in combination
with an exploit that allowed trust of keys in the keyring to be
altered.

To be safe, do not use WKD when installing using -U.

Fixes FS#73703.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 21:25:30 +10:00
Allan McRae
6b37d99431 Fix segfault when failing to import keys
Avoid a segfault when a search of the keyserver returns that the
key is found but returns no primary IDs.  We are then likely going
to fail the import, but attempt anyway because no-one know what
a keyserver will do!

Fixes FS#73534.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 20:36:59 +10:00
Allan McRae
e1246baddd Ensure WKD key lookup returns the correct key
Looking up a key using WKD just ensures you have a key with the
same email address, it does not ensure that a key with the correct
fingerprint has been downloaded.

Check a key with the relevant fingerprint is available after a
WKD import.
2022-03-06 19:57:09 +10:00
morganamilo
7340fb9b2e libalpm: mark filelist_contains as taking a const filelist
This is useful for bindings as it guarantees the value will not be
changed.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 17:32:23 +10:00
Allan McRae
7ba2c276db Fix typo/omission in man pages
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 17:25:42 +10:00
Allan McRae
c89f42f17b meson: do not use meson.source_root() and meson.build_root()
Using meson.source_root() and meson.build_root() are deprectated in
meson-0.56.  Using current_source_dir() or current_build_dir() (which
have been available in all Meson versions) would require manually
adding "../" in some places.  Instead, use project_source_root() and
project_build_root() and require meson-0.56.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 16:26:34 +10:00
Allan McRae
3a39eff15e meson.build: change ExternalProgram.path to full_path
Removes "Future-deprecated features used", but reuires meson-0.55

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 15:55:17 +10:00
Allan McRae
6cdb2030c6 Update Doxygen configuration to silence warnings
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 15:32:34 +10:00
Allan McRae
ad918bcb75 Remove reference to internal type in docs
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 15:32:27 +10:00
Allan McRae
569bcd9d26 Add missing parameter names to silence doxygen
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 15:24:19 +10:00
Allan McRae
5bbda937f1 Silence meson warning about extract_all_objects
Upstream is changing the default from false to true.  This makes
no difference to us, so just set as the future default.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 15:07:57 +10:00
Allan McRae
0a792843f9 Silence meson run_command warning
Upsteam is warning about future change in the run_command check
argument. Ref: https://github.com/mesonbuild/meson/issues/9300

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 14:53:42 +10:00
Evangelos Foutras
e1ce2351f5 Make link time optimization flags configurable
We want to use -flto=auto in Arch Linux to speed up building, but we
can't hardcode it in buildenv/lto.sh because other downstreams might
have clang < 13.0.0 which did not recognize -flto=auto as equivalent
to -flto=full.

Introducing an LTOFLAGS variable to makepkg.conf seems the way to go.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 14:45:36 +10:00
Allan McRae
49b08fa9d1 libmakepkg/autodep: fix module name
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-13 13:45:42 +10:00
Morten Linderud
241c29f0cc makepkg: Implement pkgtype in .PKGINFO
This implements pkgtype into .PKGINFO. This is useful to ensure tools
parsing packages do not miss important context on the creation of the
package.

For instance discovering if a given .pkg.tar is a debug package, one
would have to do heuristics on the pkgdesc and "${pkgbase}-debug".
However both of these values are controlled by the packager.

Similarly, the heuristic for discovering split packages is if pkgbase
and pkgname differ, which can happen in any package as both values are
packager controlled.

This should ensure we don't need to rely on heuristics and instead
include the context of how the package was created.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-09 14:03:16 +10:00
Morten Linderud
ae2f506ddf strip: Use debugedit instead of AWK to parse source files
This moves us from the fairly ugly AWK parsing line to debugedit which
originally comes out of the rpm project.

The original code has issues parsing anything that was not straight
C/C++ and languages like Rust or Go would return invalid source code
files. debugedit handles all these cases better.

Fixes FS#66755
Fixes FS#66888
Fixes FS#65677

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-09 13:58:12 +10:00
Allan McRae
42fe4864a0 libmakepkg: add extra buildflags only when buildflags is not disabled
This means options=('!buildflags') will disable the addition of CFLAG
etc for LTO and debug building.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-09 12:45:58 +10:00
Jonathan Sköld
a8d9fb8d9c Print the target arch when using the %a format specifier
Adds the %a format specifier to allow printing of a target's arch
when using --print-format.

Signed-off-by: Jonathan Sköld <arch@skold.dev>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 21:39:10 +10:00
Sefa Eyeoglu
446972b404 pacman: simplify chomp mouth logic
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 20:57:42 +10:00
Sefa Eyeoglu
e654aa8ac6 pacman: support multiple chomps at the same time
When two progressbars are present, one of them always had c while the
other always had C as the mouth

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 20:55:11 +10:00
Morten Linderud
2fe1ba5d81 makepkg: Use pkgbase in pkgdesc for debug packages
When trying to identify debug packages among other packages we
discovered that it's pkgname used in pkgdesc. Since pkgname can
sometimes be an array when building debug packages for a split package,
this could potentially include a pkgname that might not make sense
depending on the order of the array.

This patch simply uses pkgbase as it seems more correct.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 18:15:11 +10:00
Allan McRae
0be1d4e5d0 Remove parsing of long removed files in .PKGINFO
These fields have not existed for many years.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 18:06:15 +10:00
Xiretza
e37f7d8b6b makepkg: use -ffile-prefix-map instead of -fdebug-prefix-map
>From gcc(1):

-ffile-prefix-map=old=new
	[...] Specifying this option is equivalent to specifying all the
	individual -f*-prefix-map options. This can be used to make reproducible
	builds that are location independent.

Specifically, this additionally enables -fmacro-prefix-map=, which causes
prefix mapping to be applied to expansions of __FILE__ and similar macros.

Without this option, if source files are compiled by passing the
absolute file path to the compiler (as done by e.g. cmake), any
expansions of __FILE__ (e.g. from uses of assert()) will contain
$srcdir.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 17:42:43 +10:00
Allan McRae
90df85e9cf Update copyright years
./build-aux/update-copyright 2021 2022

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 13:34:52 +10:00
Oskar Roesler (bionade24) via pacman-dev
9f23654722 pacman: print additional error information to stderr
Prints extra information provided by file conflict or corrupt package messages
to stderr instead of stdout

Signed-off-by: Oskar Roesler (bionade24) <o.roesler@oscloud.info>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 17:53:51 +10:00
morganamilo
58c81fa213 alpm: return -1 for error in find_dl_candidates
This is the error value generally used and the calling function
explicitly checks for -1, later causing the error to be missed
and the transaction to continue.

> pacman -S xterm
warning: xterm-369-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Package (1)  Old Version  New Version  Net Change  Download Size

extra/xterm  369-1        369-1          0.00 MiB       0.42 MiB

Total Download Size:   0.42 MiB
Total Installed Size:  1.05 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n]
error: no servers configured for repository: extra
(1/1) checking keys in keyring                                                                 [--------------------------------------------------------] 100%
(1/1) checking package integrity                                                               [--------------------------------------------------------] 100%
error: failed to commit transaction (wrong or NULL argument passed)
Errors occurred, no packages were upgraded.
2021-12-29 16:16:18 +10:00
morganamilo
3a112668b5 pacman: improve backup printing
The current backup printing does not fit in with the rest of the info at
all. Change to be more consistant.

Old:

Backup Files    :
MODIFIED	/etc/pacman.conf
UNMODIFIED	/etc/makepkg.conf

New:

Backup Files    : /etc/pacman.conf [modified]
                  /etc/makepkg.conf [unmodified]

Signed-off-by: morganamilo <morganamilo@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 15:49:35 +10:00
Allan McRae
9b766badd2 libmakepkg: automatically add library dependencies
Add linked libraries to a packages dependency list. This is the partner
to automatically generated library provides, and thus depends take the
same format. To help with bootstrapping, library dependencies are only
added if the relevant provide exists.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 15:20:05 +10:00
Allan McRae
b234280083 libmakepkg: automatically add library sonames to provides
When the option "autodeps" is enabled, makepkg will add provides
entries for libraries found in the directories specified in LIB_DIRS
in makepkg.conf.  The entries LIB_DIRS array have the format
"prefix:directory".  For example, the entry "lib:usr/lib" will search
$pkgdir/usr/lib for library sonames and add "lib:libfoo.so.1" to the
provides array.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 15:20:05 +10:00
Allan McRae
060ab4a289 libmakepkg: add framework for autodeps
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 15:20:05 +10:00
Allan McRae
354a300cd2 makepkg: remove libdepends and libprovides
This will be replaced by a better system

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-29 15:20:05 +10:00