Commit graph

1772 commits

Author SHA1 Message Date
Levente Polyak
ee933acf84 makepkg: immutable bzr by hashing the checkout content
This feature makes bzr VCS build inputs immutable by adding support for
pinning a bzr checkout by a hash of its content using the deterministic
export functionality `bzr export`.

This feature allows to preserve security implications of immutable build inputs
using a trusted cryptographic hash function of the content.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-08-28 22:15:03 +10:00
Levente Polyak
ca3c873d48 makepkg: immutable mercurial sources by hashing the checkout content
This feature makes Mercurial VCS build inputs immutable by adding
support for pinning a Mercurial checkout by a hash of its content using
the deterministic export functionality `hg archive`.

This feature aids packagers by allowing them to use simple and
convenient refnames (instead of full commit hashes) in the `PKGBUILD`
while still preserving security implications of immutable build inputs
using a trusted cryptographic hash function of the content.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-08-28 22:15:03 +10:00
Levente Polyak
2fc2ab6cf0 makepkg: immutable git sources by hashing the checkout content
This feature makes Git VCS build inputs immutable by adding support for
pinning a Git checkout by a hash of its content using the deterministic
export functionality `git archive`.

This feature aids packagers by allowing them to use simple and
convenient refnames (instead of full commit hashes) in the `PKGBUILD`
while still preserving security implications of immutable build inputs
using a trusted cryptographic hash function of the content.

Previously VCS source downloads have been skipped for `--geninteg` and
`--source` as both options did not need a checkout. This commit changes
this behavior by forcing the download of all sources as integrity checks
and generation requires to have an up to date state.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-08-28 22:15:03 +10:00
kpcyrd
843bf21e79 libmakepkg: Fix non-reproducible binaries by processing debuginfo in order 2023-08-27 13:03:40 +02:00
Allan McRae
262aa6c24e Fix comment
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-02-13 12:09:11 +00:00
Allan McRae
3323662ee0 makepkg: do not recurse into LIB_DIRS when looking for library provides
We should only find library provides in the configured directories, and
not their subdirectories.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-02-13 12:09:11 +00:00
Allan McRae
71764b6d4c makepkg.conf: allow configuration additions via a subdirectory
Move rust related buildflags to their own configuration file to
provide an example of how other languages could be supported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-17 10:26:07 +10:00
Allan McRae
e0bbfb5682 libmakepkg: ensure clearing of buildflags happens first
When 'options=('!buildflags') is used, we want to ensure our
buildflags are cleared first. Currently this happens due to luck
of alphabetical ordering, but this could change with libmakepkg
drop-ins.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-13 11:35:42 +10:00
Allan McRae
09e82f01ea libmakepkg: move rust buildenv handling to separate file
This serves as a demonstration for how other languages could drop
in support into libmakepkg.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-13 11:35:35 +10:00
Stefan Weil
d35728f924 pacman-key: Fix shell syntax
Fixes: 3f8029af92 ("pacman-key: Use ngettext for plurals")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2023-01-01 15:54:48 +01:00
Allan McRae
3f8029af92 pacman-key: Use ngettext for plurals
There are two strings that may be singular or plural in pacman-key.
Use ngettext to handle these strings correctly, and provide a fallback
function if it is not available.

Fixes FS#70556.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-01 13:41:52 +10:00
Allan McRae
6344aab3bd zsh: make names unique to avoid clashes
The function _keys is a bit generic and can result in clashes.  Change
other functions starting with _key_ to be _pacman_key_ as well.

Fixes FS#74507.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-24 00:55:30 +10:00
morganamilo
52eb094aa2 Fix repo-add
Commit 4f43ce3e4a broke repo-add by
switching to parseopts without accounting for the added "--". This caused
the dbname to always be read as "--".

Accounts for "--" and makes repo-add respect "--" as end of opts.
2022-12-19 10:08:57 +10:00
Allan McRae
fcb1d4f87e makepkg: package debug source files with options 'debug' and '!strip'
When package software with debug symbols without stripping, we should
still process the files with debugedit and include the needed source
files in the package.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-13 10:00:13 +10:00
Allan McRae
0e938f1886 libmakepkg: fix compatibility with bash-5.2 patsub_replacement
Bash-5.2 introduced the patsub_replacement shell option, which is enabled
by default.  Apparently is it supposed to handle a sed-like idiom, but
what it does achieve is making any substitution involving a "&" requiring
special care.

For makepkg's DLAGENTS, we replace "%o" and "%u" if present.  Any "&" in
the replacement fields triggers patsub_replacement unless quoted.  This is
particularly important for the URL field.

Add relevant quotes to avoid issues.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-12 18:37:59 +10:00
Allan McRae
1327ce7bd8 makepkg: remove md5sums from generated mtree file
md5sums are cryptographically broken and we supply sha256sums to verify
files on a users system have not been modified from the packaged version.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-04 20:15:33 +10:00
Allan McRae
310bf878fc repo-add: do not add md5sums to the repo dbs
Keeping md5sums in the repo databases no longer serves a real purpose.
md5sums are no longer considered  secure, and we already have sha256sums
in the repos (along with PGP verification).

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-04 20:15:33 +10:00
Allan McRae
4f43ce3e4a repo-add: use parseopts from libmakepkg
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-04 20:14:32 +10:00
Morten Linderud
3ed08f97ec
executable/meson.build: include debugedit.sh.in
Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-11-07 01:02:12 +01:00
Allan McRae
86981383a2 Fix missing if
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-10-09 13:43:31 +10:00
Frederik Schwan
de11824527 strip: Include .o files in strip operation
`.o` objects used to be omitted by strip.sh due to a missing match in
the `Relocatable file` section. This patch fixes the issue by handling
`.o` objects similar to kernel modules.

fixes FS#74941

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-10-09 11:01:12 +10:00
Morten Linderud
478af273df strip: fix unique source paths
`${pkgbase}` was added to the wrong invocation. This ensures we are
producing correct debug packages.

Example from the package:

    /usr/src/debug/pacman/pacman-6.0.2/src/pacman/callback.c
    /usr/src/debug/pacman/pacman-6.0.2/src/pacman/callback.h
    /usr/src/debug/pacman/pacman-6.0.2/src/pacman/check.c
    /usr/src/debug/pacman/pacman-6.0.2/src/pacman/check.h

Fixes: 776b7c1e75 ("debugflags: Ensure we have unique source paths")
Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2022-10-09 10:57:26 +10:00
Allan McRae
efd0c24c07 Always create directories outputted from debugedit in debug packages
The debugedit call to list all source files may include things like
build/<...>.  We have been filtering out these <> files, but they can
point to the build directory which is important to be available for
relative source paths stored in the .debug files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-10-08 21:07:45 +10:00
Allan McRae
a6b06a5b17 libmakepkg: fix compatibility with bash-5.2 globskipdots
Bash 5.2 has a new globskipdots option, which is enabled by default. The
check_dotfiles lint fails with globskipdots due to the assumption that
at least the "." and ".." paths will match. Disabling globskipdots would
be the usual solution, but that fails on bash<5.2.  Instead, enable
nullglob for this check.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-10-02 11:40:52 +10:00
Kristian Klausen
673ce1ab10 pacman-key: Don't check gpg's trustdb after each key revocation
The trustdb is marked as dirty when a key is revoked[1] and GPG will
recheck it the next time. Checking the trustdb can take 300-500ms which
with 52 revoked keys (and counting) adds up.

This is very noticeable when initializing and populating pacman's
keyring like archiso is doing[2]. It is also unnecessary as the trustdb
is always checked as the last step when populating the keyring.

[1] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=g10/keyedit.c;h=1cb62de8a87a823e06b2ed74efdc9e7a4cd99e2b;hb=refs/heads/STABLE-BRANCH-2-2#l6509
[2] https://gitlab.archlinux.org/archlinux/archiso/-/issues/191
2022-09-26 20:22:11 +10:00
soloturn
184f593168 libmakepkg: Fix git clone command
Commit e017a5975c introduced the GITFLAGS
environmental variable. While ensuring the default of "--mirror" was
kept, there was a capitalisation mistake made. Handle the default for
GITFLAGS directly in the git clone command.
2022-08-02 13:07:09 +10:00
soloturn
e017a5975c makepkg: Add GITFLAGS environmental variable to customise checkout
The default flag used to clone a git repository when using makepkg
is "--mirror". However, when working with huge repositories, the use
of different flags during cloning can allow an faster checkout. For
example, using "--filter=blob:none" allows for small checkouts, at
the expense of requiring downloads during the build stage if anything
but the HEAD commit is used for the build. In addition, this example
would serve as a replacement for the often requested (but broken)
addition of --depth=1.

Add support for the environment variable GITFLAG to pass flags for
the git clone command. Note that this overrides the default rather
than adding to it in order to prevent incompatibilities.
2022-07-29 11:00:01 +10:00
Daan De Meyer
79bd512181 Add --keyringdir meson option to configure the keyring directory
On Debian, keyrings are stored in /usr/share/keyrings. To support
this, let's add a new --keyringdir option that allows configuring
the directory under datarootdir where the keyrings should be
imported from. We default to 'pacman/keyrings' for backwards
compatibility.
2022-07-29 10:17:52 +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
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
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
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
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
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
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
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
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
Allan McRae
26ee6ff6ad LTO: Add -flto to LDFLAGS for clang
GCC automatically detects when it is linking LTO objects, but clang does
not.  Add -flto to LDFLAGS to make this work for clang too.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-12-24 17:59:32 +10:00
Allan McRae
3710960090 Fix file permissions 2021-12-12 14:34:53 +10:00
morganamilo
b0a2fd75b2 Update mailing list url
change pacman-dev@archlinux.org to pacmandev@lists.archlinux.org

Most of this is copyright notices but this also fixes FS#72129 by
updating the address in docs/index.asciidoc.
2021-11-20 12:38:25 -08:00
Allan McRae
fbb29b5047 repo-add: add --include-sigs option
Pacman now downloads the signature files for all packages when present in a
repository.  That makes distributing signatures within repository databases
redundant and costly.

Do not distribute the package signature files within the repo databases by
default and add an --include-sigs to revert to the old behaviour.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 19:52:23 +10:00