forked from mirrors/pacman
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			morganamil
			...
			andrew/pfo
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					7dc2266c2f | 
@@ -16,10 +16,6 @@ default:
 | 
			
		||||
      python
 | 
			
		||||
      fakeroot fakechroot
 | 
			
		||||
      meson
 | 
			
		||||
  artifacts:
 | 
			
		||||
      when: always
 | 
			
		||||
      paths:
 | 
			
		||||
        - build/meson-logs/meson-log.txt
 | 
			
		||||
 | 
			
		||||
arch:
 | 
			
		||||
  extends: .arch-test
 | 
			
		||||
@@ -50,14 +46,14 @@ arch-clang:
 | 
			
		||||
    - ninja -C build
 | 
			
		||||
    - fakechroot meson test -C build
 | 
			
		||||
 | 
			
		||||
#arch-valgrind:
 | 
			
		||||
#  extends: .arch-test
 | 
			
		||||
#  script:
 | 
			
		||||
#    - pacman -Syu --needed --noconfirm valgrind
 | 
			
		||||
#    - pacman -U --noconfirm https://geo.mirror.pkgbuild.com/core-debug/os/x86_64/glibc-debug-$(pacman -S --print-format %v glibc)-x86_64.pkg.tar.zst
 | 
			
		||||
#    - meson setup build
 | 
			
		||||
#    - ninja -C build
 | 
			
		||||
#    - PACTEST_VALGRIND=1 fakechroot meson test -C build
 | 
			
		||||
arch-valgrind:
 | 
			
		||||
  extends: .arch-test
 | 
			
		||||
  script:
 | 
			
		||||
    - pacman -Syu --needed --noconfirm valgrind
 | 
			
		||||
    - pacman -U --noconfirm https://geo.mirror.pkgbuild.com/core-debug/os/x86_64/glibc-debug-$(pacman -S --print-format %v glibc)-x86_64.pkg.tar.zst
 | 
			
		||||
    - meson setup build
 | 
			
		||||
    - ninja -C build
 | 
			
		||||
    - PACTEST_VALGRIND=1 fakechroot meson test -C build
 | 
			
		||||
 | 
			
		||||
arch-nettle:
 | 
			
		||||
  extends: .arch-test
 | 
			
		||||
 
 | 
			
		||||
@@ -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})
 | 
			
		||||
sha256sums=('9124ba46db0abd873d0995c2ca880e81252676bb6c03e0a37dfc5f608a9b0ceb'
 | 
			
		||||
            'SKIP')
 | 
			
		||||
md5sums=('e9ae5393426d3ad783a300a338c09b72'
 | 
			
		||||
         'SKIP')
 | 
			
		||||
 | 
			
		||||
build() {
 | 
			
		||||
	cd "$srcdir/$pkgname-$pkgver"
 | 
			
		||||
 
 | 
			
		||||
@@ -464,9 +464,6 @@ 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*::
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
	sha256sums=('dd9995706f0f9384a15ccffe116c3b6e22f42ba2e58d8f24ed03c4a0e386edb4')
 | 
			
		||||
	md5sums=('f014aec54f0a1e2e880d317180fce502')
 | 
			
		||||
	_distname="Config-Simple"
 | 
			
		||||
 | 
			
		||||
	# template start; name=perl-module; version=1.0;
 | 
			
		||||
 
 | 
			
		||||
@@ -146,9 +146,6 @@ 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
 | 
			
		||||
 
 | 
			
		||||
@@ -199,7 +199,7 @@ Options
 | 
			
		||||
		flags specified in LTOFLAGS to CFLAGS, CXXFLAGS and LDFLAGS (or
 | 
			
		||||
		``-flto'' if LTOFLAGS is empty).
 | 
			
		||||
 | 
			
		||||
	*autodeps*;;
 | 
			
		||||
	*autodep*;;
 | 
			
		||||
		Enable the automatic addition of libraries to the depends and
 | 
			
		||||
		provides arrays. Search library directories are controlled by
 | 
			
		||||
		the LIB_DIRS variable defined below.
 | 
			
		||||
@@ -236,7 +236,7 @@ Options
 | 
			
		||||
 | 
			
		||||
**LIB_DIRS=(**lib:usr/lib ...**)**::
 | 
			
		||||
	If `autodeps` is specified in the `OPTIONS` array, this variable will
 | 
			
		||||
	instruct makepkg where to look to find libraries to add to the `provides`
 | 
			
		||||
	instruct makepkg where to look to find librarys to add to the `provides`
 | 
			
		||||
	array. The format is "prefix:path", where provides will be added for
 | 
			
		||||
	libraries found in "path" with the specified prefix added.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -237,12 +237,10 @@ 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, "%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.
 | 
			
		||||
	"%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.
 | 
			
		||||
	Implies '\--print'.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -456,11 +454,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 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.
 | 
			
		||||
	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.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Database Options (apply to '-D')[[QO]]
 | 
			
		||||
@@ -489,8 +487,8 @@ Database Options (apply to '-D')[[QO]]
 | 
			
		||||
File Options (apply to '-F')[[FO]]
 | 
			
		||||
----------------------------------
 | 
			
		||||
*-y, --refresh*::
 | 
			
		||||
	Download fresh package file databases '(repo.files)' from the server.
 | 
			
		||||
	Use twice to force a refresh even if databases are up to date.
 | 
			
		||||
	Download fresh package databases 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.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
#!/hint/bash
 | 
			
		||||
#
 | 
			
		||||
# @sysconfdir@/makepkg.conf.d/rust.conf
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# RUST LANGUAGE SUPPORT
 | 
			
		||||
#########################################################################
 | 
			
		||||
#
 | 
			
		||||
#RUSTFLAGS="-C opt-level=2"
 | 
			
		||||
#DEBUG_RUSTFLAGS="-C debuginfo=2"
 | 
			
		||||
@@ -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::breezy'
 | 
			
		||||
VCSCLIENTS=('bzr::bzr'
 | 
			
		||||
            'fossil::fossil'
 | 
			
		||||
            'git::git'
 | 
			
		||||
            'hg::mercurial'
 | 
			
		||||
@@ -42,11 +42,13 @@ CHOST="@CHOST@"
 | 
			
		||||
#CXXFLAGS="-O2 -pipe"
 | 
			
		||||
#LDFLAGS=""
 | 
			
		||||
#LTOFLAGS="-flto"
 | 
			
		||||
#RUSTFLAGS="-C opt-level=2"
 | 
			
		||||
#-- Make Flags: change this for DistCC/SMP systems
 | 
			
		||||
#MAKEFLAGS="-j2"
 | 
			
		||||
#-- Debugging flags
 | 
			
		||||
#DEBUG_CFLAGS="-g"
 | 
			
		||||
#DEBUG_CXXFLAGS="-g"
 | 
			
		||||
#DEBUG_RUSTFLAGS="-C debuginfo=2"
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# BUILD ENVIRONMENT
 | 
			
		||||
@@ -109,7 +111,7 @@ PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
 | 
			
		||||
#-- Directory to store source code in for debug packages
 | 
			
		||||
DBGSRCDIR="/usr/src/debug"
 | 
			
		||||
#-- Prefix and directories for library autodeps
 | 
			
		||||
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
 | 
			
		||||
LIB_DIRS=('lib:/usr/lib' 'lib32:/usr/lib32')
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# PACKAGE OUTPUT
 | 
			
		||||
 
 | 
			
		||||
@@ -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 ret = 0, errors = 0;
 | 
			
		||||
	int i, 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);
 | 
			
		||||
 | 
			
		||||
		while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
 | 
			
		||||
		for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
 | 
			
		||||
			int percent;
 | 
			
		||||
 | 
			
		||||
			if(newpkg->size != 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -100,11 +100,6 @@ 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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -600,10 +600,16 @@ typedef struct _alpm_depmissing_t {
 | 
			
		||||
 | 
			
		||||
/** A conflict that has occurred between two packages. */
 | 
			
		||||
typedef struct _alpm_conflict_t {
 | 
			
		||||
	/** The first package */
 | 
			
		||||
	alpm_pkg_t *package1;
 | 
			
		||||
	/** The second package */
 | 
			
		||||
	alpm_pkg_t *package2;
 | 
			
		||||
	/** 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 conflict */
 | 
			
		||||
	alpm_depend_t *reason;
 | 
			
		||||
} alpm_conflict_t;
 | 
			
		||||
@@ -2907,6 +2913,9 @@ int alpm_capabilities(void);
 | 
			
		||||
/* End of libalpm_api */
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
size_t alpm_info_print_pkg(const char *format, alpm_pkg_t *pkg);
 | 
			
		||||
size_t alpm_info_print_pkgs(const char *format, alpm_list_t *pkgs);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -50,8 +50,10 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
 | 
			
		||||
 | 
			
		||||
	CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	ASSERT(_alpm_pkg_dup(pkg1, &conflict->package1) == 0, goto error);
 | 
			
		||||
	ASSERT(_alpm_pkg_dup(pkg2, &conflict->package2) == 0, goto error);
 | 
			
		||||
	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);
 | 
			
		||||
	conflict->reason = reason;
 | 
			
		||||
 | 
			
		||||
	return conflict;
 | 
			
		||||
@@ -64,9 +66,8 @@ error:
 | 
			
		||||
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(conflict != NULL, return);
 | 
			
		||||
	_alpm_pkg_free(conflict->package1);
 | 
			
		||||
	_alpm_pkg_free(conflict->package2);
 | 
			
		||||
 | 
			
		||||
	FREE(conflict->package2);
 | 
			
		||||
	FREE(conflict->package1);
 | 
			
		||||
	FREE(conflict);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -78,8 +79,10 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
 | 
			
		||||
	alpm_conflict_t *newconflict;
 | 
			
		||||
	CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	ASSERT(_alpm_pkg_dup(conflict->package1, &newconflict->package1) == 0, goto error);
 | 
			
		||||
	ASSERT(_alpm_pkg_dup(conflict->package2, &newconflict->package2) == 0, goto error);
 | 
			
		||||
	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);
 | 
			
		||||
	newconflict->reason = conflict->reason;
 | 
			
		||||
 | 
			
		||||
	return newconflict;
 | 
			
		||||
@@ -102,10 +105,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->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) {
 | 
			
		||||
		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) {
 | 
			
		||||
			return 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										226
									
								
								lib/libalpm/info.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								lib/libalpm/info.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,226 @@
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
 | 
			
		||||
#include "mfmt.h"
 | 
			
		||||
 | 
			
		||||
typedef enum field_t {
 | 
			
		||||
  FILENAME,
 | 
			
		||||
  NAME,
 | 
			
		||||
  BASE,
 | 
			
		||||
  DESCRIPTION,
 | 
			
		||||
  VERSION,
 | 
			
		||||
  ORIGIN,
 | 
			
		||||
  REASON,
 | 
			
		||||
  LICENSE,
 | 
			
		||||
  GROUP,
 | 
			
		||||
 | 
			
		||||
  DEPENDS,
 | 
			
		||||
  OPTDEPENDS,
 | 
			
		||||
  CONFLICTS,
 | 
			
		||||
  PROVIDES,
 | 
			
		||||
  REPLACES,
 | 
			
		||||
  REQUIREDBY,
 | 
			
		||||
 | 
			
		||||
  DELTAS,
 | 
			
		||||
  FILES,
 | 
			
		||||
  BACKUP,
 | 
			
		||||
  DB,
 | 
			
		||||
  VALIDATION,
 | 
			
		||||
  URL,
 | 
			
		||||
  BUILDDATE,
 | 
			
		||||
  INSTALLDATE,
 | 
			
		||||
  PACKAGER,
 | 
			
		||||
  MD5SUM,
 | 
			
		||||
  SHA256SUM,
 | 
			
		||||
  ARCH,
 | 
			
		||||
  SIZE,
 | 
			
		||||
  ISIZE,
 | 
			
		||||
  BASE64SIG,
 | 
			
		||||
 | 
			
		||||
  UNKNOWN,
 | 
			
		||||
} field_t;
 | 
			
		||||
 | 
			
		||||
static struct field_map_t {
 | 
			
		||||
  const char *input;
 | 
			
		||||
  field_t field;
 | 
			
		||||
} field_map[] = {
 | 
			
		||||
  {"filename", FILENAME},
 | 
			
		||||
  {"name", NAME},
 | 
			
		||||
  {"base", BASE},
 | 
			
		||||
  {"description", DESCRIPTION},
 | 
			
		||||
  {"version", VERSION},
 | 
			
		||||
 | 
			
		||||
  {"license", LICENSE},
 | 
			
		||||
  {"group", GROUP},
 | 
			
		||||
  {"groups", GROUP},
 | 
			
		||||
 | 
			
		||||
  {"depends", DEPENDS},
 | 
			
		||||
  {"optdepends", OPTDEPENDS},
 | 
			
		||||
  {"conflicts", CONFLICTS},
 | 
			
		||||
  {"provides", PROVIDES},
 | 
			
		||||
  {"replaces", REPLACES},
 | 
			
		||||
  {"requiredby", REQUIREDBY},
 | 
			
		||||
 | 
			
		||||
  {"url", URL},
 | 
			
		||||
  {"builddate", BUILDDATE},
 | 
			
		||||
  {"installdate", INSTALLDATE},
 | 
			
		||||
  {"packager", PACKAGER},
 | 
			
		||||
  {"md5sum", MD5SUM},
 | 
			
		||||
  {"sha256sum", SHA256SUM},
 | 
			
		||||
  {"arch", ARCH},
 | 
			
		||||
  {"size", SIZE},
 | 
			
		||||
  {"isize", ISIZE},
 | 
			
		||||
  {"base64sig", BASE64SIG},
 | 
			
		||||
 | 
			
		||||
  {NULL, 0}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static char *_alpm_hr_size(off_t bytes, char *dest)
 | 
			
		||||
{
 | 
			
		||||
  static const char *suff[] = {"B", "K", "M", "G", "T", "P", "E", NULL};
 | 
			
		||||
  float hrsize;
 | 
			
		||||
  int s = 0;
 | 
			
		||||
  while((bytes >= 1000000 || bytes <= -1000000) && suff[s + 1]) {
 | 
			
		||||
    bytes /= 1024;
 | 
			
		||||
    ++s;
 | 
			
		||||
  }
 | 
			
		||||
  hrsize = bytes;
 | 
			
		||||
  if((hrsize >= 1000 || hrsize <= -1000) && suff[s + 1]) {
 | 
			
		||||
    hrsize /= 1024;
 | 
			
		||||
    ++s;
 | 
			
		||||
  }
 | 
			
		||||
  sprintf(dest, "%.2f %s", hrsize, suff[s]);
 | 
			
		||||
  return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static field_t _alpm_info_lookup_field(const char *name) {
 | 
			
		||||
  struct field_map_t *m;
 | 
			
		||||
  for(m = field_map; m->input; m++) {
 | 
			
		||||
    if(strcmp(name, m->input) == 0) { return m->field; }
 | 
			
		||||
  }
 | 
			
		||||
  return UNKNOWN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_print_str(mfmt_token_callback_t *t, const char *str, FILE *f) {
 | 
			
		||||
  return mfmt_render_str(t, str ? str : "NULL", f);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_print_size(mfmt_token_callback_t *t, const off_t s, FILE *f) {
 | 
			
		||||
  if(s) {
 | 
			
		||||
    char hrsize[50];
 | 
			
		||||
    if(t->conversion == 'd') {
 | 
			
		||||
      snprintf(hrsize, 50, "%lld", (long long)s);
 | 
			
		||||
    } else {
 | 
			
		||||
      _alpm_hr_size(s, hrsize);
 | 
			
		||||
    }
 | 
			
		||||
    return mfmt_render_str(t, hrsize, f);
 | 
			
		||||
  } else {
 | 
			
		||||
    return mfmt_render_str(t, "NULL", f);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_print_strlist(mfmt_token_callback_t *t, alpm_list_t *l, FILE *f) {
 | 
			
		||||
  if(l) {
 | 
			
		||||
    size_t len = 0;
 | 
			
		||||
    while(l) {
 | 
			
		||||
      len += mfmt_render_str(t, l->data, f) + 1;
 | 
			
		||||
      fputc('\n', f);
 | 
			
		||||
      l = l->next;
 | 
			
		||||
    }
 | 
			
		||||
    return len;
 | 
			
		||||
  } else {
 | 
			
		||||
    return mfmt_render_str(t, "NULL", f);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_print_deplist(mfmt_token_callback_t *t, alpm_list_t *l, FILE *f) {
 | 
			
		||||
  if(l) {
 | 
			
		||||
    size_t len = 0;
 | 
			
		||||
    while(l) {
 | 
			
		||||
      char *s = alpm_dep_compute_string(l->data);
 | 
			
		||||
      len += mfmt_render_str(t, s, f) + 1;
 | 
			
		||||
      fputc('\n', f);
 | 
			
		||||
      l = l->next;
 | 
			
		||||
      free(s);
 | 
			
		||||
    }
 | 
			
		||||
    return len;
 | 
			
		||||
  } else {
 | 
			
		||||
    return mfmt_render_str(t, "NULL", f);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_print_timestamp(mfmt_token_callback_t *t, const alpm_time_t s, FILE *f) {
 | 
			
		||||
  if(s) {
 | 
			
		||||
    char datestr[50] = "";
 | 
			
		||||
    if(strftime(datestr, 50, " %c", localtime(&s)) == 0) { return 0; }
 | 
			
		||||
    return mfmt_render_str(t, datestr + 1, f);
 | 
			
		||||
  } else {
 | 
			
		||||
    return mfmt_render_str(t, "NULL", f);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _alpm_info_process_token(FILE *f, mfmt_token_callback_t *t, void *ctx, void *arg) {
 | 
			
		||||
  alpm_pkg_t *p = arg;
 | 
			
		||||
  (void)ctx;
 | 
			
		||||
  switch(_alpm_info_lookup_field(t->name)) {
 | 
			
		||||
    case NAME:        return _alpm_info_print_str(t, alpm_pkg_get_name(p), f);
 | 
			
		||||
    case DESCRIPTION: return _alpm_info_print_str(t, alpm_pkg_get_desc(p), f);
 | 
			
		||||
    case PACKAGER:    return _alpm_info_print_str(t, alpm_pkg_get_packager(p), f);
 | 
			
		||||
    case MD5SUM:      return _alpm_info_print_str(t, alpm_pkg_get_md5sum(p), f);
 | 
			
		||||
    case FILENAME:    return _alpm_info_print_str(t, alpm_pkg_get_filename(p), f);
 | 
			
		||||
    case BASE:        return _alpm_info_print_str(t, alpm_pkg_get_base(p), f);
 | 
			
		||||
    case VERSION:     return _alpm_info_print_str(t, alpm_pkg_get_version(p), f);
 | 
			
		||||
    case URL:         return _alpm_info_print_str(t, alpm_pkg_get_url(p), f);
 | 
			
		||||
    case SHA256SUM:   return _alpm_info_print_str(t, alpm_pkg_get_sha256sum(p), f);
 | 
			
		||||
    case ARCH:        return _alpm_info_print_str(t, alpm_pkg_get_arch(p), f);
 | 
			
		||||
    case BASE64SIG:   return _alpm_info_print_str(t, alpm_pkg_get_base64_sig(p), f);
 | 
			
		||||
 | 
			
		||||
    case SIZE:  return _alpm_info_print_size(t, alpm_pkg_get_size(p), f);
 | 
			
		||||
    case ISIZE: return _alpm_info_print_size(t, alpm_pkg_get_isize(p), f);
 | 
			
		||||
 | 
			
		||||
    case BUILDDATE:   return _alpm_info_print_timestamp(t, alpm_pkg_get_builddate(p), f);
 | 
			
		||||
    case INSTALLDATE: return _alpm_info_print_timestamp(t, alpm_pkg_get_installdate(p), f);
 | 
			
		||||
 | 
			
		||||
    case DEPENDS:    return _alpm_info_print_deplist(t, alpm_pkg_get_depends(p), f);
 | 
			
		||||
    case OPTDEPENDS: return _alpm_info_print_deplist(t, alpm_pkg_get_optdepends(p), f);
 | 
			
		||||
    case CONFLICTS:  return _alpm_info_print_deplist(t, alpm_pkg_get_conflicts(p), f);
 | 
			
		||||
    case PROVIDES:   return _alpm_info_print_deplist(t, alpm_pkg_get_provides(p), f);
 | 
			
		||||
    case REPLACES:   return _alpm_info_print_deplist(t, alpm_pkg_get_replaces(p), f);
 | 
			
		||||
    case REQUIREDBY: {
 | 
			
		||||
                       alpm_list_t *rb = alpm_pkg_compute_requiredby(p);
 | 
			
		||||
                       size_t len = _alpm_info_print_strlist(t, rb, f);
 | 
			
		||||
                       FREELIST(rb);
 | 
			
		||||
                       return len;
 | 
			
		||||
                     }
 | 
			
		||||
 | 
			
		||||
    default:          errno = EINVAL; return 0;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t SYMEXPORT alpm_info_print_pkg(const char *format, alpm_pkg_t *pkg) {
 | 
			
		||||
  alpm_list_t l = {
 | 
			
		||||
    .data = pkg,
 | 
			
		||||
    .next = NULL,
 | 
			
		||||
  };
 | 
			
		||||
  l.prev = &l;
 | 
			
		||||
  return alpm_info_print_pkgs(format, &l);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t SYMEXPORT alpm_info_print_pkgs(const char *format, alpm_list_t *pkgs) {
 | 
			
		||||
  mfmt_t *mfmt = mfmt_parse(format, _alpm_info_process_token, NULL);
 | 
			
		||||
  size_t len = 0;
 | 
			
		||||
  if(mfmt == NULL) {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  for(alpm_list_t *i = pkgs; i; i = i->next) {
 | 
			
		||||
    size_t plen = mfmt_printf(mfmt, i->data, stdout);
 | 
			
		||||
    if(plen == 0) { return 0; }
 | 
			
		||||
    len += plen;
 | 
			
		||||
  }
 | 
			
		||||
  return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 et: */
 | 
			
		||||
@@ -28,5 +28,7 @@ libalpm_sources = files('''
 | 
			
		||||
  sync.h sync.c
 | 
			
		||||
  trans.h trans.c
 | 
			
		||||
  util.h util.c
 | 
			
		||||
  info.c
 | 
			
		||||
  mfmt.c mfmt.h
 | 
			
		||||
  version.c
 | 
			
		||||
'''.split())
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										193
									
								
								lib/libalpm/mfmt.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								lib/libalpm/mfmt.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,193 @@
 | 
			
		||||
#define _GNU_SOURCE
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "mfmt.h"
 | 
			
		||||
 | 
			
		||||
char *_mfmt_find_unescaped_char(char *haystack, char needle) {
 | 
			
		||||
    while(1) {
 | 
			
		||||
        haystack = strchrnul(haystack, needle);
 | 
			
		||||
        if(*haystack && *(haystack + 1) == needle) { haystack += 2; continue; }
 | 
			
		||||
        else { break; }
 | 
			
		||||
    }
 | 
			
		||||
    return haystack;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void _mfmt_brace_dedup(char *str) {
 | 
			
		||||
    char *c = str, *end = str + strlen(str);
 | 
			
		||||
    while((c = strchr(c, '{'))) {
 | 
			
		||||
        memmove(c, c + 1, end - c);
 | 
			
		||||
        c++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    c = str;
 | 
			
		||||
    while((c = strchr(c, '}'))) {
 | 
			
		||||
        memmove(c, c + 1, end - c);
 | 
			
		||||
        c++;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mfmt_t *mfmt_parse(const char *tmpl, mfmt_callback_t *cb, void *ctx) {
 | 
			
		||||
    mfmt_t *mfmt;
 | 
			
		||||
    char *c;
 | 
			
		||||
 | 
			
		||||
    mfmt = calloc(sizeof(mfmt_t), 1);
 | 
			
		||||
    if(mfmt == NULL) { return NULL; }
 | 
			
		||||
 | 
			
		||||
    mfmt->cb = cb;
 | 
			
		||||
    mfmt->ctx = ctx;
 | 
			
		||||
 | 
			
		||||
    for(c = (char*) tmpl; c && *c; ) {
 | 
			
		||||
        mfmt->token_count++;
 | 
			
		||||
        if(*c == '{' && *(c + 1) != '{') {
 | 
			
		||||
            /* replacement */
 | 
			
		||||
            if(!*(c = _mfmt_find_unescaped_char(c + 1, '}'))) {
 | 
			
		||||
                errno = EINVAL;
 | 
			
		||||
                free(mfmt);
 | 
			
		||||
                return NULL;
 | 
			
		||||
            } else {
 | 
			
		||||
                c++;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            /* literal */
 | 
			
		||||
            c = _mfmt_find_unescaped_char(c, '{');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if((mfmt->tokens = calloc(sizeof(mfmt_token_t), mfmt->token_count)) == NULL) {
 | 
			
		||||
        free(mfmt);
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    size_t i;
 | 
			
		||||
    for(c = (char*) tmpl, i = 0; c && *c; i++) {
 | 
			
		||||
        if(*c == '{' && *(c + 1) != '{') {
 | 
			
		||||
            /* replacement */
 | 
			
		||||
            mfmt_token_callback_t *t = &mfmt->tokens[i].callback;
 | 
			
		||||
            char *end = _mfmt_find_unescaped_char(c + 1, '}');
 | 
			
		||||
            t->type = MFMT_TOKEN_CALLBACK;
 | 
			
		||||
            t->name = strndup(c + 1, end - c - 1);
 | 
			
		||||
            c = end + 1;
 | 
			
		||||
        } else {
 | 
			
		||||
            /* literal */
 | 
			
		||||
            char *end = _mfmt_find_unescaped_char(c, '{');
 | 
			
		||||
            mfmt_token_literal_t *t = &mfmt->tokens[i].literal;
 | 
			
		||||
            t->type = MFMT_TOKEN_LITERAL;
 | 
			
		||||
            t->string = strndup(c, end - c);
 | 
			
		||||
            _mfmt_brace_dedup(t->string);
 | 
			
		||||
            c = end;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return mfmt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_printf(mfmt_t *mfmt, void *args, FILE *f) {
 | 
			
		||||
    size_t len = 0;
 | 
			
		||||
    size_t i;
 | 
			
		||||
    for(i = 0; i < mfmt->token_count; i++) {
 | 
			
		||||
        mfmt_token_t *t = &mfmt->tokens[i];
 | 
			
		||||
        switch(t->base.type) {
 | 
			
		||||
            case MFMT_TOKEN_LITERAL:
 | 
			
		||||
                len += fputs(t->literal.string, f);
 | 
			
		||||
                break;
 | 
			
		||||
            case MFMT_TOKEN_CALLBACK:
 | 
			
		||||
                len += mfmt->cb(f, &t->callback, mfmt->ctx, args);
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                errno = EINVAL;
 | 
			
		||||
                return 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t _mfmt_printf_close(mfmt_t *mfmt, void *args, FILE *f) {
 | 
			
		||||
    if(f) {
 | 
			
		||||
        size_t len = mfmt_printf(mfmt, args, f);
 | 
			
		||||
        fclose(f);
 | 
			
		||||
        return len;
 | 
			
		||||
    }
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_printd(mfmt_t *mfmt, void *args, int fd) {
 | 
			
		||||
    return _mfmt_printf_close(mfmt, args, fdopen(fd, "w"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_printb(mfmt_t *mfmt, void *args, char *buf, size_t buflen) {
 | 
			
		||||
    return _mfmt_printf_close(mfmt, args, fmemopen(buf, buflen, "w"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_prints(mfmt_t *mfmt, void *args, char **buf, size_t *buflen) {
 | 
			
		||||
    return _mfmt_printf_close(mfmt, args, open_memstream(buf, buflen));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_fmt(const char *tmpl, mfmt_val_t *args, FILE *f) {
 | 
			
		||||
    mfmt_t *mfmt = mfmt_parse(tmpl, NULL, NULL);
 | 
			
		||||
    size_t len;
 | 
			
		||||
    for(size_t i = 0; i < mfmt->token_count; i++) {
 | 
			
		||||
        mfmt_token_t *t = &mfmt->tokens[i];
 | 
			
		||||
        switch(t->base.type) {
 | 
			
		||||
            case MFMT_TOKEN_LITERAL:
 | 
			
		||||
                len += fputs(t->literal.string, f);
 | 
			
		||||
                break;
 | 
			
		||||
            case MFMT_TOKEN_CALLBACK:
 | 
			
		||||
                /* fprintf(stderr, "token: %s\n", t->callback.name); */
 | 
			
		||||
                if(t->callback.name[0]) {
 | 
			
		||||
                    for(mfmt_val_t *v = args; v; v++) {
 | 
			
		||||
                        /* fprintf(stderr, "val: %s\n", v->name); */
 | 
			
		||||
                        if(strcmp(v->name, t->callback.name) == 0) {
 | 
			
		||||
                            len += fputs(v->string, f);
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    len += fputs(args->string, f);
 | 
			
		||||
                    args++;
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_mfmt(mfmt_t *mfmt, mfmt_val_t *args, FILE *f) {
 | 
			
		||||
    size_t len;
 | 
			
		||||
    for(size_t i = 0; i < mfmt->token_count; i++) {
 | 
			
		||||
        mfmt_token_t *t = &mfmt->tokens[i];
 | 
			
		||||
        switch(t->base.type) {
 | 
			
		||||
            case MFMT_TOKEN_LITERAL:
 | 
			
		||||
                len += fputs(t->literal.string, f);
 | 
			
		||||
                break;
 | 
			
		||||
            case MFMT_TOKEN_CALLBACK:
 | 
			
		||||
                /* fprintf(stderr, "token: %s\n", t->callback.name); */
 | 
			
		||||
                if(t->callback.name[0]) {
 | 
			
		||||
                    for(mfmt_val_t *v = args; v; v++) {
 | 
			
		||||
                        /* fprintf(stderr, "val: %s\n", v->name); */
 | 
			
		||||
                        if(strcmp(v->name, t->callback.name) == 0) {
 | 
			
		||||
                            len += fputs(v->string, f);
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    len += fputs(args->string, f);
 | 
			
		||||
                    args++;
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_render_int(mfmt_token_callback_t *t, const intmax_t i, FILE *f) {
 | 
			
		||||
    (void)t;
 | 
			
		||||
    return fprintf(f, "%jd", i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t mfmt_render_str(mfmt_token_callback_t *t, const char *str, FILE *f) {
 | 
			
		||||
    (void)t;
 | 
			
		||||
    return fputs(str, f);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										66
									
								
								lib/libalpm/mfmt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								lib/libalpm/mfmt.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
 | 
			
		||||
typedef enum mfmt_token_type_t {
 | 
			
		||||
    MFMT_TOKEN_LITERAL,
 | 
			
		||||
    MFMT_TOKEN_CALLBACK,
 | 
			
		||||
} mfmt_token_type_t;
 | 
			
		||||
 | 
			
		||||
typedef struct mfmt_token_literal_t {
 | 
			
		||||
    mfmt_token_type_t type;
 | 
			
		||||
    char *string;
 | 
			
		||||
} mfmt_token_literal_t;
 | 
			
		||||
 | 
			
		||||
typedef struct mfmt_token_base_t {
 | 
			
		||||
    mfmt_token_type_t type;
 | 
			
		||||
} mfmt_token_base_t;
 | 
			
		||||
 | 
			
		||||
typedef struct mfmt_token_callback_t {
 | 
			
		||||
    mfmt_token_type_t type;
 | 
			
		||||
 | 
			
		||||
    size_t position;
 | 
			
		||||
    char *name;
 | 
			
		||||
    size_t width;
 | 
			
		||||
    size_t precision;
 | 
			
		||||
    char align;
 | 
			
		||||
    char fill;
 | 
			
		||||
    char conversion;
 | 
			
		||||
    int sign;
 | 
			
		||||
} mfmt_token_callback_t;
 | 
			
		||||
 | 
			
		||||
typedef union mfmt_token_t {
 | 
			
		||||
    mfmt_token_base_t base;
 | 
			
		||||
    mfmt_token_literal_t literal;
 | 
			
		||||
    mfmt_token_callback_t callback;
 | 
			
		||||
} mfmt_token_t;
 | 
			
		||||
 | 
			
		||||
typedef size_t (mfmt_callback_t)(FILE *f, mfmt_token_callback_t *token, void *ctx, void *args);
 | 
			
		||||
 | 
			
		||||
typedef struct mfmt_t {
 | 
			
		||||
    mfmt_callback_t *cb;
 | 
			
		||||
    void *ctx;
 | 
			
		||||
    size_t token_count;
 | 
			
		||||
    mfmt_token_t *tokens;
 | 
			
		||||
} mfmt_t;
 | 
			
		||||
 | 
			
		||||
typedef struct mfmt_val_t {
 | 
			
		||||
    const char *name;
 | 
			
		||||
    const char *string;
 | 
			
		||||
} mfmt_val_t;
 | 
			
		||||
 | 
			
		||||
mfmt_t *mfmt_parse(const char *tmpl, mfmt_callback_t *cb, void *ctx);
 | 
			
		||||
size_t mfmt_printf(mfmt_t *mfmt, void *args, FILE *f);
 | 
			
		||||
size_t mfmt_printd(mfmt_t *mfmt, void *args, int fd);
 | 
			
		||||
size_t mfmt_printb(mfmt_t *mfmt, void *args, char *buf, size_t buflen);
 | 
			
		||||
size_t mfmt_prints(mfmt_t *mfmt, void *args, char **buf, size_t *buflen);
 | 
			
		||||
void mfmt_free(mfmt_t *mfmt);
 | 
			
		||||
 | 
			
		||||
size_t mfmt_render_int(mfmt_token_callback_t *token, intmax_t i, FILE *f);
 | 
			
		||||
size_t mfmt_render_uint(mfmt_token_callback_t *token, uintmax_t i, FILE *f);
 | 
			
		||||
size_t mfmt_render_str(mfmt_token_callback_t *token, const char *str, FILE *f);
 | 
			
		||||
 | 
			
		||||
size_t mfmt_formatf(const char *tmpl, mfmt_callback_t *cb, void *ctx, FILE *f);
 | 
			
		||||
size_t mfmt_formatd(const char *tmpl, mfmt_callback_t *cb, void *ctx, int fd);
 | 
			
		||||
size_t mfmt_formatb(const char *tmpl, mfmt_callback_t *cb, void *ctx, char *buf, size_t buflen);
 | 
			
		||||
size_t mfmt_formats(const char *tmpl, mfmt_callback_t *cb, void *ctx, char **buf);
 | 
			
		||||
@@ -517,23 +517,21 @@ 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, name1);
 | 
			
		||||
			sync2 = alpm_pkg_find(trans->add, name2);
 | 
			
		||||
			sync1 = alpm_pkg_find(trans->add, conflict->package1);
 | 
			
		||||
			sync2 = alpm_pkg_find(trans->add, conflict->package2);
 | 
			
		||||
			if(!sync1 || !sync2) {
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
 | 
			
		||||
					name1, name2);
 | 
			
		||||
					conflict->package1, conflict->package2);
 | 
			
		||||
 | 
			
		||||
			/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
 | 
			
		||||
			alpm_depend_t *dep1 = alpm_dep_from_string(name1);
 | 
			
		||||
			alpm_depend_t *dep2 = alpm_dep_from_string(name2);
 | 
			
		||||
			alpm_depend_t *dep1 = alpm_dep_from_string(conflict->package1);
 | 
			
		||||
			alpm_depend_t *dep2 = alpm_dep_from_string(conflict->package2);
 | 
			
		||||
			if(_alpm_depcmp(sync1, dep2)) {
 | 
			
		||||
				rsync = sync2;
 | 
			
		||||
				sync = sync1;
 | 
			
		||||
@@ -561,8 +559,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
 | 
			
		||||
 | 
			
		||||
			/* Prints warning */
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
					_("removing '%s-%s' from target list because it conflicts with '%s-%s'\n"),
 | 
			
		||||
					rsync->name, rsync->version, sync->name, sync->version);
 | 
			
		||||
					_("removing '%s' from target list because it conflicts with '%s'\n"),
 | 
			
		||||
					rsync->name, sync->name);
 | 
			
		||||
			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);
 | 
			
		||||
@@ -583,18 +581,16 @@ 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 name2 (the local package) is not elected for removal,
 | 
			
		||||
			/* if conflict->package2 (the local package) is not elected for removal,
 | 
			
		||||
			   we ask the user */
 | 
			
		||||
			if(alpm_pkg_find(trans->remove, name2)) {
 | 
			
		||||
			if(alpm_pkg_find(trans->remove, conflict->package2)) {
 | 
			
		||||
				found = 1;
 | 
			
		||||
			}
 | 
			
		||||
			for(j = trans->add; j && !found; j = j->next) {
 | 
			
		||||
				alpm_pkg_t *spkg = j->data;
 | 
			
		||||
				if(alpm_pkg_find(spkg->removes, name2)) {
 | 
			
		||||
				if(alpm_pkg_find(spkg->removes, conflict->package2)) {
 | 
			
		||||
					found = 1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@@ -602,15 +598,15 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s-%s' conflicts with '%s-%s'\n",
 | 
			
		||||
					name1, conflict->package1->version, name2,conflict->package2->version);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
 | 
			
		||||
					conflict->package1, conflict->package2);
 | 
			
		||||
 | 
			
		||||
			QUESTION(handle, &question);
 | 
			
		||||
			if(question.remove) {
 | 
			
		||||
				/* append to the removes list */
 | 
			
		||||
				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);
 | 
			
		||||
				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);
 | 
			
		||||
				sync->removes = alpm_list_add(sync->removes, local);
 | 
			
		||||
			} else { /* abort */
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								meson.build
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								meson.build
									
									
									
									
									
								
							@@ -182,22 +182,7 @@ foreach type : [
 | 
			
		||||
  endif
 | 
			
		||||
endforeach
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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')
 | 
			
		||||
if 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')
 | 
			
		||||
@@ -205,7 +190,6 @@ endif
 | 
			
		||||
 | 
			
		||||
if get_option('debug')
 | 
			
		||||
  extra_cflags = [
 | 
			
		||||
    '-pedantic',
 | 
			
		||||
    '-Wcast-align',
 | 
			
		||||
    '-Wclobbered',
 | 
			
		||||
    '-Wempty-body',
 | 
			
		||||
@@ -417,12 +401,6 @@ configure_file(
 | 
			
		||||
  configuration : substs,
 | 
			
		||||
  install_dir : SYSCONFDIR)
 | 
			
		||||
 | 
			
		||||
configure_file(
 | 
			
		||||
  input : 'etc/makepkg.conf.d/rust.conf.in',
 | 
			
		||||
  output : 'rust.conf',
 | 
			
		||||
  configuration : substs,
 | 
			
		||||
  install_dir : join_paths(SYSCONFDIR, 'makepkg.conf.d/'))
 | 
			
		||||
 | 
			
		||||
configure_file(
 | 
			
		||||
  input : 'etc/pacman.conf.in',
 | 
			
		||||
  output : 'pacman.conf',
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ changelog=
 | 
			
		||||
source=("$pkgbase-$pkgver.tar.gz"
 | 
			
		||||
        "$pkgname-$pkgver.patch")
 | 
			
		||||
noextract=()
 | 
			
		||||
sha256sums=()
 | 
			
		||||
md5sums=()
 | 
			
		||||
validpgpkeys=()
 | 
			
		||||
 | 
			
		||||
prepare() {
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ options=()
 | 
			
		||||
install=
 | 
			
		||||
source=('FOLDER::VCS+URL#FRAGMENT')
 | 
			
		||||
noextract=()
 | 
			
		||||
sha256sums=('SKIP')
 | 
			
		||||
md5sums=('SKIP')
 | 
			
		||||
 | 
			
		||||
# Please refer to the 'USING VCS SOURCES' section of the PKGBUILD man page for
 | 
			
		||||
# a description of each element in the source array.
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ changelog=
 | 
			
		||||
source=("$pkgname-$pkgver.tar.gz"
 | 
			
		||||
        "$pkgname-$pkgver.patch")
 | 
			
		||||
noextract=()
 | 
			
		||||
sha256sums=()
 | 
			
		||||
md5sums=()
 | 
			
		||||
validpgpkeys=()
 | 
			
		||||
 | 
			
		||||
prepare() {
 | 
			
		||||
 
 | 
			
		||||
@@ -586,38 +586,38 @@ _pacman_conf() {
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_key_shortopts=(
 | 
			
		||||
_key_shortopts=(
 | 
			
		||||
	'-h[show help]'
 | 
			
		||||
	'-a[Add the specified keys (empty for stdin)]: :_files'
 | 
			
		||||
	'-d[Remove the Specified keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'-e[Export the specified or all keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'-f[List fingerprint for specified or all keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'-l[List the specified or all keys]:*: :_pacman_key_list'
 | 
			
		||||
	'-r[Fetch the specified keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'-d[Remove the Specified keyids]:*: :_keys'
 | 
			
		||||
	'-e[Export the specified or all keyids]:*: :_keys'
 | 
			
		||||
	'-f[List fingerprint for specified or all keyids]:*: :_keys'
 | 
			
		||||
	'-l[List the specified or all keys]:*: :_keys'
 | 
			
		||||
	'-r[Fetch the specified keyids]:*: :_keys'
 | 
			
		||||
	'-u[Update the trustdb of pacman]'
 | 
			
		||||
	'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
 | 
			
		||||
	'-V[Show program version]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_pacman_key_longopts=(
 | 
			
		||||
_key_longopts=(
 | 
			
		||||
	'--help[show help]'
 | 
			
		||||
	'--add[Add the specified keys (empty for stdin)]: :_files'
 | 
			
		||||
	'--delete[Remove the Specified keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'--export[Export the specified or all keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'--finger[List fingerprint for specified or all keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'--list-keys[List the specified or all keys]:*: :_pacman_key_list'
 | 
			
		||||
	'--recv-keys[Fetch the specified keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'--delete[Remove the Specified keyids]:*: :_keys'
 | 
			
		||||
	'--export[Export the specified or all keyids]:*: :_keys'
 | 
			
		||||
	'--finger[List fingerprint for specified or all keyids]:*: :_keys'
 | 
			
		||||
	'--list-keys[List the specified or all keys]:*: :_keys'
 | 
			
		||||
	'--recv-keys[Fetch the specified keyids]:*: :_keys'
 | 
			
		||||
	'--updatedb[Update the trustdb of pacman]'
 | 
			
		||||
	'--verify[Verify the file specified by the signature]: :_files -g "*.sig"'
 | 
			
		||||
	'--version[Show program version]'
 | 
			
		||||
	'--edit-key[Present a menu for key management task on keyids]:*: :_pacman_key_list'
 | 
			
		||||
	'--edit-key[Present a menu for key management task on keyids]:*: :_keys'
 | 
			
		||||
	'--import[Imports pubring.gpg from dir(s)]: :_files -g "*.gpg"'
 | 
			
		||||
	'--import-tb[Imports ownertrust values from trustdb.gpg in dir(s)]: :_files -g "*.gpg"'
 | 
			
		||||
	'--init[Ensure the keyring is properly initialized]'
 | 
			
		||||
	'--list-sigs[List keys and their signatures]:*: :_pacman_key_list'
 | 
			
		||||
	'--lsign-key[Locally sign the specified keyid]:*: :_pacman_key_list'
 | 
			
		||||
	'--list-sigs[List keys and their signatures]:*: :_keys'
 | 
			
		||||
	'--lsign-key[Locally sign the specified keyid]:*: :_keys'
 | 
			
		||||
	'--populate[Reload the default keys from the (given) keyrings in '@keyringdir@']: :_path_files -W @keyringdir@'
 | 
			
		||||
	'--refresh-keys[Update specified or all keys from a keyserver]:*: :_pacman_key_list'
 | 
			
		||||
	'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_pacman_key_options=(
 | 
			
		||||
@@ -631,13 +631,13 @@ _pacman_key() {
 | 
			
		||||
		--*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_key_options[@]" \
 | 
			
		||||
				"$_pacman_key_longopts[@]"
 | 
			
		||||
				"$_key_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		-*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_key_options[@]" \
 | 
			
		||||
				"$_pacman_key_shortopts[@]" \
 | 
			
		||||
				"$_pacman_key_longopts[@]"
 | 
			
		||||
				"$_key_shortopts[@]" \
 | 
			
		||||
				"$_key_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			i=$#
 | 
			
		||||
@@ -648,13 +648,13 @@ _pacman_key() {
 | 
			
		||||
				--*)
 | 
			
		||||
					_arguments -s : \
 | 
			
		||||
						"$_pacman_key_options[@]" \
 | 
			
		||||
						"$_pacman_key_longopts[@]"
 | 
			
		||||
						"$_key_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				-*)
 | 
			
		||||
					_arguments -s : \
 | 
			
		||||
						"$_pacman_key_options[@]" \
 | 
			
		||||
						"$_pacman_key_shortopts[@]" \
 | 
			
		||||
						"$_pacman_key_longopts[@]"
 | 
			
		||||
						"$_key_shortopts[@]" \
 | 
			
		||||
						"$_key_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				*)
 | 
			
		||||
					return 1
 | 
			
		||||
@@ -664,7 +664,7 @@ _pacman_key() {
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_key_list() {
 | 
			
		||||
_keys() {
 | 
			
		||||
	local keylist keys
 | 
			
		||||
	keylist=$(pacman-key --list-keys 2>/dev/null | awk '
 | 
			
		||||
		$1 == "pub" {
 | 
			
		||||
@@ -733,7 +733,7 @@ _makepkg_longopts=(
 | 
			
		||||
	'--check[Run check() function in the PKGBUILD]'
 | 
			
		||||
	'--config[Use an alternate config file instead of '@sysconfdir@/makepkg.conf']: :_files'
 | 
			
		||||
	'--holdver[Do not update VCS sources]'
 | 
			
		||||
	'--key[Specify key to use for gpg signing instead of the default]: :_pacman_key_list'
 | 
			
		||||
	'--key[Specify key to use for gpg signing instead of the default]: :_keys'
 | 
			
		||||
	'--noarchive[Do not create package archive]'
 | 
			
		||||
	'--nocheck[Do not run the check() function in the PKGBUILD]'
 | 
			
		||||
	'--noprepare[Do not run the prepare() function in the PKGBUILD]'
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ library_provides() {
 | 
			
		||||
				continue;
 | 
			
		||||
			fi
 | 
			
		||||
 | 
			
		||||
			mapfile -t filenames < <(find "$pkgdir/$dir" -maxdepth 1 -type f | LC_ALL=C sort)
 | 
			
		||||
			mapfile -t filenames < <(find "$pkgdir/$dir" -type f | LC_ALL=C sort)
 | 
			
		||||
 | 
			
		||||
			for fn in "${filenames[@]}"; do
 | 
			
		||||
				# check we have a shared library
 | 
			
		||||
@@ -44,7 +44,7 @@ library_provides() {
 | 
			
		||||
					local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
 | 
			
		||||
 | 
			
		||||
					if [[ -z "$sofile" ]]; then
 | 
			
		||||
						# the library has no soname
 | 
			
		||||
						# the library is not versioned
 | 
			
		||||
						continue
 | 
			
		||||
					fi
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,22 +25,18 @@ LIBMAKEPKG_BUILDENV_SH=1
 | 
			
		||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 | 
			
		||||
 | 
			
		||||
declare -a buildenv_functions build_options
 | 
			
		||||
buildenv_vars=('CPPFLAGS' 'CFLAGS' 'CXXFLAGS' 'LDFLAGS' 'MAKEFLAGS' 'CHOST')
 | 
			
		||||
 | 
			
		||||
for lib in "$LIBRARY/buildenv/"*.sh; do
 | 
			
		||||
	source "$lib"
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
readonly -a buildenv_functions buildenv_vars build_options
 | 
			
		||||
readonly -a buildenv_functions build_options
 | 
			
		||||
 | 
			
		||||
prepare_buildenv() {
 | 
			
		||||
	# ensure this function runs first
 | 
			
		||||
	buildenv_buildflags
 | 
			
		||||
 | 
			
		||||
	for func in ${buildenv_functions[@]}; do
 | 
			
		||||
		$func
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
	# ensure all necessary build variables are exported
 | 
			
		||||
	export ${buildenv_vars[@]}
 | 
			
		||||
	export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,9 +26,10 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 | 
			
		||||
source "$LIBRARY/util/option.sh"
 | 
			
		||||
 | 
			
		||||
build_options+=('buildflags')
 | 
			
		||||
buildenv_functions+=('buildenv_buildflags')
 | 
			
		||||
 | 
			
		||||
buildenv_buildflags() {
 | 
			
		||||
	if check_option "buildflags" "n"; then
 | 
			
		||||
		unset ${buildenv_vars[@]}
 | 
			
		||||
		unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS LTOFLAGS RUSTFLAGS DEBUG_RUSTFLAGS
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,9 @@ buildenv_debugflags() {
 | 
			
		||||
	if check_option "debug" "y" && ! check_option "buildflags" "n"; then
 | 
			
		||||
		DEBUG_CFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
 | 
			
		||||
		DEBUG_CXXFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
 | 
			
		||||
		DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
 | 
			
		||||
		CFLAGS+=" $DEBUG_CFLAGS"
 | 
			
		||||
		CXXFLAGS+=" $DEBUG_CXXFLAGS"
 | 
			
		||||
		RUSTFLAGS+=" $DEBUG_RUSTFLAGS"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,6 @@ sources = [
 | 
			
		||||
  'debugflags.sh.in',
 | 
			
		||||
  'lto.sh.in',
 | 
			
		||||
  'makeflags.sh.in',
 | 
			
		||||
  'rust.sh.in',
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
foreach src : sources
 | 
			
		||||
 
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
#!/usr/bin/bash
 | 
			
		||||
#
 | 
			
		||||
#   rust.sh - Specify flags for building a package with rust
 | 
			
		||||
#
 | 
			
		||||
#   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/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
[[ -n "$LIBMAKEPKG_BUILDENV_RUST_SH" ]] && return
 | 
			
		||||
LIBMAKEPKG_BUILDENV_RUST_SH=1
 | 
			
		||||
 | 
			
		||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 | 
			
		||||
 | 
			
		||||
source "$LIBRARY/util/option.sh"
 | 
			
		||||
 | 
			
		||||
buildenv_var+=('RUSTFLAGS' 'DEBUG_RUSTFLAGS')
 | 
			
		||||
buildenv_functions+=('buildenv_rust')
 | 
			
		||||
 | 
			
		||||
buildenv_rust() {
 | 
			
		||||
	if check_option "debug" "y" && ! check_option "buildflags" "n"; then
 | 
			
		||||
		DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
 | 
			
		||||
		RUSTFLAGS+=" $DEBUG_RUSTFLAGS"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
@@ -54,17 +54,7 @@ generate_one_checksum() {
 | 
			
		||||
 | 
			
		||||
		case $proto in
 | 
			
		||||
			bzr|git|hg|svn)
 | 
			
		||||
				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
 | 
			
		||||
				sum="SKIP"
 | 
			
		||||
				;;
 | 
			
		||||
			*)
 | 
			
		||||
				if [[ ${netfile%%::*} != *.@(sig?(n)|asc) ]]; then
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@ 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
 | 
			
		||||
@@ -69,9 +68,9 @@ check_checksums() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
verify_integrity_one() {
 | 
			
		||||
	local source_name=$1 integ=$2 expectedsum=$3 file proto realsum
 | 
			
		||||
	local source_name=$1 integ=$2 expectedsum=$3
 | 
			
		||||
 | 
			
		||||
	file="$(get_filename "$source_name")"
 | 
			
		||||
	local file="$(get_filename "$source_name")"
 | 
			
		||||
	printf '    %s ... ' "$file" >&2
 | 
			
		||||
 | 
			
		||||
	if [[ $expectedsum = 'SKIP' ]]; then
 | 
			
		||||
@@ -79,18 +78,20 @@ verify_integrity_one() {
 | 
			
		||||
		return
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
	if ! file="$(get_filepath "$file")"; then
 | 
			
		||||
		printf '%s\n' "$(gettext "NOT FOUND")" >&2
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	if [[ ${expectedsum,,} != "$realsum" ]]; then
 | 
			
		||||
	local realsum="$("${integ}sum" "$file")"
 | 
			
		||||
	realsum="${realsum%% *}"
 | 
			
		||||
	if [[ ${expectedsum,,} = "$realsum" ]]; then
 | 
			
		||||
		printf '%s\n' "$(gettext "Passed")" >&2
 | 
			
		||||
	else
 | 
			
		||||
		printf '%s\n' "$(gettext "FAILED")" >&2
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
	printf '%s\n' "$(gettext "Passed")" >&2
 | 
			
		||||
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,10 +32,10 @@ lint_config_variables() {
 | 
			
		||||
	local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS
 | 
			
		||||
	             DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ
 | 
			
		||||
	             COMPRESSLRZ COMPRESSLZO COMPRESSZ)
 | 
			
		||||
	local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LTOFLAGS DEBUG_CFLAGS
 | 
			
		||||
	              DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED
 | 
			
		||||
	              STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY
 | 
			
		||||
	              PKGEXT SRCEXT)
 | 
			
		||||
	local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS LTOFLAGS
 | 
			
		||||
	              DEBUG_CFLAGS DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR
 | 
			
		||||
	              STRIP_BINARIES STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST
 | 
			
		||||
	              LOGDEST PACKAGER GPGKEY PKGEXT SRCEXT)
 | 
			
		||||
 | 
			
		||||
	local i keys ret=0
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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,21 +95,3 @@ 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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -109,29 +109,3 @@ 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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -151,18 +151,3 @@ 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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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 --origin=origin ${GITFLAGS:---mirror} "$url" "$dir"; then
 | 
			
		||||
		if ! git clone ${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 --origin=origin -s "$dir" "${dir##*/}"; then
 | 
			
		||||
	elif ! git clone -s "$dir" "${dir##*/}"; then
 | 
			
		||||
		error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
 | 
			
		||||
		plainerr "$(gettext "Aborting...")"
 | 
			
		||||
		exit 1
 | 
			
		||||
@@ -134,30 +134,3 @@ 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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -111,30 +111,3 @@ 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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -152,7 +152,7 @@ tidy_strip() {
 | 
			
		||||
		fi
 | 
			
		||||
 | 
			
		||||
		local binary strip_flags
 | 
			
		||||
		find . -type f -perm -u+w -print0 2>/dev/null | LC_ALL=C sort -z | while IFS= read -rd '' binary ; do
 | 
			
		||||
		find . -type f -perm -u+w -print0 2>/dev/null | 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
 | 
			
		||||
 
 | 
			
		||||
@@ -37,11 +37,6 @@ source_makepkg_config() {
 | 
			
		||||
	# Source the config file; fail if it is not found
 | 
			
		||||
	if [[ -r $MAKEPKG_CONF ]]; then
 | 
			
		||||
		source_safe "$MAKEPKG_CONF"
 | 
			
		||||
		if [[ -d "$MAKEPKG_CONF.d" ]]; then
 | 
			
		||||
			for c in "$MAKEPKG_CONF.d"/*.conf; do
 | 
			
		||||
				source_safe $c
 | 
			
		||||
			done
 | 
			
		||||
		fi
 | 
			
		||||
	else
 | 
			
		||||
		error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
 | 
			
		||||
		plainerr "$(gettext "Aborting...")"
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,7 @@ 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@'}
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +51,6 @@ 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="AcCdD:efFghiLmop:rRsSV"
 | 
			
		||||
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'dir:' 'force' 'geninteg'
 | 
			
		||||
OPT_SHORT="AcCdefFghiLmop:rRsSV"
 | 
			
		||||
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg'
 | 
			
		||||
          'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild'
 | 
			
		||||
          'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'packagelist'
 | 
			
		||||
          'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg'
 | 
			
		||||
@@ -971,7 +971,6 @@ 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 ;;
 | 
			
		||||
@@ -1018,12 +1017,6 @@ 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
 | 
			
		||||
@@ -1165,7 +1158,7 @@ if (( GENINTEG )); then
 | 
			
		||||
	mkdir -p "$srcdir"
 | 
			
		||||
	chmod a-s "$srcdir"
 | 
			
		||||
	cd_safe "$srcdir"
 | 
			
		||||
	download_sources allarch >&2
 | 
			
		||||
	download_sources novcs allarch >&2
 | 
			
		||||
	generate_checksums
 | 
			
		||||
	exit $E_OK
 | 
			
		||||
fi
 | 
			
		||||
@@ -1269,7 +1262,7 @@ if (( SOURCEONLY )); then
 | 
			
		||||
		download_sources allarch
 | 
			
		||||
	elif ( (( ! SKIPCHECKSUMS )) || \
 | 
			
		||||
			( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then
 | 
			
		||||
		download_sources allarch
 | 
			
		||||
		download_sources allarch novcs
 | 
			
		||||
	fi
 | 
			
		||||
	check_source_integrity all
 | 
			
		||||
	cd_safe "$startdir"
 | 
			
		||||
 
 | 
			
		||||
@@ -84,8 +84,6 @@ 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"
 | 
			
		||||
@@ -285,6 +283,7 @@ check_keyring() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
populate_keyring() {
 | 
			
		||||
	local KEYRING_IMPORT_DIR='@keyringdir@'
 | 
			
		||||
 | 
			
		||||
	local keyring KEYRINGIDS=("$@")
 | 
			
		||||
	local ret=0
 | 
			
		||||
@@ -379,7 +378,7 @@ populate_keyring() {
 | 
			
		||||
			key_count=$((key_count+1))
 | 
			
		||||
		done
 | 
			
		||||
		if (( key_count )); then
 | 
			
		||||
			msg2 "$(ngettext "Disabled %s key." "Disabled %s keys." "${key_count}")" "${key_count}"
 | 
			
		||||
			msg2 "$(gettext "Disabled %s keys.")" "${key_count}"
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
@@ -507,7 +506,7 @@ lsign_keys() {
 | 
			
		||||
		exit 1
 | 
			
		||||
	fi
 | 
			
		||||
	if (( key_count )); then
 | 
			
		||||
		msg2 "$(ngettext "Locally signed %s key." "Locally signed %s keys." "${key_count}")" "${key_count}"
 | 
			
		||||
		msg2 "$(gettext "Locally signed %s keys.")" "${key_count}"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -613,20 +612,10 @@ if ! type gettext &>/dev/null; then
 | 
			
		||||
	}
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if ! type ngettext &>/dev/null; then
 | 
			
		||||
	ngettext() {
 | 
			
		||||
		if (( $3 == 1 )); then
 | 
			
		||||
			echo "$1"
 | 
			
		||||
		else
 | 
			
		||||
			echo "$2"
 | 
			
		||||
		fi
 | 
			
		||||
	}
 | 
			
		||||
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' 'populate-from:' 'recv-keys' 'refresh-keys' 'updatedb'
 | 
			
		||||
          'lsign-key' 'nocolor' 'populate' 'recv-keys' 'refresh-keys' 'updatedb'
 | 
			
		||||
          'verbose' 'verify' 'version')
 | 
			
		||||
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 | 
			
		||||
	exit 1 # E_INVALID_OPTION
 | 
			
		||||
@@ -648,7 +637,6 @@ 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 ;;
 | 
			
		||||
@@ -695,8 +683,6 @@ 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)}
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -423,8 +423,6 @@ 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:
 | 
			
		||||
@@ -462,30 +460,18 @@ 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(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));
 | 
			
		||||
				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);
 | 
			
		||||
				} else {
 | 
			
		||||
					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->remove = noyes(_("%s and %s are in conflict (%s). Remove %s?"),
 | 
			
		||||
							q->conflict->package1,
 | 
			
		||||
							q->conflict->package2,
 | 
			
		||||
							q->conflict->reason->name,
 | 
			
		||||
							alpm_pkg_get_name(q->conflict->package2));
 | 
			
		||||
							q->conflict->package2);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
 
 | 
			
		||||
@@ -217,6 +217,22 @@ 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)
 | 
			
		||||
{
 | 
			
		||||
@@ -412,6 +428,7 @@ 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);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1136,22 +1136,15 @@ 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", rootdir, &DBPATH[1]);
 | 
			
		||||
			snprintf(path, PATH_MAX, "%s/%s", c->rootdir, &DBPATH[1]);
 | 
			
		||||
			SETDEFAULT(c->dbpath, strdup(path));
 | 
			
		||||
		}
 | 
			
		||||
		if(!c->logfile) {
 | 
			
		||||
			snprintf(path, PATH_MAX, "%s/%s", rootdir, &LOGFILE[1]);
 | 
			
		||||
			snprintf(path, PATH_MAX, "%s/%s", c->rootdir, &LOGFILE[1]);
 | 
			
		||||
			SETDEFAULT(c->logfile, strdup(path));
 | 
			
		||||
		}
 | 
			
		||||
		free(rootdir);
 | 
			
		||||
	} else {
 | 
			
		||||
		SETDEFAULT(c->rootdir, strdup(ROOTDIR));
 | 
			
		||||
		SETDEFAULT(c->dbpath, strdup(DBPATH));
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,7 @@ typedef struct __config_t {
 | 
			
		||||
	unsigned short color;
 | 
			
		||||
	unsigned short disable_dl_timeout;
 | 
			
		||||
	char *print_format;
 | 
			
		||||
	char *pformat;
 | 
			
		||||
	/* unfortunately, we have to keep track of paths both here and in the library
 | 
			
		||||
	 * because they can come from both the command line or config file, and we
 | 
			
		||||
	 * need to ensure we get the order of preference right. */
 | 
			
		||||
@@ -172,6 +173,7 @@ enum {
 | 
			
		||||
	OP_ASEXPLICIT,
 | 
			
		||||
	OP_ARCH,
 | 
			
		||||
	OP_PRINTFORMAT,
 | 
			
		||||
	OP_PFORMAT,
 | 
			
		||||
	OP_GPGDIR,
 | 
			
		||||
	OP_DBONLY,
 | 
			
		||||
	OP_FORCE,
 | 
			
		||||
 
 | 
			
		||||
@@ -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",
 | 
			
		||||
				alpm_pkg_get_name(conflict->package1), alpm_pkg_get_name(conflict->package2));
 | 
			
		||||
				conflict->package1, conflict->package2);
 | 
			
		||||
		ret++;
 | 
			
		||||
	}
 | 
			
		||||
	alpm_list_free_inner(data, (alpm_list_fn_free)alpm_conflict_free);
 | 
			
		||||
 
 | 
			
		||||
@@ -651,6 +651,9 @@ static int parsearg_trans(int opt)
 | 
			
		||||
			free(config->print_format);
 | 
			
		||||
			config->print_format = strdup(optarg);
 | 
			
		||||
			break;
 | 
			
		||||
		case OP_PFORMAT:
 | 
			
		||||
			config->pformat = strdup(optarg);
 | 
			
		||||
			break;
 | 
			
		||||
		case OP_ASSUMEINSTALLED:
 | 
			
		||||
			parsearg_util_addlist(&(config->assumeinstalled));
 | 
			
		||||
			break;
 | 
			
		||||
@@ -944,6 +947,7 @@ static int parseargs(int argc, char *argv[])
 | 
			
		||||
		{"asexplicit",     no_argument,   0, OP_ASEXPLICIT},
 | 
			
		||||
		{"arch",       required_argument, 0, OP_ARCH},
 | 
			
		||||
		{"print-format", required_argument, 0, OP_PRINTFORMAT},
 | 
			
		||||
		{"pformat"     , required_argument, 0, OP_PFORMAT},
 | 
			
		||||
		{"gpgdir",     required_argument, 0, OP_GPGDIR},
 | 
			
		||||
		{"dbonly",     no_argument,       0, OP_DBONLY},
 | 
			
		||||
		{"color",      required_argument, 0, OP_COLOR},
 | 
			
		||||
 
 | 
			
		||||
@@ -778,19 +778,12 @@ 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-%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));
 | 
			
		||||
						colon_printf(_("%s and %s are in conflict\n"),
 | 
			
		||||
								conflict->package1, conflict->package2);
 | 
			
		||||
					} else {
 | 
			
		||||
						char *reason = alpm_dep_compute_string(conflict->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);
 | 
			
		||||
						colon_printf(_("%s and %s are in conflict (%s)\n"),
 | 
			
		||||
								conflict->package1, conflict->package2, reason);
 | 
			
		||||
						free(reason);
 | 
			
		||||
					}
 | 
			
		||||
					alpm_conflict_free(conflict);
 | 
			
		||||
 
 | 
			
		||||
@@ -61,24 +61,13 @@ enum {
 | 
			
		||||
	CELL_FREE = (1 << 3)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define PRINT_FORMAT_STRING(temp, format, func) \
 | 
			
		||||
#define VAL_FROM_FORMAT_STR(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;
 | 
			
		||||
@@ -416,37 +405,26 @@ char *strreplace(const char *str, const char *needle, const char *replace)
 | 
			
		||||
	return newstr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef char *(*formatfn)(void*);
 | 
			
		||||
 | 
			
		||||
static char *concat_list(alpm_list_t *lst, formatfn fn)
 | 
			
		||||
static char *concat_alpm_depends(alpm_list_t *lst)
 | 
			
		||||
{
 | 
			
		||||
	char *output = NULL, *tmp = NULL;
 | 
			
		||||
 | 
			
		||||
	char *depends = NULL;
 | 
			
		||||
	char *tmp = NULL;
 | 
			
		||||
	for(alpm_list_t *i = lst; i; i = alpm_list_next(i)) {
 | 
			
		||||
		char *str = fn ? fn(i->data) : i->data;
 | 
			
		||||
 | 
			
		||||
		if(str == NULL) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		alpm_depend_t *dep = i->data;
 | 
			
		||||
		char *depstring = alpm_dep_compute_string(dep);
 | 
			
		||||
		if(tmp) {
 | 
			
		||||
			asprintf(&output, "%s %s", tmp, str);
 | 
			
		||||
			free(tmp);
 | 
			
		||||
		    asprintf(&depends, "%s %s", tmp, depstring);
 | 
			
		||||
		    free(tmp);
 | 
			
		||||
		} else {
 | 
			
		||||
			asprintf(&output, "%s", str);
 | 
			
		||||
		}
 | 
			
		||||
		tmp = output;
 | 
			
		||||
 | 
			
		||||
		if(fn) {
 | 
			
		||||
			free(str);
 | 
			
		||||
		    asprintf(&depends, "%s", depstring);
 | 
			
		||||
		}
 | 
			
		||||
		tmp = depends;
 | 
			
		||||
		free(depstring);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(!output) {
 | 
			
		||||
		asprintf(&output, "%s", "");
 | 
			
		||||
	if(!depends) {
 | 
			
		||||
		asprintf(&depends, "%s", "");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return output;
 | 
			
		||||
	return depends;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t string_length(const char *s)
 | 
			
		||||
@@ -1190,6 +1168,10 @@ double humanize_size(off_t bytes, const char target_unit, int precision,
 | 
			
		||||
void print_packages(const alpm_list_t *packages)
 | 
			
		||||
{
 | 
			
		||||
	const alpm_list_t *i;
 | 
			
		||||
	if(config->pformat) {
 | 
			
		||||
		alpm_info_print_pkgs(config->pformat, (alpm_list_t*) packages);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if(!config->print_format) {
 | 
			
		||||
		config->print_format = strdup("%l");
 | 
			
		||||
	}
 | 
			
		||||
@@ -1219,23 +1201,21 @@ void print_packages(const alpm_list_t *packages)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		/* %d : description */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%d", alpm_pkg_get_desc)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%d", alpm_pkg_get_desc)
 | 
			
		||||
		/* %e : pkgbase */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%e", alpm_pkg_get_base)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%e", alpm_pkg_get_base)
 | 
			
		||||
		/* %f : filename */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%f", alpm_pkg_get_filename)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%f", alpm_pkg_get_filename)
 | 
			
		||||
		/* %g : base64 encoded PGP signature */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%g", alpm_pkg_get_base64_sig)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%g", alpm_pkg_get_base64_sig)
 | 
			
		||||
		/* %h : sha25sum */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%h", alpm_pkg_get_sha256sum)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%h", alpm_pkg_get_sha256sum)
 | 
			
		||||
		/* %n : pkgname */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%n", alpm_pkg_get_name)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%n", alpm_pkg_get_name)
 | 
			
		||||
		/* %p : packager */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%p", alpm_pkg_get_packager)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%p", alpm_pkg_get_packager)
 | 
			
		||||
		/* %v : pkgver */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%v", alpm_pkg_get_version)
 | 
			
		||||
		/* %m : md5sum */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%m", alpm_pkg_get_md5sum)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%v", alpm_pkg_get_version)
 | 
			
		||||
		/* %l : location */
 | 
			
		||||
		if(strstr(temp, "%l")) {
 | 
			
		||||
			char *pkgloc = pkg_get_location(pkg);
 | 
			
		||||
@@ -1264,26 +1244,34 @@ void print_packages(const alpm_list_t *packages)
 | 
			
		||||
			free(temp);
 | 
			
		||||
		}
 | 
			
		||||
		/* %u : url */
 | 
			
		||||
		PRINT_FORMAT_STRING(temp, "%u", alpm_pkg_get_url)
 | 
			
		||||
		VAL_FROM_FORMAT_STR(temp, "%u", alpm_pkg_get_url)
 | 
			
		||||
		/* %C : checkdepends */
 | 
			
		||||
		PRINT_FORMAT_LIST(temp, "%C", alpm_pkg_get_checkdepends, alpm_dep_compute_string)
 | 
			
		||||
		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;
 | 
			
		||||
		}
 | 
			
		||||
		/* %D : depends */
 | 
			
		||||
		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)
 | 
			
		||||
		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;
 | 
			
		||||
		}
 | 
			
		||||
		/* %M : makedepends */
 | 
			
		||||
		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)
 | 
			
		||||
 | 
			
		||||
		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;
 | 
			
		||||
		}
 | 
			
		||||
		printf("%s\n", string);
 | 
			
		||||
		free(string);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ Use the "help" option to get the full list of parameters:
 | 
			
		||||
When run with the `--valgrind' option, an additional rule will be added to all
 | 
			
		||||
tests to check for memory leaks.  To use `--valgrind' when running the full
 | 
			
		||||
test suite, run:
 | 
			
		||||
    PACTEST_VALGRIND=1 ninja test
 | 
			
		||||
    make PY_LOG_FLAGS=--valgrind check
 | 
			
		||||
 | 
			
		||||
The following pieces of software are required to run the pactest suite:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -240,20 +240,18 @@ class pmtest(object):
 | 
			
		||||
 | 
			
		||||
        cmd = []
 | 
			
		||||
        if os.geteuid() != 0:
 | 
			
		||||
            # 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")
 | 
			
		||||
 | 
			
		||||
            fakechroot = util.which("fakechroot")
 | 
			
		||||
            if not fakechroot:
 | 
			
		||||
                tap.diag("WARNING: fakechroot not found!")
 | 
			
		||||
            else:
 | 
			
		||||
                cmd.append("fakechroot")
 | 
			
		||||
 | 
			
		||||
        if pacman["gdb"]:
 | 
			
		||||
            cmd.extend(["libtool", "execute", "gdb", "--args"])
 | 
			
		||||
        if pacman["valgrind"]:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user