summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac53
-rw-r--r--contrib/.gitignore12
-rw-r--r--contrib/Makefile.am113
-rw-r--r--contrib/PKGBUILD.vim320
-rw-r--r--contrib/README41
-rw-r--r--contrib/bacman.sh.in391
-rw-r--r--contrib/checkupdates.sh.in59
-rw-r--r--contrib/doc/.gitignore2
-rw-r--r--contrib/doc/Makefile.am60
l---------contrib/doc/asciidoc.conf1
-rw-r--r--contrib/doc/bacman.8.txt67
l---------contrib/doc/footer.txt1
-rw-r--r--contrib/doc/verify-pacman-repo-db.1.txt60
-rw-r--r--contrib/paccache.sh.in366
-rw-r--r--contrib/pacdiff.sh.in194
-rw-r--r--contrib/paclist.sh.in68
-rw-r--r--contrib/paclog-pkglist.sh.in99
-rw-r--r--contrib/pacscripts.sh.in140
-rw-r--r--contrib/pacsearch.in125
-rw-r--r--contrib/rankmirrors.sh.in234
-rw-r--r--contrib/updpkgsums.sh.in115
-rwxr-xr-xcontrib/verify-pacman-repo-db.pl259
-rw-r--r--contrib/vimprojects25
-rw-r--r--doc/.gitignore1
-rw-r--r--doc/Makefile.am4
-rw-r--r--doc/PKGBUILD.5.txt17
-rw-r--r--doc/index.txt2
-rw-r--r--doc/pacman.8.txt48
-rw-r--r--doc/pacman.conf.5.txt4
-rw-r--r--doc/pactree.8.txt69
-rw-r--r--etc/makepkg.conf.in6
-rw-r--r--lib/libalpm/Makefile.am6
-rw-r--r--lib/libalpm/add.c130
-rw-r--r--lib/libalpm/add.h2
-rw-r--r--lib/libalpm/alpm.c4
-rw-r--r--lib/libalpm/alpm.h57
-rw-r--r--lib/libalpm/alpm_list.c22
-rw-r--r--lib/libalpm/alpm_list.h3
-rw-r--r--lib/libalpm/backup.c2
-rw-r--r--lib/libalpm/backup.h2
-rw-r--r--lib/libalpm/be_local.c56
-rw-r--r--lib/libalpm/be_package.c21
-rw-r--r--lib/libalpm/be_sync.c35
-rw-r--r--lib/libalpm/conflict.c69
-rw-r--r--lib/libalpm/conflict.h2
-rw-r--r--lib/libalpm/db.c28
-rw-r--r--lib/libalpm/db.h18
-rw-r--r--lib/libalpm/delta.c16
-rw-r--r--lib/libalpm/delta.h2
-rw-r--r--lib/libalpm/deps.c106
-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.c70
-rw-r--r--lib/libalpm/dload.h3
-rw-r--r--lib/libalpm/error.c2
-rw-r--r--lib/libalpm/filelist.c17
-rw-r--r--lib/libalpm/filelist.h4
-rw-r--r--lib/libalpm/graph.c2
-rw-r--r--lib/libalpm/graph.h12
-rw-r--r--lib/libalpm/group.c2
-rw-r--r--lib/libalpm/group.h2
-rw-r--r--lib/libalpm/handle.c45
-rw-r--r--lib/libalpm/handle.h10
-rw-r--r--lib/libalpm/hook.c2
-rw-r--r--lib/libalpm/hook.h2
-rw-r--r--lib/libalpm/libalpm.pc.in2
-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.c108
-rw-r--r--lib/libalpm/package.h19
-rw-r--r--lib/libalpm/pkghash.c2
-rw-r--r--lib/libalpm/pkghash.h2
-rw-r--r--lib/libalpm/remove.c15
-rw-r--r--lib/libalpm/remove.h2
-rw-r--r--lib/libalpm/signing.c12
-rw-r--r--lib/libalpm/signing.h2
-rw-r--r--lib/libalpm/sync.c30
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c10
-rw-r--r--lib/libalpm/trans.h8
-rw-r--r--lib/libalpm/util.c89
-rw-r--r--lib/libalpm/util.h6
-rw-r--r--lib/libalpm/version.c2
-rw-r--r--scripts/.gitignore3
-rw-r--r--scripts/Makefile.am99
-rw-r--r--scripts/completion/.gitignore2
-rw-r--r--scripts/completion/bash_completion.in (renamed from contrib/bash_completion.in)0
-rw-r--r--scripts/completion/zsh_completion.in (renamed from contrib/zsh_completion.in)0
-rw-r--r--scripts/libmakepkg/.gitignore3
-rw-r--r--scripts/libmakepkg/integrity.sh.in2
-rw-r--r--scripts/libmakepkg/integrity/generate_checksum.sh.in11
-rw-r--r--scripts/libmakepkg/integrity/generate_signature.sh.in2
-rw-r--r--scripts/libmakepkg/integrity/verify_checksum.sh.in6
-rw-r--r--scripts/libmakepkg/integrity/verify_signature.sh.in131
-rw-r--r--scripts/libmakepkg/lint_package.sh.in6
-rw-r--r--scripts/libmakepkg/lint_package/build_references.sh.in19
-rw-r--r--scripts/libmakepkg/lint_package/dotfiles.sh.in38
-rw-r--r--scripts/libmakepkg/lint_package/file_names.sh.in42
-rw-r--r--scripts/libmakepkg/lint_package/missing_backup.sh.in3
-rw-r--r--scripts/libmakepkg/lint_pkgbuild.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/arch.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/backup.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/changelog.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/epoch.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/install.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/options.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/package_function.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in7
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in6
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/provides.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/source.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/util.sh.in2
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/variable.sh.in2
-rw-r--r--scripts/libmakepkg/source.sh.in2
-rw-r--r--scripts/libmakepkg/source/bzr.sh.in2
-rw-r--r--scripts/libmakepkg/source/file.sh.in2
-rw-r--r--scripts/libmakepkg/source/git.sh.in13
-rw-r--r--scripts/libmakepkg/source/hg.sh.in2
-rw-r--r--scripts/libmakepkg/source/local.sh.in2
-rw-r--r--scripts/libmakepkg/source/svn.sh.in2
-rw-r--r--scripts/libmakepkg/srcinfo.sh.in2
-rw-r--r--scripts/libmakepkg/tidy.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/docs.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/emptydirs.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/libtool.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/purge.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/staticlibs.sh.in2
-rw-r--r--scripts/libmakepkg/tidy/strip.sh.in27
-rw-r--r--scripts/libmakepkg/tidy/zipman.sh.in2
-rw-r--r--scripts/libmakepkg/util.sh.in2
-rw-r--r--scripts/libmakepkg/util/message.sh.in (renamed from scripts/libmakepkg/util/message.sh)2
-rw-r--r--scripts/libmakepkg/util/option.sh.in (renamed from scripts/libmakepkg/util/option.sh)2
-rw-r--r--scripts/libmakepkg/util/parseopts.sh.in (renamed from scripts/library/parseopts.sh)50
-rw-r--r--scripts/libmakepkg/util/pkgbuild.sh.in2
-rw-r--r--scripts/libmakepkg/util/source.sh.in29
-rw-r--r--scripts/libmakepkg/util/util.sh.in (renamed from scripts/libmakepkg/util/util.sh)2
-rw-r--r--scripts/library/README20
-rwxr-xr-xscripts/makepkg-template.pl.in4
-rw-r--r--scripts/makepkg.sh.in190
-rw-r--r--scripts/pacman-db-upgrade.sh.in9
-rw-r--r--scripts/pacman-key.sh.in11
-rw-r--r--scripts/pacman-optimize.sh.in189
-rw-r--r--scripts/pkgdelta.sh.in11
-rw-r--r--scripts/po/POTFILES.in7
-rw-r--r--scripts/repo-add.sh.in28
-rw-r--r--scripts/wrapper.sh.in (renamed from scripts/makepkg-wrapper.sh.in)6
-rw-r--r--src/common/ini.c11
-rw-r--r--src/common/ini.h2
-rw-r--r--src/common/util-common.c2
-rw-r--r--src/common/util-common.h2
-rw-r--r--src/pacman/Makefile.am5
-rw-r--r--src/pacman/callback.c2
-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.c25
-rw-r--r--src/pacman/conf.h32
-rw-r--r--src/pacman/database.c16
-rw-r--r--src/pacman/deptest.c2
-rw-r--r--src/pacman/files.c2
-rw-r--r--src/pacman/package.c4
-rw-r--r--src/pacman/package.h2
-rw-r--r--src/pacman/pacman.c103
-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/sighandler.c2
-rw-r--r--src/pacman/sighandler.h2
-rw-r--r--src/pacman/sync.c13
-rw-r--r--src/pacman/upgrade.c10
-rw-r--r--src/pacman/util.c7
-rw-r--r--src/pacman/util.h5
-rw-r--r--src/util/.gitignore4
-rw-r--r--src/util/Makefile.am8
-rw-r--r--src/util/cleanupdelta.c6
-rw-r--r--src/util/pacsort.c552
-rw-r--r--src/util/pactree.c510
-rw-r--r--src/util/testpkg.c6
-rw-r--r--src/util/vercmp.c2
-rwxr-xr-xtest/pacman/pactest.py43
-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.py2
-rw-r--r--test/pacman/pmtest.py2
-rw-r--r--test/pacman/tap.py2
-rw-r--r--test/pacman/tests/TESTS7
-rw-r--r--test/pacman/tests/dbonly-extracted-files.py16
-rw-r--r--test/pacman/tests/file-conflict-with-installed-pkg.py17
-rw-r--r--test/pacman/tests/overwrite-files-match-negated.py13
-rw-r--r--test/pacman/tests/overwrite-files-match.py13
-rw-r--r--test/pacman/tests/overwrite-files-nonmatch.py13
-rw-r--r--test/pacman/tests/remove-directory-replaced-with-symlink.py16
-rw-r--r--test/pacman/tests/symlink-replace-with-dir.py18
-rw-r--r--test/pacman/util.py2
-rwxr-xr-xtest/scripts/parseopts_test.sh2
-rw-r--r--test/util/Makefile.am1
-rwxr-xr-xtest/util/pacsorttest.sh129
-rwxr-xr-xtest/util/vercmptest.sh2
-rw-r--r--valgrind.supp4
208 files changed, 1626 insertions, 5122 deletions
diff --git a/Makefile.am b/Makefile.am
index a676878e..67ffc6b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@ if WANT_DOC
SUBDIRS += doc
endif
-DIST_SUBDIRS = $(SUBDIRS) contrib src/common
+DIST_SUBDIRS = $(SUBDIRS) src/common
ACLOCAL_AMFLAGS = -I m4 --install
AM_MAKEFLAGS = --no-print-directory
@@ -30,7 +30,6 @@ 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
include $(top_srcdir)/test/pacman/tests/TESTS
@@ -39,7 +38,8 @@ 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;
+ PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR; \
+ PMTEST_LIBMAKEPKG_DIR=$(top_builddir)/scripts/libmakepkg/; export PMTEST_LIBMAKEPKG_DIR;
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
diff --git a/configure.ac b/configure.ac
index ae017d1d..57f068d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,10 +120,11 @@ AC_ARG_WITH(ldconfig,
[set the full path to ldconfig]),
[LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig])
-# Help line for using OpenSSL
-AC_ARG_WITH(openssl,
- AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]),
- [], [with_openssl=check])
+# Help line for selecting a crypto library
+AC_ARG_WITH(crypto,
+ AS_HELP_STRING([--with-crypto={openssl|nettle}],
+ [select crypto implementation @<:@default=openssl@:>@]),
+ [with_crypto=$withval], [with_crypto=openssl])
# Help line for using gpgme
AC_ARG_WITH(gpgme,
@@ -220,19 +221,25 @@ PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], ,
# Check for OpenSSL
have_openssl=no
-if test "x$with_openssl" != "xno"; then
+have_nettle=no
+if test "x$with_crypto" = "xnettle"; then
+ PKG_CHECK_MODULES(NETTLE, [nettle],
+ [AC_DEFINE(HAVE_LIBNETTLE, 1, [Define whether to use nettle]) have_nettle=yes], have_nettle=no)
+ if test "x$have_nettle" = xno -a "x$with_crypto" = xnettle; then
+ AC_MSG_ERROR([*** nettle support requested but libraries not found])
+ fi
+else if test "x$with_crypto" = "xopenssl"; then
PKG_CHECK_MODULES(LIBSSL, [libcrypto],
[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no)
- if test "x$have_openssl" = xno -a "x$with_openssl" = xyes; then
+ if test "x$have_openssl" = xno; then
AC_MSG_ERROR([*** openssl support requested but libraries not found])
fi
+else
+ AC_MSG_ERROR([*** unknown crypto support library requested - $with_crypto])
fi
-AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
-
-# Ensure one library for generating checksums is present
-if test "$have_openssl" != "yes"; then
- AC_MSG_ERROR([*** no library for checksum generation found])
fi
+AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
+AM_CONDITIONAL(HAVE_LIBNETTLE, [test "$have_nettle" = "yes"])
# Check for libcurl
have_libcurl=no
@@ -331,12 +338,11 @@ AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h>
GCC_VISIBILITY_CC
# Host-dependant definitions
+DEFAULT_DUFLAGS=" -sk --apparent-size"
INODECMD="stat -c '%i %n'"
OWNERCMD="stat -c '%u:%g'"
MODECMD="stat -c '%a'"
-SIZECMD="stat -c %s"
SEDINPLACE="sed --follow-symlinks -i"
-DUFLAGS="-sk --apparent-size"
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
@@ -345,36 +351,37 @@ case "${host_os}" in
INODECMD="stat -f '%i %N'"
OWNERCMD="stat -f '%u:%g'"
MODECMD="stat -f '%Lp'"
- SIZECMD="stat -f %z"
SEDINPLACE="sed -i \"\""
- DUFLAGS="-sk"
+ DEFAULT_DUFLAGS=" -sk"
;;
darwin*)
host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %N'"
OWNERCMD="/usr/bin/stat -f '%u:%g'"
MODECMD="/usr/bin/stat -f '%Lp'"
- SIZECMD="/usr/bin/stat -f %z"
SEDINPLACE="/usr/bin/sed -i ''"
- DUFLAGS="-sk"
+ DEFAULT_DUFLAGS=" -sk"
STRIP_BINARIES=""
STRIP_SHARED="-S"
STRIP_STATIC="-S"
;;
esac
-
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
AC_SUBST(INODECMD)
AC_SUBST(OWNERCMD)
AC_SUBST(MODECMD)
-AC_SUBST(SIZECMD)
AC_SUBST(SEDINPLACE)
-AC_SUBST(DUFLAGS)
AC_SUBST(STRIP_BINARIES)
AC_SUBST(STRIP_SHARED)
AC_SUBST(STRIP_STATIC)
+# Flags for du
+if test "${DUFLAGS+set}" != "set"; then
+ DUFLAGS="${DEFAULT_DUFLAGS}"
+fi
+AC_ARG_VAR(DUFLAGS, [flags for du, overriding the default])
+
# Variables plugged into makepkg.conf
CARCH="${host%%-*}"
CHOST="${host}"
@@ -523,8 +530,6 @@ test/pacman/Makefile
test/pacman/tests/Makefile
test/scripts/Makefile
test/util/Makefile
-contrib/Makefile
-contrib/doc/Makefile
Makefile
])
AC_OUTPUT
@@ -544,7 +549,7 @@ ${PACKAGE_NAME}:
compiler : ${CC}
preprocessor flags : ${CPPFLAGS}
compiler flags : ${WARNING_CFLAGS} ${CFLAGS}
- library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
+ library flags : ${LIBS} ${LIBSSL_LIBS} ${NETTLE_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
linker flags : ${LDFLAGS}
Architecture : ${CARCH}
@@ -552,7 +557,6 @@ ${PACKAGE_NAME}:
File inode command : ${INODECMD}
File owner command : ${OWNERCMD}
File mode command : ${MODECMD}
- Filesize command : ${SIZECMD}
In-place sed command : ${SEDINPLACE}
libalpm version : ${LIB_VERSION}
@@ -571,6 +575,7 @@ ${PACKAGE_NAME}:
Use libcurl : ${have_libcurl}
Use GPGME : ${have_gpgme}
Use OpenSSL : ${have_openssl}
+ Use nettle : ${have_nettle}
Run make in doc/ dir : ${wantdoc} ${asciidoc}
Doxygen support : ${usedoxygen}
debug support : ${debug}
diff --git a/contrib/.gitignore b/contrib/.gitignore
deleted file mode 100644
index 8a32b419..00000000
--- a/contrib/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-bacman
-bash_completion
-checkupdates
-paccache
-pacdiff
-paclist
-paclog-pkglist
-pacscripts
-pacsearch
-rankmirrors
-updpkgsums
-zsh_completion
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
deleted file mode 100644
index 897cd856..00000000
--- a/contrib/Makefile.am
+++ /dev/null
@@ -1,113 +0,0 @@
-# enforce that all scripts have a --help and --version option
-AUTOMAKE_OPTIONS = std-options
-SUBDIRS=
-if WANT_DOC
-SUBDIRS += doc
-endif
-
-DIST_SUBDIRS = $(SUBDIRS)
-
-bin_SCRIPTS = \
- $(OURSCRIPTS)
-
-BASHSCRIPTS = \
- bacman \
- checkupdates \
- paccache \
- pacdiff \
- paclist \
- paclog-pkglist \
- pacscripts \
- rankmirrors \
- updpkgsums
-
-OTHERSCRIPTS = \
- pacsearch
-
-OURSCRIPTS = \
- $(BASHSCRIPTS) \
- $(OTHERSCRIPTS)
-
-OURFILES = \
- bash_completion \
- zsh_completion
-
-EXTRA_DIST = \
- PKGBUILD.vim \
- bacman.sh.in \
- bash_completion.in \
- checkupdates.sh.in \
- paccache.sh.in \
- paclog-pkglist.sh.in \
- pacdiff.sh.in \
- paclist.sh.in \
- pacscripts.sh.in \
- pacsearch.in \
- rankmirrors.sh.in \
- updpkgsums.sh.in \
- vimprojects \
- zsh_completion.in \
- README
-
-# Files that should be removed, but which Automake does not know.
-MOSTLYCLEANFILES = $(OURSCRIPTS) $(OURFILES) *.tmp
-
-if USE_GIT_VERSION
-GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
-REAL_PACKAGE_VERSION = $(GIT_VERSION)
-else
-REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
-endif
-
-edit = sed \
- -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
- -e 's|@localstatedir[@]|$(localstatedir)|g' \
- -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
- -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
- -e 's|@SCRIPTNAME[@]|$@|g' \
- -e '1s|!/bin/bash|!$(BASH_SHELL)|g'
-
-$(OTHERSCRIPTS): Makefile
- $(AM_V_at)$(RM) $@ $@.tmp
- $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
- $(AM_V_at)chmod +x,a-w $@.tmp
- $(AM_V_at)mv $@.tmp $@
-
-$(BASHSCRIPTS): Makefile
- $(AM_V_at)$(RM) $@
- $(AM_V_GEN)test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@
- $(AM_V_at)chmod +x,a-w $@
- @$(BASH_SHELL) -O extglob -n $@
-
-$(OURFILES): Makefile
- $(AM_V_at)$(RM) $@ $@.tmp
- $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
- $(AM_V_at)chmod a-w $@.tmp
- $(AM_V_at)mv $@.tmp $@
-
-all-am: $(OURSCRIPTS) $(OURFILES)
-
-install-data-local:
- $(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
- $(INSTALL_DATA) bash_completion $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
- $(MKDIR_P) $(DESTDIR)$(datarootdir)/zsh/site-functions/
- $(INSTALL_DATA) zsh_completion $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
-
-uninstall-local:
- $(RM) $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
- $(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
-
-bacman: $(srcdir)/bacman.sh.in
-bash_completion: $(srcdir)/bash_completion.in
-checkupdates: $(srcdir)/checkupdates.sh.in
-paccache: $(srcdir)/paccache.sh.in $(top_srcdir)/scripts/library/parseopts.sh $(top_srcdir)/scripts/library/size_to_human.sh
-pacdiff: $(srcdir)/pacdiff.sh.in
-paclist: $(srcdir)/paclist.sh.in
-paclog-pkglist: $(srcdir)/paclog-pkglist.sh.in
-pacscripts: $(srcdir)/pacscripts.sh.in
-pacsearch: $(srcdir)/pacsearch.in
-rankmirrors: $(srcdir)/rankmirrors.sh.in
-updpkgsums: $(srcdir)/updpkgsums.sh.in
-zsh_completion: $(srcdir)/zsh_completion.in
-
-# vim:set noet:
diff --git a/contrib/PKGBUILD.vim b/contrib/PKGBUILD.vim
deleted file mode 100644
index 110bbc71..00000000
--- a/contrib/PKGBUILD.vim
+++ /dev/null
@@ -1,320 +0,0 @@
-" Vim syntax file
-" Language: PKGBUILD
-" Maintainer: Alessio 'mOLOk' Bolognino <themolok at gmail.com>
-" Last Change: 2007/05/08
-" Version Info: PKGBUILD-0.2 (colorphobic)
-
-" For version 5.x: Clear all syntax items
-" For version 6.x: Quit when a syntax file was already loaded
-if version < 600
- syntax clear
-elseif exists("b:current_syntax")
- finish
-endif
-
-let b:main_syntax = "sh"
-let b:is_bash = 1
-runtime! syntax/sh.vim
-
-" case on
-syn case match
-
-" pkgname
-" FIXME if '=' is in pkgname/pkgver, it highlights whole string, not just '='
-syn keyword pb_k_pkgname pkgname contained
-syn match pbValidPkgname /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgname
-syn match pbIllegalPkgname /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
-syn match pbPkgnameGroup /^pkgname=.*/ contains=pbIllegalPkgname,pb_k_pkgname,shDoubleQuote,shSingleQuote
-
-" pkgbase
-" FIXME if '=' is in pkgbase/pkgname/pkgver, it highlights whole string, not just '='
-syn keyword pb_k_pkgbase pkgbase contained
-syn match pbValidPkgbase /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgbase
-syn match pbIllegalPkgbase /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
-syn match pbPkgbaseGroup /^pkgbase=.*/ contains=pbIllegalPkgbase,pb_k_pkgbase,shDoubleQuote,shSingleQuote
-
-" pkgver
-syn keyword pb_k_pkgver pkgver contained
-syn match pbValidPkgver /\([[:alnum:]]\|\.\|+\|_\)/ contained contains=pbIllegalPkgver
-syn match pbIllegalPkgver /[^[:alnum:]+=\.\_]\|=.*=/ contained
-syn match pbPkgverGroup /^pkgver=.*/ contains=pbIllegalPkgver,pbValidPkgver,pb_k_pkgver,shDoubleQuote,shSingleQuote
-
-" pkgrel
-syn keyword pb_k_pkgrel pkgrel contained
-syn match pbValidPkgrel /[[:digit:]]*/ contained contains=pbIllegalPkgrel
-syn match pbIllegalPkgrel /[^[:digit:]=]\|=.*=/ contained
-syn match pbPkgrelGroup /^pkgrel=.*/ contains=pbIllegalPkgrel,pbValidPkgrel,pb_k_pkgrel,shDoubleQuote,shSingleQuote
-
-" pkgdesc
-syn keyword pb_k_desc pkgdesc contained
-" 90 chars: 80 for description, 8 for pkgdesc and 2 for ''
-syn match pbIllegalPkgdesc /.\{90,}\|=['"]\?.*['" ]\+[iI][sS] [aA]/ contained contains=pbPkgdescSign
-syn match pbValidPkgdesc /[^='"]\.\{,80}/ contained contains=pbIllegalPkgdesc
-syn match pbPkgdescGroup /^pkgdesc=.*/ contains=pbIllegalPkgdesc,pb_k_desc,pbValidPkgdesc,shDoubleQuote,shSingleQuote
-syn match pbPkgdescSign /[='"]/ contained
-
-" epoch
-syn keyword pb_k_epoch epoch contained
-syn match pbValidEpoch /[[:digit:]]*/ contained contains=pbIllegalEpoch
-syn match pbIllegalEpoch /[^[:digit:]=]\|=.*=/ contained
-syn match pbEpochGroup /^epoch=.*/ contains=pbIllegalEpoch,pbValidEpoch,pb_k_epoch,shDoubleQuote,shSingleQuote
-
-" url
-syn keyword pb_k_url url contained
-syn match pbValidUrl /['"]*\(https\|http\|ftp\)\:\/.*\.\+.*/ contained
-
-syn match pbIllegalUrl /[^=]/ contained contains=pbValidUrl
-syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubleQuote,shSingleQuote
-
-" license
-syn keyword pb_k_license license contained
-" echo $(pacman -Ql licenses | grep '/usr/share/licenses/common/' | cut -d'/' -f6 | sort -u)
-syn keyword pbLicense AGPL AGPL3 Apache APACHE Artistic2.0 CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PerlArtistic PHP PSF RUBY W3C ZPL contained
-" special cases from https://wiki.archlinux.org/index.php/Arch_Packaging_Standards
-syn keyword pbLicenseSpecial BSD MIT ZLIB Python contained
-syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained
-syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicenseSpecial,pbLicense
-syn region pbLicenseGroup start=/^license=(/ end=/)/ contains=pb_k_license,pbLicenseCustom,pbLicenseSpecial,pbLicense,pbIllegalLicense
-
-" backup
-syn keyword pb_k_backup backup contained
-syn match pbValidBackup /\.\?[[:alpha:]]*\/[[:alnum:]\{\}+._$-]*]*/ contained
-syn region pbBackupGroup start=/^backup=(/ end=/)/ contains=pb_k_backup,pbValidBackup,shDoubleQuote,shSingleQuote
-
-" arch
-syn keyword pb_k_arch arch contained
-syn keyword pbArch i686 x86_64 ppc any contained
-syn match pbIllegalArch /[^='"() ]/ contained contains=pbArch
-syn region pbArchGroup start=/^arch=(/ end=/)/ contains=pb_k_arch,pbArch,pbIllegalArch
-
-" groups
-syn keyword pb_k_groups groups contained
-syn match pbValidGroups /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbGroupsGroup start=/^groups=(/ end=/)/ contains=pb_k_groups,pbValidGroups,shDoubleQuote,shSingleQuote
-
-" depends
-syn keyword pb_k_depends depends contained
-syn match pbValidDepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbDependsGroup start=/^depends=(/ end=/)/ contains=pb_k_depends,pbValidDepends,shDoubleQuote,shSingleQuote
-
-" makedepends
-syn keyword pb_k_makedepends makedepends contained
-syn match pbValidMakedepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbMakedependsGroup start=/^makedepends=(/ end=/)/ contains=pb_k_makedepends,pbValidMakedepends,shDoubleQuote,shSingleQuote
-
-" optdepends
-syn keyword pb_k_optdepends optdepends contained
-syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote
-
-" checkdepends
-syn keyword pb_k_ckdepends checkdepends contained
-syn match pbValidCkdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbCkdependsGroup start=/^checkdepends=(/ end=/)/ contains=pb_k_ckdepends,pbValidCkdepends,shDoubleQuote,shSingleQuote
-
-" conflicts
-syn keyword pb_k_conflicts conflicts contained
-syn match pbValidConflicts /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbConflictsGroup start=/^conflicts=(/ end=/)/ contains=pb_k_conflicts,pbValidConflicts,shDoubleQuote,shSingleQuote
-
-" provides
-syn keyword pb_k_provides provides contained
-syn match pbValidProvides /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbProvidesGroup start=/^provides=(/ end=/)/ contains=pb_k_provides,pbValidProvides,shDoubleQuote,shSingleQuote
-
-" replaces
-syn keyword pb_k_replaces replaces contained
-syn match pbValidReplaces /\([[:alnum:]]\|+\|-\|_\)*/ contained
-syn region pbReplacesGroup start=/^replaces=(/ end=/)/ contains=pb_k_replaces,pbValidReplaces,shDoubleQuote,shSingleQuote
-
-" install
-" XXX remove install from bashStatement, fix strange bug
-syn clear bashStatement
-syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch
-
-syn keyword pb_k_install install contained
-syn match pbValidInstall /\([[:alnum:]]\|\$\|+\|-\|_\)*\.install/ contained
-syn match pbIllegalInstall /[^=]/ contained contains=pbValidInstall
-syn match pbInstallGroup /^install=.*/ contains=pb_k_install,pbValidInstall,pbIllegalInstall,shDeref,shDoubleQuote,shSingleQuote
-
-" changelog
-syn keyword pb_k_changelog changelog contained
-syn match pbValidChangelog /\([[:alnum:]]\|\$\|+\|-\|_\)*/ contained
-syn match pbIllegalChangelog /[^=]/ contained contains=pbValidChangelog
-syn match pbChangelogGroup /^changelog=.*/ contains=pb_k_changelog,pbValidChangelog,pbIllegalChangelog,shDeref,shDoubleQuote,shSingleQuote
-
-" source:
-" XXX remove source from shStatement, fix strange bug
-syn clear shStatement
-syn keyword shStatement xxx wait getopts return autoload whence printf true popd nohup enable r trap readonly fc fg kill ulimit umask disown stop pushd read history logout times local exit test pwd time eval integer suspend dirs shopt hash false newgrp bg print jobs continue functions exec help cd break unalias chdir type shift builtin let bind
-
-syn keyword pb_k_source source contained
-syn match pbIllegalSource /\(http\|ftp\|https\).*\.\+\(dl\|download.\?\)\.\(sourceforge\|sf\).net/
-syn region pbSourceGroup start=/^source=(/ end=/)/ contains=pb_k_source,pbIllegalSource,shNumber,shDoubleQuote,shSingleQuote,pbDerefEmulation
-syn match pbDerefEmulation /\$[{]\?[[:alnum:]_]*[}]\?/ contained
-hi def link pbDerefEmulation PreProc
-
-" md5sums
-syn keyword pb_k_md5sums md5sums contained
-syn match pbIllegalMd5sums /[^='"()\/ ]/ contained contains=pbValidMd5sums
-syn match pbValidMd5sums /\x\{32\}/ contained
-syn region pbMd5sumsGroup start=/^md5sums/ end=/)/ contains=pb_k_md5sums,pbMd5Quotes,pbMd5Hash,pbIllegalMd5sums keepend
-syn match pbMd5Quotes /'.*'\|".*"/ contained contains=pbMd5Hash,pbIllegalMd5sums
-syn match pbMd5Hash /\x\+/ contained contains=pbValidMd5sums
-hi def link pbMd5Quotes Keyword
-hi def link pbMd5Hash Error
-hi def link pbValidMd5sums Number
-
-" sha1sums
-syn keyword pb_k_sha1sums sha1sums contained
-syn match pbIllegalSha1sums /[^='"()\/ ]/ contained contains=pbValidSha1sums
-syn match pbValidSha1sums /\x\{40\}/ contained
-syn region pbSha1sumsGroup start=/^sha1sums/ end=/)/ contains=pb_k_sha1sums,pbSha1Quotes,pbSha1Hash,pbIllegalSha1sums keepend
-syn match pbSha1Quotes /'.*'\|".*"/ contained contains=pbSha1Hash,pbIllegalSha1sums
-syn match pbSha1Hash /\x\+/ contained contains=pbValidSha1sums
-hi def link pbSha1Quotes Keyword
-hi def link pbSha1Hash Error
-hi def link pbValidSha1sums Number
-
-" sha256sums
-syn keyword pb_k_sha256sums sha256sums contained
-syn match pbIllegalSha256sums /[^='"()\/ ]/ contained contains=pbValidSha256sums
-syn match pbValidSha256sums /\x\{64\}/ contained
-syn region pbSha256sumsGroup start=/^sha256sums/ end=/)/ contains=pb_k_sha256sums,pbSha256Quotes,pbSha256Hash,pbIllegalSha256sums keepend
-syn match pbSha256Quotes /'.*'\|".*"/ contained contains=pbSha256Hash,pbIllegalSha256sums
-syn match pbSha256Hash /\x\+/ contained contains=pbValidSha256sums
-hi def link pbSha256Quotes Keyword
-hi def link pbSha256Hash Error
-hi def link pbValidSha256sums Number
-
-" sha384sums
-syn keyword pb_k_sha384sums sha384sums contained
-syn match pbIllegalSha384sums /[^='"()\/ ]/ contained contains=pbValidSha384sums
-syn match pbValidSha384sums /\x\{96\}/ contained
-syn region pbSha384sumsGroup start=/^sha384sums/ end=/)/ contains=pb_k_sha384sums,pbSha384Quotes,pbSha384Hash,pbIllegalSha384sums keepend
-syn match pbSha384Quotes /'.*'\|".*"/ contained contains=pbSha384Hash,pbIllegalSha384sums
-syn match pbSha384Hash /\x\+/ contained contains=pbValidSha384sums
-hi def link pbSha384Quotes Keyword
-hi def link pbSha384Hash Error
-hi def link pbValidSha384sums Number
-
-" sha512sums
-syn keyword pb_k_sha512sums sha512sums contained
-syn match pbIllegalSha512sums /[^='"()\/ ]/ contained contains=pbValidSha512sums
-syn match pbValidSha512sums /\x\{128\}/ contained
-syn region pbSha512sumsGroup start=/^sha512sums/ end=/)/ contains=pb_k_sha512sums,pbSha512Quotes,pbSha512Hash,pbIllegalSha512sums keepend
-syn match pbSha512Quotes /'.*'\|".*"/ contained contains=pbSha512Hash,pbIllegalSha512sums
-syn match pbSha512Hash /\x\+/ contained contains=pbValidSha512sums
-hi def link pbSha512Quotes Keyword
-hi def link pbSha512Hash Error
-hi def link pbValidSha512sums Number
-
-" options
-syn keyword pb_k_options options contained
-syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|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
-syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions
-
-" noextract
-syn match pbNoextract /[[:alnum:]+._${}-]\+/ contained
-syn keyword pb_k_noextract noextract contained
-syn region pbNoextractGroup start=/^noextract=(/ end=/)/ contains=pb_k_noextract,pbNoextract,shDoubleQuote,shSingleQuote
-
-" comments
-syn keyword pb_k_maintainer Maintainer Contributor contained
-syn match pbMaintainerGroup /Maintainer.*/ contains=pbMaintainer contained
-
-syn match pbDate /[0-9]\{4}\/[0-9]\{2}\/[0-9]\{2}/ contained
-
-syn cluster pbCommentGroup contains=pbTodo,pb_k_maintainer,pbMaintainerGroup,pbDate
-syn keyword pbTodo contained COMBAK FIXME TODO XXX
-syn match pbComment "^#.*$" contains=@pbCommentGroup
-syn match pbComment "[^0-9]#.*$" contains=@pbCommentGroup
-
-" quotes are handled by sh.vim
-
-hi def link pbComment Comment
-hi def link pbTodo Todo
-
-hi def link pbIllegalPkgname Error
-hi def link pb_k_pkgname pbKeywords
-
-hi def link pbIllegalPkgbase Error
-hi def link pb_k_pkgbase pbKeywords
-
-hi def link pbIllegalPkgver Error
-hi def link pb_k_pkgver pbKeywords
-
-hi def link pbIllegalPkgrel Error
-hi def link pb_k_pkgrel pbKeywords
-
-hi def link pbIllegalPkgdesc Error
-hi def link pb_k_desc pbKeywords
-
-hi def link pbIllegalEpoch Error
-hi def link pb_k_epoch pbKeywords
-
-hi def link pbIllegalUrl Error
-hi def link pb_k_url pbKeywords
-
-hi def link pb_k_license pbKeywords
-hi def link pbIllegalLicense Error
-
-hi def link pb_k_backup pbKeywords
-
-hi def link pb_k_arch pbKeywords
-hi def link pbIllegalArch Error
-
-hi def link pb_k_groups pbKeywords
-hi def link pb_k_makedepends pbKeywords
-hi def link pb_k_optdepends pbKeywords
-hi def link pb_k_ckdepends pbKeywords
-hi def link pb_k_depends pbKeywords
-hi def link pb_k_replaces pbKeywords
-hi def link pb_k_conflicts pbKeywords
-hi def link pb_k_provides pbKeywords
-
-hi def link pbIllegalInstall Error
-hi def link pb_k_install pbKeywords
-
-hi def link pbIllegalChangelog Error
-hi def link pb_k_changelog pbKeywords
-
-hi def link pb_k_source pbKeywords
-hi def link pbIllegalSource Error
-
-hi def link pb_k_md5sums pbKeywords
-hi def link pbIllegalMd5sums Error
-
-hi def link pb_k_sha1sums pbKeywords
-hi def link pbIllegalSha1sums Error
-
-hi def link pb_k_sha256sums pbKeywords
-hi def link pbIllegalSha256sums Error
-
-hi def link pb_k_sha384sums pbKeywords
-hi def link pbIllegalSha384sums Error
-
-hi def link pb_k_sha512sums pbKeywords
-hi def link pbIllegalSha512sums Error
-
-hi def link pb_k_options pbKeywords
-hi def link pbOptionsDeprec Todo
-hi def link pbIllegalOption Error
-
-hi def link pb_k_noextract pbKeywords
-hi def link pbNoextract Normal
-
-hi def link pb_k_maintainer pbKeywords
-
-hi def link pbKeywords Keyword
-
-hi def link pbDate Special
-
-"syntax include @SHELL syntax/sh.vim
-"syntax region BUILD start=/^build()/ end=/^}/ contains=@SHELL
-"let b:current_syntax = "PKGBUILD"
-
-" vim: ft=vim
diff --git a/contrib/README b/contrib/README
deleted file mode 100644
index befd3c1d..00000000
--- a/contrib/README
+++ /dev/null
@@ -1,41 +0,0 @@
-Here is a brief description of the files included in this directory:
-
-PKGBUILD.vim - a vim/gvim syntax file for PKGBUILDs. Colors known variable
-names, highlights common errors such as invalid characters in pkgname or
-pkgver, etc.
-
-bacman - regenerate a pacman package based on installed files and the pacman
-database entries. Useful for reuse, or possible config file extension.
-
-bash_completion - a bash completion script for pacman, install in
-/etc/bash_completion.d/ for use (but rename to something descriptive!).
-
-checkupdates - print a list of pending updates without touching the system
-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/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,
-for instance.
-
-paclog-pkglist - lists currently installs packages based pacman's log.
-
-pacscripts - tries to print out the {pre,post}_{install,remove,upgrade}
-scripts of a given package.
-
-pacsearch - a colorized search combining both -Ss and -Qs output. Installed
-packages are easily identified with a *** and local-only packages are also
-listed.
-
-rankmirrors - ranks pacman mirrors by their connection and opening speed.
-
-updpkgsums - performs an in place update of the checksums in a PKGBUILD.
-
-vimprojects - a project file for the vim project plugin.
-
-zsh_completion - a zsh completion script, install (with a rename) to
-/usr/share/zsh/site-functions/.
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
deleted file mode 100644
index 39fbe99c..00000000
--- a/contrib/bacman.sh.in
+++ /dev/null
@@ -1,391 +0,0 @@
-#!/bin/bash
-#
-# bacman: recreate a package from a running system
-# This script rebuilds an already installed package using metadata
-# stored into the pacman database and system files
-#
-# Copyright (c) 2008 locci <carlocci_at_gmail_dot_com>
-# Copyright (c) 2008-2016 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/>.
-#
-
-shopt -s extglob
-shopt -s nullglob
-
-declare -r myname='bacman'
-declare -r myver='@PACKAGE_VERSION@'
-USE_COLOR='y'
-INCLUDE_PACNEW='n'
-QUIET=0
-# Required for fakeroot because options are shifted off the array.
-ARGS=("$@")
-
-m4_include(../scripts/library/output_format.sh)
-m4_include(../scripts/library/parseopts.sh)
-
-# Lazy recursive clean up of temporary dirs
-work_dir_root="${TMPDIR:-/tmp}/bacman"
-clean_up() {
- rm -rf "$work_dir_root".*
- echo
- exit
-}
-# Trap termination signals
-trap clean_up SIGHUP SIGINT SIGTERM
-
-# Print usage information
-usage() {
- printf "%s (pacman) %s\n" "$myname" "$myver"
- echo
- printf -- "$(gettext "Recreate packages using pacman's database and system files")\n"
- echo
- printf -- "$(gettext "Usage: %s [options] <package(s)>")\n" "$0"
- echo
- printf -- "$(gettext "Options:")\n"
- printf -- "$(gettext " -h, --help Show this help message and exit")\n"
- printf -- "$(gettext " -q, --quiet Silence most of the status reporting")\n"
- printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\n"
- printf -- "$(gettext " -o, --out <dir> Write output to specified directory (instead of \$PKGDEST)")\n"
- printf -- "$(gettext " --pacnew Package .pacnew files")\n"
- echo
- printf -- "$(gettext "Examples:")"
- printf -- " %s linux-headers\n" "$myname"
- printf -- " %s -o ~/packages libarchive\n" "$myname"
- printf -- " %s --nocolor --pacnew gzip make binutils\n" "$myname"
- printf -- " %s \$(pacman -Qq)\n" "$myname"
- echo
-}
-
-# Print version information
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
- echo 'Copyright (C) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>'
-}
-
-
-# Printing the usage information takes precedence over every other parameter
-for option in "$@"; do
- [[ $option == "-h" || $option == "--help" ]] && usage && exit 0
-done
-
-# Parse arguments
-OPT_SHORT='o:qmv'
-OPT_LONG=('out:' 'quiet' 'nocolor' 'pacnew' 'version')
-if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
- usage
- exit 1
-fi
-set -- "${OPTRET[@]}"
-unset OPT_SHORT OPT_LONG OPTRET
-
-while :; do
- case "$1" in
- -o|--out)
- pkg_dest=$2
- [[ ! -d "$2" ]] && echo -e "The directory \e[39;1m$2\e[0m does not exist!" && exit 3
- shift ;;
- -q|--quiet)
- QUIET=1 ;;
- -m|--nocolor)
- USE_COLOR='n' ;;
- --pacnew)
- INCLUDE_PACNEW='y' ;;
- -v|--version)
- version
- exit 0 ;;
- --)
- shift
- break 2 ;;
- esac
- shift
-done
-
-# Configure colored output
-m4_include(../scripts/library/term_colors.sh)
-
-# Retrieve the list of packages to be assembled and break if none was specified
-pkg_list=($*)
-if [[ ${#pkg_list[@]} == 0 ]]; then
- usage
- exit 1
-fi
-
-# Run with fake root privileges if EUID is not root
-if (( EUID )); then
- if [[ -f /usr/bin/fakeroot ]]; then
- msg "Entering fakeroot environment"
- export INFAKEROOT="1"
- /usr/bin/fakeroot -u -- "$0" "${ARGS[@]}"
- exit $?
- else
- warning "installing fakeroot or running $myname as root is required to"
- plain " preserve the ownership permissions of files in some packages\n"
- fi
-fi
-
-# Source environmental variables and specify fallbacks
-if [[ ! -r @sysconfdir@/pacman.conf ]]; then
- error "unable to read @sysconfdir@/pacman.conf"
- exit 1
-fi
-eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
-pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
-if [[ ! -r @sysconfdir@/makepkg.conf ]]; then
- error "unable to read @sysconfdir@/makepkg.conf"
- exit 1
-fi
-source "@sysconfdir@/makepkg.conf"
-if [[ -r ~/.makepkg.conf ]]; then
- source ~/.makepkg.conf
-fi
-PKGDEST="${PKGDEST:-$PWD}"
-pkg_dest="${pkg_dest:-$PKGDEST}"
-pkg_pkger="${PACKAGER:-'Unknown Packager'}"
-
-# Check for an existing database
-if [[ ! -d $pac_db ]]; then
- error "pacman database directory ${pac_db} not found"
- exit 1
-fi
-
-# Assemble a single package: $1 = pkgname
-fakebuild() {
- pkg_name="$1"
- pkg_dir=("$pac_db/$pkg_name"-+([^-])-+([^-]))
- pkg_namver=("${pkg_dir[@]##*/}")
-
- # Checks database for specified package
- if (( ${#pkg_dir[@]} != 1 )); then
- error "%d entries for package %s found in pacman database" \
- ${#pkg_dir[@]} "${pkg_name}"
- msg2 "%s" "${pkg_dir[@]}"
- exit 1
- fi
- if [[ ! -d $pkg_dir ]]; then
- error "package %s is found in pacman database," "${pkg_name}"
- plain " but '%s' is not a directory" "${pkg_dir}"
- exit 1
- fi
-
- # Create working directory
- msg "Package: ${pkg_namver}"
- work_dir=$(mktemp -d "${work_dir_root}.XXXXXXXXXX")
- cd "$work_dir" || exit 1
-
- # Assemble list of files which belong to the package and tar them
- msg2 "Copying package files..."
-
- while read i; do
- if [[ -z $i ]]; then
- continue
- fi
-
- if [[ $i == %+([A-Z])% ]]; then
- current=$i
- continue
- fi
-
- case "$current" in
- %FILES%)
- local_file="/$i"
- package_file="$work_dir/$i"
-
- if [[ ! -e $local_file ]]; then
- warning "package file $local_file is missing"
- continue
- fi
- ;;
-
- %BACKUP%)
- # Get the MD5 checksum.
- original_md5="${i##*$'\t'}"
- # Strip the md5sum after the tab.
- i="${i%$'\t'*}"
- local_file="/$i.pacnew"
- package_file="$work_dir/$i"
-
- # Include unmodified .pacnew files.
- local_md5="$(md5sum "$local_file" | cut -d' ' -f1)"
- if [[ $INCLUDE_PACNEW == 'n' ]] \
- || [[ ! -e $local_file ]] \
- || [[ $local_md5 != $original_md5 ]]; then
- # Warn about modified files.
- local_md5="$(md5sum "/$i" | cut -d' ' -f1)"
- if [[ $local_md5 != $original_md5 ]]; then
- warning "package file /$i has been modified"
- fi
- # Let the normal file be included in the %FILES% list.
- continue
- fi
- ;;
-
- *)
- continue
- ;;
- esac
-
- # Tar files
- ret=0
- bsdtar -cnf - -s'/.pacnew$//' "$local_file" 2> /dev/null | bsdtar -xpf - 2> /dev/null
- # Workaround to bsdtar not reporting a missing file as an error
- if ! [[ -e $package_file || -L $package_file ]]; then
- error "unable to add $local_file to the package"
- plain " If your user does not have permission to read this file, then"
- plain " you will need to run $myname as root."
- rm -rf "$work_dir"
- exit 1
- fi
- done < "$pkg_dir"/files
-
- ret=$?
- if (( ret )); then
- rm -rf "$work_dir"
- exit 1
- fi
-
- # Calculate package size
- pkg_size=$(du -sk | awk '{print $1 * 1024}')
-
- # Reconstruct .PKGINFO from database
- # TODO adopt makepkg's write_pkginfo() into this or scripts/library
- msg2 "Generating .PKGINFO metadata..."
- echo "# Generated by $myname $myver" > .PKGINFO
- if [[ $INFAKEROOT == "1" ]]; then
- echo "# Using $(fakeroot -v)" >> .PKGINFO
- fi
- echo "# $(LC_ALL=C date)" >> .PKGINFO
- echo "#" >> .PKGINFO
- while read i; do
- if [[ -z $i ]]; then
- continue;
- fi
- if [[ $i == %+([A-Z])% ]]; then
- current=$i
- continue
- fi
-
- case "$current" in
- # desc
- %NAME%)
- echo "pkgname = $i" >> .PKGINFO
- ;;
- %VERSION%)
- echo "pkgver = $i" >> .PKGINFO
- ;;
- %DESC%)
- echo "pkgdesc = $i" >> .PKGINFO
- ;;
- %URL%)
- echo "url = $i" >> .PKGINFO
- ;;
- %LICENSE%)
- echo "license = $i" >> .PKGINFO
- ;;
- %ARCH%)
- echo "arch = $i" >> .PKGINFO
- pkg_arch="$i"
- ;;
- %BUILDDATE%)
- echo "builddate = $(date -u "+%s")" >> .PKGINFO
- ;;
- %PACKAGER%)
- echo "packager = $pkg_pkger" >> .PKGINFO
- ;;
- %SIZE%)
- echo "size = $pkg_size" >> .PKGINFO
- ;;
- %GROUPS%)
- echo "group = $i" >> .PKGINFO
- ;;
- %REPLACES%)
- echo "replaces = $i" >> .PKGINFO
- ;;
- %DEPENDS%)
- echo "depend = $i" >> .PKGINFO
- ;;
- %OPTDEPENDS%)
- echo "optdepend = $i" >> .PKGINFO
- ;;
- %CONFLICTS%)
- echo "conflict = $i" >> .PKGINFO
- ;;
- %PROVIDES%)
- echo "provides = $i" >> .PKGINFO
- ;;
- %BACKUP%)
- # Strip the md5sum after the tab
- echo "backup = ${i%%$'\t'*}" >> .PKGINFO
- ;;
- esac
- done < <(cat "$pkg_dir"/{desc,files})
-
- comp_files=".PKGINFO"
-
- # Add instal file if present
- if [[ -f $pkg_dir/install ]]; then
- cp "$pkg_dir/install" "$work_dir/.INSTALL"
- comp_files+=" .INSTALL"
- fi
- if [[ -f $pkg_dir/changelog ]]; then
- cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
- comp_files+=" .CHANGELOG"
- fi
-
- # Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL
- chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
- chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
-
- # Generate the package
- msg2 "Generating the package..."
-
- pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
- ret=0
-
- # Move compressed package to destination
- # TODO: Maybe this can be set globally for robustness
- shopt -s -o pipefail
- bsdtar -cf - $comp_files * |
- case "$PKGEXT" in
- *tar.gz) gzip -c -f -n ;;
- *tar.bz2) bzip2 -c -f ;;
- *tar.xz) xz -c -z - ;;
- *tar.Z) compress -c -f ;;
- *tar) cat ;;
- *) warning "'%s' is not a valid archive extension." \
- "$PKGEXT"; cat ;;
- esac > "${pkg_file}"; ret=$?
-
- # Evaluate return code
- if (( ret )); then
- error "Unable to write package to $pkg_dest"
- plain " Maybe the disk is full or you do not have write access"
- rm -rf "$work_dir"
- exit 1
- fi
-
- # Clean up working directory
- rm -rf "$work_dir"
-}
-
-
-for PKG in ${pkg_list[@]}; do
- fakebuild $PKG
-done
-msg "Done."
-
-exit 0
-
-# vim: set noet:
diff --git a/contrib/checkupdates.sh.in b/contrib/checkupdates.sh.in
deleted file mode 100644
index ff62891b..00000000
--- a/contrib/checkupdates.sh.in
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# checkupdates: Safely print a list of pending updates.
-#
-# Copyright (c) 2013 Kyle Keen <keenerd@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/>.
-#
-
-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
- echo "Safely print a list of pending updates"
- echo
- echo "Usage: ${myname}"
- echo
- echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.'
- 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
-
-trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT
-
-DBPath="${DBPath:-@localstatedir@/lib/pacman/}"
-eval $(awk -F' *= *' '$1 ~ /DBPath/ { print $1 "=" $2 }' @sysconfdir@/pacman.conf)
-
-mkdir -p "$CHECKUPDATES_DB"
-ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
-fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null
-pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
-
-exit 0
-
-# vim: set noet:
diff --git a/contrib/doc/.gitignore b/contrib/doc/.gitignore
deleted file mode 100644
index 3ab20353..00000000
--- a/contrib/doc/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-verify-pacman-repo-db.1
-bacman.8
diff --git a/contrib/doc/Makefile.am b/contrib/doc/Makefile.am
deleted file mode 100644
index d5725b1e..00000000
--- a/contrib/doc/Makefile.am
+++ /dev/null
@@ -1,60 +0,0 @@
-# We have to do some funny stuff here with the manpages. In order to ensure
-# a dist tarball doesn't get put out there without manpages, we keep those
-# files listed in EXTRA_DIST no matter what. However, we only add them to
-# man_MANS if --enable-asciidoc and/or --enable-doxygen are used.
-
-ASCIIDOC_MANS = \
- verify-pacman-repo-db.1 \
- bacman.8
-
-EXTRA_DIST = \
- asciidoc.conf \
- footer.txt \
- verify-pacman-repo-db.1.txt \
- bacman.8.txt \
- $(ASCIIDOC_MANS)
-
-# Files that should be removed, but which Automake does not know.
-MOSTLYCLEANFILES = *.xml $(ASCIIDOC_MANS)
-
-# Ensure manpages are fresh when building a dist tarball
-dist-hook:
- $(MAKE) $(AM_MAKEFLAGS) clean
- $(MAKE) $(AM_MAKEFLAGS) all
-
-if USE_GIT_VERSION
-GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
-REAL_PACKAGE_VERSION = $(GIT_VERSION)
-else
-REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
-endif
-
-man_MANS =
-dist_man_MANS = $(ASCIIDOC_MANS)
-
-pkgdatadir = ${datadir}/${PACKAGE}
-
-ASCIIDOC_OPTS = \
- -f $(srcdir)/asciidoc.conf \
- -a pacman_version="$(REAL_PACKAGE_VERSION)" \
- -a pacman_date="`date +%Y-%m-%d`" \
- -a pkgdatadir=$(pkgdatadir) \
- -a localstatedir=$(localstatedir) \
- -a sysconfdir=$(sysconfdir) \
- -a datarootdir=$(datarootdir)
-
-A2X_OPTS = \
- --no-xmllint \
- -d manpage \
- -f manpage \
- --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
-
-# These rules are due to the includes and files of the asciidoc text
-$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile.am
- $(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@" $(srcdir)/$@.txt
-
-# Dependency rules
-verify-pacman-repo-db.1: verify-pacman-repo-db.1.txt
-bacman.8: bacman.8.txt
-
-# vim:set noet:
diff --git a/contrib/doc/asciidoc.conf b/contrib/doc/asciidoc.conf
deleted file mode 120000
index ff9653d3..00000000
--- a/contrib/doc/asciidoc.conf
+++ /dev/null
@@ -1 +0,0 @@
-../../doc/asciidoc.conf \ No newline at end of file
diff --git a/contrib/doc/bacman.8.txt b/contrib/doc/bacman.8.txt
deleted file mode 100644
index dc5af481..00000000
--- a/contrib/doc/bacman.8.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-/////
-vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
-/////
-bacman(8)
-==========
-
-Name
-----
-bacman - recreate installed packages
-
-
-Synopsis
---------
-'bacman' [options] <package(s)>
-
-
-Description
------------
-'bacman' was designed to reassemble installed packages using pacman's database
-and system files.
-It is useful for regenerating an installed package that you are unable to
-download that is also not available in your package cache.
-
-'bacman' honors packaging settings from linkman:makepkg.conf[8].
-
-
-Options
--------
-*-h, \--help*::
- Display usage information.
-
-*-q, \--quiet*::
- Silence most of the status reporting.
-
-*-m, \--nocolor*::
- Disable colored output.
-
-*-o, \--out <dir>*::
- Write the assembled package(s) to the specified directory.
-
-*\--pacnew*::
- Package `.pacnew` files if available instead of the (possibly modified)
- versions in place on the filesystem.
-
-
-Examples
---------
-
-The following are example usages of the 'bacman' utility:
-
-$ bacman linux-headers::
- Recreate the package ``linux-headers''.
-
-$ bacman gzip make binutils -o ~/packages::
- Assemble the packages ``gzip'', ``make'', and ``binutils'' and place
- the packages in the ``~/packages'' directory.
-
-$ bacman --nocolor --pacnew -o ~/backup $(pacman -Qq)::
- Assemble all currently installed packages using ``.pacnew'' whenever
- available, suppress colored output and place the desired packages in
- the ``~/backup''. directory
-
-See Also
---------
-linkman:makepkg[8], linkman:pacman[8]
-
-include::footer.txt[]
diff --git a/contrib/doc/footer.txt b/contrib/doc/footer.txt
deleted file mode 120000
index 9dd4bae1..00000000
--- a/contrib/doc/footer.txt
+++ /dev/null
@@ -1 +0,0 @@
-../../doc/footer.txt \ No newline at end of file
diff --git a/contrib/doc/verify-pacman-repo-db.1.txt b/contrib/doc/verify-pacman-repo-db.1.txt
deleted file mode 100644
index 62564b8f..00000000
--- a/contrib/doc/verify-pacman-repo-db.1.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-/////
-vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
-/////
-verify-pacman-repo-db(1)
-========================
-
-Name
-----
-verify-pacman-repo-db - package repository verification utility
-
-
-Synopsis
---------
-'verify-pacman-repo-db' [options]
-
-
-Description
------------
-'verify-pacman-repo-db' looks at a pacman repo database and verifies its
-content with the actual package files. The database is expected to be in
-the same directory as the packages (or symlinks to the packages).
-
-The following properties are verified for each package in the database:
-
- - existence of the package file
- - file size
- - MD5 and SHA256 checksum (--checksum)
-
-Options
--------
-*-h, \--help*::
- Output a short help message.
-
-*\--debug*::
- Enable debug output.
-
-*-c, \--checksum*::
- Verify checksums of packages. Note that this means all packages files will
- be read from disk. Otherwise only metadata is compared which does not
- require to read package file contents.
-
-*-t, \--threads* <number>::
- Use 'number' threads to verify packages. Note that each thread may use up
- to approximately 128MiB of memory. Default: 1
-
-Notes
------
-
-This script does intentionally not use any ALPM libraries. The format is simple
-enough to be parsed and this way we might just detect more problems because the
-libalpm parsing code might also have bugs. We also stay much more portable
-which might be good for people that want to check a db, but don't actually have
-pacman installed.
-
-
-See Also
---------
-linkman:repo-add[8]
-
-include::footer.txt[]
diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
deleted file mode 100644
index 02fae527..00000000
--- a/contrib/paccache.sh.in
+++ /dev/null
@@ -1,366 +0,0 @@
-#!/bin/bash
-#
-# pacache - flexible pacman cache cleaning
-#
-# Copyright (C) 2011 Dave Reisner <dreisner@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/>.
-
-
-shopt -s extglob
-
-declare -r myname='paccache'
-declare -r myver='@PACKAGE_VERSION@'
-
-declare -a cachedirs=() candidates=() cmdopts=() whitelist=() blacklist=()
-declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
-declare delim=$'\n' keep=3 movedir= scanarch=
-
-QUIET=0
-USE_COLOR='y'
-
-m4_include(../scripts/library/output_format.sh)
-m4_include(../scripts/library/parseopts.sh)
-
-die() {
- error "$@"
- exit 1
-}
-
-get_cachedir_from_config() {
- local key value
-
- while IFS=$'= \t' read -r key value _; do
- if [[ $key = CacheDir ]]; then
- echo "$value"
- return 0
- fi
- done <"$1"
-
- return 1
-}
-
-# reads a list of files on stdin and prints out deletion candidates
-pkgfilter() {
- # there's whitelist and blacklist parameters passed to this
- # script after the block of awk.
-
- awk -v keep="$1" -v scanarch="$2" '
- function basename(str) {
- sub(".*/", "", str);
- return str;
- }
-
- function parse_filename(filename, parts, count, i, pkgname, arch) {
-
- count = split(basename(filename), parts, "-")
-
- i = 1
- pkgname = parts[i++]
- while (i <= count - 3) {
- pkgname = pkgname "-" parts[i++]
- }
-
- arch = substr(parts[count], 1, index(parts[count], ".") - 1)
-
- # filter on whitelist or blacklist
- if (wlen && !whitelist[pkgname]) return
- if (blen && blacklist[pkgname]) return
-
- if ("" == packages[pkgname,arch]) {
- packages[pkgname,arch] = filename
- } else {
- packages[pkgname,arch] = packages[pkgname,arch] SUBSEP filename
- }
- }
-
- BEGIN {
- # create whitelist
- wlen = ARGV[1]; delete ARGV[1]
- for (i = 2; i < 2 + wlen; i++) {
- whitelist[ARGV[i]] = 1
- delete ARGV[i]
- }
-
- # create blacklist
- blen = ARGV[i]; delete ARGV[i]
- while (i++ < ARGC) {
- blacklist[ARGV[i]] = 1
- delete ARGV[i]
- }
-
- # read package filenames
- while (getline < "/dev/stdin") {
- parse_filename($0)
- }
-
- for (pkglist in packages) {
- # idx[1,2] = idx[pkgname,arch]
- split(pkglist, idx, SUBSEP)
-
- # enforce architecture match if specified
- if (!scanarch || scanarch == idx[2]) {
- count = split(packages[idx[1], idx[2]], pkgs, SUBSEP)
- for(i = 1; i <= count - keep; i++) {
- print pkgs[i]
- }
- }
- }
- }' "${@:3}"
-}
-
-m4_include(../scripts/library/size_to_human.sh)
-
-runcmd() {
- if (( needsroot && EUID != 0 )); then
- msg "Privilege escalation required"
- if sudo -v &>/dev/null && sudo -l &>/dev/null; then
- sudo "$@"
- else
- die 'Unable to escalate privileges using sudo'
- fi
- else
- "$@"
- fi
-}
-
-summarize() {
- (( QUIET )) && return
-
- local -i filecount=$1; shift
- local seenarch= seen= arch= name=
- local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*'
-
- if (( delete )); then
- printf -v output 'finished: %d packages removed' "$filecount"
- elif (( move )); then
- printf -v output "finished: %d packages moved to '%s'" "$filecount" "$movedir"
- elif (( dryrun )); then
- if (( verbose )); then
- msg "Candidate packages:"
- while read -r pkg; do
- if (( verbose >= 3 )); then
- [[ $pkg =~ $pkg_re ]] && name=${BASH_REMATCH[1]} arch=${BASH_REMATCH[2]}
- if [[ -z $seen || $seenarch != "$arch" || $seen != "$name" ]]; then
- seen=$name seenarch=$arch
- printf '%s (%s):\n' "${name##*/}" "$arch"
- fi
- printf ' %s\n' "${pkg##*/}"
- elif (( verbose >= 2 )); then
- printf "%s$delim" "$pkg"
- else
- printf "%s$delim" "${pkg##*/}"
- fi
- done < <(printf '%s\n' "$@" | pacsort --files)
- fi
- printf -v output 'finished dry run: %d candidates' "$filecount"
- fi
-
- echo
- msg "$output (disk space saved: %s)" "$(size_to_human "$totalsaved")"
-}
-
-usage() {
- cat <<EOF
-${myname} (pacman) v${myver}
-
-A flexible pacman cache cleaning utility.
-
-Usage: ${myname} <operation> [options] [targets...]
-
- Operations:
- -d, --dryrun perform a dry run, only finding candidate packages.
- -m, --move <dir> move candidate packages to "dir".
- -r, --remove remove candidate packages.
-
- Options:
- -a, --arch <arch> scan for "arch" (default: all architectures).
- -c, --cachedir <dir> scan "dir" for packages. can be used more than once.
- (default: read from @sysconfdir@/pacman.conf).
- -f, --force apply force to mv(1) and rm(1) operations.
- -h, --help display this help message and exit.
- -i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify
- "-" to read package names from stdin, newline-
- delimited.
- -k, --keep <num> keep "num" of each package in the cache (default: 3).
- --nocolor remove color from output.
- -q, --quiet minimize output
- -u, --uninstalled target uninstalled packages.
- -v, --verbose increase verbosity. specify up to 3 times.
- -z, --null use null delimiters for candidate names (only with -v
- and -vv).
-
-EOF
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
-}
-
-OPT_SHORT=':a:c:dfhi:k:m:qrsuVvz'
-OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
- 'nocolor' 'quiet' 'remove' 'uninstalled' 'version' 'verbose' 'null')
-
-if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
- exit 1
-fi
-set -- "${OPTRET[@]}"
-unset OPT_SHORT OPT_LONG OPTRET
-
-while :; do
- case $1 in
- -a|--arch)
- scanarch=$2
- shift ;;
- -c|--cachedir)
- cachedirs+=("$2")
- shift ;;
- -d|--dryrun)
- dryrun=1 ;;
- -f|--force)
- cmdopts=(-f) ;;
- -h|--help)
- usage
- exit 0 ;;
- -i|--ignore)
- if [[ $2 = '-' ]]; then
- [[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign
- else
- IFS=',' read -r -a ign <<< "$2"
- fi
- blacklist+=("${ign[@]}")
- unset i ign
- shift ;;
- -k|--keep)
- keep=$2
- if [[ -z $keep || -n ${keep//[0-9]/} ]]; then
- die 'argument to option -k must be a non-negative integer'
- else
- keep=$(( 10#$keep ))
- fi
- shift ;;
- -m|--move)
- move=1 movedir=$2
- shift ;;
- --nocolor)
- USE_COLOR='n' ;;
- -q|--quiet)
- QUIET=1 ;;
- -r|--remove)
- delete=1 ;;
- -u|--uninstalled)
- IFS=$'\n' read -r -d '' -a ign < <(pacman -Qq)
- # pacman -Qq may exit with an error, thus making ign an empty array
- (( ${#ign[@]} )) || die 'failed to retrieve the list of installed packages'
- blacklist+=("${ign[@]}")
- unset ign ;;
- -V|--version)
- version
- exit 0 ;;
- -v|--verbose)
- (( ++verbose )) ;;
- -z|--null)
- delim='\0' ;;
- --)
- shift
- break 2 ;;
- esac
- shift
-done
-
-m4_include(../scripts/library/term_colors.sh)
-
-# setting default cachedir
-if [[ -z $cachedirs ]]; then
- if cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf"); then
- cachedirs=("$cachedir")
- else
- cachedirs=("${cachedirs[@]:-@localstatedir@/cache/pacman/pkg}")
- fi
-fi
-
-# remaining args are a whitelist
-whitelist=("$@")
-
-# sanity checks
-case $(( dryrun+delete+move )) in
- 0) die "no operation specified (use -h for help)" ;;
- [^1]) die "only one operation may be used at a time" ;;
-esac
-
-[[ $movedir && ! -d $movedir ]] &&
- die "destination directory '%s' does not exist or is not a directory" "$movedir"
-
-if (( move || delete )); then
- # make it an absolute path since we're about to chdir
- [[ $movedir && ${movedir:0:1} != '/' ]] && movedir=$PWD/$movedir
- [[ $movedir && ! -w $movedir ]] && needsroot=1
-fi
-
-for cachedir in "${cachedirs[@]}"; do
- [[ -d $cachedir ]] ||
- die "cachedir '%s' does not exist or is not a directory" "$cachedir"
-
- if (( move || delete )); then
- [[ ! -w $cachedir ]] && needsroot=1
- fi
-
- # unlikely that this will fail, but better make sure
- pushd "$cachedir" &>/dev/null || die "failed to chdir to '%s'" "$cachedir"
-
- # note that these results are returned in an arbitrary order from awk, but
- # they'll be resorted (in summarize) iff we have a verbosity level set.
- IFS=$'\n' read -r -d '' -a cand < \
- <(printf '%s\n' "$PWD"/*.pkg.tar?(.+([^.])) | pacsort --files |
- pkgfilter "$keep" "$scanarch" \
- "${#whitelist[*]}" "${whitelist[@]}" \
- "${#blacklist[*]}" "${blacklist[@]}")
-
- candidates+=("${cand[@]}")
- unset cand
-
- popd &>/dev/null
-done
-
-if (( ! ${#candidates[*]} )); then
- msg 'no candidate packages found for pruning'
- exit 0
-fi
-
-# grab this prior to signature scavenging
-pkgcount=${#candidates[*]}
-
-# copy the list, merging in any found sigs
-for cand in "${candidates[@]}"; do
- candtemp+=("$cand")
- [[ -f $cand.sig ]] && candtemp+=("$cand.sig")
-done
-candidates=("${candtemp[@]}")
-unset candtemp
-
-# do this before we destroy anything
-totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }')
-
-# crush. kill. destroy.
-(( verbose )) && cmdopts+=(-v)
-if (( delete )); then
- printf '%s\0' "${candidates[@]}" | runcmd xargs -0 rm "${cmdopts[@]}"
-elif (( move )); then
- printf '%s\0' "${candidates[@]}" | runcmd xargs -0 mv "${cmdopts[@]}" -t "$movedir"
-fi
-
-summarize "$pkgcount" "${candidates[@]}"
-
-# vim: set noet:
diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
deleted file mode 100644
index dff2115a..00000000
--- a/contrib/pacdiff.sh.in
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/bin/bash
-# pacdiff : a simple pacnew/pacsave updater
-#
-# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
-# Copyright (c) 2013-2016 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/>.
-#
-
-shopt -s extglob
-
-declare -r myname='pacdiff'
-declare -r myver='@PACKAGE_VERSION@'
-
-diffprog=${DIFFPROG:-'vim -d'}
-diffsearchpath=${DIFFSEARCHPATH:-/etc}
-USE_COLOR='y'
-declare -a oldsaves
-declare -i USE_FIND=0 USE_LOCATE=0 USE_PACDB=0 OUTPUTONLY=0
-
-m4_include(../scripts/library/output_format.sh)
-
-usage() {
- cat <<EOF
-${myname} (pacman) v${myver}
-
-A simple program to merge or remove pacnew/pacsave files.
-
-Usage: $myname [-l | -f | -p] [--nocolor]
-
-Search Options: select one (default: --pacmandb)
- -l/--locate scan using locate
- -f/--find scan using find
- -p/--pacmandb scan active config files from pacman database
-
-General Options:
- -o/--output print files instead of merging them
- --nocolor remove colors from output
-
-Environment Variables:
- DIFFPROG override the merge program: (default: 'vim -d')
- DIFFSEARCHPATH override the search path. (only when using find)
- (default: /etc)
-
-Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname
-Example: $myname --output --locate
-
-EOF
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
- echo 'Copyright (C) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>'
-}
-
-print_existing() {
- [[ -f "$1" ]] && printf '%s\0' "$1"
-}
-
-print_existing_pacsave(){
- for f in "${1}"?(.+([0-9])); do
- [[ -f $f ]] && printf '%s\0' "$f"
- done
-}
-
-cmd() {
- if (( USE_LOCATE )); then
- locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave '*.pacsave.[0-9]*'
- elif (( USE_FIND )); then
- find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0
- elif (( USE_PACDB )); then
- awk '/^%BACKUP%$/ {
- while (getline) {
- if (/^$/) { nextfile }
- print $1
- }
- }' "${pac_db}"/*/files | while read -r bkup; do
- print_existing "/$bkup.pacnew"
- print_existing "/$bkup.pacorig"
- print_existing_pacsave "/$bkup.pacsave"
- done
- fi
-}
-
-while [[ -n "$1" ]]; do
- case "$1" in
- -l|--locate)
- USE_LOCATE=1;;
- -f|--find)
- USE_FIND=1;;
- -p|--pacmandb)
- USE_PACDB=1;;
- -o|--output)
- OUTPUTONLY=1;;
- --nocolor)
- USE_COLOR='n';;
- -V|--version)
- version; exit 0;;
- -h|--help)
- usage; exit 0;;
- *)
- usage; exit 1;;
- esac
- shift
-done
-
-m4_include(../scripts/library/term_colors.sh)
-
-if ! type -p ${diffprog%% *} >/dev/null && (( ! OUTPUTONLY )); then
- error "Cannot find the $diffprog binary required for viewing differences."
- exit 1
-fi
-
-case $(( USE_FIND + USE_LOCATE + USE_PACDB )) in
- 0) USE_PACDB=1;; # set the default search option
- [^1]) error "Only one search option may be used at a time"
- usage; exit 1;;
-esac
-
-if (( USE_PACDB )); then
- if [[ ! -r @sysconfdir@/pacman.conf ]]; then
- error "unable to read @sysconfdir@/pacman.conf"
- usage; exit 1
- fi
-
- eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
- pac_db="${DBPath:-@localstatedir@/lib/pacman/}local"
- if [[ ! -d "${pac_db}" ]]; then
- error "unable to read pacman database %s". "${pac_db}"
- usage; exit 1
- fi
-fi
-
-# see http://mywiki.wooledge.org/BashFAQ/020
-while IFS= read -u 3 -r -d '' pacfile; do
- file="${pacfile%.pac*}"
- file_type="pac${pacfile##*.pac}"
-
- if (( OUTPUTONLY )); then
- echo "$pacfile"
- continue
- fi
-
- # add matches for pacsave.N to oldsaves array, do not prompt
- if [[ $file_type = pacsave.+([0-9]) ]]; then
- oldsaves+=("$pacfile")
- continue
- fi
-
- msg "%s file found for %s" "$file_type" "$file"
- if [ ! -f "$file" ]; then
- warning "$file does not exist"
- rm -iv "$pacfile"
- continue
- fi
-
- if cmp -s "$pacfile" "$file"; then
- msg2 "Files are identical, removing..."
- rm -v "$pacfile"
- else
- ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
- while read c; do
- case $c in
- q|Q) exit 0;;
- r|R) rm -v "$pacfile"; break ;;
- o|O) mv -v "$pacfile" "$file"; break ;;
- v|V)
- $diffprog "$pacfile" "$file"
- ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type";
- continue ;;
- s|S) break ;;
- *) ask "Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
- esac
- done
- fi
-done 3< <(cmd)
-
-(( ${#oldsaves[@]} )) && warning "Ignoring %s" "${oldsaves[@]}"
-
-exit 0
-
-# vim: set noet:
diff --git a/contrib/paclist.sh.in b/contrib/paclist.sh.in
deleted file mode 100644
index f4fd540b..00000000
--- a/contrib/paclist.sh.in
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-# paclist - List all packages installed from a given repo
-#
-# Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>
-# Copyright (C) 2011 Dave Reisner <dreisner@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/>.
-
-declare -r myname='paclist'
-declare -r myver='@PACKAGE_VERSION@'
-
-export TEXTDOMAIN='pacman'
-export TEXTDOMAINDIR='/usr/share/locale'
-
-# determine whether we have gettext; make it a no-op if we do not
-if ! type gettext &>/dev/null; then
- gettext() {
- echo "$@"
- }
-fi
-
-usage() {
- printf "%s (pacman) v%s\n" "${myname}" "${myver}"
- echo
- printf "List all packages installed from a given repository\n" "${myname}"
- echo
- printf "Usage: %s <repository>\n" "${myname}"
- echo
- printf "Example: %s testing\n" "${myname}"
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>'
- echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
-}
-
-if [[ -z $1 ]]; then
- usage
- exit 1
-fi
-
-if [[ $1 = -@(h|-help) ]]; then
- usage
- exit 0
-elif [[ $1 = -@(V|-version) ]]; then
- version
- exit 0
-fi
-
-printf -v installed '[%s]' "$(gettext installed)"
-pacman -Sl $1 | awk -v i="$installed" '$NF == i { print $2,$3 }'
-
-# exit with pacman's return value, not awk's
-exit ${PIPESTATUS[0]}
-
-# vim: set noet:
diff --git a/contrib/paclog-pkglist.sh.in b/contrib/paclog-pkglist.sh.in
deleted file mode 100644
index 847b389c..00000000
--- a/contrib/paclog-pkglist.sh.in
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/bash
-#
-# paclog-pkglist - Parse a log file into a list of currently installed packages
-#
-# Copyright (C) 2011 Dave Reisner <dave@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/>.
-
-declare -r myname='paclog-pkglist'
-declare -r myver='@PACKAGE_VERSION@'
-
-export TEXTDOMAIN='pacman'
-export TEXTDOMAINDIR='/usr/share/locale'
-declare logfile=${1:-@localstatedir@/log/pacman.log}
-
-usage() {
- printf "%s (pacman) v%s\n" "${myname}" "${myver}"
- echo
- echo "Parse a log file into a list of currently installed packages"
- echo
- printf "Usage: %s [path to pacman log]\n" "${myname}"
- echo
- printf "Example: %s @localstatedir@/log/pacman.log\n" "${myname}"
- echo
- echo 'Defaults to: @localstatedir@/log/pacman.log'
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2011 Dave Reisner <dave@archlinux.org>'
-}
-
-if [[ $1 ]]; then
- if [[ $1 = -@(h|-help) ]]; then
- usage
- exit 0
- elif [[ $1 = -@(V|-version) ]]; then
- version
- exit 0
- elif [[ ! -e $logfile ]]; then
- printf $"target not found: %s\n" "$1"
- exit 1
- fi
-fi
-
-<"$logfile" awk '
-{
- if ($3 ~ /^\[.*\]$/) {
- # new style with caller name
- action = $4
- pkgname = $5
- pkgver = $6
- upgver = $8
- nfields = NF
- } else {
- action = $3
- pkgname = $4
- pkgver = $5
- upgver = $7
- nfields = (NF + 1) # compensate for missing caller field
- }
-}
-
-nfields == 6 && action == "installed" {
- gsub(/[()]/, "", pkgver)
- pkg[pkgname] = pkgver
- next
-}
-
-nfields == 8 && (action == "upgraded" || action == "downgraded") {
- sub(/\)/, "", upgver)
- pkg[pkgname] = upgver
- next
-}
-
-nfields == 6 && action == "removed" {
- pkg[pkgname] = -1
-}
-
-END {
- for (i in pkg) {
- if (pkg[i] != -1) {
- printf "%s %s\n",i,pkg[i]
- }
- }
-}' | sort
-
-# vim: set noet:
diff --git a/contrib/pacscripts.sh.in b/contrib/pacscripts.sh.in
deleted file mode 100644
index 4a1e0c50..00000000
--- a/contrib/pacscripts.sh.in
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/bin/bash
-#
-# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
-# scripts of a given package
-#
-# Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>
-# Copyright (c) 2009-2016 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/>.
-#
-
-# bash options
-set -o nounset
-set -o errexit
-
-declare -r myname='pacscripts'
-declare -r myver='@PACKAGE_VERSION@'
-
-conf="@sysconfdir@/pacman.conf"
-
-if [ ! -r "$conf" ]; then
- echo "ERROR: unable to read $conf"
- exit 1
-fi
-
-eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
-eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
-pac_db="${DBPath:-@localstatedir@/lib/pacman}/local"
-pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}"
-
-error() {
- local mesg=$1; shift
- printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
-}
-
-usage() {
- echo "${myname} (pacman) v${myver}"
- echo
- echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package."
- echo
- echo "Usage: ${myname} <pkgname|pkgfile>"
- echo
- echo " Options:"
- echo " -h, --help Print this help message"
- echo " -v, --version Print program name and version"
- echo
- echo "Example: ${myname} gconf-editor"
- echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>'
- echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>'
-}
-
-spacman() {
- if [ $EUID -eq 0 ]; then
- pacman "$@"
- else
- if ! type -p sudo; then
- error "Cannot find the sudo binary!"
- error "${myname} requires root privileges. Either install \"sudo\" or run as root."
- exit 1
- else
- sudo pacman "$@"
- fi
- fi
-}
-
-print_db() {
- pkg=$(pacman -Q "$1")
- pkg=${pkg/ /-}
- if [ -f $pac_db/$pkg*/install ]; then
- cat $pac_db/$pkg*/install
- echo
- return 0
- else
- error "Package $1 does not include any .INSTALL script"
- return 1
- fi
-}
-
-print_pkg() {
- if ! bsdtar -xqOf "$1" .INSTALL 2>/dev/null; then
- error "Package $1 does not include any .INSTALL script"
- return 1
- fi
- echo
-}
-
-print_scriptlet() {
- if [ -f "$1" ]; then
- if bsdtar tf "$1" .PKGINFO &>/dev/null; then
- print_pkg "$1"
- return
- fi
- fi
- if pacman -Q "$1" &>/dev/null; then
- print_db "$1"
- return
- fi
- if ! pacman -Si $1 &>/dev/null; then
- error "Package $1 not found"
- return 1
- fi
- url=$(pacman -Sddp $1)
- filename=$(basename $url)
- if [ ! -f "$pac_cache/$filename" ]; then
- if ! spacman -Sddw --noconfirm $1 >&2; then
- error "Failed to download $1"
- return 1
- fi
- echo >&2
- fi
- print_pkg "$pac_cache/$filename"
- return
-}
-
-if [ $# -ne 1 ] ; then
- usage
- exit 1
-fi
-
-case "$1" in
- --help|-h) usage; exit 0 ;;
- --version|-V) version; exit 0 ;;
- *) print_scriptlet $1 ;;
-esac
diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in
deleted file mode 100644
index a89328d0..00000000
--- a/contrib/pacsearch.in
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/perl
-# pacsearch - Perform a pacman search using both the local and the sync databases
-#
-# Copyright (C) 2008-2014 Dan McGee <dan@archlinux.org>
-#
-# Based off original shell script version:
-# Copyright (C) 2006-2007 Dan McGee <dan@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/>.
-
-use strict;
-use warnings;
-use Term::ANSIColor;
-
-my $myname = 'pacsearch';
-my $myver = '@PACKAGE_VERSION@';
-
-sub usage {
- print "$myname (pacman) v$myver\n\n";
- print "Perform a pacman search using both the local and the sync databases.\n\n";
- print "Usage: $myname [-n] <pattern>\n\n";
- print "Options:\n";
- print " -n, --nocolor: turn off coloring\n\n";
- print "Example: $myname ^gnome\n";
-}
-
-sub version {
- printf "%s %s\n", $myname, $myver;
- print "Copyright (C) 2008-2014 Dan McGee <dan\@archlinux.org>\n\n";
- print "Based off original shell script version:\n";
- print "Copyright (C) 2006-2007 Dan McGee <dan\@archlinux.org>\n";
-}
-
-if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
- usage;
- if ($#ARGV lt 0) {
- exit 1;
- }
- exit 0;
-}
-
-if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") {
- version;
- exit 0;
-}
-
-# define formatting variables
-my($BLUE, $CYAN, $GREEN, $MAGENTA, $RED, $YELLOW, $BOLD, $RESET);
-if ($ARGV[0] eq "--nocolor" || $ARGV[0] eq "-n") {
- shift;
- $BLUE = "";
- $CYAN = "";
- $GREEN = "";
- $MAGENTA = "";
- $RED = "";
- $YELLOW = "";
- $BOLD = "";
- $RESET = "";
-} else {
- $BLUE = color('blue');
- $CYAN = color('cyan');
- $GREEN = color('green');
- $MAGENTA = color('magenta');
- $RED = color('red');
- $YELLOW = color('yellow');
- $BOLD = color('bold');
- $RESET = color('reset');
-}
-
-# localization
-my $LC_INSTALLED = `gettext pacman installed`;
-
-# Print a "repo/pkgname pkgver (groups) [installed]" line.
-# We stick to pacman colors.
-sub print_pkg {
- my @v = @_;
- print "$RESET$BOLD";
- if ( "$v[0]" eq "local" ) {
- print "$RED";
- } else {
- print "$MAGENTA";
- }
- print "$v[0]/$RESET$BOLD$v[1] $GREEN$v[2]$BLUE$v[3]$CYAN$v[4]$RESET\n";
- print "$v[5]";
-}
-
-sub list_pkg {
- my $db = shift;
- open (my $out, '-|', 'pacman', $db, '--', @ARGV) or exit 1;
- my @pkglist = ();
- while ( readline($out) ) {
- # We grab the following fields: repo, name, ver, group, installed, and
- # desc. We grab leading space for 'group' and 'installed' so that we do
- # not need to test if non-empty when printing.
- my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?$/s;
- my $desc = readline($out);
- # since 'group' and 'installed' are optional, we should fill it in if
- # necessary
- $pkgfields[3] = "" if not defined $pkgfields[3];
- $pkgfields[4] = "" if not defined $pkgfields[4];
- $pkgfields[5] = $desc;
- push (@pkglist, \@pkgfields);
- }
- close ($out);
- return @pkglist;
-}
-
-my @sync = list_pkg('-Ss', @ARGV);
-my %allpkgs = map {$_->[1] . $_->[2] => 1} @sync;
-my @query = grep { not $allpkgs{$_->[1] . $_->[2]}} list_pkg('-Qs', @ARGV);
-$_->[4] = " [$LC_INSTALLED]" foreach @query;
-print_pkg (@{$_}) foreach (@sync, @query);
-
-#vim: set noet:
diff --git a/contrib/rankmirrors.sh.in b/contrib/rankmirrors.sh.in
deleted file mode 100644
index 7b50eb29..00000000
--- a/contrib/rankmirrors.sh.in
+++ /dev/null
@@ -1,234 +0,0 @@
-#!/bin/bash
-#
-# rankmirrors - read a list of mirrors from a file and rank them by speed
-# @configure_input@
-#
-# Copyright (c) 2009 Matthew Bruenig <matthewbruenig@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 3 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/>.
-
-# traps interrupt key to spit out pre-interrupt info
-trap finaloutput INT
-
-declare -r myname='rankmirrors'
-declare -r myver='@PACKAGE_VERSION@'
-
-usage() {
- echo "${myname} (pacman) v${myver}"
- echo
- echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror"
- echo "files are located in @sysconfdir@/pacman.d/. It can also rank one mirror if the URL is"
- echo "provided."
- echo
- echo "Usage: ${myname} [options] MIRRORFILE | URL"
- echo
- echo "Options:"
- echo " --version show program's version number and exit"
- echo " -h, --help show this help message and exit"
- echo " -n NUM number of servers to output, 0 for all"
- echo " -t, --times only output mirrors and their response times"
- echo " -u, --url test a specific URL"
- echo " -v, --verbose be verbose in ouptut"
- echo " -r, --repo specify a repository name instead of guessing"
- exit 0
-}
-
-version() {
- echo "${myname} (pacman) ${myver}"
- echo "Copyright (c) 2009 Matthew Bruenig <matthewbruenig@gmail.com>."
- echo
- echo "This is free software; see the source for copying conditions."
- echo "There is NO WARRANTY, to the extent permitted by law."
- exit 0
-}
-
-err() {
- echo "$1" >&2
- exit 1
-}
-
-# gettime fetchurl (e.g gettime http://foo.com/core/os/i686/core.db.tar.gz)
-# returns the fetching time, or timeout, or unreachable
-gettime() {
- IFS=' ' output=( $(curl -s -m 10 -w "%{time_total} %{http_code}" "$1" -o/dev/null) )
- (( $? == 28 )) && echo timeout && return
- (( ${output[1]} >= 400 || ! ${output[1]} )) && echo unreachable && return
- echo "${output[0]}"
-}
-
-# getfetchurl serverurl (e.g. getturl http://foo.com/core/os/i686)
-# if $repo is in the line, then assumes core
-# if $arch is in the line, then assumes $(uname -m)
-# returns a fetchurl (e.g. http://foo.com/core/os/i686/core.db.tar.gz)
-ARCH="$(uname -m)"
-getfetchurl() {
- local strippedurl="${1%/}"
-
- local replacedurl="${strippedurl//'$arch'/$ARCH}"
- if [[ ! $TARGETREPO ]]; then
- replacedurl="${replacedurl//'$repo'/core}"
- local tmp="${replacedurl%/*}"
- tmp="${tmp%/*}"
-
- local reponame="${tmp##*/}"
- else
- replacedurl="${replacedurl//'$repo'/$TARGETREPO}"
- local reponame="$TARGETREPO"
- fi
-
- if [[ -z $reponame || $reponame = $replacedurl ]]; then
- echo "fail"
- else
- local fetchurl="${replacedurl}/$reponame.db"
- echo "$fetchurl"
- fi
-}
-
-# This exists to remove the need for a separate interrupt function
-finaloutput() {
- IFS=$'\n' read -r -d '' -a sortedarray < \
- <(printf '%s\n' "${timesarray[@]}" | LC_COLLATE=C sort)
-
- # Final output for mirrorfile
- numiterator="0"
- if [[ $TIMESONLY ]]; then
- echo
- echo " Servers sorted by time (seconds):"
- for line in "${sortedarray[@]}"; do
- echo "${line#* } : ${line% *}"
- ((numiterator++))
- (( NUM && numiterator >= NUM )) && break
- done
- else
- for line in "${sortedarray[@]}"; do
- echo "Server = ${line#* }"
- ((numiterator++))
- (( NUM && numiterator >= NUM )) && break
- done
- fi
- exit 0
-}
-
-
-# Argument parsing
-[[ $1 ]] || usage
-while [[ $1 ]]; do
- if [[ ${1:0:2} = -- ]]; then
- case "${1:2}" in
- help) usage ;;
- version) version ;;
- times) TIMESONLY=1 ; shift ;;
- verbose) VERBOSE=1 ; shift ;;
- url)
- CHECKURL=1;
- [[ $2 ]] || err "Must specify URL.";
- URL="$2";
- shift 2;;
- repo)
- [[ $2 ]] || err "Must specify repository name.";
- TARGETREPO="$2";
- shift 2;;
- *) err "'$1' is an invalid argument."
- esac
- elif [[ ${1:0:1} = - ]]; then
-
- if [[ ! ${1:1:1} ]]; then
- [[ -t 0 ]] && err "Stdin is empty."
- IFS=$'\n' linearray=( $(</dev/stdin) )
- STDIN=1
- shift
- else
- snum=1
- for ((i=1 ; i<${#1}; i++)); do
- case ${1:$i:1} in
- h) usage ;;
- t) TIMESONLY=1 ;;
- v) VERBOSE=1 ;;
- u)
- CHECKURL=1;
- [[ $2 ]] || err "Must specify URL.";
- URL="$2";
- snum=2;;
- r)
- [[ $2 ]] || err "Must specify repository name.";
- TARGETREPO="$2";
- snum=2;;
- n)
- [[ $2 ]] || err "Must specify number.";
- NUM="$2";
- snum=2;;
- *) err "'$1' is an invalid argument." ;;
- esac
- done
- shift $snum
- fi
- elif [[ -f $1 ]]; then
- FILE="1"
- IFS=$'\n' linearray=( $(<$1) )
- [[ $linearray ]] || err "File is empty."
- shift
- else
- err "'$1' does not exist."
- fi
-done
-
-# Some sanity checks
-[[ $NUM ]] || NUM=0
-[[ $FILE && $CHECKURL ]] && err "Cannot specify a URL and mirrorfile."
-[[ $FILE || $CHECKURL || $STDIN ]] || err "Must specify URL, mirrorfile, or stdin."
-
-# Single URL handling
-if [[ $CHECKURL ]]; then
- url="$(getfetchurl "$URL")"
- [[ $url = fail ]] && err "URL '$URL' is malformed."
- [[ $VERBOSE ]] && echo "Testing $url..."
- time=$(gettime "$url")
- echo "$URL : $time"
- exit 0
-fi
-
-# Get URL results from mirrorfile, fill up the array, and so on
-if [[ $TIMESONLY ]]; then
- echo "Querying servers. This may take some time..."
-elif [[ $FILE ]]; then
- echo "# Server list generated by rankmirrors on $(date +%Y-%m-%d)"
-fi
-
-timesarray=()
-for line in "${linearray[@]}"; do
- if [[ $line =~ ^[[:space:]]*# ]]; then
- [[ $TIMESONLY ]] || echo $line
- elif [[ $line =~ ^[[:space:]]*Server ]]; then
-
- # Getting values and times and such
- server="${line#*= }"
- server="${server%%#*}"
- url="$(getfetchurl "$server")"
- [[ $url = fail ]] && err "URL '$URL' is malformed."
- time=$(gettime "$url")
- timesarray+=("$time $server")
-
- # Output
- if [[ $VERBOSE && $TIMESONLY ]]; then
- echo "$server ... $time"
- elif [[ $VERBOSE ]]; then
- echo "# $server ... $time"
- elif [[ $TIMESONLY ]]; then
- echo -n " *"
- fi
- fi
-done
-finaloutput
-
-# vim: set noet:
diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in
deleted file mode 100644
index c571d297..00000000
--- a/contrib/updpkgsums.sh.in
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/bash
-#
-# updpkgsums - update source checksums in-place in PKGBUILDs
-#
-# Copyright (C) 2012-2013 Dave Reisner <dreisner@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/>.
-
-shopt -s extglob
-
-declare -r myname='updpkgsums'
-declare -r myver='@PACKAGE_VERSION@'
-
-usage() {
- printf "%s (pacman) v%s\n" "${myname}" "${myver}"
- echo
- printf "%s will perform an in place update of the checksums in the\n" "${myname}"
- echo "path specified by [build file], defaulting to PKGBUILD in the current"
- echo "working directory."
- echo
- printf "Usage: %s [options] [build file]\n" "${myname}"
- echo
- echo " -h, --help display this help message and exit"
- echo " -V, --version display version information and exit"
- echo
- echo "These options can be passed to makepkg:"
- echo " -m, --nocolor disable colorized output messages"
-}
-
-version() {
- printf "%s %s\n" "$myname" "$myver"
- echo 'Copyright (C) 2012-2013 Dave Reisner <dreisner@archlinux.org>'
-}
-
-die() {
- printf "==> ERROR: $1\n" "${@:2}" >&2
- exit 1
-}
-
-MAKEPKG_OPTS=()
-buildfile='PKGBUILD'
-
-while (( "$#" )); do
- case "$1" in
- -h|--help) usage; exit ;;
- -m|--nocolor) MAKEPKG_OPTS+=("$1"); shift ;;
- -V|--version) version; exit ;;
- *) buildfile="$1"; break 2 ;;
- esac
-done
-
-if [[ ! -f $buildfile ]]; then
- die "%s not found or is not a file" "$buildfile"
-fi
-
-# Resolve any symlinks to avoid replacing the symlink with a file. But, we
-# have to do this portably -- readlink's flags are inconsistent across OSes.
-while [[ -L $buildfile ]]; do
- buildfile=$(readlink "$buildfile")
- if [[ $buildfile = */* ]]; then
- cd "${buildfile%/*}"
- buildfile=${buildfile##*/}
- fi
-done
-
-# cd into the directory with the build file. This avoids creating random src/
-# directories scattered about the filesystem, and avoids cases where we might
-# not be able to write in the $PWD.
-if [[ $buildfile = */* ]]; then
- cd "${buildfile%/*}"
- buildfile=${buildfile##*/}
-fi
-
-# Check $PWD/ for permission to unlink the $buildfile and write a new one
-if [[ ! -w . ]]; then
- die "No write permission in '%s'" "$PWD"
-fi
-
-# Generate the new sums
-export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
-newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
-
-trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT
-newsums=$(makepkg -g -p "$buildfile" "${MAKEPKG_OPTS[@]}") || die 'Failed to generate new checksums'
-awk -v newsums="$newsums" '
- /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ {
- if (!w) {
- print newsums
- w++
- }
- next
- }
-
- 1
- END { if (!w) print newsums }
-' "$buildfile" > "$newbuildfile" || die 'Failed to write new PKGBUILD'
-
-# Rewrite the original buildfile. Use cat instead of mv/cp to preserve
-# permissions implicitly.
-if ! cat -- "$newbuildfile" >"$buildfile"; then
- die "Failed to update %s. The file has not been modified." "$buildfile"
-fi
-
-# vim: set noet:
diff --git a/contrib/verify-pacman-repo-db.pl b/contrib/verify-pacman-repo-db.pl
deleted file mode 100755
index e0a54106..00000000
--- a/contrib/verify-pacman-repo-db.pl
+++ /dev/null
@@ -1,259 +0,0 @@
-#!/usr/bin/perl -T
-use warnings;
-use strict;
-
-
-# This is used for the usage output
-=pod
-
-=head1 SYNOPSIS
-
-verify-pacman-repo-db.pl [options] <database file> ...
-
- Options:
- --help, -h Show short help message
- --debug Enable debug output
- --checksum, -c Verify checksums of packages
- --thread, -t <num> Use num threads to verify packages. Default: 1
- NOTE: Each thread uses up to approx. 128MiB of memory
-
-=cut
-
-package main;
-use Getopt::Long;
-use Pod::Usage;
-
-exit main();
-
-sub main {
- my %opts = (
- threads => 1,
- );
-
- Getopt::Long::Configure ("bundling");
- pod2usage(-verbose => 0) if (@ARGV== 0);
- GetOptions(\%opts, "help|h", "debug", "threads|t=i", "checksum|c") or pod2usage(2);
- pod2usage(0) if $opts{help};
-
- my $verifier = Verifier->new(\%opts);
-
- for my $repodb (@ARGV) {
- $verifier->check_repodb($repodb);
- }
-
- $verifier->finalize();
- return $verifier->get_error_status();
-}
-
-package Verifier;
-use Archive::Tar;
-use Digest::MD5;
-use Digest::SHA;
-use File::Basename;
-use threads;
-use threads::shared;
-use Thread::Queue;
-
-sub new {
- my $class = shift;
- my $opts = shift;
-
- my $self :shared = shared_clone({
- opts => \%{$opts},
- package_queue => Thread::Queue->new(),
- output_queue => Thread::Queue->new(),
- workers => [],
- errors => 0,
- });
-
- bless $self, $class;
- $self->start_workers();
- return $self;
-}
-
-sub start_workers {
- my $self = shift;
-
- threads->new(\&_worker_output_queue, $self);
-
- for (my $i = 0; $i < $self->{opts}->{threads}; $i++) {
- my $thr :shared = shared_clone(threads->new(\&_worker_package_queue, $self));
- push @{$self->{workers}}, $thr;
- }
-}
-
-sub _worker_package_queue {
- my $self = shift;
- while (my $workpack = $self->{package_queue}->dequeue()) {
- my $dbdata = $self->_parse_db_entry($workpack->{db_desc_content});
- $self->{errors} += $self->_verify_db_entry($workpack->{dirname}, $dbdata);
- }
-}
-
-sub _worker_output_queue {
- my $self = shift;
- while (my $output = $self->{output_queue}->dequeue()) {
- print STDERR $output;
- }
-}
-
-sub finalize {
- my $self = shift;
-
- $self->{package_queue}->end();
- $self->_join_threads($self->{workers});
-
- $self->{output_queue}->end();
- $self->_join_threads([threads->list]);
-}
-
-sub _join_threads {
- my $self = shift;
- my $threads = shift;
-
- for my $thr (@{$threads}) {
- if ($thr->tid && !threads::equal($thr, threads->self)) {
- print "waiting for thread ".$thr->tid()." to finish\n" if $self->{opts}->{debug};
- $thr->join;
- }
- }
-}
-
-sub get_error_status {
- my $self = shift;
-
- return $self->{errors} > 0;
-}
-
-sub check_repodb {
- my $self = shift;
- my $repodb = shift;
-
- my $db = Archive::Tar->new();
- $db->read($repodb);
-
- my $dirname = dirname($repodb);
- my $pkgcount = 0;
-
- my @files = $db->list_files();
- for my $file_object ($db->get_files()) {
- if ($file_object->name =~ m/^([^\/]+)\/desc$/) {
- my $package = $1;
- $self->{package_queue}->enqueue({
- package => $package,
- db_desc_content => $file_object->get_content(),
- dirname => $dirname,
- });
- $pkgcount++;
- }
- }
-
- $self->_debug(sprintf("Queued %d package(s) from database '%s'\n", $pkgcount, $repodb));
-}
-
-sub _parse_db_entry {
- my $self = shift;
- my $content = shift;
- my %db;
- my $key;
-
- for my $line (split /\n/, $content) {
- if ($line eq '') {
- $key = undef;
- } elsif ($key) {
- push @{$db{$key}}, $line;
- } elsif ($line =~ m/^%(.+)%$/) {
- $key = $1;
- } else {
- die "\$key not set. Is the db formatted incorrectly?" unless $key;
- }
- }
- return \%db;
-}
-
-sub _output {
- my $self = shift;
- my $output = shift;
-
- return if $output eq "";
-
- $output = sprintf("Thread %s: %s", threads->self->tid(), $output);
- $self->{output_queue}->enqueue($output);
-}
-
-sub _debug {
- my $self = shift;
- my $output = shift;
- $self->_output($output) if $self->{opts}->{debug};
-}
-
-sub _verify_db_entry {
- my $self = shift;
- my $basedir = shift;
- my $dbdata = shift;
- my $ret = 0;
- my $output = "";
-
- # verify package exists
- my $pkgfile = $basedir.'/'.$dbdata->{FILENAME}[0];
- $self->_debug(sprintf("Checking package %s\n", $dbdata->{FILENAME}[0]));
- unless (-e $pkgfile) {
- $self->_output(sprintf("Package file missing: %s\n", $pkgfile));
- return 1;
- }
-
- $ret += $self->_verify_package_size($dbdata, $pkgfile);
- $ret += $self->_verify_package_checksum($dbdata, $pkgfile) if $self->{opts}->{checksum};
-
- return $ret;
-}
-
-sub _verify_package_size {
- my $self = shift;
- my $dbdata = shift;
- my $pkgfile = shift;
-
- my $csize = $dbdata->{CSIZE}[0];
- my $filesize = (stat($pkgfile))[7];
- unless ($csize == $filesize) {
- $self->_output(sprintf("Package file has incorrect size: %d vs %d: %s\n", $csize, $filesize, $pkgfile));
- return 1;
- }
- return 0;
-}
-
-sub _verify_package_checksum {
- my $self = shift;
- my $dbdata = shift;
- my $pkgfile = shift;
-
- my $md5 = Digest::MD5->new;
- my $sha = Digest::SHA->new(256);
-
- my $content;
- # 128MiB to keep random IO low when using multiple threads (only works for large packages though)
- my $chunksize = 1024*1024*128;
- open my $fh, "<", $pkgfile;
- while (read($fh, $content, $chunksize)) {
- $md5->add($content);
- $sha->add($content);
- }
-
- my $expected_sha = $dbdata->{SHA256SUM}[0];
- my $expected_md5 = $dbdata->{MD5SUM}[0];
- my $got_md5 = $md5->hexdigest;
- my $got_sha = $sha->hexdigest;
-
- unless ($expected_sha eq $got_sha and $expected_md5 eq $got_md5) {
- my $output;
- $output .= sprintf "Package file has incorrect checksum: %s\n", $pkgfile;
- $output .= sprintf "expected: SHA %s\n", $expected_sha;
- $output .= sprintf "got: SHA %s\n", $got_sha;
- $output .= sprintf "expected: MD5 %s\n", $expected_md5;
- $output .= sprintf "got: MD5 %s\n", $got_md5;
- $self->_output($output);
- return 1;
- }
- return 0;
-}
-
diff --git a/contrib/vimprojects b/contrib/vimprojects
deleted file mode 100644
index e9adfdf1..00000000
--- a/contrib/vimprojects
+++ /dev/null
@@ -1,25 +0,0 @@
-This is a project file
-for the vim-project plugin.
-Save it as ~/.vimprojects
-
-$ pacman -S vim-project
-change the pacman path below
-$ vim
-:Project
-
-Press \r in the project view
-on a project name to generate
-the list of files
-
-pacman=~/devel/pacman/ CD=. filter="*.ac *.am" flags=S {
- libalpm=lib/libalpm/ filter="*.c *.h *.am" {
- }
- pacman=src/pacman/ filter="*.c *.h *.am" {
- }
- scripts=scripts/ filter="*.sh.in *.py.in *.am" {
- }
- utils=src/util filter="*.c *.h *.am" {
- }
- contrib=contrib CD=. {
- }
-}
diff --git a/doc/.gitignore b/doc/.gitignore
index 2eae9e4b..186f45e4 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -7,7 +7,6 @@ makepkg.conf.5
pacman.8
pacman-key.8
pacman.conf.5
-pactree.8
pkgdelta.8
repo-add.8
repo-remove.8
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 5d7c9754..44e32996 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -12,7 +12,6 @@ ASCIIDOC_MANS = \
vercmp.8 \
pkgdelta.8 \
pacman-key.8 \
- pactree.8 \
PKGBUILD.5 \
makepkg.conf.5 \
pacman.conf.5 \
@@ -29,7 +28,6 @@ HTML_MANPAGES = \
vercmp.8.html \
pkgdelta.8.html \
pacman-key.8.html \
- pactree.8.html \
PKGBUILD.5.html \
makepkg.conf.5.html \
pacman.conf.5.html \
@@ -56,7 +54,6 @@ EXTRA_DIST = \
vercmp.8.txt \
pkgdelta.8.txt \
pacman-key.8.txt \
- pactree.8.txt \
PKGBUILD.5.txt \
PKGBUILD-example.txt \
makepkg.conf.5.txt \
@@ -159,7 +156,6 @@ repo-add.8 repo-add.8.html: repo-add.8.txt
vercmp.8 vercmp.8.html: vercmp.8.txt
pkgdelta.8 pkgdelta.8.html: pkgdelta.8.txt
pacman-key.8 pacman-key.8.html: pacman-key.8.txt
-pactree.8 pactree.8.html: pactree.8.txt
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.txt PKGBUILD-example.txt
makepkg.conf.5 makepkg.conf.5.html: makepkg.conf.5.txt
pacman.conf.5 pacman.conf.5.html: pacman.conf.5.txt
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index 08ef3e4d..18bc2a19 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -48,7 +48,7 @@ similar to `$_basekernver`.
*pkgver*::
The version of the software as released from the author (e.g., '2.7.1').
- The variable is not allowed to contain colons or hyphens.
+ The variable is not allowed to contain colons, forward slashes or hyphens.
+
The `pkgver` variable can be automatically updated by providing a `pkgver()`
function in the PKGBUILD that outputs the new package version.
@@ -464,12 +464,12 @@ Using VCS Sources[[VCS]]
------------------------
Building a developmental version of a package using sources from a version
control system (VCS) is enabled by specifying the source in the form
-`source=('directory::url#fragment')`. Currently makepkg supports the Bazaar, Git,
-Subversion, and Mercurial version control systems. For other version control
-systems, manual cloning of upstream repositories must be done in the `prepare()`
-function.
+`source=('directory::url#fragment?query')`. Currently makepkg supports the
+Bazaar, Git, Subversion, and Mercurial version control systems. For other
+version control systems, manual cloning of upstream repositories must be done
+in the `prepare()` function.
-The source URL is divided into three components:
+The source URL is divided into four components:
*directory*::
(optional) Specifies an alternate directory name for makepkg to download
@@ -501,6 +501,11 @@ The source URL is divided into three components:
*svn*;;
revision
+*query*::
+ (optional) Allows specifying whether a VCS checkout should be checked for
+ PGP-signed revisions. The source line should have the format
+ `source=(url#fragment?signed)` or `source=(url?signed#fragment)`. Currently
+ only supported by Git.
Example
-------
diff --git a/doc/index.txt b/doc/index.txt
index a969618f..7939923e 100644
--- a/doc/index.txt
+++ b/doc/index.txt
@@ -255,7 +255,7 @@ bugs under the Pacman project.
Copyright
---------
-pacman is Copyright (C) 2006-2016 Pacman Development Team
+pacman is Copyright (C) 2006-2017 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/pacman.8.txt b/doc/pacman.8.txt
index 2bafa414..d670e82a 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -136,11 +136,12 @@ Options
*-r, \--root* <path>::
Specify an alternative installation root (default is `/`). This should
not be used as a way to install software into `/usr/local` instead of
- `/usr`. This option is used if you want to install a package on a
- temporarily mounted partition that is "owned" by another system.
+ `/usr`.
*NOTE*: If database path or log file are not specified on either the
command line or in linkman:pacman.conf[5], their default location will
be inside this root path.
+ *NOTE*: This option is not suitable for performing operations on a mounted
+ guest system. See '\--sysroot' instead.
*-v, \--verbose*::
Output paths such as as the Root, Conf File, DB Path, Cache Dirs, etc.
@@ -193,6 +194,16 @@ Options
*\--confirm*::
Cancels the effects of a previous '\--noconfirm'.
+*\--disable-download-timeout*::
+ Disable defaults for low speed limit and timeout on downloads. Use this
+ if you have issues downloading files with proxy and/or security gateway.
+
+*\--sysroot* <dir>::
+ Specify an alternative system root. Pacman will chroot and chdir into the
+ system root prior to running. This allows mounted guest systems to be
+ properly operated on. Any other paths given will be interpreted as relative
+ to the system root. Requires root privileges.
+
Transaction Options (apply to '-S', '-R' and '-U')
--------------------------------------------------
@@ -233,14 +244,6 @@ Transaction Options (apply to '-S', '-R' and '-U')
Upgrade Options (apply to '-S' and '-U')[[UO]]
----------------------------------------------
-*\--force*::
- Bypass file conflict checks and overwrite conflicting files. If the
- package that is about to be installed contains files that are already
- installed, this option will cause all those files to be overwritten.
- Using '\--force' will not allow overwriting a directory with a file or
- installing packages with conflicting files and directories.
- This option should be used with care, ideally not at all.
-
*\--asdeps*::
Install packages non-explicitly; in other words, fake their install reason
to be installed as a dependency. This is useful for makepkg and other
@@ -266,6 +269,18 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
*\--needed*::
Do not reinstall the targets that are already up-to-date.
+*\--overwrite* <glob>::
+ Bypass file conflict checks and overwrite conflicting files. If the
+ package that is about to be installed contains files that are already
+ installed and match 'glob', this option will cause all those files to be
+ overwritten. Using '\--overwrite' will not allow overwriting a directory
+ with a file or installing packages with conflicting files and directories.
+ Multiple patterns can be specified by separating them with a comma. May be
+ specified multiple times. Patterns can be negated, such that files
+ matching them will not be overwritten, by prefixing them with an
+ exclamation mark. Subsequent matches will override previous ones. A leading
+ literal exclamation mark or backslash needs to be escaped.
+
Query Options (apply to '-Q')[[QO]]
-----------------------------------
@@ -338,10 +353,10 @@ Query Options (apply to '-Q')[[QO]]
with descriptions matching ALL of those terms are returned.
*-t, \--unrequired*::
- Restrict or filter output to packages not required or optionally required by
- any currently installed package. Specify this option twice to only filter
- packages that are direct dependencies (i.e. do not filter optional
- dependencies).
+ Restrict or filter output to print only packages neither required nor
+ optionally required by any currently installed package. Specify this
+ option twice to include packages which are optionally, but not directly,
+ required by another package.
*-u, \--upgrades*::
Restrict or filter output to packages that are out-of-date on the local
@@ -456,7 +471,7 @@ Database Options (apply to '-D')[[QO]]
package installed even when it was initially installed as a dependency
of another package.
-*-k \--check*::
+*-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
@@ -464,6 +479,9 @@ Database Options (apply to '-D')[[QO]]
a check on the sync databases to ensure all specified dependencies
are available.
+*-q, \--quiet*::
+ Suppress messages on successful completion of database operations.
+
File Options (apply to '-F')[[FO]]
----------------------------------
*-y, --refresh*::
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index c6658706..f92ee207 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -209,6 +209,10 @@ Options
Displays name, version and size of target packages formatted
as a table for upgrade, sync and remove operations.
+*DisableDownloadTimeout*::
+ Disable defaults for low speed limit and timeout on downloads. Use this
+ if you have issues downloading files with proxy and/or security gateway.
+
Repository Sections
-------------------
diff --git a/doc/pactree.8.txt b/doc/pactree.8.txt
deleted file mode 100644
index b177788a..00000000
--- a/doc/pactree.8.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-/////
-vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
-/////
-pactree(8)
-=========
-
-Name
-----
-pactree - package dependency tree viewer
-
-
-Synopsis
---------
-'pactree' [options] package
-
-
-Description
------------
-Pactree produces a dependency tree for a package.
-
-By default, a tree-like output is generated, but with the '\--graph' option, a Graphviz
-description is generated.
-
-
-Options
--------
-*-a, \--ascii*::
- Use ASCII characters for tree formatting. By default, pactree will use Unicode
- line drawing characters if it is able to detect that the locale supports them.
-
-*-b, \--dbpath*::
- Specify an alternative database location.
-
-*-c, \--color*::
- Colorize output.
-
-*-d, \--depth <num>*::
- Limits the number of levels of dependency to show. A zero means
- show the named package only, one shows the packages that are directly
- required.
-
-*-g, \--graph*::
- Generate a Graphviz description. If this option is given, the '\--color' and
- '\--linear' options are ignored.
-
-*-h, \--help*::
- Output syntax and command-line options.
-
-*-l, \--linear*::
- Prints package names at the start of each line, one per line.
-
-*-r, \--reverse*::
- Show packages that depend on the named package.
-
-*-s, \--sync*::
- Read package data from sync databases instead of local database.
-
-*-u, \--unique*::
- List dependent packages once. Implies '\--linear'.
-
-*\--config <file>*::
- Specify an alternate pacman configuration file.
-
-
-See Also
---------
-linkman:pacman[8], linkman:pacman.conf[5], linkman:makepkg[8]
-
-include::footer.txt[]
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index efac16ab..71293970 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -8,9 +8,9 @@
#
#-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent'
-DLAGENTS=('ftp::/usr/bin/curl -qfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
- 'http::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
- 'https::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
+DLAGENTS=('ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
+ 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
+ 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o')
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 945a6121..f4f20e61 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -65,13 +65,15 @@ libalpm_la_CFLAGS = \
$(GPGME_CFLAGS) \
$(LIBARCHIVE_CFLAGS) \
$(LIBCURL_CFLAGS) \
- $(LIBSSL_CFLAGS)
+ $(LIBSSL_CFLAGS) \
+ $(NETTLE_CFLAGS)
libalpm_la_LIBADD = \
$(LTLIBINTL) \
$(GPGME_LIBS) \
$(LIBARCHIVE_LIBS) \
$(LIBCURL_LIBS) \
- $(LIBSSL_LIBS)
+ $(LIBSSL_LIBS) \
+ $(NETTLE_LIBS)
# vim:set noet:
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index d132e522..0beed01c 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -1,7 +1,7 @@
/*
* add.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -110,6 +110,7 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, const char *filename)
{
int ret;
+ struct archive *archive_writer;
const int archive_flags = ARCHIVE_EXTRACT_OWNER |
ARCHIVE_EXTRACT_PERM |
ARCHIVE_EXTRACT_TIME |
@@ -118,7 +119,20 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
archive_entry_set_pathname(entry, filename);
- ret = archive_read_extract(archive, entry, archive_flags);
+ archive_writer = archive_write_disk_new();
+ if (archive_writer == NULL) {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("cannot allocate disk archive object"));
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "error: cannot allocate disk archive object");
+ return 1;
+ }
+
+ archive_write_disk_set_options(archive_writer, archive_flags);
+
+ ret = archive_read_extract2(archive, entry, archive_writer);
+
+ archive_write_free(archive_writer);
+
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"),
@@ -405,6 +419,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
alpm_event_package_operation_t event;
const char *log_msg = "adding";
const char *pkgfile;
+ struct archive *archive;
+ struct archive_entry *entry;
+ int fd, cwdfd;
+ struct stat buf;
ASSERT(trans != NULL, return -1);
@@ -477,39 +495,44 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
goto cleanup;
}
- if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
- struct archive *archive;
- struct archive_entry *entry;
- struct stat buf;
- int fd, cwdfd;
-
- _alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
+ fd = _alpm_open_archive(db->handle, pkgfile, &buf,
+ &archive, ALPM_ERR_PKG_OPEN);
+ if(fd < 0) {
+ ret = -1;
+ goto cleanup;
+ }
- fd = _alpm_open_archive(db->handle, pkgfile, &buf,
- &archive, ALPM_ERR_PKG_OPEN);
- if(fd < 0) {
- ret = -1;
- goto cleanup;
- }
+ /* save the cwd so we can restore it later */
+ OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
+ if(cwdfd < 0) {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n"));
+ }
- /* save the cwd so we can restore it later */
- OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
- if(cwdfd < 0) {
- _alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n"));
+ /* libarchive requires this for extracting hard links */
+ if(chdir(handle->root) != 0) {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
+ handle->root, strerror(errno));
+ _alpm_archive_read_free(archive);
+ if(cwdfd >= 0) {
+ close(cwdfd);
}
+ close(fd);
+ ret = -1;
+ goto cleanup;
+ }
- /* libarchive requires this for extracting hard links */
- if(chdir(handle->root) != 0) {
- _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
- handle->root, strerror(errno));
- _alpm_archive_read_free(archive);
- if(cwdfd >= 0) {
- close(cwdfd);
+ if(trans->flags & ALPM_TRANS_FLAG_DBONLY) {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extracting db files\n");
+ while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
+ const char *entryname = archive_entry_pathname(entry);
+ if(entryname[0] == '.') {
+ errors += extract_db_file(handle, archive, entry, newpkg, entryname);
+ } else {
+ archive_read_data_skip(archive);
}
- close(fd);
- ret = -1;
- goto cleanup;
}
+ } else {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
PROGRESS(handle, progress, newpkg->name, 0, pkg_count, pkg_current);
@@ -535,33 +558,34 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* extract the next file from the archive */
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
}
- _alpm_archive_read_free(archive);
- close(fd);
+ }
- /* restore the old cwd if we have it */
- if(cwdfd >= 0) {
- if(fchdir(cwdfd) != 0) {
- _alpm_log(handle, ALPM_LOG_ERROR,
- _("could not restore working directory (%s)\n"), strerror(errno));
- }
- close(cwdfd);
+ _alpm_archive_read_free(archive);
+ close(fd);
+
+ /* restore the old cwd if we have it */
+ if(cwdfd >= 0) {
+ if(fchdir(cwdfd) != 0) {
+ _alpm_log(handle, ALPM_LOG_ERROR,
+ _("could not restore working directory (%s)\n"), strerror(errno));
}
+ close(cwdfd);
+ }
- if(errors) {
- ret = -1;
- if(is_upgrade) {
- _alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
- newpkg->name);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "error: problem occurred while upgrading %s\n",
- newpkg->name);
- } else {
- _alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while installing %s\n"),
- newpkg->name);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "error: problem occurred while installing %s\n",
- newpkg->name);
- }
+ if(errors) {
+ ret = -1;
+ if(is_upgrade) {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
+ newpkg->name);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "error: problem occurred while upgrading %s\n",
+ newpkg->name);
+ } else {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while installing %s\n"),
+ newpkg->name);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "error: problem occurred while installing %s\n",
+ newpkg->name);
}
}
diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h
index c1ab62a2..d30f9b0b 100644
--- a/lib/libalpm/add.h
+++ b/lib/libalpm/add.h
@@ -1,7 +1,7 @@
/*
* add.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 6b7fa7a9..d3f951d5 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -1,7 +1,7 @@
/*
* alpm.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -152,7 +152,7 @@ const char SYMEXPORT *alpm_version(void)
/** Get the capabilities of the library.
* @return a bitmask of the capabilities
* */
-enum alpm_caps SYMEXPORT alpm_capabilities(void)
+int SYMEXPORT alpm_capabilities(void)
{
return 0
#ifdef ENABLE_NLS
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 7955585a..2637a055 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1,7 +1,7 @@
/*
* alpm.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -53,7 +53,8 @@ typedef struct __alpm_trans_t alpm_trans_t;
* @{
*/
typedef enum _alpm_errno_t {
- ALPM_ERR_MEMORY = 1,
+ ALPM_ERR_OK = 0,
+ ALPM_ERR_MEMORY,
ALPM_ERR_SYSTEM,
ALPM_ERR_BADPERMS,
ALPM_ERR_NOT_A_FILE,
@@ -829,6 +830,11 @@ int alpm_option_add_hookdir(alpm_handle_t *handle, const char *hookdir);
int alpm_option_remove_hookdir(alpm_handle_t *handle, const char *hookdir);
/** @} */
+alpm_list_t *alpm_option_get_overwrite_files(alpm_handle_t *handle);
+int alpm_option_set_overwrite_files(alpm_handle_t *handle, alpm_list_t *globs);
+int alpm_option_add_overwrite_file(alpm_handle_t *handle, const char *glob);
+int alpm_option_remove_overwrite_file(alpm_handle_t *handle, const char *glob);
+
/** Returns the logfile name. */
const char *alpm_option_get_logfile(alpm_handle_t *handle);
/** Sets the logfile name. */
@@ -916,14 +922,16 @@ int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
const char *alpm_option_get_dbext(alpm_handle_t *handle);
int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
-alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
-int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
+int alpm_option_get_default_siglevel(alpm_handle_t *handle);
+int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level);
+
+int alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
+int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level);
-alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
-int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
+int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
+int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level);
-alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
-int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
+int alpm_option_set_disable_dl_timeout(alpm_handle_t *handle, unsigned short disable_dl_timeout);
/** @} */
@@ -956,7 +964,7 @@ alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
* @return an alpm_db_t* on success (the value), NULL on error
*/
alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename,
- alpm_siglevel_t level);
+ int level);
/** Unregister all package databases.
* @param handle the context handle
@@ -982,7 +990,7 @@ const char *alpm_db_get_name(const alpm_db_t *db);
* @param db pointer to the package database
* @return the signature verification level
*/
-alpm_siglevel_t alpm_db_get_siglevel(alpm_db_t *db);
+int alpm_db_get_siglevel(alpm_db_t *db);
/** Check the validity of a database.
* This is most useful for sync databases and verifying signature status.
@@ -1049,14 +1057,14 @@ typedef enum _alpm_db_usage_ {
* @param usage a bitmask of alpm_db_usage_t values
* @return 0 on success, or -1 on error
*/
-int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage);
+int alpm_db_set_usage(alpm_db_t *db, int usage);
/** Gets the usage of a database.
* @param db pointer to the package database to get the status of
* @param usage pointer to an alpm_db_usage_t to store db's status
* @return 0 on success, or -1 on error
*/
-int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
+int alpm_db_get_usage(alpm_db_t *db, int *usage);
/** @} */
@@ -1080,7 +1088,7 @@ int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
- alpm_siglevel_t level, alpm_pkg_t **pkg);
+ int level, alpm_pkg_t **pkg);
/** Find a package in a list by name.
* @param haystack a list of alpm_pkg_t
@@ -1260,6 +1268,18 @@ alpm_list_t *alpm_pkg_get_depends(alpm_pkg_t *pkg);
*/
alpm_list_t *alpm_pkg_get_optdepends(alpm_pkg_t *pkg);
+/** Returns a list of package check dependencies
+ * @param pkg a pointer to package
+ * @return a reference to an internal list of alpm_depend_t structures.
+ */
+alpm_list_t *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg);
+
+/** Returns a list of package make dependencies
+ * @param pkg a pointer to package
+ * @return a reference to an internal list of alpm_depend_t structures.
+ */
+alpm_list_t *alpm_pkg_get_makedepends(alpm_pkg_t *pkg);
+
/** Returns the list of packages conflicting with pkg.
* @param pkg a pointer to package
* @return a reference to an internal list of alpm_depend_t structures.
@@ -1317,7 +1337,7 @@ const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
* @param pkg a pointer to package
* @return an enum member giving the validation method
*/
-alpm_pkgvalidation_t alpm_pkg_get_validation(alpm_pkg_t *pkg);
+int alpm_pkg_get_validation(alpm_pkg_t *pkg);
/* End of alpm_pkg_t accessors */
/* @} */
@@ -1479,7 +1499,7 @@ typedef enum _alpm_transflag_t {
* @param handle the context handle
* @return the bitfield of transaction flags
*/
-alpm_transflag_t alpm_trans_get_flags(alpm_handle_t *handle);
+int alpm_trans_get_flags(alpm_handle_t *handle);
/** Returns a list of packages added by the transaction.
* @param handle the context handle
@@ -1495,10 +1515,10 @@ alpm_list_t *alpm_trans_get_remove(alpm_handle_t *handle);
/** Initialize the transaction.
* @param handle the context handle
- * @param flags flags of the transaction (like nodeps, etc)
+ * @param flags flags of the transaction (like nodeps, etc; see alpm_transflag_t)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags);
+int alpm_trans_init(alpm_handle_t *handle, int flags);
/** Prepare a transaction.
* @param handle the context handle
@@ -1612,7 +1632,8 @@ enum alpm_caps {
};
const char *alpm_version(void);
-enum alpm_caps alpm_capabilities(void);
+/* Return a bitfield of capabilities using values from 'enum alpm_caps' */
+int alpm_capabilities(void);
void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
void alpm_depmissing_free(alpm_depmissing_t *miss);
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index f3effc72..0f1b819c 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -1,7 +1,7 @@
/*
* alpm_list.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -132,6 +132,26 @@ alpm_list_t SYMEXPORT *alpm_list_append(alpm_list_t **list, void *data)
}
/**
+ * @brief Duplicate and append a string to a list.
+ *
+ * @param list the list to append to
+ * @param data the string to duplicate and append
+ *
+ * @return the newly added item
+ */
+alpm_list_t SYMEXPORT *alpm_list_append_strdup(alpm_list_t **list, const char *data)
+{
+ alpm_list_t *ret;
+ char *dup;
+ if((dup = strdup(data)) && (ret = alpm_list_append(list, dup))) {
+ return ret;
+ } else {
+ free(dup);
+ return NULL;
+ }
+}
+
+/**
* @brief Add items to a list in sorted order.
*
* @param list the list to add to
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index cf7d463f..1cb237d0 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -1,7 +1,7 @@
/*
* alpm_list.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -58,6 +58,7 @@ void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn);
/* item mutators */
alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
alpm_list_t *alpm_list_append(alpm_list_t **list, void *data);
+alpm_list_t *alpm_list_append_strdup(alpm_list_t **list, const char *data);
alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_join(alpm_list_t *first, alpm_list_t *second);
alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index 50bad5e6..f00440f0 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -1,7 +1,7 @@
/*
* backup.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h
index 5cf3f90a..17ff9ae0 100644
--- a/lib/libalpm/backup.h
+++ b/lib/libalpm/backup.h
@@ -1,7 +1,7 @@
/*
* backup.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 43c6bc93..97a49688 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -47,9 +47,9 @@
/* local database format version */
size_t ALPM_LOCAL_DB_VERSION = 9;
-static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
+static int local_db_read(alpm_pkg_t *info, int inforeq);
-#define LAZY_LOAD(info, errret) \
+#define LAZY_LOAD(info) \
do { \
if(!(pkg->infolevel & info)) { \
local_db_read(pkg, info); \
@@ -65,121 +65,121 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
static const char *_cache_get_base(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->base;
}
static const char *_cache_get_desc(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->desc;
}
static const char *_cache_get_url(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->url;
}
static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, 0);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->builddate;
}
static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, 0);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->installdate;
}
static const char *_cache_get_packager(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->packager;
}
static const char *_cache_get_arch(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->arch;
}
static off_t _cache_get_isize(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, -1);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->isize;
}
static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, -1);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->reason;
}
-static alpm_pkgvalidation_t _cache_get_validation(alpm_pkg_t *pkg)
+static int _cache_get_validation(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, -1);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->validation;
}
static alpm_list_t *_cache_get_licenses(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->licenses;
}
static alpm_list_t *_cache_get_groups(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->groups;
}
static int _cache_has_scriptlet(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_SCRIPTLET, NULL);
+ LAZY_LOAD(INFRQ_SCRIPTLET);
return pkg->scriptlet;
}
static alpm_list_t *_cache_get_depends(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->depends;
}
static alpm_list_t *_cache_get_optdepends(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->optdepends;
}
static alpm_list_t *_cache_get_conflicts(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->conflicts;
}
static alpm_list_t *_cache_get_provides(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->provides;
}
static alpm_list_t *_cache_get_replaces(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_DESC, NULL);
+ LAZY_LOAD(INFRQ_DESC);
return pkg->replaces;
}
static alpm_filelist_t *_cache_get_files(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_FILES, NULL);
+ LAZY_LOAD(INFRQ_FILES);
return &(pkg->files);
}
static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg)
{
- LAZY_LOAD(INFRQ_FILES, NULL);
+ LAZY_LOAD(INFRQ_FILES);
return pkg->backup;
}
@@ -660,7 +660,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
f = alpm_list_add(f, alpm_dep_from_string(line)); \
} while(1) /* note the while(1) and not (0) */
-static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
+static int local_db_read(alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
char line[1024];
@@ -817,14 +817,12 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
if(newfiles != NULL) {
files = newfiles;
}
-
- /* make sure the list is sorted */
- qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
} else {
FREE(files);
}
info->files.count = files_count;
info->files.files = files;
+ _alpm_filelist_sort(&info->files);
continue;
nomem:
while(files_count > 0) {
@@ -910,7 +908,7 @@ static void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
fputc('\n', fp);
}
-int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
+int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
mode_t oldmask;
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 430d2aeb..7e8b7920 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -223,9 +223,11 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
alpm_depend_t *optdep = alpm_dep_from_string(ptr);
newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep);
} else if(strcmp(key, "makedepend") == 0) {
- /* not used atm */
+ alpm_depend_t *makedep = alpm_dep_from_string(ptr);
+ newpkg->makedepends = alpm_list_add(newpkg->makedepends, makedep);
} else if(strcmp(key, "checkdepend") == 0) {
- /* not used atm */
+ alpm_depend_t *checkdep = alpm_dep_from_string(ptr);
+ newpkg->checkdepends = alpm_list_add(newpkg->checkdepends, checkdep);
} else if(strcmp(key, "conflict") == 0) {
alpm_depend_t *conflict = alpm_dep_from_string(ptr);
newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict);
@@ -270,11 +272,11 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
* @return 0 if package is fully valid, -1 and pm_errno otherwise
*/
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
- const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
- alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation)
+ const char *pkgfile, alpm_pkg_t *syncpkg, int level,
+ alpm_siglist_t **sigdata, int *validation)
{
int has_sig;
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
@@ -676,8 +678,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"sorting package filelist for %s\n", pkgfile);
- qsort(newpkg->files.files, newpkg->files.count,
- sizeof(alpm_file_t), _alpm_files_cmp);
+ _alpm_filelist_sort(&newpkg->files);
}
newpkg->infolevel |= INFRQ_FILES;
}
@@ -726,9 +727,9 @@ static int read_sigfile(const char *sigpath, unsigned char **sig)
}
int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
- alpm_siglevel_t level, alpm_pkg_t **pkg)
+ int level, alpm_pkg_t **pkg)
{
- alpm_pkgvalidation_t validation = 0;
+ int validation = 0;
char *sigpath;
CHECK_HANDLE(handle, return -1);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index a8362778..5f7d31ab 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -71,7 +71,7 @@ static char *get_sync_dir(alpm_handle_t *handle)
static int sync_db_validate(alpm_db_t *db)
{
- alpm_siglevel_t level;
+ int siglevel;
const char *dbpath;
if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) {
@@ -104,20 +104,20 @@ static int sync_db_validate(alpm_db_t *db)
/* this takes into account the default verification level if UNKNOWN
* was assigned to this db */
- level = alpm_db_get_siglevel(db);
+ siglevel = alpm_db_get_siglevel(db);
- if(level & ALPM_SIG_DATABASE) {
+ if(siglevel & ALPM_SIG_DATABASE) {
int retry, ret;
do {
retry = 0;
alpm_siglist_t *siglist;
ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL,
- level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
- level & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
+ siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
+ siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
if(ret) {
retry = _alpm_process_siglist(db->handle, db->treename, siglist,
- level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
- level & ALPM_SIG_DATABASE_UNKNOWN_OK);
+ siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
+ siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK);
}
alpm_siglist_cleanup(siglist);
free(siglist);
@@ -181,12 +181,12 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
int ret = -1;
mode_t oldmask;
alpm_handle_t *handle;
- alpm_siglevel_t level;
+ int siglevel;
/* Sanity checks */
ASSERT(db != NULL, return -1);
handle = db->handle;
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
@@ -207,7 +207,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* make sure we have a sane umask */
oldmask = umask(0022);
- level = alpm_db_get_siglevel(db);
+ siglevel = alpm_db_get_siglevel(db);
/* attempt to grab a lock */
if(_alpm_handle_lock(handle)) {
@@ -247,7 +247,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
_alpm_dload_payload_reset(&payload);
updated = (updated || ret == 0);
- if(ret != -1 && updated && (level & ALPM_SIG_DATABASE)) {
+ if(ret != -1 && updated && (siglevel & ALPM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) {
@@ -292,7 +292,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.handle = handle;
payload.force = 1;
- payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL);
+ payload.errors_ok = (siglevel & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
@@ -330,7 +330,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
alpm_strerror(handle->pm_errno));
} else {
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
}
_alpm_handle_unlock(handle);
@@ -343,7 +343,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
static int sync_db_read(alpm_db_t *db, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t **likely_pkg);
-static alpm_pkgvalidation_t _sync_get_validation(alpm_pkg_t *pkg)
+static int _sync_get_validation(alpm_pkg_t *pkg)
{
if(pkg->validation) {
return pkg->validation;
@@ -735,13 +735,12 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
/* attempt to hand back any memory we don't need */
if(files_count > 0) {
files = realloc(files, sizeof(alpm_file_t) * files_count);
- /* make sure the list is sorted */
- qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
} else {
FREE(files);
}
pkg->files.count = files_count;
pkg->files.files = files;
+ _alpm_filelist_sort(&pkg->files);
}
}
if(ret != ARCHIVE_EOF) {
@@ -769,7 +768,7 @@ struct db_operations sync_db_ops = {
};
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
- alpm_siglevel_t level)
+ int level)
{
alpm_db_t *db;
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 092b019a..d52f8942 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -1,7 +1,7 @@
/*
* conflict.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -278,12 +278,15 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
- if(pkg2) {
- conflict->type = ALPM_FILECONFLICT_TARGET;
- STRDUP(conflict->ctarget, pkg2->name, goto error);
- } else {
+ if(!pkg2) {
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
STRDUP(conflict->ctarget, "", goto error);
+ } else if(pkg2->origin == ALPM_PKG_FROM_LOCALDB) {
+ conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
+ STRDUP(conflict->ctarget, pkg2->name, goto error);
+ } else {
+ conflict->type = ALPM_FILECONFLICT_TARGET;
+ STRDUP(conflict->ctarget, pkg2->name, goto error);
}
conflicts = alpm_list_add(conflicts, conflict);
@@ -385,6 +388,23 @@ static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
return owners;
}
+static alpm_pkg_t *_alpm_find_file_owner(alpm_handle_t *handle, const char *path)
+{
+ alpm_list_t *i;
+ for(i = alpm_db_get_pkgcache(handle->db_local); i; i = i->next) {
+ if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
+ return i->data;
+ }
+ }
+ return NULL;
+}
+
+static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
+{
+ return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
+ || _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0;
+}
+
/**
* @brief Find file conflicts that may occur during the transaction.
*
@@ -419,7 +439,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(current = 0, i = upgrade; i; i = i->next, current++) {
alpm_pkg_t *p1 = i->data;
alpm_list_t *j;
- alpm_list_t *tmpfiles = NULL;
+ alpm_list_t *newfiles = NULL;
alpm_pkg_t *dbpkg;
int percent = (current * 100) / numtargs;
@@ -448,8 +468,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* can skip file-file conflicts when forced *
* checking presence in p2_files detects dir-file or file-dir
* conflicts as the path from p1 is returned */
- if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
- alpm_filelist_contains(p2_files, filename)) {
+ if(_alpm_can_overwrite_file(handle, filename)
+ && alpm_filelist_contains(p2_files, filename)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s exists in both '%s' and '%s'\n", filename,
p1->name, p2->name);
@@ -483,18 +503,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
* be freed. */
if(dbpkg) {
/* older ver of package currently installed */
- tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
+ newfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
alpm_pkg_get_files(dbpkg));
} else {
/* no version of package currently installed */
alpm_filelist_t *fl = alpm_pkg_get_files(p1);
size_t filenum;
for(filenum = 0; filenum < fl->count; filenum++) {
- tmpfiles = alpm_list_add(tmpfiles, fl->files[filenum].name);
+ newfiles = alpm_list_add(newfiles, fl->files[filenum].name);
}
}
- for(j = tmpfiles; j; j = j->next) {
+ for(j = newfiles; j; j = j->next) {
const char *filestr = j->data;
const char *relative_path;
alpm_list_t *k;
@@ -503,6 +523,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
struct stat lsbuf;
char path[PATH_MAX];
size_t pathlen;
+ int pfile_isdir;
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
relative_path = path + rootlen;
@@ -514,7 +535,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
- if(path[pathlen - 1] == '/') {
+ pfile_isdir = path[pathlen - 1] == '/';
+ if(pfile_isdir) {
if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
continue;
@@ -551,6 +573,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"local file will be removed, not a conflict\n");
resolved_conflict = 1;
+ if(pfile_isdir) {
+ /* go ahead and skip any files inside filestr as they will
+ * necessarily be resolved by replacing the file with a dir
+ * NOTE: afterward, j will point to the last file inside filestr */
+ size_t fslen = strlen(filestr);
+ for( ; j->next; j = j->next) {
+ const char *filestr2 = j->next->data;
+ if(strncmp(filestr, filestr2, fslen) != 0) {
+ break;
+ }
+ }
+ }
}
}
@@ -640,25 +674,26 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
}
/* skip file-file conflicts when being forced */
- if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
- !S_ISDIR(lsbuf.st_mode)) {
+ if(!S_ISDIR(lsbuf.st_mode)
+ && _alpm_can_overwrite_file(handle, filestr)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"conflict with file on filesystem being forced\n");
resolved_conflict = 1;
}
if(!resolved_conflict) {
- conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
+ conflicts = add_fileconflict(handle, conflicts, path, p1,
+ _alpm_find_file_owner(handle, relative_path));
if(handle->pm_errno == ALPM_ERR_MEMORY) {
alpm_list_free_inner(conflicts,
(alpm_list_fn_free) alpm_conflict_free);
alpm_list_free(conflicts);
- alpm_list_free(tmpfiles);
+ alpm_list_free(newfiles);
return NULL;
}
}
}
- alpm_list_free(tmpfiles);
+ alpm_list_free(newfiles);
}
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current);
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 801c201c..a2ae332d 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -1,7 +1,7 @@
/*
* conflict.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 f70f83c1..789478e8 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -1,7 +1,7 @@
/*
* db.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -44,7 +44,7 @@
/** Register a sync database of packages. */
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
- const char *treename, alpm_siglevel_t level)
+ const char *treename, int siglevel)
{
alpm_list_t *i;
@@ -67,7 +67,7 @@ alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
}
}
- return _alpm_db_register_sync(handle, treename, level);
+ return _alpm_db_register_sync(handle, treename, siglevel);
}
/* Helper function for alpm_db_unregister{_all} */
@@ -112,7 +112,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
ASSERT(db != NULL, return -1);
/* Do not unregister a database if a transaction is on-going */
handle = db->handle;
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) {
@@ -179,7 +179,7 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url);
@@ -206,7 +206,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url);
@@ -235,7 +235,7 @@ const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db)
}
/** Get the signature verification level for a database. */
-alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
+int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
if(db->siglevel & ALPM_SIG_USE_DEFAULT) {
@@ -249,7 +249,7 @@ alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
return db->ops->validate(db);
}
@@ -258,7 +258,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
{
alpm_pkg_t *pkg;
ASSERT(db != NULL, return NULL);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(name != NULL && strlen(name) != 0,
RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
@@ -273,7 +273,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_db_get_pkgcache(db);
}
@@ -292,7 +292,7 @@ alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
{
ASSERT(db != NULL, return NULL);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_db_get_groupcache(db);
}
@@ -301,13 +301,13 @@ alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
{
ASSERT(db != NULL, return NULL);
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_db_search(db, needles);
}
/** Sets the usage bitmask for a repo */
-int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
+int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
{
ASSERT(db != NULL, return -1);
db->usage = usage;
@@ -315,7 +315,7 @@ int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
}
/** Gets the usage bitmask for a repo */
-int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage)
+int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
{
ASSERT(db != NULL, return -1);
ASSERT(usage != NULL, return -1);
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index e6962985..e1c47d32 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -1,7 +1,7 @@
/*
* db.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -71,10 +71,14 @@ struct __alpm_db_t {
alpm_list_t *grpcache;
alpm_list_t *servers;
struct db_operations *ops;
- /* flags determining validity, local, loaded caches, etc. */
- enum _alpm_dbstatus_t status;
- alpm_siglevel_t siglevel;
- alpm_db_usage_t usage;
+
+ /* bitfields for validity, local, loaded caches, etc. */
+ /* From _alpm_dbstatus_t */
+ int status;
+ /* alpm_siglevel_t */
+ int siglevel;
+ /* alpm_db_usage_t */
+ int usage;
};
@@ -86,12 +90,12 @@ int _alpm_db_cmp(const void *d1, const void *d2);
alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
- alpm_siglevel_t level);
+ int level);
void _alpm_db_unregister(alpm_db_t *db);
/* be_*.c, backend specific calls */
int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info);
-int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
+int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq);
int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename);
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 6d6de056..89bc32ff 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -1,7 +1,7 @@
/*
* delta.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -71,7 +71,7 @@ static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse)
v_i->children = alpm_list_add(v_i->children, v_j);
}
}
- v_i->childptr = v_i->children;
+ v_i->iterator = v_i->children;
}
return vertices;
}
@@ -130,7 +130,7 @@ static void dijkstra(alpm_list_t *vertices)
for(i = vertices; i; i = i->next) {
alpm_graph_t *v_i = i->data;
- if(v_i->state == -1) {
+ if(v_i->state == ALPM_GRAPH_STATE_PROCESSING) {
continue;
}
@@ -142,18 +142,18 @@ static void dijkstra(alpm_list_t *vertices)
break;
}
- v->state = -1;
+ v->state = ALPM_GRAPH_STATE_PROCESSING;
- v->childptr = v->children;
- while(v->childptr) {
- alpm_graph_t *v_c = v->childptr->data;
+ v->iterator = v->children;
+ while(v->iterator) {
+ alpm_graph_t *v_c = v->iterator->data;
alpm_delta_t *d_c = v_c->data;
if(v_c->weight > v->weight + d_c->download_size) {
v_c->weight = v->weight + d_c->download_size;
v_c->parent = v;
}
- v->childptr = (v->childptr)->next;
+ v->iterator = (v->iterator)->next;
}
}
diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h
index 26c3c4ce..8fd02e7e 100644
--- a/lib/libalpm/delta.h
+++ b/lib/libalpm/delta.h
@@ -1,7 +1,7 @@
/*
* delta.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 ae5d60bc..96f91739 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -1,7 +1,7 @@
/*
* deps.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -152,12 +152,48 @@ static alpm_list_t *dep_graph_init(alpm_handle_t *handle,
j = next;
}
- vertex_i->childptr = vertex_i->children;
+ vertex_i->iterator = vertex_i->children;
}
alpm_list_free(localpkgs);
return vertices;
}
+static void _alpm_warn_dep_cycle(alpm_handle_t *handle, alpm_list_t *targets,
+ alpm_graph_t *ancestor, alpm_graph_t *vertex, int reverse)
+{
+ /* vertex depends on and is required by ancestor */
+ if(!alpm_list_find_ptr(targets, vertex->data)) {
+ /* child is not part of the transaction, not a problem */
+ return;
+ }
+
+ /* find the nearest ancestor that's part of the transaction */
+ while(ancestor) {
+ if(alpm_list_find_ptr(targets, ancestor->data)) {
+ break;
+ }
+ ancestor = ancestor->parent;
+ }
+
+ if(!ancestor || ancestor == vertex) {
+ /* no transaction package in our ancestry or the package has
+ * a circular dependency with itself, not a problem */
+ } else {
+ alpm_pkg_t *ancestorpkg = ancestor->data;
+ alpm_pkg_t *childpkg = vertex->data;
+ _alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
+ if(reverse) {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("%s will be removed after its %s dependency\n"),
+ ancestorpkg->name, childpkg->name);
+ } else {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("%s will be installed before its %s dependency\n"),
+ ancestorpkg->name, childpkg->name);
+ }
+ }
+}
+
/* Re-order a list of target packages with respect to their dependencies.
*
* Example (reverse == 0):
@@ -179,7 +215,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
{
alpm_list_t *newtargs = NULL;
alpm_list_t *vertices = NULL;
- alpm_list_t *vptr;
+ alpm_list_t *i;
alpm_graph_t *vertex;
if(targets == NULL) {
@@ -190,67 +226,35 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
vertices = dep_graph_init(handle, targets, ignore);
- vptr = vertices;
+ i = vertices;
vertex = vertices->data;
- while(vptr) {
+ while(i) {
/* mark that we touched the vertex */
- vertex->state = -1;
- int found = 0;
- while(vertex->childptr && !found) {
- alpm_graph_t *nextchild = vertex->childptr->data;
- vertex->childptr = vertex->childptr->next;
- if(nextchild->state == 0) {
- found = 1;
+ vertex->state = ALPM_GRAPH_STATE_PROCESSING;
+ int switched_to_child = 0;
+ while(vertex->iterator && !switched_to_child) {
+ alpm_graph_t *nextchild = vertex->iterator->data;
+ vertex->iterator = vertex->iterator->next;
+ if(nextchild->state == ALPM_GRAPH_STATE_UNPROCESSED) {
+ switched_to_child = 1;
nextchild->parent = vertex;
vertex = nextchild;
- } else if(nextchild->state == -1) {
- /* child is an ancestor of vertex */
- alpm_graph_t *transvertex = vertex;
-
- if(!alpm_list_find_ptr(targets, nextchild->data)) {
- /* child is not part of the transaction, not a problem */
- continue;
- }
-
- /* find the nearest parent that's part of the transaction */
- while(transvertex) {
- if(alpm_list_find_ptr(targets, transvertex->data)) {
- break;
- }
- transvertex = transvertex->parent;
- }
-
- if(!transvertex || transvertex == nextchild) {
- /* no transaction package in our ancestry or the package has
- * a circular dependency with itself, not a problem */
- } else {
- alpm_pkg_t *transpkg = transvertex->data;
- alpm_pkg_t *childpkg = nextchild->data;
- _alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
- if(reverse) {
- _alpm_log(handle, ALPM_LOG_WARNING,
- _("%s will be removed after its %s dependency\n"),
- transpkg->name, childpkg->name);
- } else {
- _alpm_log(handle, ALPM_LOG_WARNING,
- _("%s will be installed before its %s dependency\n"),
- transpkg->name, childpkg->name);
- }
- }
+ } else if(nextchild->state == ALPM_GRAPH_STATE_PROCESSING) {
+ _alpm_warn_dep_cycle(handle, targets, vertex, nextchild, reverse);
}
}
- if(!found) {
+ if(!switched_to_child) {
if(alpm_list_find_ptr(targets, vertex->data)) {
newtargs = alpm_list_add(newtargs, vertex->data);
}
/* mark that we've left this vertex */
- vertex->state = 1;
+ vertex->state = ALPM_GRAPH_STATE_PROCESSED;
vertex = vertex->parent;
if(!vertex) {
/* top level vertex reached, move to the next unprocessed vertex */
- for( vptr = vptr->next; vptr; vptr = vptr->next) {
- vertex = vptr->data;
- if(vertex->state == 0) {
+ for(i = i->next; i; i = i->next) {
+ vertex = i->data;
+ if(vertex->state == ALPM_GRAPH_STATE_UNPROCESSED) {
break;
}
}
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 91c6eb62..d1bb66ae 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -1,7 +1,7 @@
/*
* deps.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 da4ad560..7d80202c 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -1,7 +1,7 @@
/*
* diskspace.c
*
- * Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2017 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
@@ -348,11 +348,11 @@ static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp)
_alpm_log(handle, ALPM_LOG_DEBUG,
"partition %s, needed %jd, cushion %ju, free %ju\n",
mp->mount_dir, (intmax_t)mp->max_blocks_needed,
- (uintmax_t)cushion, (uintmax_t)mp->fsp.f_bfree);
- if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bfree) {
+ (uintmax_t)cushion, (uintmax_t)mp->fsp.f_bavail);
+ if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bavail) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("Partition %s too full: %jd blocks needed, %ju blocks free\n"),
- mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bfree);
+ mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bavail);
return 1;
}
return 0;
diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h
index 8c0e4e60..86bc4e45 100644
--- a/lib/libalpm/diskspace.h
+++ b/lib/libalpm/diskspace.h
@@ -1,7 +1,7 @@
/*
* diskspace.h
*
- * Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2017 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 dc57c929..875b689c 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -1,7 +1,7 @@
/*
* download.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -246,47 +246,6 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
return realsize;
}
-static int dload_sockopt_cb(void *userdata, curl_socket_t curlfd,
- curlsocktype purpose)
-{
- alpm_handle_t *handle = userdata;
- int optval = 1;
-
- /* this whole method is to prevent FTP control connections from going sour
- * during a long data transfer; crappy firewalls love to drop otherwise idle
- * connections if there is no traffic. */
- if(purpose != CURLSOCKTYPE_IPCXN) {
- return 0;
- }
-
- /* don't abort operation if any setsockopt fails, just log to debug */
- if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set SO_KEEPALIVE on fd %d\n", curlfd);
- }
- else {
-#ifdef TCP_KEEPIDLE
- optval = 60;
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set TCP_KEEPIDLE on fd %d\n", curlfd);
- }
-#endif
-#ifdef TCP_KEEPINTVL
- optval = 60;
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set TCP_KEEPINTVL on fd %d\n", curlfd);
- }
-#endif
- }
-
- return 0;
-}
-
static void curl_set_handle_opts(struct dload_payload *payload,
CURL *curl, char *error_buffer)
{
@@ -305,13 +264,16 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload);
- curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
- curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
+ if(!handle->disable_dl_timeout) {
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
+ }
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb);
- curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload);
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)payload);
curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
- curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, dload_sockopt_cb);
- curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, (void *)handle);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);
@@ -412,7 +374,7 @@ static int curl_download_internal(struct dload_payload *payload,
/* shortcut to our handle within the payload */
alpm_handle_t *handle = payload->handle;
CURL *curl = get_libcurl_handle(handle);
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
/* make sure these are NULL */
FREE(payload->tempfile_name);
@@ -712,7 +674,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
size_t len;
len = strlen(final_pkg_url) + 5;
- MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ MALLOC(payload.fileurl, len, free(final_file); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
sig_filepath = filecache_find_url(handle, payload.fileurl);
@@ -762,4 +724,14 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
memset(payload, '\0', sizeof(*payload));
}
+void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload)
+{
+ ASSERT(payload, return);
+
+ FREE(payload->fileurl);
+ payload->initial_size += payload->prevprogress;
+ payload->prevprogress = 0;
+ payload->unlink_on_fail = 0;
+}
+
/* vim: set noet: */
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 427c4860..6ca775a7 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -1,7 +1,7 @@
/*
* dload.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -47,6 +47,7 @@ struct dload_payload {
};
void _alpm_dload_payload_reset(struct dload_payload *payload);
+void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload);
int _alpm_download(struct dload_payload *payload, const char *localpath,
char **final_file, const char **final_url);
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 2d6d0715..b87c3f2e 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -1,7 +1,7 @@
/*
* error.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 5783373e..97f639a9 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -1,7 +1,7 @@
/*
* filelist.c
*
- * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2017 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
@@ -111,7 +111,7 @@ alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
/* Helper function for comparing files list entries
*/
-int _alpm_files_cmp(const void *f1, const void *f2)
+static int _alpm_files_cmp(const void *f1, const void *f2)
{
const alpm_file_t *file1 = f1;
const alpm_file_t *file2 = f2;
@@ -133,4 +133,17 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
sizeof(alpm_file_t), _alpm_files_cmp);
}
+void _alpm_filelist_sort(alpm_filelist_t *filelist)
+{
+ size_t i;
+ for(i = 1; i < filelist->count; i++) {
+ if(strcmp(filelist->files[i - 1].name, filelist->files[i].name) > 0) {
+ /* filelist is not pre-sorted */
+ qsort(filelist->files, filelist->count,
+ sizeof(alpm_file_t), _alpm_files_cmp);
+ return;
+ }
+ }
+}
+
/* vim: set noet: */
diff --git a/lib/libalpm/filelist.h b/lib/libalpm/filelist.h
index a74bdea0..c879058d 100644
--- a/lib/libalpm/filelist.h
+++ b/lib/libalpm/filelist.h
@@ -1,7 +1,7 @@
/*
* filelist.h
*
- * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2017 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
@@ -27,7 +27,7 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
alpm_filelist_t *filesB);
-int _alpm_files_cmp(const void *f1, const void *f2);
+void _alpm_filelist_sort(alpm_filelist_t *filelist);
#endif /* ALPM_FILELIST_H */
diff --git a/lib/libalpm/graph.c b/lib/libalpm/graph.c
index 8492ebee..137cd686 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2017 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 22f0aa9d..75cec937 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2017 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
@@ -23,13 +23,19 @@
#include "alpm_list.h"
+enum __alpm_graph_vertex_state {
+ ALPM_GRAPH_STATE_UNPROCESSED,
+ ALPM_GRAPH_STATE_PROCESSING,
+ ALPM_GRAPH_STATE_PROCESSED
+};
+
typedef struct __alpm_graph_t {
void *data;
struct __alpm_graph_t *parent; /* where did we come from? */
alpm_list_t *children;
- alpm_list_t *childptr; /* points to a child in children list */
+ alpm_list_t *iterator; /* used for DFS without recursion */
off_t weight; /* weight of the node */
- signed char state; /* 0: untouched, -1: entered, other: leaving time */
+ enum __alpm_graph_vertex_state state;
} alpm_graph_t;
alpm_graph_t *_alpm_graph_new(void);
diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c
index ecc4664b..19ddb72b 100644
--- a/lib/libalpm/group.c
+++ b/lib/libalpm/group.c
@@ -1,7 +1,7 @@
/*
* group.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 aa330761..c144c0d9 100644
--- a/lib/libalpm/group.h
+++ b/lib/libalpm/group.h
@@ -1,7 +1,7 @@
/*
* group.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 e9439a0b..b6b27881 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -1,7 +1,7 @@
/*
* handle.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -283,6 +283,12 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregroups(alpm_handle_t *handle)
return handle->ignoregroup;
}
+alpm_list_t SYMEXPORT *alpm_option_get_overwrite_files(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->overwrite_files;
+}
+
alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
@@ -657,6 +663,21 @@ int SYMEXPORT alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *
return _alpm_option_strlist_rem(handle, &(handle->ignoregroup), grp);
}
+int SYMEXPORT alpm_option_add_overwrite_file(alpm_handle_t *handle, const char *glob)
+{
+ return _alpm_option_strlist_add(handle, &(handle->overwrite_files), glob);
+}
+
+int SYMEXPORT alpm_option_set_overwrite_files(alpm_handle_t *handle, alpm_list_t *globs)
+{
+ return _alpm_option_strlist_set(handle, &(handle->overwrite_files), globs);
+}
+
+int SYMEXPORT alpm_option_remove_overwrite_file(alpm_handle_t *handle, const char *glob)
+{
+ return _alpm_option_strlist_rem(handle, &(handle->overwrite_files), glob);
+}
+
int SYMEXPORT alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
{
alpm_depend_t *depcpy;
@@ -777,7 +798,7 @@ int SYMEXPORT alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext)
}
int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
- alpm_siglevel_t level)
+ int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -790,14 +811,14 @@ int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
return 0;
}
-alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
+int SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
return handle->siglevel;
}
int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
- alpm_siglevel_t level)
+ int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -810,7 +831,7 @@ int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
return 0;
}
-alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
+int SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -821,7 +842,7 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *han
}
int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
- alpm_siglevel_t level)
+ int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -834,7 +855,7 @@ int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
return 0;
}
-alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
+int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -844,4 +865,14 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *ha
}
}
+int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle,
+ unsigned short disable_dl_timeout)
+{
+ CHECK_HANDLE(handle, return -1);
+#ifdef HAVE_LIBCURL
+ handle->disable_dl_timeout = disable_dl_timeout;
+#endif
+ return 0;
+}
+
/* vim: set noet: */
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index ecbe8370..115c3481 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -1,7 +1,7 @@
/*
* handle.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -60,6 +60,7 @@ struct __alpm_handle_t {
#ifdef HAVE_LIBCURL
/* libcurl handle */
CURL *curl; /* reusable curl_easy handle */
+ unsigned short disable_dl_timeout;
#endif
#ifdef HAVE_LIBGPGME
@@ -83,6 +84,7 @@ struct __alpm_handle_t {
char *gpgdir; /* Directory where GnuPG files are stored */
alpm_list_t *cachedirs; /* Paths to pacman cache directories */
alpm_list_t *hookdirs; /* Paths to hook directories */
+ alpm_list_t *overwrite_files; /* Paths that may be overwritten */
/* package lists */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
@@ -97,10 +99,10 @@ struct __alpm_handle_t {
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
int checkspace; /* Check disk space before installing */
char *dbext; /* Sync DB extension */
- alpm_siglevel_t siglevel; /* Default signature verification level */
- alpm_siglevel_t localfilesiglevel; /* Signature verification level for local file
+ int siglevel; /* Default signature verification level */
+ int localfilesiglevel; /* Signature verification level for local file
upgrade operations */
- alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file
+ int remotefilesiglevel; /* Signature verification level for remote file
upgrade operations */
/* error code */
diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c
index ccde225e..4ec2a906 100644
--- a/lib/libalpm/hook.c
+++ b/lib/libalpm/hook.c
@@ -1,7 +1,7 @@
/*
* hook.c
*
- * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2015-2017 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/hook.h b/lib/libalpm/hook.h
index f33dfe13..36528621 100644
--- a/lib/libalpm/hook.h
+++ b/lib/libalpm/hook.h
@@ -1,7 +1,7 @@
/*
* hook.h
*
- * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2015-2017 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/libalpm.pc.in b/lib/libalpm/libalpm.pc.in
index e4be1741..e1d74ef9 100644
--- a/lib/libalpm/libalpm.pc.in
+++ b/lib/libalpm/libalpm.pc.in
@@ -9,4 +9,4 @@ URL: http://www.archlinux.org/pacman/
Version: @LIB_VERSION@
Cflags: -I${includedir} @LFS_CFLAGS@
Libs: -L${libdir} -lalpm
-Libs.private: @LIBS@ @LIBARCHIVE_LIBS@ @LIBSSL_LIBS@ @LIBCURL_LIBS@ @GPGME_LIBS@
+Libs.private: @LIBS@ @LIBARCHIVE_LIBS@ @LIBSSL_LIBS@ @NETTLE_LIBS@ @LIBCURL_LIBS@ @GPGME_LIBS@
diff --git a/lib/libalpm/libarchive-compat.h b/lib/libalpm/libarchive-compat.h
index d4aa4fa2..9f081568 100644
--- a/lib/libalpm/libarchive-compat.h
+++ b/lib/libalpm/libarchive-compat.h
@@ -4,7 +4,7 @@
/*
* libarchive-compat.h
*
- * Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2017 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 56a788e6..9e986d69 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -1,7 +1,7 @@
/*
* log.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 79074fc6..6ec04561 100644
--- a/lib/libalpm/log.h
+++ b/lib/libalpm/log.h
@@ -1,7 +1,7 @@
/*
* log.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 f08df8b2..e9ecc178 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -60,7 +60,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
int retval;
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
/* We only inspect packages from sync repositories */
ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
@@ -69,9 +69,9 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
- if(retval == 0) {
- return 0;
- } else if(retval == 1) {
+ FREE(fpath);
+
+ if(retval == 1) {
pkg->handle->pm_errno = ALPM_ERR_PKG_INVALID;
retval = -1;
}
@@ -92,13 +92,15 @@ static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager;
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
-static alpm_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
+static int _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; }
static alpm_list_t *_pkg_get_groups(alpm_pkg_t *pkg) { return pkg->groups; }
static alpm_list_t *_pkg_get_depends(alpm_pkg_t *pkg) { return pkg->depends; }
static alpm_list_t *_pkg_get_optdepends(alpm_pkg_t *pkg) { return pkg->optdepends; }
+static alpm_list_t *_pkg_get_checkdepends(alpm_pkg_t *pkg) { return pkg->checkdepends; }
+static alpm_list_t *_pkg_get_makedepends(alpm_pkg_t *pkg) { return pkg->makedepends; }
static alpm_list_t *_pkg_get_conflicts(alpm_pkg_t *pkg) { return pkg->conflicts; }
static alpm_list_t *_pkg_get_provides(alpm_pkg_t *pkg) { return pkg->provides; }
static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; }
@@ -161,6 +163,8 @@ struct pkg_operations default_pkg_ops = {
.get_groups = _pkg_get_groups,
.get_depends = _pkg_get_depends,
.get_optdepends = _pkg_get_optdepends,
+ .get_checkdepends = _pkg_get_checkdepends,
+ .get_makedepends = _pkg_get_makedepends,
.get_conflicts = _pkg_get_conflicts,
.get_provides = _pkg_get_provides,
.get_replaces = _pkg_get_replaces,
@@ -184,196 +188,210 @@ struct pkg_operations default_pkg_ops = {
const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->filename;
}
const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_base(pkg);
}
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->name;
}
const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->version;
}
alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->origin;
}
const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_desc(pkg);
}
const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_url(pkg);
}
alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_builddate(pkg);
}
alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_installdate(pkg);
}
const char SYMEXPORT *alpm_pkg_get_packager(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_packager(pkg);
}
const char SYMEXPORT *alpm_pkg_get_md5sum(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->md5sum;
}
const char SYMEXPORT *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->sha256sum;
}
const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->base64_sig;
}
const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_arch(pkg);
}
off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->size;
}
off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_isize(pkg);
}
alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_reason(pkg);
}
-alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
+int SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_validation(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_licenses(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_groups(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_groups(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_depends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_optdepends(pkg);
}
+alpm_list_t SYMEXPORT *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg)
+{
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = ALPM_ERR_OK;
+ return pkg->ops->get_checkdepends(pkg);
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_makedepends(alpm_pkg_t *pkg)
+{
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = ALPM_ERR_OK;
+ return pkg->ops->get_makedepends(pkg);
+}
+
alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_conflicts(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_provides(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_provides(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_replaces(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->deltas;
}
alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_files(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_backup(pkg);
}
@@ -382,7 +400,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
/* Sanity checks */
ASSERT(pkg != NULL, return NULL);
ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->origin_data.db;
}
@@ -391,7 +409,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_open(pkg);
}
@@ -400,7 +418,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const alpm_pkg_t *pkg, void *fp)
{
ASSERT(pkg != NULL, return 0);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_read(ptr, size, pkg, fp);
}
@@ -408,7 +426,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_close(pkg, fp);
}
@@ -416,7 +434,7 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
{
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_open(pkg);
}
@@ -425,7 +443,7 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
struct archive_entry **entry)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_next(pkg, archive, entry);
}
@@ -433,14 +451,14 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_close(pkg, archive);
}
int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->has_scriptlet(pkg);
}
@@ -448,7 +466,7 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs,
int optional)
{
const alpm_list_t *i;
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
alpm_pkg_t *cachepkg = i->data;
@@ -478,7 +496,7 @@ static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
alpm_db_t *db;
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
if(pkg->origin == ALPM_PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 114d2250..8531b212 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -1,7 +1,7 @@
/*
* package.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -52,13 +52,15 @@ struct pkg_operations {
const char *(*get_arch) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *);
alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
- alpm_pkgvalidation_t (*get_validation) (alpm_pkg_t *);
+ int (*get_validation) (alpm_pkg_t *);
int (*has_scriptlet) (alpm_pkg_t *);
alpm_list_t *(*get_licenses) (alpm_pkg_t *);
alpm_list_t *(*get_groups) (alpm_pkg_t *);
alpm_list_t *(*get_depends) (alpm_pkg_t *);
alpm_list_t *(*get_optdepends) (alpm_pkg_t *);
+ alpm_list_t *(*get_checkdepends) (alpm_pkg_t *);
+ alpm_list_t *(*get_makedepends) (alpm_pkg_t *);
alpm_list_t *(*get_conflicts) (alpm_pkg_t *);
alpm_list_t *(*get_provides) (alpm_pkg_t *);
alpm_list_t *(*get_replaces) (alpm_pkg_t *);
@@ -112,6 +114,8 @@ struct __alpm_pkg_t {
alpm_list_t *backup;
alpm_list_t *depends;
alpm_list_t *optdepends;
+ alpm_list_t *checkdepends;
+ alpm_list_t *makedepends;
alpm_list_t *conflicts;
alpm_list_t *provides;
alpm_list_t *deltas;
@@ -130,11 +134,14 @@ struct __alpm_pkg_t {
char *file;
} origin_data;
- alpm_dbinfrq_t infolevel;
- alpm_pkgvalidation_t validation;
alpm_pkgfrom_t origin;
alpm_pkgreason_t reason;
int scriptlet;
+
+ /* Bitfield from alpm_dbinfrq_t */
+ int infolevel;
+ /* Bitfield from alpm_pkgvalidation_t */
+ int validation;
};
alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
@@ -145,8 +152,8 @@ void _alpm_pkg_free(alpm_pkg_t *pkg);
void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
- const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
- alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation);
+ const char *pkgfile, alpm_pkg_t *syncpkg, int level,
+ alpm_siglist_t **sigdata, int *validation);
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
const char *pkgfile, int full);
diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c
index 968218e2..45e63082 100644
--- a/lib/libalpm/pkghash.c
+++ b/lib/libalpm/pkghash.c
@@ -1,7 +1,7 @@
/*
* pkghash.c
*
- * Copyright (c) 2011-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2017 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 be064f69..dd163346 100644
--- a/lib/libalpm/pkghash.h
+++ b/lib/libalpm/pkghash.h
@@ -1,7 +1,7 @@
/*
* pkghash.h
*
- * Copyright (c) 2011-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2017 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 173dbc69..ffe92518 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -1,7 +1,7 @@
/*
* remove.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -440,8 +440,19 @@ static int unlink_file(alpm_handle_t *handle, alpm_pkg_t *oldpkg,
{
struct stat buf;
char file[PATH_MAX];
+ int file_len;
- snprintf(file, PATH_MAX, "%s%s", handle->root, fileobj->name);
+ file_len = snprintf(file, PATH_MAX, "%s%s", handle->root, fileobj->name);
+ if(file_len <= 0 || file_len >= PATH_MAX) {
+ /* 0 is a valid value from snprintf, but should be impossible here */
+ _alpm_log(handle, ALPM_LOG_DEBUG, "path too long to unlink %s%s\n",
+ handle->root, fileobj->name);
+ return -1;
+ } else if(file[file_len-1] == '/') {
+ /* trailing slashes cause errors and confusing messages if the user has
+ * replaced a directory with a symlink */
+ file[--file_len] = '\0';
+ }
if(llstat(file, &buf)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file %s does not exist\n", file);
diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h
index b26ea602..c7c5fba9 100644
--- a/lib/libalpm/remove.h
+++ b/lib/libalpm/remove.h
@@ -1,7 +1,7 @@
/*
* remove.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 6557c200..95cb3280 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -1,7 +1,7 @@
/*
* signing.c
*
- * Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2017 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
@@ -356,6 +356,10 @@ static int key_search(alpm_handle_t *handle, const char *fpr,
#if GPGME_VERSION_NUMBER >= 0x010500
case GPGME_PK_ECC:
#endif
+/* value added in gpgme 1.7.0 */
+#if GPGME_VERSION_NUMBER >= 0x010700
+ case GPGME_PK_EDDSA:
+#endif
pgpkey->pubkey_algo = 'E';
break;
}
@@ -771,7 +775,7 @@ int _alpm_check_pgp_helper(alpm_handle_t *handle, const char *path,
if(ret && handle->pm_errno == ALPM_ERR_SIG_MISSING) {
if(optional) {
_alpm_log(handle, ALPM_LOG_DEBUG, "missing optional signature\n");
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
ret = 0;
} else {
_alpm_log(handle, ALPM_LOG_DEBUG, "missing required signature\n");
@@ -931,7 +935,7 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg,
{
ASSERT(pkg != NULL, return -1);
ASSERT(siglist != NULL, RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
return _alpm_gpgme_checksig(pkg->handle, pkg->filename,
pkg->base64_sig, siglist);
@@ -948,7 +952,7 @@ int SYMEXPORT alpm_db_check_pgp_signature(alpm_db_t *db,
{
ASSERT(db != NULL, return -1);
ASSERT(siglist != NULL, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
- db->handle->pm_errno = 0;
+ db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_gpgme_checksig(db->handle, _alpm_db_path(db), NULL, siglist);
}
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index 960b644c..3507f584 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -1,7 +1,7 @@
/*
* signing.h
*
- * Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2017 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 00b68d05..ae0f1e49 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -1,7 +1,7 @@
/*
* sync.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -57,7 +57,7 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
alpm_pkg_t *spkg = NULL;
ASSERT(pkg != NULL, return NULL);
- pkg->handle->pm_errno = 0;
+ pkg->handle->pm_errno = ALPM_ERR_OK;
for(i = dbs_sync; !spkg && i; i = i->next) {
alpm_db_t *db = i->data;
@@ -460,7 +460,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
transaction. The packages will be removed from the actual
transaction when the transaction packages are replaced with a
dependency-reordered list below */
- handle->pm_errno = 0;
+ handle->pm_errno = ALPM_ERR_OK;
if(data) {
alpm_list_free_inner(*data,
(alpm_list_fn_free)alpm_depmissing_free);
@@ -946,9 +946,7 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
EVENT(handle, &event);
return 0;
}
-
- FREE(payload->fileurl);
- payload->unlink_on_fail = 0;
+ _alpm_dload_payload_reset_for_retry(payload);
}
event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
@@ -1056,7 +1054,7 @@ static int check_keyring(alpm_handle_t *handle)
for(i = handle->trans->add; i; i = i->next, current++) {
alpm_pkg_t *pkg = i->data;
- alpm_siglevel_t level;
+ int level;
int percent = (current * 100) / numtargs;
PROGRESS(handle, ALPM_PROGRESS_KEYRING_START, "", percent,
@@ -1126,8 +1124,8 @@ static int check_validity(alpm_handle_t *handle,
alpm_pkg_t *pkg;
char *path;
alpm_siglist_t *siglist;
- alpm_siglevel_t level;
- alpm_pkgvalidation_t validation;
+ int siglevel;
+ int validation;
alpm_errno_t error;
};
size_t current = 0;
@@ -1151,10 +1149,10 @@ static int check_validity(alpm_handle_t *handle,
current_bytes += v.pkg->size;
v.path = _alpm_filecache_find(handle, v.pkg->filename);
- v.level = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg));
+ v.siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg));
if(_alpm_pkg_validate_internal(handle, v.path, v.pkg,
- v.level, &v.siglist, &v.validation) == -1) {
+ v.siglevel, &v.siglist, &v.validation) == -1) {
struct validity *invalid;
v.error = handle->pm_errno;
MALLOC(invalid, sizeof(struct validity), return -1);
@@ -1181,9 +1179,9 @@ static int check_validity(alpm_handle_t *handle,
_("%s: missing required signature\n"), v->pkg->name);
} else if(v->error == ALPM_ERR_PKG_INVALID_SIG) {
_alpm_process_siglist(handle, v->pkg->name, v->siglist,
- v->level & ALPM_SIG_PACKAGE_OPTIONAL,
- v->level & ALPM_SIG_PACKAGE_MARGINAL_OK,
- v->level & ALPM_SIG_PACKAGE_UNKNOWN_OK);
+ v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL,
+ v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK,
+ v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK);
prompt_to_delete(handle, v->path, v->error);
} else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) {
prompt_to_delete(handle, v->path, v->error);
@@ -1195,7 +1193,7 @@ static int check_validity(alpm_handle_t *handle,
}
alpm_list_free(errors);
- if(!handle->pm_errno) {
+ if(handle->pm_errno == ALPM_ERR_OK) {
RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
}
return -1;
@@ -1280,7 +1278,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
EVENT(handle, &event);
if(errors) {
- if(!handle->pm_errno) {
+ if(handle->pm_errno == ALPM_ERR_OK) {
RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
}
return -1;
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index 1aa48b7a..882e90f0 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -1,7 +1,7 @@
/*
* sync.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 13984707..7689079b 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -1,7 +1,7 @@
/*
* trans.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -48,7 +48,7 @@
*/
/** Initialize the transaction. */
-int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags)
+int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, int flags)
{
alpm_trans_t *trans;
@@ -305,6 +305,7 @@ void _alpm_trans_free(alpm_trans_t *trans)
static int grep(const char *fn, const char *needle)
{
FILE *fp;
+ char *ptr;
if((fp = fopen(fn, "r")) == NULL) {
return 0;
@@ -314,6 +315,9 @@ static int grep(const char *fn, const char *needle)
if(safe_fgets(line, sizeof(line), fp) == NULL) {
continue;
}
+ if((ptr = strchr(line, '#')) != NULL) {
+ *ptr = '\0';
+ }
/* TODO: this will not work if the search string
* ends up being split across line reads */
if(strstr(line, needle)) {
@@ -415,7 +419,7 @@ cleanup:
return retval;
}
-alpm_transflag_t SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle)
+int SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle)
{
/* Sanity checks */
CHECK_HANDLE(handle, return -1);
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 73111be4..f97db9ee 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -1,7 +1,7 @@
/*
* trans.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -37,7 +37,8 @@ typedef enum _alpm_transstate_t {
/* Transaction */
struct __alpm_trans_t {
- alpm_transflag_t flags;
+ /* bitfield of alpm_transflag_t flags */
+ int flags;
alpm_transstate_t state;
alpm_list_t *unresolvable; /* list of (alpm_pkg_t *) */
alpm_list_t *add; /* list of (alpm_pkg_t *) */
@@ -46,7 +47,8 @@ struct __alpm_trans_t {
};
void _alpm_trans_free(alpm_trans_t *trans);
-int _alpm_trans_init(alpm_trans_t *trans, alpm_transflag_t flags);
+/* flags is a bitfield of alpm_transflag_t flags */
+int _alpm_trans_init(alpm_trans_t *trans, int flags);
int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath,
const char *script, const char *ver, const char *oldver, int is_archive);
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 7ef4bf34..35fc7f41 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -1,7 +1,7 @@
/*
* util.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -30,6 +30,7 @@
#include <errno.h>
#include <limits.h>
#include <sys/wait.h>
+#include <sys/socket.h>
#include <fnmatch.h>
#include <poll.h>
@@ -42,6 +43,11 @@
#include <openssl/sha.h>
#endif
+#ifdef HAVE_LIBNETTLE
+#include <nettle/md5.h>
+#include <nettle/sha2.h>
+#endif
+
/* libalpm */
#include "util.h"
#include "log.h"
@@ -458,7 +464,6 @@ static int _alpm_chroot_write_to_child(alpm_handle_t *handle, int fd,
_alpm_cb_io out_cb, void *cb_ctx)
{
ssize_t nwrite;
- struct sigaction newaction, oldaction;
if(*buf_size == 0) {
/* empty buffer, ask the callback for more */
@@ -468,16 +473,7 @@ static int _alpm_chroot_write_to_child(alpm_handle_t *handle, int fd,
}
}
- /* ignore SIGPIPE in case the pipe has been closed */
- newaction.sa_handler = SIG_IGN;
- sigemptyset(&newaction.sa_mask);
- newaction.sa_flags = 0;
- sigaction(SIGPIPE, &newaction, &oldaction);
-
- nwrite = write(fd, buf, *buf_size);
-
- /* restore previous SIGPIPE handler */
- sigaction(SIGPIPE, &oldaction, NULL);
+ nwrite = send(fd, buf, *buf_size, MSG_NOSIGNAL);
if(nwrite != -1) {
/* write was successful, remove the written data from the buffer */
@@ -568,6 +564,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
int cwdfd;
int retval = 0;
+#define HEAD 1
+#define TAIL 0
+
/* save the cwd so we can restore it later */
OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
if(cwdfd < 0) {
@@ -587,13 +586,13 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
/* Flush open fds before fork() to avoid cloning buffers */
fflush(NULL);
- if(pipe(child2parent_pipefd) == -1) {
+ if(socketpair(AF_UNIX, SOCK_STREAM, 0, child2parent_pipefd) == -1) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno));
retval = 1;
goto cleanup;
}
- if(pipe(parent2child_pipefd) == -1) {
+ if(socketpair(AF_UNIX, SOCK_STREAM, 0, parent2child_pipefd) == -1) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno));
retval = 1;
goto cleanup;
@@ -612,13 +611,13 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
close(0);
close(1);
close(2);
- while(dup2(child2parent_pipefd[1], 1) == -1 && errno == EINTR);
- while(dup2(child2parent_pipefd[1], 2) == -1 && errno == EINTR);
- while(dup2(parent2child_pipefd[0], 0) == -1 && errno == EINTR);
- close(parent2child_pipefd[0]);
- close(parent2child_pipefd[1]);
- close(child2parent_pipefd[0]);
- close(child2parent_pipefd[1]);
+ while(dup2(child2parent_pipefd[HEAD], 1) == -1 && errno == EINTR);
+ while(dup2(child2parent_pipefd[HEAD], 2) == -1 && errno == EINTR);
+ while(dup2(parent2child_pipefd[TAIL], 0) == -1 && errno == EINTR);
+ close(parent2child_pipefd[TAIL]);
+ close(parent2child_pipefd[HEAD]);
+ close(child2parent_pipefd[TAIL]);
+ close(child2parent_pipefd[HEAD]);
if(cwdfd >= 0) {
close(cwdfd);
}
@@ -647,20 +646,20 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
nfds_t nfds = 2;
struct pollfd fds[2], *child2parent = &(fds[0]), *parent2child = &(fds[1]);
- child2parent->fd = child2parent_pipefd[0];
+ child2parent->fd = child2parent_pipefd[TAIL];
child2parent->events = POLLIN;
fcntl(child2parent->fd, F_SETFL, O_NONBLOCK);
- close(child2parent_pipefd[1]);
- close(parent2child_pipefd[0]);
+ close(child2parent_pipefd[HEAD]);
+ close(parent2child_pipefd[TAIL]);
if(stdin_cb) {
- parent2child->fd = parent2child_pipefd[1];
+ parent2child->fd = parent2child_pipefd[HEAD];
parent2child->events = POLLOUT;
fcntl(parent2child->fd, F_SETFL, O_NONBLOCK);
} else {
parent2child->fd = -1;
parent2child->events = 0;
- close(parent2child_pipefd[1]);
+ close(parent2child_pipefd[HEAD]);
}
#define STOP_POLLING(p) do { close(p->fd); p->fd = -1; } while(0)
@@ -695,6 +694,8 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
}
#undef STOP_POLLING
+#undef HEAD
+#undef TAIL
if(parent2child->fd != -1) {
close(parent2child->fd);
@@ -856,7 +857,7 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle)
return cachedir;
}
-#ifdef HAVE_LIBSSL
+#if defined HAVE_LIBSSL || defined HAVE_LIBNETTLE
/** Compute the MD5 message digest of a file.
* @param path file path of file to compute MD5 digest of
* @param output string to hold computed MD5 digest
@@ -864,7 +865,11 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle)
*/
static int md5_file(const char *path, unsigned char output[16])
{
+#if HAVE_LIBSSL
MD5_CTX ctx;
+#else /* HAVE_LIBNETTLE */
+ struct md5_ctx ctx;
+#endif
unsigned char *buf;
ssize_t n;
int fd;
@@ -877,13 +882,21 @@ static int md5_file(const char *path, unsigned char output[16])
return 1;
}
+#if HAVE_LIBSSL
MD5_Init(&ctx);
+#else /* HAVE_LIBNETTLE */
+ md5_init(&ctx);
+#endif
while((n = read(fd, buf, ALPM_BUFFER_SIZE)) > 0 || errno == EINTR) {
if(n < 0) {
continue;
}
+#if HAVE_LIBSSL
MD5_Update(&ctx, buf, n);
+#else /* HAVE_LIBNETTLE */
+ md5_update(&ctx, n, buf);
+#endif
}
close(fd);
@@ -893,7 +906,11 @@ static int md5_file(const char *path, unsigned char output[16])
return 2;
}
+#if HAVE_LIBSSL
MD5_Final(output, &ctx);
+#else /* HAVE_LIBNETTLE */
+ md5_digest(&ctx, MD5_DIGEST_SIZE, output);
+#endif
return 0;
}
@@ -904,7 +921,11 @@ static int md5_file(const char *path, unsigned char output[16])
*/
static int sha256_file(const char *path, unsigned char output[32])
{
+#if HAVE_LIBSSL
SHA256_CTX ctx;
+#else /* HAVE_LIBNETTLE */
+ struct sha256_ctx ctx;
+#endif
unsigned char *buf;
ssize_t n;
int fd;
@@ -917,13 +938,21 @@ static int sha256_file(const char *path, unsigned char output[32])
return 1;
}
+#if HAVE_LIBSSL
SHA256_Init(&ctx);
+#else /* HAVE_LIBNETTLE */
+ sha256_init(&ctx);
+#endif
while((n = read(fd, buf, ALPM_BUFFER_SIZE)) > 0 || errno == EINTR) {
if(n < 0) {
continue;
}
+#if HAVE_LIBSSL
SHA256_Update(&ctx, buf, n);
+#else /* HAVE_LIBNETTLE */
+ sha256_update(&ctx, n, buf);
+#endif
}
close(fd);
@@ -933,10 +962,14 @@ static int sha256_file(const char *path, unsigned char output[32])
return 2;
}
+#if HAVE_LIBSSL
SHA256_Final(output, &ctx);
+#else /* HAVE_LIBNETTLE */
+ sha256_digest(&ctx, SHA256_DIGEST_SIZE, output);
+#endif
return 0;
}
-#endif
+#endif /* HAVE_LIBSSL || HAVE_LIBNETTLE */
/** Create a string representing bytes in hexadecimal.
* @param bytes the bytes to represent in hexadecimal
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 5a2c105d..e1423ce3 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -1,7 +1,7 @@
/*
* util.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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>
@@ -77,7 +77,7 @@ void _alpm_alloc_fail(size_t size);
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
-#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
+#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = ALPM_ERR_OK; } while(0)
/** Standard buffer size used throughout the library. */
#ifdef BUFSIZ
@@ -131,6 +131,8 @@ int _alpm_ldconfig(alpm_handle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
const char *_alpm_filecache_setup(alpm_handle_t *handle);
+/* Unlike many uses of alpm_pkgvalidation_t, _alpm_test_checksum expects
+ * an enum value rather than a bitfield. */
int _alpm_test_checksum(const char *filepath, const char *expected, alpm_pkgvalidation_t type);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
int _alpm_splitname(const char *target, char **name, char **version,
diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c
index 29c41834..64dbe6f0 100644
--- a/lib/libalpm/version.c
+++ b/lib/libalpm/version.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/.gitignore b/scripts/.gitignore
index 8dac5035..3a5ac8a7 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -1,10 +1,9 @@
makepkg
makepkg-template
-makepkg-wrapper
pacman-db-upgrade
pacman-key
-pacman-optimize
pkgdelta
repo-add
repo-elephant
repo-remove
+*-wrapper
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index e4f9fb1b..4bb08a24 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,39 +1,41 @@
# enforce that all scripts have a --help and --version option
AUTOMAKE_OPTIONS = std-options
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = makepkg-wrapper
+AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = \
+ makepkg-wrapper \
+ pacman-db-upgrade-wrapper \
+ pacman-key-wrapper \
+ pkgdelta-wrapper
SUBDIRS = po
bin_SCRIPTS = \
$(OURSCRIPTS) \
makepkg-template \
- makepkg-wrapper \
repo-remove \
- repo-elephant
+ repo-elephant \
+ $(WRAPPER)
OURSCRIPTS = \
makepkg \
pacman-db-upgrade \
pacman-key \
- pacman-optimize \
pkgdelta \
repo-add
EXTRA_DIST = \
makepkg.sh.in \
makepkg-template.pl.in \
- makepkg-wrapper.sh.in \
pacman-db-upgrade.sh.in \
pacman-key.sh.in \
- pacman-optimize.sh.in \
pkgdelta.sh.in \
repo-add.sh.in \
+ wrapper.sh.in \
+ $(COMPLETION_DIST) \
$(LIBRARY) \
$(LIBMAKEPKG_DIST)
LIBRARY = \
library/output_format.sh \
- library/parseopts.sh \
library/human_to_size.sh \
library/size_to_human.sh \
library/term_colors.sh
@@ -48,11 +50,6 @@ LIBMAKEPKGDIRS = \
tidy \
util
-LIBMAKEPKG = \
- libmakepkg/util/message.sh \
- libmakepkg/util/option.sh \
- libmakepkg/util/util.sh
-
LIBMAKEPKG_IN = \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
@@ -61,6 +58,8 @@ LIBMAKEPKG_IN = \
libmakepkg/integrity/verify_signature.sh \
libmakepkg/lint_package.sh \
libmakepkg/lint_package/build_references.sh \
+ libmakepkg/lint_package/dotfiles.sh \
+ libmakepkg/lint_package/file_names.sh \
libmakepkg/lint_package/missing_backup.sh \
libmakepkg/lint_pkgbuild.sh \
libmakepkg/lint_pkgbuild/arch.sh \
@@ -97,15 +96,31 @@ LIBMAKEPKG_IN = \
libmakepkg/tidy/strip.sh \
libmakepkg/tidy/zipman.sh \
libmakepkg/util.sh \
+ libmakepkg/util/message.sh \
+ libmakepkg/util/option.sh \
+ libmakepkg/util/parseopts.sh \
libmakepkg/util/pkgbuild.sh \
- libmakepkg/util/source.sh
+ libmakepkg/util/source.sh \
+ libmakepkg/util/util.sh
LIBMAKEPKG_DIST = \
- $(LIBMAKEPKG) \
$(addsuffix .in, $(LIBMAKEPKG_IN))
+WRAPPER = \
+ makepkg-wrapper \
+ pacman-db-upgrade-wrapper \
+ pacman-key-wrapper \
+ pkgdelta-wrapper
+
+COMPLETION_IN = \
+ completion/bash_completion \
+ completion/zsh_completion
+
+COMPLETION_DIST = \
+ $(addsuffix .in, $(COMPLETION_IN))
+
# Files that should be removed, but which Automake does not know.
-MOSTLYCLEANFILES = $(bin_SCRIPTS) $(LIBMAKEPKG_IN)
+MOSTLYCLEANFILES = $(bin_SCRIPTS) $(LIBMAKEPKG_IN) $(COMPLETION_IN)
clean-local:
$(AM_V_at)$(RM) -r .lib
@@ -159,10 +174,17 @@ $(LIBMAKEPKG_IN): %: %.in Makefile
$(AM_V_at)chmod a-w $@
@$(BASH_SHELL) -O extglob -n $@
+$(COMPLETION_IN): %: %.in Makefile
+ $(AM_V_at)$(RM) $@
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@
+ $(AM_V_at)chmod a-w $@
+
+all-am: $(COMPLETION_IN)
+
makepkg: \
$(srcdir)/makepkg.sh.in \
- $(srcdir)/makepkg-wrapper.sh.in \
- $(srcdir)/library/parseopts.sh \
+ $(srcdir)/wrapper.sh.in \
$(LIBMAKEPKG_IN)
makepkg-template: \
@@ -179,17 +201,11 @@ pacman-db-upgrade: \
pacman-key: \
$(srcdir)/pacman-key.sh.in \
- $(srcdir)/library/output_format.sh \
- $(srcdir)/library/parseopts.sh
-
-pacman-optimize: \
- $(srcdir)/pacman-optimize.sh.in \
$(srcdir)/library/output_format.sh
pkgdelta: \
$(srcdir)/pkgdelta.sh.in \
- $(srcdir)/library/output_format.sh \
- $(srcdir)/library/parseopts.sh
+ $(srcdir)/library/output_format.sh
repo-add: \
$(srcdir)/repo-add.sh.in \
@@ -203,26 +219,36 @@ repo-elephant: $(srcdir)/repo-add.sh.in
$(AM_V_at)$(RM) repo-elephant
$(AM_V_at)$(LN_S) repo-add repo-elephant
-makepkg-wrapper: \
- Makefile \
- $(srcdir)/makepkg-wrapper.sh.in \
- $(srcdir)/makepkg.sh.in \
- $(srcdir)/library/parseopts.sh \
- | makepkg
+.SECONDEXPANSION:
+$(WRAPPER): \
+ $$(subst -wrapper,,$$@)
+
$(AM_V_at)$(MKDIR_P) .lib
- $(AM_V_at)mv -f makepkg .lib
+ $(AM_V_at)mv -f $(subst -wrapper,,$@) .lib
$(AM_V_at)$(RM) $@
$(AM_V_GEN)sed \
-e "s|@PWD[@]|$$(pwd)|" \
+ -e "s|@PROGNAME[@]|$(subst -wrapper,,$@)|g" \
-e '1s|!/bin/bash|!$(BASH_SHELL)|g' \
- $(srcdir)/$@.sh.in > $@
+ $(srcdir)/wrapper.sh.in > $@
$(AM_V_at)chmod +x,a-w $@
- $(AM_V_at)$(LN_S) makepkg-wrapper makepkg
+ $(AM_V_at)$(LN_S) $@ $(subst -wrapper,,$@)
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
+ $(INSTALL_DATA) completion/bash_completion $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
+ $(MKDIR_P) $(DESTDIR)$(datarootdir)/zsh/site-functions/
+ $(INSTALL_DATA) completion/zsh_completion $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
+ $(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
install-exec-hook:
- cd $(DESTDIR)$(bindir) && \
- $(RM) makepkg makepkg-wrapper
- $(INSTALL) .lib/makepkg $(DESTDIR)$(bindir)/makepkg
+ for wrapper in $(WRAPPER); do \
+ $(RM) $(DESTDIR)$(bindir)/$${wrapper}; \
+ $(INSTALL) .lib/$${wrapper%-wrapper} $(DESTDIR)$(bindir)/$${wrapper%-wrapper}; \
+ done
for dir in $(LIBMAKEPKGDIRS); do \
$(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/$$dir; \
done
@@ -253,4 +279,5 @@ uninstall-hook:
$(RM) -r $(DESTDIR)$(libmakepkgdir)/$$dir; \
done
+
# vim:set noet:
diff --git a/scripts/completion/.gitignore b/scripts/completion/.gitignore
new file mode 100644
index 00000000..881bfd14
--- /dev/null
+++ b/scripts/completion/.gitignore
@@ -0,0 +1,2 @@
+bash_completion
+zsh_completion
diff --git a/contrib/bash_completion.in b/scripts/completion/bash_completion.in
index 06963c42..06963c42 100644
--- a/contrib/bash_completion.in
+++ b/scripts/completion/bash_completion.in
diff --git a/contrib/zsh_completion.in b/scripts/completion/zsh_completion.in
index f74fa297..f74fa297 100644
--- a/contrib/zsh_completion.in
+++ b/scripts/completion/zsh_completion.in
diff --git a/scripts/libmakepkg/.gitignore b/scripts/libmakepkg/.gitignore
index 941d39a5..ceb7bfc4 100644
--- a/scripts/libmakepkg/.gitignore
+++ b/scripts/libmakepkg/.gitignore
@@ -10,5 +10,8 @@ srcinfo.sh
tidy.sh
tidy/*.sh
util.sh
+util/message.sh
+util/option.sh
+util/parseopts.sh
util/pkgbuild.sh
util/source.sh
diff --git a/scripts/libmakepkg/integrity.sh.in b/scripts/libmakepkg/integrity.sh.in
index cb8159d3..3a77ef16 100644
--- a/scripts/libmakepkg/integrity.sh.in
+++ b/scripts/libmakepkg/integrity.sh.in
@@ -2,7 +2,7 @@
#
# integrity.sh - functions relating to source integrity checking
#
-# Copyright (c) 2011-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2011-2017 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/libmakepkg/integrity/generate_checksum.sh.in b/scripts/libmakepkg/integrity/generate_checksum.sh.in
index 7a567100..902a989e 100644
--- a/scripts/libmakepkg/integrity/generate_checksum.sh.in
+++ b/scripts/libmakepkg/integrity/generate_checksum.sh.in
@@ -2,7 +2,7 @@
#
# generate_checksum.sh - functions for generating source checksums
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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
@@ -59,8 +59,8 @@ generate_one_checksum() {
if [[ $netfile != *.@(sig?(n)|asc) ]]; then
local file
file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
- sum="$(openssl dgst -${integ} "$file")"
- sum=${sum##* }
+ sum="$("${integ}sum" "$file")"
+ sum=${sum%% *}
else
sum="SKIP"
fi
@@ -80,11 +80,6 @@ generate_one_checksum() {
generate_checksums() {
msg "$(gettext "Generating checksums for source files...")"
- if ! type -p openssl >/dev/null; then
- error "$(gettext "Cannot find the %s binary required for generating sourcefile checksums.")" "openssl"
- exit 1 # $E_MISSING_PROGRAM
- fi
-
local integlist
if (( $# == 0 )); then
IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
diff --git a/scripts/libmakepkg/integrity/generate_signature.sh.in b/scripts/libmakepkg/integrity/generate_signature.sh.in
index d7f7cb14..060ae344 100644
--- a/scripts/libmakepkg/integrity/generate_signature.sh.in
+++ b/scripts/libmakepkg/integrity/generate_signature.sh.in
@@ -2,7 +2,7 @@
#
# generate_signature.sh - functions for generating PGP signatures
#
-# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2008-2017 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/libmakepkg/integrity/verify_checksum.sh.in b/scripts/libmakepkg/integrity/verify_checksum.sh.in
index 44a2b2e1..1a11a082 100644
--- a/scripts/libmakepkg/integrity/verify_checksum.sh.in
+++ b/scripts/libmakepkg/integrity/verify_checksum.sh.in
@@ -2,7 +2,7 @@
#
# verify_checksum.sh - functions for checking source checksums
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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
@@ -82,8 +82,8 @@ verify_integrity_one() {
return 1
fi
- local realsum="$(openssl dgst -${integ} "$file")"
- realsum="${realsum##* }"
+ local realsum="$("${integ}sum" "$file")"
+ realsum="${realsum%% *}"
if [[ ${expectedsum,,} = "$realsum" ]]; then
printf '%s\n' "$(gettext "Passed")" >&2
else
diff --git a/scripts/libmakepkg/integrity/verify_signature.sh.in b/scripts/libmakepkg/integrity/verify_signature.sh.in
index 6df62727..b5577523 100644
--- a/scripts/libmakepkg/integrity/verify_signature.sh.in
+++ b/scripts/libmakepkg/integrity/verify_signature.sh.in
@@ -2,7 +2,7 @@
#
# verify_signature.sh - functions for checking PGP signatures
#
-# Copyright (c) 2011-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2011-2017 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
@@ -32,7 +32,7 @@ check_pgpsigs() {
msg "$(gettext "Verifying source file signatures with %s...")" "gpg"
- local file ext decompress found pubkey success status fingerprint trusted
+ local netfile proto pubkey success status fingerprint trusted
local warning=0
local errors=0
local statusfile=$(mktemp)
@@ -46,44 +46,15 @@ check_pgpsigs() {
get_all_sources_for_arch 'all_sources'
;;
esac
- for file in "${all_sources[@]}"; do
- file="$(get_filename "$file")"
- if [[ $file != *.@(sig?(n)|asc) ]]; then
- continue
- fi
-
- printf " %s ... " "${file%.*}" >&2
-
- if ! file="$(get_filepath "$file")"; then
- printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
- errors=1
- continue
- fi
+ for netfile in "${all_sources[@]}"; do
+ proto="$(get_protocol "$netfile")"
- found=0
- for ext in "" gz bz2 xz lrz lzo Z; do
- if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
- found=1
- break;
- fi
- done
- if (( ! found )); then
- printf '%s\n' "$(gettext "SOURCE FILE NOT FOUND")" >&2
- errors=1
- continue
+ if [[ $proto = git* ]]; then
+ verify_git_signature "$netfile" "$statusfile" || continue
+ else
+ verify_file_signature "$netfile" "$statusfile" || continue
fi
- case "$ext" in
- gz) decompress="gzip -c -d -f" ;;
- bz2) decompress="bzip2 -c -d -f" ;;
- xz) decompress="xz -c -d" ;;
- lrz) decompress="lrzip -q -d" ;;
- lzo) decompress="lzop -c -d -q" ;;
- Z) decompress="uncompress -c -f" ;;
- "") decompress="cat" ;;
- esac
-
- $decompress < "$sourcefile" | gpg --quiet --batch --status-file "$statusfile" --verify "$file" - 2> /dev/null
# these variables are assigned values in parse_gpg_statusfile
success=0
status=
@@ -145,6 +116,85 @@ check_pgpsigs() {
fi
}
+verify_file_signature() {
+ local netfile="$1" statusfile="$2"
+ local file ext decompress found sourcefile
+
+ file="$(get_filename "$netfile")"
+ if [[ $file != *.@(sig?(n)|asc) ]]; then
+ return 1
+ fi
+
+ printf " %s ... " "${file%.*}" >&2
+
+ if ! file="$(get_filepath "$netfile")"; then
+ printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
+ errors=1
+ return 1
+ fi
+
+ found=0
+ for ext in "" gz bz2 xz lrz lzo Z; do
+ if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
+ found=1
+ break;
+ fi
+ done
+ if (( ! found )); then
+ printf '%s\n' "$(gettext "SOURCE FILE NOT FOUND")" >&2
+ errors=1
+ return 1
+ fi
+
+ case "$ext" in
+ gz) decompress="gzip -c -d -f" ;;
+ bz2) decompress="bzip2 -c -d -f" ;;
+ xz) decompress="xz -c -d" ;;
+ lrz) decompress="lrzip -q -d" ;;
+ lzo) decompress="lzop -c -d -q" ;;
+ Z) decompress="uncompress -c -f" ;;
+ "") decompress="cat" ;;
+ esac
+
+ $decompress < "$sourcefile" | gpg --quiet --batch --status-file "$statusfile" --verify "$file" - 2> /dev/null
+}
+
+verify_git_signature() {
+ local netfile=$1 statusfile=$2
+ local dir fragment query fragtype fragval
+
+ dir=$(get_filepath "$netfile")
+ fragment=$(get_uri_fragment "$netfile")
+ query=$(get_uri_query "$netfile")
+
+ if [[ $query != signed ]]; then
+ return 1
+ fi
+
+ case ${fragment%%=*} in
+ tag)
+ fragtype=tag
+ fragval=${fragment##*=}
+ ;;
+ commit|branch)
+ fragtype=commit
+ fragval=${fragment##*=}
+ ;;
+ '')
+ fragtype=commit
+ fragval=HEAD
+ esac
+
+ printf " %s git repo ... " "${dir##*/}" >&2
+
+ git -C "$dir" verify-$fragtype --raw "$fragval" > "$statusfile" 2>&1
+ if ! grep -qs NEWSIG "$statusfile"; then
+ printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
+ errors=1
+ return 1
+ fi
+}
+
parse_gpg_statusfile() {
local type arg1 arg6 arg10
@@ -204,11 +254,14 @@ parse_gpg_statusfile() {
}
source_has_signatures() {
- local file all_sources
+ local file all_sources proto
get_all_sources_for_arch 'all_sources'
for file in "${all_sources[@]}"; do
- if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then
+ proto="$(get_protocol "$file")"
+ query=$(get_uri_query "$netfile")
+
+ if [[ ${file%%::*} = *.@(sig?(n)|asc) || ( $proto = git* && $query = signed ) ]]; then
return 0
fi
done
diff --git a/scripts/libmakepkg/lint_package.sh.in b/scripts/libmakepkg/lint_package.sh.in
index 82b8b9b8..ff0894ec 100644
--- a/scripts/libmakepkg/lint_package.sh.in
+++ b/scripts/libmakepkg/lint_package.sh.in
@@ -2,7 +2,7 @@
#
# lint_package.sh - functions for checking for packaging errors
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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
@@ -40,7 +40,9 @@ lint_package() {
cd_safe "$pkgdir"
msg "$(gettext "Checking for packaging issue...")"
+ local ret=0
for func in ${lint_package_functions[@]}; do
- $func
+ $func || ret=1
done
+ return $ret
}
diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in b/scripts/libmakepkg/lint_package/build_references.sh.in
index 67c14e66..9183fce9 100644
--- a/scripts/libmakepkg/lint_package/build_references.sh.in
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -2,7 +2,7 @@
#
# build_references.sh - Warn about files containing references to build directories
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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
@@ -25,14 +25,17 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
-
lint_package_functions+=('warn_build_references')
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
+ local refs
+
+ for var in srcdir pkgdir; do
+ mapfile -t refs < <(find "$pkgdir" -type f -exec grep -l "${!var}" {} +)
+ if (( ${#refs} > 0 )); then
+ warning "$(gettext 'Package contains reference to %s')" "\$$var"
+ printf '%s\n' "${refs[@]}" >&2
+ fi
+ done
+ return 0
}
diff --git a/scripts/libmakepkg/lint_package/dotfiles.sh.in b/scripts/libmakepkg/lint_package/dotfiles.sh.in
new file mode 100644
index 00000000..9842028c
--- /dev/null
+++ b/scripts/libmakepkg/lint_package/dotfiles.sh.in
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# dotfiles.sh - check for dotfiles in the package root
+#
+# Copyright (c) 2016-2017 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_LINT_PACKAGE_DOTFILES_SH" ]] && return
+LIBMAKEPKG_LINT_PACKAGE_DOTFILES_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+lint_package_functions+=('check_dotfiles')
+
+check_dotfiles() {
+ local ret=0
+ for f in "$pkgdir"/.*; do
+ [[ ${f##*/} == . || ${f##*/} == .. ]] && continue
+ error "$(gettext "Dotfile found in package root '%s'")" "$f"
+ ret=1
+ done
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_package/file_names.sh.in b/scripts/libmakepkg/lint_package/file_names.sh.in
new file mode 100644
index 00000000..0b8e7a03
--- /dev/null
+++ b/scripts/libmakepkg/lint_package/file_names.sh.in
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# file_names.sh - check package file names
+#
+# Copyright (c) 2016-2017 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_LINT_PACKAGE_FILE_NAMES_SH" ]] && return
+LIBMAKEPKG_LINT_PACKAGE_FILE_NAMES_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+lint_package_functions+=('lint_file_names')
+
+lint_file_names() {
+ local ret=0 paths
+
+ # alpm's local database format does not support newlines in paths
+ mapfile -t paths < <(find "$pkgdir" -name \*$'\n'\*)
+ if (( ${#paths} > 0 )); then
+ error "$(gettext 'Package contains paths with newlines')"
+ printf '%s\n' "${paths[@]}" >&2
+ ret=1
+ fi
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_package/missing_backup.sh.in b/scripts/libmakepkg/lint_package/missing_backup.sh.in
index 727a18bf..934dd12f 100644
--- a/scripts/libmakepkg/lint_package/missing_backup.sh.in
+++ b/scripts/libmakepkg/lint_package/missing_backup.sh.in
@@ -2,7 +2,7 @@
#
# missing_backup.sh - Warn about missing files in the backup array
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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,4 +35,5 @@ warn_missing_backup() {
warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
fi
done
+ return 0
}
diff --git a/scripts/libmakepkg/lint_pkgbuild.sh.in b/scripts/libmakepkg/lint_pkgbuild.sh.in
index 25bb848f..d3a1a083 100644
--- a/scripts/libmakepkg/lint_pkgbuild.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild.sh.in
@@ -2,7 +2,7 @@
#
# lint_pkgbuild.sh - functions for detecting PKGBUILD errors
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/lint_pkgbuild/arch.sh.in b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
index 623dc81a..ddc2f29e 100644
--- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -2,7 +2,7 @@
#
# arch.sh - Check the 'arch' array conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/backup.sh.in b/scripts/libmakepkg/lint_pkgbuild/backup.sh.in
index 99fa15fe..5b37b4e9 100644
--- a/scripts/libmakepkg/lint_pkgbuild/backup.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/backup.sh.in
@@ -2,7 +2,7 @@
#
# backup.sh - Check the 'backup' array conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/changelog.sh.in b/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in
index 039db512..264ea105 100644
--- a/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in
@@ -2,7 +2,7 @@
#
# changelog.sh - Check the files in the 'changelog' array exist.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/epoch.sh.in b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
index e6daf14c..cc11d975 100644
--- a/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
@@ -2,7 +2,7 @@
#
# epoch.sh - Check the 'epoch' variable conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/install.sh.in b/scripts/libmakepkg/lint_pkgbuild/install.sh.in
index ab89ebea..3e268923 100644
--- a/scripts/libmakepkg/lint_pkgbuild/install.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/install.sh.in
@@ -2,7 +2,7 @@
#
# install.sh - Check the files in the 'install' array exist.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/optdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
index fe71fd77..f5fdbb90 100644
--- a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
@@ -2,7 +2,7 @@
#
# optdepends.sh - Check the 'optdepends' array conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/options.sh.in b/scripts/libmakepkg/lint_pkgbuild/options.sh.in
index bf1cfa52..ffcd19e3 100644
--- a/scripts/libmakepkg/lint_pkgbuild/options.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/options.sh.in
@@ -2,7 +2,7 @@
#
# options.sh - Check the 'options' array conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/package_function.sh.in b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
index 78c5c7cc..14398217 100644
--- a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
@@ -2,7 +2,7 @@
#
# package_function.sh - Check that required package functions exist.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/pkgbase.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in
index 035b3abb..911e1128 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in
@@ -2,7 +2,7 @@
#
# pkgbase.sh - Check the 'pkgbase' variable conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/pkglist.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in
index 50ac3c0d..8c09ad5b 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in
@@ -2,7 +2,7 @@
#
# pkglist.sh - Check the packages selected to build exist.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in
index a0440827..b66eda68 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in
@@ -2,7 +2,7 @@
#
# pkgname.sh - Check the 'pkgname' variable conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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
@@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname')
lint_pkgname() {
local ret=0 i
+ if [[ -z ${pkgname[@]} ]]; then
+ error "$(gettext "%s is not allowed to be empty.")" "pkgname"
+ return 1
+ fi
+
for i in "${pkgname[@]}"; do
if [[ -z $i ]]; then
error "$(gettext "%s is not allowed to be empty.")" "pkgname"
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
index 95cb8080..b5cdfcf1 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
@@ -2,7 +2,7 @@
#
# pkgrel.sh - Check the 'pkgrel' variable conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/pkgver.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
index 09041d17..0ec6584c 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
@@ -2,7 +2,7 @@
#
# pkgver.sh - Check the 'pkgver' variable conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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,8 +35,8 @@ check_pkgver() {
return 1
fi
- if [[ $1 = *[[:space:]:-]* ]]; then
- error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
+ if [[ $1 = *[[:space:]/:-]* ]]; then
+ error "$(gettext "%s is not allowed to contain colons, forward slashes, hyphens or whitespace.")" "pkgver"
return 1
fi
}
diff --git a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
index 5fedd7fc..f521d0f5 100644
--- a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
@@ -2,7 +2,7 @@
#
# provides.sh - Check the 'provides' array conforms to requirements.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/source.sh.in b/scripts/libmakepkg/lint_pkgbuild/source.sh.in
index b6edf1ce..052b9d54 100644
--- a/scripts/libmakepkg/lint_pkgbuild/source.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/source.sh.in
@@ -2,7 +2,7 @@
#
# source.sh - Check the 'source' array is not sparse.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/util.sh.in b/scripts/libmakepkg/lint_pkgbuild/util.sh.in
index 3c248f91..e8a35933 100644
--- a/scripts/libmakepkg/lint_pkgbuild/util.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/util.sh.in
@@ -2,7 +2,7 @@
#
# util.sh - utility functions for pkgbuild linting.
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 30c99090..1e749638 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -2,7 +2,7 @@
#
# variable.sh - Check that variables are or are not arrays as appropriate
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/source.sh.in b/scripts/libmakepkg/source.sh.in
index 9bed41da..234e35e4 100644
--- a/scripts/libmakepkg/source.sh.in
+++ b/scripts/libmakepkg/source.sh.in
@@ -2,7 +2,7 @@
#
# source.sh - functions for downloading and extracting sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/source/bzr.sh.in b/scripts/libmakepkg/source/bzr.sh.in
index af8c3c50..97206714 100644
--- a/scripts/libmakepkg/source/bzr.sh.in
+++ b/scripts/libmakepkg/source/bzr.sh.in
@@ -2,7 +2,7 @@
#
# bzr.sh - function for handling the download and "extraction" of Bazaar sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/source/file.sh.in b/scripts/libmakepkg/source/file.sh.in
index 20493a67..1d85ea9b 100644
--- a/scripts/libmakepkg/source/file.sh.in
+++ b/scripts/libmakepkg/source/file.sh.in
@@ -2,7 +2,7 @@
#
# file.sh - function for handling the download and extraction of source files
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/source/git.sh.in b/scripts/libmakepkg/source/git.sh.in
index cc27663d..6d7e0a67 100644
--- a/scripts/libmakepkg/source/git.sh.in
+++ b/scripts/libmakepkg/source/git.sh.in
@@ -2,7 +2,7 @@
#
# git.sh - function for handling the download and "extraction" of Git sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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
@@ -39,6 +39,7 @@ download_git() {
local url=$(get_url "$netfile")
url=${url#git+}
url=${url%%#*}
+ url=${url%%\?*}
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
@@ -66,14 +67,8 @@ download_git() {
extract_git() {
local netfile=$1
- local fragment=${netfile#*#}
- if [[ $fragment = "$netfile" ]]; then
- unset fragment
- fi
-
- local repo=${netfile##*/}
- repo=${repo%%#*}
- repo=${repo%%.git*}
+ local fragment=$(get_uri_fragment "$netfile")
+ local repo=$(get_filename "$netfile")
local dir=$(get_filepath "$netfile")
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
diff --git a/scripts/libmakepkg/source/hg.sh.in b/scripts/libmakepkg/source/hg.sh.in
index 61774e81..4e6ebad9 100644
--- a/scripts/libmakepkg/source/hg.sh.in
+++ b/scripts/libmakepkg/source/hg.sh.in
@@ -2,7 +2,7 @@
#
# hg.sh - function for handling the download and "extraction" of Mercurial sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/source/local.sh.in b/scripts/libmakepkg/source/local.sh.in
index 6a4b8824..8104141a 100644
--- a/scripts/libmakepkg/source/local.sh.in
+++ b/scripts/libmakepkg/source/local.sh.in
@@ -2,7 +2,7 @@
#
# local.sh - function for handling the "download" of local sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/source/svn.sh.in b/scripts/libmakepkg/source/svn.sh.in
index a78fca3d..6cb78235 100644
--- a/scripts/libmakepkg/source/svn.sh.in
+++ b/scripts/libmakepkg/source/svn.sh.in
@@ -2,7 +2,7 @@
#
# svn.sh - function for handling the download and "extraction" of Subversion sources
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/srcinfo.sh.in b/scripts/libmakepkg/srcinfo.sh.in
index 83765fa5..99f5628a 100644
--- a/scripts/libmakepkg/srcinfo.sh.in
+++ b/scripts/libmakepkg/srcinfo.sh.in
@@ -2,7 +2,7 @@
#
# srcinfo.sh - functions for writing .SRCINFO files
#
-# Copyright (c) 2014-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2014-2017 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/libmakepkg/tidy.sh.in b/scripts/libmakepkg/tidy.sh.in
index fc14c6e2..856f2394 100644
--- a/scripts/libmakepkg/tidy.sh.in
+++ b/scripts/libmakepkg/tidy.sh.in
@@ -3,7 +3,7 @@
# tidy.sh - functions for modifying/removing installed files before
# package creation
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/tidy/docs.sh.in b/scripts/libmakepkg/tidy/docs.sh.in
index ac86573b..0919f201 100644
--- a/scripts/libmakepkg/tidy/docs.sh.in
+++ b/scripts/libmakepkg/tidy/docs.sh.in
@@ -2,7 +2,7 @@
#
# docs.sh - Remove documentation files from the package
#
-# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2008-2017 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/libmakepkg/tidy/emptydirs.sh.in b/scripts/libmakepkg/tidy/emptydirs.sh.in
index 85ab39df..2b16afdf 100644
--- a/scripts/libmakepkg/tidy/emptydirs.sh.in
+++ b/scripts/libmakepkg/tidy/emptydirs.sh.in
@@ -2,7 +2,7 @@
#
# emptydirs.sh - Remove empty directories from the package
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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/libmakepkg/tidy/libtool.sh.in b/scripts/libmakepkg/tidy/libtool.sh.in
index e8187c78..b844c792 100644
--- a/scripts/libmakepkg/tidy/libtool.sh.in
+++ b/scripts/libmakepkg/tidy/libtool.sh.in
@@ -2,7 +2,7 @@
#
# libtool.sh - Remove libtool files from the package
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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/libmakepkg/tidy/purge.sh.in b/scripts/libmakepkg/tidy/purge.sh.in
index 501d7531..5d37ded5 100644
--- a/scripts/libmakepkg/tidy/purge.sh.in
+++ b/scripts/libmakepkg/tidy/purge.sh.in
@@ -2,7 +2,7 @@
#
# purge.sh - Remove unwanted files from the package
#
-# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2008-2017 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/libmakepkg/tidy/staticlibs.sh.in b/scripts/libmakepkg/tidy/staticlibs.sh.in
index 07282a80..643932dd 100644
--- a/scripts/libmakepkg/tidy/staticlibs.sh.in
+++ b/scripts/libmakepkg/tidy/staticlibs.sh.in
@@ -2,7 +2,7 @@
#
# staticlibs.sh - Remove static library files from the package
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
index 1c7aacfd..76562808 100644
--- a/scripts/libmakepkg/tidy/strip.sh.in
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -2,7 +2,7 @@
#
# strip.sh - Strip debugging symbols from binary files
#
-# Copyright (c) 2007-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2007-2017 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
@@ -32,7 +32,12 @@ tidy_modify+=('tidy_strip')
build_id() {
- LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
+ LANG=C readelf -n "$1" | sed -n '/Build ID/ { s/.*: //p; q; }'
+}
+
+source_files() {
+ LANG=C readelf "$1" --debug-dump | \
+ awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{print $8 "/" name}'
}
strip_file() {
@@ -50,6 +55,18 @@ strip_file() {
return
fi
+ # copy source files to debug directory
+ local f t
+ while read -r f; do
+ t=${f/"$srcdir"/$dbgsrc}
+ mkdir -p "${t%/*}"
+ cp -- "$f" "$t"
+ done < <(source_files "$binary")
+
+ # adjust debug symbols to point at sources
+ debugedit -b "${srcdir}" -d /usr/src/debug/ -i "$binary" &> /dev/null
+
+ # copy debug symbols to debug directory
mkdir -p "$dbgdir/${binary%/*}"
objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
@@ -88,8 +105,10 @@ tidy_strip() {
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
if check_option "debug" "y"; then
- dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
- mkdir -p "$dbgdir"
+
+ dbgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/lib/debug"
+ dbgsrc="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/src/debug"
+ mkdir -p "$dbgdir" "$dbgsrc"
fi
local binary strip_flags
diff --git a/scripts/libmakepkg/tidy/zipman.sh.in b/scripts/libmakepkg/tidy/zipman.sh.in
index 7ef4d5c3..ff82d43c 100644
--- a/scripts/libmakepkg/tidy/zipman.sh.in
+++ b/scripts/libmakepkg/tidy/zipman.sh.in
@@ -2,7 +2,7 @@
#
# zipman.sh - Compress man and info pages
#
-# Copyright (c) 2011-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2011-2017 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/libmakepkg/util.sh.in b/scripts/libmakepkg/util.sh.in
index c296d565..b7b56d34 100644
--- a/scripts/libmakepkg/util.sh.in
+++ b/scripts/libmakepkg/util.sh.in
@@ -2,7 +2,7 @@
#
# util.sh - utility functions for makepkg
#
-# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2015-2017 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/libmakepkg/util/message.sh b/scripts/libmakepkg/util/message.sh.in
index 341ccf3f..33808de7 100644
--- a/scripts/libmakepkg/util/message.sh
+++ b/scripts/libmakepkg/util/message.sh.in
@@ -2,7 +2,7 @@
#
# message.sh - functions for outputting messages in makepkg
#
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh.in
index 54ba4740..8cf0039b 100644
--- a/scripts/libmakepkg/util/option.sh
+++ b/scripts/libmakepkg/util/option.sh.in
@@ -2,7 +2,7 @@
#
# option.sh - functions to test if build/packaging options are enabled
#
-# Copyright (c) 2009-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2009-2017 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/library/parseopts.sh b/scripts/libmakepkg/util/parseopts.sh.in
index cf6aa6c6..a7638cf1 100644
--- a/scripts/library/parseopts.sh
+++ b/scripts/libmakepkg/util/parseopts.sh.in
@@ -1,4 +1,40 @@
-# getopt-like parser
+#!/bin/bash
+#
+# parseopts.sh - getopt_long-like parser
+#
+# Copyright (c) 2012-2017 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/>.
+#
+# A getopt_long-like parser which portably supports longopts and
+# shortopts with some GNU extensions. It does not allow for options
+# with optional arguments. For both short and long opts, options
+# requiring an argument should be suffixed with a colon. After the
+# first argument containing the short opts, any number of valid long
+# opts may be be passed. The end of the options delimiter must then be
+# added, followed by the user arguments to the calling program.
+#
+# Recommended Usage:
+# OPT_SHORT='fb:z'
+# OPT_LONG=('foo' 'bar:' 'baz')
+# if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
+# exit 1
+# fi
+# set -- "${OPTRET[@]}"
+# Returns:
+# 0: parse success
+# 1: parse failure (error message supplied)
parseopts() {
local opt= optarg= i= shortopts=$1
local -a longopts=() unused_argv=()
@@ -34,7 +70,7 @@ parseopts() {
return 255 ;;
*)
# fail, ambiguous match
- printf "@SCRIPTNAME@: $(gettext "option '%s' is ambiguous; possibilities:")" "--$1"
+ printf "${0##*/}: $(gettext "option '%s' is ambiguous; possibilities:")" "--$1"
printf " '%s'" "${longmatch[@]%:}"
printf '\n'
return 254 ;;
@@ -53,7 +89,7 @@ parseopts() {
# option doesn't exist
if [[ $shortopts != *$opt* ]]; then
- printf "@SCRIPTNAME@: $(gettext "invalid option") -- '%s'\n" "$opt" >&2
+ printf "${0##*/}: $(gettext "invalid option") -- '%s'\n" "$opt" >&2
OPTRET=(--)
return 1
fi
@@ -72,7 +108,7 @@ parseopts() {
break
# parse failure
else
- printf "@SCRIPTNAME@: $(gettext "option requires an argument") -- '%s'\n" "$opt" >&2
+ printf "${0##*/}: $(gettext "option requires an argument") -- '%s'\n" "$opt" >&2
OPTRET=(--)
return 1
fi
@@ -86,7 +122,7 @@ parseopts() {
0)
# parse failure
if [[ $optarg ]]; then
- printf "@SCRIPTNAME@: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2
+ printf "${0##*/}: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2
OPTRET=(--)
return 1
# --longopt
@@ -104,7 +140,7 @@ parseopts() {
shift
# parse failure
else
- printf "@SCRIPTNAME@: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2
+ printf "${0##*/}: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2
OPTRET=(--)
return 1
fi
@@ -116,7 +152,7 @@ parseopts() {
;;
255)
# parse failure
- printf "@SCRIPTNAME@: $(gettext "invalid option") '--%s'\n" "$opt" >&2
+ printf "${0##*/}: $(gettext "invalid option") '--%s'\n" "$opt" >&2
OPTRET=(--)
return 1
;;
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 7bf7c3e4..2a4bd3af 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -2,7 +2,7 @@
#
# pkgbuild.sh - functions to extract information from PKGBUILD files
#
-# Copyright (c) 2009-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2009-2017 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/libmakepkg/util/source.sh.in b/scripts/libmakepkg/util/source.sh.in
index 9d4ba4a6..238d1f58 100644
--- a/scripts/libmakepkg/util/source.sh.in
+++ b/scripts/libmakepkg/util/source.sh.in
@@ -2,7 +2,7 @@
#
# source.sh - functions to extract information from source URLs
#
-# Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2017 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
@@ -65,6 +65,7 @@ get_filename() {
case $proto in
bzr*|git*|hg*|svn*)
filename=${netfile%%#*}
+ filename=${filename%%\?*}
filename=${filename%/}
filename=${filename##*/}
if [[ $proto = bzr* ]]; then
@@ -111,6 +112,32 @@ get_filepath() {
printf "%s\n" "$file"
}
+# extract the VCS revision/branch specifier from a source entry
+get_uri_fragment() {
+ local netfile=$1
+
+ local fragment=${netfile#*#}
+ if [[ $fragment = "$netfile" ]]; then
+ unset fragment
+ fi
+ fragment=${fragment%\?*}
+
+ printf "%s\n" "$fragment"
+}
+
+# extract the VCS "signed" status from a source entry
+get_uri_query() {
+ local netfile=$1
+
+ local query=${netfile#*\?}
+ if [[ $query = "$netfile" ]]; then
+ unset query
+ fi
+ query=${query%#*}
+
+ printf "%s\n" "$query"
+}
+
get_downloadclient() {
local proto=$1
diff --git a/scripts/libmakepkg/util/util.sh b/scripts/libmakepkg/util/util.sh.in
index f9f1c200..d676249d 100644
--- a/scripts/libmakepkg/util/util.sh
+++ b/scripts/libmakepkg/util/util.sh.in
@@ -2,7 +2,7 @@
#
# util.sh - general utility functions
#
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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/scripts/library/README b/scripts/library/README
index e9615a2e..a9d15f1e 100644
--- a/scripts/library/README
+++ b/scripts/library/README
@@ -8,26 +8,6 @@ stdout and can be silenced by defining 'QUIET'. The 'warning' and 'error'
functions print to stderr with the appropriate prefix added to the
message.
-parseopts.sh:
-A getopt_long-like parser which portably supports longopts and shortopts
-with some GNU extensions. It does not allow for options with optional
-arguments. For both short and long opts, options requiring an argument
-should be suffixed with a colon. After the first argument containing
-the short opts, any number of valid long opts may be be passed. The end
-of the options delimiter must then be added, followed by the user arguments
-to the calling program.
-
-Recommended Usage:
- OPT_SHORT='fb:z'
- OPT_LONG=('foo' 'bar:' 'baz')
- if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
- exit 1
- fi
- set -- "${OPTRET[@]}"
-Returns:
- 0: parse success
- 1: parse failure (error message supplied)
-
human_to_size.sh:
A function to convert human readable sizes (such as "5.3 GiB") to raw byte
equivalents. base10 and base2 suffixes are supported, case sensitively. If
diff --git a/scripts/makepkg-template.pl.in b/scripts/makepkg-template.pl.in
index 483dc8bd..e0513776 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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
@@ -191,7 +191,7 @@ sub version {
my ($exitstatus) = @_;
printf "makepkg-template (pacman) %s\n", '@PACKAGE_VERSION@';
print gettext(
- 'Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>.'."\n".
+ 'Copyright (c) 2013-2017 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.sh.in b/scripts/makepkg.sh.in
index 7b2ce511..0218e13b 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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>
@@ -28,7 +28,7 @@
# makepkg uses quite a few external programs during its execution. You
# need to have at least the following installed for makepkg to function:
# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, file, find (findutils),
-# gettext, gpg, grep, gzip, openssl, sed, tput (ncurses), xz
+# gettext, gpg, grep, gzip, sed, tput (ncurses), xz
# gettext initialization
export TEXTDOMAIN='pacman-scripts'
@@ -137,6 +137,12 @@ clean_up() {
if [[ -n $pkgbase ]]; then
local fullver=$(get_full_version)
# Can't do this unless the BUILDSCRIPT has been sourced.
+ if (( PKGVERFUNC )); then
+ rm -f "${pkgbase}-${fullver}-${CARCH}-pkgver.log"*
+ fi
+ if (( PREPAREFUNC )); then
+ rm -f "${pkgbase}-${fullver}-${CARCH}-prepare.log"*
+ fi
if (( BUILDFUNC )); then
rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"*
fi
@@ -243,7 +249,7 @@ handle_deps() {
(( $# == 0 )) && return $R_DEPS_SATISFIED
- local deplist="$*"
+ local deplist=("$@")
if (( ! DEP_BIN )); then
return $R_DEPS_MISSING
@@ -253,7 +259,7 @@ handle_deps() {
# install missing deps from binary packages (using pacman -S)
msg "$(gettext "Installing missing dependencies...")"
- if ! run_pacman -S --asdeps $deplist; then
+ if ! run_pacman -S --asdeps "${deplist[@]}"; then
error "$(gettext "'%s' failed to install missing dependencies.")" "$PACMAN"
exit 1 # TODO: error code
fi
@@ -276,12 +282,12 @@ resolve_deps() {
# deplist cannot be declared like this: local deplist=$(foo)
# Otherwise, the return value will depend on the assignment.
local deplist
- deplist="$(set +E; check_deps $*)" || exit 1
+ deplist=($(check_deps "$@")) || exit 1
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
- if handle_deps $deplist; then
+ if handle_deps "${deplist[@]}"; then
# check deps again to make sure they were resolved
- deplist="$(set +E; check_deps $*)" || exit 1
+ deplist=$(check_deps "$@") || exit 1
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
fi
@@ -398,20 +404,23 @@ prepare_buildenv() {
}
run_function_safe() {
- local restoretrap
+ local restoretrap restoreset restoreshopt
- set -e
- set -E
+ # we don't set any special shopts of our own, but we don't want the user to
+ # muck with our environment.
+ restoreshopt=$(shopt -p)
+
+ restoreset=$(shopt -o -p)
+ shopt -o -s errexit errtrace
restoretrap=$(trap -p ERR)
- trap 'error_function $pkgfunc' ERR
+ trap "error_function '$1'" ERR
run_function "$1"
- eval $restoretrap
-
- set +E
- set +e
+ eval "$restoretrap"
+ eval "$restoreset"
+ eval "$restoreshopt"
}
run_function() {
@@ -494,7 +503,7 @@ find_libdepends() {
done
if (( sodepends == 0 )); then
- printf '%s\n' "${depends[@]}"
+ (( ${#depends[@]} )) && printf '%s\n' "${depends[@]}"
return;
fi
@@ -543,7 +552,7 @@ find_libdepends() {
esac
done
- printf '%s\n' "${libdepends[@]}"
+ (( ${#libdepends[@]} )) && printf '%s\n' "${libdepends[@]}"
}
@@ -594,7 +603,20 @@ find_libprovides() {
fi
done
- printf '%s\n' "${libprovides[@]}"
+ (( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}"
+}
+
+write_kv_pair() {
+ local key="$1"
+ shift
+
+ for val in "$@"; do
+ if [[ $val = *$'\n'* ]]; then
+ error "$(gettext "Invalid value for %s: %s")" "$key" "$val"
+ exit 1
+ fi
+ printf "%s = %s\n" "$key" "$val"
+ done
}
write_pkginfo() {
@@ -615,15 +637,15 @@ write_pkginfo() {
printf "# using %s\n" "$(fakeroot -v)"
printf "# %s\n" "$(LC_ALL=C date -u)"
- printf "pkgname = %s\n" "$pkgname"
+ write_kv_pair "pkgname" "$pkgname"
if (( SPLITPKG )) || [[ "$pkgbase" != "$pkgname" ]]; then
- printf "pkgbase = %s\n" "$pkgbase"
+ write_kv_pair "pkgbase" "$pkgbase"
fi
local fullver=$(get_full_version)
- printf "pkgver = %s\n" "$fullver"
+ write_kv_pair "pkgver" "$fullver"
if [[ "$fullver" != "$basever" ]]; then
- printf "basever = %s\n" "$basever"
+ write_kv_pair "basever" "$basever"
fi
# TODO: all fields should have this treatment
@@ -631,43 +653,52 @@ write_pkginfo() {
spd=("${spd[@]#[[:space:]]}")
spd=("${spd[@]%[[:space:]]}")
- printf "pkgdesc = %s\n" "$spd"
- printf "url = %s\n" "$url"
- printf "builddate = %s\n" "$builddate"
- printf "packager = %s\n" "$packager"
- printf "size = %s\n" "$size"
- printf "arch = %s\n" "$pkgarch"
+ write_kv_pair "pkgdesc" "$spd"
+ write_kv_pair "url" "$url"
+ write_kv_pair "builddate" "$builddate"
+ write_kv_pair "packager" "$packager"
+ write_kv_pair "size" "$size"
+ write_kv_pair "arch" "$pkgarch"
mapfile -t provides < <(find_libprovides)
mapfile -t depends < <(find_libdepends)
- [[ $license ]] && printf "license = %s\n" "${license[@]}"
- [[ $replaces ]] && printf "replaces = %s\n" "${replaces[@]}"
- [[ $groups ]] && printf "group = %s\n" "${groups[@]}"
- [[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
- [[ $provides ]] && printf "provides = %s\n" "${provides[@]}"
- [[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
- [[ $depends ]] && printf "depend = %s\n" "${depends[@]}"
- [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
- [[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}"
- [[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}"
+ write_kv_pair "license" "${license[@]}"
+ write_kv_pair "replaces" "${replaces[@]}"
+ write_kv_pair "group" "${groups[@]}"
+ write_kv_pair "conflict" "${conflicts[@]}"
+ write_kv_pair "provides" "${provides[@]}"
+ write_kv_pair "backup" "${backup[@]}"
+ write_kv_pair "depend" "${depends[@]}"
+ write_kv_pair "optdepend" "${optdepends[@]//+([[:space:]])/ }"
+ write_kv_pair "makedepend" "${makedepends[@]}"
+ write_kv_pair "checkdepend" "${checkdepends[@]}"
}
write_buildinfo() {
msg2 "$(gettext "Generating %s file...")" ".BUILDINFO"
- printf "builddir = %s\n" "${BUILDDIR}"
+ write_kv_pair "builddir" "${BUILDDIR}"
- local sum="$(openssl dgst -sha256 "${BUILDFILE}")"
- sum=${sum##* }
+ local sum="$(sha256sum "${BUILDFILE}")"
+ sum=${sum%% *}
- printf "pkgbuild_sha256sum = %s\n" $sum
+ write_kv_pair "pkgbuild_sha256sum" $sum
- printf "buildenv = %s\n" "${BUILDENV[@]}"
- printf "options = %s\n" "${OPTIONS[@]}"
+ write_kv_pair "buildenv" "${BUILDENV[@]}"
+ write_kv_pair "options" "${OPTIONS[@]}"
local pkglist=($(run_pacman -Q | sed "s# #-#"))
- printf "installed = %s\n" "${pkglist[@]}"
+ write_kv_pair "installed" "${pkglist[@]}"
+}
+
+# build a sorted NUL-separated list of the full contents of the current
+# directory suitable for passing to `bsdtar --files-from`
+# database files are placed at the beginning of the package regardless of
+# sorting
+list_package_files() {
+ (find . -path './.*' \! -name '.'; find . \! -path './.*' \! -name '.' | LC_ALL=C sort) |
+ sed -e 's|^\./||' | tr '\n' '\0'
}
create_package() {
@@ -686,8 +717,6 @@ create_package() {
write_pkginfo > .PKGINFO
write_buildinfo > .BUILDINFO
- local comp_files=('.PKGINFO' '.BUILDINFO')
-
# check for changelog/install files
for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do
IFS='/' read -r orig dest < <(printf '%s\n' "$i")
@@ -699,7 +728,6 @@ create_package() {
exit 1
fi
chmod 644 "$dest"
- comp_files+=("$dest")
fi
done
@@ -711,15 +739,10 @@ create_package() {
[[ -f $pkg_file ]] && rm -f "$pkg_file"
[[ -f $pkg_file.sig ]] && rm -f "$pkg_file.sig"
- # when fileglobbing, we want * in an empty directory to expand to
- # the null string rather than itself
- shopt -s nullglob
-
msg2 "$(gettext "Generating .MTREE file...")"
- LANG=C bsdtar -czf .MTREE --format=mtree \
+ list_package_files | LANG=C bsdtar -cnzf .MTREE --format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
- "${comp_files[@]}" *
- comp_files+=(".MTREE")
+ --null --files-from - --exclude .MTREE
msg2 "$(gettext "Compressing package...")"
# TODO: Maybe this can be set globally for robustness
@@ -727,7 +750,7 @@ create_package() {
# bsdtar's gzip compression always saves the time stamp, making one
# archive created using the same command line distinct from another.
# Disable bsdtar compression and use gzip -n for now.
- LANG=C bsdtar -cf - "${comp_files[@]}" * |
+ list_package_files | LANG=C bsdtar -cnf - --null --files-from - |
case "$PKGEXT" in
*tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
@@ -740,7 +763,6 @@ create_package() {
"$PKGEXT"; cat ;;
esac > "${pkg_file}" || ret=$?
- shopt -u nullglob
shopt -u -o pipefail
if (( ret )); then
@@ -771,18 +793,24 @@ create_debug_package() {
return
fi
- pkgdir="${pkgdir}-@DEBUGSUFFIX@"
+ pkgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@"
# check if we have any debug symbols to package
if dir_is_empty "$pkgdir/usr/lib/debug"; then
return
fi
- depends=("$pkgname=$(get_full_version)")
- pkgdesc="Detached debugging symbols for $pkgname"
- pkgname=$pkgname-@DEBUGSUFFIX@
+ unset groups depends optdepends provides conflicts replaces backup install changelog
- unset groups optdepends provides conflicts replaces backup install changelog
+ local pkg
+ for pkg in ${pkgname[@]}; do
+ if [[ $pkg != $pkgbase ]]; then
+ provides+=("$pkg-@DEBUGSUFFIX@")
+ fi
+ done
+
+ pkgdesc="Detached debugging symbols for $pkgname"
+ pkgname=$pkgbase-@DEBUGSUFFIX@
create_package
}
@@ -959,7 +987,7 @@ check_vcs_software() {
client=$(get_vcsclient "$proto") || exit $?
# ensure specified program is installed
local uninstalled
- uninstalled="$(set +E; check_deps $client)" || exit 1
+ uninstalled=$(check_deps "$client") || exit 1
# if not installed, check presence in depends or makedepends
if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then
if ! in_array "$client" ${all_deps[@]}; then
@@ -1022,12 +1050,18 @@ check_software() {
fi
fi
- # openssl - checksum operations
- if (( ! SKIPCHECKSUMS )); then
- if ! type -p openssl >/dev/null; then
- error "$(gettext "Cannot find the %s binary required for validating source file checksums.")" "openssl"
- ret=1
- fi
+ # checksum operations
+ if (( GENINTEG || ! SKIPCHECKSUMS )); then
+ local integlist
+ IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
+
+ local integ
+ for integ in "${integlist[@]}"; do
+ if ! type -p "${integ}sum" >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum"
+ ret=1
+ fi
+ done
fi
# distcc - compilation with distcc
@@ -1145,16 +1179,14 @@ run_split_packaging() {
backup_package_variables
run_package $pkgname
tidy_install
- lint_package
+ lint_package || exit 1
create_package
- create_debug_package
restore_package_variables
done
pkgname=("${pkgname_backup[@]}")
+ create_debug_package
}
-m4_include(library/parseopts.sh)
-
usage() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
echo
@@ -1212,7 +1244,7 @@ usage() {
version() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
printf -- "$(gettext "\
-Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2006-2017 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")"
@@ -1448,7 +1480,11 @@ fi
unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
unset md5sums replaces depends conflicts backup source install changelog build
-unset makedepends optdepends options noextract validpgpkeys
+unset sha{1,224,256,384,512}sums makedepends optdepends options noextract validpgpkeys
+unset "${!makedepends_@}" "${!depends_@}" "${!source_@}" "${!checkdepends_@}"
+unset "${!optdepends_@}" "${!conflicts_@}" "${!provides_@}" "${!replaces_@}"
+unset "${!md5sums_@}" "${!sha1sums_@}" "${!sha224sums_@}" "${!sha256sums_@}"
+unset "${!sha384sums_@}" "${!sha512sums_@}"
BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
if [[ ! -f $BUILDFILE ]]; then
@@ -1476,7 +1512,7 @@ pkgbase=${pkgbase:-${pkgname[0]}}
# check the PKGBUILD for some basic requirements
lint_pkgbuild || exit 1
-if (( !SOURCEONLY )); then
+if (( !SOURCEONLY && !PRINTSRCINFO )); then
merge_arch_attrs
fi
@@ -1581,7 +1617,7 @@ if (( INFAKEROOT )); then
run_package
fi
tidy_install
- lint_package
+ lint_package || exit 1
create_package
create_debug_package
else
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index 79e1c590..a6ff3b25 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2017 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
@@ -30,7 +30,10 @@ declare -r myver='@PACKAGE_VERSION@'
m4_include(library/output_format.sh)
-m4_include(library/parseopts.sh)
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+# Import parseopts.sh
+source "$LIBRARY"/util/parseopts.sh
usage() {
printf "pacman-db-upgrade (pacman) %s\n" "${myver}"
@@ -52,7 +55,7 @@ usage() {
version() {
printf "pacman-db-upgrade (pacman) %s\n" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2017 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 ffefc68c..7b158da7 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2017 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
@@ -26,6 +26,11 @@ export TEXTDOMAINDIR='@localedir@'
declare -r myver="@PACKAGE_VERSION@"
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+# Import parseopts.sh
+source "$LIBRARY"/util/parseopts.sh
+
# Options
ADD=0
DELETE=0
@@ -50,8 +55,6 @@ DEFAULT_KEYSERVER='hkp://pool.sks-keyservers.net'
m4_include(library/output_format.sh)
-m4_include(library/parseopts.sh)
-
usage() {
printf "pacman-key (pacman) %s\n" ${myver}
echo
@@ -92,7 +95,7 @@ usage() {
version() {
printf "pacman-key (pacman) %s\n" "${myver}"
printf -- "$(gettext "\
-Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2017 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
deleted file mode 100644
index f5ad924b..00000000
--- a/scripts/pacman-optimize.sh.in
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/bin/bash
-#
-# pacman-optimize
-# @configure_input@
-#
-# Copyright (c) 2006-2016 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/>.
-#
-
-# gettext initialization
-export TEXTDOMAIN='pacman-scripts'
-export TEXTDOMAINDIR='@localedir@'
-
-USE_COLOR='y'
-
-declare -r myver='@PACKAGE_VERSION@'
-
-eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
-dbroot="${DBPath:-@localstatedir@/lib/pacman/}"
-
-m4_include(library/output_format.sh)
-
-usage() {
- printf "pacman-optimize (pacman) %s\n\n" "$myver"
- printf -- "$(gettext "Usage: %s [--nocolor] [pacman_db_root]")\n\n" "$0"
- printf -- "$(gettext "\
-pacman-optimize is a little hack that should improve the performance\n\
-of pacman when reading/writing to its filesystem-based database.\n\n")"
- printf -- "$(gettext "\
-Because pacman uses many small files to keep track of packages,\n\
-there is a tendency for these files to become fragmented over time.\n\
-This script attempts to relocate these small files into one\n\
-continuous location on your hard drive. The result is that the hard\n\
-drive should be able to read them faster, since the hard drive head\n\
-does not have to move around the disk as much.\n")"
-}
-
-version() {
- printf "pacman-optimize (pacman) %s\n" "$myver"
- printf -- "$(gettext "\
-Copyright (c) 2006-2016 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")"
-}
-
-die() {
- error "$@"
- exit 1
-}
-
-die_r() {
- rm -f "$lockfile"
- die "$@"
-}
-
-# PROGRAM START
-
-# determine whether we have gettext; make it a no-op if we do not
-if ! type gettext &>/dev/null; then
- gettext() {
- echo "$@"
- }
-fi
-
-if [[ $1 = "-h" || $1 = "--help" ]]; then
- usage
- exit 0
-fi
-
-if [[ $1 = "-V" || $1 = "--version" ]]; then
- version
- exit 0
-fi
-
-if [[ $1 = "--nocolor" ]]; then
- USE_COLOR='n'
- shift
-fi
-
-m4_include(library/term_colors.sh)
-
-if [[ -n $1 ]]; then
- dbroot="$1"
-fi
-
-if ! type -p openssl >/dev/null; then
- die "$(gettext "Cannot find the %s binary required for verifying integrity.")" "openssl"
-fi
-
-if [[ ! -d $dbroot || ! -d $dbroot/local ]]; then
- die "$(gettext "%s does not exist or is not a directory.")" "$dbroot"
-fi
-
-if [[ ! -w $dbroot ]]; then
- die "$(gettext "You must have correct permissions to optimize the database.")"
-fi
-
-# strip any trailing slash from our dbroot
-dbroot="${dbroot%/}"
-lockfile="${dbroot}/db.lck"
-localdb="${dbroot}/local"
-
-# make sure pacman isn't running
-if [[ -f $lockfile ]]; then
- die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")"
-fi
-# do not let pacman run while we do this
-touch "$lockfile"
-
-workdir=$(mktemp -d "${TMPDIR:-/tmp}/pacman-optimize.XXXXXXXXXX") ||
- die_r "$(gettext "Cannot create temporary directory for database building.")\n" >&2
-
-# step 1: sum the old db
-msg "$(gettext "MD5sum'ing the old database...")"
-(cd "$localdb" && find . -type f -print0 | \
- xargs -0 openssl dgst -md5 | sort > "$workdir/pacsums.old")
-
-# step 2: tar it up
-msg "$(gettext "Tar'ing up %s...")" "$localdb"
-bsdtar -czf "$workdir/pacman-db.tar.gz" -C "$localdb" ./
-if (( $? )); then
- rm -rf "$workdir"
- die_r "$(gettext "Tar'ing up %s failed.")" "$localdb"
-fi
-
-# step 3: make and sum the new db side-by-side with the old
-msg "$(gettext "Making and MD5sum'ing the new database...")"
-mkdir "$localdb.new"
-bsdtar -xpf "$workdir/pacman-db.tar.gz" -C "$localdb.new"
-if (( $? )); then
- rm -rf "$workdir"
- die_r "$(gettext "Untar'ing %s failed.")" "$localdb"
-fi
-# immediate sync following extraction should get it written continuously on HDD
-msg "$(gettext "Syncing database to disk...")"
-sync
-(cd "$localdb.new" && find . -type f -print0 | \
- xargs -0 openssl dgst -md5 | sort > "$workdir/pacsums.new")
-
-# step 4: compare the sums
-msg "$(gettext "Checking integrity...")"
-read -ra old_dgst < <(openssl dgst -md5 < "$workdir/pacsums.old")
-read -ra new_dgst < <(openssl dgst -md5 < "$workdir/pacsums.new")
-if [[ ${old_dgst[@]:(-1)} != ${new_dgst[@]:(-1)} ]]; then
- # failed
- # leave our pacman-optimize tmpdir for checking to see what doesn't match up
- rm -rf "$localdb.new"
- die_r "$(gettext "Integrity check FAILED, reverting to old database.")"
-fi
-
-# step 5: shuffle the newly extracted DB into the proper location
-msg "$(gettext "Rotating database into place...")"
-
-fail=0
-mv "$localdb" "$localdb.old" || fail=1
-mv "$localdb.new" "$localdb" || fail=1
-chmod $(@MODECMD@ "$localdb.old") "$localdb" || fail=1
-chown $(@OWNERCMD@ "$localdb.old") "$localdb" || fail=1
-if (( fail )); then
- # failure with our directory shuffle
- die_r "$(gettext "New database substitution failed. Check for %s, %s, and %s directories.")" "$localdb" "$localdb.old" "$localdb.new"
-fi
-rm -rf "$localdb.old"
-
-# remove the lock file and our working directory with sums and tarfile
-rm -f "$lockfile"
-rm -rf "$workdir"
-
-echo
-msg "$(gettext "Finished. Your pacman database has been optimized.")"
-echo
-
-exit 0
-
-# vim: set noet:
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index fe63974d..4500dd75 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -28,6 +28,12 @@ export TEXTDOMAINDIR='@localedir@'
declare -r myver='@PACKAGE_VERSION@'
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+# Import parseopts.sh
+source "$LIBRARY"/util/parseopts.sh
+
+# Options
QUIET=0
USE_COLOR='y'
@@ -41,7 +47,6 @@ max_delta_size=70
# ensure we have a sane umask set
umask 0022
-m4_include(library/parseopts.sh)
m4_include(library/output_format.sh)
# print usage instructions
@@ -114,7 +119,7 @@ create_xdelta()
newver="$pkgver"
newarch="$arch"
- pkgsize="$(@SIZECMD@ -L "$newfile")"
+ pkgsize="$(wc -c "$newfile" | cut -d' ' -f1)"
if ((pkgsize < min_pkg_size)); then
msg "$(gettext "Skipping delta creation for small package: %s - size %s")" "$newname" "$pkgsize"
@@ -146,7 +151,7 @@ create_xdelta()
return 1
fi
- deltasize="$(@SIZECMD@ -L "$deltafile")"
+ deltasize="$(wc -c "$deltafile" | cut -d' ' -f1)"
if ((max_delta_size * pkgsize / 100 < deltasize)); then
msg "$(gettext "Delta package larger than maximum size. Removing.")"
diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in
index 53dd545e..7cc6a031 100644
--- a/scripts/po/POTFILES.in
+++ b/scripts/po/POTFILES.in
@@ -5,7 +5,6 @@ scripts/makepkg.sh.in
scripts/makepkg-template.pl.in
scripts/pacman-db-upgrade.sh.in
scripts/pacman-key.sh.in
-scripts/pacman-optimize.sh.in
scripts/pkgdelta.sh.in
scripts/repo-add.sh.in
scripts/libmakepkg/integrity.sh.in
@@ -15,6 +14,8 @@ scripts/libmakepkg/integrity/verify_checksum.sh.in
scripts/libmakepkg/integrity/verify_signature.sh.in
scripts/libmakepkg/lint_package.sh.in
scripts/libmakepkg/lint_package/build_references.sh.in
+scripts/libmakepkg/lint_package/dotfiles.sh.in
+scripts/libmakepkg/lint_package/file_names.sh.in
scripts/libmakepkg/lint_package/missing_backup.sh.in
scripts/libmakepkg/lint_pkgbuild.sh.in
scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -49,7 +50,7 @@ scripts/libmakepkg/tidy/purge.sh.in
scripts/libmakepkg/tidy/staticlibs.sh.in
scripts/libmakepkg/tidy/strip.sh.in
scripts/libmakepkg/tidy/zipman.sh.in
-scripts/libmakepkg/util/message.sh
+scripts/libmakepkg/util/message.sh.in
+scripts/libmakepkg/util/parseopts.sh.in
scripts/libmakepkg/util/source.sh.in
scripts/library/output_format.sh
-scripts/library/parseopts.sh
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 4da2c317..68edbf4b 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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
@@ -94,7 +94,7 @@ version() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>\n\n\
+Copyright (c) 2006-2017 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")"
}
@@ -151,9 +151,9 @@ db_write_delta() {
echo -e "%DELTAS%" >"$deltas"
fi
# get md5sum and compressed size of package
- md5sum=$(openssl dgst -md5 "$deltafile")
- md5sum=${md5sum##* }
- csize=$(@SIZECMD@ -L "$deltafile")
+ md5sum=$(md5sum "$deltafile")
+ md5sum=${md5sum%% *}
+ csize=$(wc -c "$deltafile" | cut -d' ' -f1)
oldfile=$(xdelta3 printhdr "$deltafile" | grep "XDELTA filename (source)" | sed 's/.*: *//')
newfile=$(xdelta3 printhdr "$deltafile" | grep "XDELTA filename (output)" | sed 's/.*: *//')
@@ -368,23 +368,23 @@ db_write_entry() {
error "$(gettext "Cannot use armored signatures for packages: %s")" "$pkgfile.sig"
return 1
fi
- pgpsigsize=$(@SIZECMD@ -L "$pkgfile.sig")
+ pgpsigsize=$(wc -c "$pkgfile.sig" | cut -d' ' -f1)
if (( pgpsigsize > 16384 )); then
error "$(gettext "Invalid package signature file '%s'.")" "$pkgfile.sig"
return 1
fi
msg2 "$(gettext "Adding package signature...")"
- pgpsig=$(openssl base64 -in "$pkgfile.sig" | tr -d '\n')
+ pgpsig=$(base64 "$pkgfile.sig" | tr -d '\n')
fi
- csize=$(@SIZECMD@ -L "$pkgfile")
+ csize=$(wc -c "$pkgfile" | cut -d' ' -f1)
# compute checksums
msg2 "$(gettext "Computing checksums...")"
- md5sum=$(openssl dgst -md5 "$pkgfile")
- md5sum=${md5sum##* }
- sha256sum=$(openssl dgst -sha256 "$pkgfile")
- sha256sum=${sha256sum##* }
+ md5sum=$(md5sum "$pkgfile")
+ md5sum=${md5sum%% *}
+ sha256sum=$(sha256sum "$pkgfile")
+ sha256sum=${sha256sum%% *}
# remove an existing entry if it exists, ignore failures
db_remove_entry "$pkgname"
@@ -455,7 +455,7 @@ db_write_entry() {
msg2 "$(gettext "Creating '%s' db entry...")" 'files'
local files_path="$tmpdir/files/$pkgname-$pkgver/files"
echo "%FILES%" >"$files_path"
- bsdtar --exclude='^.*' -tf "$pkgfile" >>"$files_path"
+ bsdtar --exclude='^.*' -tf "$pkgfile" | LC_ALL=C sort -u >>"$files_path"
if (( RMEXISTING )); then
msg2 "$(gettext "Removing old package file '%s'")" "$oldfilename"
@@ -501,7 +501,7 @@ elephant() {
"ZL9JFFZeAa0a2+lKjL2anpYfV+0Zx9LJ+/MC8nRayuDlSNy2rfAPibOzsiWHL0jL" \
"SsjFAQAA"
;;
- esac | openssl base64 -d | gzip -d
+ esac | base64 -d | gzip -d
}
prepare_repo_db() {
diff --git a/scripts/makepkg-wrapper.sh.in b/scripts/wrapper.sh.in
index 6e713145..f7595fce 100644
--- a/scripts/makepkg-wrapper.sh.in
+++ b/scripts/wrapper.sh.in
@@ -1,8 +1,8 @@
#!/bin/bash
#
-# makepkg - a wrapper for running the real makepkg in the source tree
+# @PROGNAME@ - a wrapper for running the real @PROGNAME@ in the source tree
#
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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
@@ -20,4 +20,4 @@
DIR="@PWD@"
-LIBRARY="$DIR"/libmakepkg exec "$DIR"/.lib/makepkg "$@"
+LIBRARY="$DIR"/libmakepkg exec "$DIR"/.lib/@PROGNAME@ "$@"
diff --git a/src/common/ini.c b/src/common/ini.c
index a4b29d17..e6437de3 100644
--- a/src/common/ini.c
+++ b/src/common/ini.c
@@ -1,7 +1,7 @@
/*
* ini.c
*
- * Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2017 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
@@ -61,19 +61,14 @@ int parse_ini(const char *file, ini_parser_fn cb, void *data)
}
while(safe_fgets(line, PATH_MAX, fp)) {
- char *key, *value, *ptr;
+ char *key, *value;
size_t line_len;
linenum++;
- /* ignore whole line and end of line comments */
- if((ptr = strchr(line, '#'))) {
- *ptr = '\0';
- }
-
line_len = strtrim(line);
- if(line_len == 0) {
+ if(line_len == 0 || line[0] == '#') {
continue;
}
diff --git a/src/common/ini.h b/src/common/ini.h
index e03a83fd..4a4b1edf 100644
--- a/src/common/ini.h
+++ b/src/common/ini.h
@@ -1,7 +1,7 @@
/*
* ini.h
*
- * Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2017 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.c b/src/common/util-common.c
index 794273fd..6825a435 100644
--- a/src/common/util-common.c
+++ b/src/common/util-common.c
@@ -1,7 +1,7 @@
/*
* util-common.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 14520944..b0280d7a 100644
--- a/src/common/util-common.h
+++ b/src/common/util-common.h
@@ -1,7 +1,7 @@
/*
* util-common.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/Makefile.am b/src/pacman/Makefile.am
index 14572cd4..8999f2b7 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -47,6 +47,9 @@ pacman_SOURCES = \
util.h util.c \
util-common.h util-common.c
-LDADD = $(LTLIBINTL) $(top_builddir)/lib/libalpm/.libs/libalpm.la
+pacman_LDADD = \
+ $(LTLIBINTL) \
+ $(top_builddir)/lib/libalpm/.libs/libalpm.la \
+ $(LIBARCHIVE_LIBS)
# vim:set noet:
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 7f72b84f..e1e77f78 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -1,7 +1,7 @@
/*
* callback.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/callback.h b/src/pacman/callback.h
index ad395e9d..b9bfeab5 100644
--- a/src/pacman/callback.h
+++ b/src/pacman/callback.h
@@ -1,7 +1,7 @@
/*
* callback.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 87fcf677..5c7d3631 100644
--- a/src/pacman/check.c
+++ b/src/pacman/check.c
@@ -1,7 +1,7 @@
/*
* check.c
*
- * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2017 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 5052376e..9fe1a1e2 100644
--- a/src/pacman/check.h
+++ b/src/pacman/check.h
@@ -1,7 +1,7 @@
/*
* check.h
*
- * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2017 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 25de7afa..261c8213 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -1,7 +1,7 @@
/*
* conf.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -325,10 +325,10 @@ int config_set_arch(const char *arch)
* @param linenum current line number in file
* @return 0 on success, 1 on any parsing error
*/
-static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
- alpm_siglevel_t *storage_mask, const char *file, int linenum)
+static int process_siglevel(alpm_list_t *values, int *storage,
+ int *storage_mask, const char *file, int linenum)
{
- alpm_siglevel_t level = *storage, mask = *storage_mask;
+ int level = *storage, mask = *storage_mask;
alpm_list_t *i;
int ret = 0;
@@ -421,13 +421,12 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
}
/**
- * Merge the package entires of two signature verification levels.
+ * Merge the package entries of two signature verification levels.
* @param base initial siglevel
- * @param over overridden siglevel
+ * @param over overriding siglevel
* @return merged siglevel
*/
-static alpm_siglevel_t merge_siglevel(alpm_siglevel_t base,
- alpm_siglevel_t over, alpm_siglevel_t mask)
+static int merge_siglevel(int base, int over, int mask)
{
return mask ? (over & mask) | (base & ~mask) : over;
}
@@ -499,6 +498,8 @@ static int _parse_options(const char *key, char *value,
config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF;
enable_colors(config->color);
}
+ } else if(strcmp(key, "DisableDownloadTimeout") == 0) {
+ config->disable_dl_timeout = 1;
} else {
pm_printf(ALPM_LOG_WARNING,
_("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"),
@@ -782,6 +783,8 @@ static int setup_libalpm(void)
alpm_option_set_cachedirs(handle, config->cachedirs);
}
+ alpm_option_set_overwrite_files(handle, config->overwrite_files);
+
alpm_option_set_default_siglevel(handle, config->siglevel);
config->localfilesiglevel = merge_siglevel(config->siglevel,
@@ -816,6 +819,8 @@ static int setup_libalpm(void)
alpm_option_set_noupgrades(handle, config->noupgrade);
alpm_option_set_noextracts(handle, config->noextract);
+ alpm_option_set_disable_dl_timeout(handle, config->disable_dl_timeout);
+
for(i = config->assumeinstalled; i; i = i->next) {
char *entry = i->data;
alpm_depend_t *dep = alpm_dep_from_string(entry);
@@ -845,11 +850,11 @@ struct section_t {
int depth;
};
-static int process_usage(alpm_list_t *values, alpm_db_usage_t *usage,
+static int process_usage(alpm_list_t *values, int *usage,
const char *file, int linenum)
{
alpm_list_t *i;
- alpm_db_usage_t level = *usage;
+ int level = *usage;
int ret = 0;
for(i = values; i; i = i->next) {
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 2ddeadb3..53b44be6 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -1,7 +1,7 @@
/*
* conf.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -37,9 +37,9 @@ typedef struct __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;
+ int usage;
+ int siglevel;
+ int siglevel_mask;
} config_repo_t;
typedef struct __config_t {
@@ -55,6 +55,7 @@ typedef struct __config_t {
unsigned short checkspace;
unsigned short usesyslog;
unsigned short color;
+ unsigned short disable_dl_timeout;
double deltaratio;
char *arch;
char *print_format;
@@ -66,6 +67,7 @@ typedef struct __config_t {
char *dbpath;
char *logfile;
char *gpgdir;
+ char *sysroot;
alpm_list_t *hookdirs;
alpm_list_t *cachedirs;
@@ -95,14 +97,16 @@ typedef struct __config_t {
unsigned short group;
unsigned short noask;
unsigned int ask;
- alpm_transflag_t flags;
- alpm_siglevel_t siglevel;
- alpm_siglevel_t localfilesiglevel;
- alpm_siglevel_t remotefilesiglevel;
+ /* Bitfield of alpm_transflag_t */
+ int flags;
+ /* Bitfields of alpm_siglevel_t */
+ int siglevel;
+ int localfilesiglevel;
+ int remotefilesiglevel;
- alpm_siglevel_t siglevel_mask;
- alpm_siglevel_t localfilesiglevel_mask;
- alpm_siglevel_t remotefilesiglevel_mask;
+ int siglevel_mask;
+ int localfilesiglevel_mask;
+ int remotefilesiglevel_mask;
/* conf file options */
/* I Love Candy! */
@@ -120,6 +124,7 @@ typedef struct __config_t {
alpm_list_t *assumeinstalled;
alpm_list_t *noupgrade;
alpm_list_t *noextract;
+ alpm_list_t *overwrite_files;
char *xfercommand;
/* our connection to libalpm */
@@ -169,6 +174,7 @@ enum {
OP_GPGDIR,
OP_DBONLY,
OP_FORCE,
+ OP_OVERWRITE_FILES,
OP_COLOR,
OP_DBPATH,
OP_CASCADE,
@@ -190,6 +196,7 @@ enum {
OP_PRINT,
OP_QUIET,
OP_ROOT,
+ OP_SYSROOT,
OP_RECURSIVE,
OP_SEARCH,
OP_REGEX,
@@ -201,7 +208,8 @@ enum {
OP_VERBOSE,
OP_DOWNLOADONLY,
OP_REFRESH,
- OP_ASSUMEINSTALLED
+ OP_ASSUMEINSTALLED,
+ OP_DISABLEDLTIMEOUT
};
/* clean method */
diff --git a/src/pacman/database.c b/src/pacman/database.c
index 01979034..8b99fdf6 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -1,7 +1,7 @@
/*
* database.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -74,10 +74,12 @@ static int change_install_reason(alpm_list_t *targets)
pkgname, alpm_strerror(alpm_errno(config->handle)));
ret = 1;
} else {
- if(reason == ALPM_PKG_REASON_DEPEND) {
- printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname);
- } else {
- printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname);
+ if(!config->quiet) {
+ if(reason == ALPM_PKG_REASON_DEPEND) {
+ printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname);
+ } else {
+ printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname);
+ }
}
}
}
@@ -286,6 +288,10 @@ int pacman_database(alpm_list_t *targets)
} else {
ret = check_db_sync();
}
+
+ if(ret == 0 && !config->quiet) {
+ printf(_("No database errors have been found!\n"));
+ }
}
if(config->flags & (ALPM_TRANS_FLAG_ALLDEPS | ALPM_TRANS_FLAG_ALLEXPLICIT)) {
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 7c89ad8e..2163c1ce 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -1,7 +1,7 @@
/*
* deptest.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/files.c b/src/pacman/files.c
index f5cba5b2..3072e280 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -1,7 +1,7 @@
/*
* files.c
*
- * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2015-2017 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 3ab9abc0..65f7aee6 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -230,7 +230,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
break;
}
- alpm_pkgvalidation_t v = alpm_pkg_get_validation(pkg);
+ int v = alpm_pkg_get_validation(pkg);
if(v) {
if(v & ALPM_PKG_VALIDATION_NONE) {
validation = alpm_list_add(validation, _("None"));
diff --git a/src/pacman/package.h b/src/pacman/package.h
index 3129a736..46081381 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -1,7 +1,7 @@
/*
* package.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 be52d1be..605aec3e 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -1,7 +1,7 @@
/*
* pacman.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -171,6 +171,7 @@ static void usage(int op, const char * const myname)
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"));
+ addlist(_(" -q, --quiet suppress output of success messages\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);
@@ -188,7 +189,8 @@ static void usage(int op, const char * const myname)
switch(op) {
case PM_OP_SYNC:
case PM_OP_UPGRADE:
- addlist(_(" --force force install, overwrite conflicting files\n"));
+ addlist(_(" --overwrite <path>\n"
+ " overwrite conflicting files (can be used more than once)\n"));
addlist(_(" --asdeps install packages as non-explicitly installed\n"));
addlist(_(" --asexplicit install packages as explicitly installed\n"));
addlist(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
@@ -212,6 +214,7 @@ static void usage(int op, const char * const myname)
addlist(_(" -r, --root <path> set an alternate installation root\n"));
addlist(_(" -v, --verbose be verbose\n"));
addlist(_(" --arch <arch> set an alternate architecture\n"));
+ addlist(_(" --sysroot operate on a mounted guest system (root-only)\n"));
addlist(_(" --cachedir <dir> set an alternate package cache location\n"));
addlist(_(" --hookdir <dir> set an alternate hook location\n"));
addlist(_(" --color <when> colorize the output\n"));
@@ -221,6 +224,8 @@ static void usage(int op, const char * const myname)
addlist(_(" --logfile <path> set an alternate log file\n"));
addlist(_(" --noconfirm do not ask for any confirmation\n"));
addlist(_(" --confirm always ask for confirmation\n"));
+ addlist(_(" --disable-download-timeout\n"
+ " use relaxed timeouts for download\n"));
}
list = alpm_list_msort(list, alpm_list_count(list), options_cmp);
for(i = list; i; i = alpm_list_next(i)) {
@@ -236,7 +241,7 @@ static void version(void)
{
printf("\n");
printf(" .--. Pacman v%s - libalpm v%s\n", PACKAGE_VERSION, alpm_version());
- printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2016 Pacman Development Team\n");
+ printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2017 Pacman Development Team\n");
printf("\\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet\n");
printf(" '--'\n");
printf(_(" This program may be freely redistributed under\n"
@@ -443,6 +448,13 @@ static int parsearg_global(int opt)
free(config->rootdir);
config->rootdir = strdup(optarg);
break;
+ case OP_SYSROOT:
+ free(config->sysroot);
+ config->sysroot = strdup(optarg);
+ break;
+ case OP_DISABLEDLTIMEOUT:
+ config->disable_dl_timeout = 1;
+ break;
case OP_VERBOSE:
case 'v':
(config->verbose)++;
@@ -466,6 +478,10 @@ static int parsearg_database(int opt)
case 'k':
(config->op_q_check)++;
break;
+ case OP_QUIET:
+ case 'q':
+ config->quiet = 1;
+ break;
default:
return 1;
}
@@ -696,8 +712,13 @@ static int parsearg_upgrade(int opt)
}
switch(opt) {
case OP_FORCE:
+ pm_printf(ALPM_LOG_WARNING,
+ _("option --force is deprecated; use --overwrite instead\n"));
config->flags |= ALPM_TRANS_FLAG_FORCE;
break;
+ case OP_OVERWRITE_FILES:
+ parsearg_util_addlist(&(config->overwrite_files));
+ break;
case OP_ASDEPS:
config->flags |= ALPM_TRANS_FLAG_ALLDEPS;
break;
@@ -901,6 +922,7 @@ static int parseargs(int argc, char *argv[])
{"print", no_argument, 0, OP_PRINT},
{"quiet", no_argument, 0, OP_QUIET},
{"root", required_argument, 0, OP_ROOT},
+ {"sysroot", required_argument, 0, OP_SYSROOT},
{"recursive", no_argument, 0, OP_RECURSIVE},
{"search", no_argument, 0, OP_SEARCH},
{"regex", no_argument, 0, OP_REGEX},
@@ -919,6 +941,7 @@ static int parseargs(int argc, char *argv[])
{"assume-installed", required_argument, 0, OP_ASSUMEINSTALLED},
{"debug", optional_argument, 0, OP_DEBUG},
{"force", no_argument, 0, OP_FORCE},
+ {"overwrite", required_argument, 0, OP_OVERWRITE_FILES},
{"noprogressbar", no_argument, 0, OP_NOPROGRESSBAR},
{"noscriptlet", no_argument, 0, OP_NOSCRIPTLET},
{"ask", required_argument, 0, OP_ASK},
@@ -934,6 +957,7 @@ static int parseargs(int argc, char *argv[])
{"gpgdir", required_argument, 0, OP_GPGDIR},
{"dbonly", no_argument, 0, OP_DBONLY},
{"color", required_argument, 0, OP_COLOR},
+ {"disable-download-timeout", no_argument, 0, OP_DISABLEDLTIMEOUT},
{0, 0, 0, 0}
};
@@ -1089,7 +1113,6 @@ static void cl_to_log(int argc, char *argv[])
int main(int argc, char *argv[])
{
int ret = 0;
- size_t i;
uid_t myuid = getuid();
install_segv_handler();
@@ -1133,48 +1156,52 @@ int main(int argc, char *argv[])
cleanup(ret);
}
+ /* check if we have sufficient permission for the requested operation */
+ if(myuid > 0 && needs_root()) {
+ pm_printf(ALPM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
+ cleanup(EXIT_FAILURE);
+ }
+
+ if(config->sysroot && (chroot(config->sysroot) != 0 || chdir("/") != 0)) {
+ pm_printf(ALPM_LOG_ERROR,
+ _("chroot to '%s' failed: (%s)\n"), config->sysroot, strerror(errno));
+ cleanup(EXIT_FAILURE);
+ }
+
/* we support reading targets from stdin if a cmdline parameter is '-' */
if(alpm_list_find_str(pm_targets, "-")) {
if(!isatty(fileno(stdin))) {
int target_found = 0;
- size_t current_size = PATH_MAX;
- char *vdata, *line = malloc(current_size);
- int c;
+ char *vdata, *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
/* remove the '-' from the list */
pm_targets = alpm_list_remove_str(pm_targets, "-", &vdata);
free(vdata);
- i = 0;
- do {
- c = fgetc(stdin);
- if(c == EOF || isspace(c)) {
- /* avoid adding zero length arg when multiple spaces separate args */
- if(i > 0) {
- line[i] = '\0';
- pm_targets = alpm_list_add(pm_targets, strdup(line));
- target_found = 1;
- i = 0;
- }
- } else {
- line[i++] = (char)c;
- /* we may be at the end of our allocated buffer now */
- if(i >= current_size) {
- char *new = realloc(line, current_size * 2);
- if(new) {
- line = new;
- current_size *= 2;
- } else {
- free(line);
- pm_printf(ALPM_LOG_ERROR,
- _("memory exhausted in argument parsing\n"));
- cleanup(EXIT_FAILURE);
- }
- }
+ while((nread = getline(&line, &line_size, stdin)) != -1) {
+ if(line[nread - 1] == '\n') {
+ /* remove trailing newline */
+ line[nread - 1] = '\0';
}
- } while(c != EOF);
-
+ if(line[0] == '\0') {
+ /* skip empty lines */
+ continue;
+ }
+ if(!alpm_list_append_strdup(&pm_targets, line)) {
+ break;
+ }
+ target_found = 1;
+ }
free(line);
+
+ if(ferror(stdin)) {
+ pm_printf(ALPM_LOG_ERROR,
+ _("failed to read arguments from stdin: (%s)\n"), strerror(errno));
+ cleanup(EXIT_FAILURE);
+ }
+
if(!freopen(ctermid(NULL), "r", stdin)) {
pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"),
strerror(errno));
@@ -1213,12 +1240,6 @@ int main(int argc, char *argv[])
config->logmask &= ~ALPM_LOG_WARNING;
}
- /* check if we have sufficient permission for the requested operation */
- if(myuid > 0 && needs_root()) {
- pm_printf(ALPM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
- cleanup(EXIT_FAILURE);
- }
-
if(config->verbose > 0) {
alpm_list_t *j;
printf("Root : %s\n", alpm_option_get_root(config->handle));
diff --git a/src/pacman/pacman.h b/src/pacman/pacman.h
index 84f70a66..107d4268 100644
--- a/src/pacman/pacman.h
+++ b/src/pacman/pacman.h
@@ -1,7 +1,7 @@
/*
* pacman.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 a8f4e675..a8417570 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -1,7 +1,7 @@
/*
* query.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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 73b48c36..7de6f8b6 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -1,7 +1,7 @@
/*
* remove.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/sighandler.c b/src/pacman/sighandler.c
index 366718b2..73a46db6 100644
--- a/src/pacman/sighandler.c
+++ b/src/pacman/sighandler.c
@@ -1,7 +1,7 @@
/*
* sighandler.c
*
- * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2015-2017 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/sighandler.h b/src/pacman/sighandler.h
index 108a7e00..e39f546c 100644
--- a/src/pacman/sighandler.h
+++ b/src/pacman/sighandler.h
@@ -1,7 +1,7 @@
/*
* sighandler.h
*
- * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2015-2017 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/sync.c b/src/pacman/sync.c
index 8b306034..680d7b3e 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -1,7 +1,7 @@
/*
* sync.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -630,7 +630,7 @@ static int process_target(const char *target, int error)
if(targname && targname != targstring) {
alpm_db_t *db;
const char *dbname;
- alpm_db_usage_t usage;
+ int usage;
*targname = '\0';
targname++;
@@ -823,8 +823,13 @@ int sync_prepare_execute(void)
conflict->file, conflict->target, conflict->ctarget);
break;
case ALPM_FILECONFLICT_FILESYSTEM:
- printf(_("%s: %s exists in filesystem\n"),
- conflict->target, conflict->file);
+ if(conflict->ctarget[0]) {
+ printf(_("%s: %s exists in filesystem (owned by %s)\n"),
+ conflict->target, conflict->file, conflict->ctarget);
+ } else {
+ printf(_("%s: %s exists in filesystem\n"),
+ conflict->target, conflict->file);
+ }
break;
}
alpm_fileconflict_free(conflict);
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 591556d3..d4808b60 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -1,7 +1,7 @@
/*
* upgrade.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -89,15 +89,15 @@ int pacman_upgrade(alpm_list_t *targets)
for(i = targets, n = 0; i; i = alpm_list_next(i), n++) {
const char *targ = i->data;
alpm_pkg_t *pkg;
- alpm_siglevel_t level;
+ int siglevel;
if(file_is_remote[n]) {
- level = alpm_option_get_remote_file_siglevel(config->handle);
+ siglevel = alpm_option_get_remote_file_siglevel(config->handle);
} else {
- level = alpm_option_get_local_file_siglevel(config->handle);
+ siglevel = alpm_option_get_local_file_siglevel(config->handle);
}
- if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) {
+ if(alpm_pkg_load(config->handle, targ, 1, siglevel, &pkg) != 0) {
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle)));
retval = 1;
diff --git a/src/pacman/util.c b/src/pacman/util.c
index b9790836..ae8a74d3 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1,7 +1,7 @@
/*
* util.c
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -61,7 +61,7 @@ enum {
CELL_FREE = (1 << 3)
};
-int trans_init(alpm_transflag_t flags, int check_valid)
+int trans_init(int flags, int check_valid)
{
int ret;
@@ -103,6 +103,9 @@ int trans_release(void)
int needs_root(void)
{
+ if(config->sysroot) {
+ return 1;
+ }
switch(config->op) {
case PM_OP_DATABASE:
return !config->op_q_check;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 74ce4cb2..5f1df2f2 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -1,7 +1,7 @@
/*
* util.h
*
- * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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
@@ -45,7 +45,8 @@ typedef struct _pm_target_t {
} pm_target_t;
void trans_init_error(void);
-int trans_init(alpm_transflag_t flags, int check_valid);
+/* flags is a bitfield of alpm_transflag_t flags */
+int trans_init(int flags, int check_valid);
int trans_release(void);
int needs_root(void);
int check_syncdbs(size_t need_repos, int check_valid);
diff --git a/src/util/.gitignore b/src/util/.gitignore
index 202fb753..4cb3103e 100644
--- a/src/util/.gitignore
+++ b/src/util/.gitignore
@@ -2,10 +2,6 @@
.libs
cleanupdelta
cleanupdelta.exe
-pacsort
-pacsort.exe
-pactree
-pactree.exe
testpkg
testpkg.exe
vercmp
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 6a89ea69..562151bc 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 cleanupdelta pacsort pactree
+bin_PROGRAMS = vercmp testpkg cleanupdelta
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
@@ -21,12 +21,6 @@ AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS) \
cleanupdelta_SOURCES = cleanupdelta.c
cleanupdelta_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
-pacsort_SOURCES = pacsort.c util-common.c
-pacsort_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
-
-pactree_SOURCES = pactree.c util-common.c
-pactree_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 043acf1a..2a1544e4 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2017 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
@@ -68,11 +68,11 @@ static void checkdbs(alpm_list_t *dbnames)
{
alpm_db_t *db = NULL;
alpm_list_t *i;
- const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
+ const int siglevel = 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);
+ db = alpm_register_syncdb(handle, dbname, siglevel);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database '%s' (%s)\n",
dbname, alpm_strerror(alpm_errno(handle)));
diff --git a/src/util/pacsort.c b/src/util/pacsort.c
deleted file mode 100644
index 662b250d..00000000
--- a/src/util/pacsort.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * pacsort.c - a sort utility implementing alpm_pkg_vercmp
- *
- * Copyright (c) 2010-2016 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/>.
- */
-
-#include <errno.h>
-#include <fnmatch.h>
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <alpm.h>
-#include "util-common.h"
-
-#define DELIM ' '
-#define INVALD_ESCAPE_CHAR ((char)-1)
-
-#ifndef MIN
-#define MIN(a, b) \
- __extension__({ \
- __typeof__(a) _a = (a); \
- __typeof__(b) _b = (b); \
- _a < _b ? _a : _b; \
- })
-#endif
-
-struct buffer_t {
- char *mem;
- size_t len;
- size_t maxlen;
-};
-
-struct list_t {
- void **list;
- size_t count;
- size_t maxcount;
-};
-
-struct input_t {
- char *data;
- int is_file;
-
- const char *pkgname;
- size_t pkgname_len;
-
- const char *pkgver;
- size_t pkgver_len;
-};
-
-static struct options_t {
- int order;
- int sortkey;
- int null;
- int filemode;
- int help;
- char delim;
-} opts;
-
-static struct buffer_t *buffer_new(size_t initial_size)
-{
- struct buffer_t *buf;
-
- buf = calloc(1, sizeof(*buf));
- if(!buf) {
- return NULL;
- }
-
- buf->mem = calloc(initial_size, sizeof(char));
- if(!buf->mem) {
- free(buf);
- return NULL;
- }
-
- buf->len = 0;
- buf->maxlen = initial_size;
-
- return buf;
-}
-
-static void buffer_free(struct buffer_t *buf)
-{
- if(!buf) {
- return;
- }
-
- free(buf->mem);
- free(buf);
-}
-
-static int buffer_grow(struct buffer_t *buffer)
-{
- size_t newsz = buffer->maxlen * 2.5;
- char* new_mem = realloc(buffer->mem, newsz * sizeof(char));
- if(!new_mem) {
- return 1;
- }
- buffer->mem = new_mem;
- buffer->maxlen = newsz;
-
- return 0;
-}
-
-static struct list_t *list_new(size_t initial_size)
-{
- struct list_t *list;
-
- list = calloc(1, sizeof(struct list_t));
- if(!list) {
- return NULL;
- }
-
- list->list = calloc(initial_size, sizeof(char *));
- if(!list->list) {
- free(list);
- return NULL;
- }
-
- list->maxcount = initial_size;
-
- return list;
-}
-
-static int list_grow(struct list_t *list)
-{
- size_t newsz = list->maxcount * 2.5;
- void **new_list = realloc(list->list, newsz * sizeof(char *));
- if(!new_list) {
- return 1;
- }
-
- list->list = new_list;
- list->maxcount = newsz;
-
- return 0;
-}
-
-static int list_add(struct list_t *list, void *obj)
-{
- if(!list || !obj) {
- return 1;
- }
-
- if(list->count + 1 >= list->maxcount) {
- if(list_grow(list) != 0) {
- return 1;
- }
- }
-
- list->list[list->count] = obj;
- list->count++;
-
- return 0;
-}
-
-static void list_free(struct list_t *list, void (*freefn)(void *))
-{
- size_t i;
-
- if(!list) {
- return;
- }
-
- if(list->list) {
- for(i = 0; i < list->count; i++) {
- freefn(list->list[i]);
- }
- free(list->list);
- }
- free(list);
-}
-
-static void input_free(void *p)
-{
- struct input_t *in = p;
-
- if(in == NULL) {
- return;
- }
-
- free(in->data);
- free(in);
-}
-
-static struct input_t *input_new(const char *path, int pathlen)
-{
- const char *pkgver_end;
- const char *slash;
- struct input_t *in;
-
- in = calloc(1, sizeof(struct input_t));
- if(in == NULL) {
- return NULL;
- }
-
- in->data = strndup(path, pathlen);
- if(in->data == NULL) {
- free(in);
- return NULL;
- }
-
- in->is_file = fnmatch("*-*.pkg.tar.?z", in->data, 0) == 0;
- if(!in->is_file) {
- return in;
- }
-
- /* for files, we parse the pkgname and pkgrel from the full filename. */
-
- slash = strrchr(in->data, '/');
- if(slash == NULL) {
- in->pkgname = in->data;
- } else {
- in->pkgname = slash + 1;
- }
-
- pkgver_end = strrchr(in->pkgname, '-');
-
- /* read backwards through pkgrel */
- for(in->pkgver = pkgver_end - 1;
- in->pkgver > in->pkgname && *in->pkgver != '-';
- --in->pkgver)
- ;
- /* read backwards through pkgver */
- for(--in->pkgver;
- in->pkgver > in->pkgname && *in->pkgver != '-';
- --in->pkgver)
- ;
- ++in->pkgver;
-
- in->pkgname_len = in->pkgver - in->pkgname - 1;
- in->pkgver_len = pkgver_end - in->pkgver;
-
- return in;
-}
-
-static char *explode(struct buffer_t *buffer, struct list_t *list)
-{
- char *ptr, *end;
- const char linedelim = opts.null ? '\0' : '\n';
- struct input_t *meta;
-
- ptr = buffer->mem;
- while((end = memchr(ptr, linedelim, &buffer->mem[buffer->len] - ptr))) {
- *end = '\0';
- meta = input_new(ptr, end - ptr);
- if(meta == NULL || list_add(list, meta) != 0) {
- input_free(meta);
- return NULL;
- }
- ptr = end + 1;
- }
-
- return ptr;
-}
-
-static int splitfile(FILE *stream, struct buffer_t *buffer, struct list_t *list)
-{
- size_t nread;
- char *ptr;
-
- while(!feof(stream)) {
- /* check if a read of BUFSIZ chars will overflow */
- if(buffer->len + BUFSIZ + 1 >= buffer->maxlen) {
- if(buffer_grow(buffer) != 0) {
- return 1;
- }
- }
-
- nread = fread(&buffer->mem[buffer->len], 1, BUFSIZ, stream);
- if(nread == 0) {
- break; /* EOF */
- }
- buffer->len += nread;
-
- if((ptr = explode(buffer, list)) == NULL) {
- return 1;
- }
-
- if(ptr != buffer->mem) {
- /* realign the data in the buffer */
- buffer->len = &buffer->mem[buffer->len] - ptr;
- memmove(&buffer->mem[0], ptr, buffer->len + 1);
- }
- }
-
- if(buffer->len) {
- struct input_t *meta = input_new(buffer->mem, buffer->len + 1);
- if(meta == NULL || list_add(list, meta) != 0) {
- input_free(meta);
- return 1;
- }
- }
-
- return 0;
-}
-
-/* returns a pointer to the nth column of a string without being destructive */
-static const char *nth_column(const char *string)
-{
- const char *prev, *ptr;
- int col;
-
- ptr = prev = string;
- for(col = 0; ptr && col < opts.sortkey; col++) {
- prev = ptr;
- ptr = strchr(ptr, opts.delim);
- if(ptr) {
- ptr++;
- }
- }
-
- return prev;
-}
-
-static int compare_versions(const char *v1, const char *v2)
-{
- if(opts.sortkey == 0) {
- return opts.order * alpm_pkg_vercmp(v1, v2);
- } else {
- return opts.order * alpm_pkg_vercmp(nth_column(v1), nth_column(v2));
- }
-}
-
-static int compare_files(const struct input_t *meta1, const struct input_t *meta2)
-{
- int cmp;
- char *verbuf;
- const char *v1, *v2;
-
- /* sort first by package name */
- cmp = memcmp(meta1->pkgname, meta2->pkgname,
- MIN(meta1->pkgname_len, meta2->pkgname_len));
-
- /* 1) package names differ, sort by package name */
- if(cmp != 0) {
- return opts.order * cmp;
- }
-
- /* 2) prefixes are the same but length differs, sort by length */
- if(meta1->pkgname_len != meta2->pkgname_len) {
- return opts.order * (meta1->pkgname_len - meta2->pkgname_len);
- }
-
- /* allocate once with enough space for both pkgver */
- verbuf = calloc(1, meta1->pkgver_len + 1 + meta2->pkgver_len + 1);
- memcpy(verbuf, meta1->pkgver, meta1->pkgver_len);
- memcpy(&verbuf[meta1->pkgver_len + 1], meta2->pkgver, meta2->pkgver_len);
-
- /* 3) sort by package version */
- v1 = verbuf;
- v2 = verbuf + meta1->pkgver_len + 1;
- cmp = compare_versions(v1, v2);
- free(verbuf);
-
- return cmp;
-}
-
-static int vercmp(const void *p1, const void *p2)
-{
- const struct input_t *meta1, *meta2;
-
- meta1 = *(struct input_t **)p1;
- meta2 = *(struct input_t **)p2;
-
- if(opts.filemode && meta1->is_file && meta2->is_file) {
- return compare_files(meta1, meta2);
- } else {
- return compare_versions(meta1->data, meta2->data);
- }
-}
-
-static char escape_char(const char *string)
-{
- if(!string) {
- return INVALD_ESCAPE_CHAR;
- }
-
- const size_t len = strlen(string);
-
- if(len > 2) {
- return INVALD_ESCAPE_CHAR;
- }
-
- if(len == 1) {
- return *string;
- }
-
- if(*string != '\\') {
- return INVALD_ESCAPE_CHAR;
- }
-
- switch(string[1]) {
- case 't':
- return '\t';
- case 'n':
- return '\n';
- case 'v':
- return '\v';
- case '0':
- return '\0';
- default:
- return INVALD_ESCAPE_CHAR;
- }
-}
-
-static void usage(void)
-{
- fprintf(stderr, "pacsort (pacman) v" PACKAGE_VERSION "\n\n"
- "A sort utility implementing alpm_pkg_vercmp.\n\n"
- "Usage: pacsort [options] [files...]\n\n"
- " -f, --files assume inputs are file paths of packages\n"
- " -h, --help display this help message\n"
- " -k, --key <index> sort input starting on specified column\n"
- " -r, --reverse sort in reverse order (default: oldest to newest)\n"
- " -t, --separator <sep> specify field separator (default: space)\n"
- " -z, --null lines end with null bytes, not newlines\n\n"
- "pacsort writes the sorted concatenation of all files, to standard output.\n"
- "Files should contain a list of inputs to sort.\n\n"
- "Standard input is read when no files are given.\n\n");
-}
-
-static int parse_options(int argc, char **argv)
-{
- int opt;
-
- static const struct option opttable[] = {
- {"files", no_argument, 0, 'f'},
- {"help", no_argument, 0, 'h'},
- {"key", required_argument, 0, 'k'},
- {"reverse", no_argument, 0, 'r'},
- {"separator", required_argument, 0, 't'},
- {"null", no_argument, 0, 'z'},
- {0, 0, 0, 0}
- };
-
- while((opt = getopt_long(argc, argv, "fhk:rt:z", opttable, NULL)) != -1) {
- switch(opt) {
- case 'f':
- opts.filemode = 1;
- break;
- case 'h':
- opts.help = 1;
- return 0;
- case 'k':
- opts.sortkey = (int)strtol(optarg, NULL, 10);
- if(opts.sortkey <= 0) {
- fprintf(stderr, "error: invalid sort key -- %s\n", optarg);
- return 1;
- }
- break;
- case 'r':
- opts.order = -1;
- break;
- case 't':
- opts.delim = escape_char(optarg);
- if(opts.delim == INVALD_ESCAPE_CHAR) {
- fprintf(stderr, "error: invalid field separator -- `%s'\n", optarg);
- return 1;
- }
- break;
- case 'z':
- opts.null = 1;
- break;
- default:
- return 1;
- }
- }
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- struct list_t *list;
- struct buffer_t *buffer;
- size_t i;
- int ret = 0;
-
- /* option defaults */
- opts.order = 1;
- opts.delim = DELIM;
- opts.sortkey = 0;
- opts.null = 0;
-
- if(parse_options(argc, argv) != 0) {
- usage();
- return 2;
- }
-
- if(opts.help) {
- usage();
- return 0;
- }
-
- list = list_new(100);
- buffer = buffer_new(BUFSIZ * 3);
-
- if(optind == argc) {
- if(splitfile(stdin, buffer, list) != 0) {
- fprintf(stderr, "%s: memory exhausted\n", argv[0]);
- ret = ENOMEM;
- goto cleanup;
- }
- } else {
- while(optind < argc) {
- FILE *input = fopen(argv[optind], "r");
- if(input) {
- if(splitfile(input, buffer, list) != 0) {
- fprintf(stderr, "%s: memory exhausted\n", argv[0]);
- fclose(input);
- ret = ENOMEM;
- goto cleanup;
- }
- fclose(input);
- } else {
- fprintf(stderr, "%s: %s: %s\n", argv[0], argv[optind], strerror(errno));
- }
- optind++;
- }
- }
-
- if(list->count) {
- const char linedelim = opts.null ? '\0' : '\n';
- qsort(list->list, list->count, sizeof(void *), vercmp);
- for(i = 0; i < list->count; i++) {
- const struct input_t *in = list->list[i];
- printf("%s%c", in->data, linedelim);
- }
- }
-
-cleanup:
- list_free(list, input_free);
- buffer_free(buffer);
-
- return ret;
-}
-
-/* vim: set noet: */
diff --git a/src/util/pactree.c b/src/util/pactree.c
deleted file mode 100644
index 67be9f94..00000000
--- a/src/util/pactree.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * pactree.c - a simple dependency tree viewer
- *
- * Copyright (c) 2010-2016 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/>.
- */
-
-#include <ctype.h>
-#include <getopt.h>
-#include <stdio.h>
-#include <string.h>
-#include <locale.h>
-#include <alpm.h>
-#include <alpm_list.h>
-
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-
-#include "util-common.h"
-
-#define LINE_MAX 512
-
-typedef struct tdepth {
- struct tdepth *prev;
- struct tdepth *next;
- int level;
-} tdepth;
-
-/* output */
-struct graph_style {
- const char *provides;
- const char *tip;
- const char *last;
- const char *limb;
- int indent;
-};
-
-#define UTF_V "\342\224\202" /* U+2502, Vertical line drawing char */
-#define UTF_VR "\342\224\234" /* U+251C, Vertical and right */
-#define UTF_H "\342\224\200" /* U+2500, Horizontal */
-#define UTF_UR "\342\224\224" /* U+2514, Up and right */
-
-static struct graph_style graph_utf8 = {
- " provides",
- UTF_VR UTF_H,
- UTF_UR UTF_H,
- UTF_V " ",
- 2
-};
-
-static struct graph_style graph_default = {
- " provides",
- "|-",
- "`-",
- "|",
- 2
-};
-
-static struct graph_style graph_linear = {
- "",
- "",
- "",
- "",
- 0
-};
-
-/* color choices */
-struct color_choices {
- const char *branch1;
- const char *branch2;
- const char *leaf1;
- const char *leaf2;
- const char *off;
-};
-
-static struct color_choices use_color = {
- "\033[0;33m", /* yellow */
- "\033[0;37m", /* white */
- "\033[1;32m", /* bold green */
- "\033[0;32m", /* green */
- "\033[0m"
-};
-
-static struct color_choices no_color = {
- "",
- "",
- "",
- "",
- ""
-};
-
-/* long operations */
-enum {
- OP_CONFIG = 1000
-};
-
-/* globals */
-alpm_handle_t *handle = NULL;
-alpm_list_t *walked = NULL;
-alpm_list_t *provisions = NULL;
-
-/* options */
-struct color_choices *color = &no_color;
-struct graph_style *style = &graph_utf8;
-int graphviz = 0;
-int max_depth = -1;
-int reverse = 0;
-int unique = 0;
-int searchsyncs = 0;
-const char *dbpath = DBPATH;
-const char *configfile = CONFFILE;
-
-static int register_syncs(void)
-{
- FILE *fp;
- char *section = NULL;
- char line[LINE_MAX];
- const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
-
- fp = fopen(configfile, "r");
- if(!fp) {
- fprintf(stderr, "error: config file %s could not be read\n", configfile);
- return 1;
- }
-
- while(fgets(line, LINE_MAX, fp)) {
- size_t linelen;
- char *ptr;
-
- /* ignore whole line and end of line comments */
- if((ptr = strchr(line, '#'))) {
- *ptr = '\0';
- }
-
- linelen = strtrim(line);
-
- if(linelen == 0) {
- continue;
- }
-
- if(line[0] == '[' && line[linelen - 1] == ']') {
- free(section);
- section = strndup(&line[1], linelen - 2);
-
- if(section && strcmp(section, "options") != 0) {
- alpm_db_t *db = alpm_register_syncdb(handle, section, level);
- alpm_db_set_usage(db, ALPM_DB_USAGE_ALL);
- }
- }
- }
-
- free(section);
- fclose(fp);
-
- return 0;
-}
-
-static int parse_options(int argc, char *argv[])
-{
- int opt, option_index = 0;
- char *endptr = NULL;
-
- static const struct option opts[] = {
- {"ascii", no_argument, 0, 'a'},
- {"dbpath", required_argument, 0, 'b'},
- {"color", no_argument, 0, 'c'},
- {"depth", required_argument, 0, 'd'},
- {"graph", no_argument, 0, 'g'},
- {"help", no_argument, 0, 'h'},
- {"linear", no_argument, 0, 'l'},
- {"reverse", no_argument, 0, 'r'},
- {"sync", no_argument, 0, 's'},
- {"unique", no_argument, 0, 'u'},
-
- {"config", required_argument, 0, OP_CONFIG},
- {0, 0, 0, 0}
- };
-
-#ifdef HAVE_LANGINFO_H
- setlocale(LC_ALL, "");
- if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
- style = &graph_utf8;
- }
-#else
- style = &graph_default;
-#endif
-
- while((opt = getopt_long(argc, argv, "ab:cd:ghlrsu", opts, &option_index))) {
- if(opt < 0) {
- break;
- }
-
- switch(opt) {
- case 'a':
- style = &graph_default;
- break;
- case OP_CONFIG:
- configfile = optarg;
- break;
- case 'b':
- dbpath = optarg;
- break;
- case 'c':
- color = &use_color;
- break;
- case 'd':
- /* validate depth */
- max_depth = (int)strtol(optarg, &endptr, 10);
- if(*endptr != '\0') {
- fprintf(stderr, "error: invalid depth -- %s\n", optarg);
- return 1;
- }
- break;
- case 'g':
- graphviz = 1;
- break;
- case 'l':
- style = &graph_linear;
- break;
- case 'r':
- reverse = 1;
- break;
- case 's':
- searchsyncs = 1;
- break;
- case 'u':
- unique = 1;
- style = &graph_linear;
- break;
- case 'h':
- case '?':
- default:
- return 1;
- }
- }
-
- if(!argv[optind]) {
- return 1;
- }
-
- return 0;
-}
-
-static void usage(void)
-{
- fprintf(stderr, "pactree (pacman) v" PACKAGE_VERSION "\n\n"
- "A simple dependency tree viewer.\n\n"
- "Usage: pactree [options] PACKAGE\n\n"
- " -a, --ascii use ASCII characters for tree formatting\n"
- " -b, --dbpath <path> set an alternate database location\n"
- " -c, --color colorize output\n"
- " -d, --depth <#> limit the depth of recursion\n"
- " -g, --graph generate output for graphviz's dot\n"
- " -h, --help display this help message\n"
- " -l, --linear enable linear output\n"
- " -r, --reverse list packages that depend on the named package\n"
- " -s, --sync search sync databases instead of local\n"
- " -u, --unique show dependencies with no duplicates (implies -l)\n"
- " --config <path> set an alternate configuration file\n");
-}
-
-static void cleanup(void)
-{
- alpm_list_free(walked);
- alpm_list_free(provisions);
- alpm_release(handle);
-}
-
-/* pkg provides provision */
-static void print_text(const char *pkg, const char *provision,
- tdepth *depth, int last)
-{
- const char *tip = "";
- int level = 1;
- if(!pkg && !provision) {
- /* not much we can do */
- return;
- }
-
- if(depth->level > 0) {
- tip = last ? style->last : style->tip;
-
- /* print limbs */
- while(depth->prev) {
- depth = depth->prev;
- }
- printf("%s", color->branch1);
- while(depth->next) {
- printf("%*s%-*s", style->indent * (depth->level - level), "",
- style->indent, style->limb);
- level = depth->level + 1;
- depth = depth->next;
- }
- printf("%*s", style->indent * (depth->level - level), "");
- }
-
- /* print tip */
- /* If style->provides is empty (e.g. when using linear style), we do not
- * want to print the provided package. This makes output easier to parse and
- * to reuse. */
- if(!pkg && provision) {
- printf("%s%s%s%s [unresolvable]%s\n", tip, color->leaf1,
- provision, color->branch1, color->off);
- } else if(provision && strcmp(pkg, provision) != 0 && *(style->provides) != '\0') {
- printf("%s%s%s%s%s %s%s%s\n", tip, color->leaf1, pkg,
- color->leaf2, style->provides, color->leaf1, provision,
- color->off);
- } else {
- printf("%s%s%s%s\n", tip, color->leaf1, pkg, color->off);
- }
-}
-
-static void print_graph(const char *parentname, const char *pkgname, const char *depname)
-{
- if(depname) {
- printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, depname);
- if(pkgname && strcmp(depname, pkgname) != 0 && !alpm_list_find_str(provisions, depname)) {
- printf("\"%s\" -> \"%s\" [arrowhead=none, color=grey];\n", depname, pkgname);
- provisions = alpm_list_add(provisions, (char *)depname);
- }
- } else if(pkgname) {
- printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, pkgname);
- }
-}
-
-/* parent depends on dep which is satisfied by pkg */
-static void print(const char *parentname, const char *pkgname,
- const char *depname, tdepth *depth, int last)
-{
- if(graphviz) {
- print_graph(parentname, pkgname, depname);
- } else {
- print_text(pkgname, depname, depth, last);
- }
-}
-
-static void print_start(const char *pkgname, const char *provname)
-{
- if(graphviz) {
- printf("digraph G { START [color=red, style=filled];\n"
- "node [style=filled, color=green];\n"
- " \"START\" -> \"%s\";\n", pkgname);
- } else {
- tdepth d = {
- NULL,
- NULL,
- 0
- };
- print_text(pkgname, provname, &d, 0);
- }
-}
-
-static void print_end(void)
-{
- if(graphviz) {
- /* close graph output */
- printf("}\n");
- }
-}
-
-static alpm_list_t *get_pkg_dep_names(alpm_pkg_t *pkg)
-{
- alpm_list_t *i, *names = NULL;
- for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
- alpm_depend_t *d = i->data;
- names = alpm_list_add(names, d->name);
- }
- return names;
-}
-
-/**
- * walk dependencies, showing dependencies of the target
- */
-static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, tdepth *depth, int rev)
-{
- alpm_list_t *deps, *i;
-
- if(!pkg || ((max_depth >= 0) && (depth->level > max_depth))) {
- return;
- }
-
- walked = alpm_list_add(walked, (void *)alpm_pkg_get_name(pkg));
-
- if(rev) {
- deps = alpm_pkg_compute_requiredby(pkg);
- } else {
- deps = get_pkg_dep_names(pkg);
- }
-
- for(i = deps; i; i = alpm_list_next(i)) {
- const char *pkgname = i->data;
- int last = alpm_list_next(i) ? 0 : 1;
-
- alpm_pkg_t *dep_pkg = alpm_find_dbs_satisfier(handle, dblist, pkgname);
-
- if(alpm_list_find_str(walked, dep_pkg ? alpm_pkg_get_name(dep_pkg) : pkgname)) {
- /* if we've already seen this package, don't print in "unique" output
- * and don't recurse */
- if(!unique) {
- print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth, last);
- }
- } else {
- print(alpm_pkg_get_name(pkg), alpm_pkg_get_name(dep_pkg), pkgname, depth, last);
- if(dep_pkg) {
- tdepth d = {
- depth,
- NULL,
- depth->level + 1
- };
- depth->next = &d;
- /* last dep, cut off the limb here */
- if(last) {
- if(depth->prev) {
- depth->prev->next = &d;
- d.prev = depth->prev;
- depth = &d;
- } else {
- d.prev = NULL;
- }
- }
- walk_deps(dblist, dep_pkg, &d, rev);
- depth->next = NULL;
- }
- }
- }
-
- if(rev) {
- FREELIST(deps);
- } else {
- alpm_list_free(deps);
- }
-}
-
-int main(int argc, char *argv[])
-{
- int freelist = 0, ret = 0;
- alpm_errno_t err;
- const char *target_name;
- alpm_pkg_t *pkg;
- alpm_list_t *dblist = NULL;
-
- if(parse_options(argc, argv) != 0) {
- usage();
- ret = 1;
- goto finish;
- }
-
- handle = alpm_initialize(ROOTDIR, dbpath, &err);
- if(!handle) {
- fprintf(stderr, "error: cannot initialize alpm: %s\n",
- alpm_strerror(err));
- ret = 1;
- goto finish;
- }
-
- if(searchsyncs) {
- if(register_syncs() != 0) {
- ret = 1;
- goto finish;
- }
- dblist = alpm_get_syncdbs(handle);
- } else {
- dblist = alpm_list_add(dblist, alpm_get_localdb(handle));
- freelist = 1;
- }
-
- /* we only care about the first non option arg for walking */
- target_name = argv[optind];
-
- pkg = alpm_find_dbs_satisfier(handle, dblist, target_name);
- if(!pkg) {
- fprintf(stderr, "error: package '%s' not found\n", target_name);
- ret = 1;
- goto finish;
- }
-
- print_start(alpm_pkg_get_name(pkg), target_name);
-
- tdepth d = {
- NULL,
- NULL,
- 1
- };
- walk_deps(dblist, pkg, &d, reverse);
-
- print_end();
-
- if(freelist) {
- alpm_list_free(dblist);
- }
-
-finish:
- cleanup();
- return ret;
-}
-
-/* vim: set noet: */
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 89e8dbd4..6bbded06 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2017 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
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
alpm_handle_t *handle;
alpm_errno_t err;
alpm_pkg_t *pkg = NULL;
- const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
+ const int siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
if(argc != 2) {
fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n"
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
/* set gpgdir to default */
alpm_option_set_gpgdir(handle, GPGDIR);
- if(alpm_pkg_load(handle, argv[1], 1, level, &pkg) == -1
+ if(alpm_pkg_load(handle, argv[1], 1, siglevel, &pkg) == -1
|| pkg == NULL) {
err = alpm_errno(handle);
switch(err) {
diff --git a/src/util/vercmp.c b/src/util/vercmp.c
index adeebc0f..3521a96a 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2017 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/pactest.py b/test/pacman/pactest.py
index 4d7c61e3..b5f6d4d7 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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
@@ -23,6 +23,8 @@ import os
import shutil
import sys
import tempfile
+import glob
+import subprocess
import pmenv
import tap
@@ -31,6 +33,30 @@ import util
__author__ = "Aurelien FORET"
__version__ = "0.4"
+# writer to send output to multiple destinations simultaneously
+class MultiWriter():
+ def __init__(self, *outputs):
+ self.outputs = outputs
+
+ def write(self, message):
+ for op in self.outputs:
+ op.write(message)
+
+# duplicate stdout/stderr to a temporary file
+class OutputSaver():
+ def __init__(self):
+ self.save_file = tempfile.NamedTemporaryFile(prefix='pactest-output-')
+
+ def __enter__(self):
+ sys.stdout = MultiWriter(sys.stdout, self.save_file)
+ sys.stderr = MultiWriter(sys.stderr, self.save_file)
+ return self.save_file
+
+ def __exit__(self, type, value, traceback):
+ sys.stdout = sys.__stdout__
+ sys.stderr = sys.__stderr__
+ self.save_file.flush()
+
def create_parser():
usage = "usage: %prog [options] <path/to/testfile.py>..."
description = "Runs automated tests on the pacman binary. Tests are " \
@@ -71,6 +97,12 @@ def create_parser():
parser.add_option("--ldconfig", type = "string",
dest = "ldconfig", default = "/sbin/ldconfig",
help = "specify path to ldconfig")
+ parser.add_option("--review", action = "store_true",
+ dest = "review", default = False,
+ help = "review test files, test output, and saved logs")
+ parser.add_option("--editor", action = "store",
+ dest = "editor", default = os.getenv('EDITOR', 'vim'),
+ help = "editor to use for viewing files")
return parser
@@ -114,7 +146,14 @@ if __name__ == "__main__":
sys.exit(2)
# run tests
- env.run()
+ if not opts.review:
+ env.run()
+ else:
+ # save output in tempfile for review
+ with OutputSaver() as save_file:
+ env.run()
+ files = [save_file.name] + args + glob.glob(root_path + "/var/log/*")
+ subprocess.call([opts.editor] + files)
if not opts.keeproot:
shutil.rmtree(root_path)
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index 1f20506d..5ada9270 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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 14dea943..1b624124 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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 d7500f17..9e1f4d3a 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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 8a88a356..a8bac307 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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 61eded04..3c912c0d 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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/pmtest.py b/test/pacman/pmtest.py
index 9072b4d6..c5e629db 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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 d4886ce0..fd3239b2 100644
--- a/test/pacman/tap.py
+++ b/test/pacman/tap.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 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/TESTS b/test/pacman/tests/TESTS
index 2d877962..309eb17e 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -11,6 +11,7 @@ TESTS += test/pacman/tests/database002.py
TESTS += test/pacman/tests/database010.py
TESTS += test/pacman/tests/database011.py
TESTS += test/pacman/tests/database012.py
+TESTS += test/pacman/tests/dbonly-extracted-files.py
TESTS += test/pacman/tests/depconflict100.py
TESTS += test/pacman/tests/depconflict110.py
TESTS += test/pacman/tests/depconflict111.py
@@ -27,6 +28,7 @@ TESTS += test/pacman/tests/epoch005.py
TESTS += test/pacman/tests/epoch010.py
TESTS += test/pacman/tests/epoch011.py
TESTS += test/pacman/tests/epoch012.py
+TESTS += test/pacman/tests/file-conflict-with-installed-pkg.py
TESTS += test/pacman/tests/fileconflict001.py
TESTS += test/pacman/tests/fileconflict002.py
TESTS += test/pacman/tests/fileconflict003.py
@@ -79,6 +81,9 @@ TESTS += test/pacman/tests/mode001.py
TESTS += test/pacman/tests/mode002.py
TESTS += test/pacman/tests/mode003.py
TESTS += test/pacman/tests/noupgrade-inverted.py
+TESTS += test/pacman/tests/overwrite-files-match-negated.py
+TESTS += test/pacman/tests/overwrite-files-match.py
+TESTS += test/pacman/tests/overwrite-files-nonmatch.py
TESTS += test/pacman/tests/pacman001.py
TESTS += test/pacman/tests/pacman002.py
TESTS += test/pacman/tests/pacman003.py
@@ -109,6 +114,7 @@ TESTS += test/pacman/tests/querycheck002.py
TESTS += test/pacman/tests/querycheck_fast_file_type.py
TESTS += test/pacman/tests/reason001.py
TESTS += test/pacman/tests/remove-assumeinstalled.py
+TESTS += test/pacman/tests/remove-directory-replaced-with-symlink.py
TESTS += test/pacman/tests/remove-optdepend-of-installed-package.py
TESTS += test/pacman/tests/remove-recursive-cycle.py
TESTS += test/pacman/tests/remove001.py
@@ -149,6 +155,7 @@ TESTS += test/pacman/tests/smoke001.py
TESTS += test/pacman/tests/smoke002.py
TESTS += test/pacman/tests/smoke003.py
TESTS += test/pacman/tests/smoke004.py
+TESTS += test/pacman/tests/symlink-replace-with-dir.py
TESTS += test/pacman/tests/symlink001.py
TESTS += test/pacman/tests/symlink002.py
TESTS += test/pacman/tests/symlink010.py
diff --git a/test/pacman/tests/dbonly-extracted-files.py b/test/pacman/tests/dbonly-extracted-files.py
new file mode 100644
index 00000000..a1bc48df
--- /dev/null
+++ b/test/pacman/tests/dbonly-extracted-files.py
@@ -0,0 +1,16 @@
+import util
+import os.path
+
+self.description = "Install a package with dbonly"
+
+sp = pmpkg("foobar", "1-1")
+sp.files = ["bin/foobar"]
+sp.install['post_install'] = "echo foobar"
+self.addpkg2db("sync", sp)
+
+self.args = "-S --dbonly %s" % sp.name
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foobar")
+self.addrule("FILE_EXIST=%s" % os.path.join(util.PM_DBPATH, "local/foobar-1-1/install"))
+self.addrule("!FILE_EXIST=bin/foobar")
diff --git a/test/pacman/tests/file-conflict-with-installed-pkg.py b/test/pacman/tests/file-conflict-with-installed-pkg.py
new file mode 100644
index 00000000..cf88e8a9
--- /dev/null
+++ b/test/pacman/tests/file-conflict-with-installed-pkg.py
@@ -0,0 +1,17 @@
+self.description = "File conflict with an installed package"
+
+lp = pmpkg("foobar")
+lp.files = ["conflicting-file"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1")
+p1.files = ["conflicting-file"]
+self.addpkg(p1)
+
+self.args = "-U %s" % (p1.filename())
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foobar")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("FILE_EXIST=conflicting-file")
+self.addrule("PACMAN_OUTPUT=foobar")
diff --git a/test/pacman/tests/overwrite-files-match-negated.py b/test/pacman/tests/overwrite-files-match-negated.py
new file mode 100644
index 00000000..42b1be2d
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-match-negated.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file matching a negated --overwrite pattern"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foobar --overwrite=!foo* %s" % p.filename()
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("!FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/overwrite-files-match.py b/test/pacman/tests/overwrite-files-match.py
new file mode 100644
index 00000000..004155c3
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-match.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file matching an --overwrite pattern"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foobar %s" % p.filename()
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=dummy")
+self.addrule("FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/overwrite-files-nonmatch.py b/test/pacman/tests/overwrite-files-nonmatch.py
new file mode 100644
index 00000000..38932d5f
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-nonmatch.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file not matching --overwrite patterns"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foo %s" % p.filename()
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("!FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/remove-directory-replaced-with-symlink.py b/test/pacman/tests/remove-directory-replaced-with-symlink.py
new file mode 100644
index 00000000..37be7579
--- /dev/null
+++ b/test/pacman/tests/remove-directory-replaced-with-symlink.py
@@ -0,0 +1,16 @@
+self.description = "remove a package with a directory that has been replaced with a symlink"
+
+self.filesystem = [ "var/", "srv -> var/" ]
+
+lpkg = pmpkg("pkg1")
+lpkg.files = ["srv/"]
+self.addpkg2db("local", lpkg)
+
+self.args = "-R %s" % (lpkg.name)
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("DIR_EXIST=var/")
+self.addrule("!LINK_EXIST=srv")
+self.addrule("!FILE_EXIST=srv")
+self.addrule("!DIR_EXIST=srv")
+self.addrule("!PACMAN_OUTPUT=cannot remove")
diff --git a/test/pacman/tests/symlink-replace-with-dir.py b/test/pacman/tests/symlink-replace-with-dir.py
new file mode 100644
index 00000000..511d751b
--- /dev/null
+++ b/test/pacman/tests/symlink-replace-with-dir.py
@@ -0,0 +1,18 @@
+self.description = "incoming package replaces symlink with directory"
+
+lp = pmpkg("pkg1")
+lp.files = ["usr/lib/foo",
+ "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg2")
+p1.files = ["lib/foo"]
+p1.conflicts = ["pkg1"]
+self.addpkg2db("sync", p1)
+
+self.args = "-S pkg2 --ask=4"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("PKG_EXIST=pkg2")
+self.addrule("FILE_TYPE=lib|dir")
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 208e2f4a..cad4fe13 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-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 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/parseopts_test.sh b/test/scripts/parseopts_test.sh
index a8738a4c..a5821986 100755
--- a/test/scripts/parseopts_test.sh
+++ b/test/scripts/parseopts_test.sh
@@ -3,7 +3,7 @@
source "$(dirname "$0")"/../tap.sh || exit 1
# source the library function
-lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh}
+lib=${1:-${PMTEST_LIBMAKEPKG_DIR}util/parseopts.sh}
if [[ -z $lib || ! -f $lib ]]; then
tap_bail "parseopts library ($lib) could not be located"
exit 1
diff --git a/test/util/Makefile.am b/test/util/Makefile.am
index 0a9f7ead..27ef49f1 100644
--- a/test/util/Makefile.am
+++ b/test/util/Makefile.am
@@ -1,5 +1,4 @@
check_SCRIPTS = \
- pacsorttest.sh \
vercmptest.sh
noinst_SCRIPTS = $(check_SCRIPTS)
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
deleted file mode 100755
index 390a3125..00000000
--- a/test/util/pacsorttest.sh
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/bash
-#
-# pacsorttest - a test suite for pacsort
-#
-# Copyright (c) 2013-2016 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
-# 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/>.
-
-source "$(dirname "$0")"/../tap.sh || exit 1
-
-# default binary if one was not specified as $1
-bin=${1:-${PMTEST_UTIL_DIR}pacsort}
-
-if ! type -p "$bin" &>/dev/null; then
- tap_bail "pacsort binary ($bin) could not be located"
- exit 1
-fi
-
-# args:
-# runtest input expected test_description optional_opts
-tap_runtest() {
- # run the test
- tap_diff <(printf "$1" | $bin $4) <(printf "$2") "$3"
-}
-
-# args:
-# check_return_value input expected_return_value test_description optional_opts
-tap_check_return_value() {
- # run the test
- printf "$1" | $bin $4 2>/dev/null
- tap_is_int "$?" "$2" "$3"
-
-}
-
-tap_plan 32
-
-in="1\n2\n3\n4\n"
-tap_runtest $in $in "already ordered"
-
-in="4\n2\n3\n1\n"
-ex="1\n2\n3\n4\n"
-tap_runtest $in $ex "easy reordering"
-
-in="1\n2\n3\n4"
-ex="1\n2\n3\n4\n"
-tap_runtest $in $ex "add trailing newline"
-
-in="1\n2\n4\n3"
-ex="1\n2\n3\n4\n"
-tap_runtest $in $ex "add trailing newline"
-
-in="1.0-1\n1.0\n1.0-2\n1.0\n"
-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"
-tap_runtest $in $in "filename sort" "--files"
-
-in="firefox-18.0-2\nfirefox-18.0.1-1-x86_64.pkg.tar.xz\n"
-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"
-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"
-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"
-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"
-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"
-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"
-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"
-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
-for ((i=1; i<600; i++)); do
- normal="${normal}${i}\n"
- reverse="${reverse}$((600 - ${i}))\n"
- fields="${fields}colA bogus$((600 - ${i})) ${i}\n"
- fields_reverse="${fields_reverse}colA bogus${i} $((600 - ${i}))\n"
- separator="${separator}colA|bogus$((600 - ${i}))|${i}\n"
- separator_reverse="${separator_reverse}colA|bogus${i}|$((600 - ${i}))\n"
-done
-
-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"
-
-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"
-
-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"
-
-tap_check_return_value "" "2" "invalid sort key (no argument)" "-k"
-tap_check_return_value "" "2" "invalid sort key (non-numeric)" "-k asd"
-tap_check_return_value "" "2" "invalid field separator (no argument)" "-t"
-tap_check_return_value "" "2" "invalid field separator (multiple characters)" "-t sda"
-tap_check_return_value "" "2" "invalid field separator (two characters must start with a slash)" "-t ag"
-tap_check_return_value "" "2" "invalid field separator (\g is invalid)" '-t \g'
-
-tap_finish
-
-# vim: set noet:
diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh
index 5542f59d..3f1330d5 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-2016 by Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2009-2017 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
diff --git a/valgrind.supp b/valgrind.supp
index 0691e808..69265dff 100644
--- a/valgrind.supp
+++ b/valgrind.supp
@@ -160,8 +160,10 @@
fakechroot-call-init
Memcheck:Leak
match-leak-kinds: reachable
- fun:malloc
+ fun:?alloc
+ ...
obj:/usr/lib/libfakeroot/fakechroot/libfakechroot.so
+ ...
fun:call_init.part.0
fun:_dl_init
obj:/usr/lib/ld-*.so