Commit graph

259 commits

Author SHA1 Message Date
Filip Hejsek
9151c44658 libmakepkg: Use git -c safe.bareRepository=all in bare repositories
Git commands can fail in bare repositories when global git config contains safe.bareRepository=explicit.
Some users set this option for increased security.
To be compatible with this configuration, explicitly set safe.bareRepository=all when invoking git in a bare repository.
2024-07-06 08:57:20 +00:00
Allan McRae
3f1943c84d Only copy source files onces when creating debug packages
The Arch sharutils package was spewing messages about "Permission denied" when
copying source files into the debug package.  This is due to the source files
having 444 permissions and being used in multiple binaries.  Only copy each
source file into the debug package onces to avoid this error.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-06-20 00:34:32 +00:00
Allan McRae
f0a7f85dbb libmakepkg: make configured BUILDENV readonly
PKGBUILDs should not be directly adjusting this variable

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-31 16:15:54 +00:00
Diego Viola
7bbfc17f3c Fix typos
Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-20 02:30:50 -03:00
Allan McRae
d74d7ec32c makepkg: remove GITFLAGS support
Supporting git source fragments (branch, commit, tag) is difficult in
conjunction with GITFLAGS usage - particularly with the most common
use cases that reduce the amount of data cloned from the upstream repo.

Leaving GITFLAGS in place an documenting that various git source features
are not supported when GITFLAGS are in used is not an ideal 'solution'.
Instead, remove GITFLAGS support.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-20 00:18:43 +00:00
Allan McRae
76e1cb1bf1 Revert "Prepare git src with git worktree"
This causes issues when repeatedly building a package using the same
git checkout.  There is also ambiguity of the default checkout when
trying to build from HEAD. See #142 and #143.

This reverts commit 85c421f1cb.
2024-05-20 10:15:33 +10:00
EnnoxHD
8aba032de4 makepkg: make 'not a clone of' visible with a new error code
Add a new error code to expose the 'not a clone of' error state of some source
providers (git and fossil). This allows other tools integrating further and
handle this specific error state.

One usecase evolves around frequently changing source locations in PKGBUILDs
of packages in the AUR.
2024-05-05 12:24:56 +10:00
Tom "Ravi" Hale
85c421f1cb Prepare git src with git worktree 2024-05-04 22:28:57 +10:00
Chih-Hsuan Yen
9548d6cc76 Fix unstable git checksums
Closes https://gitlab.archlinux.org/pacman/pacman/-/issues/131
2024-05-04 10:14:11 +00:00
Allan McRae
792df078fa libmakepkg: add fortran buildenv to meson sources array
Fixes #132.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-04 10:10:23 +00:00
lilydjwg
8e30cd4e38 makepkg: fix git checksumming depends on user config 2024-04-22 04:48:19 +00:00
Allan McRae
7dcf9a2b49 libmakepkg: do not unset CHOST with !buildflags
Also ensure CHOST and MAKEFLAGS are exported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-20 11:37:54 +10:00
Allan McRae
027ecbc7b8 libmakepkg: remove MAKEFLAGS from buildenv_vars
MAKEFLAGS should not be cleared by options=(!buildenv).

Regression introduced in commit 09e82f01ea

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:43:57 +00:00
bartus
082094a1d8 Limit scope of name and a variable to avoid conflict with PKGBUILD scripts. 2024-03-19 12:43:00 +00:00
Morten Linderud
bae9594ac1
debugedit: only check for debugedit if we build a package
We only really need debugedit while building the package, while this
check would run if you tried something like `makepkg --verifysource`.
Use the same checks as we have for fakeroot to wrap debugedit so we
don't beg for dependencies we don't need.

Fixes: 3ed08f97ec

Signed-off-by: Morten Linderud <morten@linderud.pw>
2024-03-14 23:07:08 +01:00
Levente Polyak
016fd2633e
libmakepkg/srcinfo.sh: fix missing extglob in srcinfo_write_attr
We use an extended glob here, but were relying on having it globally set
in makepkg. This causes it to fail when used in scripts.

Since scripts using libmakepkg may not want extglob to be set, save and
restore the environment while explicitly setting extglob only where we
need it.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2024-02-28 21:30:22 +01:00
loqs
dba383f092 makepkg: Add support for Fortran build flags
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-25 09:33:29 +10:00
Allan McRae
d55b47e551 Update copyright years
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-24 18:40:44 +10:00
Allan McRae
c7c4c2a7d2 verify_signature: wait as long as possible before bailing
Bailing early caused problems with makepkg failing on verify but expired
signatures.  As this is often out of the packagers control, and it is
better to verify a signature than not, we try bailing as late as possible
and let makepkg warn about the expired signature.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-19 09:24:13 +10:00
Allan McRae
48729f8ecc libmakepkg: skip stripping guile-2.2 files
Guile 2.2 uses ELF format for its byte-compiled files.  These are not
normal executables, and are not strippable in the normal sense.

Given these are ELF files and detected by "file" as non-stripped binaries,
it is only possible to skip these using the file path.

Fixes #73

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-15 23:34:05 +00:00
Allan McRae
22c043d4c3 Fix format string
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-16 09:09:45 +10:00
David Runge
16a064701a
makepkg: Move check for signature metadata to central location
Move the check for the `NEWSIG` metadata keyword contained in the
GnuPG based statusfile to `parse_gpg_statusfile()` so that it is also
run when creating the statusfile in `verify_file_signature()` and not
only when running `verify_git_signature()`.

Signed-off-by: David Runge <dvzrv@archlinux.org>
2024-02-04 10:06:42 +01:00
David Runge
86ec26b2d3
makepkg: Improve robustness of signature verification by limiting terms
The output of
`gpg --quiet --batch --status-fd /dev/stdout --verify <signature_file> <file> 2> /dev/null`
or
`git verify-commit --raw <commit> 2>&1`
may contain binary data, if the signature has been created with an
OpenPGP implementation, that e.g. makes use of notations.
If the notation string (see `NOTATION_DATA` in /usr/share/doc/gnupg/
DETAILS) contains a trailing binary char, this will break signature
verification, as any following entry (e.g. `VALIDSIG`) will be offset.

As we are only making use of a narrow set of terms from the statusfile
(namely `NEWSIG`, `GOODSIG`, `EXPSIG`, `EXPKEYSIG`, `REVKEYSIG`,
`BADSIG`, `ERRSIG`, `VALIDSIG`, `TRUST_UNDEFINED`, `TRUST_NEVER`,
`TRUST_MARGINAL`, `TRUST_FULLY`, `TRUST_ULTIMATE`), we are applying a
filter, so that only understood terms are written to the file.

Signed-off-by: David Runge <dvzrv@archlinux.org>
2024-02-04 10:06:42 +01:00
David Runge
3aa096a74f
makepkg: Emit early error if signature verification fails
Emit an early error message if tag or commit verification with git or
detached signature verification with gpg fails.
Make `verify_file_signature()` and `verify_git_signature()` return
non-zero in this case and set errors to `1`, so that later checks
in `check_pgpsigs()`, although still run, can not lead to a positive
result.

Signed-off-by: David Runge <dvzrv@archlinux.org>
2024-02-04 10:06:40 +01: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
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
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
morganamilo
9af4033cad Rename LIBRARY to MAKEPKG_LIBRARY
Implements #59.
2023-11-04 00:02:17 +00: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
Matthias Kurz
366b527757 libmakepkg: make sure git cloned repo's remote is named origin
makepkg assumes that the remote git repo is named "origin" at several
places in its handling of git sources. It is possible to set the remote
repo name since git v2.30.0 (with bug fix for bare checkouts in v2.30.2).

Add "--origin=origin" to all git clone commands.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 13:51:32 +10:00
morganamilo
e83e53f3f9 makepkg: lint empty arrays
While depend arrays are already linted, many array kinds are still
not. An empty string is never a valid array value so check all
arrays for it.
2023-09-06 12:14:55 +10:00
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
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
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