Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am11
-rw-r--r--NEWS3
-rw-r--r--README15
-rw-r--r--contrib/PKGBUILD.vim2
-rw-r--r--contrib/README2
-rw-r--r--contrib/bacman.sh.in4
-rw-r--r--contrib/checkupdates.sh.in10
-rw-r--r--contrib/pacdiff.sh.in8
-rw-r--r--contrib/pacscripts.sh.in2
-rw-r--r--doc/PKGBUILD.5.txt3
-rw-r--r--doc/index.txt2
-rw-r--r--doc/makepkg.conf.5.txt10
-rw-r--r--doc/pacman.8.txt34
-rw-r--r--etc/makepkg.conf.in5
-rw-r--r--lib/libalpm/add.c421
-rw-r--r--lib/libalpm/add.h2
-rw-r--r--lib/libalpm/alpm.c2
-rw-r--r--lib/libalpm/alpm.h26
-rw-r--r--lib/libalpm/alpm_list.c2
-rw-r--r--lib/libalpm/alpm_list.h2
-rw-r--r--lib/libalpm/backup.c9
-rw-r--r--lib/libalpm/backup.h2
-rw-r--r--lib/libalpm/be_local.c21
-rw-r--r--lib/libalpm/be_package.c7
-rw-r--r--lib/libalpm/be_sync.c6
-rw-r--r--lib/libalpm/conflict.c23
-rw-r--r--lib/libalpm/conflict.h2
-rw-r--r--lib/libalpm/db.c13
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/delta.c26
-rw-r--r--lib/libalpm/delta.h2
-rw-r--r--lib/libalpm/deps.c38
-rw-r--r--lib/libalpm/deps.h2
-rw-r--r--lib/libalpm/diskspace.c8
-rw-r--r--lib/libalpm/diskspace.h2
-rw-r--r--lib/libalpm/dload.c4
-rw-r--r--lib/libalpm/dload.h2
-rw-r--r--lib/libalpm/error.c2
-rw-r--r--lib/libalpm/filelist.c2
-rw-r--r--lib/libalpm/filelist.h2
-rw-r--r--lib/libalpm/graph.c2
-rw-r--r--lib/libalpm/graph.h2
-rw-r--r--lib/libalpm/group.c2
-rw-r--r--lib/libalpm/group.h2
-rw-r--r--lib/libalpm/handle.c2
-rw-r--r--lib/libalpm/handle.h2
-rw-r--r--lib/libalpm/libarchive-compat.h2
-rw-r--r--lib/libalpm/log.c2
-rw-r--r--lib/libalpm/log.h2
-rw-r--r--lib/libalpm/package.c13
-rw-r--r--lib/libalpm/package.h4
-rw-r--r--lib/libalpm/pkghash.c2
-rw-r--r--lib/libalpm/pkghash.h2
-rw-r--r--lib/libalpm/remove.c2
-rw-r--r--lib/libalpm/remove.h2
-rw-r--r--lib/libalpm/signing.c2
-rw-r--r--lib/libalpm/signing.h2
-rw-r--r--lib/libalpm/sync.c8
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c4
-rw-r--r--lib/libalpm/trans.h2
-rw-r--r--lib/libalpm/util.c6
-rw-r--r--lib/libalpm/util.h2
-rw-r--r--lib/libalpm/version.c2
-rw-r--r--scripts/Makefile.am61
-rw-r--r--scripts/libmakepkg/.gitignore13
-rw-r--r--scripts/libmakepkg/tidy.sh.in60
-rw-r--r--scripts/libmakepkg/tidy/build_references.sh.in36
-rw-r--r--scripts/libmakepkg/tidy/docs.sh.in35
-rw-r--r--scripts/libmakepkg/tidy/emptydirs.sh.in35
-rw-r--r--scripts/libmakepkg/tidy/libtool.sh.in35
-rw-r--r--scripts/libmakepkg/tidy/missing_backup.sh.in36
-rw-r--r--scripts/libmakepkg/tidy/optipng.sh.in41
-rw-r--r--scripts/libmakepkg/tidy/purge.sh.in42
-rw-r--r--scripts/libmakepkg/tidy/staticlibs.sh.in40
-rw-r--r--scripts/libmakepkg/tidy/strip.sh.in64
-rw-r--r--scripts/libmakepkg/tidy/upx.sh.in41
-rw-r--r--scripts/libmakepkg/tidy/zipman.sh.in58
-rw-r--r--scripts/libmakepkg/util.sh.in28
-rw-r--r--scripts/libmakepkg/util/message.sh49
-rw-r--r--scripts/libmakepkg/util/option.sh108
-rwxr-xr-xscripts/makepkg-template.pl.in8
-rw-r--r--scripts/makepkg-wrapper.sh.in2
-rw-r--r--scripts/makepkg.sh.in277
-rw-r--r--scripts/pacman-db-upgrade.sh.in4
-rw-r--r--scripts/pacman-key.sh.in4
-rw-r--r--scripts/pacman-optimize.sh.in4
-rw-r--r--scripts/pkgdelta.sh.in2
-rw-r--r--scripts/po/POTFILES.in12
-rw-r--r--scripts/repo-add.sh.in4
-rw-r--r--src/common/util-common.c2
-rw-r--r--src/common/util-common.h2
-rw-r--r--src/pacman/callback.c22
-rw-r--r--src/pacman/callback.h2
-rw-r--r--src/pacman/check.c2
-rw-r--r--src/pacman/check.h2
-rw-r--r--src/pacman/conf.c309
-rw-r--r--src/pacman/conf.h18
-rw-r--r--src/pacman/database.c220
-rw-r--r--src/pacman/deptest.c2
-rw-r--r--src/pacman/ini.c149
-rw-r--r--src/pacman/ini.h2
-rw-r--r--src/pacman/package.c2
-rw-r--r--src/pacman/package.h2
-rw-r--r--src/pacman/pacman.c27
-rw-r--r--src/pacman/pacman.h2
-rw-r--r--src/pacman/query.c2
-rw-r--r--src/pacman/remove.c2
-rw-r--r--src/pacman/sync.c2
-rw-r--r--src/pacman/upgrade.c2
-rw-r--r--src/pacman/util.c5
-rw-r--r--src/pacman/util.h2
-rw-r--r--src/util/.gitignore2
-rw-r--r--src/util/Makefile.am5
-rw-r--r--src/util/cleanupdelta.c2
-rw-r--r--src/util/pacsort.c3
-rw-r--r--src/util/pactree.c2
-rw-r--r--src/util/testdb.c297
-rw-r--r--src/util/testpkg.c2
-rw-r--r--src/util/vercmp.c2
-rw-r--r--test/pacman/README1
-rwxr-xr-xtest/pacman/pactest.py2
-rw-r--r--test/pacman/pmdb.py2
-rw-r--r--test/pacman/pmenv.py2
-rw-r--r--test/pacman/pmfile.py2
-rw-r--r--test/pacman/pmpkg.py2
-rw-r--r--test/pacman/pmrule.py5
-rw-r--r--test/pacman/pmtest.py2
-rw-r--r--test/pacman/tap.py2
-rw-r--r--test/pacman/tests/upgrade015.py1
-rw-r--r--test/pacman/tests/upgrade016.py5
-rw-r--r--test/pacman/tests/upgrade027.py1
-rw-r--r--test/pacman/tests/upgrade028.py1
-rw-r--r--test/pacman/tests/upgrade029.py1
-rw-r--r--test/pacman/util.py2
-rw-r--r--test/scripts/Makefile.am1
-rwxr-xr-xtest/scripts/human_to_size_test.sh73
-rw-r--r--test/scripts/makepkg-template-tests/invalid-key/PKGBUILD1
-rw-r--r--test/scripts/makepkg-template-tests/invalid-key/testcase-config11
-rw-r--r--test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD1
-rw-r--r--test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config11
-rw-r--r--test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD9
-rw-r--r--test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config11
-rw-r--r--test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD15
-rw-r--r--test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template1
-rw-r--r--test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template6
-rw-r--r--test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template7
-rw-r--r--test/scripts/makepkg-template-tests/keep-old-version/testcase-config29
-rw-r--r--test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD7
-rw-r--r--test/scripts/makepkg-template-tests/missing-template-file/testcase-config14
-rw-r--r--test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD7
-rw-r--r--test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template1
-rw-r--r--test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config9
-rw-r--r--test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD8
-rw-r--r--test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config10
-rw-r--r--test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD8
-rw-r--r--test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template1
-rw-r--r--test/scripts/makepkg-template-tests/name-charset-valid/testcase-config19
-rw-r--r--test/scripts/makepkg-template-tests/template-without-version/PKGBUILD8
-rw-r--r--test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template0
-rw-r--r--test/scripts/makepkg-template-tests/template-without-version/testcase-config9
-rw-r--r--test/scripts/makepkg-template-tests/testcase-config-template9
-rw-r--r--test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD7
-rw-r--r--test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template1
-rw-r--r--test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template6
-rw-r--r--test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template7
-rw-r--r--test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config29
-rwxr-xr-xtest/scripts/makepkg-template_test.sh67
-rwxr-xr-xtest/scripts/parseopts_test.sh102
-rw-r--r--test/tap.sh163
-rwxr-xr-xtest/util/pacsorttest.sh92
-rwxr-xr-xtest/util/vercmptest.sh153
172 files changed, 2386 insertions, 1566 deletions
diff --git a/Makefile.am b/Makefile.am
index 4f807f9a..3f10d156 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version
# Some files automatically included, so they aren't specified below:
# AUTHORS, COPYING, NEWS, README
-EXTRA_DIST = HACKING
+EXTRA_DIST = HACKING test/tap.sh
# Sample makepkg prototype files
pkgdatadir = ${datadir}/${PACKAGE}
@@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py)
TESTS = test/scripts/parseopts_test.sh \
test/scripts/human_to_size_test.sh \
+ test/scripts/makepkg-template_test.sh \
test/scripts/pacman-db-upgrade-v9.py \
test/util/pacsorttest.sh \
test/util/vercmptest.sh
@@ -37,6 +38,7 @@ TEST_SUITE_LOG = test/test-suite.log
TEST_EXTENSIONS = .py
AM_TESTS_ENVIRONMENT = \
PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \
+ PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_DIR; \
PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR;
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
@@ -60,6 +62,11 @@ update-po:
$(MAKE) -C scripts/po update-po
$(MAKE) -C src/pacman/po update-po
-.PHONY: update-po
+update-copyright:
+ for file in $(shell sh -c 'git grep -l "Copyright .* Pacman Development" | grep -v "\.po"'); do \
+ sed -i -e "/Copyright (/s/-$(OLD)/-$(NEW)/" -e "/Copyright (/s/ $(OLD)/ $(OLD)-$(NEW)/" "$$file"; \
+ done
+
+.PHONY: update-po update-copyright
# vim:set noet:
diff --git a/NEWS b/NEWS
index f4e6bf30..483badc1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
+5.0.0 - pacman can check the validity of the local and sync databases
+ (-Dk and -Dkk respectively). This replaces the 'testdb'
+ software
4.2.0 - symlinks to directories on the filesystem are no longer
treated as directories
- pacman-db-upgrade - fix local database for files installed
diff --git a/README b/README
index eddd3416..8c17d335 100644
--- a/README
+++ b/README
@@ -560,3 +560,18 @@ API CHANGES BETWEEN 4.1 AND 4.2
- ALPM_EVENT_RETRIEVE_DONE, ALPM_EVENT_RETRIEVE_FAILED, ALPM_EVENT_PKGDOWNLOAD_START,
ALPM_EVENT_PKGDOWNLOAD_DONE, ALPM_EVENT_PKGDOWNLOAD_FAILED, ALPM_EVENT_OPTDEP_REMOVAL,
ALPM_EVENT_PACNEW_CREATED, ALPM_EVENT_PACSVAE_CREATED, ALPM_EVENT_PACORIG_CREATED
+
+
+API CHANGES BETWEEN 4.2 AND 5.0
+===============================
+
+[REMOVED]
+- alpm_siglevel_t - removed members ALPM_SIG_PACKAGE_SET, ALPM_SIG_PACKAGE_TRUST_SET
+
+- ALPM_EVENT_PACORIG_CREATED
+- alpm_event_pacorig_created_t
+- alpm_event_t.pacorig_created
+
+[ADDED]
+- pkgbase accessor
+ - alpm_pkg_get_base()
diff --git a/contrib/PKGBUILD.vim b/contrib/PKGBUILD.vim
index cf264f93..35ca6bd9 100644
--- a/contrib/PKGBUILD.vim
+++ b/contrib/PKGBUILD.vim
@@ -211,7 +211,7 @@ hi def link pbValidSha512sums Number
" options
syn keyword pb_k_options options contained
-syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
+syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|optipng\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
syn match pbOptionsNeg /\!/ contained
syn match pbOptionsDeprec /no/ contained
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
diff --git a/contrib/README b/contrib/README
index bcb4b853..befd3c1d 100644
--- a/contrib/README
+++ b/contrib/README
@@ -16,7 +16,7 @@ sync databases (for safety on rolling release distributions).
paccache - a flexible package cache cleaning utility that allows greater
control over which packages are removed.
-pacdiff - a simple pacnew/pacorig/pacsave updater for /etc/.
+pacdiff - a simple pacnew/pacsave updater for /etc/.
paclist - list all packages installed from a given repository. Useful for
seeing which packages you may have installed from the testing repository,
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 14919422..fcee6a0d 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -5,7 +5,7 @@
# stored into the pacman database and system files
#
# Copyright (c) 2008 locci <carlocci_at_gmail_dot_com>
-# Copyright (c) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@ usage() {
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
- echo 'Copyright (C) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>'
+ echo 'Copyright (C) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>'
}
while [[ ! -z $1 ]]; do
diff --git a/contrib/checkupdates.sh.in b/contrib/checkupdates.sh.in
index f4f36c09..e8a81986 100644
--- a/contrib/checkupdates.sh.in
+++ b/contrib/checkupdates.sh.in
@@ -21,6 +21,9 @@
declare -r myname='checkupdates'
declare -r myver='@PACKAGE_VERSION@'
+m4_include(../scripts/library/output_format.sh)
+m4_include(../scripts/library/term_colors.sh)
+
if (( $# > 0 )); then
echo "${myname} (pacman) v${myver}"
echo
@@ -32,6 +35,11 @@ if (( $# > 0 )); then
exit 0
fi
+if ! type -P fakeroot >/dev/null; then
+ error 'Cannot find the fakeroot binary.'
+ exit 1
+fi
+
if [[ -z $CHECKUPDATES_DB ]]; then
CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/"
fi
@@ -44,7 +52,7 @@ eval $(awk -F' *= *' '$1 ~ /DBPath/ { print $1 "=" $2 }' @sysconfdir@/pacman.con
mkdir -p "$CHECKUPDATES_DB"
ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
fakeroot pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null
-pacman -Qqu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
+pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
exit 0
diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
index ecb6ae29..90eb3cc2 100644
--- a/contrib/pacdiff.sh.in
+++ b/contrib/pacdiff.sh.in
@@ -1,8 +1,8 @@
#!/bin/bash
-# pacdiff : a simple pacnew/pacorig/pacsave updater
+# pacdiff : a simple pacnew/pacsave updater
#
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@ usage() {
cat <<EOF
${myname} (pacman) v${myver}
-A simple program to merge or remove pacnew/pacorig/pacsave files.
+A simple program to merge or remove pacnew/pacsave files.
Usage: $myname [-l | -f | -p] [--nocolor]
@@ -62,7 +62,7 @@ EOF
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
- echo 'Copyright (C) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>'
+ echo 'Copyright (C) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>'
}
print_existing() {
diff --git a/contrib/pacscripts.sh.in b/contrib/pacscripts.sh.in
index f1bf8227..931d3610 100644
--- a/contrib/pacscripts.sh.in
+++ b/contrib/pacscripts.sh.in
@@ -5,7 +5,7 @@
#
# Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>
# Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>
-# Copyright (c) 2009-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2009-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index c95c41d8..10980aba 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -296,6 +296,9 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
*upx*;;
Compress binary executable files using UPX.
+ *optipng*;;
+ Optimize PNG images with optipng.
+
*ccache*;;
Allow the use of ccache during build. More useful in its negative
form `!ccache` with select packages that have problems building
diff --git a/doc/index.txt b/doc/index.txt
index ab1dc793..03a62f7a 100644
--- a/doc/index.txt
+++ b/doc/index.txt
@@ -247,7 +247,7 @@ bugs under the Pacman project.
Copyright
---------
-pacman is Copyright (C) 2006-2014 Pacman Development Team
+pacman is Copyright (C) 2006-2015 Pacman Development Team
<pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet
<jvinet@zeroflux.org> and is licensed through the GNU General Public License,
version 2 or later.
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index 5bd3a4a8..ac5791fd 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -140,7 +140,7 @@ Options
Specify a key to use for GPG signing instead of the default key in the
keyring. Can be overridden with makepkg's '\--key' option.
-**OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx**)**::
+**OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx !optipng**)**::
This array contains options that affect default packaging. They are
equivalent to options that can be placed in the PKGBUILD; the defaults are
shown here. All options should always be left in the array; to enable or
@@ -178,8 +178,12 @@ Options
package.
*upx*;;
- Compress binary executable files using UPX. Additional options
- can be passed to UPX by specifying the `UPXFLAGS` variable.
+ Compress binary executable files using UPX. Additional options
+ can be passed to UPX by specifying the `UPXFLAGS` array variable.
+
+ *optipng*;;
+ Optimize PNG images with optipng. Additional options can be passed
+ to optipng by specifying the `OPTIPNGFLAGS` array variable.
*debug*;;
Add the user-specified debug flags as specified in DEBUG_CFLAGS and
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index 74436155..5c57450b 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -35,10 +35,10 @@ as an argument, targets will be read from stdin.
Operations
----------
*-D, \--database*::
- Modify the package database. This operation allows you to modify certain
- attributes of the installed packages in pacman's database. At the
- moment, you can only change the install reason using '\--asdeps' and
- '\--asexplicit' options.
+ Operate on the package database. This operation allows you to modify
+ certain attributes of the installed packages in pacman's database. It
+ also allows you to check the databases for internal consistency.
+ See <<DO,Database Options>> below.
*-Q, \--query*::
Query the package database. This operation allows you to view installed
@@ -431,6 +431,27 @@ system upgrade and install/upgrade the "foo" package in the same operation.
to-date.
+Database Options[[QO]]
+----------------------
+*\--asdeps* <package>::
+ Mark a package as non-explicitly installed; in other words, set their install
+ reason to be installed as a dependency.
+
+*\--asexplicit<package>*::
+ Mark a package as explicitly installed; in other words, set their install
+ reason to be explicitly installed. This is useful it you want to keep a
+ package installed even when it was initially installed as a dependency
+ of another package.
+
+*-k \--check*::
+ Check the local package database is internally consistent. This will
+ check all required files are present and that installed packages have
+ the required dependencies, do not conflict and that multiple packages
+ do not own the same file. Specifying this option twice will perform
+ a check on the sync databases to ensure all specified dependencies
+ are available.
+
+
Handling Config Files[[HCF]]
----------------------------
Pacman uses the same logic as 'rpm' to determine action against files that are
@@ -463,8 +484,9 @@ original=X, current=Y, new=Z::
original=NULL, current=Y, new=Z::
The package was not previously installed, and the file already exists on the
- file system. Save the current file with a '.pacorig' extension, install the
- new file, and warn the user.
+ file system. Install the new file with a '.pacnew' extension and warn the
+ user. The user must then manually merge any necessary changes into the
+ original file.
Examples
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 19f673d1..71ec624b 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -71,7 +71,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings
#########################################################################
#
-# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
+# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -82,9 +82,10 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS
#-- upx: Compress binary executable files using UPX
+#-- optipng: Optimize PNG images with optipng
#-- debug: Add debugging flags as specified in DEBUG_* variables
#
-OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
+OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 5e2d0a15..ed29e680 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -1,7 +1,7 @@
/*
* add.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -107,7 +107,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
}
static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
- struct archive_entry *entry, const char *filename, const char *origname)
+ struct archive_entry *entry, const char *filename)
{
int ret;
const int archive_flags = ARCHIVE_EXTRACT_OWNER |
@@ -120,13 +120,13 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
if(ret == ARCHIVE_WARN && archive_errno(archive) != ENOSPC) {
/* operation succeeded but a "non-critical" error was encountered */
_alpm_log(handle, ALPM_LOG_WARNING, _("warning given when extracting %s (%s)\n"),
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
} else if(ret != ARCHIVE_OK) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not extract %s (%s)\n"),
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: could not extract %s (%s)\n",
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
return 1;
}
return 0;
@@ -144,49 +144,59 @@ static int try_rename(alpm_handle_t *handle, const char *src, const char *dest)
return 0;
}
+static int extract_db_file(alpm_handle_t *handle, struct archive *archive,
+ struct archive_entry *entry, alpm_pkg_t *newpkg, const char *entryname)
+{
+ char filename[PATH_MAX]; /* the actual file we're extracting */
+ const char *dbfile;
+ if(strcmp(entryname, ".INSTALL") == 0) {
+ dbfile = "install";
+ } else if(strcmp(entryname, ".CHANGELOG") == 0) {
+ dbfile = "changelog";
+ } else if(strcmp(entryname, ".MTREE") == 0) {
+ dbfile = "mtree";
+ } else if(*entryname == '.') {
+ /* reserve all files starting with '.' for future possibilities */
+ _alpm_log(handle, ALPM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
+ archive_read_data_skip(archive);
+ return 0;
+ }
+ archive_entry_set_perm(entry, 0644);
+ snprintf(filename, PATH_MAX, "%s%s-%s/%s",
+ _alpm_db_path(handle->db_local), newpkg->name, newpkg->version, dbfile);
+ return perform_extraction(handle, archive, entry, filename);
+}
+
static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg)
{
- const char *entryname;
- mode_t entrymode;
+ const char *entryname = archive_entry_pathname(entry);
+ mode_t entrymode = archive_entry_mode(entry);
+ alpm_backup_t *backup = _alpm_needbackup(entryname, newpkg);
char filename[PATH_MAX]; /* the actual file we're extracting */
int needbackup = 0, notouch = 0;
const char *hash_orig = NULL;
- char *entryname_orig = NULL;
int errors = 0;
+ struct stat lsbuf;
+ size_t filename_len;
- entryname = archive_entry_pathname(entry);
- entrymode = archive_entry_mode(entry);
+ if(*entryname == '.') {
+ return extract_db_file(handle, archive, entry, newpkg, entryname);
+ }
- if(strcmp(entryname, ".INSTALL") == 0) {
- /* the install script goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/install",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(strcmp(entryname, ".CHANGELOG") == 0) {
- /* the changelog goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(strcmp(entryname, ".MTREE") == 0) {
- /* the mtree file goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/mtree",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(*entryname == '.') {
- /* for now, ignore all files starting with '.' that haven't
- * already been handled (for future possibilities) */
- _alpm_log(handle, ALPM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
- archive_read_data_skip(archive);
+ if (!alpm_filelist_contains(&newpkg->files, entryname)) {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("file not found in file list for package %s. skipping extraction of %s\n"),
+ newpkg->name, entryname);
return 0;
- } else {
- if (!alpm_filelist_contains(&newpkg->files, entryname)) {
- _alpm_log(handle, ALPM_LOG_WARNING, _("file not found in file list for package %s. skipping extraction of %s\n"),
- newpkg->name, entryname);
- return 0;
- }
- /* build the new entryname relative to handle->root */
- snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
+ }
+
+ /* build the new entryname relative to handle->root */
+ filename_len = snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
+ if(filename_len >= PATH_MAX) {
+ _alpm_log(handle, ALPM_LOG_ERROR,
+ _("unable to extract %s%s: path too long"), handle->root, entryname);
+ return 1;
}
/* if a file is in NoExtract then we never extract it */
@@ -214,123 +224,124 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* 6- skip extraction, dir already exists.
*/
- struct stat lsbuf;
if(llstat(filename, &lsbuf) != 0) {
/* cases 1,2: file doesn't exist, skip all backup checks */
- } else {
- if(S_ISDIR(lsbuf.st_mode)) {
- if(S_ISDIR(entrymode)) {
+ } else if(S_ISDIR(lsbuf.st_mode) && S_ISDIR(entrymode)) {
#if 0
- uid_t entryuid = archive_entry_uid(entry);
- gid_t entrygid = archive_entry_gid(entry);
+ uid_t entryuid = archive_entry_uid(entry);
+ gid_t entrygid = archive_entry_gid(entry);
#endif
- /* case 6: existing dir, ignore it */
- if(lsbuf.st_mode != entrymode) {
- /* if filesystem perms are different than pkg perms, warn user */
- mode_t mask = 07777;
- _alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
- "filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
- entrymode & mask);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: directory permissions differ on %s\n"
- "filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
- entrymode & mask);
- }
+ /* case 6: existing dir, ignore it */
+ if(lsbuf.st_mode != entrymode) {
+ /* if filesystem perms are different than pkg perms, warn user */
+ mode_t mask = 07777;
+ _alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
+ "filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
+ entrymode & mask);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: directory permissions differ on %s\n"
+ "filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
+ entrymode & mask);
+ }
#if 0
- /* Disable this warning until our user management in packages has improved.
- Currently many packages have to create users in post_install and chown the
- directories. These all resulted in "false-positive" warnings. */
-
- if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
- _alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
- "filesystem: %u:%u package: %u:%u\n"), filename,
- lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: directory ownership differs on %s\n"
- "filesystem: %u:%u package: %u:%u\n", filename,
- lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
- }
+ /* Disable this warning until our user management in packages has improved.
+ Currently many packages have to create users in post_install and chown the
+ directories. These all resulted in "false-positive" warnings. */
+
+ if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
+ _alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
+ "filesystem: %u:%u package: %u:%u\n"), filename,
+ lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: directory ownership differs on %s\n"
+ "filesystem: %u:%u package: %u:%u\n", filename,
+ lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
+ }
#endif
- _alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
- filename);
- archive_read_data_skip(archive);
- return 0;
- } else {
- /* case 5: trying to overwrite dir with file, don't allow it */
- _alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
- filename);
- archive_read_data_skip(archive);
- return 1;
- }
- } else if(S_ISDIR(entrymode)) {
- /* case 4: trying to overwrite file with dir */
- _alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
- filename);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
+ filename);
+ archive_read_data_skip(archive);
+ return 0;
+ } else if(S_ISDIR(lsbuf.st_mode)) {
+ /* case 5: trying to overwrite dir with file, don't allow it */
+ _alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
+ filename);
+ archive_read_data_skip(archive);
+ return 1;
+ } else if(S_ISDIR(entrymode)) {
+ /* case 4: trying to overwrite file with dir */
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
+ filename);
+ } else {
+ /* case 3: trying to overwrite file with file */
+ /* if file is in NoUpgrade, don't touch it */
+ if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
+ notouch = 1;
} else {
- /* case 3: */
- /* if file is in NoUpgrade, don't touch it */
- if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
- notouch = 1;
- } else {
- alpm_backup_t *backup;
- /* go to the backup array and see if our conflict is there */
- /* check newpkg first, so that adding backup files is retroactive */
- backup = _alpm_needbackup(entryname, newpkg);
- if(backup) {
- needbackup = 1;
- }
-
- /* check oldpkg for a backup entry, store the hash if available */
- if(oldpkg) {
- backup = _alpm_needbackup(entryname, oldpkg);
- if(backup) {
- hash_orig = backup->hash;
- needbackup = 1;
- }
- }
+ alpm_backup_t *oldbackup;
+ if(oldpkg && (oldbackup = _alpm_needbackup(entryname, oldpkg))) {
+ hash_orig = oldbackup->hash;
+ needbackup = 1;
+ } else if(backup) {
+ /* allow adding backup files retroactively */
+ needbackup = 1;
}
}
}
- /* we need access to the original entryname later after calls to
- * archive_entry_set_pathname(), so we need to dupe it and free() later */
- STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ if(notouch || needbackup) {
+ if(filename_len + strlen(".pacnew") >= PATH_MAX) {
+ _alpm_log(handle, ALPM_LOG_ERROR,
+ _("unable to extract %s.pacnew: path too long"), filename);
+ return 1;
+ }
+ strcpy(filename + filename_len, ".pacnew");
+ }
- if(needbackup) {
- char *checkfile;
- char *hash_local = NULL, *hash_pkg = NULL;
- size_t len;
+ if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
+ /* if FORCE was used, unlink() each file (whether it's there
+ * or not) before extracting. This prevents the old "Text file busy"
+ * error that crops up if forcing a glibc or pacman upgrade. */
+ unlink(filename);
+ }
+
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
+ if(perform_extraction(handle, archive, entry, filename)) {
+ errors++;
+ return errors;
+ }
- len = strlen(filename) + 10;
- MALLOC(checkfile, len,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(checkfile, len, "%s.paccheck", filename);
+ if(backup) {
+ FREE(backup->hash);
+ backup->hash = alpm_compute_md5sum(filename);
+ }
- if(perform_extraction(handle, archive, entry, checkfile, entryname_orig)) {
- errors++;
- goto needbackup_cleanup;
- }
+ if(notouch) {
+ alpm_event_pacnew_created_t event = {
+ .type = ALPM_EVENT_PACNEW_CREATED,
+ .from_noupgrade = 1,
+ .oldpkg = oldpkg,
+ .newpkg = newpkg,
+ .file = filename
+ };
+ /* "remove" the .pacnew suffix */
+ filename[filename_len] = '\0';
+ EVENT(handle, &event);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: %s installed as %s.pacnew\n", filename, filename);
+ } else if(needbackup) {
+ char *hash_local = NULL, *hash_pkg = NULL;
+ char origfile[PATH_MAX] = "";
- hash_local = alpm_compute_md5sum(filename);
- hash_pkg = alpm_compute_md5sum(checkfile);
+ strncat(origfile, filename, filename_len);
- /* update the md5 hash in newpkg's backup (it will be the new original) */
- alpm_list_t *i;
- for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
- alpm_backup_t *backup = i->data;
- char *newhash;
- if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
- continue;
- }
- STRDUP(newhash, hash_pkg, errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- FREE(backup->hash);
- backup->hash = newhash;
- }
+ hash_local = alpm_compute_md5sum(origfile);
+ hash_pkg = backup ? backup->hash : alpm_compute_md5sum(filename);
- _alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", origfile);
_alpm_log(handle, ALPM_LOG_DEBUG, "current: %s\n", hash_local);
_alpm_log(handle, ALPM_LOG_DEBUG, "new: %s\n", hash_pkg);
_alpm_log(handle, ALPM_LOG_DEBUG, "original: %s\n", hash_orig);
@@ -339,8 +350,8 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
/* local and new files are the same, updating anyway to get
* correct timestamps */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
- entryname_orig);
- if(try_rename(handle, checkfile, filename)) {
+ origfile);
+ if(try_rename(handle, filename, origfile)) {
errors++;
}
} else if(hash_orig && hash_pkg && strcmp(hash_orig, hash_pkg) == 0) {
@@ -348,146 +359,38 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* including any user changes */
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: leaving existing file in place\n");
- unlink(checkfile);
+ unlink(filename);
} else if(hash_orig && hash_local && strcmp(hash_orig, hash_local) == 0) {
/* installed file has NOT been changed by user,
* update to the new version */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
- entryname_orig);
- if(try_rename(handle, checkfile, filename)) {
+ origfile);
+ if(try_rename(handle, filename, origfile)) {
errors++;
}
} else {
- /* none of the three files matched another, unpack the new file alongside
- * the local file */
-
- if(oldpkg) {
- char *newpath;
- size_t newlen = strlen(filename) + strlen(".pacnew") + 1;
-
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "action: keeping current file and installing"
- " new one with .pacnew ending\n");
-
- MALLOC(newpath, newlen,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(newpath, newlen, "%s.pacnew", filename);
-
- if(try_rename(handle, checkfile, newpath)) {
- errors++;
- } else {
- alpm_event_pacnew_created_t event = {
- .type = ALPM_EVENT_PACNEW_CREATED,
- .from_noupgrade = 0,
- .oldpkg = oldpkg,
- .newpkg = newpkg,
- .file = filename
- };
- EVENT(handle, &event);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s installed as %s\n", filename, newpath);
- }
-
- free(newpath);
- } else {
- char *newpath;
- size_t newlen = strlen(filename) + strlen(".pacorig") + 1;
-
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "action: saving existing file with a .pacorig ending"
- " and installing a new one\n");
-
- MALLOC(newpath, newlen,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(newpath, newlen, "%s.pacorig", filename);
-
- /* move the existing file to the "pacorig" */
- if(try_rename(handle, filename, newpath)) {
- errors++; /* failed rename filename -> filename.pacorig */
- errors++; /* failed rename checkfile -> filename */
- } else {
- /* rename the file we extracted to the real name */
- if(try_rename(handle, checkfile, filename)) {
- errors++;
- } else {
- alpm_event_pacorig_created_t event = {
- .type = ALPM_EVENT_PACORIG_CREATED,
- .newpkg = newpkg,
- .file = filename
- };
- EVENT(handle, &event);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s saved as %s\n", filename, newpath);
- }
- }
-
- free(newpath);
- }
- }
-
-needbackup_cleanup:
- free(checkfile);
- free(hash_local);
- free(hash_pkg);
- } else {
- size_t len;
- /* we didn't need a backup */
- if(notouch) {
- /* change the path to a .pacnew extension */
- _alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
- /* remember len so we can get the old filename back for the event */
- len = strlen(filename);
- strncat(filename, ".pacnew", PATH_MAX - len);
- } else {
- _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
- }
-
- if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
- /* if FORCE was used, unlink() each file (whether it's there
- * or not) before extracting. This prevents the old "Text file busy"
- * error that crops up if forcing a glibc or pacman upgrade. */
- unlink(filename);
- }
-
- if(perform_extraction(handle, archive, entry, filename, entryname_orig)) {
- /* error */
- free(entryname_orig);
- errors++;
- return errors;
- }
-
- if(notouch) {
+ /* none of the three files matched another, leave the unpacked
+ * file alongside the local file */
alpm_event_pacnew_created_t event = {
.type = ALPM_EVENT_PACNEW_CREATED,
- .from_noupgrade = 1,
+ .from_noupgrade = 0,
.oldpkg = oldpkg,
.newpkg = newpkg,
- .file = filename
+ .file = origfile
};
- /* "remove" the .pacnew suffix */
- filename[len] = '\0';
+ _alpm_log(handle, ALPM_LOG_DEBUG,
+ "action: keeping current file and installing"
+ " new one with .pacnew ending\n");
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s installed as %s.pacnew\n", filename, filename);
- /* restore */
- filename[len] = '.';
+ "warning: %s installed as %s\n", origfile, filename);
}
- /* calculate an hash if this is in newpkg's backup */
- alpm_list_t *i;
- for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
- alpm_backup_t *backup = i->data;
- char *newhash;
- if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
- continue;
- }
- _alpm_log(handle, ALPM_LOG_DEBUG, "appending backup entry for %s\n", entryname_orig);
- newhash = alpm_compute_md5sum(filename);
- FREE(backup->hash);
- backup->hash = newhash;
+ free(hash_local);
+ if(!backup) {
+ free(hash_pkg);
}
}
- free(entryname_orig);
return errors;
}
diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h
index 711e0e83..6613e509 100644
--- a/lib/libalpm/add.h
+++ b/lib/libalpm/add.h
@@ -1,7 +1,7 @@
/*
* add.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 4a69bf84..21102860 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -1,7 +1,7 @@
/*
* alpm.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index e6ef3ae3..06e080be 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1,7 +1,7 @@
/*
* alpm.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -202,9 +202,6 @@ typedef enum _alpm_siglevel_t {
ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12),
ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13),
- ALPM_SIG_PACKAGE_SET = (1 << 27),
- ALPM_SIG_PACKAGE_TRUST_SET = (1 << 28),
-
ALPM_SIG_USE_DEFAULT = (1 << 31)
} alpm_siglevel_t;
@@ -445,10 +442,7 @@ typedef enum _alpm_event_type_t {
ALPM_EVENT_PACNEW_CREATED,
/** A .pacsave file was created; See alpm_event_pacsave_created_t for
* arguments */
- ALPM_EVENT_PACSAVE_CREATED,
- /** A .pacorig file was created; See alpm_event_pacorig_created_t for
- * arguments */
- ALPM_EVENT_PACORIG_CREATED
+ ALPM_EVENT_PACSAVE_CREATED
} alpm_event_type_t;
typedef struct _alpm_event_any_t {
@@ -539,15 +533,6 @@ typedef struct _alpm_event_pacsave_created_t {
const char *file;
} alpm_event_pacsave_created_t;
-typedef struct _alpm_event_pacorig_created_t {
- /** Type of event. */
- alpm_event_type_t type;
- /** New package. */
- alpm_pkg_t *newpkg;
- /** Filename of the file without the .pacorig suffix. */
- const char *file;
-} alpm_event_pacorig_created_t;
-
/** Events.
* This is an union passed to the callback, that allows the frontend to know
* which type of event was triggered (via type). It is then possible to
@@ -564,7 +549,6 @@ typedef union _alpm_event_t {
alpm_event_pkgdownload_t pkgdownload;
alpm_event_pacnew_created_t pacnew_created;
alpm_event_pacsave_created_t pacsave_created;
- alpm_event_pacorig_created_t pacorig_created;
} alpm_event_t;
/** Event callback. */
@@ -1101,6 +1085,12 @@ int alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_filename(alpm_pkg_t *pkg);
+/** Returns the package base name.
+ * @param pkg a pointer to package
+ * @return a reference to an internal string
+ */
+const char *alpm_pkg_get_base(alpm_pkg_t *pkg);
+
/** Returns the package name.
* @param pkg a pointer to package
* @return a reference to an internal string
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index e881196d..70bd8cf2 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -1,7 +1,7 @@
/*
* alpm_list.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index 65b26bec..5c6d3cad 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -1,7 +1,7 @@
/*
* alpm_list.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index aeb41316..5ccec036 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -1,7 +1,7 @@
/*
* backup.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -47,11 +47,10 @@ int _alpm_split_backup(const char *string, alpm_backup_t **backup)
*ptr = '\0';
ptr++;
/* now str points to the filename and ptr points to the hash */
- STRDUP((*backup)->name, str, return -1);
- STRDUP((*backup)->hash, ptr, return -1);
+ STRDUP((*backup)->name, str, FREE(str); return -1);
+ STRDUP((*backup)->hash, ptr, FREE(str); return -1);
FREE(str);
- return 0;
-}
+ return 0;}
/* Look for a filename in a alpm_pkg_t.backup list. If we find it,
* then we return the full backup entry.
diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h
index 3d9d4e53..03c9872a 100644
--- a/lib/libalpm/backup.h
+++ b/lib/libalpm/backup.h
@@ -1,7 +1,7 @@
/*
* backup.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 7d141c6d..6fd6cd5b 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -1,7 +1,7 @@
/*
* be_local.c : backend for the local database
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -63,6 +63,12 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
* initialized.
*/
+static const char *_cache_get_base(alpm_pkg_t *pkg)
+{
+ LAZY_LOAD(INFRQ_DESC, NULL);
+ return pkg->base;
+}
+
static const char *_cache_get_desc(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
@@ -297,6 +303,7 @@ static int _cache_force_load(alpm_pkg_t *pkg)
* logic.
*/
static struct pkg_operations local_pkg_ops = {
+ .get_base = _cache_get_base,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
@@ -701,6 +708,8 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s database is inconsistent: version "
"mismatch on package %s\n"), db->treename, info->name);
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(info->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(info->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -801,6 +810,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
alpm_backup_t *backup;
CALLOC(backup, 1, sizeof(alpm_backup_t), goto error);
if(_alpm_split_backup(line, &backup)) {
+ FREE(backup);
goto error;
}
info->backup = alpm_list_add(info->backup, backup);
@@ -904,6 +914,10 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
free(path);
fprintf(fp, "%%NAME%%\n%s\n\n"
"%%VERSION%%\n%s\n\n", info->name, info->version);
+ if(info->base) {
+ fprintf(fp, "%%BASE%%\n"
+ "%s\n\n", info->base);
+ }
if(info->desc) {
fprintf(fp, "%%DESC%%\n"
"%s\n\n", info->desc);
@@ -1022,11 +1036,6 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
cleanup:
umask(oldmask);
-
- if(fp) {
- fclose(fp);
- }
-
return retval;
}
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 5617f4fa..3e27232d 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -1,7 +1,7 @@
/*
* be_package.c : backend for packages
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -193,7 +193,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
STRDUP(newpkg->name, ptr, return -1);
newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
} else if(strcmp(key, "pkgbase") == 0) {
- /* not used atm */
+ STRDUP(newpkg->base, ptr, return -1);
} else if(strcmp(key, "pkgver") == 0) {
STRDUP(newpkg->version, ptr, return -1);
} else if(strcmp(key, "basever") == 0) {
@@ -437,6 +437,7 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, struct archive *archive)
{
int ret = 0;
+ size_t i;
size_t mtree_maxsize = 0;
size_t mtree_cursize = 0;
size_t files_size = 0; /* we clean up the existing array so this is fine */
@@ -448,7 +449,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
"found mtree for package %s, getting file list\n", pkg->filename);
/* throw away any files we might have already found */
- for (size_t i = 0; i < pkg->files.count; i++) {
+ for(i = 0; i < pkg->files.count; i++) {
free(pkg->files.files[i].name);
}
free(pkg->files.files);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 52459483..20130dcd 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -1,7 +1,7 @@
/*
* be_sync.c : backend for sync databases
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -614,6 +614,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(_alpm_validate_filename(db, pkg->name, pkg->filename) < 0) {
return -1;
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(pkg->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(pkg->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -707,7 +709,7 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
_alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
#ifndef HAVE_LIBGPGME
- if((level &= ~ALPM_SIG_PACKAGE_SET) != 0 && level != ALPM_SIG_USE_DEFAULT) {
+ if(level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
}
#endif
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index db07102c..0af3e3a8 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -1,7 +1,7 @@
/*
* conflict.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -48,15 +48,19 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
{
alpm_conflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_conflict_t), return NULL);
+ CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
- STRDUP(conflict->package1, pkg1->name, return NULL);
- STRDUP(conflict->package2, pkg2->name, return NULL);
+ STRDUP(conflict->package1, pkg1->name, goto error);
+ STRDUP(conflict->package2, pkg2->name, goto error);
conflict->reason = reason;
return conflict;
+
+error:
+ alpm_conflict_free(conflict);
+ return NULL;
}
/**
@@ -79,11 +83,15 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
newconflict->package1_hash = conflict->package1_hash;
newconflict->package2_hash = conflict->package2_hash;
- STRDUP(newconflict->package1, conflict->package1, return NULL);
- STRDUP(newconflict->package2, conflict->package2, return NULL);
+ STRDUP(newconflict->package1, conflict->package1, goto error);
+ STRDUP(newconflict->package2, conflict->package2, goto error);
newconflict->reason = conflict->reason;
return newconflict;
+
+error:
+ alpm_conflict_free(newconflict);
+ return NULL;
}
/**
@@ -265,7 +273,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
{
alpm_fileconflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
+ CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
@@ -284,6 +292,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
return conflicts;
error:
+ alpm_fileconflict_free(conflict);
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
}
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 886e9279..a5daad10 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -1,7 +1,7 @@
/*
* conflict.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 26e351fd..fe208be0 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -1,7 +1,7 @@
/*
* db.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -331,7 +331,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local)
alpm_db_t *db;
CALLOC(db, 1, sizeof(alpm_db_t), return NULL);
- STRDUP(db->treename, treename, return NULL);
+ STRDUP(db->treename, treename, FREE(db); return NULL);
if(is_local) {
db->status |= DB_STATUS_LOCAL;
} else {
@@ -542,7 +542,10 @@ alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
}
if(!(db->status & DB_STATUS_PKGCACHE)) {
- load_pkgcache(db);
+ if(load_pkgcache(db)) {
+ /* handle->error set in local/sync-db-populate */
+ return NULL;
+ }
}
return db->pkgcache;
@@ -562,13 +565,15 @@ alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db)
/* "duplicate" pkg then add it to pkgcache */
int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
{
- alpm_pkg_t *newpkg;
+ alpm_pkg_t *newpkg = NULL;
if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) {
return -1;
}
if(_alpm_pkg_dup(pkg, &newpkg)) {
+ /* we return memory on "non-fatal" error in _alpm_pkg_dup */
+ _alpm_pkg_free(newpkg);
return -1;
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 3025be9a..b19cb3f8 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -1,7 +1,7 @@
/*
* db.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index baa02b75..a43269d0 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -1,7 +1,7 @@
/*
* delta.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -306,10 +306,10 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
/* start at index 1 -- match 0 is the entire match */
len = pmatch[1].rm_eo - pmatch[1].rm_so;
- STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, return NULL);
+ STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, goto error);
len = pmatch[2].rm_eo - pmatch[2].rm_so;
- STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, return NULL);
+ STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, goto error);
len = pmatch[3].rm_eo - pmatch[3].rm_so;
if(len < sizeof(filesize)) {
@@ -319,12 +319,16 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
}
len = pmatch[4].rm_eo - pmatch[4].rm_so;
- STRNDUP(delta->from, &line[pmatch[4].rm_so], len, return NULL);
+ STRNDUP(delta->from, &line[pmatch[4].rm_so], len, goto error);
len = pmatch[5].rm_eo - pmatch[5].rm_so;
- STRNDUP(delta->to, &line[pmatch[5].rm_so], len, return NULL);
+ STRNDUP(delta->to, &line[pmatch[5].rm_so], len, goto error);
return delta;
+
+error:
+ _alpm_delta_free(delta);
+ return NULL;
}
#undef NUM_MATCHES
@@ -342,14 +346,18 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta)
{
alpm_delta_t *newdelta;
CALLOC(newdelta, 1, sizeof(alpm_delta_t), return NULL);
- STRDUP(newdelta->delta, delta->delta, return NULL);
- STRDUP(newdelta->delta_md5, delta->delta_md5, return NULL);
- STRDUP(newdelta->from, delta->from, return NULL);
- STRDUP(newdelta->to, delta->to, return NULL);
+ STRDUP(newdelta->delta, delta->delta, goto error);
+ STRDUP(newdelta->delta_md5, delta->delta_md5, goto error);
+ STRDUP(newdelta->from, delta->from, goto error);
+ STRDUP(newdelta->to, delta->to, goto error);
newdelta->delta_size = delta->delta_size;
newdelta->download_size = delta->download_size;
return newdelta;
+
+error:
+ _alpm_delta_free(newdelta);
+ return NULL;
}
/* vim: set noet: */
diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h
index c57e6c50..d52f73b8 100644
--- a/lib/libalpm/delta.h
+++ b/lib/libalpm/delta.h
@@ -1,7 +1,7 @@
/*
* delta.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index f2ee8f41..daab9c3f 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -1,7 +1,7 @@
/*
* deps.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -48,13 +48,17 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
{
alpm_depmissing_t *miss;
- MALLOC(miss, sizeof(alpm_depmissing_t), return NULL);
+ CALLOC(miss, 1, sizeof(alpm_depmissing_t), return NULL);
- STRDUP(miss->target, target, return NULL);
+ STRDUP(miss->target, target, goto error);
miss->depend = _alpm_dep_dup(dep);
- STRDUP(miss->causingpkg, causingpkg, return NULL);
+ STRDUP(miss->causingpkg, causingpkg, goto error);
return miss;
+
+error:
+ alpm_depmissing_free(miss);
+ return NULL;
}
void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss)
@@ -465,11 +469,11 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
return NULL;
}
- MALLOC(depend, sizeof(alpm_depend_t), return NULL);
+ CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL);
/* Note the extra space in ": " to avoid matching the epoch */
if((desc = strstr(depstring, ": ")) != NULL) {
- STRDUP(depend->desc, desc + 2, return NULL);
+ STRDUP(depend->desc, desc + 2, goto error);
deplen = desc - depstring;
} else {
/* no description- point desc at NULL at end of string for later use */
@@ -509,13 +513,17 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
}
/* copy the right parts to the right places */
- STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
+ STRNDUP(depend->name, depstring, ptr - depstring, goto error);
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
- STRNDUP(depend->version, version, desc - version, return NULL);
+ STRNDUP(depend->version, version, desc - version, goto error);
}
return depend;
+
+error:
+ alpm_dep_free(depend);
+ return NULL;
}
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
@@ -523,13 +531,17 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
alpm_depend_t *newdep;
CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL);
- STRDUP(newdep->name, dep->name, return NULL);
- STRDUP(newdep->version, dep->version, return NULL);
- STRDUP(newdep->desc, dep->desc, return NULL);
+ STRDUP(newdep->name, dep->name, goto error);
+ STRDUP(newdep->version, dep->version, goto error);
+ STRDUP(newdep->desc, dep->desc, goto error);
newdep->name_hash = dep->name_hash;
newdep->mod = dep->mod;
return newdep;
+
+error:
+ alpm_dep_free(newdep);
+ return NULL;
}
/* These parameters are messy. We check if this package, given a list of
@@ -597,11 +609,13 @@ int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit)
alpm_pkg_t *deppkg = j->data;
if(_alpm_pkg_depends_on(pkg, deppkg)
&& can_remove_package(db, deppkg, *targs, include_explicit)) {
- alpm_pkg_t *copy;
+ alpm_pkg_t *copy = NULL;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "adding '%s' to the targets\n",
deppkg->name);
/* add it to the target list */
if(_alpm_pkg_dup(deppkg, &copy)) {
+ /* we return memory on "non-fatal" error in _alpm_pkg_dup */
+ _alpm_pkg_free(copy);
return -1;
}
*targs = alpm_list_add(*targs, copy);
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index bd717bbd..06504497 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -1,7 +1,7 @@
/*
* deps.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index af87f755..3b496c2e 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -1,7 +1,7 @@
/*
* diskspace.c
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -112,7 +112,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((mnt = getmntent(fp))) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, mnt->mnt_dir, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, mnt->mnt_dir, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -135,7 +135,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((ret = getmntent(fp, &mnt)) == 0) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, mnt->mnt_mountp, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, mnt->mnt_mountp, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -162,7 +162,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
for(; entries-- > 0; fsp++) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, fsp->f_mntonname, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, fsp->f_mntonname, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
#if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG)
diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h
index c9fab9b4..2f5116d0 100644
--- a/lib/libalpm/diskspace.h
+++ b/lib/libalpm/diskspace.h
@@ -1,7 +1,7 @@
/*
* diskspace.h
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index e3409f99..63523aa3 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -1,7 +1,7 @@
/*
* download.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -379,7 +379,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
payload->tempfile_name = randpath;
free(payload->remote_name);
STRDUP(payload->remote_name, strrchr(randpath, '/') + 1,
- RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
+ fclose(fp); RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
return fp;
}
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 512a376b..b1e8b079 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -1,7 +1,7 @@
/*
* dload.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index fb6b8564..76b710cb 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -1,7 +1,7 @@
/*
* error.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index c41989ca..b1d01927 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -1,7 +1,7 @@
/*
* filelist.c
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/filelist.h b/lib/libalpm/filelist.h
index f948cfb5..580e8a91 100644
--- a/lib/libalpm/filelist.h
+++ b/lib/libalpm/filelist.h
@@ -1,7 +1,7 @@
/*
* filelist.h
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/graph.c b/lib/libalpm/graph.c
index 725b7045..4d58169c 100644
--- a/lib/libalpm/graph.c
+++ b/lib/libalpm/graph.c
@@ -1,7 +1,7 @@
/*
* graph.c - helpful graph structure and setup/teardown methods
*
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h
index 401260b2..fb24d730 100644
--- a/lib/libalpm/graph.h
+++ b/lib/libalpm/graph.h
@@ -1,7 +1,7 @@
/*
* graph.h - helpful graph structure and setup/teardown methods
*
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c
index aa51a63c..9c7de903 100644
--- a/lib/libalpm/group.c
+++ b/lib/libalpm/group.c
@@ -1,7 +1,7 @@
/*
* group.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/group.h b/lib/libalpm/group.h
index fb28457c..97ea878c 100644
--- a/lib/libalpm/group.h
+++ b/lib/libalpm/group.h
@@ -1,7 +1,7 @@
/*
* group.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index fa999489..4915d0bf 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -1,7 +1,7 @@
/*
* handle.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 2888f0f3..58931395 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -1,7 +1,7 @@
/*
* handle.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/libarchive-compat.h b/lib/libalpm/libarchive-compat.h
index 7c126416..610c7cd9 100644
--- a/lib/libalpm/libarchive-compat.h
+++ b/lib/libalpm/libarchive-compat.h
@@ -4,7 +4,7 @@
/*
* libarchive-compat.h
*
- * Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 9af5e846..8ee61df5 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -1,7 +1,7 @@
/*
* log.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/log.h b/lib/libalpm/log.h
index 41f98b20..6365eff3 100644
--- a/lib/libalpm/log.h
+++ b/lib/libalpm/log.h
@@ -1,7 +1,7 @@
/*
* log.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index d9ed3d31..4b5120b0 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
@@ -83,6 +83,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
* backend logic that needs lazy access, such as the local database through
* a lazy-load cache. However, the defaults will work just fine for fully-
* populated package structures. */
+static const char *_pkg_get_base(alpm_pkg_t *pkg) { return pkg->base; }
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
@@ -144,6 +145,7 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
* struct itself with no abstraction layer or any type of lazy loading.
*/
struct pkg_operations default_pkg_ops = {
+ .get_base = _pkg_get_base,
.get_desc = _pkg_get_desc,
.get_url = _pkg_get_url,
.get_builddate = _pkg_get_builddate,
@@ -186,6 +188,13 @@ const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
return pkg->filename;
}
+const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
+{
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->get_base(pkg);
+}
+
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -566,6 +575,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->name_hash = pkg->name_hash;
STRDUP(newpkg->filename, pkg->filename, goto cleanup);
+ STRDUP(newpkg->base, pkg->base, goto cleanup);
STRDUP(newpkg->name, pkg->name, goto cleanup);
STRDUP(newpkg->version, pkg->version, goto cleanup);
STRDUP(newpkg->desc, pkg->desc, goto cleanup);
@@ -641,6 +651,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
}
FREE(pkg->filename);
+ FREE(pkg->base);
FREE(pkg->name);
FREE(pkg->version);
FREE(pkg->desc);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 357c20ef..4a32f611 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -1,7 +1,7 @@
/*
* package.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -43,6 +43,7 @@
* defined default_pkg_ops struct to work just fine for their needs.
*/
struct pkg_operations {
+ const char *(*get_base) (alpm_pkg_t *);
const char *(*get_desc) (alpm_pkg_t *);
const char *(*get_url) (alpm_pkg_t *);
alpm_time_t (*get_builddate) (alpm_pkg_t *);
@@ -85,6 +86,7 @@ extern struct pkg_operations default_pkg_ops;
struct __alpm_pkg_t {
unsigned long name_hash;
char *filename;
+ char *base;
char *name;
char *version;
char *desc;
diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c
index a740233d..989a8c1b 100644
--- a/lib/libalpm/pkghash.c
+++ b/lib/libalpm/pkghash.c
@@ -1,7 +1,7 @@
/*
* pkghash.c
*
- * Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/pkghash.h b/lib/libalpm/pkghash.h
index f2887c3d..9184f9e4 100644
--- a/lib/libalpm/pkghash.h
+++ b/lib/libalpm/pkghash.h
@@ -1,7 +1,7 @@
/*
* pkghash.h
*
- * Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index f9b24ef1..ccf64dc5 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -1,7 +1,7 @@
/*
* remove.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h
index 123720ab..a9392e2e 100644
--- a/lib/libalpm/remove.h
+++ b/lib/libalpm/remove.h
@@ -1,7 +1,7 @@
/*
* remove.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 8391315a..b1c1ee98 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -1,7 +1,7 @@
/*
* signing.c
*
- * Copyright (c) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index b414b1f1..e5137d7b 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -1,7 +1,7 @@
/*
* signing.h
*
- * Copyright (c) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index c513b6b5..79192cff 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -1,7 +1,7 @@
/*
* sync.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -736,11 +736,11 @@ static int apply_deltas(alpm_handle_t *handle)
} else {
/* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2;
- MALLOC(from, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(from, len, free(delta); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(from, len, "%s/%s", cachedir, d->from);
}
len = strlen(cachedir) + strlen(d->to) + 2;
- MALLOC(to, len, free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(to, len, free(delta); free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(to, len, "%s/%s", cachedir, d->to);
/* build the patch command */
@@ -862,7 +862,7 @@ static struct dload_payload *build_payload(alpm_handle_t *handle,
struct dload_payload *payload;
CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(payload->remote_name, filename, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(payload->remote_name, filename, FREE(payload); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload->max_size = size;
payload->servers = servers;
return payload;
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index c15d348f..6281550f 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -1,7 +1,7 @@
/*
* sync.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index e1caa5e3..6a26e753 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -1,7 +1,7 @@
/*
* trans.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -347,7 +347,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath,
/* either extract or copy the scriptlet */
len += strlen("/.INSTALL");
- MALLOC(scriptfn, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ MALLOC(scriptfn, len, free(tmpdir); RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(scriptfn, len, "%s/.INSTALL", tmpdir);
if(is_archive) {
if(_alpm_unpack_single(handle, filepath, tmpdir, ".INSTALL")) {
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index d2bbcf80..fa9886d0 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -1,7 +1,7 @@
/*
* trans.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 1e367369..4d851327 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -1,7 +1,7 @@
/*
* util.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -542,7 +542,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
while(dup2(pipefd[1], 2) == -1 && errno == EINTR);
close(pipefd[0]);
close(pipefd[1]);
- close(cwdfd);
+ if(cwdfd >= 0) {
+ close(cwdfd);
+ }
/* use fprintf instead of _alpm_log to send output through the parent */
if(chroot(handle->root) != 0) {
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 6f47073b..4839618a 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -1,7 +1,7 @@
/*
* util.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c
index 6d68aacd..c7a57e45 100644
--- a/lib/libalpm/version.c
+++ b/lib/libalpm/version.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 4ef3ce0e..4745b6e0 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -28,7 +28,8 @@ EXTRA_DIST = \
pacman-optimize.sh.in \
pkgdelta.sh.in \
repo-add.sh.in \
- $(LIBRARY)
+ $(LIBRARY) \
+ $(LIBMAKEPKG_DIST)
LIBRARY = \
library/output_format.sh \
@@ -37,10 +38,37 @@ LIBRARY = \
library/size_to_human.sh \
library/term_colors.sh
-# Files that should be removed, but which Automake does not know.
-MOSTLYCLEANFILES = $(bin_SCRIPTS)
+libmakepkgdir = $(datarootdir)/makepkg
+
+LIBMAKEPKGDIRS = \
+ tidy \
+ util
+
+LIBMAKEPKG = \
+ libmakepkg/util/message.sh \
+ libmakepkg/util/option.sh
+
+LIBMAKEPKG_IN = \
+ libmakepkg/tidy.sh \
+ libmakepkg/tidy/build_references.sh \
+ libmakepkg/tidy/docs.sh \
+ libmakepkg/tidy/emptydirs.sh \
+ libmakepkg/tidy/libtool.sh \
+ libmakepkg/tidy/missing_backup.sh \
+ libmakepkg/tidy/optipng.sh \
+ libmakepkg/tidy/purge.sh \
+ libmakepkg/tidy/staticlibs.sh \
+ libmakepkg/tidy/strip.sh \
+ libmakepkg/tidy/upx.sh \
+ libmakepkg/tidy/zipman.sh \
+ libmakepkg/util.sh
+
+LIBMAKEPKG_DIST = \
+ $(LIBMAKEPKG) \
+ $(addsuffix .in, $(LIBMAKEPKG_IN))
-libmakepkgdir = $(libdir)/makepkg
+# Files that should be removed, but which Automake does not know.
+MOSTLYCLEANFILES = $(bin_SCRIPTS) $(LIBMAKEPKG_IN)
clean-local:
$(AM_V_at)$(RM) -r .lib
@@ -87,10 +115,18 @@ $(OURSCRIPTS): Makefile
$(AM_V_at)chmod +x,a-w $@
@$(BASH_SHELL) -O extglob -n $@
+$(LIBMAKEPKG_IN): %: %.in Makefile
+ $(AM_V_at)$(RM) $@
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_GEN)test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@
+ $(AM_V_at)chmod a-w $@
+ @$(BASH_SHELL) -O extglob -n $@
+
makepkg: \
$(srcdir)/makepkg.sh.in \
$(srcdir)/makepkg-wrapper.sh.in \
- $(srcdir)/library/parseopts.sh
+ $(srcdir)/library/parseopts.sh \
+ $(LIBMAKEPKG_IN)
makepkg-template: \
$(srcdir)/makepkg-template.pl.in \
@@ -150,6 +186,15 @@ install-exec-hook:
cd $(DESTDIR)$(bindir) && \
$(RM) makepkg makepkg-wrapper
$(INSTALL) .lib/makepkg $(DESTDIR)$(bindir)/makepkg
+ for dir in $(LIBMAKEPKGDIRS); do \
+ $(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/$$dir; \
+ done
+ for lib in $(LIBMAKEPKG); do \
+ $(INSTALL) $(srcdir)/$$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
+ for lib in $(LIBMAKEPKG_IN); do \
+ $(INSTALL) $$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
cd $(DESTDIR)$(bindir) && \
$(RM) repo-elephant && \
( $(LN_S) repo-add repo-elephant || \
@@ -164,5 +209,11 @@ install-exec-hook:
uninstall-hook:
cd $(DESTDIR)$(bindir) && \
$(RM) repo-remove repo-elephant
+ for lib in $(LIBMAKEPKG) $(LIBMAKEPKG_IN); do \
+ $(RM) $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
+ for dir in $(LIBMAKEPKGDIRS); do \
+ $(RM) -r $(DESTDIR)$(libmakepkgdir)/$$dir; \
+ done
# vim:set noet:
diff --git a/scripts/libmakepkg/.gitignore b/scripts/libmakepkg/.gitignore
new file mode 100644
index 00000000..7072d8b9
--- /dev/null
+++ b/scripts/libmakepkg/.gitignore
@@ -0,0 +1,13 @@
+tidy.sh
+tidy/build_references.sh
+tidy/docs.sh
+tidy/emptydirs.sh
+tidy/libtool.sh
+tidy/missing_backup.sh
+tidy/optipng.sh
+tidy/purge.sh
+tidy/staticlibs.sh
+tidy/strip.sh
+tidy/upx.sh
+tidy/zipman.sh
+util.sh
diff --git a/scripts/libmakepkg/tidy.sh.in b/scripts/libmakepkg/tidy.sh.in
new file mode 100644
index 00000000..483afcbf
--- /dev/null
+++ b/scripts/libmakepkg/tidy.sh.in
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# tidy.sh - functions for modifying/removing installed files before
+# package creation
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_SH" ] && return
+LIBMAKEPKG_TIDY_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+for lib in "$LIBRARY/tidy/"*.sh; do
+ source "$lib"
+done
+
+
+packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
+ 'purge' 'upx' 'optipng' 'debug')
+readonly -a packaging_options
+
+
+tidy_install() {
+ cd_safe "$pkgdir"
+ msg "$(gettext "Tidying install...")"
+
+ # options that remove unwanted files
+ tidy_docs
+ tidy_purge
+ tidy_libtool
+ tidy_staticlibs
+ tidy_emptydirs
+
+ # warn about packaging issues
+ # TODO: move these to another module
+ warn_missing_backup
+ warn_build_references
+
+ # options that reduce file sizes
+ tidy_zipman
+ tidy_strip
+ tidy_upx
+ tidy_optipng
+}
diff --git a/scripts/libmakepkg/tidy/build_references.sh.in b/scripts/libmakepkg/tidy/build_references.sh.in
new file mode 100644
index 00000000..2611869a
--- /dev/null
+++ b/scripts/libmakepkg/tidy/build_references.sh.in
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# build_references.sh - Warn about files containing references to build directories
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_BUILD_REFERENCES_SH" ] && return
+LIBMAKEPKG_TIDY_BUILD_REFERENCES_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+warn_build_references() {
+ if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
+ warning "$(gettext "Package contains reference to %s")" "\$srcdir"
+ fi
+ if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
+ warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/docs.sh.in b/scripts/libmakepkg/tidy/docs.sh.in
new file mode 100644
index 00000000..09b7234c
--- /dev/null
+++ b/scripts/libmakepkg/tidy/docs.sh.in
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# docs.sh - Remove documentation files from the package
+#
+# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_DOCS_SH" ] && return
+LIBMAKEPKG_TIDY_DOCS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_docs() {
+ if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
+ msg2 "$(gettext "Removing doc files...")"
+ rm -rf -- ${DOC_DIRS[@]}
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/emptydirs.sh.in b/scripts/libmakepkg/tidy/emptydirs.sh.in
new file mode 100644
index 00000000..8cdb4b09
--- /dev/null
+++ b/scripts/libmakepkg/tidy/emptydirs.sh.in
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# emptydirs.sh - Remove empty directories from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_EMPTYDIRS_SH" ] && return
+LIBMAKEPKG_TIDY_EMPTYDIRS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_emptydirs() {
+ if check_option "emptydirs" "n"; then
+ msg2 "$(gettext "Removing empty directories...")"
+ find . -depth -type d -exec rmdir '{}' + 2>/dev/null
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/libtool.sh.in b/scripts/libmakepkg/tidy/libtool.sh.in
new file mode 100644
index 00000000..e1dafe6d
--- /dev/null
+++ b/scripts/libmakepkg/tidy/libtool.sh.in
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# libtool.sh - Remove libtool files from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_LIBTOOL_SH" ] && return
+LIBMAKEPKG_TIDY_LIBTOOL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_libtool() {
+ if check_option "libtool" "n"; then
+ msg2 "$(gettext "Removing "%s" files...")" "libtool"
+ find . ! -type d -name "*.la" -exec rm -f -- '{}' +
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/missing_backup.sh.in b/scripts/libmakepkg/tidy/missing_backup.sh.in
new file mode 100644
index 00000000..fae04a27
--- /dev/null
+++ b/scripts/libmakepkg/tidy/missing_backup.sh.in
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# missing_backup.sh - Warn about missing files in the backup array
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_MISSING_BACKUP_SH" ] && return
+LIBMAKEPKG_TIDY_MISSING_BACKUP_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+warn_missing_backup() {
+ local file
+ for file in "${backup[@]}"; do
+ if [[ ! -f $file ]]; then
+ warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
+ fi
+ done
+}
diff --git a/scripts/libmakepkg/tidy/optipng.sh.in b/scripts/libmakepkg/tidy/optipng.sh.in
new file mode 100644
index 00000000..1cd74f54
--- /dev/null
+++ b/scripts/libmakepkg/tidy/optipng.sh.in
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# optipng.sh - Compress PNG files using optpng
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_OPTIPNG_SH" ] && return
+LIBMAKEPKG_TIDY_OPTIPNG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_optipng() {
+ if check_option "optipng" "y"; then
+ msg2 "$(gettext "Optimizing PNG images...")"
+ local png
+ find . -type f -iname "*.png" 2>/dev/null | while read -r png ; do
+ if [[ $(file --brief --mime-type "$png") = 'image/png' ]]; then
+ optipng "${OPTIPNGFLAGS[@]}" "$png" &>/dev/null ||
+ warning "$(gettext "Could not optimize PNG image : %s")" "${png/$pkgdir\//}"
+ fi
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/purge.sh.in b/scripts/libmakepkg/tidy/purge.sh.in
new file mode 100644
index 00000000..dbc03813
--- /dev/null
+++ b/scripts/libmakepkg/tidy/purge.sh.in
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# purge.sh - Remove unwanted files from the package
+#
+# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_PURGE_SH" ] && return
+LIBMAKEPKG_TIDY_PURGE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_purge() {
+ if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
+ msg2 "$(gettext "Purging unwanted files...")"
+ local pt
+ for pt in "${PURGE_TARGETS[@]}"; do
+ if [[ ${pt} = "${pt//\/}" ]]; then
+ find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
+ else
+ rm -f ${pt}
+ fi
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/staticlibs.sh.in b/scripts/libmakepkg/tidy/staticlibs.sh.in
new file mode 100644
index 00000000..7dbe8011
--- /dev/null
+++ b/scripts/libmakepkg/tidy/staticlibs.sh.in
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# staticlibs.sh - Remove static library files from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_STATICLIBS_SH" ] && return
+LIBMAKEPKG_TIDY_STATICLIBS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_staticlibs() {
+ if check_option "staticlibs" "n"; then
+ msg2 "$(gettext "Removing static library files...")"
+ local l
+ while read -rd '' l; do
+ if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
+ rm "$l"
+ fi
+ done < <(find . ! -type d -name "*.a" -print0)
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
new file mode 100644
index 00000000..4fe334bd
--- /dev/null
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# strip.sh - Strip debugging symbols from binary files
+#
+# Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_STRIP_SH" ] && return
+LIBMAKEPKG_TIDY_STRIP_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_strip() {
+ if check_option "strip" "y"; then
+ msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
+ # make sure library stripping variables are defined to prevent excess stripping
+ [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
+ [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
+
+ if check_option "debug" "y"; then
+ dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
+ mkdir -p "$dbgdir"
+ fi
+
+ local binary strip_flags
+ find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
+ case "$(file -bi "$binary")" in
+ *application/x-sharedlib*) # Libraries (.so)
+ strip_flags="$STRIP_SHARED";;
+ *application/x-archive*) # Libraries (.a)
+ strip_flags="$STRIP_STATIC";;
+ *application/x-object*)
+ case "$binary" in
+ *.ko) # Kernel module
+ strip_flags="$STRIP_SHARED";;
+ *)
+ continue;;
+ esac;;
+ *application/x-executable*) # Binaries
+ strip_flags="$STRIP_BINARIES";;
+ *)
+ continue ;;
+ esac
+ strip_file "$binary" ${strip_flags}
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/upx.sh.in b/scripts/libmakepkg/tidy/upx.sh.in
new file mode 100644
index 00000000..9012cd3e
--- /dev/null
+++ b/scripts/libmakepkg/tidy/upx.sh.in
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# upx.sh - Compress package binaries with UPX
+#
+# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_UPX_SH" ] && return
+LIBMAKEPKG_TIDY_UPX_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_upx() {
+ if check_option "upx" "y"; then
+ msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
+ local binary
+ find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
+ if [[ $(file --brief --mime-type "$binary") = 'application/x-executable' ]]; then
+ upx "${UPXFLAGS[@]}" "$binary" &>/dev/null ||
+ warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
+ fi
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/zipman.sh.in b/scripts/libmakepkg/tidy/zipman.sh.in
new file mode 100644
index 00000000..8557789b
--- /dev/null
+++ b/scripts/libmakepkg/tidy/zipman.sh.in
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# zipman.sh - Compress man and info pages
+#
+# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_ZIPMAN_SH" ] && return
+LIBMAKEPKG_TIDY_ZIPMAN_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+tidy_zipman() {
+ if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
+ msg2 "$(gettext "Compressing man and info pages...")"
+ local file files inode link
+ while read -rd ' ' inode; do
+ read file
+ find ${MAN_DIRS[@]} -type l 2>/dev/null |
+ while read -r link ; do
+ if [[ "${file}" -ef "${link}" ]] ; then
+ rm -f "$link" "${link}.gz"
+ if [[ ${file%/*} = ${link%/*} ]]; then
+ ln -s -- "${file##*/}.gz" "${link}.gz"
+ else
+ ln -s -- "/${file}.gz" "${link}.gz"
+ fi
+ fi
+ done
+ if [[ -z ${files[$inode]} ]]; then
+ files[$inode]=$file
+ gzip -9 -n -f "$file"
+ else
+ rm -f "$file"
+ ln "${files[$inode]}.gz" "${file}.gz"
+ chmod 644 "${file}.gz"
+ fi
+ done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
+ -exec @INODECMD@ '{}' + 2>/dev/null)
+ fi
+}
diff --git a/scripts/libmakepkg/util.sh.in b/scripts/libmakepkg/util.sh.in
new file mode 100644
index 00000000..86c76590
--- /dev/null
+++ b/scripts/libmakepkg/util.sh.in
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# util.sh - utility functions for makepkg
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_UTIL_SH" ] && return
+LIBMAKEPKG_UTIL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+for lib in "$LIBRARY/util/"*.sh; do
+ source "$lib"
+done
diff --git a/scripts/libmakepkg/util/message.sh b/scripts/libmakepkg/util/message.sh
new file mode 100644
index 00000000..15208ef8
--- /dev/null
+++ b/scripts/libmakepkg/util/message.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# message.sh - functions for outputting messages in makepkg
+#
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.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_UTIL_MESSAGE_SH" ] && return
+LIBMAKEPKG_UTIL_MESSAGE_SH=1
+
+
+plain() {
+ local mesg=$1; shift
+ printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+msg() {
+ local mesg=$1; shift
+ printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+msg2() {
+ local mesg=$1; shift
+ printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+warning() {
+ local mesg=$1; shift
+ printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+error() {
+ local mesg=$1; shift
+ printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
diff --git a/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh
new file mode 100644
index 00000000..fc649288
--- /dev/null
+++ b/scripts/libmakepkg/util/option.sh
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# option.sh - functions to test if build/packaging options are enabled
+#
+# Copyright (c) 2009-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ] && return
+LIBMAKEPKG_UTIL_OPTION_SH=1
+
+
+##
+# usage : in_opt_array( $needle, $haystack )
+# return : 0 - enabled
+# 1 - disabled
+# 127 - not found
+##
+in_opt_array() {
+ local needle=$1; shift
+
+ local i opt
+ for (( i = $#; i > 0; i-- )); do
+ opt=${!i}
+ if [[ $opt = "$needle" ]]; then
+ # enabled
+ return 0
+ elif [[ $opt = "!$needle" ]]; then
+ # disabled
+ return 1
+ fi
+ done
+
+ # not found
+ return 127
+}
+
+
+##
+# Checks to see if options are present in makepkg.conf or PKGBUILD;
+# PKGBUILD options always take precedence.
+#
+# usage : check_option( $option, $expected_val )
+# return : 0 - matches expected
+# 1 - does not match expected
+# 127 - not found
+##
+check_option() {
+ in_opt_array "$1" ${options[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = y ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = n ]]
+ return
+ esac
+
+ # fall back to makepkg.conf options
+ in_opt_array "$1" ${OPTIONS[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = y ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = n ]]
+ return
+ esac
+
+ # not found
+ return 127
+}
+
+
+##
+# Check if option is present in BUILDENV
+#
+# usage : check_buildenv( $option, $expected_val )
+# return : 0 - matches expected
+# 1 - does not match expected
+# 127 - not found
+##
+check_buildenv() {
+ in_opt_array "$1" ${BUILDENV[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = "y" ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = "n" ]]
+ return ;;
+ esac
+
+ # not found
+ return 127
+}
diff --git a/scripts/makepkg-template.pl.in b/scripts/makepkg-template.pl.in
index d9da1674..71d2aae2 100755
--- a/scripts/makepkg-template.pl.in
+++ b/scripts/makepkg-template.pl.in
@@ -2,7 +2,7 @@
# makepkg-template - template system for makepkg
# @configure_input@
#
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -109,7 +109,7 @@ sub load_template {
my ($version) = (abs_path($path) =~ /-([0-9.]+)[.]template$/);
if (!$version) {
- die sprintf(gettext("Couldn't detect version for template '%s'"), $values->{name});
+ die sprintf(gettext("Couldn't detect version for template '%s'\n"), $values->{name});
}
my $parsed = process_file($path);
@@ -128,7 +128,7 @@ sub process_file {
my $nesting_level = 0;
my $linenumber = 0;
- open (my $fh, "<", $filename) or die sprintf(gettext("failed to open '%s': %s"), $filename, $!);
+ open (my $fh, "<", $filename) or die sprintf(gettext("failed to open '%s': %s\n"), $filename, $!);
my @lines = <$fh>;
close $fh;
@@ -186,7 +186,7 @@ sub version {
my ($exitstatus) = @_;
printf "makepkg-template (pacman) %s\n", '@PACKAGE_VERSION@';
print gettext(
- 'Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>.'."\n".
+ 'Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>.'."\n".
'This is free software; see the source for copying conditions.'."\n".
'There is NO WARRANTY, to the extent permitted by law.'."\n");
exit($exitstatus);
diff --git a/scripts/makepkg-wrapper.sh.in b/scripts/makepkg-wrapper.sh.in
index fd83a01f..400db40f 100644
--- a/scripts/makepkg-wrapper.sh.in
+++ b/scripts/makepkg-wrapper.sh.in
@@ -2,7 +2,7 @@
#
# makepkg - a wrapper for running the real makepkg in the source tree
#
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 4461d12f..c01e9399 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -3,7 +3,7 @@
# makepkg - make packages compatible for use with pacman
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -48,13 +48,11 @@ declare -r startdir="$PWD"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
-packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
- 'purge' 'upx' 'debug')
-other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
+build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
'options' 'install' 'changelog')
-readonly -a packaging_options other_options splitpkg_overrides
+readonly -a build_options splitpkg_overrides
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
@@ -100,31 +98,10 @@ shopt -s extglob
### SUBROUTINES ###
-plain() {
- local mesg=$1; shift
- printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg() {
- local mesg=$1; shift
- printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg2() {
- local mesg=$1; shift
- printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-warning() {
- local mesg=$1; shift
- printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
+# Import libmakepkg
+for lib in "$LIBRARY"/*.sh; do
+ source "$lib"
+done
##
# Special exit call for traps, Don't print any error messages when inside,
@@ -930,92 +907,6 @@ get_pkg_arch() {
}
##
-# Checks to see if options are present in makepkg.conf or PKGBUILD;
-# PKGBUILD options always take precedence.
-#
-# usage : check_option( $option, $expected_val )
-# return : 0 - matches expected
-# 1 - does not match expected
-# 127 - not found
-##
-check_option() {
- in_opt_array "$1" ${options[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = y ]]
- return ;;
- 1) # assert disabled
- [[ $2 = n ]]
- return
- esac
-
- # fall back to makepkg.conf options
- in_opt_array "$1" ${OPTIONS[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = y ]]
- return ;;
- 1) # assert disabled
- [[ $2 = n ]]
- return
- esac
-
- # not found
- return 127
-}
-
-
-##
-# Check if option is present in BUILDENV
-#
-# usage : check_buildenv( $option, $expected_val )
-# return : 0 - matches expected
-# 1 - does not match expected
-# 127 - not found
-##
-check_buildenv() {
- in_opt_array "$1" ${BUILDENV[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = "y" ]]
- return ;;
- 1) # assert disabled
- [[ $2 = "n" ]]
- return ;;
- esac
-
- # not found
- return 127
-}
-
-
-##
-# usage : in_opt_array( $needle, $haystack )
-# return : 0 - enabled
-# 1 - disabled
-# 127 - not found
-##
-in_opt_array() {
- local needle=$1; shift
-
- local i opt
- for (( i = $#; i > 0; i-- )); do
- opt=${!i}
- if [[ $opt = "$needle" ]]; then
- # enabled
- return 0
- elif [[ $opt = "!$needle" ]]; then
- # disabled
- return 1
- fi
- done
-
- # not found
- return 127
-}
-
-
-##
# usage : in_array( $needle, $haystack )
# return : 0 - found
# 1 - not found
@@ -1284,22 +1175,23 @@ verify_integrity_one() {
}
verify_integrity_sums() {
- local integ=$1 arch=$2 integrity_sums=() sources=()
+ local integ=$1 arch=$2 integrity_sums=() sources=() srcname
if [[ $arch ]]; then
array_build integrity_sums "${integ}sums_$arch"
- array_build sources "source_$arch"
+ srcname=source_$arch
else
array_build integrity_sums "${integ}sums"
- array_build sources source
+ srcname=source
fi
+ array_build sources "$srcname"
if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then
return 1
fi
if (( ${#integrity_sums[@]} == ${#sources[@]} )); then
- msg "$(gettext "Validating source files with %s...")" "${integ}sums"
+ msg "$(gettext "Validating %s files with %s...")" "$srcname" "${integ}sums"
local idx errors=0
for (( idx = 0; idx < ${#sources[*]}; idx++ )); do
verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1
@@ -1352,7 +1244,7 @@ check_checksums() {
done
if (( ${#correlation[*]} )); then
- error "$(gettext "Integrity checks are missing.")"
+ error "$(gettext "Integrity checks are missing for: %s")" "${!correlation[*]}"
exit 1 # TODO: error code
fi
}
@@ -1788,137 +1680,6 @@ strip_file() {
strip $@ "$binary"
}
-tidy_install() {
- cd_safe "$pkgdir"
- msg "$(gettext "Tidying install...")"
-
- if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
- msg2 "$(gettext "Removing doc files...")"
- rm -rf -- ${DOC_DIRS[@]}
- fi
-
- if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
- msg2 "$(gettext "Purging unwanted files...")"
- local pt
- for pt in "${PURGE_TARGETS[@]}"; do
- if [[ ${pt} = "${pt//\/}" ]]; then
- find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
- else
- rm -f ${pt}
- fi
- done
- fi
-
- if check_option "libtool" "n"; then
- msg2 "$(gettext "Removing "%s" files...")" "libtool"
- find . ! -type d -name "*.la" -exec rm -f -- '{}' +
- fi
-
- if check_option "staticlibs" "n"; then
- msg2 "$(gettext "Removing static library files...")"
- local l
- while read -rd '' l; do
- if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
- rm "$l"
- fi
- done < <(find . ! -type d -name "*.a" -print0)
- fi
-
- if check_option "emptydirs" "n"; then
- msg2 "$(gettext "Removing empty directories...")"
- find . -depth -type d -exec rmdir '{}' + 2>/dev/null
- fi
-
- # check existence of backup files
- local file
- for file in "${backup[@]}"; do
- if [[ ! -f $file ]]; then
- warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
- fi
- done
-
- # check for references to the build and package directory
- if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
- warning "$(gettext "Package contains reference to %s")" "\$srcdir"
- fi
- if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
- warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
- fi
-
- if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
- msg2 "$(gettext "Compressing man and info pages...")"
- local file files inode link
- while read -rd ' ' inode; do
- read file
- find ${MAN_DIRS[@]} -type l 2>/dev/null |
- while read -r link ; do
- if [[ "${file}" -ef "${link}" ]] ; then
- rm -f "$link" "${link}.gz"
- if [[ ${file%/*} = ${link%/*} ]]; then
- ln -s -- "${file##*/}.gz" "${link}.gz"
- else
- ln -s -- "/${file}.gz" "${link}.gz"
- fi
- fi
- done
- if [[ -z ${files[$inode]} ]]; then
- files[$inode]=$file
- gzip -9 -n -f "$file"
- else
- rm -f "$file"
- ln "${files[$inode]}.gz" "${file}.gz"
- chmod 644 "${file}.gz"
- fi
- done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
- -exec @INODECMD@ '{}' + 2>/dev/null)
- fi
-
- if check_option "strip" "y"; then
- msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
- # make sure library stripping variables are defined to prevent excess stripping
- [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
- [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
-
- if check_option "debug" "y"; then
- dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
- mkdir -p "$dbgdir"
- fi
-
- local binary strip_flags
- find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
- case "$(file -bi "$binary")" in
- *application/x-sharedlib*) # Libraries (.so)
- strip_flags="$STRIP_SHARED";;
- *application/x-archive*) # Libraries (.a)
- strip_flags="$STRIP_STATIC";;
- *application/x-object*)
- case "$binary" in
- *.ko) # Kernel module
- strip_flags="$STRIP_SHARED";;
- *)
- continue;;
- esac;;
- *application/x-executable*) # Binaries
- strip_flags="$STRIP_BINARIES";;
- *)
- continue ;;
- esac
- strip_file "$binary" ${strip_flags}
- done
- fi
-
- if check_option "upx" "y"; then
- msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
- local binary
- find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
- if [[ $(file -bi "$binary") = *'application/x-executable'* ]]; then
- upx $UPXFLAGS "$binary" &>/dev/null ||
- warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
- fi
- done
- fi
-}
-
find_libdepends() {
local d sodepends;
@@ -2771,7 +2532,7 @@ lint_options() {
for i in "${options_list[@]}"; do
# check if option matches a known option or its inverse
- for kopt in "${packaging_options[@]}" "${other_options[@]}"; do
+ for kopt in "${packaging_options[@]}" "${build_options[@]}"; do
if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
# continue to the next $i
continue 2
@@ -3007,6 +2768,14 @@ check_software() {
fi
fi
+ # optipng - PNG image optimization
+ if check_option "optipng" "y"; then
+ if ! type -p optipng >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for optimizing PNG images.")" "optipng"
+ ret=1
+ fi
+ fi
+
# distcc - compilation with distcc
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
if ! type -p distcc >/dev/null; then
@@ -3209,7 +2978,7 @@ usage() {
version() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index 7d01bce9..a8beb808 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -3,7 +3,7 @@
# pacman-db-upgrade - upgrade the local pacman db to a newer format
# @configure_input@
#
-# Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ usage() {
version() {
printf "pacman-db-upgrade (pacman) %s\n" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 5ba0ad8f..82328515 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -4,7 +4,7 @@
# Based on apt-key, from Debian
# @configure_input@
#
-# Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -92,7 +92,7 @@ usage() {
version() {
printf "pacman-key (pacman) %s\n" "${myver}"
printf -- "$(gettext "\
-Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 7c809193..3e038fb3 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -3,7 +3,7 @@
# pacman-optimize
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -51,7 +51,7 @@ does not have to move around the disk as much.\n")"
version() {
printf "pacman-optimize (pacman) %s\n" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index be49326e..fe63974d 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -140,7 +140,7 @@ create_xdelta()
deltafile=$(dirname "$newfile")/$pkgname-${oldver}_to_${newver}-$arch.delta
local ret=0
- xdelta3 -q -f -s "$oldfile" "$newfile" "$deltafile" || ret=$?
+ xdelta3 -q -f -9 -S lzma -s "$oldfile" "$newfile" "$deltafile" || ret=$?
if (( ret )); then
error "$(gettext "Delta could not be created.")"
return 1
diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in
index f9e8a481..007227a6 100644
--- a/scripts/po/POTFILES.in
+++ b/scripts/po/POTFILES.in
@@ -8,5 +8,17 @@ scripts/pacman-key.sh.in
scripts/pacman-optimize.sh.in
scripts/pkgdelta.sh.in
scripts/repo-add.sh.in
+scripts/libmakepkg/tidy/build_references.sh.in
+scripts/libmakepkg/tidy/docs.sh.in
+scripts/libmakepkg/tidy/emptydirs.sh.in
+scripts/libmakepkg/tidy/libtool.sh.in
+scripts/libmakepkg/tidy/missing_backup.sh.in
+scripts/libmakepkg/tidy/optipng.sh.in
+scripts/libmakepkg/tidy/purge.sh.in
+scripts/libmakepkg/tidy/staticlibs.sh.in
+scripts/libmakepkg/tidy/strip.sh.in
+scripts/libmakepkg/tidy/upx.sh.in
+scripts/libmakepkg/tidy/zipman.sh.in
+scripts/libmakepkg/util/message.sh
scripts/library/output_format.sh
scripts/library/parseopts.sh
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 4325dbfb..5089f993 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -4,7 +4,7 @@
# repo-remove - remove a package entry from a given repo database file
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -93,7 +93,7 @@ version() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>\n\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
diff --git a/src/common/util-common.c b/src/common/util-common.c
index ab74e7c6..f5b00f17 100644
--- a/src/common/util-common.c
+++ b/src/common/util-common.c
@@ -1,7 +1,7 @@
/*
* util-common.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/common/util-common.h b/src/common/util-common.h
index ca8db5ab..a2093bef 100644
--- a/src/common/util-common.h
+++ b/src/common/util-common.h
@@ -1,7 +1,7 @@
/*
* util-common.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 4993382d..695e38d4 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -1,7 +1,7 @@
/*
* callback.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -269,9 +269,11 @@ void cb_event(alpm_event_t *event)
case ALPM_EVENT_OPTDEP_REMOVAL:
{
alpm_event_optdep_removal_t *e = &event->optdep_removal;
+ char *dep_string = alpm_dep_compute_string(e->optdep);
colon_printf(_("%s optionally requires %s\n"),
alpm_pkg_get_name(e->pkg),
- alpm_dep_compute_string(e->optdep));
+ dep_string);
+ free(dep_string);
}
break;
case ALPM_EVENT_DATABASE_MISSING:
@@ -313,22 +315,6 @@ void cb_event(alpm_event_t *event)
}
}
break;
- case ALPM_EVENT_PACORIG_CREATED:
- {
- alpm_event_pacorig_created_t *e = &event->pacorig_created;
- if(on_progress) {
- char *string = NULL;
- pm_sprintf(&string, ALPM_LOG_WARNING, _("%s saved as %s.pacorig\n"),
- e->file, e->file);
- if(string != NULL) {
- output = alpm_list_add(output, string);
- }
- } else {
- pm_printf(ALPM_LOG_WARNING, _("%s saved as %s.pacorig\n"),
- e->file, e->file);
- }
- }
- break;
/* all the simple done events, with fallthrough for each */
case ALPM_EVENT_FILECONFLICTS_DONE:
case ALPM_EVENT_CHECKDEPS_DONE:
diff --git a/src/pacman/callback.h b/src/pacman/callback.h
index 498536fe..a0e9e120 100644
--- a/src/pacman/callback.h
+++ b/src/pacman/callback.h
@@ -1,7 +1,7 @@
/*
* callback.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/check.c b/src/pacman/check.c
index 628e79de..74d17ce1 100644
--- a/src/pacman/check.c
+++ b/src/pacman/check.c
@@ -1,7 +1,7 @@
/*
* check.c
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/pacman/check.h b/src/pacman/check.h
index c2940dd3..fc129b48 100644
--- a/src/pacman/check.h
+++ b/src/pacman/check.h
@@ -1,7 +1,7 @@
/*
* check.h
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 873ca0ee..ccf8183d 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -1,7 +1,7 @@
/*
* conf.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include <limits.h>
#include <locale.h> /* setlocale */
#include <fcntl.h> /* open */
+#include <glob.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* strdup */
@@ -131,6 +132,9 @@ int config_free(config_t *oldconfig)
alpm_list_free(oldconfig->explicit_adds);
alpm_list_free(oldconfig->explicit_removes);
+ alpm_list_free_inner(config->repos, (alpm_list_fn_free) config_repo_free);
+ alpm_list_free(config->repos);
+
FREELIST(oldconfig->holdpkg);
FREELIST(oldconfig->ignorepkg);
FREELIST(oldconfig->ignoregrp);
@@ -151,6 +155,16 @@ int config_free(config_t *oldconfig)
return 0;
}
+void config_repo_free(config_repo_t *repo)
+{
+ if(repo == NULL) {
+ return;
+ }
+ free(repo->name);
+ FREELIST(repo->servers);
+ free(repo);
+}
+
/** Helper function for download_with_xfercommand() */
static char *get_filename(const char *url)
{
@@ -309,12 +323,15 @@ int config_set_arch(const char *arch)
* @return 0 on success, 1 on any parsing error
*/
static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
- const char *file, int linenum)
+ alpm_siglevel_t *storage_mask, const char *file, int linenum)
{
- alpm_siglevel_t level = *storage;
+ alpm_siglevel_t level = *storage, mask = *storage_mask;
alpm_list_t *i;
int ret = 0;
+#define SLSET(sl) do { level |= (sl); mask |= (sl); } while(0)
+#define SLUNSET(sl) do { level &= ~(sl); mask |= (sl); } while(0)
+
/* Collapse the option names into a single bitmasked value */
for(i = values; i; i = alpm_list_next(i)) {
const char *original = i->data, *value;
@@ -337,51 +354,40 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
/* now parse out and store actual flag if it is valid */
if(strcmp(value, "Never") == 0) {
if(package) {
- level &= ~ALPM_SIG_PACKAGE;
- level |= ALPM_SIG_PACKAGE_SET;
+ SLUNSET(ALPM_SIG_PACKAGE);
}
if(database) {
- level &= ~ALPM_SIG_DATABASE;
+ SLUNSET(ALPM_SIG_DATABASE);
}
} else if(strcmp(value, "Optional") == 0) {
if(package) {
- level |= ALPM_SIG_PACKAGE;
- level |= ALPM_SIG_PACKAGE_OPTIONAL;
- level |= ALPM_SIG_PACKAGE_SET;
+ SLSET(ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL);
}
if(database) {
- level |= ALPM_SIG_DATABASE;
- level |= ALPM_SIG_DATABASE_OPTIONAL;
+ SLSET(ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL);
}
} else if(strcmp(value, "Required") == 0) {
if(package) {
- level |= ALPM_SIG_PACKAGE;
- level &= ~ALPM_SIG_PACKAGE_OPTIONAL;
- level |= ALPM_SIG_PACKAGE_SET;
+ SLSET(ALPM_SIG_PACKAGE);
+ SLUNSET(ALPM_SIG_PACKAGE_OPTIONAL);
}
if(database) {
- level |= ALPM_SIG_DATABASE;
- level &= ~ALPM_SIG_DATABASE_OPTIONAL;
+ SLSET(ALPM_SIG_DATABASE);
+ SLUNSET(ALPM_SIG_DATABASE_OPTIONAL);
}
} else if(strcmp(value, "TrustedOnly") == 0) {
if(package) {
- level &= ~ALPM_SIG_PACKAGE_MARGINAL_OK;
- level &= ~ALPM_SIG_PACKAGE_UNKNOWN_OK;
- level |= ALPM_SIG_PACKAGE_TRUST_SET;
+ SLUNSET(ALPM_SIG_PACKAGE_MARGINAL_OK | ALPM_SIG_PACKAGE_UNKNOWN_OK);
}
if(database) {
- level &= ~ALPM_SIG_DATABASE_MARGINAL_OK;
- level &= ~ALPM_SIG_DATABASE_UNKNOWN_OK;
+ SLUNSET(ALPM_SIG_DATABASE_MARGINAL_OK | ALPM_SIG_DATABASE_UNKNOWN_OK);
}
} else if(strcmp(value, "TrustAll") == 0) {
if(package) {
- level |= ALPM_SIG_PACKAGE_MARGINAL_OK;
- level |= ALPM_SIG_PACKAGE_UNKNOWN_OK;
- level |= ALPM_SIG_PACKAGE_TRUST_SET;
+ SLSET(ALPM_SIG_PACKAGE_MARGINAL_OK | ALPM_SIG_PACKAGE_UNKNOWN_OK);
}
if(database) {
- level |= ALPM_SIG_DATABASE_MARGINAL_OK;
- level |= ALPM_SIG_DATABASE_UNKNOWN_OK;
+ SLSET(ALPM_SIG_DATABASE_MARGINAL_OK | ALPM_SIG_DATABASE_UNKNOWN_OK);
}
} else {
pm_printf(ALPM_LOG_ERROR,
@@ -392,6 +398,9 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
level &= ~ALPM_SIG_USE_DEFAULT;
}
+#undef SLSET
+#undef SLUNSET
+
/* ensure we have sig checking ability and are actually turning it on */
if(!(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) &&
level & (ALPM_SIG_PACKAGE | ALPM_SIG_DATABASE)) {
@@ -403,6 +412,7 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
if(!ret) {
*storage = level;
+ *storage_mask = mask;
}
return ret;
}
@@ -410,23 +420,13 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
/**
* Merge the package entires of two signature verification levels.
* @param base initial siglevel
- * @param over overridden siglevel, derived value is stored here
+ * @param over overridden siglevel
+ * @return merged siglevel
*/
-static void merge_siglevel(alpm_siglevel_t *base, alpm_siglevel_t *over)
+static alpm_siglevel_t merge_siglevel(alpm_siglevel_t base,
+ alpm_siglevel_t over, alpm_siglevel_t mask)
{
- alpm_siglevel_t level = *over;
- if(!(level & ALPM_SIG_USE_DEFAULT)) {
- if(!(level & ALPM_SIG_PACKAGE_SET)) {
- level |= *base & ALPM_SIG_PACKAGE;
- level |= *base & ALPM_SIG_PACKAGE_OPTIONAL;
- }
- if(!(level & ALPM_SIG_PACKAGE_TRUST_SET)) {
- level |= *base & ALPM_SIG_PACKAGE_MARGINAL_OK;
- level |= *base & ALPM_SIG_PACKAGE_UNKNOWN_OK;
- }
- }
-
- *over = level;
+ return mask ? (over & mask) | (base & ~mask) : over;
}
static int process_cleanmethods(alpm_list_t *values,
@@ -575,7 +575,8 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "SigLevel") == 0) {
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
- if(process_siglevel(values, &config->siglevel, file, linenum)) {
+ if(process_siglevel(values, &config->siglevel,
+ &config->siglevel_mask, file, linenum)) {
FREELIST(values);
return 1;
}
@@ -583,7 +584,8 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "LocalFileSigLevel") == 0) {
alpm_list_t *values = NULL;
setrepeatingoption(value, "LocalFileSigLevel", &values);
- if(process_siglevel(values, &config->localfilesiglevel, file, linenum)) {
+ if(process_siglevel(values, &config->localfilesiglevel,
+ &config->localfilesiglevel_mask, file, linenum)) {
FREELIST(values);
return 1;
}
@@ -591,7 +593,8 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "RemoteFileSigLevel") == 0) {
alpm_list_t *values = NULL;
setrepeatingoption(value, "RemoteFileSigLevel", &values);
- if(process_siglevel(values, &config->remotefilesiglevel, file, linenum)) {
+ if(process_siglevel(values, &config->remotefilesiglevel,
+ &config->remotefilesiglevel_mask, file, linenum)) {
FREELIST(values);
return 1;
}
@@ -640,6 +643,40 @@ static int _add_mirror(alpm_db_t *db, char *value)
return 0;
}
+static int register_repo(config_repo_t *repo)
+{
+ alpm_list_t *i;
+ alpm_db_t *db;
+
+ repo->siglevel = merge_siglevel(config->siglevel,
+ repo->siglevel, repo->siglevel_mask);
+
+ db = alpm_register_syncdb(config->handle, repo->name, repo->siglevel);
+ if(db == NULL) {
+ pm_printf(ALPM_LOG_ERROR, _("could not register '%s' database (%s)\n"),
+ repo->name, alpm_strerror(alpm_errno(config->handle)));
+ return 1;
+ }
+
+ pm_printf(ALPM_LOG_DEBUG,
+ "setting usage of %d for %s repository\n",
+ repo->usage == 0 ? ALPM_DB_USAGE_ALL : repo->usage,
+ repo->name);
+ alpm_db_set_usage(db, repo->usage == 0 ? ALPM_DB_USAGE_ALL : repo->usage);
+
+ for(i = repo->servers; i; i = alpm_list_next(i)) {
+ char *value = i->data;
+ if(_add_mirror(db, value) != 0) {
+ pm_printf(ALPM_LOG_ERROR,
+ _("could not add mirror '%s' to database '%s' (%s)\n"),
+ value, repo->name, alpm_strerror(alpm_errno(config->handle)));
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/** Sets up libalpm global stuff in one go. Called after the command line
* and initial config file parsing. Once this is complete, we can see if any
* paths were defined. If a rootdir was defined and nothing else, we want all
@@ -680,7 +717,7 @@ static int setup_libalpm(void)
pm_printf(ALPM_LOG_ERROR, _("failed to initialize alpm library\n(%s: %s)\n"),
alpm_strerror(err), config->dbpath);
if(err == ALPM_ERR_DB_VERSION) {
- pm_printf(ALPM_LOG_ERROR, _(" try running pacman-db-upgrade\n"));
+ fprintf(stderr, _("try running pacman-db-upgrade\n"));
}
return -1;
}
@@ -719,11 +756,18 @@ static int setup_libalpm(void)
alpm_option_set_default_siglevel(handle, config->siglevel);
- merge_siglevel(&config->siglevel, &config->localfilesiglevel);
- merge_siglevel(&config->siglevel, &config->remotefilesiglevel);
+ config->localfilesiglevel = merge_siglevel(config->siglevel,
+ config->localfilesiglevel, config->localfilesiglevel_mask);
+ config->remotefilesiglevel = merge_siglevel(config->siglevel,
+ config->remotefilesiglevel, config->remotefilesiglevel_mask);
+
alpm_option_set_local_file_siglevel(handle, config->localfilesiglevel);
alpm_option_set_remote_file_siglevel(handle, config->remotefilesiglevel);
+ for(i = config->repos; i; i = alpm_list_next(i)) {
+ register_repo(i->data);
+ }
+
if(config->xfercommand) {
alpm_option_set_fetchcb(handle, download_with_xfercommand);
} else if(!(alpm_capabilities() & ALPM_CAPABILITY_DOWNLOADER)) {
@@ -754,7 +798,7 @@ static int setup_libalpm(void)
ret = alpm_option_add_assumeinstalled(handle, dep);
if(ret) {
- pm_printf(ALPM_LOG_ERROR, _("Failed to pass assume installed entry to libalpm"));
+ pm_printf(ALPM_LOG_ERROR, _("Failed to pass %s entry to libalpm"), "assume-installed");
alpm_dep_free(dep);
return ret;
}
@@ -768,14 +812,9 @@ static int setup_libalpm(void)
* calling library methods.
*/
struct section_t {
- /* useful for all sections */
const char *name;
- int is_options;
- int parse_options;
- /* db section option gathering */
- alpm_list_t *servers;
- alpm_siglevel_t siglevel;
- alpm_db_usage_t usage;
+ config_repo_t *repo;
+ int depth;
};
static int process_usage(alpm_list_t *values, alpm_db_usage_t *usage,
@@ -816,6 +855,7 @@ static int _parse_repo(const char *key, char *value, const char *file,
int line, struct section_t *section)
{
int ret = 0;
+ config_repo_t *repo = section->repo;
if(strcmp(key, "Server") == 0) {
if(!value) {
@@ -823,7 +863,7 @@ static int _parse_repo(const char *key, char *value, const char *file,
file, line, key);
ret = 1;
} else {
- section->servers = alpm_list_add(section->servers, strdup(value));
+ repo->servers = alpm_list_add(repo->servers, strdup(value));
}
} else if(strcmp(key, "SigLevel") == 0) {
if(!value) {
@@ -833,10 +873,8 @@ static int _parse_repo(const char *key, char *value, const char *file,
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
if(values) {
- if(section->siglevel == ALPM_SIG_USE_DEFAULT) {
- section->siglevel = config->siglevel;
- }
- ret = process_siglevel(values, &section->siglevel, file, line);
+ ret = process_siglevel(values, &repo->siglevel,
+ &repo->siglevel_mask, file, line);
FREELIST(values);
}
}
@@ -844,7 +882,7 @@ static int _parse_repo(const char *key, char *value, const char *file,
alpm_list_t *values = NULL;
setrepeatingoption(value, "Usage", &values);
if(values) {
- if(process_usage(values, &section->usage, file, line)) {
+ if(process_usage(values, &repo->usage, file, line)) {
FREELIST(values);
return 1;
}
@@ -853,67 +891,72 @@ static int _parse_repo(const char *key, char *value, const char *file,
} else {
pm_printf(ALPM_LOG_WARNING,
_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
- file, line, key, section->name);
+ file, line, key, repo->name);
}
return ret;
}
-/**
- * Wrap up a section once we have reached the end of it. This should be called
- * when a subsequent section is encountered, or when we have reached the end of
- * the root config file. Once called, all existing saved config pieces on the
- * section struct are freed.
- * @param section the current parsed and saved section data
- * @param parse_options whether we are parsing options or repo data
- * @return 0 on success, 1 on failure
- */
-static int finish_section(struct section_t *section)
-{
- int ret = 0;
- alpm_list_t *i;
- alpm_db_t *db;
+static int _parse_directive(const char *file, int linenum, const char *name,
+ char *key, char *value, void *data);
- pm_printf(ALPM_LOG_DEBUG, "config: finish section '%s'\n", section->name);
+static int process_include(const char *value, void *data,
+ const char *file, int linenum)
+{
+ glob_t globbuf;
+ int globret, ret = 0;
+ size_t gindex;
+ struct section_t *section = data;
+ static const int config_max_recursion = 10;
- /* parsing options (or nothing)- nothing to do except free the pieces */
- if(!section->name || section->parse_options || section->is_options) {
- goto cleanup;
+ if(value == NULL) {
+ pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
+ file, linenum, "Include");
+ return 1;
}
- /* if we are not looking at options sections only, register a db */
- db = alpm_register_syncdb(config->handle, section->name, section->siglevel);
- if(db == NULL) {
- pm_printf(ALPM_LOG_ERROR, _("could not register '%s' database (%s)\n"),
- section->name, alpm_strerror(alpm_errno(config->handle)));
- ret = 1;
- goto cleanup;
+ if(section->depth >= config_max_recursion) {
+ pm_printf(ALPM_LOG_ERROR,
+ _("config parsing exceeded max recursion depth of %d.\n"),
+ config_max_recursion);
+ return 1;
}
- pm_printf(ALPM_LOG_DEBUG,
- "setting usage of %d for %s repoistory\n",
- section->usage == 0 ? ALPM_DB_USAGE_ALL : section->usage,
- section->name);
- alpm_db_set_usage(db, section->usage == 0 ? ALPM_DB_USAGE_ALL : section->usage);
-
- for(i = section->servers; i; i = alpm_list_next(i)) {
- char *value = i->data;
- if(_add_mirror(db, value) != 0) {
- pm_printf(ALPM_LOG_ERROR,
- _("could not add mirror '%s' to database '%s' (%s)\n"),
- value, section->name, alpm_strerror(alpm_errno(config->handle)));
- ret = 1;
- goto cleanup;
- }
- free(value);
+ section->depth++;
+
+ /* Ignore include failures... assume non-critical */
+ globret = glob(value, GLOB_NOCHECK, NULL, &globbuf);
+ switch(globret) {
+ case GLOB_NOSPACE:
+ pm_printf(ALPM_LOG_DEBUG,
+ "config file %s, line %d: include globbing out of space\n",
+ file, linenum);
+ break;
+ case GLOB_ABORTED:
+ pm_printf(ALPM_LOG_DEBUG,
+ "config file %s, line %d: include globbing read error for %s\n",
+ file, linenum, value);
+ break;
+ case GLOB_NOMATCH:
+ pm_printf(ALPM_LOG_DEBUG,
+ "config file %s, line %d: no include found for %s\n",
+ file, linenum, value);
+ break;
+ default:
+ for(gindex = 0; gindex < globbuf.gl_pathc; gindex++) {
+ pm_printf(ALPM_LOG_DEBUG, "config file %s, line %d: including %s\n",
+ file, linenum, globbuf.gl_pathv[gindex]);
+ ret = parse_ini(globbuf.gl_pathv[gindex], _parse_directive, data);
+ if(ret) {
+ goto cleanup;
+ }
+ }
+ break;
}
cleanup:
- alpm_list_free(section->servers);
- section->servers = NULL;
- section->siglevel = ALPM_SIG_USE_DEFAULT;
- section->name = NULL;
- section->usage = 0;
+ section->depth--;
+ globfree(&globbuf);
return ret;
}
@@ -921,16 +964,27 @@ static int _parse_directive(const char *file, int linenum, const char *name,
char *key, char *value, void *data)
{
struct section_t *section = data;
- if(!key && !value) {
- int ret = finish_section(section);
- pm_printf(ALPM_LOG_DEBUG, "config: new section '%s'\n", name);
+ if(!name && !key && !value) {
+ pm_printf(ALPM_LOG_ERROR, _("config file %s could not be read: %s\n"),
+ file, strerror(errno));
+ return 1;
+ } else if(!key && !value) {
section->name = name;
- if(name && strcmp(name, "options") == 0) {
- section->is_options = 1;
+ pm_printf(ALPM_LOG_DEBUG, "config: new section '%s'\n", name);
+ if(strcmp(name, "options") == 0) {
+ section->repo = NULL;
} else {
- section->is_options = 0;
+ section->repo = calloc(sizeof(config_repo_t), 1);
+ section->repo->name = strdup(name);
+ section->repo->siglevel = ALPM_SIG_USE_DEFAULT;
+ section->repo->usage = 0;
+ config->repos = alpm_list_add(config->repos, section->repo);
}
- return ret;
+ return 0;
+ }
+
+ if(strcmp(key, "Include") == 0) {
+ return process_include(value, data, file, linenum);
}
if(section->name == NULL) {
@@ -939,15 +993,13 @@ static int _parse_directive(const char *file, int linenum, const char *name,
return 1;
}
- if(section->parse_options && section->is_options) {
+ if(!section->repo) {
/* we are either in options ... */
return _parse_options(key, value, file, linenum);
- } else if(!section->parse_options && !section->is_options) {
+ } else {
/* ... or in a repo section */
return _parse_repo(key, value, file, linenum, section);
}
-
- return 0;
}
/** Parse a configuration file.
@@ -959,25 +1011,18 @@ int parseconfig(const char *file)
int ret;
struct section_t section;
memset(&section, 0, sizeof(struct section_t));
- section.siglevel = ALPM_SIG_USE_DEFAULT;
- section.usage = 0;
- /* the config parse is a two-pass affair. We first parse the entire thing for
- * the [options] section so we can get all default and path options set.
- * Next, we go back and parse everything but [options]. */
-
- /* call the real parseconfig function with a null section & db argument */
- pm_printf(ALPM_LOG_DEBUG, "parseconfig: options pass\n");
- section.parse_options = 1;
+ pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file);
if((ret = parse_ini(file, _parse_directive, &section))) {
return ret;
}
+ pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
if((ret = setup_libalpm())) {
return ret;
}
- /* second pass, repo section parsing */
- pm_printf(ALPM_LOG_DEBUG, "parseconfig: repo pass\n");
- section.parse_options = 0;
- return parse_ini(file, _parse_directive, &section);
+ alpm_list_free_inner(config->repos, (alpm_list_fn_free) config_repo_free);
+ alpm_list_free(config->repos);
+ config->repos = NULL;
+ return ret;
}
/* vim: set noet: */
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 3141e2c3..d6feb7ac 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -1,7 +1,7 @@
/*
* conf.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,14 @@ typedef struct __colstr_t {
const char *nocolor;
} colstr_t;
+typedef struct __config_repo_t {
+ char *name;
+ alpm_list_t *servers;
+ alpm_db_usage_t usage;
+ alpm_siglevel_t siglevel;
+ alpm_siglevel_t siglevel_mask;
+} config_repo_t;
+
typedef struct __config_t {
unsigned short op;
unsigned short quiet;
@@ -88,6 +96,10 @@ typedef struct __config_t {
alpm_siglevel_t localfilesiglevel;
alpm_siglevel_t remotefilesiglevel;
+ alpm_siglevel_t siglevel_mask;
+ alpm_siglevel_t localfilesiglevel_mask;
+ alpm_siglevel_t remotefilesiglevel_mask;
+
/* conf file options */
/* I Love Candy! */
unsigned short chomp;
@@ -114,6 +126,8 @@ typedef struct __config_t {
/* Color strings for output */
colstr_t colstr;
+
+ alpm_list_t *repos;
} config_t;
/* Operations */
@@ -208,6 +222,8 @@ void enable_colors(int colors);
config_t *config_new(void);
int config_free(config_t *oldconfig);
+void config_repo_free(config_repo_t *repo);
+
int config_set_arch(const char *arch);
int parseconfig(const char *file);
#endif /* _PM_CONF_H */
diff --git a/src/pacman/database.c b/src/pacman/database.c
index e858e0c8..abc3fd28 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -1,7 +1,7 @@
/*
* database.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <dirent.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <alpm.h>
@@ -35,11 +38,12 @@
*
* @return 0 on success, 1 on failure
*/
-int pacman_database(alpm_list_t *targets)
+static int change_install_reason(alpm_list_t *targets)
{
alpm_list_t *i;
alpm_db_t *db_local;
- int retval = 0;
+ int ret = 0;
+
alpm_pkgreason_t reason;
if(targets == NULL) {
@@ -68,7 +72,7 @@ int pacman_database(alpm_list_t *targets)
if(!pkg || alpm_pkg_set_reason(pkg, reason)) {
pm_printf(ALPM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"),
pkgname, alpm_strerror(alpm_errno(config->handle)));
- retval = 1;
+ ret = 1;
} else {
if(reason == ALPM_PKG_REASON_DEPEND) {
printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname);
@@ -82,7 +86,213 @@ int pacman_database(alpm_list_t *targets)
if(trans_release() == -1) {
return 1;
}
- return retval;
+ return ret;
+}
+
+static int check_db_missing_deps(alpm_list_t *pkglist)
+{
+ alpm_list_t *data, *i;
+ int ret = 0;
+ /* check dependencies */
+ data = alpm_checkdeps(config->handle, NULL, NULL, pkglist, 0);
+ for(i = data; i; i = alpm_list_next(i)) {
+ alpm_depmissing_t *miss = i->data;
+ char *depstring = alpm_dep_compute_string(miss->depend);
+ pm_printf(ALPM_LOG_ERROR, "missing '%s' dependency for '%s'\n",
+ depstring, miss->target);
+ free(depstring);
+ ret++;
+ }
+ FREELIST(data);
+ return ret;
+}
+
+static int check_db_local_files(void)
+{
+ struct dirent *ent;
+ const char *dbpath;
+ char path[PATH_MAX];
+ int ret = 0;
+ DIR *dbdir;
+
+ dbpath = alpm_option_get_dbpath(config->handle);
+ snprintf(path, PATH_MAX, "%slocal", dbpath);
+ if(!(dbdir = opendir(path))) {
+ pm_printf(ALPM_LOG_ERROR, "could not open local database directory %s: %s\n",
+ path, strerror(errno));
+ return 1;
+ }
+
+ while((ent = readdir(dbdir)) != NULL) {
+ if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0
+ || strcmp(ent->d_name, "ALPM_DB_VERSION") == 0) {
+ continue;
+ }
+ /* check for expected db files in local database */
+ snprintf(path, PATH_MAX, "%slocal/%s/desc", dbpath, ent->d_name);
+ if(access(path, F_OK)) {
+ pm_printf(ALPM_LOG_ERROR, "'%s': description file is missing\n", ent->d_name);
+ ret++;
+ }
+ snprintf(path, PATH_MAX, "%slocal/%s/files", dbpath, ent->d_name);
+ if(access(path, F_OK)) {
+ pm_printf(ALPM_LOG_ERROR, "'%s': file list is missing\n", ent->d_name);
+ ret++;
+ }
+ }
+ closedir(dbdir);
+
+ return ret;
+}
+
+static int check_db_local_package_conflicts(alpm_list_t *pkglist)
+{
+ alpm_list_t *data, *i;
+ int ret = 0;
+ /* check conflicts */
+ data = alpm_checkconflicts(config->handle, pkglist);
+ for(i = data; i; i = i->next) {
+ alpm_conflict_t *conflict = i->data;
+ pm_printf(ALPM_LOG_ERROR, "'%s' conflicts with '%s'\n",
+ conflict->package1, conflict->package2);
+ ret++;
+ }
+ FREELIST(data);
+ return ret;
+}
+
+struct fileitem {
+ alpm_file_t *file;
+ alpm_pkg_t *pkg;
+};
+
+static int fileitem_cmp(const void *p1, const void *p2)
+{
+ const struct fileitem * fi1 = p1;
+ const struct fileitem * fi2 = p2;
+ return strcmp(fi1->file->name, fi2->file->name);
+}
+
+static int check_db_local_filelist_conflicts(alpm_list_t *pkglist)
+{
+ alpm_list_t *i;
+ int ret = 0;
+ size_t list_size = 4096;
+ size_t offset = 0, j;
+ struct fileitem *all_files;
+ struct fileitem *prev_fileitem = NULL;
+
+ all_files = malloc(list_size * sizeof(struct fileitem));
+
+ for(i = pkglist; i; i = i->next) {
+ alpm_pkg_t *pkg = i->data;
+ alpm_filelist_t *filelist = alpm_pkg_get_files(pkg);
+ for(j = 0; j < filelist->count; j++) {
+ alpm_file_t *file = filelist->files + j;
+ /* only add files, not directories, to our big list */
+ if(file->name[strlen(file->name) - 1] == '/') {
+ continue;
+ }
+
+ /* do we need to reallocate and grow our array? */
+ if(offset >= list_size) {
+ struct fileitem *new_files;
+ new_files = realloc(all_files, list_size * 2 * sizeof(struct fileitem));
+ if(!new_files) {
+ free(all_files);
+ return 1;
+ }
+ all_files = new_files;
+ list_size *= 2;
+ }
+
+ /* we can finally add it to the list */
+ all_files[offset].file = file;
+ all_files[offset].pkg = pkg;
+ offset++;
+ }
+ }
+
+ /* now sort the list so we can find duplicates */
+ qsort(all_files, offset, sizeof(struct fileitem), fileitem_cmp);
+
+ /* do a 'uniq' style check on the list */
+ for(j = 0; j < offset; j++) {
+ struct fileitem *fileitem = all_files + j;
+ if(prev_fileitem && fileitem_cmp(prev_fileitem, fileitem) == 0) {
+ pm_printf(ALPM_LOG_ERROR, "file owned by '%s' and '%s': '%s'\n",
+ alpm_pkg_get_name(prev_fileitem->pkg),
+ alpm_pkg_get_name(fileitem->pkg),
+ fileitem->file->name);
+ }
+ prev_fileitem = fileitem;
+ }
+
+ free(all_files);
+ return ret;
+}
+
+/**
+ * @brief Check 'local' package database for consistency
+ *
+ * @return 0 on success, >=1 on failure
+ */
+static int check_db_local(void) {
+ int ret = 0;
+ alpm_db_t *db = NULL;
+ alpm_list_t *pkglist;
+
+ ret = check_db_local_files();
+ if(ret) {
+ return ret;
+ }
+
+ db = alpm_get_localdb(config->handle);
+ pkglist = alpm_db_get_pkgcache(db);
+ ret += check_db_missing_deps(pkglist);
+ ret += check_db_local_package_conflicts(pkglist);
+ ret += check_db_local_filelist_conflicts(pkglist);
+
+ return 0;
+}
+
+/**
+ * @brief Check 'sync' package databases for consistency
+ *
+ * @return 0 on success, >=1 on failure
+ */
+static int check_db_sync(void) {
+ int ret = 0;
+ alpm_list_t *i, *dblist, *pkglist, *syncpkglist = NULL;
+
+ dblist = alpm_get_syncdbs(config->handle);
+ for(i = dblist; i; i = alpm_list_next(i)) {
+ pkglist = alpm_db_get_pkgcache(i->data);
+ syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
+ }
+ ret = check_db_missing_deps(syncpkglist);
+
+ alpm_list_free(syncpkglist);
+ return ret;
+}
+
+int pacman_database(alpm_list_t *targets)
+{
+ int ret = 0;
+
+ if(config->op_q_check) {
+ if(config->op_q_check == 1) {
+ ret = check_db_local();
+ } else {
+ ret = check_db_sync();
+ }
+ }
+
+ if(config->flags & (ALPM_TRANS_FLAG_ALLDEPS | ALPM_TRANS_FLAG_ALLEXPLICIT)) {
+ ret = change_install_reason(targets);
+ }
+
+ return ret;
}
/* vim: set noet: */
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 511c398d..a43d1797 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -1,7 +1,7 @@
/*
* deptest.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/ini.c b/src/pacman/ini.c
index 2eb32302..fed0b187 100644
--- a/src/pacman/ini.c
+++ b/src/pacman/ini.c
@@ -1,7 +1,7 @@
/*
* ini.c
*
- * Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
*/
#include <errno.h>
-#include <glob.h>
#include <limits.h>
#include <string.h> /* strdup */
@@ -27,43 +26,38 @@
#include "ini.h"
#include "util.h"
-static const int ini_max_recursion = 10;
-
/**
- * @brief INI parser backend.
+ * @brief Parse a pacman-style INI config file.
*
* @param file path to the config file
* @param cb callback for key/value pairs
* @param data caller defined data to be passed to the callback
- * @param section_name the name of the current section
- * @param line buffer to read into, must be at least PATH_MAX long
- * @param depth recursion depth, should initially be 0
*
- * @return 0 on success, 1 on parsing errors, the callback return value
- * otherwise
+ * @return the callback return value
+ *
+ * @note The callback will be called at the beginning of each section with an
+ * empty key and value and for each key/value pair.
+ *
+ * @note If the parser encounters an error the callback will be called with
+ * section, key, and value set to NULL and errno set by fopen, fgets, or
+ * strdup.
+ *
+ * @note The @a key and @a value passed to @ cb will be overwritten between
+ * calls. The section name will remain valid until after @a cb is called to
+ * begin a new section.
+ *
+ * @note Parsing will immediately stop if the callback returns non-zero.
*/
-static int _parse_ini(const char *file, ini_parser_fn cb, void *data,
- char **section_name, char *line, int depth)
+int parse_ini(const char *file, ini_parser_fn cb, void *data)
{
+ char line[PATH_MAX], *section_name = NULL;
FILE *fp = NULL;
int linenum = 0;
int ret = 0;
- if(depth >= ini_max_recursion) {
- pm_printf(ALPM_LOG_ERROR,
- _("config parsing exceeded max recursion depth of %d.\n"),
- ini_max_recursion);
- ret = 1;
- goto cleanup;
- }
-
- pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file);
fp = fopen(file, "r");
if(fp == NULL) {
- pm_printf(ALPM_LOG_ERROR, _("config file %s could not be read: %s\n"),
- file, strerror(errno));
- ret = 1;
- goto cleanup;
+ return cb(file, 0, NULL, NULL, NULL, data);
}
while(safe_fgets(line, PATH_MAX, fp)) {
@@ -85,20 +79,13 @@ static int _parse_ini(const char *file, ini_parser_fn cb, void *data,
if(line[0] == '[' && line[line_len - 1] == ']') {
char *name;
- /* only possibility here is a line == '[]' */
- if(line_len <= 2) {
- pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: bad section name.\n"),
- file, linenum);
- ret = 1;
- goto cleanup;
- }
/* new config section, skip the '[' */
name = strdup(line + 1);
name[line_len - 2] = '\0';
ret = cb(file, linenum, name, NULL, NULL, data);
- free(*section_name);
- *section_name = name;
+ free(section_name);
+ section_name = name;
/* we're at a new section; perform any post-actions for the prior */
if(ret) {
@@ -115,103 +102,15 @@ static int _parse_ini(const char *file, ini_parser_fn cb, void *data,
strtrim(key);
strtrim(value);
- if(key == NULL) {
- pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: syntax error in config file- missing key.\n"),
- file, linenum);
- ret = 1;
- goto cleanup;
- }
- /* Include is allowed in both options and repo sections */
- if(strcmp(key, "Include") == 0) {
- glob_t globbuf;
- int globret;
- size_t gindex;
-
- if(value == NULL) {
- pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"),
- file, linenum, key);
- ret = 1;
- goto cleanup;
- }
- /* Ignore include failures... assume non-critical */
- globret = glob(value, GLOB_NOCHECK, NULL, &globbuf);
- switch(globret) {
- case GLOB_NOSPACE:
- pm_printf(ALPM_LOG_DEBUG,
- "config file %s, line %d: include globbing out of space\n",
- file, linenum);
- break;
- case GLOB_ABORTED:
- pm_printf(ALPM_LOG_DEBUG,
- "config file %s, line %d: include globbing read error for %s\n",
- file, linenum, value);
- break;
- case GLOB_NOMATCH:
- pm_printf(ALPM_LOG_DEBUG,
- "config file %s, line %d: no include found for %s\n",
- file, linenum, value);
- break;
- default:
- for(gindex = 0; gindex < globbuf.gl_pathc; gindex++) {
- pm_printf(ALPM_LOG_DEBUG, "config file %s, line %d: including %s\n",
- file, linenum, globbuf.gl_pathv[gindex]);
- ret =_parse_ini(globbuf.gl_pathv[gindex], cb, data,
- section_name, line, depth + 1);
- if(ret) {
- globfree(&globbuf);
- goto cleanup;
- }
- }
- break;
- }
- globfree(&globbuf);
- continue;
- }
- if((ret = cb(file, linenum, *section_name, key, value, data)) != 0) {
+ if((ret = cb(file, linenum, section_name, key, value, data)) != 0) {
goto cleanup;
}
}
- if(depth == 0) {
- ret = cb(NULL, 0, NULL, NULL, NULL, data);
- }
-
cleanup:
- if(fp) {
- fclose(fp);
- }
- if(depth == 0) {
- free(*section_name);
- *section_name = NULL;
- }
- pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
+ fclose(fp);
+ free(section_name);
return ret;
}
-/**
- * @brief Parse a pacman-style INI config file.
- *
- * @param file path to the config file
- * @param cb callback for key/value pairs
- * @param data caller defined data to be passed to the callback
- *
- * @return 0 on success, 1 on parsing errors, the callback return value
- * otherwise
- *
- * @note The callback will be called at the beginning of each section with an
- * empty key and value, for each key/value pair, and when parsing is complete
- * with all arguments except @a data empty.
- *
- * @note The @a key and @a value passed to @ cb will be overwritten between
- * calls. The section name will remain valid until after @a cb is called to
- * begin a new section.
- *
- * @note Parsing will immediately stop if the callback returns non-zero.
- */
-int parse_ini(const char *file, ini_parser_fn cb, void *data)
-{
- char *section_name = NULL, line[PATH_MAX];
- return _parse_ini(file, cb, data, &section_name, line, 0);
-}
-
/* vim: set noet: */
diff --git a/src/pacman/ini.h b/src/pacman/ini.h
index 23786a09..e85a505d 100644
--- a/src/pacman/ini.h
+++ b/src/pacman/ini.h
@@ -1,7 +1,7 @@
/*
* ini.h
*
- * Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 1ac0fcae..14a7b9f0 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/package.h b/src/pacman/package.h
index a6f02b97..4860d577 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -1,7 +1,7 @@
/*
* package.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 6f05c68c..fce0131c 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -1,7 +1,7 @@
/*
* pacman.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -169,6 +169,7 @@ static void usage(int op, const char * const myname)
printf("%s:\n", str_opt);
addlist(_(" --asdeps mark packages as non-explicitly installed\n"));
addlist(_(" --asexplicit mark packages as explicitly installed\n"));
+ addlist(_(" -k, --check test local database for validity (-kk for sync databases)\n"));
} else if(op == PM_OP_DEPTEST) {
printf("%s: %s {-T --deptest} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
printf("%s:\n", str_opt);
@@ -223,7 +224,7 @@ static void version(void)
{
printf("\n");
printf(" .--. Pacman v%s - libalpm v%s\n", PACKAGE_VERSION, alpm_version());
- printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2014 Pacman Development Team\n");
+ printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2015 Pacman Development Team\n");
printf("\\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet\n");
printf(" '--'\n");
printf(_(" This program may be freely redistributed under\n"
@@ -484,9 +485,18 @@ static int parsearg_global(int opt)
static int parsearg_database(int opt)
{
switch(opt) {
- case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
- case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
- default: return 1;
+ case OP_ASDEPS:
+ config->flags |= ALPM_TRANS_FLAG_ALLDEPS;
+ break;
+ case OP_ASEXPLICIT:
+ config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT;
+ break;
+ case OP_CHECK:
+ case 'k':
+ (config->op_q_check)++;
+ break;
+ default:
+ return 1;
}
return 0;
}
@@ -496,6 +506,13 @@ static void checkargs_database(void)
invalid_opt(config->flags & ALPM_TRANS_FLAG_ALLDEPS
&& config->flags & ALPM_TRANS_FLAG_ALLEXPLICIT,
"--asdeps", "--asexplicit");
+
+ if(config->op_q_check) {
+ invalid_opt(config->flags & ALPM_TRANS_FLAG_ALLDEPS,
+ "--asdeps", "--check");
+ invalid_opt(config->flags & ALPM_TRANS_FLAG_ALLEXPLICIT,
+ "--asexplicit", "--check");
+ }
}
static int parsearg_query(int opt)
diff --git a/src/pacman/pacman.h b/src/pacman/pacman.h
index 7b33a74e..ddf6e62a 100644
--- a/src/pacman/pacman.h
+++ b/src/pacman/pacman.h
@@ -1,7 +1,7 @@
/*
* pacman.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 477e4fed..f7570156 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -1,7 +1,7 @@
/*
* query.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 38ad2a29..069f2363 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -1,7 +1,7 @@
/*
* remove.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 215497f6..91eca7e4 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -1,7 +1,7 @@
/*
* sync.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index a6be0e18..a3faf7ac 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -1,7 +1,7 @@
/*
* upgrade.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 36f4414a..5d683608 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1,7 +1,7 @@
/*
* util.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -105,7 +105,7 @@ int needs_root(void)
{
switch(config->op) {
case PM_OP_DATABASE:
- return 1;
+ return !config->op_q_check;
case PM_OP_UPGRADE:
case PM_OP_REMOVE:
return !config->print;
@@ -284,6 +284,7 @@ void indentprint(const char *str, unsigned short indent, unsigned short cols)
cidx = indent;
if(!p || !len) {
+ free(wcstr);
return;
}
diff --git a/src/pacman/util.h b/src/pacman/util.h
index b591fbaf..fda9b51a 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -1,7 +1,7 @@
/*
* util.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/util/.gitignore b/src/util/.gitignore
index 1813506b..202fb753 100644
--- a/src/util/.gitignore
+++ b/src/util/.gitignore
@@ -6,8 +6,6 @@ pacsort
pacsort.exe
pactree
pactree.exe
-testdb
-testdb.exe
testpkg
testpkg.exe
vercmp
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index a0075887..25c025b5 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -4,7 +4,7 @@ dbpath = ${localstatedir}/lib/pacman/
gpgdir = ${sysconfdir}/pacman.d/gnupg/
cachedir = ${localstatedir}/cache/pacman/pkg/
-bin_PROGRAMS = vercmp testpkg testdb cleanupdelta pacsort pactree
+bin_PROGRAMS = vercmp testpkg cleanupdelta pacsort pactree
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
@@ -26,9 +26,6 @@ pacsort_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
pactree_SOURCES = pactree.c
pactree_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
-testdb_SOURCES = testdb.c
-testdb_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
-
testpkg_SOURCES = testpkg.c
testpkg_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 4a67fc38..8fe14b08 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -1,7 +1,7 @@
/*
* cleanupdelta.c : return list of unused delta in a given sync database
*
- * Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/util/pacsort.c b/src/util/pacsort.c
index 665f2180..02b9084b 100644
--- a/src/util/pacsort.c
+++ b/src/util/pacsort.c
@@ -1,7 +1,7 @@
/*
* pacsort.c - a sort utility implementing alpm_pkg_vercmp
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -227,6 +227,7 @@ static struct input_t *input_new(const char *path, int pathlen)
in->data = strndup(path, pathlen);
if(in->data == NULL) {
+ free(in);
return NULL;
}
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 14579e42..67f456fe 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -1,7 +1,7 @@
/*
* pactree.c - a simple dependency tree viewer
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/util/testdb.c b/src/util/testdb.c
deleted file mode 100644
index cd8c4d83..00000000
--- a/src/util/testdb.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * testdb.c : Test a pacman local database for validity
- *
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
- * Copyright (c) 2007 by Aaron Griffin <aaronmgriffin@gmail.com>
- *
- * 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/>.
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <dirent.h>
-
-#include <alpm.h>
-#include <alpm_list.h>
-
-alpm_handle_t *handle = NULL;
-
-static void cleanup(int signum)
-{
- if(handle && alpm_release(handle) == -1) {
- fprintf(stderr, "error releasing alpm\n");
- }
-
- exit(signum);
-}
-
-__attribute__((format(printf, 2, 0)))
-static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
-{
- if(strlen(fmt)) {
- switch(level) {
- case ALPM_LOG_ERROR: printf("error: "); break;
- case ALPM_LOG_WARNING: printf("warning: "); break;
- default: return;
- }
- vprintf(fmt, args);
- }
-}
-
-static int check_localdb_files(void)
-{
- struct dirent *ent;
- const char *dbpath;
- char path[4096];
- int ret = 0;
- DIR *dir;
-
- dbpath = alpm_option_get_dbpath(handle);
- snprintf(path, sizeof(path), "%slocal", dbpath);
- if(!(dir = opendir(path))) {
- fprintf(stderr, "error : '%s' : %s\n", path, strerror(errno));
- return 1;
- }
-
- while((ent = readdir(dir)) != NULL) {
- if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0
- || strcmp(ent->d_name, "ALPM_DB_VERSION") == 0) {
- continue;
- }
- /* check for known db files in local database */
- snprintf(path, sizeof(path), "%slocal/%s/desc", dbpath, ent->d_name);
- if(access(path, F_OK)) {
- printf("'%s': description file is missing\n", ent->d_name);
- ret++;
- }
- snprintf(path, sizeof(path), "%slocal/%s/files", dbpath, ent->d_name);
- if(access(path, F_OK)) {
- printf("'%s': file list is missing\n", ent->d_name);
- ret++;
- }
- }
- if(closedir(dir)) {
- fprintf(stderr, "error closing dbpath : %s\n", strerror(errno));
- return 1;
- }
-
- return ret;
-}
-
-static int check_deps(alpm_list_t *pkglist)
-{
- alpm_list_t *data, *i;
- int ret = 0;
- /* check dependencies */
- data = alpm_checkdeps(handle, NULL, NULL, pkglist, 0);
- for(i = data; i; i = alpm_list_next(i)) {
- alpm_depmissing_t *miss = i->data;
- char *depstring = alpm_dep_compute_string(miss->depend);
- printf("missing '%s' dependency for '%s'\n", depstring, miss->target);
- free(depstring);
- ret++;
- }
- FREELIST(data);
- return ret;
-}
-
-static int check_conflicts(alpm_list_t *pkglist)
-{
- alpm_list_t *data, *i;
- int ret = 0;
- /* check conflicts */
- data = alpm_checkconflicts(handle, pkglist);
- for(i = data; i; i = i->next) {
- alpm_conflict_t *conflict = i->data;
- printf("'%s' conflicts with '%s'\n",
- conflict->package1, conflict->package2);
- ret++;
- }
- FREELIST(data);
- return ret;
-}
-
-struct fileitem {
- alpm_file_t *file;
- alpm_pkg_t *pkg;
-};
-
-static int fileitem_cmp(const void *p1, const void *p2)
-{
- const struct fileitem * fi1 = p1;
- const struct fileitem * fi2 = p2;
- return strcmp(fi1->file->name, fi2->file->name);
-}
-
-static int check_filelists(alpm_list_t *pkglist)
-{
- alpm_list_t *i;
- int ret = 0;
- size_t list_size = 4096;
- size_t offset = 0, j;
- struct fileitem *all_files;
- struct fileitem *prev_fileitem = NULL;
-
- all_files = malloc(list_size * sizeof(struct fileitem));
-
- for(i = pkglist; i; i = i->next) {
- alpm_pkg_t *pkg = i->data;
- alpm_filelist_t *filelist = alpm_pkg_get_files(pkg);
- for(j = 0; j < filelist->count; j++) {
- alpm_file_t *file = filelist->files + j;
- /* only add files, not directories, to our big list */
- if(file->name[strlen(file->name) - 1] == '/') {
- continue;
- }
-
- /* do we need to reallocate and grow our array? */
- if(offset >= list_size) {
- struct fileitem *new_files;
- new_files = realloc(all_files, list_size * 2 * sizeof(struct fileitem));
- if(!new_files) {
- free(all_files);
- return 1;
- }
- all_files = new_files;
- list_size *= 2;
- }
-
- /* we can finally add it to the list */
- all_files[offset].file = file;
- all_files[offset].pkg = pkg;
- offset++;
- }
- }
-
- /* now sort the list so we can find duplicates */
- qsort(all_files, offset, sizeof(struct fileitem), fileitem_cmp);
-
- /* do a 'uniq' style check on the list */
- for(j = 0; j < offset; j++) {
- struct fileitem *fileitem = all_files + j;
- if(prev_fileitem && fileitem_cmp(prev_fileitem, fileitem) == 0) {
- printf("file owned by '%s' and '%s': '%s'\n",
- alpm_pkg_get_name(prev_fileitem->pkg),
- alpm_pkg_get_name(fileitem->pkg),
- fileitem->file->name);
- }
- prev_fileitem = fileitem;
- }
-
- free(all_files);
- return ret;
-}
-
-static int check_localdb(void)
-{
- int ret = 0;
- alpm_db_t *db = NULL;
- alpm_list_t *pkglist;
-
- ret = check_localdb_files();
- if(ret) {
- return ret;
- }
-
- db = alpm_get_localdb(handle);
- pkglist = alpm_db_get_pkgcache(db);
- ret += check_deps(pkglist);
- ret += check_conflicts(pkglist);
- ret += check_filelists(pkglist);
- return ret;
-}
-
-static int check_syncdbs(alpm_list_t *dbnames)
-{
- int ret = 0;
- alpm_db_t *db = NULL;
- alpm_list_t *i, *pkglist, *syncpkglist = NULL;
- const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
-
- for(i = dbnames; i; i = alpm_list_next(i)) {
- const char *dbname = i->data;
- db = alpm_register_syncdb(handle, dbname, level);
- if(db == NULL) {
- fprintf(stderr, "error: could not register sync database (%s)\n",
- alpm_strerror(alpm_errno(handle)));
- ret = 1;
- goto cleanup;
- }
- pkglist = alpm_db_get_pkgcache(db);
- syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
- }
- ret += check_deps(syncpkglist);
-
-cleanup:
- alpm_list_free(syncpkglist);
- return ret;
-}
-
-static void usage(void)
-{
- fprintf(stderr, "testdb (pacman) v" PACKAGE_VERSION "\n\n"
- "Test a pacman local database for validity.\n\n"
- "Usage: testdb [options]\n\n"
- " -b <pacman db> : check the local database\n"
- " -b <pacman db> core extra ... : check the listed sync databases\n");
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- int errors = 0;
- alpm_errno_t err;
- const char *dbpath = DBPATH;
- int a = 1;
- alpm_list_t *dbnames = NULL;
-
- while(a < argc) {
- if(strcmp(argv[a], "-b") == 0) {
- if(++a < argc) {
- dbpath = argv[a];
- } else {
- usage();
- }
- } else if(strcmp(argv[a], "-h") == 0 ||
- strcmp(argv[a], "--help") == 0 ) {
- usage();
- } else {
- dbnames = alpm_list_add(dbnames, argv[a]);
- }
- a++;
- }
-
- handle = alpm_initialize(ROOTDIR, dbpath, &err);
- if(!handle) {
- fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerror(err));
- return EXIT_FAILURE;
- }
-
- /* let us get log messages from libalpm */
- alpm_option_set_logcb(handle, output_cb);
-
- if(!dbnames) {
- errors = check_localdb();
- } else {
- errors = check_syncdbs(dbnames);
- alpm_list_free(dbnames);
- }
-
- cleanup(errors > 0);
-}
-
-/* vim: set noet: */
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index cc7d9c2b..bd95a86b 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -1,7 +1,7 @@
/*
* testpkg.c : Test a pacman package for validity
*
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007 by Aaron Griffin <aaronmgriffin@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/util/vercmp.c b/src/util/vercmp.c
index cc445185..561881e0 100644
--- a/src/util/vercmp.c
+++ b/src/util/vercmp.c
@@ -2,7 +2,7 @@
* vercmp.c - Compare package version numbers using pacman's version
* comparison logic
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/pacman/README b/test/pacman/README
index 8d8354ab..6c601b2f 100644
--- a/test/pacman/README
+++ b/test/pacman/README
@@ -310,7 +310,6 @@ its DEPENDS field.
FILE_TYPE=path/to/file|type (possible types: dir, file, link)
FILE_PACNEW=path/to/file
FILE_PACSAVE=path/to/file
- FILE_PACORIG=path/to/file
Example:
FILE_EXIST=etc/test.conf
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py
index 8e87c288..548ccc44 100755
--- a/test/pacman/pactest.py
+++ b/test/pacman/pactest.py
@@ -3,7 +3,7 @@
# pactest : run automated testing on the pacman binary
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index aa14dfff..84a90786 100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py
index 27f44c90..593f0ec5 100644
--- a/test/pacman/pmenv.py
+++ b/test/pacman/pmenv.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Developmet Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index 4d09e1d7..7f96f6ca 100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index e7362d39..31336610 100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index c2336c5d..3bcac86a 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -146,9 +146,6 @@ class pmrule(object):
elif case == "PACNEW":
if not os.path.isfile("%s.pacnew" % filename):
success = 0
- elif case == "PACORIG":
- if not os.path.isfile("%s.pacorig" % filename):
- success = 0
elif case == "PACSAVE":
if not os.path.isfile("%s.pacsave" % filename):
success = 0
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 49919718..c7bda9c1 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/tap.py b/test/pacman/tap.py
index 216bc9f7..520f1e3c 100644
--- a/test/pacman/tap.py
+++ b/test/pacman/tap.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/tests/upgrade015.py b/test/pacman/tests/upgrade015.py
index ea6046cb..64fe2813 100644
--- a/test/pacman/tests/upgrade015.py
+++ b/test/pacman/tests/upgrade015.py
@@ -12,4 +12,3 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy")
self.addrule("FILE_MODIFIED=etc/dummy.conf")
self.addrule("!FILE_PACNEW=etc/dummy.conf")
-self.addrule("!FILE_PACORIG=etc/dummy.conf")
diff --git a/test/pacman/tests/upgrade016.py b/test/pacman/tests/upgrade016.py
index b6b3f3ae..ddf57e8c 100644
--- a/test/pacman/tests/upgrade016.py
+++ b/test/pacman/tests/upgrade016.py
@@ -11,6 +11,5 @@ self.args = "-U --force %s" % p.filename()
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy")
-self.addrule("FILE_MODIFIED=etc/dummy.conf")
-self.addrule("!FILE_PACNEW=etc/dummy.conf")
-self.addrule("FILE_PACORIG=etc/dummy.conf")
+self.addrule("!FILE_MODIFIED=etc/dummy.conf")
+self.addrule("FILE_PACNEW=etc/dummy.conf")
diff --git a/test/pacman/tests/upgrade027.py b/test/pacman/tests/upgrade027.py
index 99087f34..3dd694af 100644
--- a/test/pacman/tests/upgrade027.py
+++ b/test/pacman/tests/upgrade027.py
@@ -18,5 +18,4 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSION=dummy|1.0-2")
self.addrule("FILE_PACNEW=etc/dummy.conf")
self.addrule("!FILE_PACSAVE=etc/dummy.conf")
-self.addrule("!FILE_PACORIG=etc/dummy.conf")
self.addrule("FILE_EXIST=etc/dummy.conf")
diff --git a/test/pacman/tests/upgrade028.py b/test/pacman/tests/upgrade028.py
index 18a10f57..1e31aa31 100644
--- a/test/pacman/tests/upgrade028.py
+++ b/test/pacman/tests/upgrade028.py
@@ -18,5 +18,4 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSION=dummy|1.0-2")
self.addrule("!FILE_PACNEW=etc/dummy.conf")
self.addrule("!FILE_PACSAVE=etc/dummy.conf")
-self.addrule("!FILE_PACORIG=etc/dummy.conf")
self.addrule("FILE_EXIST=etc/dummy.conf")
diff --git a/test/pacman/tests/upgrade029.py b/test/pacman/tests/upgrade029.py
index c308f426..eef5c700 100644
--- a/test/pacman/tests/upgrade029.py
+++ b/test/pacman/tests/upgrade029.py
@@ -20,5 +20,4 @@ self.addrule("PACMAN_RETCODE=1")
self.addrule("PKG_VERSION=dummy|1.0-1")
self.addrule("!FILE_PACNEW=etc/dummy.conf")
self.addrule("!FILE_PACSAVE=etc/dummy.conf")
-self.addrule("!FILE_PACORIG=etc/dummy.conf")
self.addrule("FILE_EXIST=etc/dummy.conf")
diff --git a/test/pacman/util.py b/test/pacman/util.py
index ae96a3b7..2e643cc6 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/scripts/Makefile.am b/test/scripts/Makefile.am
index 8d6bc842..ed1a9511 100644
--- a/test/scripts/Makefile.am
+++ b/test/scripts/Makefile.am
@@ -1,6 +1,7 @@
check_SCRIPTS = \
parseopts_test.sh \
pacman-db-upgrade-v9.py \
+ makepkg-template_test.sh \
human_to_size_test.sh
noinst_SCRIPTS = $(check_SCRIPTS)
diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh
index dfa01f72..6334495f 100755
--- a/test/scripts/human_to_size_test.sh
+++ b/test/scripts/human_to_size_test.sh
@@ -1,82 +1,57 @@
#!/bin/bash
-declare -i testcount=0 fail=0 pass=0 total=15
+source "$(dirname "$0")"/../tap.sh || exit 1
# source the library function
lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh}
if [[ -z $lib || ! -f $lib ]]; then
- printf "Bail out! human_to_size library (%s) could not be located\n" "${lib}"
+ tap_bail "human_to_size library (%s) could not be located" "${lib}"
exit 1
fi
. "$lib"
if ! type -t human_to_size &>/dev/null; then
- printf "Bail out! human_to_size function not found\n"
+ tap_bail "human_to_size function not found"
exit 1
fi
-parse_hts() {
- local input=$1 expected=$2 result
-
- (( ++testcount ))
-
- result=$(human_to_size "$1")
- if [[ $result = "$expected" ]]; then
- (( ++pass ))
- printf "ok %d - %s\n" "$testcount" "$input"
- else
- (( ++fail ))
- printf "not ok %d - %s\n" "$testcount" "$input"
- printf '# [TEST %3s]: FAIL\n' "$testcount"
- printf '# input: %s\n' "$input"
- printf '# output: %s\n' "$result"
- printf '# expected: %s\n' "$expected"
- fi
+tap_parse_hts() {
+ local input=$1 expected=$2
+ tap_is_str "$(human_to_size "$input")" "$expected" "$input"
}
-summarize() {
- if (( !fail )); then
- printf '# All %s tests successful\n\n' "$testcount"
- exit 0
- else
- printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
- exit 1
- fi
-}
-trap 'summarize' EXIT
-
-printf '# Beginning human_to_size tests\n'
+tap_plan 15
-echo "1..$total"
+# tap_parse_hts <input> <expected output>
-# parse_hts <input> <expected output>
+tap_parse_hts '1MiB' 1048576
-parse_hts '1MiB' 1048576
+tap_parse_hts '10XiB' ''
-parse_hts '10XiB' ''
+tap_parse_hts '10 MiB' 10485760
-parse_hts '10 MiB' 10485760
+tap_parse_hts '10 XiB' ''
-parse_hts '10 XiB' ''
+tap_parse_hts '.1 TiB' 109951162778
-parse_hts '.1 TiB' 109951162778
+tap_parse_hts ' -3 KiB ' -3072
-parse_hts ' -3 KiB ' -3072
+tap_parse_hts 'foo3KiB' ''
-parse_hts 'foo3KiB' ''
+tap_parse_hts '3KiBfoo' ''
-parse_hts '3KiBfoo' ''
+tap_parse_hts '3kib' ''
-parse_hts '3kib' ''
+tap_parse_hts '+1KiB' 1024
-parse_hts '+1KiB' 1024
+tap_parse_hts '+1.0 KiB' 1024
-parse_hts '+1.0 KiB' 1024
+tap_parse_hts '1MB' 1000000
-parse_hts '1MB' 1000000
+tap_parse_hts '1M' 1048576
-parse_hts '1M' 1048576
+tap_parse_hts ' 1 G ' 1073741824
-parse_hts ' 1 G ' 1073741824
+tap_parse_hts '1Q' ''
-parse_hts '1Q' ''
+# vim: set noet:
diff --git a/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD
new file mode 100644
index 00000000..02bfadcc
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD
@@ -0,0 +1 @@
+# template input; []³|>=bar;
diff --git a/test/scripts/makepkg-template-tests/invalid-key/testcase-config b/test/scripts/makepkg-template-tests/invalid-key/testcase-config
new file mode 100644
index 00000000..4e4725e2
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-key/testcase-config
@@ -0,0 +1,11 @@
+arguments+=()
+expected_exitcode=255
+
+# set IFS="" if you want trailing new lines, otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+invalid key/value pair
+./makepkg-template-tests/invalid-key/PKGBUILD:1: # template input; []³|>=bar;
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD
new file mode 100644
index 00000000..d0a20c18
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD
@@ -0,0 +1 @@
+# template input;
diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config
new file mode 100644
index 00000000..6bfda327
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config
@@ -0,0 +1,11 @@
+arguments+=()
+expected_exitcode=255
+
+# set IFS="" if you want trailing new lines, otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+invalid template line: can't find template name
+./makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD:1: # template input;
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD
new file mode 100644
index 00000000..645ea371
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD
@@ -0,0 +1,9 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template boom; name=test
+perl Makefile.pl
+make
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config
new file mode 100644
index 00000000..077a85c3
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config
@@ -0,0 +1,11 @@
+arguments+=()
+expected_exitcode=255
+
+# set IFS="" if you want trailing new lines, otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+Unknown template marker 'boom'
+./makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD:5: # template boom; name=test
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD
new file mode 100644
index 00000000..09da2e03
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD
@@ -0,0 +1,15 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module; version=1.0;
+echo "before bla template"
+# template start; name=perl-bla; version=1.2;
+bla bla
+# template end;
+echo "after bla template"
+perl Makefile.pl
+make
+make install
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template
new file mode 100644
index 00000000..b72e7d48
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template
@@ -0,0 +1 @@
+bla bla
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template
new file mode 100644
index 00000000..415025ac
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template
@@ -0,0 +1,6 @@
+echo "before bla template"
+# template input; name=perl-bla
+echo "after bla template"
+perl Makefile.pl
+make
+make install
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template
new file mode 100644
index 00000000..5ad32c3c
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template
@@ -0,0 +1,7 @@
+echo "perl-module version 1.1"
+echo "before bla template"
+# template input; name=perl-bla
+echo "after bla template"
+perl Makefile.pl
+make
+make install
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/testcase-config b/test/scripts/makepkg-template-tests/keep-old-version/testcase-config
new file mode 100644
index 00000000..b9448a08
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/keep-old-version/testcase-config
@@ -0,0 +1,29 @@
+arguments+=()
+expected_exitcode=0
+
+_setup_testcase() {
+ ln -sr "templates/"{perl-bla-1.2.template,perl-bla.template}
+ ln -sr "templates/"{perl-module-1.1.template,perl-module.template}
+}
+
+# set IFS="" if you want trailing new lines, otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module; version=1.0;
+echo "before bla template"
+# template start; name=perl-bla; version=1.2;
+bla bla
+# template end;
+echo "after bla template"
+perl Makefile.pl
+make
+make install
+# template end;
+}
+EOF
diff --git a/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD
new file mode 100644
index 00000000..dbfda1dd
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD
@@ -0,0 +1,7 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module; version=1.0;
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/missing-template-file/testcase-config b/test/scripts/makepkg-template-tests/missing-template-file/testcase-config
new file mode 100644
index 00000000..bdfde40d
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/missing-template-file/testcase-config
@@ -0,0 +1,14 @@
+arguments+=()
+expected_exitcode=2
+
+_setup_testcase() {
+ ln -sr "templates/"{perl-module-1.0.template,perl-module.template}
+}
+
+# set IFS="" if you want trailing new lines, otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+failed to open './makepkg-template-tests/missing-template-file/templates/perl-module-1.0.template': No such file or directory
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD
new file mode 100644
index 00000000..8ee94aca
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD
@@ -0,0 +1,7 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module;
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template
new file mode 100644
index 00000000..f499d252
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template
@@ -0,0 +1 @@
+this should not be included
diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config b/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config
new file mode 100644
index 00000000..c0eabe0d
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config
@@ -0,0 +1,9 @@
+arguments+=()
+expected_exitcode=255
+
+IFS="" read -d '' expected_output <<'EOF'
+Couldn't detect version for template 'perl-module'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD
new file mode 100644
index 00000000..36ed75bb
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD
@@ -0,0 +1,8 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=foo/
+make install
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config b/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config
new file mode 100644
index 00000000..7ea9502c
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config
@@ -0,0 +1,10 @@
+arguments+=()
+expected_exitcode=255
+
+IFS="" read -d '' expected_output <<'EOF'
+invalid chars used in name 'foo/'. allowed: [:alnum:]+_.@-
+./makepkg-template-tests/name-charset-invalid/PKGBUILD:5: # template start; name=foo/
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD
new file mode 100644
index 00000000..ec21cdb4
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD
@@ -0,0 +1,8 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=foo@-_.+a
+make install
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template
new file mode 100644
index 00000000..d0884a6c
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template
@@ -0,0 +1 @@
+42 cookies
diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config b/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config
new file mode 100644
index 00000000..409444a9
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config
@@ -0,0 +1,19 @@
+arguments+=()
+expected_exitcode=0
+
+_setup_testcase() {
+ ln -sr "templates/"{foo\@-_.+a-1.template,foo\@-_.+a.template}
+}
+IFS="" read -d '' expected_output <<'EOF'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=foo@-_.+a; version=1;
+42 cookies
+# template end;
+}
+EOF
diff --git a/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD
new file mode 100644
index 00000000..a4509a1a
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD
@@ -0,0 +1,8 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=template-without_version
+make install
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template b/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template
diff --git a/test/scripts/makepkg-template-tests/template-without-version/testcase-config b/test/scripts/makepkg-template-tests/template-without-version/testcase-config
new file mode 100644
index 00000000..ec04f2fa
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/template-without-version/testcase-config
@@ -0,0 +1,9 @@
+arguments+=()
+expected_exitcode=255
+
+IFS="" read -d '' expected_output <<'EOF'
+Couldn't detect version for template 'template-without_version'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/testcase-config-template b/test/scripts/makepkg-template-tests/testcase-config-template
new file mode 100644
index 00000000..66267d3b
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/testcase-config-template
@@ -0,0 +1,9 @@
+arguments+=()
+expected_exitcode=0
+
+# set IFS="" if you want trailing new line(s), otherwise remove it
+IFS="" read -d '' expected_output <<'EOF'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+EOF
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD
new file mode 100644
index 00000000..e1687cc8
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD
@@ -0,0 +1,7 @@
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module; version=1.0
+# template end;
+}
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template
new file mode 100644
index 00000000..b72e7d48
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template
@@ -0,0 +1 @@
+bla bla
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template
new file mode 100644
index 00000000..415025ac
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template
@@ -0,0 +1,6 @@
+echo "before bla template"
+# template input; name=perl-bla
+echo "after bla template"
+perl Makefile.pl
+make
+make install
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template
new file mode 100644
index 00000000..5ad32c3c
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template
@@ -0,0 +1,7 @@
+echo "perl-module version 1.1"
+echo "before bla template"
+# template input; name=perl-bla
+echo "after bla template"
+perl Makefile.pl
+make
+make install
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config b/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config
new file mode 100644
index 00000000..5956a0a2
--- /dev/null
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config
@@ -0,0 +1,29 @@
+arguments+=(-n)
+expected_exitcode=0
+
+_setup_testcase() {
+ ln -sr "templates/"{perl-bla-1.2.template,perl-bla.template}
+ ln -sr "templates/"{perl-module-1.1.template,perl-module.template}
+}
+
+IFS="" read -d '' expected_output <<'EOF'
+EOF
+
+IFS="" read -d '' expected_result <<'EOF'
+pkgname=foo
+pkgver=1
+
+build() {
+# template start; name=perl-module; version=1.1;
+echo "perl-module version 1.1"
+echo "before bla template"
+# template start; name=perl-bla; version=1.2;
+bla bla
+# template end;
+echo "after bla template"
+perl Makefile.pl
+make
+make install
+# template end;
+}
+EOF
diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh
new file mode 100755
index 00000000..b2531d4a
--- /dev/null
+++ b/test/scripts/makepkg-template_test.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+source "$(dirname "$0")"/../tap.sh || exit 1
+
+script=${1:-${PMTEST_SCRIPT_DIR}makepkg-template}
+
+if ! type -p "$script" &>/dev/null; then
+ tap_bail "makepkg-template executable (%s) could not be located" "${script}"
+ exit 1
+fi
+
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+cp -r "${0%/*}/makepkg-template-tests" "$TMPDIR/makepkg-template-tests"
+
+# normalize paths
+script="$(readlink -f $(type -p "$script"))"
+cd "$TMPDIR"
+testdir="./makepkg-template-tests"
+
+
+total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l)
+if [[ -z "$total" ]]; then
+ tap_bail "unable to determine total number of tests"
+ exit 1
+fi
+tap_plan "$((total*3))"
+
+run_test() {
+ local testcase=$1 exitcode expected_result expected_output
+ local -a arguments
+ local -i expected_exitcode=-1
+
+ [[ -f "$testdir/$testcase/testcase-config" ]] || continue
+ source "$testdir/$testcase/testcase-config"
+
+ mkdir "$TMPDIR/$testcase"
+ touch "$TMPDIR/$testcase/result"
+
+ # work around autotools not putting symlinks into the release tarball
+ [[ -d "$TMPDIR/$testdir/$testcase/templates" ]] || mkdir "$TMPDIR/$testdir/$testcase/templates"
+ if type -t _setup_testcase >/dev/null; then
+ cd "$TMPDIR/$testdir/$testcase"
+ _setup_testcase
+ unset -f _setup_testcase
+ cd "$TMPDIR"
+ fi
+
+ LC_ALL=C "$script" \
+ --template-dir "$testdir/$testcase/templates" \
+ -p "$testdir/$testcase/PKGBUILD" \
+ -o "$TMPDIR/$testcase/result" \
+ &> "$TMPDIR/$testcase/output" "${arguments[@]}"
+ exitcode=$?
+
+ tap_is_int "$exitcode" "$expected_exitcode" "$testcase exitcode"
+ tap_diff "$TMPDIR/$testcase/output" <(printf "%s" "$expected_output") "$testcase output"
+ tap_diff "$TMPDIR/$testcase/result" <(printf "%s" "$expected_result") "$testcase resulting PKGBUILD"
+}
+
+for dir in "$testdir/"*; do
+ if [[ -d "$dir" ]]; then
+ run_test "${dir##*/}"
+ fi
+done
+
+tap_finish
diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh
index 2c055b1b..a8738a4c 100755
--- a/test/scripts/parseopts_test.sh
+++ b/test/scripts/parseopts_test.sh
@@ -1,17 +1,17 @@
#!/bin/bash
-declare -i testcount=0 pass=0 fail=0 total=25
+source "$(dirname "$0")"/../tap.sh || exit 1
# source the library function
lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh}
if [[ -z $lib || ! -f $lib ]]; then
- printf "Bail out! parseopts library ($lib) could not be located\n"
+ tap_bail "parseopts library ($lib) could not be located"
exit 1
fi
. "$lib"
if ! type -t parseopts &>/dev/null; then
- printf "Bail out! parseopts function not found\n"
+ tap_bail "parseopts function not found"
exit 1
fi
@@ -23,120 +23,94 @@ OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean:' 'cleanall' 'nodeps'
'repackage' 'skipinteg' 'sign' 'source' 'syncdeps' 'version' 'config:'
'noconfirm' 'noprogressbar')
-parse() {
+tap_parse() {
local result=$1 tokencount=$2; shift 2
-
- (( ++testcount ))
parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null
- test_result "$result" "$tokencount" "$*" "${OPTRET[@]}"
+ tap_is_int "${#OPTRET[@]}" "$tokencount" "$* - tokencount"
+ tap_is_str "$result" "${OPTRET[*]}" "$* - result"
unset OPTRET
}
-test_result() {
- local result=$1 tokencount=$2 input=$3; shift 3
-
- if [[ $result = "$*" ]] && (( tokencount == $# )); then
- (( ++pass ))
- printf 'ok %d - %s\n' "$testcount" "$input"
- else
- printf 'not ok %d - %s\n' "$testcount" "$input"
- printf '# [TEST %3s]: FAIL\n' "$testcount"
- printf '# input: %s\n' "$input"
- printf '# output: %s (%s tokens)\n' "$*" "$#"
- printf '# expected: %s (%s tokens)\n' "$result" "$tokencount"
- (( ++fail ))
- fi
-}
-
-summarize() {
- if (( !fail )); then
- printf '# All %s tests successful\n\n' "$testcount"
- exit 0
- else
- printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
- exit 1
- fi
-}
-trap 'summarize' EXIT
-
-printf '# Beginning parseopts tests\n'
-
-echo "1..$total"
+tap_plan 50
-# usage: parse <expected result> <token count> test-params...
-# a failed parse will match only the end of options marker '--'
+# usage: tap_parse <expected result> <token count> test-params...
+# a failed tap_parse will match only the end of options marker '--'
# no options
-parse '--' 1
+tap_parse '--' 1
# short options
-parse '-s -r --' 3 -s -r
+tap_parse '-s -r --' 3 -s -r
# short options, no spaces
-parse '-s -r --' 3 -sr
+tap_parse '-s -r --' 3 -sr
# short opt missing an opt arg
-parse '--' 1 -s -p
+tap_parse '--' 1 -s -p
# short opt with an opt arg
-parse '-p PKGBUILD -L --' 4 -p PKGBUILD -L
+tap_parse '-p PKGBUILD -L --' 4 -p PKGBUILD -L
# short opt with an opt arg, no space
-parse '-p PKGBUILD --' 3 -pPKGBUILD
+tap_parse '-p PKGBUILD --' 3 -pPKGBUILD
# valid shortopts as a long opt
-parse '--' 1 --sir
+tap_parse '--' 1 --sir
# long opt with no optarg
-parse '--log --' 2 --log
+tap_parse '--log --' 2 --log
# long opt with missing optarg
-parse '--' 1 -sr --pkg
+tap_parse '--' 1 -sr --pkg
# long opt with optarg
-parse '--pkg foo --' 3 --pkg foo
+tap_parse '--pkg foo --' 3 --pkg foo
# long opt with optarg with whitespace
-parse '--pkg foo bar -- baz' 4 --pkg "foo bar" baz
+tap_parse '--pkg foo bar -- baz' 4 --pkg "foo bar" baz
# long opt with optarg with =
-parse '--pkg foo=bar -- baz' 4 --pkg foo=bar baz
+tap_parse '--pkg foo=bar -- baz' 4 --pkg foo=bar baz
# long opt with explicit optarg
-parse '--pkg bar -- foo baz' 5 foo --pkg=bar baz
+tap_parse '--pkg bar -- foo baz' 5 foo --pkg=bar baz
# long opt with explicit optarg, with whitespace
-parse '--pkg foo bar -- baz' 4 baz --pkg="foo bar"
+tap_parse '--pkg foo bar -- baz' 4 baz --pkg="foo bar"
# long opt with explicit optarg that doesn't take optarg
-parse '--' 1 --force=always -s
+tap_parse '--' 1 --force=always -s
# long opt with explicit optarg with =
-parse '--pkg foo=bar --' 3 --pkg=foo=bar
+tap_parse '--pkg foo=bar --' 3 --pkg=foo=bar
# explicit end of options with options after
-parse '-s -r -- foo bar baz' 6 -s -r -- foo bar baz
+tap_parse '-s -r -- foo bar baz' 6 -s -r -- foo bar baz
# non-option parameters mixed in with options
-parse '-s -r -- foo baz' 5 -s foo baz -r
+tap_parse '-s -r -- foo baz' 5 -s foo baz -r
# optarg with whitespace
-parse '-p foo bar -s --' 4 -p'foo bar' -s
+tap_parse '-p foo bar -s --' 4 -p'foo bar' -s
# non-option parameter with whitespace
-parse '-i -- foo bar' 3 -i 'foo bar'
+tap_parse '-i -- foo bar' 3 -i 'foo bar'
# successful stem match (opt has no arg)
-parse '--nocolor --' 2 --nocol
+tap_parse '--nocolor --' 2 --nocol
# successful stem match (opt has arg)
-parse '--config foo --' 3 --conf foo
+tap_parse '--config foo --' 3 --conf foo
# ambiguous long opt
-parse '--' 1 '--for'
+tap_parse '--' 1 '--for'
# exact match on a possible stem (--force & --forcever)
-parse '--force --' 2 --force
+tap_parse '--force --' 2 --force
# exact match on possible stem (opt has optarg)
-parse '--clean foo --' 3 --clean=foo
+tap_parse '--clean foo --' 3 --clean=foo
+
+tap_finish
+
+# vim: set noet:
diff --git a/test/tap.sh b/test/tap.sh
new file mode 100644
index 00000000..38852691
--- /dev/null
+++ b/test/tap.sh
@@ -0,0 +1,163 @@
+# Copyright 2014 Andrew Gregory <andrew.gregory.8@gmail.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+# Project URL: http://github.com/andrewgregory/tap.sh
+
+declare -i tap_planned=0 tap_run=0 tap_failed=0 tap_passed=0
+declare tap_todo=''
+
+tap_plan() {
+ tap_planned=$1
+ printf "1..%d\n" "$tap_planned"
+}
+
+tap_done_testing() {
+ tap_plan $tap_run
+}
+
+tap_skip_all() {
+ printf "1..0 # SKIP"
+ _tap_print_reason " " "$@"
+ printf "\n"
+}
+
+tap_diag() {
+ if [[ -n $tap_todo ]]; then
+ tap_note "$@"
+ else
+ tap_note "$@" 1>&2
+ fi
+}
+
+tap_note() {
+ printf "# "
+ printf -- "$@"
+ printf "\n"
+}
+
+tap_bail() {
+ printf "Bail out!"
+ _tap_print_reason " " "$@"
+ printf "\n"
+}
+
+tap_finish() {
+ local tap_todo=''
+ if (( tap_planned != tap_run )); then
+ tap_note "Looks like you planned %d tests but ran %d." "$tap_planned" "$tap_run"
+ elif (( tap_planned == tap_run && tap_failed == 0 )); then
+ tap_note "All %d tests successfully run." "$tap_planned"
+ else
+ tap_note "Failed %d of %d tests." "$tap_failed" "$tap_planned"
+ fi
+ (( tap_planned == tap_run && tap_failed == 0 ))
+}
+
+tap_skip() {
+ local -i count="$1"; shift
+ while (( count-- )); do
+ (( tap_run++ ))
+ printf "ok %d # SKIP" "$tap_run"
+ _tap_print_reason " " "$@"
+ printf "\n"
+ done
+}
+
+_tap_print_reason() {
+ local sep="$1"; shift
+ if [[ $# -gt 0 ]]; then
+ printf "%s" "$sep"
+ printf -- "$@"
+ fi
+}
+
+tap_ok() {
+ local ok="$1"; shift
+ (( tap_run++ ))
+ if [[ $ok -eq 0 ]]; then
+ (( tap_passed++ ))
+ printf "ok %d" "$tap_run"
+ else
+ (( tap_failed++ ))
+ printf "not ok %d" "$tap_run"
+ fi
+ _tap_print_reason " - " "$@"
+ if [[ -n $tap_todo ]]; then
+ printf " # TODO %s" "$tap_todo"
+ fi
+ printf "\n"
+ if [[ $ok -ne 0 ]]; then
+ local line func file
+ local -i i=0
+
+ read line func file < <(caller $i)
+ while [[ -n $func && $func == tap_* ]]; do
+ (( i++ ))
+ read line func file < <(caller $i)
+ done
+
+ if [[ -n $file ]]; then
+ file=${file##*/}
+ if [[ -n $tap_todo ]]; then
+ tap_diag " Failed (TODO) test at %s line %d." "${file}" "$line"
+ else
+ tap_diag " Failed test at %s line %d." "${file}" "$line"
+ fi
+ fi
+ fi
+ return $ok
+}
+
+tap_is_str() {
+ local got="$1" expected="$2"; shift 2
+ [[ $got == $expected ]]
+ local ret=$?
+ if ! tap_ok $ret "$@"; then
+ tap_diag " got: '%s'" "$got"
+ tap_diag " expected: '%s'" "$expected"
+ fi
+ return $ret
+}
+
+tap_is_int() {
+ local got="$1" expected="$2"; shift 2
+ [[ $got -eq $expected ]]
+ local ret=$?
+ if ! tap_ok $ret "$@"; then
+ tap_diag " got: '%s'" "$got"
+ tap_diag " expected: '%s'" "$expected"
+ fi
+ return $ret
+}
+
+tap_diff() {
+ local got="$1" expected="$2"; shift 2
+ local output ret
+ output="$(diff -u --label got --label expected "$got" "$expected" 2>&1)"
+ ret=$?
+ if ! tap_ok $ret "$@"; then
+ while IFS= read line; do
+ tap_diag "$line"
+ done <<<"$output"
+ fi
+ return $ret
+}
+
+# vim: ft=sh
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
index 49d6d8ed..3b285b8b 100755
--- a/test/util/pacsorttest.sh
+++ b/test/util/pacsorttest.sh
@@ -2,7 +2,7 @@
#
# pacsorttest - a test suite for pacsort
#
-# Copyright (c) 2013-2014 by Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 by Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011 by Dan McGee <dan@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -18,85 +18,69 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+source "$(dirname "$0")"/../tap.sh || exit 1
+
# default binary if one was not specified as $1
bin=${1:-${PMTEST_UTIL_DIR}pacsort}
-# holds counts of tests
-total=26
-run=0
-failure=0
if ! type -p "$bin" &>/dev/null; then
- echo "Bail out! pacsort binary ($bin) could not be located"
+ tap_bail "pacsort binary ($bin) could not be located"
exit 1
fi
# args:
# runtest input expected test_description optional_opts
-runtest() {
+tap_runtest() {
# run the test
- ((run++))
- out=$(diff -u <(printf "$1" | $bin $4) <(printf "$2"))
- if [[ $? -eq 0 ]]; then
- echo "ok $run - $3"
- else
- ((failure++))
- echo "not ok $run - $3"
- while read line; do
- echo " # $line"
- done <<<"$out"
- fi
+ tap_diff <(printf "$1" | $bin $4) <(printf "$2") "$3"
}
-echo "# Running pacsort tests..."
-
-echo "1..$total"
-
-# BEGIN TESTS
+tap_plan 26
in="1\n2\n3\n4\n"
-runtest $in $in "already ordered"
+tap_runtest $in $in "already ordered"
in="4\n2\n3\n1\n"
ex="1\n2\n3\n4\n"
-runtest $in $ex "easy reordering"
+tap_runtest $in $ex "easy reordering"
in="1\n2\n3\n4"
ex="1\n2\n3\n4\n"
-runtest $in $ex "add trailing newline"
+tap_runtest $in $ex "add trailing newline"
in="1\n2\n4\n3"
ex="1\n2\n3\n4\n"
-runtest $in $ex "add trailing newline"
+tap_runtest $in $ex "add trailing newline"
in="1.0-1\n1.0\n1.0-2\n1.0\n"
-runtest $in $in "stable sort"
+tap_runtest $in $in "stable sort"
in="firefox-18.0-2-x86_64.pkg.tar.xz\nfirefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort" "--files"
+tap_runtest $in $in "filename sort" "--files"
in="firefox-18.0-2\nfirefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with invalid filename" "--files"
+tap_runtest $in $in "filename sort with invalid filename" "--files"
in="firefox-18.0-2-x86_64.pkg.tar.xz\n/path2/firefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort maybe with leading paths" "--files"
+tap_runtest $in $in "filename sort maybe with leading paths" "--files"
in="/path1/firefox-18.0-2-x86_64.pkg.tar.xz\n/path2/firefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with different leading paths" "--files"
+tap_runtest $in $in "filename sort with different leading paths" "--files"
in="/path2/firefox-18.0-2-x86_64.pkg.tar.xz\n/path1/path2/firefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with uneven leading path components" "--files"
+tap_runtest $in $in "filename sort with uneven leading path components" "--files"
in="firefox-18.0-2-i686.pkg.tar.xz\nfirefox-18.0.1-1-x86_64.pkg.tar.gz\n"
-runtest $in $in "filename sort with different extensions" "--files"
+tap_runtest $in $in "filename sort with different extensions" "--files"
in="/packages/dialog-1.2_20131001-1-x86_64.pkg.tar.xz\n/packages/dialog-1:1.2_20130928-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with epoch" "--files"
+tap_runtest $in $in "filename sort with epoch" "--files"
in="/packages/dia-log-1:1.2_20130928-1-x86_64.pkg.tar.xz\n/packages/dialog-1.2_20131001-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with differing package names and epoch" "--files"
+tap_runtest $in $in "filename sort with differing package names and epoch" "--files"
in="/packages/systemd-217-1-x86_64.pkg.tar.xz\n/packages/systemd-sysvcompat-217-1-x86_64.pkg.tar.xz\n"
-runtest $in $in "filename sort with package names as shared substring" "--files"
+tap_runtest $in $in "filename sort with package names as shared substring" "--files"
# generate some long input/expected for the next few tests
declare normal reverse names_normal names_reverse
@@ -109,27 +93,21 @@ for ((i=1; i<600; i++)); do
separator_reverse="${separator_reverse}colA|bogus${i}|$((600 - ${i}))\n"
done
-runtest $normal $normal "really long input"
-runtest $reverse $normal "really long input"
-runtest $reverse $reverse "really long input, reversed" "-r"
-runtest $normal $reverse "really long input, reversed" "-r"
+tap_runtest $normal $normal "really long input"
+tap_runtest $reverse $normal "really long input"
+tap_runtest $reverse $reverse "really long input, reversed" "-r"
+tap_runtest $normal $reverse "really long input, reversed" "-r"
-runtest "$fields" "$fields" "really long input, sort key" "-k3"
-runtest "$fields_reverse" "$fields" "really long input, sort key" "-k3"
-runtest "$fields_reverse" "$fields_reverse" "really long input, sort key, reversed" "-k 3 -r"
-runtest "$fields" "$fields_reverse" "really long input, sort key, reversed" "-k 3 -r"
+tap_runtest "$fields" "$fields" "really long input, sort key" "-k3"
+tap_runtest "$fields_reverse" "$fields" "really long input, sort key" "-k3"
+tap_runtest "$fields_reverse" "$fields_reverse" "really long input, sort key, reversed" "-k 3 -r"
+tap_runtest "$fields" "$fields_reverse" "really long input, sort key, reversed" "-k 3 -r"
-runtest "$separator" "$separator" "really long input, sort key, separator" "-k3 -t|"
-runtest "$separator_reverse" "$separator" "really long input, sort key, separator" "-k3 -t|"
-runtest "$separator_reverse" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
-runtest "$separator" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
+tap_runtest "$separator" "$separator" "really long input, sort key, separator" "-k3 -t|"
+tap_runtest "$separator_reverse" "$separator" "really long input, sort key, separator" "-k3 -t|"
+tap_runtest "$separator_reverse" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
+tap_runtest "$separator" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
-#END TESTS
-
-if [[ $failure -eq 0 ]]; then
- echo "# All $run tests successful"
- exit 0
-fi
+tap_finish
-echo "# $failure of $run tests failed"
-exit 1
+# vim: set noet:
diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh
index 9032cbf9..a5b2727b 100755
--- a/test/util/vercmptest.sh
+++ b/test/util/vercmptest.sh
@@ -2,7 +2,7 @@
#
# vercmptest - a test suite for the vercmp/libalpm program
#
-# Copyright (c) 2009-2014 by Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2009-2015 by Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2008 by Dan McGee <dan@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -18,136 +18,101 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+source "$(dirname "$0")"/../tap.sh || exit 1
+
# default binary if one was not specified as $1
bin=${1:-${PMTEST_UTIL_DIR}vercmp}
-# holds counts of tests
-total=92
-run=0
-failure=0
# use first arg as our binary if specified
if ! type -p "$bin" &>/dev/null; then
- echo "Bail out! vercmp binary ($bin) could not be located"
+ tap_bail "vercmp binary ($bin) could not be located"
exit 1
fi
# args:
-# pass ver1 ver2 ret expected
-pass() {
- echo "ok $run - ver1: $1 ver2: $2 ret: $3"
-}
-
-# args:
-# fail ver1 ver2 ret expected
-fail() {
- echo "not ok $run - test: ver1: $1 ver2: $2 ret: $3 expected: $4"
- ((failure++))
-}
-
-# args:
# runtest ver1 ver2 expected
-runtest() {
- # run the test
- ((run++))
- ret=$($bin $1 $2)
- func='pass'
- [[ -n $ret && $ret -eq $3 ]] || func='fail'
- $func $1 $2 $ret $3
+tap_runtest() {
+ local ver1=$1 ver2=$2 exp=$3
+ tap_is_str "$($bin "$ver1" "$ver2")" "$exp" "$ver1 $ver2"
# and run its mirror case just to be sure
- ((run++))
- reverse=0
- [[ $3 -eq 1 ]] && reverse=-1
- [[ $3 -eq -1 ]] && reverse=1
- ret=$($bin $2 $1)
- func='pass'
- [[ -n $ret && $ret -eq $reverse ]] || func='fail'
- $func $2 $1 $ret $reverse
+ (( exp *= -1 ))
+ tap_is_str "$($bin "$ver2" "$ver1")" "$exp" "$ver2 $ver1"
}
-echo "# Running vercmp tests..."
-
-echo "1..$total"
-
-# BEGIN TESTS
+tap_plan 92
# all similar length, no pkgrel
-runtest 1.5.0 1.5.0 0
-runtest 1.5.1 1.5.0 1
+tap_runtest 1.5.0 1.5.0 0
+tap_runtest 1.5.1 1.5.0 1
# mixed length
-runtest 1.5.1 1.5 1
+tap_runtest 1.5.1 1.5 1
# with pkgrel, simple
-runtest 1.5.0-1 1.5.0-1 0
-runtest 1.5.0-1 1.5.0-2 -1
-runtest 1.5.0-1 1.5.1-1 -1
-runtest 1.5.0-2 1.5.1-1 -1
+tap_runtest 1.5.0-1 1.5.0-1 0
+tap_runtest 1.5.0-1 1.5.0-2 -1
+tap_runtest 1.5.0-1 1.5.1-1 -1
+tap_runtest 1.5.0-2 1.5.1-1 -1
# with pkgrel, mixed lengths
-runtest 1.5-1 1.5.1-1 -1
-runtest 1.5-2 1.5.1-1 -1
-runtest 1.5-2 1.5.1-2 -1
+tap_runtest 1.5-1 1.5.1-1 -1
+tap_runtest 1.5-2 1.5.1-1 -1
+tap_runtest 1.5-2 1.5.1-2 -1
# mixed pkgrel inclusion
-runtest 1.5 1.5-1 0
-runtest 1.5-1 1.5 0
-runtest 1.1-1 1.1 0
-runtest 1.0-1 1.1 -1
-runtest 1.1-1 1.0 1
+tap_runtest 1.5 1.5-1 0
+tap_runtest 1.5-1 1.5 0
+tap_runtest 1.1-1 1.1 0
+tap_runtest 1.0-1 1.1 -1
+tap_runtest 1.1-1 1.0 1
# alphanumeric versions
-runtest 1.5b-1 1.5-1 -1
-runtest 1.5b 1.5 -1
-runtest 1.5b-1 1.5 -1
-runtest 1.5b 1.5.1 -1
+tap_runtest 1.5b-1 1.5-1 -1
+tap_runtest 1.5b 1.5 -1
+tap_runtest 1.5b-1 1.5 -1
+tap_runtest 1.5b 1.5.1 -1
# from the manpage
-runtest 1.0a 1.0alpha -1
-runtest 1.0alpha 1.0b -1
-runtest 1.0b 1.0beta -1
-runtest 1.0beta 1.0rc -1
-runtest 1.0rc 1.0 -1
+tap_runtest 1.0a 1.0alpha -1
+tap_runtest 1.0alpha 1.0b -1
+tap_runtest 1.0b 1.0beta -1
+tap_runtest 1.0beta 1.0rc -1
+tap_runtest 1.0rc 1.0 -1
# going crazy? alpha-dotted versions
-runtest 1.5.a 1.5 1
-runtest 1.5.b 1.5.a 1
-runtest 1.5.1 1.5.b 1
+tap_runtest 1.5.a 1.5 1
+tap_runtest 1.5.b 1.5.a 1
+tap_runtest 1.5.1 1.5.b 1
# alpha dots and dashes
-runtest 1.5.b-1 1.5.b 0
-runtest 1.5-1 1.5.b -1
+tap_runtest 1.5.b-1 1.5.b 0
+tap_runtest 1.5-1 1.5.b -1
# same/similar content, differing separators
-runtest 2.0 2_0 0
-runtest 2.0_a 2_0.a 0
-runtest 2.0a 2.0.a -1
-runtest 2___a 2_a 1
+tap_runtest 2.0 2_0 0
+tap_runtest 2.0_a 2_0.a 0
+tap_runtest 2.0a 2.0.a -1
+tap_runtest 2___a 2_a 1
# epoch included version comparisons
-runtest 0:1.0 0:1.0 0
-runtest 0:1.0 0:1.1 -1
-runtest 1:1.0 0:1.0 1
-runtest 1:1.0 0:1.1 1
-runtest 1:1.0 2:1.1 -1
+tap_runtest 0:1.0 0:1.0 0
+tap_runtest 0:1.0 0:1.1 -1
+tap_runtest 1:1.0 0:1.0 1
+tap_runtest 1:1.0 0:1.1 1
+tap_runtest 1:1.0 2:1.1 -1
# epoch + sometimes present pkgrel
-runtest 1:1.0 0:1.0-1 1
-runtest 1:1.0-1 0:1.1-1 1
+tap_runtest 1:1.0 0:1.0-1 1
+tap_runtest 1:1.0-1 0:1.1-1 1
# epoch included on one version
-runtest 0:1.0 1.0 0
-runtest 0:1.0 1.1 -1
-runtest 0:1.1 1.0 1
-runtest 1:1.0 1.0 1
-runtest 1:1.0 1.1 1
-runtest 1:1.1 1.1 1
-
-#END TESTS
-
-if [[ $failure -eq 0 ]]; then
- echo "# All $run tests successful"
- exit 0
-fi
+tap_runtest 0:1.0 1.0 0
+tap_runtest 0:1.0 1.1 -1
+tap_runtest 0:1.1 1.0 1
+tap_runtest 1:1.0 1.0 1
+tap_runtest 1:1.0 1.1 1
+tap_runtest 1:1.1 1.1 1
+
+tap_finish
-echo "# $failure of $run tests failed"
-exit 1
+# vim: set noet: