Commit graph

1739 commits

Author SHA1 Message Date
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
Allan McRae
70d0b2c4b9 Include az_AZ translation files
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 18:02:39 +10:00
Allan McRae
4c3c0e06e5 Update translations from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 16:16:20 +10:00
Daan De Meyer
c7e4f45922 pacman-key: Reduce gpg trustdb checks
Every time we modify gpg's state by signing or revoking a key, gpg
marks the trustdb as stale and rechecks it the next time key_is_lsigned()
or key_is_revoked() is called.

Currently, we alternate calls signing of keys and calling key_is_lsigned()
(idem for revoking) which means that for each key we sign (or revoke), gpg
will check the trustdb once.

To avoid checking the trustb so many times, we can simply do all the
key_is_lsigned() and key_is_revoked() checks upfront. Inbetween read
operations the trustdb is not marked stale and inbetween write operations
the trustdb is also not marked stale. This reduces the amount of trustdb
checks from 50 to 1.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 13:43:26 +10:00
Daan De Meyer
160f5bec8c pacman-key: Add --quiet to a few more gpg invocations
Currently, when running pacman-key --populate, gpg prints the
trustdb check output once for each locally signed and revoked key.
When bootstrapping a new container image, about 50 keys get signed
and revoked which leads to a huge amount of output when running
pacman-key which is repeated 50x.

To avoid overloading the user with gpg output, we add --quiet to the gpg
calls generating the trustdb checking output to silence those calls which
gets rid of the trustdb check output on the terminal.

Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 13:34:58 +10:00
Allan McRae
1c5a56884f libmakepkg: reproducibilty for python packages
Arch Linux has been setting PYTHONHASHSEED=0 to create deterministic
.pyc files.  After a thorough review by the Arch Security Team, setting
this variable was determined not to generated vulnerable .pyc files, as
when the loader loads the .pyc file and unmarshalls it, the internal
runtime will just populate the unordered data structures and use a new
runtime hash for them.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-08-08 22:49:32 +10:00
Eli Schwartz
2d198c1af9 libmakepkg: allow correctly sourcing when $LIBRARY is not set
We usually set this up to default to the build time configured install
location, but a couple of files crept in without this.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-08-04 21:59:32 +10:00
Allan McRae
a193979cb6 makepkg: fix stripping of relocatable binaries with binutils>=2.37
Binutils commit 93df3340fd5ad32f784214fc125de71811da72ff enabled readelf
to report "Position-Independent Executable" files.  Fix stripping to
account for this change.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-08-04 18:52:08 +10:00
Allan McRae
b8dcb4b33c Pull translations from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-05-20 12:33:05 +10:00
Eli Schwartz
e176b8ec19 makepkg: squelch readelf warnings from debug stripping
readelf --debug-dump sometimes reports inscrutable warnings which don't
actually affect our extraction of source filenames. For example:

readelf: Warning: There is a hole [0xd3d - 0xd89] in .debug_loc section.

Now gcc 11 seems to have dramatically increased the number of warnings:

readelf: Warning: Corrupt offset (0x0000008e) in range entry 9
[...]
readelf: Warning: Corrupt offset (0x000010f0) in range entry 250

The resulting debuginfo created by the very same toolchain works fine,
as does the list of source filenames. But the warnings are quite
noisy... send them to /dev/null since they are not actionable in the
context of getting source files

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-05-19 19:05:34 +10:00
Allan McRae
558d08d821 Prepare translations for next release
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-23 10:44:27 +10:00
morganamilo
41f9c50abf Always enable TotalDownload
Previously TotalDownload would switch the % download from per package to
overall. Meaning you had a choice of which information to dispplay.

Now with parallel downloads TotalDownload adds an extra progress bar.
There's no reason to have this an off by default feature. Let's just
make it always on.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-23 09:43:30 +10:00
Levente Polyak
a33cdac10b makepkg: add tool details to buildinfo to aid determining flags
If a makepkg consumer uses a build wrapper to override compiler
flags this may lead to unreproducible packages as there is no way to
know which exact files were used for tooling that tries to reproduce
said package.

Instead of vendoring the whole used makepkg.conf file into buildinfo,
this patch adds two new properties to the .BUILDINFO file named
BUILDTOOL and BUILDTOOLVER which by default are simply makepkg's own
values. Downstream consumers may override those values: For example in
Arch Linux the devtools package can set those values and allow
reproducible builds tooling to fetch the appropriate makepkg.conf.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-23 09:07:40 +10:00
Jelle van der Waa
c294b7cb4c Update urls to not use www. for archlinux.org
www.archlinux.org now redirects to archlinux.org.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-08 10:14:33 +10:00
Eli Schwartz
2535611d6c makepkg: add PACMAN_AUTH configurable setting for sudo elevation
If specified, this will be used no matter what. If not, then we check if
sudo exists and use that, or else fall back on su.

Implements FS#32621

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-07 22:41:54 +10:00
Eli Schwartz
8aa2a48fc3 makepkg: fix the use of spaces in the localname:: component of sources
Broken via refactoring in commit aa6fe1160b
but for obvious reasons only one person in the last 9 years has ever
actually tried to do this. Still, it's technically correct to allow it.

Fixes FS#70254

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-07 22:38:34 +10:00
Allan McRae
bdf6aa3fb7 libmakepkg: fix detection of source file names for debug packages
The current gcc build from git master give different output from
readelf:

gcc-10.2.0
$ readelf "hello" --debug-dump | grep hello
<11> DW_AT_name : (indirect string, offset: 0xbfc): hello.cpp

gcc-git
$ readelf "hello" --debug-dump | grep hello
<12> DW_AT_name : (indirect line string, offset: 0x0): hello.cpp

This causes the awk statement extracting the file name to fail as it
relied on the information being in the 8th field. Instead, extract
the information from the final field.

Fixes FS#70168

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-27 09:22:15 +10:00
Eli Schwartz
ede73f4d89 fix syntax error when running pacman-key --help
In commit 0f75ab3224 some unbalanced
quotes were added by the committer while editing an error message.

Fixes FS#69865

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-06 12:01:26 +10:00
Allan McRae
c118a61f62 Strip LTO symbols from distributed .a/.o files
GCC's LTO implementation emits bytecodes into .o files it generates.
These bytecodes are _not_ considered stable from one release of GCC
to the next. There we need to strip the LTO bytecode out of any .o
(and .a) file that gets installed into the package.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-03 14:35:52 +10:00
Allan McRae
4a0891f49d Add link time optimization support to makepkg
Add the 'lto' option to enable building with link time optimization
by adding '-flto' to both CFLAGS and CXXFLAGS.  The 'lto' option can
be specificed both in the PKGBUILD or by setting the default in
makepkg.conf.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-03 14:35:45 +10:00
Allan McRae
17f9911ffc Update copyright year
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-01 12:22:20 +10:00
Morten Linderud
0f75ab3224 pacman-key: --refresh-keys queries WKD before keyserver
With the recent outages of the keyservers there is a possibility of
`--refresh-keys` failing to fetch new keys. A lot of current key
distribution is done over WKD these days, and `pacman-key` has the
ability to use it for `--recv-key`.

There was a hope `gpg` would end up supporting WKD for the refresh
functionality, but this seems to be limited to expired keys fetched
through WKD. Since this functionality isn't yet available it makes sense
to stuff it into `pacman-key`.

The current implementation looks over all available keyids in the
keyring, attempts to fetch over WKD and then fall backs to keyservers if
no email has a valid WKD available. The downside of this approach is
that it takes a bit longer to refresh the keys, but it should be more
robust as the distribution should be providing their own WKDs.

Co-authored-by: Jonas Witschel <diabonas@archlinux.org>
Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-02-24 23:05:48 +10:00
Morten Linderud
7587153a44 libmakepkg: Support zstd decompression for sources
This enables us to extract files in the source array and ensures that we
can decompress files if the uncompressed signature is served.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-02-24 22:51:14 +10:00
Matti Niemenmaa
9e425cd1ea makepkg: Don't double-layer distcc on ccache
buildenv is set once for build() and a second time for package(). When
using both distcc and ccache, this lead to CCACHE_PREFIX="distcc distcc"
in package(), which breaks PKGBUILDs that execute the compiler in
package() because distcc complains:

    distcc[383041] (main) CRITICAL! distcc seems to have invoked itself
    recursively!

Avoid causing this error by only adding "distcc" to CCACHE_PREFIX if
it's not yet there.

Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-02-08 14:24:49 +10:00
Eli Schwartz
88d054093c makepkg: don't let the strip routine mess up file attributes
It updates the stripped/objcopied file by creating a temp file,
chown/chmodding it, and replacing the original file. But upstream
binutils has CVE-worthy issues with this if running strip as root, and
some recent versions of strip don't play nicely with fakeroot.

Also, this has always destroyed xattrs. :/

Sidestep the issue by telling strip/objcopy to write to a temporary
file, and manually dump the contents of that back into the original
binary. Since the original binary is intact, albeit with different
contents, it retains its correct attributes in fakeroot.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-02-08 14:22:55 +10:00
Morten Linderud
8566cd9be9 pacman-key: Close msg string in generate_master_key
In 19980a61e9 there was a msg added which
didn't get the string closed.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-11 11:11:06 +10:00
Allan McRae
19980a61e9 pacman-key: warn about time taken for master key generation
Generating the pacman master key can take some time on systems
without enough entropy. Warn the user that the generation may
take some time.

Fixes FS#30286.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-03 11:19:21 +10:00
Ivy Foster
08f4ae709c Add fossil scm support to makepkg
Signed-off-by: Ivy Foster <escondida@iff.ink>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 21:58:40 +10:00
Michael Straube
94ac3330dd libmakepkg: compress: fix tar extension
With commit 74aacf4495 creating uncompressed .tar
packages fails.

  -> Compressing package...
/usr/share/makepkg/util/compress.sh: line 70: COMPRESS.TAR[@]: invalid variable name
bsdtar: Write error

Empty the '$ext' variable for the '.tar' extension in get_compress_command() to
fix this. We would fallback to cat for 'tar' anyways.

Signed-off-by: Michael Straube <michael.straubej@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-11-26 15:45:29 +10:00
Michael Straube
4d8f58d3b9 makepkg: emptydirs: fix typo
Fix typo in a comment in tidy_emptydirs().

Signed-off-by: Michael Straube <michael.straubej@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:19:01 +10:00
Eli Schwartz
c99a3cc867 makepkg: properly localize some internal function variables
We leaked fullver and pkgarch all over the place, and only conditionally
unset the other variables. Marking them local is a more proactive
solution.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:18:32 +10:00
Eli Schwartz
f76bd2c6c1 makepkg: fix signing of source packages
In commit c6b04c0465 the signing stage was
moved out of fakeroot, and thus into the main control flow instead of
create_{,src}package

While the function for signing binary packages has logic to build
and gpg-sign multiple filenames, the source package never got this
special treatment. This would be fine, except it uses the standard
variables to set define the filename... like ${fullver}, which is
usually set beforehand, but in this case is not. We don't define fullver
globally as it's an internal implementation detail, except by sheer
coincidence if PKGVERFUNC is false due to improperly guarded code.

Result: source packages didn't end up signed. Instead, we raised a logic
error:

==> WARNING: Failed to sign package file somepackage-.src.tar.gz.

==> ERROR: An unknown error has occurred. Exiting...

Instead, let's just build the version inline, since we only use it once.

Reported-by: GaKu999 <g4ku999@gmail.com>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-10-21 11:17:14 +10:00
Eli Schwartz
406a37206f makepkg: libprovides: don't provide both versioned and unversioned sonames
If multiple files match the pattern libfoo.so*, we want to check each of
them and see if they are shared libraries, and if so, if they have
versions attached.

But some packages can have both shared libraries and random files which
match the filename pattern. This is true at least for files in
/usr/share/gdb/auto-load/, which must match the filename they are paired
with, followed by "-gdb.py" (or some other gdb scripting ext), but
definitely don't contain a shared library. In this case, we don't want
to double-report the library in the generated provides.

It's also possible (probably) for a package to provide a versioned as
well as an unversioned shared library, but in such cases a single
provides entry is sufficient to cover both cases (and the libdepends
for the depending package would contain an unversioned dependency).

Solve this by keeping track of whether we have added a versioned soname
provides already, and then only adding a maximum of one unversioned
provides *iff* there isn't a versioned one yet.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-23 17:12:01 +10:00
Ronan Pigott
d85d9c8c60 Add pacman-conf zsh completions
Signed-off-by: Ronan Pigott <rpigott@berkeley.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-09-03 12:55:34 +10:00