Compare commits

..

32 Commits

Author SHA1 Message Date
morganamilo
5e52dc0906 libalpm: free trans before databases
When releasing the handle, alpm tries to do some self clean up by
freeing the databases and transaction.

However, databases refuse to unregister is there is an in progress
transaction. Causing them to leak if the handle is released while
a transaction is active.
2023-09-20 14:59:39 +01:00
morganamilo
015cdb21bd Fix unused variable warning 2023-09-20 04:32:21 +01:00
Xiretza
05f283b5ad tests: fix order of fakechroot + fakeroot nesting
As noted in the fakechroot(1) man page, fakeroot and fakechroot
might wrap the same C library functions. Arch Linux hit this
recently with calls to stat(). It is important to start the fake
environment in proper order - fakeroot should be started inside
fakechroot.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-19 17:55:24 +10:00
Finlay Maroney
34611a6643 Avoid double slash when explicitly passing --root or --rootdir
Passing a path with a trailing slash to --root or --rootdir can lead to a
double slash at the start of paths.  e.g.

$ pacman --root / -v 2>1  | grep " //"
Log File  : //var/log/pacman.log

In MSYS2, paths starting with // will hit the network and fail.

Avoid this be explicitly stripping the trailing / from paths passed to these
flags.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-12 14:22:36 +10:00
Robin Candau
76b140c72a Replace the bzr package by breezy for the bzr protocol in makepkg.conf 2023-09-11 19:11:40 +02:00
Matthew Sexton
5f43ac85f6 specify which files are updated by --refresh option
Ref: FS#77697

Signed-off-by: Matthew Sexton <mssxtn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-11 22:59:53 +10:00
morganamilo
0dfe5c96ae makepkg: add -D flag to change directory before building
This is similar to -C in git/make/nina. Sadly -C is already taken for
us.

This is useful for scripts where you for loop over packages, as well as
when I'm testing makepkg builds and I'm too lazy to cd.
2023-09-09 11:52:11 +10:00
InsanePrawn
36d70a93e2 pacman-key: allow overriding KEYRING_IMPORT_DIR with --populate-from
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-07 00:12:41 +10:00
Allan McRae
717e5e9157 Add PRINT_FORMAT_LIST define to remove repetitive code
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Allan McRae
e7d7433b4b Rename macro for print-format handling of strings
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
e210634982 util.c: extend --print-format with "%m"
Add md5sum as printable format string.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
6968f77026 util.c: extend --print-format with "%G"
Add a new print attribute "%G" which prints groups.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
06db927a1a util.c: extend --print-format with "%H"
Add a new print attribute "%H" which shows conflicts.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
909f2e86c3 util.c: add "%O" to --print-format
Add the option to print optional depends with "%O".

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
5bd0b98b42 util.c: extend --print-format with %R and %P
Add provides "%P" and replaces "%R" as format attribute.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Jelle van der Waa
c1d4a6198c Extend --print-format with %L
Add format attribute for licenses.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Allan McRae
f5af66f130 Remove unnecessary check
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Allan McRae
5473c9fd3f squash
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 17:56:55 +10:00
Allan McRae
e58d799c47 Generalise concat_alpm_depends for any list
Replace concat_alpm_depends() with concat_list() which takes an
additional parameter to handle the formatting of non-string
data types.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 14:39:00 +10:00
Matthias Kurz
366b527757 libmakepkg: make sure git cloned repo's remote is named origin
makepkg assumes that the remote git repo is named "origin" at several
places in its handling of git sources. It is possible to set the remote
repo name since git v2.30.0 (with bug fix for bare checkouts in v2.30.2).

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

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-06 13:51:32 +10:00
morganamilo
e83e53f3f9 makepkg: lint empty arrays
While depend arrays are already linted, many array kinds are still
not. An empty string is never a valid array value so check all
arrays for it.
2023-09-06 12:14:55 +10:00
morganamilo
2348dcab22 pacman+libalpm: print version names for conflicting packages
When ever pacman prints a conflict, it now prints pkgname-version,
instead of just pkgname.

alpm_conflict_t now carries *alpm_pkg_ts instead of just the
names of each package.

Fixes FS#12536 (point 2)
2023-09-05 01:57:01 +00:00
morganamilo
f9d8beef45 Add meson log to artifacts 2023-09-04 22:00:51 +02:00
morganamilo
85ab0307d7 Fix compile on some platforms
Controlling the type of getmntinfo's param was decided by
whether or not we had the statvfs type avaliable. But getmntinfo uses
statfs regardless of this except on netbsd where it uses statvfs.

Add a check to detect which type our version of the function uses.
2023-09-04 22:00:48 +02:00
Nicolas Rolans
ffde12cebd repo-add: fix exit on mktemp failure 2023-08-28 12:43:56 +00:00
Jouke Witteveen
37dae721d3 Replace md5sums with sha256sums in documentation
As noted in !24, md5sums are outdated.
2023-08-28 12:27:28 +00:00
Ben Westover
aa3a1bc3b5 proto: Change the default checksum from md5 to sha256
MD5 isn't a very good checksum, and the PKGBUILD page on the Arch Wiki
states that it should not be used, instead recommending sha256 or b2.
This patch changes the default from md5 to sha256 because that seems to
be the most commonly used checksum today.

Signed-off-by: Ben Westover <kwestover.kw@gmail.com>
2023-08-28 22:25:10 +10:00
Allan McRae
298755c905 pacman: do not check file md5sums
The file md5sums are removed from the .MTREE file, so pacman should
not attempt to check them.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-08-28 22:17:51 +10:00
Levente Polyak
ee933acf84 makepkg: immutable bzr by hashing the checkout content
This feature makes bzr VCS build inputs immutable by adding support for
pinning a bzr checkout by a hash of its content using the deterministic
export functionality `bzr export`.

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

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

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

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

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

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

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-08-28 22:15:03 +10:00
kpcyrd
843bf21e79 libmakepkg: Fix non-reproducible binaries by processing debuginfo in order 2023-08-27 13:03:40 +02:00
36 changed files with 364 additions and 477 deletions

View File

@@ -16,6 +16,10 @@ default:
python
fakeroot fakechroot
meson
artifacts:
when: always
paths:
- build/meson-logs/meson-log.txt
arch:
extends: .arch-test

View File

@@ -12,8 +12,8 @@ depends=('glibc')
makedepends=('ed')
optdepends=('ed: for "patch -e" functionality')
source=("ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig})
md5sums=('e9ae5393426d3ad783a300a338c09b72'
'SKIP')
sha256sums=('9124ba46db0abd873d0995c2ca880e81252676bb6c03e0a37dfc5f608a9b0ceb'
'SKIP')
build() {
cd "$srcdir/$pkgname-$pkgver"

View File

@@ -464,6 +464,9 @@ Currently makepkg supports the Bazaar, Git, Subversion, Fossil and Mercurial
version control systems. For other version control systems, manual cloning of
upstream repositories must be done in the `prepare()` function.
Some <<VCS,VCS Sources>> like Git support pinning the checkout by a checksum of
its content using deterministic export functionality like ``git archive''.
The source URL is divided into four components:
*directory*::

View File

@@ -85,7 +85,7 @@ Example PKGBUILD
license=('PerlArtistic' 'GPL')
depends=('perl')
source=("http://search.cpan.org/CPAN/authors/id/S/SH/SHERZODR/Config-Simple-${pkgver}.tar.gz")
md5sums=('f014aec54f0a1e2e880d317180fce502')
sha256sums=('dd9995706f0f9384a15ccffe116c3b6e22f42ba2e58d8f24ed03c4a0e386edb4')
_distname="Config-Simple"
# template start; name=perl-module; version=1.0;

View File

@@ -146,6 +146,9 @@ Options
*-C, \--cleanbuild*::
Remove the $srcdir before building the package.
*-D* <dir>, *\--dir* <dir> ::
Change to directory <dir> before reading the PKGBUILD or doing anything else.
*\--allsource*::
Do not actually build the package, but build a source-only tarball that
includes all sources, including those that are normally downloaded via

View File

@@ -237,10 +237,12 @@ Transaction Options (apply to '-S', '-R' and '-U')
Specify a printf-like format to control the output of the '\--print'
operation. The possible attributes are: "%a" for arch, "%b" for
builddate, "%d" for description, "%e" for pkgbase, "%f" for filename,
"%g" for base64 encoded PGP signature, "%h" for sha256sum, "%n" for
pkgname, "%p" for packager, "%v" for pkgver, "%l" for location, "%r"
for repository, "%s" for size, "%C" for checkdepends, "%D" for depends
and "%M" for makedepends.
"%g" for base64 encoded PGP signature, "%h" for sha256sum, "%m" for
md5sum, "%n" for pkgname, "%p" for packager, "%v" for pkgver, "%l" for
location, "%r" for repository, "%s" for size, "%C" for checkdepends,
"%D" for depends, "%G" for groups, "%H" for conflicts, "%L" for
licenses, "%M" for makedepends, "%O" for optional depends, "%P" for
provides and "%R" for replaces.
Implies '\--print'.
@@ -454,11 +456,11 @@ Additional targets can also be specified manually, so that '-Su foo' will do a
system upgrade and install/upgrade the "foo" package in the same operation.
*-y, \--refresh*::
Download a fresh copy of the master package database from the server(s)
defined in linkman:pacman.conf[5]. This should typically be used each time
you use '\--sysupgrade' or '-u'. Passing two '\--refresh' or '-y' flags
will force a refresh of all package databases, even if they appear to be
up-to-date.
Download a fresh copy of the master package databases '(repo.db)' from the
server(s) defined in linkman:pacman.conf[5]. This should typically be used
each time you use '\--sysupgrade' or '-u'. Passing two '\--refresh' or '-y'
flags will force a refresh of all package databases, even if they appear to
be up-to-date.
Database Options (apply to '-D')[[QO]]
@@ -487,8 +489,8 @@ Database Options (apply to '-D')[[QO]]
File Options (apply to '-F')[[FO]]
----------------------------------
*-y, --refresh*::
Download fresh package databases from the server. Use twice to force a
refresh even if databases are up to date.
Download fresh package file databases '(repo.files)' from the server.
Use twice to force a refresh even if databases are up to date.
*-l, \--list*::
List the files owned by the queried package.

View File

@@ -23,7 +23,7 @@ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
VCSCLIENTS=('bzr::breezy'
'fossil::fossil'
'git::git'
'hg::mercurial'

View File

@@ -415,7 +415,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
size_t pkg_current, size_t pkg_count)
{
int i, ret = 0, errors = 0;
int ret = 0, errors = 0;
int is_upgrade = 0;
alpm_pkg_t *oldpkg = NULL;
alpm_db_t *db = handle->db_local;
@@ -538,7 +538,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
PROGRESS(handle, progress, newpkg->name, 0, pkg_count, pkg_current);
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
int percent;
if(newpkg->size != 0) {

View File

@@ -100,6 +100,11 @@ int SYMEXPORT alpm_release(alpm_handle_t *myhandle)
CHECK_HANDLE(myhandle, return -1);
/* free transaction memory */
if(myhandle->trans && alpm_trans_release(myhandle) == -1) {
return -1;
}
/* close local database */
db = myhandle->db_local;
if(db) {

View File

@@ -600,16 +600,10 @@ typedef struct _alpm_depmissing_t {
/** A conflict that has occurred between two packages. */
typedef struct _alpm_conflict_t {
/** Hash of the first package name
* (used internally to speed up conflict checks) */
unsigned long package1_hash;
/** Hash of the second package name
* (used internally to speed up conflict checks) */
unsigned long package2_hash;
/** Name of the first package */
char *package1;
/** Name of the second package */
char *package2;
/** The first package */
alpm_pkg_t *package1;
/** The second package */
alpm_pkg_t *package2;
/** The conflict */
alpm_depend_t *reason;
} alpm_conflict_t;

View File

@@ -50,10 +50,8 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
STRDUP(conflict->package1, pkg1->name, goto error);
STRDUP(conflict->package2, pkg2->name, goto error);
ASSERT(_alpm_pkg_dup(pkg1, &conflict->package1) == 0, goto error);
ASSERT(_alpm_pkg_dup(pkg2, &conflict->package2) == 0, goto error);
conflict->reason = reason;
return conflict;
@@ -66,8 +64,9 @@ error:
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
{
ASSERT(conflict != NULL, return);
FREE(conflict->package2);
FREE(conflict->package1);
_alpm_pkg_free(conflict->package1);
_alpm_pkg_free(conflict->package2);
FREE(conflict);
}
@@ -79,10 +78,8 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
alpm_conflict_t *newconflict;
CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL);
newconflict->package1_hash = conflict->package1_hash;
newconflict->package2_hash = conflict->package2_hash;
STRDUP(newconflict->package1, conflict->package1, goto error);
STRDUP(newconflict->package2, conflict->package2, goto error);
ASSERT(_alpm_pkg_dup(conflict->package1, &newconflict->package1) == 0, goto error);
ASSERT(_alpm_pkg_dup(conflict->package2, &newconflict->package2) == 0, goto error);
newconflict->reason = conflict->reason;
return newconflict;
@@ -105,10 +102,10 @@ static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack)
alpm_list_t *i;
for(i = haystack; i; i = i->next) {
alpm_conflict_t *conflict = i->data;
if(needle->package1_hash == conflict->package1_hash
&& needle->package2_hash == conflict->package2_hash
&& strcmp(needle->package1, conflict->package1) == 0
&& strcmp(needle->package2, conflict->package2) == 0) {
if(needle->package1->name_hash == conflict->package1->name_hash
&& needle->package2->name_hash == conflict->package2->name_hash
&& strcmp(needle->package1->name, conflict->package1->name) == 0
&& strcmp(needle->package2->name, conflict->package2->name) == 0) {
return 1;
}
}

View File

@@ -517,21 +517,23 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
for(i = deps; i; i = i->next) {
alpm_conflict_t *conflict = i->data;
const char *name1 = conflict->package1->name;
const char *name2 = conflict->package2->name;
alpm_pkg_t *rsync, *sync, *sync1, *sync2;
/* have we already removed one of the conflicting targets? */
sync1 = alpm_pkg_find(trans->add, conflict->package1);
sync2 = alpm_pkg_find(trans->add, conflict->package2);
sync1 = alpm_pkg_find(trans->add, name1);
sync2 = alpm_pkg_find(trans->add, name2);
if(!sync1 || !sync2) {
continue;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
conflict->package1, conflict->package2);
name1, name2);
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
alpm_depend_t *dep1 = alpm_dep_from_string(conflict->package1);
alpm_depend_t *dep2 = alpm_dep_from_string(conflict->package2);
alpm_depend_t *dep1 = alpm_dep_from_string(name1);
alpm_depend_t *dep2 = alpm_dep_from_string(name2);
if(_alpm_depcmp(sync1, dep2)) {
rsync = sync2;
sync = sync1;
@@ -559,8 +561,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* Prints warning */
_alpm_log(handle, ALPM_LOG_WARNING,
_("removing '%s' from target list because it conflicts with '%s'\n"),
rsync->name, sync->name);
_("removing '%s-%s' from target list because it conflicts with '%s-%s'\n"),
rsync->name, rsync->version, sync->name, sync->version);
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
/* rsync is not a transaction target anymore */
trans->unresolvable = alpm_list_add(trans->unresolvable, rsync);
@@ -581,16 +583,18 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
.conflict = i->data
};
alpm_conflict_t *conflict = i->data;
const char *name1 = conflict->package1->name;
const char *name2 = conflict->package2->name;
int found = 0;
/* if conflict->package2 (the local package) is not elected for removal,
/* if name2 (the local package) is not elected for removal,
we ask the user */
if(alpm_pkg_find(trans->remove, conflict->package2)) {
if(alpm_pkg_find(trans->remove, name2)) {
found = 1;
}
for(j = trans->add; j && !found; j = j->next) {
alpm_pkg_t *spkg = j->data;
if(alpm_pkg_find(spkg->removes, conflict->package2)) {
if(alpm_pkg_find(spkg->removes, name2)) {
found = 1;
}
}
@@ -598,15 +602,15 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
continue;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
conflict->package1, conflict->package2);
_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s-%s' conflicts with '%s-%s'\n",
name1, conflict->package1->version, name2,conflict->package2->version);
QUESTION(handle, &question);
if(question.remove) {
/* append to the removes list */
alpm_pkg_t *sync = alpm_pkg_find(trans->add, conflict->package1);
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2);
_alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
alpm_pkg_t *sync = alpm_pkg_find(trans->add, name1);
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, name2);
_alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", name2);
sync->removes = alpm_list_add(sync->removes, local);
} else { /* abort */
_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));

View File

@@ -182,7 +182,22 @@ foreach type : [
endif
endforeach
if conf.has('HAVE_STRUCT_STATVFS_F_FLAG')
if conf.has('HAVE_GETMNTINFO')
if cc.compiles('''
#include <sys/types.h>
#include <sys/statvfs.h>
void func() {
struct statvfs *buf;
getmntinfo(&buf, 0);
}
''')
conf.set('FSSTATSTYPE', 'struct statvfs')
else
conf.set('FSSTATSTYPE', 'struct statfs')
endif
elif conf.has('HAVE_STRUCT_STATVFS_F_FLAG')
conf.set('FSSTATSTYPE', 'struct statvfs')
elif conf.has('HAVE_STRUCT_STATFS_F_FLAGS')
conf.set('FSSTATSTYPE', 'struct statfs')

View File

@@ -28,7 +28,7 @@ changelog=
source=("$pkgbase-$pkgver.tar.gz"
"$pkgname-$pkgver.patch")
noextract=()
md5sums=()
sha256sums=()
validpgpkeys=()
prepare() {

View File

@@ -25,7 +25,7 @@ options=()
install=
source=('FOLDER::VCS+URL#FRAGMENT')
noextract=()
md5sums=('SKIP')
sha256sums=('SKIP')
# Please refer to the 'USING VCS SOURCES' section of the PKGBUILD man page for
# a description of each element in the source array.

View File

@@ -27,7 +27,7 @@ changelog=
source=("$pkgname-$pkgver.tar.gz"
"$pkgname-$pkgver.patch")
noextract=()
md5sums=()
sha256sums=()
validpgpkeys=()
prepare() {

View File

@@ -54,7 +54,17 @@ generate_one_checksum() {
case $proto in
bzr|git|hg|svn)
sum="SKIP"
if declare -f "calc_checksum_$proto" > /dev/null; then
if ! sum=$("calc_checksum_$proto" "$netfile" "$integ"); then
local name
name=$(get_filename "$netfile")
error "$(gettext "Failure while calculating %s %s checksum")" "${name}" "${proto}"
plainerr "$(gettext "Aborting...")"
exit 1
fi
else
sum="SKIP"
fi
;;
*)
if [[ ${netfile%%::*} != *.@(sig?(n)|asc) ]]; then

View File

@@ -26,6 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
source "$LIBRARY/source.sh"
check_checksums() {
local integ a
@@ -68,9 +69,9 @@ check_checksums() {
}
verify_integrity_one() {
local source_name=$1 integ=$2 expectedsum=$3
local source_name=$1 integ=$2 expectedsum=$3 file proto realsum
local file="$(get_filename "$source_name")"
file="$(get_filename "$source_name")"
printf ' %s ... ' "$file" >&2
if [[ $expectedsum = 'SKIP' ]]; then
@@ -78,20 +79,18 @@ verify_integrity_one() {
return
fi
if ! file="$(get_filepath "$file")"; then
printf '%s\n' "$(gettext "NOT FOUND")" >&2
return 1
proto="$(get_protocol "$source_name")"
if declare -f "calc_checksum_${proto}" > /dev/null; then
realsum=$("calc_checksum_${proto}" "$source_name" "$integ") || return 1
else
realsum=$(calc_checksum_file "$source_name" "$integ") || return 1
fi
local realsum="$("${integ}sum" "$file")"
realsum="${realsum%% *}"
if [[ ${expectedsum,,} = "$realsum" ]]; then
printf '%s\n' "$(gettext "Passed")" >&2
else
if [[ ${expectedsum,,} != "$realsum" ]]; then
printf '%s\n' "$(gettext "FAILED")" >&2
return 1
fi
printf '%s\n' "$(gettext "Passed")" >&2
return 0
}

View File

@@ -28,7 +28,7 @@ source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
lint_pkgbuild_functions+=('lint_variable')
lint_pkgbuild_functions+=('lint_array')
lint_variable() {
local i a pkg out bad ret=0
@@ -95,3 +95,21 @@ lint_variable() {
return $ret
}
lint_array() {
local i var ret=0
for i in ${pkgbuild_schema_arrays[@]}; do
local l=()
get_pkgbuild_all_split_attributes $i l
for var in "${l[@]}"; do
if [[ -z $var ]]; then
error "$(gettext "%s does not allow empty values.")" "$i"
ret=1
fi
done
done
return $ret
}

View File

@@ -109,3 +109,29 @@ extract_bzr() {
popd &>/dev/null
}
calc_checksum_bzr() {
local netfile=$1 integ=$2 ret=0 shellopts dir url fragment fragval sum
# this function requires pipefail - save current status to restore later
shellopts=$(shopt -p -o pipefail)
shopt -s -o pipefail
dir=$(get_filepath "$netfile")
url=$(get_url "$netfile")
fragment=$(get_uri_fragment "$url")
case ${fragment%%=*} in
revision)
fragval=${fragment##*=}
sum=$(bzr export --directory "$dir" --format tar --revision "$fragval" - | "${integ}sum" 2>&1) || ret=1
sum="${sum%% *}"
;;
*)
sum="SKIP"
esac
eval "$shellopts"
printf '%s' "$sum"
return $ret
}

View File

@@ -151,3 +151,18 @@ extract_file() {
chown -R 0:0 "$srcdir"
fi
}
calc_checksum_file() {
local netfile=$1 integ=$2 ret=0 file sum
if ! file="$(get_filepath "$netfile")"; then
printf '%s\n' "$(gettext "NOT FOUND")" >&2
return 1
fi
sum="$("${integ}sum" "$file")" || ret=1
sum="${sum%% *}"
printf '%s' "$sum"
return $ret
}

View File

@@ -48,7 +48,7 @@ download_git() {
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
if ! git clone ${GITFLAGS:---mirror} "$url" "$dir"; then
if ! git clone --origin=origin ${GITFLAGS:---mirror} "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
plainerr "$(gettext "Aborting...")"
exit 1
@@ -91,7 +91,7 @@ extract_git() {
exit 1
fi
cd_safe "$srcdir"
elif ! git clone -s "$dir" "${dir##*/}"; then
elif ! git clone --origin=origin -s "$dir" "${dir##*/}"; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plainerr "$(gettext "Aborting...")"
exit 1
@@ -134,3 +134,30 @@ extract_git() {
popd &>/dev/null
}
calc_checksum_git() {
local netfile=$1 integ=$2 ret=0 shellopts dir url fragment sum
# this function requires pipefail - save current status to restore later
shellopts=$(shopt -p -o pipefail)
shopt -s -o pipefail
dir=$(get_filepath "$netfile")
url=$(get_url "$netfile")
fragment=$(get_uri_fragment "$url")
case ${fragment%%=*} in
tag|commit)
fragval=${fragment##*=}
sum=$(git -c core.abbrev=no -C "$dir" archive --format tar "$fragval" | "${integ}sum" 2>&1) || ret=1
sum="${sum%% *}"
;;
*)
sum="SKIP"
;;
esac
eval "$shellopts"
printf '%s' "$sum"
return $ret
}

View File

@@ -111,3 +111,30 @@ extract_hg() {
popd &>/dev/null
}
calc_checksum_hg() {
local netfile=$1 integ=$2 ret=0 shellopts dir url fragment fragval sum
# this function requires pipefail - save current status to restore later
shellopts=$(shopt -p -o pipefail)
shopt -s -o pipefail
dir=$(get_filepath "$netfile")
url=$(get_url "$netfile")
fragment=$(get_uri_fragment "$url")
case ${fragment%%=*} in
tag|revision)
fragval=${fragment##*=}
sum=$(hg --repository "$dir" archive --type tar --rev "$fragval" - | "${integ}sum" 2>&1) || ret=1
sum="${sum%% *}"
;;
*)
sum="SKIP"
;;
esac
eval "$shellopts"
printf '%s' "$sum"
return $ret
}

View File

@@ -152,7 +152,7 @@ tidy_strip() {
fi
local binary strip_flags
find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do
find . -type f -perm -u+w -print0 2>/dev/null | LC_ALL=C sort -z | while IFS= read -rd '' binary ; do
local STRIPLTO=0
case "$(LC_ALL=C readelf -h "$binary" 2>/dev/null)" in
*Type:*'DYN (Shared object file)'*) # Libraries (.so) or Relocatable binaries

View File

@@ -43,7 +43,6 @@ unset GREP_OPTIONS
declare -r makepkg_version='@PACKAGE_VERSION@'
declare -r confdir='@sysconfdir@'
declare -r BUILDSCRIPT='@BUILDSCRIPT@'
declare -r startdir="$(pwd -P)"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
@@ -51,6 +50,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
ASDEPS=0
BUILDFUNC=0
BUILDPKG=1
CHDIR=''
CHECKFUNC=0
CLEANBUILD=0
CLEANUP=0
@@ -939,8 +939,8 @@ fi
ARGLIST=("$@")
# Parse Command Line Options.
OPT_SHORT="AcCdefFghiLmop:rRsSV"
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg'
OPT_SHORT="AcCdD:efFghiLmop:rRsSV"
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'dir:' 'force' 'geninteg'
'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild'
'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'packagelist'
'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg'
@@ -971,6 +971,7 @@ while true; do
--check) RUN_CHECK='y' ;;
--config) shift; MAKEPKG_CONF=$1 ;;
-d|--nodeps) NODEPS=1 ;;
-D|--dir) shift; CHDIR=$1 ;;
-e|--noextract) NOEXTRACT=1 ;;
-f|--force) FORCE=1 ;;
-F) INFAKEROOT=1 ;;
@@ -1017,6 +1018,12 @@ while [[ $1 ]]; do
shift
done
if [[ -n $CHDIR ]]; then
cd_safe "$CHDIR"
fi
declare -r startdir="$(pwd -P)"
# setup signal traps
trap 'clean_up' 0
for signal in TERM HUP QUIT; do
@@ -1158,7 +1165,7 @@ if (( GENINTEG )); then
mkdir -p "$srcdir"
chmod a-s "$srcdir"
cd_safe "$srcdir"
download_sources novcs allarch >&2
download_sources allarch >&2
generate_checksums
exit $E_OK
fi
@@ -1262,7 +1269,7 @@ if (( SOURCEONLY )); then
download_sources allarch
elif ( (( ! SKIPCHECKSUMS )) || \
( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then
download_sources allarch novcs
download_sources allarch
fi
check_source_integrity all
cd_safe "$startdir"

View File

@@ -2,7 +2,6 @@ wrapped_scripts = [
'makepkg.sh.in',
'pacman-db-upgrade.sh.in',
'pacman-key.sh.in',
'pkgdiff.sh.in',
'repo-add.sh.in'
]

View File

@@ -84,6 +84,8 @@ usage() {
'%s')")\n" "@sysconfdir@/pacman.conf"
printf -- "$(gettext " --gpgdir <dir> Set an alternate directory for GnuPG (instead\n\
of '%s')")\n" "@sysconfdir@/pacman.d/gnupg"
printf -- "$(gettext " --populate-from <dir> Set an alternate directory for --populate (instead\n\
of '%s')")\n" "@keyringdir@"
printf -- "$(gettext " --keyserver <server-url> Specify a keyserver to use if necessary")\n"
echo
printf -- "$(gettext " -h, --help Show this help message and exit")\n"
@@ -283,7 +285,6 @@ check_keyring() {
}
populate_keyring() {
local KEYRING_IMPORT_DIR='@keyringdir@'
local keyring KEYRINGIDS=("$@")
local ret=0
@@ -625,7 +626,7 @@ fi
OPT_SHORT="adefhlruvV"
OPT_LONG=('add' 'config:' 'delete' 'edit-key' 'export' 'finger' 'gpgdir:'
'help' 'import' 'import-trustdb' 'init' 'keyserver:' 'list-keys' 'list-sigs'
'lsign-key' 'nocolor' 'populate' 'recv-keys' 'refresh-keys' 'updatedb'
'lsign-key' 'nocolor' 'populate' 'populate-from:' 'recv-keys' 'refresh-keys' 'updatedb'
'verbose' 'verify' 'version')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1 # E_INVALID_OPTION
@@ -647,6 +648,7 @@ while (( $# )); do
-e|--export) EXPORT=1 ;;
-f|--finger) FINGER=1 ;;
--gpgdir) shift; PACMAN_KEYRING_DIR=$1 ;;
--populate-from) shift; KEYRING_IMPORT_DIR=$1 ;;
--import) IMPORT=1 UPDATEDB=1 ;;
--import-trustdb) IMPORT_TRUSTDB=1 UPDATEDB=1 ;;
--init) INIT=1 ;;
@@ -693,6 +695,8 @@ if [[ ! -r "${CONFIG}" ]]; then
exit 1
fi
KEYRING_IMPORT_DIR=${KEYRING_IMPORT_DIR:-"@keyringdir@"}
# if PACMAN_KEYRING_DIR isn't assigned, try to get it from the config
# file, falling back on a hard default
PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:-$(pacman-conf --config="$CONFIG" gpgdir)}

View File

@@ -1,301 +0,0 @@
#!/bin/bash
#
# pkgdiff - package differencing utility
#
# Copyright (c) 2022 Pacman Development Team <pacman-dev@lists.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/>.
# gettext initialization
export TEXTDOMAIN='pacman-scripts'
export TEXTDOMAINDIR='@localedir@'
declare -r myver='@PACKAGE_VERSION@'
declare -r confdir='@sysconfdir@'
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
QUIET=0
USE_COLOR='y'
source "$LIBRARY"/util/compress.sh
source "$LIBRARY"/util/message.sh
source "$LIBRARY"/util/parseopts.sh
# minimal of package before a pkgdiff is generated (bytes)
min_pkg_size=$((1024*1024))
# percent of new package above which the pkgdiff will be discarded
max_diff_size=70
# ensure we have a sane umask set
umask 0022
# print usage instructions
usage() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
echo
printf -- $(gettext "Usage: pkgdiff <old> <new>\n")
echo
printf -- "$(gettext "\
pkgdiff will create a file providing the differences between two packages.\n
This file can then be added to a database using repo-add.\n")"
echo
printf -- "$(gettext "Example: pkgdiff pacman-6.0.0-1-x86_64.pkg.tar.gz pacman-6.0.1-1-x86_64.pkg.tar.gz")\n"
echo
printf -- "$(gettext "Options:\n")"
printf -- "$(gettext " -q, --quiet minimize output\n")"
printf -- "$(gettext " --nocolor remove color from output\n")"
printf -- "$(gettext " --min-pkg-size minimum package size before pkgdiffs are generated\n")"
printf -- "$(gettext " --max-diff-size percent of new package above which the pkgdiff will be discarded\n")"
}
version() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
printf -- "Copyright (c) 2022 Pacman Development Team <pacman-dev@lists.archlinux.org>.\n"
echo
printf -- "$(gettext "\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
trap_exit() {
# unhook all traps to avoid race conditions
trap '' EXIT TERM HUP QUIT INT ERR
echo
error "$@"
clean_up 1
}
clean_up() {
local exit_code=${1:-$?}
# unhook all traps to avoid race conditions
trap '' EXIT TERM HUP QUIT INT ERR
[[ -d $tmpdir ]] && rm -rf "$tmpdir"
exit $exit_code
}
read_pkginfo() {
unset pkgver pkgname arch
while IFS='=' read -r field value; do
# skip comments and invalid lines
[[ $field = '#'* || -z $value ]] && continue
# skip lines which aren't fields we care about
[[ $field != @(pkgver|pkgname|arch) ]] || continue
declare -g "${field% }=${value# }"
[[ $pkgname && $pkgver && $arch ]] && return 0
done < <(bsdtar -xOqf "$1" .PKGINFO 2>/dev/null)
error "$(gettext "Invalid package file '%s'.")" "$1"
return 1
}
create_pkgdiff() {
local oldfile=$1
local newfile=$2
local \
oldname oldver oldarch \
newname newver newarch \
diff_file
read_pkginfo "$oldfile" || return 1
oldname="$pkgname"
oldver="$pkgver"
oldarch="$arch"
read_pkginfo "$newfile" || return 1
newname="$pkgname"
newver="$pkgver"
newarch="$arch"
pkgsize=$(wc -c < "$newfile")
if ((pkgsize < min_pkg_size)); then
msg "$(gettext "Skipping pkgdiff creation for small package: %s - size %s")" "$newname" "$pkgsize"
return 0
fi
if [[ $oldname != "$newname" ]]; then
error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname"
return 1
fi
if [[ $oldarch != "$newarch" ]]; then
error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch"
return 1
fi
if [[ $oldver == "$newver" ]]; then
error "$(gettext "Both packages have the same version : '%s'")" "$newver"
return 1
fi
### TODO: check oldver < newver with vercmp ###
declare -r startdir="$(pwd -P)"
if [[ ${oldfile::1} != "/" ]]; then
oldfile=${startdir}/${oldfile}
fi
if [[ ${newfile::1} != "/" ]]; then
newfile=${startdir}/${newfile}
fi
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/pkgdiff.XXXXXXXXXX")
pushd $tmpdir &>/dev/null
### TODO: almost everything below here is a quick hack... ###
bsdtar -xOf $oldfile .MTREE | zcat | awk '{for (i=1;i<=NF;i++){if ($i ~/^sha256/) {print $1 " " $i}}}' > ${oldver}.files
bsdtar -xOf $newfile .MTREE | zcat | awk '{for (i=1;i<=NF;i++){if ($i ~/^sha256/) {print $1 " " $i}}}' > ${newver}.files
files=($(diff -Naur ${oldver}.files ${newver}.files |
grep "^+\./" |
grep -v -e "\.BUILDINFO" -e "\.PKGINFO" |
cut -f1 -d' ' |
sed 's|+./||'))
mkdir $newname
tar -xf $newfile -C $newname
diffdir="${oldname}-${oldver}-to-${newname}-${newver}-${newarch}.pkgdiff"
mkdir $diffdir
for f in ${files[@]}; do
mkdir -p ${diffdir}/${f%/*}
cp ${newname}/$f ${diffdir}/$f
done
cp ${newname}/.{BUILD,PKG}INFO ${diffdir}
### TODO: this should use libmakepkg/compress - need PKGEXT from makepkg.conf ###
### TODO: collect files in same order as makepkg ###
tar -cf ${diffdir}.tar ${diffdir}
zstd -T0 --ultra -20 ${diffdir}.tar &> /dev/null
diff_file=${diffdir}.tar.zst
diffsize=$(wc -c < "$diff_file")
if ((max_diff_size * pkgsize / 100 < diffsize)); then
msg "$(gettext "pkgdiff larger than maximum size. Removing.")"
rm -f "$diff_file"
return 0
fi
popd &>/dev/null
mv ${tmpdir}/${diff_file} .
msg "$(gettext "Generated pkgdiff : '%s'")" "$diff_file"
(( QUIET )) && echo "$diff_file"
return 0
}
# PROGRAM START
# determine whether we have gettext; make it a no-op if we do not
if ! type gettext &>/dev/null; then
gettext() {
echo "$@"
}
fi
case $1 in
-h|--help) usage; exit 0;;
-V|--version) version; exit 0;;
esac
trap 'clean_up' EXIT
for signal in TERM HUP QUIT; do
trap "trap_exit \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
done
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
OPT_SHORT='hqV'
OPT_LONG=('help' 'quiet' 'max-diff-size:' 'min-pkg-size:' 'nocolor' 'version')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1
fi
set -- "${OPTRET[@]}"
unset OPT_SHORT OPT_LONG OPTRET
# parse options
while :; do
case $1 in
-h|--help)
usage
exit 0 ;;
-V|--version)
version
exit 0 ;;
-q|--quiet)
QUIET=1;;
--nocolor)
USE_COLOR='n';;
--min-pkg-size)
### TODO ###
shift ;;
--max-delta-size)
### TODO ###
shift ;;
--)
shift
break ;;
esac
shift
done
# check if messages are to be printed using color
if [[ -t 2 && $USE_COLOR != "n" ]]; then
colorize
else
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
fi
if (( $# != 2 )); then
usage
exit 1
fi
for i in "$@"; do
if [[ ! -f $i ]]; then
error "$(gettext "File '%s' does not exist")" "$i"
exit 1
fi
done
### TODO: the creation of the pkgdiff should be done in fakeroot ###
create_pkgdiff "$@"

View File

@@ -584,9 +584,9 @@ if [[ $cmd != "repo-add" && $cmd != "repo-remove" ]]; then
exit 1
fi
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || (\
error "$(gettext "Cannot create temp directory for database building.")"; \
exit 1)
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || {
error "$(gettext "Cannot create temp directory for database building.")";
exit 1; }
for repo in "db" "files"; do
mkdir "$tmpdir/$repo"

View File

@@ -423,6 +423,8 @@ void cb_event(void *ctx, alpm_event_t *event)
void cb_question(void *ctx, alpm_question_t *question)
{
(void)ctx;
const colstr_t *colstr = &config->colstr;
if(config->print) {
switch(question->type) {
case ALPM_QUESTION_INSTALL_IGNOREPKG:
@@ -460,18 +462,30 @@ void cb_question(void *ctx, alpm_question_t *question)
{
alpm_question_conflict_t *q = &question->conflict;
/* print conflict only if it contains new information */
if(strcmp(q->conflict->package1, q->conflict->reason->name) == 0
|| strcmp(q->conflict->package2, q->conflict->reason->name) == 0) {
q->remove = noyes(_("%s and %s are in conflict. Remove %s?"),
q->conflict->package1,
q->conflict->package2,
q->conflict->package2);
if(strcmp(alpm_pkg_get_name(q->conflict->package1), q->conflict->reason->name) == 0
|| strcmp(alpm_pkg_get_name(q->conflict->package2), q->conflict->reason->name) == 0) {
q->remove = noyes(_("%s-%s%s%s and %s-%s%s%s are in conflict. Remove %s?"),
alpm_pkg_get_name(q->conflict->package1),
colstr->faint,
alpm_pkg_get_version(q->conflict->package1),
colstr->nocolor,
alpm_pkg_get_name(q->conflict->package2),
colstr->faint,
alpm_pkg_get_version(q->conflict->package2),
colstr->nocolor,
alpm_pkg_get_name(q->conflict->package2));
} else {
q->remove = noyes(_("%s and %s are in conflict (%s). Remove %s?"),
q->conflict->package1,
q->conflict->package2,
q->remove = noyes(_("%s-%s%s%s and %s-%s%s%s are in conflict (%s). Remove %s?"),
alpm_pkg_get_name(q->conflict->package1),
colstr->faint,
alpm_pkg_get_version(q->conflict->package1),
colstr->nocolor,
alpm_pkg_get_name(q->conflict->package2),
colstr->faint,
alpm_pkg_get_version(q->conflict->package2),
colstr->nocolor,
q->conflict->reason->name,
q->conflict->package2);
alpm_pkg_get_name(q->conflict->package2));
}
}
break;

View File

@@ -217,22 +217,6 @@ static int check_file_cksum(const char *pkgname, const char *filepath,
}
#endif
static int check_file_md5sum(const char *pkgname, const char *filepath,
struct archive_entry *entry, int backup)
{
int errors = 0;
#if ARCHIVE_VERSION_NUMBER >= 3005000
char *cksum_calc = alpm_compute_md5sum(filepath);
char *cksum_mtree = hex_representation(archive_entry_digest(entry,
ARCHIVE_ENTRY_DIGEST_MD5), 16);
errors = check_file_cksum(pkgname, filepath, backup, "MD5", cksum_calc,
cksum_mtree);
free(cksum_mtree);
free(cksum_calc);
#endif
return (errors != 0 ? 1 : 0);
}
static int check_file_sha256sum(const char *pkgname, const char *filepath,
struct archive_entry *entry, int backup)
{
@@ -428,7 +412,6 @@ int check_pkg_full(alpm_pkg_t *pkg)
if(type == AE_IFREG) {
file_errors += check_file_size(pkgname, filepath, &st, entry, backup);
file_errors += check_file_md5sum(pkgname, filepath, entry, backup);
file_errors += check_file_sha256sum(pkgname, filepath, entry, backup);
}

View File

@@ -1136,15 +1136,22 @@ int setdefaults(config_t *c)
#define SETDEFAULT(opt, val) if(!opt) { opt = val; if(!opt) { return -1; } }
if(c->rootdir) {
char* rootdir = strdup(c->rootdir);
int rootdir_len = strlen(rootdir);
/* This removes trailing slashes from the root directory */
if(rootdir[rootdir_len-1] == '/'){
rootdir[rootdir_len-1] = '\0';
}
char path[PATH_MAX];
if(!c->dbpath) {
snprintf(path, PATH_MAX, "%s/%s", c->rootdir, &DBPATH[1]);
snprintf(path, PATH_MAX, "%s/%s", rootdir, &DBPATH[1]);
SETDEFAULT(c->dbpath, strdup(path));
}
if(!c->logfile) {
snprintf(path, PATH_MAX, "%s/%s", c->rootdir, &LOGFILE[1]);
snprintf(path, PATH_MAX, "%s/%s", rootdir, &LOGFILE[1]);
SETDEFAULT(c->logfile, strdup(path));
}
free(rootdir);
} else {
SETDEFAULT(c->rootdir, strdup(ROOTDIR));
SETDEFAULT(c->dbpath, strdup(DBPATH));

View File

@@ -157,7 +157,7 @@ static int check_db_local_package_conflicts(alpm_list_t *pkglist)
for(i = data; i; i = i->next) {
alpm_conflict_t *conflict = i->data;
pm_printf(ALPM_LOG_ERROR, "'%s' conflicts with '%s'\n",
conflict->package1, conflict->package2);
alpm_pkg_get_name(conflict->package1), alpm_pkg_get_name(conflict->package2));
ret++;
}
alpm_list_free_inner(data, (alpm_list_fn_free)alpm_conflict_free);

View File

@@ -778,12 +778,19 @@ int sync_prepare_execute(void)
alpm_conflict_t *conflict = i->data;
/* only print reason if it contains new information */
if(conflict->reason->mod == ALPM_DEP_MOD_ANY) {
colon_printf(_("%s and %s are in conflict\n"),
conflict->package1, conflict->package2);
colon_printf(_("%s-%s and %s-%s are in conflict\n"),
alpm_pkg_get_name(conflict->package1),
alpm_pkg_get_version(conflict->package1),
alpm_pkg_get_name(conflict->package2),
alpm_pkg_get_version(conflict->package2));
} else {
char *reason = alpm_dep_compute_string(conflict->reason);
colon_printf(_("%s and %s are in conflict (%s)\n"),
conflict->package1, conflict->package2, reason);
colon_printf(_("%s-%s and %s-%s are in conflict (%s)\n"),
alpm_pkg_get_name(conflict->package1),
alpm_pkg_get_version(conflict->package1),
alpm_pkg_get_name(conflict->package2),
alpm_pkg_get_version(conflict->package2),
reason);
free(reason);
}
alpm_conflict_free(conflict);

View File

@@ -61,13 +61,24 @@ enum {
CELL_FREE = (1 << 3)
};
#define VAL_FROM_FORMAT_STR(temp, format, func) \
#define PRINT_FORMAT_STRING(temp, format, func) \
if(strstr(temp, format)) { \
string = strreplace(temp, format, func(pkg)); \
free(temp); \
temp = string; \
} \
#define PRINT_FORMAT_LIST(temp, format, func, extract) \
if(strstr(temp, format)) { \
alpm_list_t *lst = func(pkg); \
char *cl = concat_list(lst, (formatfn)extract); \
string = strreplace(temp, format, cl); \
free(cl); \
free(temp); \
temp = string; \
} \
int trans_init(int flags, int check_valid)
{
int ret;
@@ -405,26 +416,37 @@ char *strreplace(const char *str, const char *needle, const char *replace)
return newstr;
}
static char *concat_alpm_depends(alpm_list_t *lst)
typedef char *(*formatfn)(void*);
static char *concat_list(alpm_list_t *lst, formatfn fn)
{
char *depends = NULL;
char *tmp = NULL;
char *output = NULL, *tmp = NULL;
for(alpm_list_t *i = lst; i; i = alpm_list_next(i)) {
alpm_depend_t *dep = i->data;
char *depstring = alpm_dep_compute_string(dep);
if(tmp) {
asprintf(&depends, "%s %s", tmp, depstring);
free(tmp);
} else {
asprintf(&depends, "%s", depstring);
char *str = fn ? fn(i->data) : i->data;
if(str == NULL) {
continue;
}
if(tmp) {
asprintf(&output, "%s %s", tmp, str);
free(tmp);
} else {
asprintf(&output, "%s", str);
}
tmp = output;
if(fn) {
free(str);
}
tmp = depends;
free(depstring);
}
if(!depends) {
asprintf(&depends, "%s", "");
if(!output) {
asprintf(&output, "%s", "");
}
return depends;
return output;
}
static size_t string_length(const char *s)
@@ -1197,21 +1219,23 @@ void print_packages(const alpm_list_t *packages)
}
}
/* %d : description */
VAL_FROM_FORMAT_STR(temp, "%d", alpm_pkg_get_desc)
PRINT_FORMAT_STRING(temp, "%d", alpm_pkg_get_desc)
/* %e : pkgbase */
VAL_FROM_FORMAT_STR(temp, "%e", alpm_pkg_get_base)
PRINT_FORMAT_STRING(temp, "%e", alpm_pkg_get_base)
/* %f : filename */
VAL_FROM_FORMAT_STR(temp, "%f", alpm_pkg_get_filename)
PRINT_FORMAT_STRING(temp, "%f", alpm_pkg_get_filename)
/* %g : base64 encoded PGP signature */
VAL_FROM_FORMAT_STR(temp, "%g", alpm_pkg_get_base64_sig)
PRINT_FORMAT_STRING(temp, "%g", alpm_pkg_get_base64_sig)
/* %h : sha25sum */
VAL_FROM_FORMAT_STR(temp, "%h", alpm_pkg_get_sha256sum)
PRINT_FORMAT_STRING(temp, "%h", alpm_pkg_get_sha256sum)
/* %n : pkgname */
VAL_FROM_FORMAT_STR(temp, "%n", alpm_pkg_get_name)
PRINT_FORMAT_STRING(temp, "%n", alpm_pkg_get_name)
/* %p : packager */
VAL_FROM_FORMAT_STR(temp, "%p", alpm_pkg_get_packager)
PRINT_FORMAT_STRING(temp, "%p", alpm_pkg_get_packager)
/* %v : pkgver */
VAL_FROM_FORMAT_STR(temp, "%v", alpm_pkg_get_version)
PRINT_FORMAT_STRING(temp, "%v", alpm_pkg_get_version)
/* %m : md5sum */
PRINT_FORMAT_STRING(temp, "%m", alpm_pkg_get_md5sum)
/* %l : location */
if(strstr(temp, "%l")) {
char *pkgloc = pkg_get_location(pkg);
@@ -1240,34 +1264,26 @@ void print_packages(const alpm_list_t *packages)
free(temp);
}
/* %u : url */
VAL_FROM_FORMAT_STR(temp, "%u", alpm_pkg_get_url)
PRINT_FORMAT_STRING(temp, "%u", alpm_pkg_get_url)
/* %C : checkdepends */
if(strstr(temp, "%C")) {
alpm_list_t *lst = alpm_pkg_get_checkdepends(pkg);
char *depends = concat_alpm_depends(lst);
string = strreplace(temp, "%C", lst ? depends : "");
free(depends);
free(temp);
temp = string;
}
PRINT_FORMAT_LIST(temp, "%C", alpm_pkg_get_checkdepends, alpm_dep_compute_string)
/* %D : depends */
if(strstr(temp, "%D")) {
alpm_list_t *lst = alpm_pkg_get_depends(pkg);
char *depends = concat_alpm_depends(lst);
string = strreplace(temp, "%D", depends);
free(depends);
free(temp);
temp = string;
}
PRINT_FORMAT_LIST(temp, "%D", alpm_pkg_get_depends, alpm_dep_compute_string)
/* %G : groups */
PRINT_FORMAT_LIST(temp, "%G", alpm_pkg_get_groups, NULL)
/* %H : conflicts */
PRINT_FORMAT_LIST(temp, "%H", alpm_pkg_get_conflicts, alpm_dep_compute_string)
/* %M : makedepends */
if(strstr(temp, "%M")) {
alpm_list_t *lst = alpm_pkg_get_makedepends(pkg);
char *depends = concat_alpm_depends(lst);
string = strreplace(temp, "%M", depends);
free(depends);
free(temp);
temp = string;
}
PRINT_FORMAT_LIST(temp, "%M", alpm_pkg_get_makedepends, alpm_dep_compute_string)
/* %O : optdepends */
PRINT_FORMAT_LIST(temp, "%O", alpm_pkg_get_optdepends, alpm_dep_compute_string)
/* %P : provides */
PRINT_FORMAT_LIST(temp, "%P", alpm_pkg_get_provides, alpm_dep_compute_string)
/* %R : replaces */
PRINT_FORMAT_LIST(temp, "%R", alpm_pkg_get_replaces, alpm_dep_compute_string)
/* %L : license */
PRINT_FORMAT_LIST(temp, "%L", alpm_pkg_get_licenses, NULL)
printf("%s\n", string);
free(string);
}

View File

@@ -240,18 +240,20 @@ class pmtest(object):
cmd = []
if os.geteuid() != 0:
fakeroot = util.which("fakeroot")
if not fakeroot:
tap.diag("WARNING: fakeroot not found!")
else:
cmd.append("fakeroot")
# fakechroot must be called before fakeroot due to potential
# potential interactions when wrapping the same C functions
fakechroot = util.which("fakechroot")
if not fakechroot:
tap.diag("WARNING: fakechroot not found!")
else:
cmd.append("fakechroot")
fakeroot = util.which("fakeroot")
if not fakeroot:
tap.diag("WARNING: fakeroot not found!")
else:
cmd.append("fakeroot")
if pacman["gdb"]:
cmd.extend(["libtool", "execute", "gdb", "--args"])
if pacman["valgrind"]: