Compare commits

..

58 Commits

Author SHA1 Message Date
Jelle van der Waa
377d47142f doc: add man page for pacman-conf
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-07 11:12:12 +10:00
Jelle van der Waa
298bcf7986 doc: set rootdir correctly in man pages
If an alternative rootdir is specified in either meson or configure it's
not respected in the generated man pages.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-07 11:12:12 +10:00
Eli Schwartz
e03752e6ad makepkg: add new checksum algorithm via coreutils b2sum
coreutils 8.26 in December 2016 added this new hashing method which is
compatible with the existing md5sum and sha*sum tool usage, while using
the blake2 hash algorithm.

makepkg uses coreutils to provide source file integrity checks via
${integ}sum binaries and it makes sense to offer this as an additional
option.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-07 11:12:12 +10:00
morganamilo
0113214db9 pacman: fix segfault when Usage is specified without a value
And extract all the common code to a macro.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-07 11:12:12 +10:00
Andrew Gregory
d197d8ab82 Sanitize file name received from Content-Disposition header
When installing a remote package with "pacman -U <url>", pacman renames
the downloaded package file to match the name given in the
Content-Disposition header. However, pacman does not sanitize this name,
which may contain slashes, before calling rename(). A malicious server (or
a network MitM if downloading over HTTP) can send a content-disposition
header to make pacman place the file anywhere in the filesystem,
potentially leading to arbitrary root code execution. Notably, this
bypasses pacman's package signature checking.

For example, a malicious package-hosting server (or a network
man-in-the-middle, if downloading over HTTP) could serve the following
header:

Content-Disposition: filename=../../../../../../usr/share/libalpm/hooks/evil.hook

and pacman would move the downloaded file to
/usr/share/libalpm/hooks/evil.hook. This invocation of "pacman -U" would
later fail, unable to find the downloaded package in the cache directory,
but the hook file would remain in place. The commands in the malicious
hook would then be run (as root) the next time any package is installed.

Discovered-by: Adam Suhl <asuhl@mit.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-01 11:23:20 +10:00
Sever Oraz
adb961a88e Use standard, consistent units in the download progress.
Rather than use M/s which can be either MB or MiB, specify that it uses
MiB (consistent with the displayed total size).

Fixes FS#59201

Signed-off-by: Sever Oraz <severoraz@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21 14:55:49 +10:00
Eli Schwartz
ba7a41031c meson: fix static/shared split again
shared_library does not generate a sane pkg-config file because it
assumes we don't want dependencies.

Additionally, since we key off of buildstatic, when *not* using
buildstatic but attempting to build libalpm on its own as static using
-Ddefault_library=static, we are building and linking to a shared
libalpm anyway.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21 14:34:02 +10:00
Eli Schwartz
3c774252ef libmakepkg: migrate to schema.sh for integsums
We cannot use most of the arrays defined in schema.sh as srcinfo is dependent
on the order, but migrate the hashes for now.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21 14:26:59 +10:00
Eli Schwartz
656e851f0a makepkg: simplify run_pacman logic
We don't need to check the options twice, since it is the same check
both times. Instead, merge the conditionals.

As far as I can tell, the only reason the checks for:

- PACMAN_OPTS and
- whether to use sudo

were ever separated is due to the historic existence of --asroot, since
the second check included a check for (( ! ASROOT )) until it was
cleaned up in commit 61ba5c961e.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21 14:18:25 +10:00
Eli Schwartz
4b83bcfcee makepkg: implement locking for pacman commands
When pacman is run as root to do -S, -U, or -R, it would immediately
abort if pacman is not ready for use. Instead, poll the lockfile and
wait until it becomes available.

Implements FS#28840

Original-patch-by: Georges Dubus <georges.dubus@compiletoi.net>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21 14:16:16 +10:00
Eli Schwartz
477a66cd0e build: link vercmp with a static copy of libalpm
This has historically been the case in autotools since we want vercmp to
not break mid-transaction in an install script.

For convenience, we create libalpm.a and use this to optionally generate
libalpm.so (when not configured with -Dbuildstatic=true) as well as to
link any binary which explicitly wishes to be built statically "with
libalpm", but does not care where a function is defined. meson then
treats this correctly: it builds the object file only once for both
libraries, and the compiler strips out unused functionality from the
final static binary.

Currently the only binary which requires this is vercmp.

Fixes FS#61719

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-12 21:58:19 +10:00
Allan McRae
86004227d1 Add implicit fall through warning
Requires modification to our comment about fall through to match compilers
expectations.  Works for GCC and Clang.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-12 11:29:13 +10:00
Mark Ulrich
db102c67ef libalpm: prevent 301 redirect loop from hanging the process
If a mirror responds with a 301 redirect to itself, it will create an
infinite redirect loop. This will cause pacman to hang, unresponsive to
even a SIGINT. The result is pacman being unable to sync or
download any package from a particular repo if its current mirror
is stuck in a redirect loop. Setting libcurl's MAXREDIRS option
effectively prevents a redirect loop from hanging the process.

Signed-off-by: Mark Ulrich <mark.ulrich.86@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-07 09:51:01 +10:00
Allan McRae
714a1b4e4e I blame everyone but me for this
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-07 09:50:49 +10:00
morganamilo
04e77591d6 fix various typos
Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-04 10:17:30 +10:00
morganamilo
11bc315cdb libmakepkg: lint disallowed architecture specific variables
Variables such as 'pkgdesc_x86_64' are invalid, instead of ignoring them
raise an error.

This also disallows using 'any' as an architecture specific variable

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31 15:03:28 +10:00
morganamilo
14755df06f libmakepkg: lint disallowed variables in package()
makepkg will now error if disallowed variables are set inside of
the package function.

Disallowed variables are variables that do exist, like 'makedepends'
and 'pkgver' but can not be set inside of a package function.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31 15:03:25 +10:00
morganamilo
75aae126c4 libmakepkg: centralise random arrays of pkgbuild variables
Refactor many of the different arrays of pkgbuild variables
into scripts/libmakepkg/util/schema.sh.in.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31 10:02:37 +10:00
Allan McRae
6cf0548128 makepkg: use --unneeded for pacman call in remove_deps()
This patch was inspired by FS#32723 which asks makepkg to install makedepends
before depends.  The use case is to build a package depending on a virtual
package that is only provided by other packages (e.g. java-runtime in Arch
Linux), but wanting to build against a specific version.  Installing makedepends
first (but not at the same time as depends) would allow specifying the version
to build against, instead of pacman resolving to the default version when
installing depends.

It turns out, we can already achieve installing makedepends first by specifying
dependencies only in the package function (and making sure makedepends includes
everything needed). The only issue is that if we use makepkg to install the
built package with the --install flag and along with the --rmdeps flag, we will
try to remove any installed dependencies that are specified in the depends
array in the package function.  To counter this, we need to use the --unneeded
flag for the pacman call.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-30 13:39:35 +10:00
Chloe Kudryavtsev
776fbe1cde libmakepkg: Add lzip ext support
lzip is a lossless data compressor designed to replace gzip and bzip2 as
the standard general-purpose compressed format.
- add .lz (lzip) support to libmakepkg/util/compress.sh:compress_as
- add COMPRESSLZ to makepkg.conf.in
- document COMPRESSLZ
- document PKGEXT with `.tar.lz`

Signed-off-by: Chloe Kudryavtsev <toast@toastin.space>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-30 10:06:55 +10:00
morganamilo
5bd54fa0c6 libmakepkg: move checkdepends to the correct array
Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22 11:06:11 +10:00
Eli Schwartz
1e040153bc libmakepkg: Implement extendable signature verification
Lookup the existence of matching functions for each protocol, and
fallback on the generic file handler. New verification protocols can
then be added via thirdparty libmakepkg drop-ins without requiring
modifications to verify_signature.sh

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22 09:42:38 +10:00
Eli Schwartz
9c817b6549 libmakepkg: implement extendable source protocols
Lookup the existence of matching functions for each protocol, and
fallback on the generic file handler. New source protocols can then be
added via thirdparty libmakepkg drop-ins without requiring modifications
to source.sh

Fixes FS#49076

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22 09:38:31 +10:00
Eli Schwartz
ac0e21a6df libmakepkg: optimize get_protocol to always return proto, not proto+uri
e.g. git+https:// is commonly used for git repositories cloned over
HTTPS, but we assume a proto with a plus in it is actually a protocol
followed by some URI handler. So we might as well simplify the return
value and not have to always add glob matching everywhere when checking
the proto in use.

This is required in order to use the proto directly in function calls,
which will be used in a followup patch.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22 09:38:21 +10:00
Eli Schwartz
1b9e358f1d libmakepkg: make gettext replacements more templated
Making the undescore be translated is probably not something we need
translators to think about.

Additionally, a number of places which use the same text differ only by
the variable being referenced, so simplifying the string means we can
drop a redundant translation.

Bonus: we save a few bytes here and there. \o/
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22 07:32:41 +10:00
morganamilo
4d1d857ef0 libalpm: fix minor typo in _alpm_db_usage_
Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-21 13:47:23 +10:00
Allan McRae
ff8c96fa7d Fix typo in pacman man page
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-21 13:20:47 +10:00
morganamilo
c15f7ae606 libmakepkg: disallow using 'any' with other arches
Error if the arch array contains any and any other values. This also
fixes a bug where the check for `$arch == 'any'` which only evaluated
the first value in the array, meaning the rest of the values would not
be linted.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-16 11:23:17 +10:00
Eli Schwartz
a5090217f9 meson: fix website target
A number of pages don't actually exist as html inside the source tree,
and need to be generated even though they are manpages.

This caused the website.tar.gz target to only work inside a dirty tree
initially created by autotools.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-16 11:22:48 +10:00
Eli Schwartz
10bcf66db8 update a bunch of links for https and to adapt to changing domains
projects.archlinux.org and mailman.archlinux.org are both migrated to
new domains.

Transifex supports https, so encourage its use by default.

Take advantage of the opportunity when updating these links, to also
delist some projects that are dead.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-14 13:35:47 +10:00
Eli Schwartz
02598521b1 doc: add a couple missing manpages from the html index
The index embeds the names of all doc subpages, and these were never
updated.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-14 13:19:05 +10:00
Eli Schwartz
a769fbfd40 doc: keep manpages and html pages in sync
We forgot to add BUILDINFO to the list of html docs. Instead of always
updating things in two places, just derive the one from the other.

meson did not have this problem as it already derives both lists from
one template.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-14 13:15:11 +10:00
Eli Schwartz
b76dbb1159 meson: fix regression that broke building libmakepkg
In commit f7efa6a93d we added a new file,
and also wired it up to the build systems, but it got added under the
wrong name in meson.build

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-14 13:12:33 +10:00
Eli Schwartz
ce040514c4 makepkg: return E_PKGBUILD_ERROR for nonexistent PKGBUILD
This is not really an error with a "user function".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:07:23 +10:00
Eli Schwartz
5d2f7ee6c3 libmakepkg: simplify splitting command output into array
Use mapfile instead of hacking around read -a with the $IFS.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:03:04 +10:00
Eli Schwartz
031611ff40 libmakepkg: add routine for linting $SOURCE_DATE_EPOCH
This can only ever be an int, and the specification states that a
malformed timestamp should be considered a fatal error.

https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:01:30 +10:00
Eli Schwartz
10fe71e5f3 makepkg: fix unguarded use of printf
paths can contain printf-unsafe chars, and printf -v is not somehow immune to this

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:00:05 +10:00
Luke Shumaker
aa284c97f1 makepkg: check_pkgrel: Don't say "decimal" in the error message
If you have a malformed pkgrel, the error message says that it must be a
"decimal".  That isn't quite true, as that would mean that `1.1 == 1.10`.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:00:05 +10:00
Luke Shumaker
f7efa6a93d makepkg: Better error messages for versions in (check, make, opt)depends/provides/conflicts
Given the depends

    depends=('foo>=1.2-1.par2')

and the error message

    ==> ERROR: pkgver in depends is not allowed to contain colons, forward slashes, hyphens or whitespace.

One would be lead to believe that the problem is that they gave a pkgrel in
depends at all, not that the pkgrel contains letters.

Each of the (check,make,opt)depends, conflicts, and provides linters use a
glob to trim off properly formed epoch an rel from the full version string,
and pass the remainder to check_pkgver().  This does a good job of
accepting/rejecting full versions, but doesn't do a good job of generating
good error messages when rejecting if it's because of the epoch or rel.

1. Factor out check_epoch() and check_pkgrel() from lint_epoch() and
   lint_pkgrel(), similarly to check_pkgver().
2. Add a check_fullpkgver() that takes a full [epoch:]ver[-rel] string and
   splits it in to epoch/ver/rel, and calls the appropriate check_ function
   on each.
3. Use check_fullpkgver() in the {,check,make,opt}depends, conflicts, and
   provides linters.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 17:00:03 +10:00
Eli Schwartz
30e3e21e87 libmakepkg/lint_pkgbuild: check for invalid variables even if they're empty
Checking the length of the variable to be non-zero before considering it
an error is inconsistent; license=() and depends='' and `declare arch`
should be considered just as wrong.

In fact the current check detects depends='' as non-zero and returns an
error, but happily considers the others to be perfectly okay.

A more reliable check is to simply see if the name has been declared
(whether it is set or not), and then enforce that it's been declared to
the right type.

As an added benefit, avoiding the creation of proxy-evaled variables to
count the number of indexes results in simpler code.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 15:21:13 +10:00
Allan McRae
03d85763e0 Add [ignored] to -Qu output for packages in repos that are not Usage = Upgrade
List all available updates in -Qu output, but include [ignored] beside
those that will not be updated in a -Su operation due to thier repo Usage
value (in addition to those that are Ignored).

Fixes FS#59854.

The following people provided initial patches to print [ignored] on -Qu
operations, which highlighted a larger problem to be fixed first:

With-thanks-to: morganamilo <morganamilo@gmail.com>
With-thanks-to: Michael Straube <michael.straube@posteo.de>

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 14:14:04 +10:00
Allan McRae
e9d91a688d libalpm/sync.c: change alpm_sync_newversion() to alpm_sync_get_new_version()
The behaviour of "pacman -Qu" was very strange...  It would only consider
packages from repos with Usage = Search (or All), and ignore those with
Usage = Sync, Install or Upgrade.

This is because the function alpm_sync_newversion() used ALPM_DB_USAGE_SEARCH
for its filtering. Given this function is documented (at least in the source)
to "Check for new version of pkg in sync repos", I would expect that to look at
all repos. However, just changing this parameter, would result in a fairly
silent change in behaviour of this function. Instead, rename the function
and remove this filtering altogether.  Users of this function can filter
the dbs passed to this function to achieve their desired output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 14:14:04 +10:00
Allan McRae
9b2a90cfb1 Add -fstack-clash-protection to CFLAGS in debug builds if available
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 14:14:04 +10:00
Allan McRae
9b637cc27a be_local.c: remove aligment in local_pkg_ops
The alignment was not overly helpful and caused unnecessary churn when a new
value with longer name was added.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 14:10:55 +10:00
morganamilo
f9eb2aacb4 libalpm: parse {check, make}depends when reading database
Commit 0994893b0e added the
alpm_pkg_get_{make,check}depends functions but forgot to include
logic for parsing these fields from the database. As a result these
functions will always return an empty list.

This commit adds the parsing logic.

Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 14:04:59 +10:00
Eli Schwartz
238fa4af45 makepkg: fix broken check for the fakeroot binary
In commit d8ee8d0c99 we made use of
fakeroot absolutely mandatory, and disabled a lot of the code which
checked to see if this now-defunct BUILDENV option was set, before
setting up the environment to use fakeroot. Unfortunately, we missed one
spot.

The check_software routine still checked to see if fakeroot was
enabled, but due to the option being removed, thought that it was in
fact disabled, and as a result this check would never run.

Fix by checking to see if we are trying to build either a package or a
source package, and if so, checking for fakeroot. These are the only two
situations where fakeroot is needed.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 13:25:12 +10:00
Eli Schwartz
268b0255fa makepkg: add internal variable to track when we're building a package
There are state variables for everything else, and we use them to do
conditional checks on things, but it's currently a bit difficult to test
whether a package is being built, as it's the default action if *no*
options are specified.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10 13:25:12 +10:00
Jan Alexander Steffens (heftig)
c5c7fc7f4a makepkg: Make pkgdir a local
Causes it to be reset (to $pkgdirbase/$pkgbase) between subpackages.
This shouldn't be visible.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 15:43:41 +10:00
Jan Alexander Steffens (heftig)
2f15921230 makepkg: Create a single-package packaging function
Merge the similar code handling unsplit PKGBUILDs and individual
packages in a split PKGBUILD and make it a new function.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 15:43:41 +10:00
Jan Alexander Steffens (heftig)
7c5958e0eb makepkg: Only backup package variables once
We don't need to re-backup the variables we restored on the previous
iteration.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 15:43:41 +10:00
Michael Straube
e1fc2f901e libalpm/add.c: move assignment into conditional in alpm_add_pkg
While at it and for consistency move the assignment of the variable
'local' into the subsequent conditional.

Signed-off-by: Michael Straube <michael.straube@posteo.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:32:49 +10:00
Michael Straube
3a5a0d53bc Move skipping of duplicate sync/remove targets into libalpm
sync:
As pointed out by Andrew Gregory there could be an error when adding
duplicates if they are two separate packages with the same name. Add a
check in alpm_add_pkg() to test whether the duplicate is actually the
same package, and if so, log a debug message and return success to skip
the package. If the duplicate is a different package return
ALPM_ERR_TRANS_DUP_TARGET and treat that error just like any other error
in pacman.

remove:
Change alpm_remove_pkg() to just log a debug message and return success
to skip duplicates. Remove the handling of ALPM_ERR_TRANS_DUP_TARGET in
pacman.

Also fixes FS#49377.

Suggested-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Michael Straube <michael.straube@posteo.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:31:55 +10:00
Eli Schwartz
984492b92f repo-add: don't break if delta package sources contain epoch
Our sed parser for xdelta3 headers will greedily match on ":" which
coincidentally is also the character we use to define a version with an
epoch.

While we are at it, simply use sed for the whole pipeline, rather than
using both grep and sed.

Fixes FS#61195

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:15:16 +10:00
Eli Schwartz
4778f13188 repo-remove: fix removing packages with deltas
We have code in order to remove deltas when removing a package, but it
is never run, since we try to remove the wrong file.

This was broken in commit cb0f2bd038 which
modified the internal layout we use to modify the db, changing "tree" to
"db", but did not update all locations where it was used.

This worked swimmingly well as long as only repo-add updates were
handling the backup and restore of the delta file, as the delta file
therefore got backed up to the correct location (db) in the shared
db_remove_entry() function.

But later on in the repo-remove logic, we tried removing a different
file that will never exist (tree).

Fixes FS#53041

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:14:52 +10:00
Andrew Gregory
2d403709d9 allow tests for disabled features to be skipped
Previously, pacman's test suite would fail when compiled without
signature support.

Adds a require_capability method to pmtest objects.  Currently
recognized values are 'gpg', 'curl', and 'nls'; although only gpg is
used presently.  Missing features are indicated by running pactest with
one of the --without-<feature> options.

This modifies pmenv to run each case as independent tests.  Previously,
a single pmenv could run multiple tests, combining there output into
a single TAP stream but making it impossible to properly skip an entire
test case.  This change does not affect running pactest.py with a single
test (as both autotools and meson do), but will affect anybody manually
running pactest.py with multiple tests at once.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:10:47 +10:00
Andrew Gregory
ecac357c1a tap.py: add skip_all function
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:10:37 +10:00
Andrew Gregory
d150b97190 remove unused test summary code
Unused since 12e00af531

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:09:48 +10:00
Andrew Gregory
33a8ced334 silence warning when built without curl
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:08:54 +10:00
84 changed files with 804 additions and 691 deletions

View File

@@ -1,4 +1,4 @@
SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/makepkg test/pacman test/util test/scripts
SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util test/scripts
if WANT_DOC
SUBDIRS += doc
endif
@@ -27,15 +27,11 @@ dist_pkgdata_DATA = \
$(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py)
@printf "TESTS += %s\n" $^ | LC_ALL=C sort -u > "$@"
$(top_srcdir)/test/makepkg/tests/TESTS: $(wildcard test/makepkg/tests/*.sh)
@printf "TESTS += %s\n" $^ | LC_ALL=C sort -u > "$@"
TESTS = test/scripts/parseopts_test.sh \
test/scripts/human_to_size_test.sh \
test/scripts/makepkg-template_test.sh \
test/scripts/pacman-db-upgrade-v9.py \
test/util/vercmptest.sh
include $(top_srcdir)/test/makepkg/tests/TESTS
include $(top_srcdir)/test/pacman/tests/TESTS
TEST_SUITE_LOG = test/test-suite.log
@@ -55,6 +51,12 @@ AM_PY_LOG_FLAGS = \
--ldconfig $(LDCONFIG) \
--bindir $(top_builddir)/src/pacman \
--bindir $(top_builddir)/scripts
if !HAVE_LIBGPGME
AM_PY_LOG_FLAGS += --without-gpg
endif
if !HAVE_LIBCURL
AM_PY_LOG_FLAGS += --without-curl
endif
# create the pacman DB, cache, makepkg-template and system hook directories upon install
install-data-local:

12
NEWS
View File

@@ -167,7 +167,7 @@ VERSION DESCRIPTION
- fix triggering of Install hooks (FS#47996)
- fix handling of stdin scripts called by pacman
- hook activity is logged
- documentataion updates for alpm-hooks (FS#48080)
- documentation updates for alpm-hooks (FS#48080)
- makepkg:
- increase robustness of variable array checks
- makepkg -g does not perform current architecture checks
@@ -259,9 +259,9 @@ VERSION DESCRIPTION
- Fix removal of static libraries when the shared library
uses the absolute path in symbolic links (FS#43395)
- Improve Bazaar cloning (FS#43448)
- Fix issues with architecture dependant checksum
- Fix issues with architecture dependent checksum
verification (FS#43192)
- Fix .SRCINFO file with architecture dependant fields
- Fix .SRCINFO file with architecture dependent fields
(FS#43247)
- Fix compatibility with older bash versions
- Allow git checkouts to be downloaded into directory ending
@@ -351,7 +351,7 @@ VERSION DESCRIPTION
- checkupdates: rename CHECKUPDATE_DB to CHECKUPDATES_DB
- pacdiff: add a "Quit" option, and many other improvements
- pacsysclean is removed
4.1.2 - validate %FILEPATH% when parsing repos to prevent arbitary
4.1.2 - validate %FILEPATH% when parsing repos to prevent arbitrary
file overwrites from malicious databases
- makepkg:
- restrict package name from starting with a dot
@@ -816,7 +816,7 @@ VERSION DESCRIPTION
- repo-add: use openssl instead of md5sum
- simplify doc building process for ease of development
- ensure correct handling of syscall interruptions
- readd missing newline on -Qi/-Si output (FS#11331)
- re-add missing newline on -Qi/-Si output (FS#11331)
- fix TotalDownload regression (FS#11339)
- makepkg:
- replace getopt with an internal function
@@ -1262,7 +1262,7 @@ VERSION DESCRIPTION
external download utility like wget
- added a license field to package meta-data
- add url support to -A and -U operations (download packages)
- -Ss now searches thru provides fields
- -Ss now searches through provides fields
- added --dbonly option to -R
2.7.6 - added --print-uris option
- fixed an http download bug (FS#667)

View File

@@ -72,7 +72,7 @@ if test "x$CFLAGS" = "x"; then
CFLAGS=""
fi
# Set subsitution values for version stuff in Makefiles and anywhere else,
# Set substitution values for version stuff in Makefiles and anywhere else,
# and put LIB_VERSION in config.h
AC_SUBST(LIB_VERSION)
AC_SUBST(LIB_VERSION_INFO)
@@ -443,6 +443,7 @@ if test "x$debug" = "xyes" ; then
# Check for -fstack-protector availability
GCC_STACK_PROTECT_LIB
GCC_STACK_PROTECT_CC
GCC_STACK_CLASH_PROTECTION
GCC_FORTIFY_SOURCE_CC
WARNING_CFLAGS="-g -Wall -Werror"
else
@@ -461,6 +462,7 @@ if test "x$warningflags" = "xyes" ; then
CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS])
CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS])
CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS])
CFLAGS_ADD([-Wimplicit-fallthrough], [WARNING_CFLAGS])
CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS])
CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS])
@@ -539,8 +541,6 @@ scripts/Makefile
scripts/po/Makefile.in
doc/Makefile
etc/Makefile
test/makepkg/Makefile
test/makepkg/tests/Makefile
test/pacman/Makefile
test/pacman/tests/Makefile
test/scripts/Makefile

View File

@@ -16,23 +16,12 @@ MANPAGES = \
makepkg.conf.5 \
pacman.conf.5 \
libalpm.3 \
BUILDINFO.5
BUILDINFO.5 \
pacman-conf.8
DOXYGEN_MANS = $(wildcard man3/*.3)
HTML_MANPAGES = \
alpm-hooks.5.html \
pacman.8.html \
makepkg.8.html \
makepkg-template.1.html \
repo-add.8.html \
vercmp.8.html \
pkgdelta.8.html \
pacman-key.8.html \
PKGBUILD.5.html \
makepkg.conf.5.html \
pacman.conf.5.html \
libalpm.3.html
HTML_MANPAGES = $(addsuffix .html,$(MANPAGES))
HTML_OTHER = \
index.html \
@@ -124,7 +113,8 @@ ASCIIDOC_OPTS = \
-a pkgdatadir=$(pkgdatadir) \
-a localstatedir=$(localstatedir) \
-a sysconfdir=$(sysconfdir) \
-a datarootdir=$(datarootdir)
-a datarootdir=$(datarootdir) \
-a rootdir=$(ROOTDIR)
A2X_OPTS = \
--no-xmllint \

View File

@@ -60,8 +60,8 @@ systems (see below).
allows package maintainers to make updates to the package's configure
flags, for example. This is typically set to '1' for each new upstream
software release and incremented for intermediate PKGBUILD updates. The
variable is a postive integer, with an optional subrelease level
specified by adding another postive integer separated by a period
variable is a positive integer, with an optional subrelease level
specified by adding another positive integer separated by a period
(i.e. in the form x.y).
*epoch*::
@@ -154,7 +154,7 @@ contain whitespace characters.
be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
If desired, move the md5sums line to an appropriate location.
*sha1sums, sha224sums, sha256sums, sha384sums, sha512sums (arrays)*::
*sha1sums, sha224sums, sha256sums, sha384sums, sha512sums, b2sums (arrays)*::
Alternative integrity checks that makepkg supports; these all behave
similar to the md5sums option described above. To enable use and generation
of these checksums, be sure to set up the `INTEGRITY_CHECK` option in

View File

@@ -43,9 +43,11 @@ There are several man pages available for the programs, utilities, and
configuration files dealing with pacman.
* linkman:alpm-hooks[5]
* linkman:BUILDINFO[5]
* linkman:PKGBUILD[5]
* linkman:libalpm[3]
* linkman:makepkg[8]
* linkman:makepkg-template[1]
* linkman:makepkg.conf[5]
* linkman:pacman[8]
* linkman:pacman-key[8]
@@ -57,11 +59,11 @@ configuration files dealing with pacman.
Changelog
~~~~~~~~~
For a good idea of what is going on in pacman development, take a look at the
link:https://projects.archlinux.org/pacman.git/[Git summary page] for the
link:https://git.archlinux.org/pacman.git/[Git summary page] for the
project.
See the most recent
link:https://projects.archlinux.org/pacman.git/tree/NEWS[NEWS]
link:https://git.archlinux.org/pacman.git/tree/NEWS[NEWS]
file for a not-as-frequently-updated list of changes. However, this should
contain the biggest changes in a format more concise than the commit log.
@@ -201,8 +203,8 @@ Development
Mailing List
~~~~~~~~~~~~
There is a mailing list devoted to pacman development, hosted by Arch Linux.
link:https://mailman.archlinux.org/mailman/listinfo/pacman-dev/[Subscribe] or
link:https://mailman.archlinux.org/pipermail/pacman-dev/[view the archives].
link:https://lists.archlinux.org/listinfo/pacman-dev/[Subscribe] or
link:https://lists.archlinux.org/pipermail/pacman-dev/[view the archives].
Source Code
~~~~~~~~~~~
@@ -213,11 +215,11 @@ these trees).
The current development tree can be fetched with the following command:
git clone git://projects.archlinux.org/pacman.git pacman
git clone git://git.archlinux.org/pacman.git pacman
which will fetch the full development history into a directory named pacman.
You can browse the source as well using
link:https://projects.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also
link:https://git.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also
available for cloning purposes; these URLs are listed at the above page.
If you are interested in hacking on pacman, it is highly recommended you join
@@ -236,15 +238,13 @@ Although the package manager itself is quite simple, many scripts have been
developed that help automate building and installing packages. These are used
extensively in link:https://www.archlinux.org/[Arch Linux]. Most of these utilities
are available in the Arch Linux projects
link:https://projects.archlinux.org/[code browser].
link:https://git.archlinux.org/[code browser].
Utilities available:
* link:https://projects.archlinux.org/abs.git/[abs] - ABS (Arch Build System), scripts to download & use the Arch Linux PKGBUILD tree
* link:https://projects.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories
* link:https://projects.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking
* link:https://projects.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python
* link:https://projects.archlinux.org/srcpac.git/[srcpac] - a bash build-from-source pacman wrapper
* link:https://git.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories
* link:https://git.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking
* link:https://git.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python
Bugs
----

View File

@@ -183,7 +183,7 @@ Options
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
`md5`, `sha1`, `sha224`, `sha256`, `sha384`, and `sha512`.
`md5`, `sha1`, `sha224`, `sha256`, `sha384`, `sha512`, and `b2`.
**STRIP_BINARIES=**"--strip-all"::
Options to be used when stripping binaries. See linkman:strip[1]
@@ -254,13 +254,14 @@ Options
**COMPRESSLRZ=**"(lrzip -q)"::
**COMPRESSLZ4=**"(lz4 -q)"::
**COMPRESSZ=**"(compress -c -f)"::
**COMPRESSLZ=**"(lzip -c -f)"::
Sets the command and options used when compressing compiled or source
packages in the named format.
**PKGEXT=**".pkg.tar.gz", **SRCEXT=**".src.tar.gz"::
Sets the compression used when making compiled or source packages.
Valid suffixes are `.tar`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, `.tar.zst`,
`.tar.lzo`, `.tar.lrz`, `.tar.lz4`, and `.tar.Z`.
`.tar.lzo`, `.tar.lrz`, `.tar.lz4`, `.tar.lz` and `.tar.Z`.
Do not touch these unless you know what you are doing.

View File

@@ -12,6 +12,14 @@ manpages = [
{ 'name': 'pacman.conf.5' },
{ 'name': 'libalpm.3' },
{ 'name': 'BUILDINFO.5' },
{ 'name': 'pacman-conf.8' },
]
sitepages = [
{ 'name': 'submitting-patches' },
{ 'name': 'translation-help' },
{ 'name': 'HACKING', 'source': '../HACKING' },
{ 'name': 'index' },
]
asciidoc_conf = join_paths(meson.current_source_dir(), 'asciidoc.conf')
@@ -24,6 +32,7 @@ asciidoc_opts = [
'-a', 'localstatedir=@0@'.format(LOCALSTATEDIR),
'-a', 'sysconfdir=@0@'.format(SYSCONFDIR),
'-a', 'datarootdir=@0@'.format(DATAROOTDIR),
'-a', 'rootdir=@0@'.format(ROOTDIR),
]
html_targets = []
@@ -58,6 +67,12 @@ foreach page : manpages
install : true,
install_dir : mandirn,
)
endforeach
foreach page: manpages + sitepages
manpage = page['name']
htmlpage = '@0@.html'.format(manpage)
input = page.get('source', '@0@.asciidoc'.format(manpage))
html = custom_target(
htmlpage,
@@ -96,10 +111,6 @@ custom_target(
'-C', meson.current_build_dir(),
] + html_files + [
'-C', meson.current_source_dir(),
'submitting-patches.html',
'translation-help.html',
'HACKING.html',
'index.html',
'asciidoc-override.css',
'-C', '/etc/asciidoc/stylesheets/',
'asciidoc.css',

View File

@@ -0,0 +1,67 @@
pacman-conf(8)
==============
Name
----
pacman-conf - query pacman's configuration file
Synopsis
--------
'pacman-conf' [options] [<directive> ...]
'pacman-conf' (--repo-list|--help|--version)
Description
-----------
'pacman-conf' is a utility for parsing the 'pacman' configuration file
and returning script-friendly output. It is designed to properly handle
non-trivial configuration features such as variable interpolation and
the use of the Include directive, and guarantees that it will return the
same configuration values which 'pacman' itself would use.
'pacman-conf' will output the fully-resolved contents of the
configuration file by default, or, if provided with the name of a
configuration directive, output the contents of the given directive alone.
Options
-------
*-c, \--config* <path>::
Specify an alternate configuration file.
*-R, \--rootdir* <path>::
Specify an alternate installation root (default is `/`).
*-r, \--repo* <remote>::
Query options for a specific repository.
*-v, \--verbose*::
Always shown directive names.
*-l, \--repo-list*::
List configured repositories.
*-h, \--help*::
Output syntax and command line options.
*-V, \--version*::
Display version and exit.
Examples
--------
pacman-conf -r core Usage::
Show the value of the Usage configuration option for core repository.
pacman-conf HoldPkg::
Show the value of the HoldPkg configuration option.
See Also
--------
linkman:pacman.conf[5]
include::footer.asciidoc[]

View File

@@ -131,7 +131,7 @@ Options
not automatically prepended.
*-r, \--root* <path>::
Specify an alternative installation root (default is `/`). This should
Specify an alternative installation root (default is +{rootdir}+). This should
not be used as a way to install software into `/usr/local` instead of
`/usr`.
*NOTE*: If database path or log file are not specified on either the
@@ -514,7 +514,7 @@ designated to be backed up. During an upgrade, three MD5 hashes are used for
each backup file to determine the required action: one for the original file
installed, one for the new file that is about to be installed, and one for the
actual file existing on the file system. After comparing these three hashes, the
follow scenarios can result:
following scenarios can result:
original=X, current=X, new=X::
All three files are the same, so overwrites are not an issue. Install the

View File

@@ -20,7 +20,7 @@ started with GIT if you have not worked with it before.
The pacman code can be fetched using the following command:
git clone git://projects.archlinux.org/pacman.git
git clone git://git.archlinux.org/pacman.git
Creating your patch

View File

@@ -4,10 +4,10 @@ Pacman - Translating
This document is here to guide you in helping translate pacman messages,
libalpm messages, and the manual pages for the entire pacman package.
We are currently using http://www.transifex.com/[Transifex] as the translation
We are currently using https://www.transifex.com/[Transifex] as the translation
platform for pacman and libalpm. You will need to sign up for an account there
and then register with a translation team on the
http://www.transifex.com/projects/p/archlinux-pacman/[pacman project page].
https://www.transifex.com/projects/p/archlinux-pacman/[pacman project page].
NOTE: This may be old information due to our switch to Transifex, but the
gettext website is a very useful guide to read before embarking on translation
@@ -31,7 +31,7 @@ either be hand-edited, or modified with a tool such as poedit, gtranslator or
kbabel. Using a translation tool tends to make the job easier.
Please read up on Transifex usage using the
http://docs.transifex.com/[Transifex Help] if you are not familiar.
https://docs.transifex.com/[Transifex Help] if you are not familiar.
Transifex provides a command-line client to help with translations. Here is
an example set of commands if you have a source code checkout and are not
@@ -78,7 +78,7 @@ Incremental Updates
If you have more advanced needs you will have to get a copy of the pacman
repository.
git clone git://projects.archlinux.org/pacman.git pacman
git clone git://git.archlinux.org/pacman.git pacman
Next, you will need to run `./autogen.sh` and `./configure` in the base
directory to generate the correct Makefiles. At this point, all necessary

View File

@@ -87,7 +87,7 @@ BUILDENV=(!distcc color !ccache check !sign)
#
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="@STRIP_BINARIES@"
@@ -135,6 +135,7 @@ COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)
#########################################################################
# EXTENSION DEFAULTS

View File

@@ -53,6 +53,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
const char *pkgname, *pkgver;
alpm_trans_t *trans;
alpm_pkg_t *local;
alpm_pkg_t *dup;
/* Sanity checks */
CHECK_HANDLE(handle, return -1);
@@ -70,12 +71,16 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
_alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname);
if(alpm_pkg_find(trans->add, pkgname)) {
if((dup = alpm_pkg_find(trans->add, pkgname))) {
if(dup == pkg) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping duplicate target: %s\n", pkgname);
return 0;
}
/* error for separate packages with the same name */
RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
}
local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
if(local) {
if((local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname))) {
const char *localpkgname = local->name;
const char *localpkgver = local->version;
int cmp = _alpm_pkg_compare_versions(pkg, local);

View File

@@ -1046,7 +1046,7 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
*/
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
typedef enum _alpm_db_usage_ {
typedef enum _alpm_db_usage_t {
ALPM_DB_USAGE_SYNC = 1,
ALPM_DB_USAGE_SEARCH = (1 << 1),
ALPM_DB_USAGE_INSTALL = (1 << 2),
@@ -1452,7 +1452,7 @@ alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name);
* Sync
*/
alpm_pkg_t *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
/** @addtogroup alpm_api_trans Transaction Functions
* Functions to manipulate libalpm transactions

View File

@@ -153,6 +153,18 @@ static alpm_list_t *_cache_get_optdepends(alpm_pkg_t *pkg)
return pkg->optdepends;
}
static alpm_list_t *_cache_get_makedepends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
return pkg->makedepends;
}
static alpm_list_t *_cache_get_checkdepends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
return pkg->checkdepends;
}
static alpm_list_t *_cache_get_conflicts(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
@@ -303,36 +315,38 @@ static int _cache_force_load(alpm_pkg_t *pkg)
* logic.
*/
static struct pkg_operations local_pkg_ops = {
.get_base = _cache_get_base,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
.get_base = _cache_get_base,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
.get_installdate = _cache_get_installdate,
.get_packager = _cache_get_packager,
.get_arch = _cache_get_arch,
.get_isize = _cache_get_isize,
.get_reason = _cache_get_reason,
.get_validation = _cache_get_validation,
.has_scriptlet = _cache_has_scriptlet,
.get_licenses = _cache_get_licenses,
.get_groups = _cache_get_groups,
.get_depends = _cache_get_depends,
.get_optdepends = _cache_get_optdepends,
.get_conflicts = _cache_get_conflicts,
.get_provides = _cache_get_provides,
.get_replaces = _cache_get_replaces,
.get_files = _cache_get_files,
.get_backup = _cache_get_backup,
.get_packager = _cache_get_packager,
.get_arch = _cache_get_arch,
.get_isize = _cache_get_isize,
.get_reason = _cache_get_reason,
.get_validation = _cache_get_validation,
.has_scriptlet = _cache_has_scriptlet,
.get_licenses = _cache_get_licenses,
.get_groups = _cache_get_groups,
.get_depends = _cache_get_depends,
.get_optdepends = _cache_get_optdepends,
.get_makedepends = _cache_get_makedepends,
.get_checkdepends = _cache_get_checkdepends,
.get_conflicts = _cache_get_conflicts,
.get_provides = _cache_get_provides,
.get_replaces = _cache_get_replaces,
.get_files = _cache_get_files,
.get_backup = _cache_get_backup,
.changelog_open = _cache_changelog_open,
.changelog_read = _cache_changelog_read,
.changelog_open = _cache_changelog_open,
.changelog_read = _cache_changelog_read,
.changelog_close = _cache_changelog_close,
.mtree_open = _cache_mtree_open,
.mtree_next = _cache_mtree_next,
.mtree_close = _cache_mtree_close,
.mtree_open = _cache_mtree_open,
.mtree_next = _cache_mtree_next,
.mtree_close = _cache_mtree_close,
.force_load = _cache_force_load,
.force_load = _cache_force_load,
};
static int checkdbdir(alpm_db_t *db)
@@ -773,6 +787,10 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
READ_AND_SPLITDEP(info->depends);
} else if(strcmp(line, "%OPTDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->optdepends);
} else if(strcmp(line, "%MAKEDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->makedepends);
} else if(strcmp(line, "%CHECKDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->checkdepends);
} else if(strcmp(line, "%CONFLICTS%") == 0) {
READ_AND_SPLITDEP(info->conflicts);
} else if(strcmp(line, "%PROVIDES%") == 0) {

View File

@@ -700,17 +700,9 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
} else if(strcmp(line, "%OPTDEPENDS%") == 0) {
READ_AND_SPLITDEP(pkg->optdepends);
} else if(strcmp(line, "%MAKEDEPENDS%") == 0) {
/* currently unused */
while(1) {
READ_NEXT();
if(strlen(line) == 0) break;
}
READ_AND_SPLITDEP(pkg->makedepends);
} else if(strcmp(line, "%CHECKDEPENDS%") == 0) {
/* currently unused */
while(1) {
READ_NEXT();
if(strlen(line) == 0) break;
}
READ_AND_SPLITDEP(pkg->checkdepends);
} else if(strcmp(line, "%CONFLICTS%") == 0) {
READ_AND_SPLITDEP(pkg->conflicts);
} else if(strcmp(line, "%PROVIDES%") == 0) {

View File

@@ -259,6 +259,7 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10L);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@@ -534,7 +535,8 @@ static int curl_download_internal(struct dload_payload *payload,
if(payload->content_disp_name) {
/* content-disposition header has a better name for our file */
free(payload->destfile_name);
payload->destfile_name = get_fullpath(localpath, payload->content_disp_name, "");
payload->destfile_name = get_fullpath(localpath,
get_filename(payload->content_disp_name), "");
} else {
const char *effective_filename = strrchr(effective_url, '/');
if(effective_filename && strlen(effective_filename) > 2) {

View File

@@ -876,6 +876,8 @@ int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle,
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBCURL
handle->disable_dl_timeout = disable_dl_timeout;
#else
(void)disable_dl_timeout; /* silence unused variable warnings */
#endif
return 0;
}

View File

@@ -38,7 +38,7 @@
/** Package operations struct. This struct contains function pointers to
* all methods used to access data in a package to allow for things such
* as lazy package initialization (such as used by the file backend). Each
* backend is free to define a stuct containing pointers to a specific
* backend is free to define a struct containing pointers to a specific
* implementation of these methods. Some backends may find using the
* defined default_pkg_ops struct to work just fine for their needs.
*/

View File

@@ -74,7 +74,8 @@ int SYMEXPORT alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
pkgname = pkg->name;
if(alpm_pkg_find(trans->remove, pkgname)) {
RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping duplicate target: %s\n", pkgname);
return 0;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "adding package %s to the transaction remove list\n",

View File

@@ -182,7 +182,7 @@ static int init_gpgme(alpm_handle_t *handle)
#endif
/* NOTE:
* The GPGME library installs a SIGPIPE signal handler automatically if
* the default signal hander is in use. The only time we set a handler
* the default signal handler is in use. The only time we set a handler
* for SIGPIPE is in dload.c, and we reset it when we are done. Given that
* we do this, we can let GPGME do its automagic. However, if we install
* a library-wide SIGPIPE handler, we will have to be careful.

View File

@@ -51,7 +51,7 @@
/** Check for new version of pkg in sync repos
* (only the first occurrence is considered in sync)
*/
alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync)
alpm_pkg_t SYMEXPORT *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync)
{
alpm_list_t *i;
alpm_pkg_t *spkg = NULL;
@@ -61,10 +61,6 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
for(i = dbs_sync; !spkg && i; i = i->next) {
alpm_db_t *db = i->data;
if(!(db->usage & ALPM_DB_USAGE_SEARCH)) {
continue;
}
spkg = _alpm_db_get_pkgfromcache(db, pkg->name);
}

View File

@@ -38,6 +38,25 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
])
dnl GCC_STACK_CLASH_PROTECTION
dnl check -fstack-clash-protection with the C compiler, if it exists then
dnl updates CFLAGS
AC_DEFUN([GCC_STACK_CLASH_PROTECTION],[
AC_LANG_ASSERT(C)
if test "X$CC" != "X"; then
AC_CACHE_CHECK([whether ${CC} accepts -fstack-clash-protection],
scp_cv_cc,
[scp_old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fstack-clash-protection"
AC_TRY_COMPILE(,, scp_cv_cc=yes, scp_cv_cc=no)
CFLAGS="$scp_old_cflags"
])
if test $scp_cv_cc = yes; then
CFLAGS="$CFLAGS -fstack-clash-protection"
fi
fi
])
dnl GCC_FORTIFY_SOURCE_CC
dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
dnl CPPFLAGS

View File

@@ -220,6 +220,7 @@ if get_option('buildtype').startswith('debug')
'-Wformat-nonliteral',
'-Wformat-security',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough',
'-Winit-self',
'-Wlogical-op',
'-Wmissing-declarations',
@@ -354,15 +355,24 @@ libcommon = static_library(
include_directories : includes,
install : false)
libalpm = library(
libalpm_a = static_library(
'alpm',
libalpm_sources,
version : libalpm_version,
include_directories : includes,
dependencies : [crypto_provider, libarchive, libcurl] + gpgme_libs,
link_with : [libcommon],
install : true)
if get_option('default_library') != 'static'
libalpm = library(
'alpm',
version : libalpm_version,
link_whole: [libalpm_a],
install : true)
else
libalpm = libalpm_a
endif
install_headers(
'lib/libalpm/alpm.h',
'lib/libalpm/alpm_list.h')
@@ -413,7 +423,7 @@ executable(
'vercmp',
vercmp_sources,
include_directories : includes,
link_with : [libalpm],
link_with : [libalpm_a],
install : true,
)

View File

@@ -2,7 +2,7 @@
option('use-git-version', type : 'boolean', value : false,
description : 'take version information from git')
option('buildstatic', type : 'boolean', value : false,
description : 'if true, build staticly linked binaries')
description : 'if true, build statically linked binaries')
# directories and filenames
option('root-dir', type : 'string', value : '/',

View File

@@ -71,6 +71,7 @@ LIBMAKEPKG_IN = \
libmakepkg/integrity/verify_signature.sh \
libmakepkg/lint_config.sh \
libmakepkg/lint_config/paths.sh \
libmakepkg/lint_config/source_date_epoch.sh \
libmakepkg/lint_config/variable.sh \
libmakepkg/lint_package.sh \
libmakepkg/lint_package/build_references.sh \
@@ -79,17 +80,20 @@ LIBMAKEPKG_IN = \
libmakepkg/lint_package/missing_backup.sh \
libmakepkg/lint_pkgbuild.sh \
libmakepkg/lint_pkgbuild/arch.sh \
libmakepkg/lint_pkgbuild/arch_specific.sh \
libmakepkg/lint_pkgbuild/backup.sh \
libmakepkg/lint_pkgbuild/changelog.sh \
libmakepkg/lint_pkgbuild/checkdepends.sh \
libmakepkg/lint_pkgbuild/conflicts.sh \
libmakepkg/lint_pkgbuild/depends.sh \
libmakepkg/lint_pkgbuild/epoch.sh \
libmakepkg/lint_pkgbuild/fullpkgver.sh \
libmakepkg/lint_pkgbuild/install.sh \
libmakepkg/lint_pkgbuild/makedepends.sh \
libmakepkg/lint_pkgbuild/optdepends.sh \
libmakepkg/lint_pkgbuild/options.sh \
libmakepkg/lint_pkgbuild/package_function.sh \
libmakepkg/lint_pkgbuild/package_function_variable.sh \
libmakepkg/lint_pkgbuild/pkgbase.sh \
libmakepkg/lint_pkgbuild/pkglist.sh \
libmakepkg/lint_pkgbuild/pkgname.sh \
@@ -122,6 +126,7 @@ LIBMAKEPKG_IN = \
libmakepkg/util/option.sh \
libmakepkg/util/parseopts.sh \
libmakepkg/util/pkgbuild.sh \
libmakepkg/util/schema.sh \
libmakepkg/util/source.sh \
libmakepkg/util/util.sh

View File

@@ -29,7 +29,7 @@ executable_functions+=('executable_checksum')
executable_checksum() {
if (( GENINTEG || ! SKIPCHECKSUMS )); then
local integlist
IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
mapfile -t integlist < <(get_integlist)
local integ
for integ in "${integlist[@]}"; do

View File

@@ -28,7 +28,7 @@ source "$LIBRARY/util/option.sh"
executable_functions+=('executable_fakeroot')
executable_fakeroot() {
if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
if (( SOURCEONLY || BUILDPKG )); then
if ! type -p fakeroot >/dev/null; then
error "$(gettext "Cannot find the %s binary.")" "fakeroot"
return 1

View File

@@ -1,6 +1,6 @@
#!/usr/bin/bash
#
# strip.sh - Confirm presense of strip binary
# strip.sh - Confirm presence of strip binary
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
#

View File

@@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
generate_one_checksum() {
local integ=$1 arch=$2 sources numsrc indentsz idx
@@ -52,7 +53,7 @@ generate_one_checksum() {
proto="$(get_protocol "$netfile")"
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
sum="SKIP"
;;
*)

View File

@@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
check_checksums() {
local integ a

View File

@@ -49,8 +49,8 @@ check_pgpsigs() {
for netfile in "${all_sources[@]}"; do
proto="$(get_protocol "$netfile")"
if [[ $proto = git* ]]; then
verify_git_signature "$netfile" "$statusfile" || continue
if declare -f verify_${proto}_signature > /dev/null; then
verify_${proto}_signature "$netfile" "$statusfile" || continue
else
verify_file_signature "$netfile" "$statusfile" || continue
fi
@@ -263,7 +263,8 @@ source_has_signatures() {
proto="$(get_protocol "$netfile")"
query=$(get_uri_query "$netfile")
if [[ ${netfile%%::*} = *.@(sig?(n)|asc) || ( $proto = git* && $query = signed ) ]]; then
if [[ ${netfile%%::*} = *.@(sig?(n)|asc) ]] || \
( declare -f verify_${proto}_signature > /dev/null && [[ $query = signed ]] ); then
return 0
fi
done

View File

@@ -2,6 +2,7 @@ libmakepkg_module = 'lint_config'
sources = [
'paths.sh.in',
'source_date_epoch.sh.in',
'variable.sh.in',
]

View File

@@ -0,0 +1,37 @@
#!/bin/bash
#
# source_date_epoch.sh - Check that reproducible builds timestamp is valid
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n $LIBMAKEPKG_LINT_CONFIG_SOURCE_DATE_EPOCH_SH ]] && return
LIBMAKEPKG_LINT_CONFIG_SOURCE_DATE_EPOCH_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
lint_config_functions+=('lint_source_date_epoch')
lint_source_date_epoch() {
if [[ $SOURCE_DATE_EPOCH = *[^[:digit:]]* ]]; then
error "$(gettext "%s contains invalid characters: %s")" \
"\$SOURCE_DATE_EPOCH" "${SOURCE_DATE_EPOCH//[[:digit:]]}"
return 1
fi
}

View File

@@ -33,8 +33,13 @@ lint_pkgbuild_functions+=('lint_arch')
lint_arch() {
local a name list ret=0
if [[ $arch == 'any' ]]; then
return 0
if in_array "any" "${arch[@]}"; then
if (( ${#arch[@]} == 1 )); then
return 0;
else
error "$(gettext "Can not use '%s' architecture with other architectures")" "any"
return 1;
fi
fi
for a in "${arch[@]}"; do

View File

@@ -0,0 +1,82 @@
#!/bin/bash
#
# arch_specific.sh - Check that arch specific variables can be arch specific.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_ARCH_SPECIFIC_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_ARCH_SPECIFIC_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
source "$LIBRARY/util/util.sh"
lint_pkgbuild_functions+=('lint_arch_specific')
lint_arch_specific() {
local i a pkg ret=0
# global variables
for a in ${arch[@]}; do
if [[ $a == "any" ]]; then
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if declare -p "${i}_${a}" > /dev/null 2>&1; then
error "$(gettext "Can not provide architecture specific variables for the '%s' architecture: %s")" "any" "${i}_${a}"
ret=1
fi
done
fi
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_arch_arrays[@]} && continue
v="${i}_${a}"
if declare -p "$v" > /dev/null 2>&1; then
error "$(gettext "%s can not be architecture specific: %s")" "$i" "${i}_${a}"
ret=1
fi
done
done
# package function variables
for pkg in ${pkgname[@]}; do
for a in ${arch[@]}; do
if [[ $a == "any" ]]; then
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "Can not provide architecture specific variables for the '%s' architecture: %s")" "any" "${i}_${a}"
ret=1
fi
done
fi
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_arch_arrays[@]} && continue
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "%s can not be architecture specific: %s")" "$i" "${i}_${a}"
ret=1
fi
done
done
done
return $ret
}

View File

@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -43,12 +43,10 @@ lint_checkdepends() {
for checkdepend in "${checkdepends_list[@]}"; do
name=${checkdepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${checkdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname checkdepends "$name" || ret=1
if [[ $ver != $checkdepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" checkdepends || ret=1
if [[ $name != $checkdepend ]]; then
ver=${checkdepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" checkdepends || ret=1
fi
done

View File

@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -43,12 +43,10 @@ lint_conflicts() {
for conflict in "${conflicts_list[@]}"; do
name=${conflict%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${conflict##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname conflicts "$name" || ret=1
if [[ $ver != $conflict ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts || ret=1
if [[ $name != $conflict ]]; then
ver=${conflict##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" conflicts || ret=1
fi
done

View File

@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -43,13 +43,13 @@ lint_depends() {
for depend in "${depends_list[@]}"; do
name=${depend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${depend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname depends "$name" || ret=1
# Don't validate empty version because of https://bugs.archlinux.org/task/58776
if [[ $ver != $depend && -n $ver ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" depends || ret=1
if [[ $name != $depend ]]; then
ver=${depend##$name@(<|>|=|>=|<=)}
# Don't validate empty version because of https://bugs.archlinux.org/task/58776
if [[ -n $ver ]]; then
check_fullpkgver "$ver" depends || ret=1
fi
fi
done

View File

@@ -29,9 +29,15 @@ source "$LIBRARY/util/message.sh"
lint_pkgbuild_functions+=('lint_epoch')
lint_epoch() {
check_epoch() {
local epoch=$1 type=$2
if [[ $epoch != *([[:digit:]]) ]]; then
error "$(gettext "%s must be an integer, not %s.")" "epoch" "$epoch"
error "$(gettext "%s must be an integer, not %s.")" "epoch${type:+ in $type}" "$epoch"
return 1
fi
}
lint_epoch() {
check_epoch "$epoch"
}

View File

@@ -0,0 +1,58 @@
#!/bin/bash
#
# fullpkgver.sh - Check whether a full version conforms to requirements.
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/epoch.sh"
source "$LIBRARY/lint_pkgbuild/pkgrel.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
check_fullpkgver() {
local fullver=$1 type=$2
local ret=0
# If there are multiple colons or multiple hyphens, there's a
# question of how we split it--it's invalid either way, but it
# will affect error messages. Let's mimic version.c:parseEVR().
if [[ $fullver = *:* ]]; then
# split at the *first* colon
check_epoch "${fullver%%:*}" "$type" || ret=1
fullver=${fullver#*:}
fi
# Since ver isn't allowed to be empty, don't let rel strip it
# down to nothing. Given "-XXX", "pkgver isn't allowed to
# contain hyphens" is more helpful than "pkgver isn't allowed
# to be empty".
if [[ $fullver = ?*-* ]]; then
# split at the *last* hyphen
check_pkgrel "${fullver##*-}" "$type" || ret=1
fullver=${fullver%-*}
fi
check_pkgver "$fullver" "$type" || ret=1
return $ret
}

View File

@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -43,12 +43,10 @@ lint_makedepends() {
for makedepend in "${makedepends_list[@]}"; do
name=${makedepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${makedepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname makedepends "$name" || ret=1
if [[ $ver != $makedepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" makedepends || ret=1
if [[ $name != $makedepend ]]; then
ver=${makedepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" makedepends || ret=1
fi
done

View File

@@ -2,17 +2,20 @@ libmakepkg_module = 'lint_pkgbuild'
sources = [
'arch.sh.in',
'arch_specific.sh.in',
'backup.sh.in',
'changelog.sh.in',
'checkdepends.sh.in',
'conflicts.sh.in',
'depends.sh.in',
'epoch.sh.in',
'fullpkgver.sh.in',
'install.sh.in',
'makedepends.sh.in',
'optdepends.sh.in',
'options.sh.in',
'package_function.sh.in',
'package_function_variable.sh.in',
'pkgbase.sh.in',
'pkglist.sh.in',
'pkgname.sh.in',

View File

@@ -23,6 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -41,12 +43,10 @@ lint_optdepends() {
for optdepend in "${optdepends_list[@]%%:[[:space:]]*}"; do
name=${optdepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${optdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname optdepends "$name" || ret=1
if [[ $ver != $optdepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" optdepends || ret=1
if [[ $name != $optdepend ]]; then
ver=${optdepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" optdepends || ret=1
fi
done

View File

@@ -0,0 +1,62 @@
#!/bin/bash
#
# package_function_variable.sh - Check variables inside the package function.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_VARIABLE_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_VARIABLE_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
source "$LIBRARY/util/util.sh"
lint_pkgbuild_functions+=('lint_package_function_variable')
lint_package_function_variable() {
local i a pkg ret=0
# package function variables
for pkg in ${pkgname[@]}; do
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_package_overrides[@]} && continue
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "%s can not be set inside a package function")" "${i}_${a}"
ret=1
fi
done
done
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_package_overrides[@]} && continue
if exists_function_variable "package_$pkg" "$i"; then
error "$(gettext "%s can not be set inside a package function")" "$i"
ret=1
fi
done
done
return $ret
}

View File

@@ -29,14 +29,19 @@ source "$LIBRARY/util/message.sh"
lint_pkgbuild_functions+=('lint_pkgrel')
lint_pkgrel() {
if [[ -z $pkgrel ]]; then
error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
check_pkgrel() {
local rel=$1 type=$2
if [[ -z $rel ]]; then
error "$(gettext "%s is not allowed to be empty.")" "pkgrel${type:+ in $type}"
return 1
fi
if [[ $pkgrel != +([0-9])?(.+([0-9])) ]]; then
error "$(gettext "%s must be a decimal, not %s.")" "pkgrel" "$pkgrel"
if [[ $rel != +([0-9])?(.+([0-9])) ]]; then
error "$(gettext "%s must be of the form 'integer[.integer]', not %s.")" "pkgrel${type:+ in $type}" "$rel"
return 1
fi
}
lint_pkgrel() {
check_pkgrel "$pkgrel"
}

View File

@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@@ -48,12 +48,10 @@ lint_provides() {
continue
fi
name=${provide%=*}
# remove optional epoch in version specifier
ver=${provide##$name=?(+([0-9]):)}
lint_one_pkgname provides "$name" || ret=1
if [[ $ver != $provide ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1
if [[ $name != $provide ]]; then
ver=${provide##$name=}
check_fullpkgver "$ver" provides || ret=1
fi
done

View File

@@ -25,25 +25,17 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
lint_pkgbuild_functions+=('lint_variable')
lint_variable() {
# TODO: refactor - similar arrays are used elsewhere
local array=(arch backup checkdepends groups license noextract options
validpgpkeys)
local arch_array=(conflicts depends makedepends md5sums optdepends provides
replaces sha1sums sha224sums sha256sums sha384sums sha512sums
source)
local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url)
local i a v pkg keys out bad ret=0
local i a pkg out bad ret=0
# global variables
for i in ${array[@]} ${arch_array[@]}; do
eval "keys=(\"\${!$i[@]}\")"
if (( ${#keys[*]} > 0 )); then
for i in ${pkgbuild_schema_arrays[@]}; do
if declare -p $i > /dev/null 2>&1; then
if ! is_array $i; then
error "$(gettext "%s should be an array")" "$i"
ret=1
@@ -54,21 +46,18 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${arch_array[@]}; do
v="${i}_${a}"
eval "keys=(\"\${!${v}[@]}\")"
if (( ${#keys[*]} > 0 )); then
if ! is_array $v; then
error "$(gettext "%s_%s should be an array")" "$i" "$a"
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if declare -p "${i}_${a}" > /dev/null 2>&1; then
if ! is_array ${i}_${a}; then
error "$(gettext "%s should be an array")" "${i}_${a}"
ret=1
fi
fi
done
done
for i in ${string[@]}; do
eval "keys=(\"\${!$i[@]}\")"
if (( ${#keys[*]} > 0 )); then
for i in ${pkgbuild_schema_strings[@]}; do
if declare -p "$i" > /dev/null 2>&1; then
if is_array $i; then
error "$(gettext "%s should not be an array")" "$i"
ret=1
@@ -78,7 +67,7 @@ lint_variable() {
# package function variables
for pkg in ${pkgname[@]}; do
for i in ${array[@]} ${arch_array[@]}; do
for i in ${pkgbuild_schema_arrays[@]}; do
if extract_function_variable "package_$pkg" $i 0 out; then
error "$(gettext "%s should be an array")" "$i"
ret=1
@@ -88,15 +77,15 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${arch_array[@]}; do
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if extract_function_variable "package_$pkg" "${i}_${a}" 0 out; then
error "$(gettext "%s_%s should be an array")" "$i" "$a"
error "$(gettext "%s should be an array")" "${i}_${a}"
ret=1
fi
done
done
for i in ${string[@]}; do
for i in ${pkgbuild_schema_strings[@]}; do
if extract_function_variable "package_$pkg" $i 1 out; then
error "$(gettext "%s should not be an array")" "$i"
ret=1

View File

@@ -59,26 +59,11 @@ download_sources() {
pushd "$SRCDEST" &>/dev/null
local proto=$(get_protocol "$netfile")
case "$proto" in
local)
download_local "$netfile"
;;
bzr*)
(( get_vcs )) && download_bzr "$netfile"
;;
git*)
(( get_vcs )) && download_git "$netfile"
;;
hg*)
(( get_vcs )) && download_hg "$netfile"
;;
svn*)
(( get_vcs )) && download_svn "$netfile"
;;
*)
download_file "$netfile"
;;
esac
if declare -f download_$proto > /dev/null; then
download_$proto "$netfile"
else
download_file "$netfile"
fi
popd &>/dev/null
done
@@ -92,22 +77,10 @@ extract_sources() {
for netfile in "${all_sources[@]}"; do
local file=$(get_filename "$netfile")
local proto=$(get_protocol "$netfile")
case "$proto" in
bzr*)
extract_bzr "$netfile"
;;
git*)
extract_git "$netfile"
;;
hg*)
extract_hg "$netfile"
;;
svn*)
extract_svn "$netfile"
;;
*)
extract_file "$file"
;;
esac
if declare -f extract_$proto > /dev/null; then
extract_$proto "$netfile"
else
extract_file "$file"
fi
done
}

View File

@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_bzr() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local url=$(get_url "$netfile")

View File

@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_git() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")

View File

@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_hg() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")

View File

@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_svn() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local fragment=${netfile#*#}

View File

@@ -24,6 +24,7 @@ LIBMAKEPKG_SRCINFO_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
srcinfo_open_section() {
printf '%s = %s\n' "$1" "$2"
@@ -63,7 +64,7 @@ srcinfo_write_section_details() {
local attr package_arch a
local multivalued_arch_attrs=(source provides conflicts depends replaces
optdepends makedepends checkdepends
{md5,sha{1,224,256,384,512}}sums)
"${known_hash_algos[@]/%/sums}")
for attr in "${singlevalued[@]}"; do
pkgbuild_extract_to_srcinfo "$1" "$attr" 0

View File

@@ -42,6 +42,7 @@ compress_as() {
*tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
*tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
*tar.lz4) ${COMPRESSLZ4[@]:-lz4 -q} ;;
*tar.lz) ${COMPRESSLZ[@]:-lzip -c -f} ;;
*tar) cat ;;
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
"$ext"; cat ;;

View File

@@ -7,6 +7,7 @@ sources = [
'option.sh.in',
'parseopts.sh.in',
'pkgbuild.sh.in',
'schema.sh.in',
'source.sh.in',
'util.sh.in',
]

View File

@@ -18,9 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
LIBMAKEPKG_UTIL_PKGBUILD_SH=1
source "$LIBRARY/util/schema.sh"
have_function() {
declare -f "$1" >/dev/null
@@ -36,7 +38,7 @@ array_build() {
# it's an error to try to copy a value which doesn't exist.
declare -p "$2" &>/dev/null || return 1
# Build an array of the indicies of the source array.
# Build an array of the indices of the source array.
eval "keys=(\"\${!$2[@]}\")"
# Clear the destination array
@@ -98,6 +100,15 @@ extract_function_variable() {
return $r
}
exists_function_variable() {
# $1: function name
# $2: variable name
local funcname=$1 attr=$2 out
extract_function_variable "$funcname" "$attr" 0 out ||
extract_function_variable "$funcname" "$attr" 1 out
}
get_pkgbuild_attribute() {
# $1: package name
# $2: attribute name

View File

@@ -0,0 +1,49 @@
#!/bin/bash
#
# schema.sh - declare specific groups of pkgbuild variables
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "$LIBMAKEPKG_SCHEMA_SH" ]] && return
LIBMAKEPKG_SCHEMA_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/util.sh"
known_hash_algos=({md5,sha{1,224,256,384,512},b2})
pkgbuild_schema_arrays=(arch backup checkdepends conflicts depends groups
license makedepends noextract optdepends options
provides replaces source validpgpkeys
"${known_hash_algos[@]/%/sums}")
pkgbuild_schema_strings=(changelog epoch install pkgbase pkgdesc pkgrel pkgver
url)
pkgbuild_schema_arch_arrays=(checkdepends conflicts depends makedepends
optdepends provides replaces source
"${known_hash_algos[@]/%/sums}")
pkgbuild_schema_package_overrides=(pkgdesc arch url license groups depends
optdepends provides conflicts replaces
backup options install changelog)
readonly -a known_hash_algos pkgbuild_schema_arrays \
pkgbuild_schema_strings pkgbuild_schema_arch_arrays \
pkgbuild_schema_package_overrides

View File

@@ -41,10 +41,12 @@ get_protocol() {
if [[ $1 = *://* ]]; then
# strip leading filename
local proto="${1#*::}"
printf "%s\n" "${proto%%://*}"
proto="${proto%%://*}"
# strip proto+uri://
printf "%s\n" "${proto%%+*}"
elif [[ $1 = *lp:* ]]; then
local proto="${1#*::}"
printf "%s\n" "${proto%%lp:*}"
printf "%s\n" "${proto%%+lp:*}"
else
printf "%s\n" local
fi
@@ -63,15 +65,15 @@ get_filename() {
local proto=$(get_protocol "$netfile")
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
filename=${netfile%%#*}
filename=${filename%%\?*}
filename=${filename%/}
filename=${filename##*/}
if [[ $proto = bzr* ]]; then
if [[ $proto = bzr ]]; then
filename=${filename#*lp:}
fi
if [[ $proto = git* ]]; then
if [[ $proto = git ]]; then
filename=${filename%%.git*}
fi
;;
@@ -89,7 +91,7 @@ get_filepath() {
local proto="$(get_protocol "$1")"
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
if [[ -d "$startdir/$file" ]]; then
file="$startdir/$file"
elif [[ -d "$SRCDEST/$file" ]]; then

View File

@@ -48,16 +48,10 @@ declare -r startdir="$(pwd -P)"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
'options' 'install' 'changelog')
readonly -a splitpkg_overrides
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
# Options
ASDEPS=0
BUILDFUNC=0
BUILDPKG=1
CHECKFUNC=0
CLEANBUILD=0
CLEANUP=0
@@ -223,17 +217,24 @@ missing_source_file() {
run_pacman() {
local cmd
if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
else
if [[ $1 = -@(T|Q)*([[:alpha:]]) ]]; then
cmd=("$PACMAN_PATH" "$@")
fi
if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
else
cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
if type -p sudo >/dev/null; then
cmd=(sudo "${cmd[@]}")
else
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
fi
local lockfile="$(pacman-conf DBPath)/db.lck"
while [[ -f $lockfile ]]; do
local timer=0
msg "$(gettext "Pacman is currently in use, please wait...")"
while [[ -f $lockfile ]] && (( timer < 10 )); do
(( ++timer ))
sleep 3
done
done
fi
"${cmd[@]}"
}
@@ -335,7 +336,7 @@ remove_deps() {
msg "Removing installed dependencies..."
# exit cleanly on failure to remove deps as package has been built successfully
if ! run_pacman -Rn ${deplist[@]}; then
if ! run_pacman -Rnu ${deplist[@]}; then
warning "$(gettext "Failed to remove installed dependencies.")"
return $E_REMOVE_DEPS_FAILED
fi
@@ -739,7 +740,7 @@ create_debug_package() {
return 0
fi
pkgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@"
local pkgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@"
# check if we have any debug symbols to package
if dir_is_empty "$pkgdir/usr/lib/debug"; then
@@ -904,7 +905,7 @@ check_build_status() {
backup_package_variables() {
local var
for var in ${splitpkg_overrides[@]}; do
for var in ${pkgbuild_schema_package_overrides[@]}; do
local indirect="${var}_backup"
eval "${indirect}=(\"\${$var[@]}\")"
done
@@ -912,7 +913,7 @@ backup_package_variables() {
restore_package_variables() {
local var
for var in ${splitpkg_overrides[@]}; do
for var in ${pkgbuild_schema_package_overrides[@]}; do
local indirect="${var}_backup"
if [[ -n ${!indirect} ]]; then
eval "${var}=(\"\${$indirect[@]}\")"
@@ -922,20 +923,25 @@ restore_package_variables() {
done
}
run_single_packaging() {
local pkgdir="$pkgdirbase/$pkgname"
mkdir "$pkgdir"
if [[ -n $1 ]] || (( PKGFUNC )); then
run_package $1
fi
tidy_install
lint_package || exit $E_PACKAGE_FAILED
create_package
}
run_split_packaging() {
local pkgname_backup=("${pkgname[@]}")
backup_package_variables
for pkgname in ${pkgname_backup[@]}; do
pkgdir="$pkgdirbase/$pkgname"
mkdir "$pkgdir"
backup_package_variables
run_package $pkgname
tidy_install
lint_package || exit $E_PACKAGE_FAILED
create_package
run_single_packaging $pkgname
restore_package_variables
done
pkgname=("${pkgname_backup[@]}")
create_debug_package
}
usage() {
@@ -1042,7 +1048,7 @@ while true; do
--noprogressbar) PACMAN_OPTS+=("--noprogressbar") ;;
# Makepkg Options
--allsource) SOURCEONLY=2 ;;
--allsource) BUILDPKG=0 SOURCEONLY=2 ;;
-A|--ignorearch) IGNOREARCH=1 ;;
-c|--clean) CLEANUP=1 ;;
-C|--cleanbuild) CLEANBUILD=1 ;;
@@ -1053,7 +1059,7 @@ while true; do
-f|--force) FORCE=1 ;;
-F) INFAKEROOT=1 ;;
# generating integrity checks does not depend on architecture
-g|--geninteg) GENINTEG=1 IGNOREARCH=1;;
-g|--geninteg) BUILDPKG=0 GENINTEG=1 IGNOREARCH=1;;
--holdver) HOLDVER=1 ;;
-i|--install) INSTALL=1 ;;
--key) shift; GPGKEY=$1 ;;
@@ -1063,10 +1069,10 @@ while true; do
--nocheck) RUN_CHECK='n' ;;
--noprepare) RUN_PREPARE='n' ;;
--nosign) SIGNPKG='n' ;;
-o|--nobuild) NOBUILD=1 ;;
-o|--nobuild) BUILDPKG=0 NOBUILD=1 ;;
-p) shift; BUILDFILE=$1 ;;
--packagelist) PACKAGELIST=1 IGNOREARCH=1;;
--printsrcinfo) PRINTSRCINFO=1 IGNOREARCH=1;;
--packagelist) BUILDPKG=0 PACKAGELIST=1 IGNOREARCH=1;;
--printsrcinfo) BUILDPKG=0 PRINTSRCINFO=1 IGNOREARCH=1;;
-r|--rmdeps) RMDEPS=1 ;;
-R|--repackage) REPKG=1 ;;
--sign) SIGNPKG='y' ;;
@@ -1074,8 +1080,8 @@ while true; do
--skipinteg) SKIPCHECKSUMS=1; SKIPPGPCHECK=1 ;;
--skippgpcheck) SKIPPGPCHECK=1;;
-s|--syncdeps) DEP_BIN=1 ;;
-S|--source) SOURCEONLY=1 ;;
--verifysource) VERIFYSOURCE=1 ;;
-S|--source) BUILDPKG=0 SOURCEONLY=1 ;;
--verifysource) BUILDPKG=0 VERIFYSOURCE=1 ;;
-h|--help) usage; exit $E_OK ;;
-V|--version) version; exit $E_OK ;;
@@ -1138,7 +1144,7 @@ fi
# canonicalize paths and provide defaults if anything is still undefined
for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR; do
printf -v "$var" "$(canonicalize_path "${!var:-$startdir}")"
printf -v "$var" '%s' "$(canonicalize_path "${!var:-$startdir}")"
done
unset var
PACKAGER=${PACKAGER:-"Unknown Packager"}
@@ -1211,12 +1217,12 @@ unset sha{1,224,256,384,512}sums makedepends optdepends options noextract validp
unset "${!makedepends_@}" "${!depends_@}" "${!source_@}" "${!checkdepends_@}"
unset "${!optdepends_@}" "${!conflicts_@}" "${!provides_@}" "${!replaces_@}"
unset "${!md5sums_@}" "${!sha1sums_@}" "${!sha224sums_@}" "${!sha256sums_@}"
unset "${!sha384sums_@}" "${!sha512sums_@}"
unset "${!sha384sums_@}" "${!sha512sums_@}" "${!b2sums_@}"
BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
if [[ ! -f $BUILDFILE ]]; then
error "$(gettext "%s does not exist.")" "$BUILDFILE"
exit $E_USER_FUNCTION_FAILED
exit $E_PKGBUILD_ERROR
else
if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
@@ -1337,18 +1343,12 @@ if (( INFAKEROOT )); then
chmod 755 "$pkgdirbase"
if (( ! SPLITPKG )); then
pkgdir="$pkgdirbase/$pkgname"
mkdir "$pkgdir"
if (( PKGFUNC )); then
run_package
fi
tidy_install
lint_package || exit $E_PACKAGE_FAILED
create_package
create_debug_package
run_single_packaging
else
run_split_packaging
fi
create_debug_package
msg "$(gettext "Leaving %s environment.")" "fakeroot"
exit $E_OK

View File

@@ -159,8 +159,8 @@ db_write_delta() {
md5sum=${md5sum%% *}
csize=$(wc -c "$deltafile" | cut -d' ' -f1)
oldfile=$(xdelta3 printhdr "$deltafile" | grep "XDELTA filename (source)" | sed 's/.*: *//')
newfile=$(xdelta3 printhdr "$deltafile" | grep "XDELTA filename (output)" | sed 's/.*: *//')
oldfile=$(xdelta3 printhdr "$deltafile" | sed -n 's/XDELTA filename (source):\s\+\(\.*\)/\1/p')
newfile=$(xdelta3 printhdr "$deltafile" | sed -n 's/XDELTA filename (output):\s\+\(\.*\)/\1/p')
if grep -q "$oldfile.*$newfile" "$deltas"; then
sed -i.backup "/$oldfile.*$newfile/d" "$deltas" && rm -f "$deltas.backup"
@@ -611,7 +611,7 @@ remove() {
msg "$(gettext "Searching for package '%s'...")" "$pkgname"
if db_remove_entry "$pkgname"; then
rm -f "$tmpdir/tree/$pkgname.deltas"
rm -f "$tmpdir/db/$pkgname.deltas"
return 0
else
error "$(gettext "Package matching '%s' not found.")" "$pkgname"

View File

@@ -800,9 +800,9 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
fname[len] = '\0';
/* 1 space + filenamelen + 1 space + 6 for size + 1 space + 3 for label +
* + 2 spaces + 4 for rate + 1 for label + 2 for /s + 1 space +
* 8 for eta, gives us the magic 30 */
filenamelen = infolen - 30;
* + 2 spaces + 4 for rate + 1 space + 3 for label + 2 for /s + 1 space +
* 8 for eta, gives us the magic 33 */
filenamelen = infolen - 33;
/* see printf() code, we omit 'HH:' in these conditions */
if(eta_h == 0 || eta_h >= 100) {
filenamelen += 3;
@@ -837,16 +837,16 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
xfered_human = humanize_size(xfered, '\0', -1, &xfered_label);
printf(" %ls%-*s ", wcfname, padwid, "");
/* We will show 1.62M/s, 11.6M/s, but 116K/s and 1116K/s */
/* We will show 1.62 MiB/s, 11.6 MiB/s, but 116 KiB/s and 1116 KiB/s */
if(rate_human < 9.995) {
printf("%6.1f %3s %4.2f%c/s ",
xfered_human, xfered_label, rate_human, rate_label[0]);
printf("%6.1f %3s %4.2f %3s/s ",
xfered_human, xfered_label, rate_human, rate_label);
} else if(rate_human < 99.95) {
printf("%6.1f %3s %4.1f%c/s ",
xfered_human, xfered_label, rate_human, rate_label[0]);
printf("%6.1f %3s %4.1f %3s/s ",
xfered_human, xfered_label, rate_human, rate_label);
} else {
printf("%6.1f %3s %4.f%c/s ",
xfered_human, xfered_label, rate_human, rate_label[0]);
printf("%6.1f %3s %4.f %3s/s ",
xfered_human, xfered_label, rate_human, rate_label);
}
if(eta_h == 0) {
printf("%02u:%02u", eta_m, eta_s);

View File

@@ -844,28 +844,28 @@ static int _parse_repo(const char *key, char *value, const char *file,
int ret = 0;
config_repo_t *repo = section->repo;
#define CHECK_VALUE(val) do { \
if(!val) { \
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), \
file, line, key); \
return 1; \
} \
} while(0)
if(strcmp(key, "Server") == 0) {
if(!value) {
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
file, line, key);
ret = 1;
} else {
repo->servers = alpm_list_add(repo->servers, strdup(value));
}
CHECK_VALUE(value);
repo->servers = alpm_list_add(repo->servers, strdup(value));
} else if(strcmp(key, "SigLevel") == 0) {
if(!value) {
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
file, line, key);
} else {
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
if(values) {
ret = process_siglevel(values, &repo->siglevel,
&repo->siglevel_mask, file, line);
FREELIST(values);
}
CHECK_VALUE(value);
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
if(values) {
ret = process_siglevel(values, &repo->siglevel,
&repo->siglevel_mask, file, line);
FREELIST(values);
}
} else if(strcmp(key, "Usage") == 0) {
CHECK_VALUE(value);
alpm_list_t *values = NULL;
setrepeatingoption(value, "Usage", &values);
if(values) {
@@ -881,6 +881,8 @@ static int _parse_repo(const char *key, char *value, const char *file,
file, line, key, repo->name);
}
#undef CHECK_VALUE
return ret;
}

View File

@@ -196,7 +196,7 @@ static void usage(int op, const char * const myname)
addlist(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
addlist(_(" --ignoregroup <grp>\n"
" ignore a group upgrade (can be used more than once)\n"));
/* pass through */
/* fall through */
case PM_OP_REMOVE:
addlist(_(" -d, --nodeps skip dependency version checks (-dd to skip all checks)\n"));
addlist(_(" --assume-installed <package=version>\n"

View File

@@ -286,7 +286,7 @@ static int filter(alpm_pkg_t *pkg)
return 0;
}
/* check if this pkg is outdated */
if(config->op_q_upgrade && (alpm_sync_newversion(pkg,
if(config->op_q_upgrade && (alpm_sync_get_new_version(pkg,
alpm_get_syncdbs(config->handle)) == NULL)) {
return 0;
}
@@ -325,10 +325,14 @@ static int display(alpm_pkg_t *pkg)
colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor);
if(config->op_q_upgrade) {
alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle));
int usage;
alpm_pkg_t *newpkg = alpm_sync_get_new_version(pkg, alpm_get_syncdbs(config->handle));
alpm_db_t *db = alpm_pkg_get_db(newpkg);
alpm_db_get_usage(db, &usage);
printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor);
if(alpm_pkg_should_ignore(config->handle, pkg)) {
if(alpm_pkg_should_ignore(config->handle, pkg) || !(usage & ALPM_DB_USAGE_UPGRADE)) {
printf(" %s", _("[ignored]"));
}
}

View File

@@ -44,14 +44,8 @@ static int remove_target(const char *target)
if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) {
if(alpm_remove_pkg(config->handle, pkg) == -1) {
alpm_errno_t err = alpm_errno(config->handle);
if(err == ALPM_ERR_TRANS_DUP_TARGET) {
/* just skip duplicate targets */
pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), target);
return 0;
} else {
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target, alpm_strerror(err));
return -1;
}
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target, alpm_strerror(err));
return -1;
}
config->explicit_removes = alpm_list_add(config->explicit_removes, pkg);
return 0;

View File

@@ -521,15 +521,8 @@ static int process_pkg(alpm_pkg_t *pkg)
if(ret == -1) {
alpm_errno_t err = alpm_errno(config->handle);
if(err == ALPM_ERR_TRANS_DUP_TARGET) {
/* just skip duplicate targets */
pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
return 0;
} else {
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),
alpm_strerror(err));
return 1;
}
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg), alpm_strerror(err));
return 1;
}
config->explicit_adds = alpm_list_add(config->explicit_adds, pkg);
return 0;

View File

@@ -1359,7 +1359,7 @@ static int multiselect_parse(char *array, int count, char *response)
len--;
include = 0;
} else if(str) {
/* if first token is including, we unselect all targets */
/* if first token is including, we deselect all targets */
memset(array, 0, count);
}

View File

@@ -1,9 +0,0 @@
SUBDIRS = tests
check_SCRIPTS = test_functions.sh
noinst_SCRIPTS = $(check_SCRIPTS)
EXTRA_DIST = $(check_SCRIPTS)
# vim:set noet:

View File

@@ -1,15 +0,0 @@
README
======
Running Tests
-------------
Environment Variables
---------------------
PMTEST_SCRIPT_DIR - location of the makepkg executable; defaults to "$(dirname "$0")/../../../scripts)"
PMTEST_LIBMAKEPKG_DIR - base directory of the makepkg library; defaults to "$PMTEST_SCRIPT_DIR/libmakepkg"
VERBOSE - enable additional test output for debugging
Adding New Tests
----------------

View File

@@ -1,143 +0,0 @@
# basic setup to run before every test
# tap_init
tap_init() {
set +e
set -u
set -o pipefail
}
# wrapper around tap_bail that immediately causes the test to exit non-zero
# tap_xbail $reason...
tap_xbail() {
tap_bail "$@"
exit 1;
}
# read from stdin and reprint as diagnostic messages if VERBOSE is set and
# non-zero, otherwise, discard
# $command |& tap_filter
tap_filter() {
local v=${VERBOSE:-0}
if (( $v )); then
while IFS= read line; do
tap_diag "$line"
done
else
while IFS= read line; do
:
done
fi
}
# locate the script that should be tested
locate_bin() {
local scriptdir="${PMTEST_SCRIPT_DIR:-"$(dirname "$0")/../../../scripts"}"
local script="$(realpath "${1:-"$scriptdir/makepkg-wrapper"}")"
if ! type -p "$script" &>/dev/null; then
tap_xbail "makepkg executable (%s) could not be located" "${script}"
exit 1
fi
printf "%s" "$script"
}
# locate an source libmakepkg files
source_libmakepkg_file() {
local file=$1; shift 1
local scriptdir="${PMTEST_SCRIPT_DIR:-"$(dirname "$0")/../../../scripts"}"
local libdir="${PMTEST_LIBMAKEPKG_DIR:-"$scriptdir/libmakepkg"}"
source "$(realpath "$libdir/$file")"
}
# eval a piece of code and test the return value
# tap_eval $code $test_name...
tap_eval() {
local t=$1; shift 1
eval "$t"
tap_ok $? "$@"
}
# extract ls-style information about a file:
# mode nhardlinks user group size month date time/year filename
_ar_stat() {
local ar=$1 path=$2; shift 2
bsdtar --fast-read -tvf "$ar" "$@" "$path" 2>/dev/null
}
# same as _ar_stat but with numeric owner ids
_ar_nstat() {
local ar=$1 path=$2; shift 2
_ar_stat "$ar" "$path" --numeric-owner "$@"
}
# check the owner of a given file, owner may be a numeric id or user name
# tap_ar_is_owner $path_to_archive $file $expected_owner $test_name...
tap_ar_is_owner() {
local ar=$1 path=$2 expect=$3; shift 3
local statfun="_ar_stat" owner unused
[[ $expect =~ ^[0-9]+$ ]] && statfun="_ar_nstat"
if ! read -r unused unused owner unused < <($statfun "$ar" "$path"); then
tap_ok 1 "$@"
tap_diag " got: invalid path"
tap_diag " expected: '%s'" "$expect"
elif [[ $owner != $expect ]]; then
tap_ok 1 "$@"
tap_diag " got: '%s'" "$owner"
tap_diag " expected: '%s'" "$expect"
else
tap_ok 0 "$@"
fi
}
# check the group of a given file, group may be a numeric id or user name
# tap_ar_is_group $path_to_archive $file $expected_group $test_name...
tap_ar_is_group() {
local ar=$1 path=$2 expect=$3; shift 3
local statfun="_ar_stat" group unused
[[ $expect =~ ^[0-9]+$ ]] && statfun="_ar_nstat"
if ! read -r unused unused unused group unused < <($statfun "$ar" "$path"); then
tap_ok 1 "$@"
tap_diag " got: invalid path"
tap_diag " expected: '%s'" "$expect"
elif [[ $group != $expect ]]; then
tap_ok 1 "$@"
tap_diag " got: '%s'" "$group"
tap_diag " expected: '%s'" "$expect"
else
tap_ok 0 "$@"
fi
}
# check if a path within an archive refers to a file
# tap_ar_is_file $path_to_archive $file $test_name...
tap_ar_is_file() {
local ar=$1 path=$2; shift 2
local stat="$(_ar_stat "$ar" "$path")"
if [[ ${stat:0:1} != '-' ]]; then
tap_ok 1 "$@"
tap_diag " got: not a file"
tap_diag " expected: '%s'" "$path"
else
tap_ok 0 "$@"
fi
}
# check if a path within an archive refers to a symbolic link
# tap_ar_is_link $path_to_archive $file $expected_destination $test_name...
tap_ar_is_link() {
local ar=$1 path=$2 dest=$3; shift 3
local stat="$(_ar_stat "$ar" "$path")"
if [[ ${stat:0:1} != 'l' ]]; then
tap_ok 1 "$@"
tap_diag " got: not a link"
tap_diag " expected: '%s'" "$dest"
elif [[ ${stat##*$path -> } != $dest ]]; then
tap_ok 1 "$@"
tap_diag " got: '%s'" "${stat##*$path -> }"
tap_diag " expected: '%s'" "$dest"
else
tap_ok 0 "$@"
fi
}
source "$(dirname "$0")"/../../tap.sh || exit 1
tap_init

View File

@@ -1,7 +0,0 @@
check_SCRIPTS = $(wildcard *.sh)
noinst_SCRIPTS = $(check_SCRIPTS)
EXTRA_DIST = $(check_SCRIPTS)
# vim:set noet:

View File

@@ -1,4 +0,0 @@
TESTS += test/makepkg/tests/dbfiles.sh
TESTS += test/makepkg/tests/dotfiles.sh
TESTS += test/makepkg/tests/pkgbuild.sh
TESTS += test/makepkg/tests/util-pkgbuild.sh

View File

@@ -1,35 +0,0 @@
#!/bin/bash
source "$(dirname "$0")"/../test_functions.sh || exit 1
script="$(locate_bin "${1:-}")"
TMPDIR="$(mktemp -d --tmpdir "${0##*/}.XXXXXX")"
trap "rm -rf '${TMPDIR}'" EXIT TERM
tap_note "check that required metadata files are created"
tap_note "testing '%s'" "$script"
tap_note "using test dir '%s'" "$TMPDIR"
(
set -e
cd "$TMPDIR"
cat >PKGBUILD <<-'PKGBUILD'
pkgname=foo
pkgver=1
pkgrel=1
arch=(any)
PKGBUILD
MAKEPKG_CONF="/dev/null" PKGEXT=".pkg.tar" $script
) |& tap_filter
[[ $? -eq 0 ]] || tap_xbail "test setup failed"
pkgfile="$TMPDIR/foo-1-1-any.pkg.tar"
tap_plan 10
for f in .BUILDINFO .PKGINFO .MTREE; do
tap_ar_is_file "$pkgfile" "$f" "pkg contains %s" "$f"
tap_ar_is_owner "$pkgfile" "$f" "0" "%s owner is root" "$f"
tap_ar_is_group "$pkgfile" "$f" "0" "%s group is root" "$f"
done
tap_is_int "$(bsdtar -tf "$pkgfile" | wc -l)" 3 "pkg only contains known metainfo files"

View File

@@ -1,33 +0,0 @@
#!/bin/bash
source "$(dirname "$0")"/../test_functions.sh || exit 1
script="$(locate_bin "${1:-}")"
TMPDIR="$(mktemp -d --tmpdir "${0##*/}.XXXXXX")"
[[ ${KEEPFILES:-0} == 0 ]] || trap "rm -rf '${TMPDIR}'" EXIT TERM
tap_note "test that dotfiles don't make it into the package root"
tap_note "testing '%s'" "$script"
tap_note "using test dir '%s'" "$TMPDIR"
output="$(
set -e
cd "$TMPDIR"
cat >PKGBUILD <<-'PKGBUILD'
pkgname=foo
pkgver=1
pkgrel=1
arch=(any)
package() {
touch "$pkgdir"/.dotfile
}
PKGBUILD
MAKEPKG_CONF="/dev/null" PKGEXT=".pkg.tar" $script 2>&1
)"
ret=$?
tap_plan 3
tap_eval "[[ '$ret' -ne 0 ]]" "makepkg exited non-zero"
tap_eval "[[ ! -f '$TMPDIR/foo-1-1-any.pkg.tar' ]]" "no package was built"
tap_eval "[[ '$output' = *'Dotfile found in package root'* ]]" "error message references dotfile"

View File

@@ -1,53 +0,0 @@
#!/bin/bash
source "$(dirname "$0")"/../test_functions.sh || exit 1
script="$(locate_bin "${1:-}")"
TMPDIR="$(mktemp -d --tmpdir "${0##*/}.XXXXXX")"
trap "rm -rf '${TMPDIR}'" EXIT TERM
tap_note "basic package building test"
tap_note "testing '%s'" "$script"
tap_note "using test dir '%s'" "$TMPDIR"
(
set -e
cd "$TMPDIR"
cat >PKGBUILD <<-'PKGBUILD'
pkgname=foo
pkgver=1
pkgrel=1
arch=(any)
package() {
touch "$pkgdir/!first"
touch "$pkgdir/target"
ln -s target "$pkgdir/link"
mkdir "$pkgdir/dir"
touch "$pkgdir/dir/.dotfile"
}
PKGBUILD
MAKEPKG_CONF="/dev/null" PKGEXT=".pkg.tar" $script
) |& tap_filter
[[ $? -eq 0 ]] || tap_xbail "test setup failed"
pkgfile="$TMPDIR/foo-1-1-any.pkg.tar"
tap_plan 10
tap_ar_is_file "$pkgfile" "!first" "pkg contains !first"
tap_ar_is_file "$pkgfile" "target" "pkg contains target"
tap_ar_is_file "$pkgfile" "dir/.dotfile" "pkg contains dir/.dotfile"
tap_ar_is_link "$pkgfile" "link" "target" "pkg contains link to target"
tap_ar_is_owner "$pkgfile" "target" "0" "target owner is root"
tap_ar_is_group "$pkgfile" "target" "0" "target group is root"
tap_eval "! bsdtar -tf '$pkgfile' | grep -qE '^\\.?\\.?/'" \
"package paths are relative without leading dot dirs"
tap_eval "bsdtar -tf '$pkgfile' | grep -v '^\\.' | LANG=C sort -Cu" \
"package files are sorted"
tap_eval "bsdtar -tf '$pkgfile' | LANG=C sort | LANG=C sort -Cu" \
"package files are unique"
tap_eval "bsdtar -tf '$pkgfile' | head -n1 | grep -q '^\\.'" \
"db files are placed at the beginning of the package"
tap_finish

View File

@@ -1,35 +0,0 @@
#!/bin/bash
source "$(dirname "$0")"/../test_functions.sh || exit 1
tap_note "testing libmakepkg/util/pkgbuild.sh"
source_libmakepkg_file 'util/pkgbuild.sh'
test_foo() {
myarray=(foo bar)
myarray+=(baz)
#myarray+=(this should be ignored)
myscalar=baz
myscalar=quux
#myscalar=ignored
}
declare -a oarray
declare oscalar
tap_plan 9
tap_eval 'have_function test_foo' 'detected existing function test_foo'
tap_eval '! have_function test_bar' 'detected missing function test_bar'
tap_eval 'extract_function_variable test_foo myarray 1 oarray' 'extract array variable'
tap_is_int "${#oarray[@]}" 3 'extracted array length'
tap_is_str "${oarray[0]}" 'foo' 'extracted array contents'
tap_is_str "${oarray[1]}" 'bar' 'extracted array contents'
tap_is_str "${oarray[2]}" 'baz' 'extracted array contents'
tap_eval 'extract_function_variable test_foo myscalar 0 oscalar' 'extract scalar variable'
tap_is_str "$oscalar" 'quux' 'extracted scalar value'
tap_finish

View File

@@ -342,19 +342,26 @@ foreach testobj : pacman_tests
input = testobj.get('name')
test_name = input.split('/')[1]
should_fail = testobj.get('should_fail', false)
args = [
join_paths(meson.source_root(), 'build-aux/tap-driver.py'),
join_paths(meson.current_source_dir(), 'pactest.py'),
'--scriptlet-shell', get_option('scriptlet-shell'),
'--bindir', meson.build_root(),
'--ldconfig', LDCONFIG,
'--verbose',
join_paths(meson.current_source_dir(), input)
]
if not conf.get('HAVE_LIBCURL')
args += '--without-curl'
endif
if not conf.get('HAVE_LIBGPGME')
args += '--without-gpg'
endif
test(
test_name,
PYTHON,
args : [
join_paths(meson.source_root(), 'build-aux/tap-driver.py'),
join_paths(meson.current_source_dir(), 'pactest.py'),
'--scriptlet-shell', get_option('scriptlet-shell'),
'--bindir', meson.build_root(),
'--ldconfig', LDCONFIG,
'--verbose',
join_paths(meson.current_source_dir(), input)
],
args : args,
depends : [pacman_bin],
should_fail : should_fail)
endforeach

View File

@@ -77,6 +77,15 @@ def create_parser():
parser.add_option("--bindir", type = "string",
dest = "bindir", action = "append",
help = "specify location of binaries")
parser.add_option("--without-gpg", action = "store_true",
dest = "missing_gpg", default = False,
help = "skip gpg-related tests")
parser.add_option("--without-curl", action = "store_true",
dest = "missing_curl", default = False,
help = "skip downloader-related tests")
parser.add_option("--without-nls", action = "store_true",
dest = "missing_nls", default = False,
help = "skip translation-related tests")
parser.add_option("--keep-root", action = "store_true",
dest = "keeproot", default = False,
help = "don't remove the generated pacman root filesystem")
@@ -137,6 +146,9 @@ if __name__ == "__main__":
env.pacman["manual-confirm"] = opts.manualconfirm
env.pacman["scriptlet-shell"] = opts.scriptletshell
env.pacman["ldconfig"] = opts.ldconfig
env.config["gpg"] = not opts.missing_gpg
env.config["nls"] = not opts.missing_nls
env.config["curl"] = not opts.missing_curl
try:
for i in args:
@@ -160,6 +172,3 @@ if __name__ == "__main__":
shutil.rmtree(root_path)
else:
tap.diag("pacman testing root saved: %s" % root_path)
if env.failed > 0:
sys.exit(1)

View File

@@ -24,12 +24,7 @@ import tap
class pmenv(object):
"""Environment object
"""
testcases = []
passed = 0
failed = 0
expectedfail = 0
unexpectedpass = 0
def __init__(self, root = "root"):
self.root = os.path.abspath(root)
@@ -41,6 +36,11 @@ class pmenv(object):
"valgrind": 0,
"nolog": 0
}
self.config = {
"gpg": True,
"nls": True,
"curl": True
}
def __str__(self):
return "root = %s\n" \
@@ -57,15 +57,18 @@ class pmenv(object):
def run(self):
"""
"""
tap.plan(len(self.testcases))
for testcase in self.testcases:
t = pmtest.pmtest(testcase, self.root)
tap.diag("Running '%s'" % t.testname)
t = pmtest.pmtest(testcase, self.root, self.config)
t.load()
t.generate(self.pacman)
t.run(self.pacman)
if t.skipall:
tap.skip_all("skipping %s (%s)" % (t.description, t.skipall))
else:
tap.plan(1)
tap.diag("Running '%s'" % t.testname)
tap.diag("==> Checking rules")
tap.todo = t.expectfailure
tap.subtest(lambda: t.check(), t.description)
t.generate(self.pacman)
t.run(self.pacman)
tap.diag("==> Checking rules")
tap.todo = t.expectfailure
tap.subtest(lambda: t.check(), t.description)

View File

@@ -33,12 +33,13 @@ class pmtest(object):
"""Test object
"""
def __init__(self, name, root):
def __init__(self, name, root, config):
self.name = name
self.testname = os.path.basename(name).replace('.py', '')
self.root = root
self.dbver = 9
self.cachepkgs = True
self.config = config
self.cmd = ["pacman", "--noconfirm",
"--config", self.configfile(),
"--root", self.rootdir(),
@@ -101,6 +102,7 @@ class pmtest(object):
self.rules = []
self.files = []
self.expectfailure = False
self.skipall = False
if os.path.isfile(self.name):
# all tests expect this to be available
@@ -201,6 +203,10 @@ class pmtest(object):
self.files.append(f)
vprint("\t%s" % f.name)
def require_capability(self, cap):
if not self.config[cap]:
self.skipall = "missing capability " + cap
def add_hook(self, name, content):
if not name.endswith(".hook"):
name = name + ".hook"

View File

@@ -21,6 +21,11 @@ failed = 0
def _output(msg):
print("%s%s" % (" "*level, str(msg).replace("\n", "\\n")))
def skip_all(description=""):
if description:
description = " # " + description
_output("1..0%s" % (description))
def ok(ok, description=""):
global count, failed
count += 1

View File

@@ -1,4 +1,5 @@
self.description = "Add a bogus signature to a package DB"
self.require_capability("gpg")
sp = pmpkg("pkg1")
sp.pgpsig = "asdfasdfsdfasdfsdafasdfsdfasd"