Commit graph

6428 commits

Author SHA1 Message Date
Alastair Hughes
62bfba53db Make the flags used for sed -i configurable
Not all sed implementations on linux accept the --follow-symlinks
argument, so let the user configure the arguments passed to sed if
required.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>

[Allan: fixed configure summary output]
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-14 13:03:44 +10:00
Allan McRae
2ddbc6964b libmakepkg: grammar fix
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-14 09:45:53 +10:00
Eli Schwartz
4dae3fde17 makepkg: respect $SOURCE_DATE_EPOCH to activate reproducible builds
If SOURCE_DATE_EPOCH is set, `touch` all source files between the (optional)
prepare() and build() functions to unify the modification times. This works
around build systems and compilers that embed the file modification times
into the file contents of release artifacts.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-13 14:21:34 +10:00
Eli Schwartz
39319c1860 libmakepkg: check for invalid tags in git
As per https://lists.archlinux.org/pipermail/arch-general/2017-July/043876.html
git doesn't check that the tag name matches what an annotated tag object
*thinks* it should be called. This is a bit of a theoretical attack and
some would argue that we should always use commits since upstream can
legitimately change a tag, but nevertheless this can result in a
downgrade attack if the git download transport was manipulated or the
upstream repository hacked.

So, check the tag blob to make sure the tag actually matches the name we
used for `git checkout`.

This really should be fixed in git itself, rather than forcing all
downstream users of git verify-tag to implement their own checks, but
the git developers disagree, see the discussion surrounding
https://public-inbox.org/git/xmqqk2hzldx8.fsf@gitster.mtv.corp.google.com/

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-13 14:20:35 +10:00
Michael Straube
64b7edd2fe Fix brace coding style issues
- Add missing braces to one-line if blocks
- Move opening brace to line end

Signed-off-by: Michael Straube <straubem@gmx.de>
2017-07-28 12:34:03 +10:00
Michael Straube
064e7280cb Fix coding style issue in pacman/util.c
Add missing braces to some one-line if blocks.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-28 12:33:24 +10:00
Michael Straube
b4a197a615 test/pacman: fix spelling of distribution name and another typo
Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:37:23 +10:00
Andrew Gregory
2b1b7b7075 clarify broken dependency error messages
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:36:16 +10:00
Andrew Gregory
fa8419a0b5 provide command for downloading missing databases
This is primarily to help users who are not aware that -F operations use
a separate set of databases that need to be separately downloaded.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:35:57 +10:00
Andrew Gregory
bcc9c417ae alpm_list: abort on memory allocation failure
This makes it possible to detect a failure in several alpm_list
functions.  Previously these functions would continue after a failure,
returning partial results and potentially leaking memory.
Unfortunately, NULL is a valid return value for the affected functions
if the input list is empty, so they still do not have a dedicated error
value.  Callers can at least detect an error by checking if the input
list was empty.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 14:48:03 +10:00
Levente Polyak
c44c649a52 makepkg: add more information to .BUILDINFO
The .BUILDINFO file should retain all the information needed to reproducibly
build a package.  Add some extra information to the file and also provide a
version number to keep track of future changes.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:57:27 +10:00
Allan McRae
9ab44178f4 makepkg: set default value for PACKAGER
In write_pkginfo, we checked if $PACKAGER was undefined, and gave a default
value if not.  Just do this upfront to simplify this function.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:34:31 +10:00
Allan McRae
1c8b3f2562 makepkg: always write pkgbase
There is little savings in only writing pkgbase when different to pkgname, and
it makes determining the pkgbase by parsing .PKGINFO slightly easier. Lets just
write it...

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:27:22 +10:00
Allan McRae
d170c4580c makepkg: do not write basever
Since 8a02abcf19, this attribute will never exist.  Remove check to write it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:26:04 +10:00
Eli Schwartz
b14ff66038 libmakepkg: Fix improperly spelled local variable declaration
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:21:42 +10:00
Eli Schwartz
d4193d43cf libmakepkg/integrity: Fix error message not sent to stderr
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:55:45 +10:00
Eli Schwartz
9c604af0a0 libmakepkg: fix unsanitized source filenames
There were a couple places where filenames beginning with "-" were not
properly guarded against by passing them after "--". Some PKGBUILD
authors are crazy, but we still take those into account.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:55:25 +10:00
Christian Hesse
3c433abb54 fix typo in libalpm comment
contatenate -> concatenate

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:54:34 +10:00
Allan McRae
d30878763c makepkg: introduce SOURCE_DATE_EPOCH
This patch introduces the SOURCE_DATE_EPOCH environmental variable.  All files
in a package are adjusted to have their modification dates set to the value
of SOURCE_DATE_EPOCH, which defaults to "date +%s".

Setting this variable allows a package that is built twice in the same
environment to be (potentially) reproducible in that the checksum of the
generated package file will be the same.

Also adjust the compression of the mtree file to avoid gzip embedding a
timestamp.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2017-05-16 12:54:01 +10:00
Allan McRae
5f38128686 makepkg: remove build date from .PKGINFO header
This information is duplicated (in less friendly format) in the "builddate"
entry and removing it improves reproducible packaging.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2017-05-16 12:47:01 +10:00
Andrew Gregory
5a1bf3d803 remove unused byte from user agent buffer
snprintf prints at most n bytes including the terminating '\0'.  The
extra reserved byte was never being used.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:44:08 +10:00
Andrew Gregory
63087c31b5 check for overflow when setting HTTP_USER_AGENT
gcc7 issues a warning about a potential overflow if left unchecked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:43:17 +10:00
Andrew Gregory
a2b776f6c9 query_fileowner: avoid buffer overflow
Copying a string into a buffer that  has just been determined to not be
able to hold it is obviously incorrect.  The actual error handling
appears to have been unintentionally removed in
47762ab687.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:39:39 +10:00
Andrew Gregory
1bc79cb9a5 alpm_unlock: check handle before dereferencing
Prevents SIGSEGV if we catch SIGINT or SIGHUP before initializing alpm.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:38:58 +10:00
Michael Straube
f4e2009e9b pacman.8: fix typo in query options
Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:55 +10:00
Andrew Gregory
bf468c0956 free memory for --overwrite lists
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:55 +10:00
Andrew Gregory
12f74fd895 add send_fakem to valgrind.supp
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:54 +10:00
Andrew Gregory
bf23f85d4a be_sync: error out if a db cannot be parsed
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:54 +10:00
Allan McRae
c6b04c0465 makepkg: create signature files outside of fakeroot
With recent version of gpg, signing within fakeroot works on the first
invocation, but fails on later runs.  Sign all packages outside of fakeroot
to avoid this issue.

Fixes FS#49946.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:53 +10:00
Allan McRae
c0a5884b18 makepkg: do not create symlinks in build directory
Setting PKGDEST and friends enables us to keep all built packages in a single
location.  Symlinking these files into the build directory creates unnecessary
clutter and requires clean-up in multiple places when removing old version.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-17 18:33:52 +10:00
Michael Straube
4f2fea240d makepkg: clean up pkgver and prepare log files
Delete log files for the pkgver and prepare functions if -c,--clean is
passed.

Fixes FS#51039 and FS#51075

Includes patch submitted by Christian Braun.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-17 10:50:41 +10:00
Andrew Gregory
3c013f68ac run_chroot: label pipe endpoints for readability
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
fae33a1faf add --sysroot option
--root is not sufficient to properly operate on a mounted guest system.
Using --root still uses the host system's configuration and there is no
way to correctly use the guest configuration without manually modifying
any Include directives.  --sysroot provides an easier way to operate on
a guest system by chrooting immediately after option parsing before
configuration parsing or performing any operations.  It is currently
limited to the root user, but that's enough for restoring a guest system
to a working state, which is the primary intended use case.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
6a4c6a02de use sockets for scriptlet/hook communication
If a scriptlet/hook dies at the wrong moment it can trigger SIGPIPE,
terminating the process.  For pipes, there is no way to prevent SIGPIPE
other than ignoring it process-wide.  This can have unintended
consequences in a multi-threaded process.  Using send(2) with sockets,
however, allows ignoring SIGPIPE on a per-call basis, leaving other
threads able to make use of SIGPIPE.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
6d1dcf7937 conflict: include owner for filesystem conflicts
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
16b91f798f unlink_file: strip trailing slashes
If the user replaces a directory with a symlink, libalpm would get
confused because the trailing slash causes system calls to resolve the
symlink.  This leads to errors and a misleading message during upgrades.
Even though libalpm does not support this, it should not be giving
misleading errors.

Also adds an overflow check.

Fixes FS#51377

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
f9de3b22ad sortbydeps: rename vptr -> i
vptr is a simple list iterator, which are typically named i.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
a8670304c9 sortbydeps: rename found -> switched_to_child
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
098e114f58 sortbydeps: factor out dep cycle warning
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
1550938ce1 graph.h: rename childptr -> iterator
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:54 -04:00
Andrew Gregory
9c763a0d1b graph.h: replace hardcoded values with an enum
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:26:13 -04:00
Andrew Gregory
13ec13c85e deprecate --force in favor of --overwrite
--force is widely misunderstood and the same effect can now be achieved
with --overwrite, which is better named and can be used more safely.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-12 11:47:44 +10:00
Andrew Gregory
04d211effa add --overwrite option to ignore file conflicts
Allows for safer, more fine-grained control for overwriting files than
--force's all-or-nothing approach.

Implements FS#31549.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-12 11:47:33 +10:00
Armin K
86f5c74694 libalpm: Use archive_read_extract2
archive_read_extract() forces resolution of uid/gid to names
when extracting the tarball. This can lead to wrong file
ownership when using pacman with -r option and when uid/gid
differ in the host and in the chroot.

archive_read_extract2() uses uid's and gid's only. See also:

https://lists.archlinux.org/pipermail/pacman-dev/2017-March/021912.html

Signed-off-by: Armin K <krejzi@email.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-12 11:44:56 +10:00
Drew DeVault
1af766987f Replace @SIZECMD@ with POSIX-compatible command
Now uses wc -c $file | cut -d' ' -f1, which works using only POSIX
commands and removes the need for any platform-specific usages.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:21:20 +10:00
Andrew Gregory
d9908fc1f2 parse stdin as newline-separated
Newline-separated input is more reliable because most of the arguments
we accept over stdin can validly contain spaces but not newlines.

Resolves FS#52992

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:04:16 +10:00
Andrew Gregory
a138db3c07 add alpm_list_append_strdup
Makes error detection and handling easier for a common operation.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:03:22 +10:00
Andrew Gregory
a202959a19 pactest: add --review option
Opens the test file(s), test output, and any log files in the test
environment in an editor after the tests run for review.  Simplifies
debugging tests by avoiding the need to use --keep-root and manually
opening the relevant files.  The editor used can be set with --editor or
$EDITOR, falling back to vim.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 11:55:31 +10:00
Michael Straube
5678298f7d Ignore comments in INSTALL files (FS#51916)
If a comment in an INSTALL file contains the name of a valid
INSTALL file function but the function itself is not present,
pacman tries to execute that function. That leads to an error.

Ignore comments in the grep function in libalpm/trans.c to
avoid such errors.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 11:54:36 +10:00
Christian Hesse
c635f185ba Introduce a 'disable-download-timeout' option
Add command line option ('--disable-download-timeout') and config file
option ('DisableDownloadTimeout') to disable defaults for low speed
limit and timeout on downloads. Use this if you have issues downloading
files with proxy and/or security gateway.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-13 12:52:50 +10:00