summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--doc/PKGBUILD.5.txt6
-rw-r--r--doc/makepkg.8.txt3
-rw-r--r--doc/makepkg.conf.5.txt13
-rw-r--r--etc/Makefile.am7
-rw-r--r--etc/makepkg.conf.in10
-rw-r--r--lib/libalpm/add.c13
-rw-r--r--lib/libalpm/alpm.h19
-rw-r--r--lib/libalpm/conflict.c6
-rw-r--r--lib/libalpm/db.c4
-rw-r--r--lib/libalpm/deps.c12
-rw-r--r--lib/libalpm/dload.c47
-rw-r--r--lib/libalpm/error.c6
-rw-r--r--lib/libalpm/handle.c9
-rw-r--r--lib/libalpm/package.c9
-rw-r--r--lib/libalpm/remove.c6
-rw-r--r--lib/libalpm/sync.c101
-rw-r--r--lib/libalpm/sync.h3
-rw-r--r--lib/libalpm/trans.c22
-rw-r--r--lib/libalpm/trans.h1
-rw-r--r--pactest/Makefile.am3
-rwxr-xr-xpactest/pmenv.py8
-rwxr-xr-xpactest/pmfile.py8
-rw-r--r--pactest/tests/Makefile.am27
-rw-r--r--pactest/tests/sync200.py.in (renamed from pactest/tests/sync200.py)3
-rw-r--r--scripts/Makefile.am15
-rw-r--r--scripts/makepkg.sh.in157
-rw-r--r--scripts/repo-add.sh.in21
-rw-r--r--src/pacman/callback.c19
-rw-r--r--src/pacman/conf.c4
-rw-r--r--src/pacman/conf.h1
-rw-r--r--src/pacman/pacman.c5
-rw-r--r--src/pacman/query.c36
-rw-r--r--src/pacman/remove.c6
-rw-r--r--src/pacman/sync.c69
-rw-r--r--src/pacman/util.c48
-rw-r--r--src/pacman/util.h4
-rw-r--r--src/util/testdb.c175
38 files changed, 511 insertions, 396 deletions
diff --git a/configure.ac b/configure.ac
index c3b3722c..c7841b80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -326,6 +326,7 @@ doc/Makefile
etc/Makefile
po/Makefile.in
pactest/Makefile
+pactest/tests/Makefile
contrib/Makefile
Makefile
])
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index 9db10576..081c35b3 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -185,8 +185,8 @@ name. The syntax is: `source=('filename::url')`
disable this option.
*docs*;;
- Save doc and info directories. If you wish to delete doc and
- info directories, specify `!docs` in the array.
+ Save doc directories. If you wish to delete doc directories,
+ specify `!docs` in the array.
*libtool*;;
Leave libtool (.la) files in packages. Specify `!libtool` to
@@ -196,7 +196,7 @@ name. The syntax is: `source=('filename::url')`
Leave empty directories in packages.
*zipman*;;
- Compress man pages with gzip.
+ Compress man and info pages with gzip.
*ccache*;;
Allow the use of ccache during build. More useful in its negative
diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index b6d9373a..ddf73dae 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -52,6 +52,9 @@ Options
Removes all cached source files from the directory specified in `SRCDEST`
in linkman:makepkg.conf[5].
+*--config* <`/path/to/config`>::
+ Use an alternate config file instead of the `/etc/makepkg.conf` default;
+
*-d, \--nodeps*::
Do not perform any dependency checks. This will let you override and
ignore any dependencies required. There is a good chance this option
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index b5398af7..ca9df025 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -98,7 +98,7 @@ Options
running in the DistCC cluster. In addition, you will want to modify your
`MAKEFLAGS`.
-**OPTIONS=(**strip docs libtool emptydirs zipman**)**::
+**OPTIONS=(**strip !docs libtool emptydirs zipman**)**::
This array contains options that affect the default packaging. They are
equivalent to options that can be placed in the PKGBUILD; the defaults are
shown here. All options should always be left in the array; to enable or
@@ -111,8 +111,9 @@ Options
option.
*docs*;;
- Save doc and info directories. If you wish to delete doc and info
- directories, specify `!docs' in the array.
+ Save doc directories. If you wish to delete doc directories, specify
+ `!docs' in the array. The directories affected are specified by the
+ `DOC_DIRS` variable.
*libtool*;;
Leave libtool (.la) files in packages. Specify `!libtool' to remove
@@ -122,14 +123,14 @@ Options
Leave empty directories in packages.
*zipman*;;
- Compress man pages with gzip.
+ Compress man and info pages with gzip.
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
`md5`, `sha1`, `sha256`, `sha384`, and `sha512`.
-**DOC_DIRS=(**usr/{,share/}{info,doc} ...**)**::
+**DOC_DIRS=(**usr/{,share/}{doc,gtk-doc} ...**)**::
If "!docs" is specified in the OPTIONS array, this variable will
instruct makepkg where to look to remove docs. If you build packages
that are located in opt/, you may need to add the directory to this
@@ -157,7 +158,7 @@ Options
This value is used when querying a package to see who was the builder.
It is recommended you change this to your name and email address.
-*BUILDSCRIPT*, *PKGEXT*, *SRCEXT*, *DB_COMPRESSION*, *DB_CHECKSUMS*::
+*BUILDSCRIPT*, *PKGEXT*, *SRCEXT*::
Do not touch these unless you know what you are doing.
diff --git a/etc/Makefile.am b/etc/Makefile.am
index b4f4972e..55c28c3b 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -20,9 +20,10 @@ edit = sed \
-e 's|@ROOTDIR[@]|$(ROOTDIR)|g'
$(dist_sysconf_DATA): Makefile
- rm -f $@ $@.tmp
- $(edit) `test -f ./$@.in || echo $(srcdir)/`$@.in >$@.tmp
- mv $@.tmp $@
+ @echo ' ' GEN $@;
+ @rm -f $@ $@.tmp
+ @$(edit) `test -f ./$@.in || echo $(srcdir)/`$@.in >$@.tmp
+ @mv $@.tmp $@
makepkg.conf: $(srcdir)/makepkg.conf.in
pacman.conf: $(srcdir)/pacman.conf.in
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 0241a8ec..7eb647b2 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -58,7 +58,7 @@ BUILDENV=(fakeroot !distcc color !ccache !xdelta)
# These are default values for the options=() settings
#########################################################################
#
-# Default: OPTIONS=(strip docs libtool emptydirs zipman)
+# Default: OPTIONS=(strip !docs libtool emptydirs zipman)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -67,12 +67,12 @@ BUILDENV=(fakeroot !distcc color !ccache !xdelta)
#-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manpages with gzip
#
-OPTIONS=(strip docs libtool emptydirs zipman)
+OPTIONS=(strip !docs libtool emptydirs zipman)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
-#-- Info and doc directories to remove (if option set correctly above)
-DOC_DIRS=(usr/{,share/}{info,doc,gtk-doc} opt/*/{info,doc,gtk-doc})
+#-- Doc directories to remove (if option set correctly above)
+DOC_DIRS=(usr/{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Directories to be searched for the strip option (if option set correctly above)
STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin})
@@ -99,7 +99,5 @@ STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,
BUILDSCRIPT='PKGBUILD'
PKGEXT='@PKGEXT@'
SRCEXT='@SRCEXT@'
-DB_COMPRESSION='gz'
-DB_CHECKSUMS=(md5)
# vim: set ft=sh ts=2 sw=2 et:
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index eef7aab1..50405895 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -114,7 +114,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
/* look for unsatisfied dependencies */
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, NULL, trans->packages);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, NULL, trans->packages);
if(lp != NULL) {
if(data) {
*data = lp;
@@ -650,17 +650,18 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
if(local) {
is_upgrade = 1;
- EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, NULL);
- _alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
- newpkg->name, newpkg->version);
-
/* we'll need to save some record for backup checks later */
oldpkg = _alpm_pkg_dup(local);
/* make sure all infos are loaded because the database entry
* will be removed soon */
_alpm_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
+
+ EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
+ _alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
+ newpkg->name, newpkg->version);
+
/* copy over the install reason */
- newpkg->reason = alpm_pkg_get_reason(local);
+ newpkg->reason = alpm_pkg_get_reason(oldpkg);
/* pre_upgrade scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 16b48a0a..eda35d30 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -170,10 +170,10 @@ int alpm_db_setserver(pmdb_t *db, const char *url);
int alpm_db_update(int level, pmdb_t *db);
pmpkg_t *alpm_db_get_pkg(pmdb_t *db, const char *name);
-alpm_list_t *alpm_db_getpkgcache(pmdb_t *db);
+alpm_list_t *alpm_db_get_pkgcache(pmdb_t *db);
pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
-alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
+alpm_list_t *alpm_db_get_grpcache(pmdb_t *db);
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
/*
@@ -218,6 +218,7 @@ alpm_list_t *alpm_pkg_get_deltas(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
+pmdb_t *alpm_pkg_get_db(pmpkg_t *pkg);
void *alpm_pkg_changelog_open(pmpkg_t *pkg);
size_t alpm_pkg_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp);
@@ -253,8 +254,6 @@ alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp);
pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync);
alpm_list_t *alpm_sync_get_removes(const pmsyncpkg_t *sync);
pmpkg_t *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync);
-int alpm_sync_sysupgrade(pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
/*
* Transactions
@@ -282,7 +281,7 @@ typedef enum _pmtransflag_t {
PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
PM_TRANS_FLAG_NOCONFLICTS = 0x800,
- PM_TRANS_FLAG_PRINTURIS = 0x1000,
+ /* 0x1000 flag can go here */
PM_TRANS_FLAG_NEEDED = 0x2000,
PM_TRANS_FLAG_ALLEXPLICIT = 0x4000,
PM_TRANS_FLAG_UNNEEDED = 0x8000,
@@ -364,10 +363,6 @@ typedef enum _pmtransevt_t {
* A line of text is passed to the callback.
*/
PM_TRANS_EVT_SCRIPTLET_INFO,
- /** Print URI.
- * The database's URI and the package's filename are passed to the callback.
- */
- PM_TRANS_EVT_PRINTURI,
/** Files will be downloaded from a repository.
* The repository's tree name is passed to the callback.
*/
@@ -431,7 +426,7 @@ typedef enum _pmdepmod_t {
} pmdepmod_t;
int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
-alpm_list_t *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade);
alpm_list_t *alpm_deptest(pmdb_t *db, alpm_list_t *targets);
@@ -439,7 +434,7 @@ const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-alpm_list_t *alpm_checkdbconflicts(pmdb_t *db_local);
+alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist);
const char *alpm_conflict_get_package1(pmconflict_t *conflict);
const char *alpm_conflict_get_package2(pmconflict_t *conflict);
@@ -531,7 +526,7 @@ enum _pmerrno_t {
PM_ERR_INVALID_REGEX,
/* External library errors */
PM_ERR_LIBARCHIVE,
- PM_ERR_LIBDOWNLOAD,
+ PM_ERR_LIBFETCH,
PM_ERR_EXTERNAL_DOWNLOAD
};
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index a044fc60..499e55a4 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -218,11 +218,11 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
/** Check the package conflicts in a database
*
- * @param db_local the database to check
+ * @param pkglist the list of packages to check
* @return an alpm_list_t of pmconflict_t
*/
-alpm_list_t SYMEXPORT *alpm_checkdbconflicts(pmdb_t *db_local) {
- return(_alpm_innerconflicts(_alpm_db_get_pkgcache(db_local)));
+alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) {
+ return(_alpm_innerconflicts(pkglist));
}
/* Returns a alpm_list_t* of file conflicts.
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 5632ffac..9b91ce47 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -263,7 +263,7 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
* @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error
*/
-alpm_list_t SYMEXPORT *alpm_db_getpkgcache(pmdb_t *db)
+alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
{
ALPM_LOG_FUNC;
@@ -295,7 +295,7 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name)
* @param db pointer to the package database to get the group from
* @return the list of groups on success, NULL on error
*/
-alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db)
+alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db)
{
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c667daa2..96c971a2 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -229,13 +229,13 @@ alpm_list_t SYMEXPORT *alpm_deptest(pmdb_t *db, alpm_list_t *targets)
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
- * @param db pointer to the local package database
+ * @param pkglist the list of local packages
* @param reversedeps handles the backward dependencies
* @param remove an alpm_list_t* of packages to be removed
* @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade)
* @return an alpm_list_t* of pmpkg_t* of missing_t pointers.
*/
-alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade)
{
alpm_list_t *i, *j;
@@ -245,12 +245,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
ALPM_LOG_FUNC;
- if(db == NULL) {
- return(NULL);
- }
-
targets = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade));
- for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
+ for(i = pkglist; i; i = i->next) {
void *pkg = i->data;
if(alpm_list_find(targets, pkg, _alpm_pkg_cmp)) {
modified = alpm_list_add(modified, pkg);
@@ -572,7 +568,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, alpm_list_t *list,
for(i = list; i; i = i->next) {
pmpkg_t *tpkg = i->data;
targ = alpm_list_add(NULL, tpkg);
- deps = alpm_checkdeps(local, 0, remove, targ);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(local), 0, remove, targ);
alpm_list_free(targ);
for(j = deps; j; j = j->next) {
pmdepmissing_t *miss = j->data;
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index c07040b5..f197d060 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <signal.h>
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
@@ -35,14 +36,14 @@
#if defined(HAVE_LIBDOWNLOAD)
#include <download.h>
+#define fetchFreeURL downloadFreeURL
+#define fetchLastErrCode downloadLastErrCode
+#define fetchLastErrString downloadLastErrString
+#define fetchParseURL downloadParseURL
+#define fetchTimeout downloadTimeout
+#define fetchXGet downloadXGet
#elif defined(HAVE_LIBFETCH)
#include <fetch.h>
-#define downloadFreeURL fetchFreeURL
-#define downloadLastErrCode fetchLastErrCode
-#define downloadLastErrString fetchLastErrString
-#define downloadParseURL fetchParseURL
-#define downloadTimeout fetchTimeout
-#define downloadXGet fetchXGet
#endif
/* libalpm */
@@ -86,7 +87,7 @@ static char *get_tempfile(const char *path, const char *filename) {
static struct url *url_for_string(const char *url)
{
struct url *ret = NULL;
- ret = downloadParseURL(url);
+ ret = fetchParseURL(url);
if(!ret) {
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
@@ -115,6 +116,7 @@ static int download_internal(const char *url, const char *localpath,
size_t dl_thisfile = 0;
char *tempfile, *destfile, *filename;
int ret = 0;
+ struct sigaction new_action, old_action;
struct url *fileurl = url_for_string(url);
if(!fileurl) {
@@ -142,23 +144,29 @@ static int download_internal(const char *url, const char *localpath,
dl_thisfile = 0;
}
- /* libdownload does not reset the error code, reset it in
- * the case of previous errors */
- downloadLastErrCode = 0;
+ /* libfetch does not reset the error code */
+ fetchLastErrCode = 0;
/* 10s timeout - TODO make a config option */
- downloadTimeout = 10000;
+ fetchTimeout = 10000;
- dlf = downloadXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
+ /* ignore any SIGPIPE signals- these may occur if our FTP socket dies or
+ * something along those lines. Store the old signal handler first. */
+ new_action.sa_handler = SIG_IGN;
+ sigemptyset(&new_action.sa_mask);
+ sigaction(SIGPIPE, NULL, &old_action);
+ sigaction(SIGPIPE, &new_action, NULL);
- if(downloadLastErrCode != 0 || dlf == NULL) {
+ dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
+
+ if(fetchLastErrCode != 0 || dlf == NULL) {
const char *host = _("disk");
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
host = fileurl->host;
}
- pm_errno = PM_ERR_LIBDOWNLOAD;
+ pm_errno = PM_ERR_LIBFETCH;
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
- filename, host, downloadLastErrString);
+ filename, host, fetchLastErrString);
ret = -1;
goto cleanup;
} else {
@@ -204,9 +212,9 @@ static int download_internal(const char *url, const char *localpath,
char buffer[PM_DLBUF_LEN];
while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
if(ferror(dlf)) {
- pm_errno = PM_ERR_LIBDOWNLOAD;
+ pm_errno = PM_ERR_LIBFETCH;
_alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"),
- filename, downloadLastErrString);
+ filename, fetchLastErrString);
ret = -1;
goto cleanup;
}
@@ -239,6 +247,9 @@ static int download_internal(const char *url, const char *localpath,
ret = 0;
cleanup:
+ /* restore any existing SIGPIPE signal handler */
+ sigaction(SIGPIPE, &old_action, NULL);
+
FREE(tempfile);
FREE(destfile);
if(localf != NULL) {
@@ -247,7 +258,7 @@ cleanup:
if(dlf != NULL) {
fclose(dlf);
}
- downloadFreeURL(fileurl);
+ fetchFreeURL(fileurl);
return(ret);
}
#endif
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 05caf8ec..80a4fb1a 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -32,9 +32,9 @@
#if defined(HAVE_LIBDOWNLOAD)
#include <download.h> /* downloadLastErrString */
+#define fetchLastErrString downloadLastErrString
#elif defined(HAVE_LIBFETCH)
#include <fetch.h> /* fetchLastErrString */
-#define downloadLastErrString fetchLastErrString
#endif
/* libalpm */
@@ -154,9 +154,9 @@ const char SYMEXPORT *alpm_strerror(int err)
* requires the archive struct, so we can't. Just use a generic
* error string instead. */
return _("libarchive error");
- case PM_ERR_LIBDOWNLOAD:
+ case PM_ERR_LIBFETCH:
#if defined(INTERNAL_DOWNLOAD)
- return downloadLastErrString;
+ return fetchLastErrString;
#else
/* obviously shouldn't get here... */
return _("download library error");
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index af1cc78b..7dc01223 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -48,16 +48,7 @@ pmhandle_t *_alpm_handle_new()
ALPM_LOG_FUNC;
CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL));
-
handle->lckfd = -1;
- handle->logstream = NULL;
-
- handle->root = NULL;
- handle->dbpath = NULL;
- handle->cachedirs = NULL;
- handle->lockfile = NULL;
- handle->logfile = NULL;
- handle->usedelta = 0;
return(handle);
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a9f4b43d..ee0ff6f5 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -422,6 +422,15 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
return pkg->backup;
}
+pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
+{
+ /* Sanity checks */
+ ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg->origin == PKG_FROM_CACHE, return(NULL));
+
+ return(pkg->origin_data.db);
+}
+
/**
* Open a package changelog for reading. Similar to fopen in functionality,
* except that the returned 'file stream' could really be from an archive
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 864fafaf..f0734902 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -104,7 +104,7 @@ static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -134,7 +134,7 @@ static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -161,7 +161,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 4a705b57..b458874d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -77,17 +77,12 @@ void _alpm_sync_free(pmsyncpkg_t *sync)
/* Find recommended replacements for packages during a sync.
*/
-static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
+static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
alpm_list_t *i, *j, *k; /* wow */
ALPM_LOG_FUNC;
- if(syncpkgs == NULL) {
- return(-1);
- }
-
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_DEBUG, "checking for package replacements\n");
for(i = dbs_sync; i; i = i->next) {
@@ -113,13 +108,10 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
} else {
- /* get confirmation for the replacement */
- if(trans) {
- int doreplace = 0;
- QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
- if(!doreplace) {
- continue;
- }
+ int doreplace = 0;
+ QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
+ if(!doreplace) {
+ continue;
}
/* if confirmed, add this to the 'final' list, designating 'lpkg' as
@@ -129,7 +121,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
/* check if spkg->name is already in the packages list. */
/* TODO: same package name doesn't mean same package */
- sync = _alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg));
+ sync = _alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg));
if(sync) {
/* found it -- just append to the removes list */
sync->removes = alpm_list_add(sync->removes, lpkg);
@@ -143,15 +135,12 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
sync = _alpm_sync_new(alpm_pkg_get_reason(lpkg), spkg, NULL);
if(sync == NULL) {
pm_errno = PM_ERR_MEMORY;
- alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free);
- alpm_list_free(*syncpkgs);
- *syncpkgs = NULL;
return(-1);
}
sync->removes = alpm_list_add(NULL, lpkg);
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
- *syncpkgs = alpm_list_add(*syncpkgs, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
_alpm_log(PM_LOG_DEBUG, "%s-%s elected for removal (to be replaced by %s-%s)\n",
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
@@ -199,33 +188,19 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
return(NULL);
}
-/** Get a list of upgradable packages on the current system
- * Adds out of date packages to *list.
- * @arg list pointer to a list of pmsyncpkg_t.
- */
-int SYMEXPORT alpm_sync_sysupgrade(pmdb_t *db_local,
- alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
-{
- return(_alpm_sync_sysupgrade(NULL, db_local, dbs_sync, syncpkgs));
-}
-
-int _alpm_sync_sysupgrade(pmtrans_t *trans,
- pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
alpm_list_t *i, *j, *replaced = NULL;
ALPM_LOG_FUNC;
- if(syncpkgs == NULL) {
- return(-1);
- }
/* check for "recommended" package replacements */
- if(find_replacements(trans, db_local, dbs_sync, syncpkgs)) {
+ if(find_replacements(trans, db_local, dbs_sync)) {
return(-1);
}
/* compute the to-be-replaced packages for efficiency */
- for(i = *syncpkgs; i; i = i->next) {
+ for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
for(j = sync->removes; j; j = j->next) {
replaced = alpm_list_add(replaced, j->data);
@@ -255,22 +230,19 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans,
}
/* add the upgrade package to our pmsyncpkg_t list */
- if(_alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg))) {
+ if(_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) {
/* avoid duplicated targets */
continue;
}
/* we can set any reason here, it will be overridden by add_commit */
pmsyncpkg_t *sync = _alpm_sync_new(PM_PKG_REASON_EXPLICIT, spkg, NULL);
if(sync == NULL) {
- alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free);
- alpm_list_free(*syncpkgs);
- *syncpkgs = NULL;
alpm_list_free(replaced);
return(-1);
}
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
- *syncpkgs = alpm_list_add(*syncpkgs, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
}
@@ -497,8 +469,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
}
- /* We don't care about conflicts if we're just printing uris */
- if(!(trans->flags & (PM_TRANS_FLAG_NOCONFLICTS | PM_TRANS_FLAG_PRINTURIS))) {
+ if(!(trans->flags & PM_TRANS_FLAG_NOCONFLICTS)) {
/* check for inter-conflicts and whatnot */
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
@@ -631,7 +602,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
- deps = alpm_checkdeps(db_local, 1, remove, list);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, remove, list);
if(deps) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
ret = -1;
@@ -838,32 +809,27 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
fname = alpm_pkg_get_filename(spkg);
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
- if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
- EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current),
- (char *)fname);
- } else {
- if(spkg->download_size != 0) {
- alpm_list_t *delta_path = spkg->delta_path;
- if(delta_path) {
- alpm_list_t *dlts = NULL;
-
- for(dlts = delta_path; dlts; dlts = dlts->next) {
- pmdelta_t *d = dlts->data;
-
- if(d->download_size != 0) {
- /* add the delta filename to the download list if
- * it's not in the cache */
- files = alpm_list_add(files, strdup(d->delta));
- }
-
- /* keep a list of the delta files for md5sums */
- deltas = alpm_list_add(deltas, d);
+ if(spkg->download_size != 0) {
+ alpm_list_t *delta_path = spkg->delta_path;
+ if(delta_path) {
+ alpm_list_t *dlts = NULL;
+
+ for(dlts = delta_path; dlts; dlts = dlts->next) {
+ pmdelta_t *d = dlts->data;
+
+ if(d->download_size != 0) {
+ /* add the delta filename to the download list if
+ * it's not in the cache */
+ files = alpm_list_add(files, strdup(d->delta));
}
- } else {
- /* not using deltas, so add the file to the download list */
- files = alpm_list_add(files, strdup(fname));
+ /* keep a list of the delta files for md5sums */
+ deltas = alpm_list_add(deltas, d);
}
+
+ } else {
+ /* not using deltas, so add the file to the download list */
+ files = alpm_list_add(files, strdup(fname));
}
}
}
@@ -880,9 +846,6 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
FREELIST(files);
}
}
- if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
- return(0);
- }
/* clear out value to let callback know we are done */
if(handle->totaldlcb) {
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index b71f0ef2..b6a4bbff 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -33,8 +33,7 @@ struct __pmsyncpkg_t {
pmsyncpkg_t *_alpm_sync_new(pmpkgreason_t newreason, pmpkg_t *spkg, alpm_list_t *removes);
void _alpm_sync_free(pmsyncpkg_t *data);
-int _alpm_sync_sysupgrade(pmtrans_t *trans,
- pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync);
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name);
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index acad84e8..4b831193 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -100,7 +100,7 @@ int SYMEXPORT alpm_trans_sysupgrade()
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
ASSERT(trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
- return(_alpm_trans_sysupgrade(trans));
+ return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync));
}
/** Add a target to the transaction.
@@ -226,15 +226,6 @@ pmtrans_t *_alpm_trans_new()
ALPM_LOG_FUNC;
CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL));
-
- trans->packages = NULL;
- trans->skip_add = NULL;
- trans->skip_remove = NULL;
- trans->type = 0;
- trans->flags = 0;
- trans->cb_event = NULL;
- trans->cb_conv = NULL;
- trans->cb_progress = NULL;
trans->state = STATE_IDLE;
return(trans);
@@ -280,17 +271,6 @@ int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags,
return(0);
}
-int _alpm_trans_sysupgrade(pmtrans_t *trans)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
-
- return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync,
- &(trans->packages)));
-}
-
/** Add a target to the transaction.
* @param trans the current transaction
* @param target the name of the target to add
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index d74c3e90..48996573 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -71,7 +71,6 @@ void _alpm_trans_free(pmtrans_t *trans);
int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags,
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress progress);
-int _alpm_trans_sysupgrade(pmtrans_t *trans);
int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
diff --git a/pactest/Makefile.am b/pactest/Makefile.am
index ce611f78..64f9a22e 100644
--- a/pactest/Makefile.am
+++ b/pactest/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = tests
+
check_SCRIPTS = \
pactest.py \
pmdb.py \
@@ -7,7 +9,6 @@ check_SCRIPTS = \
pmrule.py \
pmtest.py \
util.py \
- $(wildcard tests/*.py) \
vercmptest.sh
noinst_SCRIPTS = $(check_SCRIPTS)
diff --git a/pactest/pmenv.py b/pactest/pmenv.py
index e9d0b4c9..cc433dd0 100755
--- a/pactest/pmenv.py
+++ b/pactest/pmenv.py
@@ -71,9 +71,11 @@ class pmenv:
t.generate()
# Hack for mtimes consistency
for i in t.rules:
- if i.rule.find("MODIFIED") != -1:
- time.sleep(1.5)
- break
+ if i.rule.find("FILE_MODIFIED") != -1:
+ [test, arg] = i.rule.split("=")
+ for f in t.files:
+ if f.name == arg:
+ f.resettimes()
t.run(self.pacman)
diff --git a/pactest/pmfile.py b/pactest/pmfile.py
index 21baf017..ab4aa2c7 100755
--- a/pactest/pmfile.py
+++ b/pactest/pmfile.py
@@ -56,6 +56,14 @@ class pmfile:
return retval
+ def resettimes(self):
+ """
+ """
+
+ filename = os.path.join(self.root, self.name)
+ os.utime(filename, (355, 355))
+ self.mtime = getmtime(filename)
+ vprint("\tmtime reset (%s)" % self.name)
if __name__ == "__main__":
f = pmfile("/tmp", "foobar")
diff --git a/pactest/tests/Makefile.am b/pactest/tests/Makefile.am
new file mode 100644
index 00000000..b793687b
--- /dev/null
+++ b/pactest/tests/Makefile.am
@@ -0,0 +1,27 @@
+CONFTESTS = $(patsubst %py.in,%py,$(wildcard *.py.in))
+
+check_SCRIPTS = \
+ $(wildcard *.py) \
+ $(CONFTESTS)
+
+noinst_SCRIPTS = $(check_SCRIPTS)
+
+EXTRA_DIST = $(check_SCRIPTS)
+
+CLEANFILES = $(CONFTESTS)
+
+#### Taken from the autoconf scripts Makefile.am ####
+edit = sed \
+ -e 's|@LIBS[@]|$(LIBS)|g' \
+ -e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g'
+
+
+$(CONFTESTS): Makefile
+ @echo ' ' GEN $@;
+ @rm -f $@ $@.tmp
+ @test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@.tmp || true
+ @test -f $@.tmp || false
+ @chmod a-w $@.tmp
+ @mv $@.tmp $@
+
+# vim:set ts=2 sw=2 noet:
diff --git a/pactest/tests/sync200.py b/pactest/tests/sync200.py.in
index 9005bd3d..3c11f83f 100644
--- a/pactest/tests/sync200.py
+++ b/pactest/tests/sync200.py.in
@@ -1,5 +1,8 @@
self.description = "Synchronize the local database"
+if not "download" in "@LIBS@":
+ self.option['XferCommand'] = ['/usr/bin/curl %u > %o']
+
sp1 = pmpkg("spkg1", "1.0-1")
sp1.depends = ["spkg2"]
sp2 = pmpkg("spkg2", "2.0-1")
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index fd8fab7f..014ae870 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -46,13 +46,14 @@ edit = sed \
# two 'test' lines- make sure we can handle both sh and py type scripts
# third 'test' line- make sure one of the two checks succeeded
$(OURSCRIPTS): Makefile
- rm -f $@ $@.tmp
- test -f $(srcdir)/$@.sh.in && $(edit) $(srcdir)/$@.sh.in >$@.tmp || true
- test -f $(srcdir)/$@.py.in && $(edit) $(srcdir)/$@.py.in >$@.tmp || true
- test -f $@.tmp || false
- chmod +x $@.tmp
- chmod a-w $@.tmp
- mv $@.tmp $@
+ @echo ' ' GEN $@;
+ @rm -f $@ $@.tmp
+ @test -f $(srcdir)/$@.sh.in && $(edit) $(srcdir)/$@.sh.in >$@.tmp || true
+ @test -f $(srcdir)/$@.py.in && $(edit) $(srcdir)/$@.py.in >$@.tmp || true
+ @test -f $@.tmp || false
+ @chmod +x $@.tmp
+ @chmod a-w $@.tmp
+ @mv $@.tmp $@
makepkg: $(srcdir)/makepkg.sh.in
pacman-optimize: $(srcdir)/pacman-optimize.sh.in
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 599f0f9c..6dc7db41 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -278,7 +278,7 @@ get_downloadclient() {
# if we didn't find an agent, return an error
if [ -z "$agent" ]; then
- error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$confdir/makepkg.conf"
+ error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$MAKEPKG_CONF"
plain "$(gettext "Aborting...")"
exit 1 # $E_CONFIG_ERROR
fi
@@ -488,6 +488,11 @@ generate_checksums() {
msg "$(gettext "Generating checksums for source files...")"
plain ""
+ if [ ! $(type -p openssl) ]; then
+ error "$(gettext "Cannot find openssl.")"
+ exit 1 # $E_MISSING_PROGRAM
+ fi
+
local integ
for integ in ${INTEGRITY_CHECK[@]}; do
integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
@@ -498,11 +503,6 @@ generate_checksums() {
exit 1;; # $E_CONFIG_ERROR
esac
- if [ ! $(type -p openssl) ]; then
- error "$(gettext "Cannot find openssl.")"
- exit 1 # $E_MISSING_PROGRAM
- fi
-
local ct=0
local numsrc=${#source[@]}
echo -n "${integ}sums=("
@@ -540,21 +540,13 @@ generate_checksums() {
}
check_checksums() {
- local integ
- for integ in ${INTEGRITY_CHECK[@]}; do
- integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
- case "$integ" in
- md5|sha1|sha256|sha384|sha512) : ;;
- *)
- error "$(gettext "Invalid integrity algorithm '%s' specified")" "$integ"
- exit 1;; # $E_CONFIG_ERROR
- esac
-
- if [ ! $(type -p openssl) ]; then
- error "$(gettext "Cannot find openssl.")"
- exit 1 # $E_MISSING_PROGRAM
- fi
+ if [ ! $(type -p openssl) ]; then
+ error "$(gettext "Cannot find openssl.")"
+ exit 1 # $E_MISSING_PROGRAM
+ fi
+ local integ required
+ for integ in md5 sha1 sha256 sha384 sha512; do
local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
msg "$(gettext "Validating source files with %s...")" "${integ}sums"
@@ -592,7 +584,13 @@ check_checksums() {
exit 1 # TODO: error code
fi
else
- warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
+ for required in ${INTEGRITY_CHECK[@]}; do
+ required="$(echo $required | tr '[:upper:]' '[:lower:]')"
+ if [ "$integ" = "$required" ]; then
+ warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
+ break
+ fi
+ done
fi
done
}
@@ -709,16 +707,16 @@ tidy_install() {
msg "$(gettext "Tidying install...")"
if [ "$(check_option docs)" = "n" ]; then
- msg2 "$(gettext "Removing info/doc files...")"
+ msg2 "$(gettext "Removing doc files...")"
#fix flyspray bug #5021
rm -rf ${DOC_DIRS[@]}
fi
if [ "$(check_option zipman)" = "y" ]; then
- msg2 "$(gettext "Compressing man pages...")"
+ msg2 "$(gettext "Compressing man and info pages...")"
local manpage mandirs ext file link hardlinks hl
- mandirs="usr/man usr/share/man usr/local/man usr/local/share/man opt/*/man"
- find ${mandirs} -type f 2>/dev/null |
+ mandirs=({usr{,/local}{,/share},opt/*}/{man,info})
+ find ${mandirs[@]} -type f 2>/dev/null |
while read manpage ; do
# check file still exists (potentially compressed with hard link)
if [ -f ${manpage} ]; then
@@ -726,7 +724,7 @@ tidy_install() {
file="${manpage##*/}"
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
# update symlinks to this manpage
- find ${mandirs} -lname "$file" 2>/dev/null |
+ find ${mandirs[@]} -lname "$file" 2>/dev/null |
while read link ; do
rm -f "$link"
ln -sf "${file}.gz" "${link}.gz"
@@ -734,7 +732,7 @@ tidy_install() {
# find hard links and remove them
# the '|| true' part keeps the script from bailing if find returned an
# error, such as when one of the man directories doesn't exist
- hardlinks="$(find ${mandirs} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
+ hardlinks="$(find ${mandirs[@]} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
for hl in ${hardlinks}; do
rm -f "${hl}";
done
@@ -873,13 +871,21 @@ create_package() {
# tar it up
msg2 "$(gettext "Compressing package...")"
+ local TAR_OPT
+ case "$PKGEXT" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' is not a valid archive extension.")" \
+ "$PKGEXT" ;;
+ esac
+
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
# when fileglobbing, we want * in an empty directory to expand to
# the null string rather than itself
shopt -s nullglob
- if ! bsdtar -czf "$pkg_file" $comp_files *; then
+ if ! bsdtar -c${TAR_OPT}f "$pkg_file" $comp_files *; then
error "$(gettext "Failed to create package file.")"
exit 1 # TODO: error code
fi
@@ -994,12 +1000,20 @@ create_srcpackage() {
fi
done
+ local TAR_OPT
+ case "$SRCEXT" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' is not a valid archive extension.")" \
+ "$SRCEXT" ;;
+ esac
+
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}"
# tar it up
msg2 "$(gettext "Compressing source package...")"
cd "${srclinks}"
- if ! bsdtar -czLf "$pkg_file" ${pkgname}; then
+ if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgname}; then
error "$(gettext "Failed to create source package file.")"
exit 1 # TODO: error code
fi
@@ -1023,6 +1037,10 @@ devel_check() {
if [ "$HOLDVER" = "1" ]; then
return
fi
+ # Cannot update pkgver/pkgrel if reading PKGBUILD from pipe
+ if [ ! -f "./$BUILDSCRIPT" ]; then
+ return
+ fi
if [ "$FORCE_VER" = "" ]; then
# Check if this is a svn/cvs/etc PKGBUILD; set $newpkgver if so.
# This will only be used on the first call to makepkg; subsequent
@@ -1090,9 +1108,11 @@ devel_update() {
#
if [ "$newpkgver" != "" ]; then
if [ "$newpkgver" != "$pkgver" ]; then
- sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" ./$BUILDSCRIPT
- sed -i "s/^pkgrel=[^ ]*/pkgrel=1/" ./$BUILDSCRIPT
- source $BUILDSCRIPT
+ if [ -f "./$BUILDSCRIPT" ]; then
+ sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" ./$BUILDSCRIPT
+ sed -i "s/^pkgrel=[^ ]*/pkgrel=1/" ./$BUILDSCRIPT
+ source $BUILDSCRIPT
+ fi
fi
fi
}
@@ -1106,6 +1126,7 @@ usage() {
printf "$(gettext " -A, --ignorearch Ignore incomplete arch field in %s")\n" "$BUILDSCRIPT"
echo "$(gettext " -c, --clean Clean up work files after build")"
echo "$(gettext " -C, --cleancache Clean up source files from the cache")"
+ printf "$(gettext " --config <config> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
echo "$(gettext " -d, --nodeps Skip all dependency checks")"
echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")"
echo "$(gettext " -f, --force Overwrite existing package")"
@@ -1153,36 +1174,12 @@ fi
ARGLIST=$@
-#preserve environment variables
-_PKGDEST=${PKGDEST}
-_SRCDEST=${SRCDEST}
-
-# Source makepkg.conf; fail if it is not found
-if [ -r "$confdir/makepkg.conf" ]; then
- source "$confdir/makepkg.conf"
-else
- error "$(gettext "%s not found.")" "$confdir/makepkg.conf"
- plain "$(gettext "Aborting...")"
- exit 1 # $E_CONFIG_ERROR
-fi
-
-# Source user-specific makepkg.conf overrides
-if [ -r ~/.makepkg.conf ]; then
- source ~/.makepkg.conf
-fi
-
-# override settings with an environment variable for batch processing
-PKGDEST=${_PKGDEST:-$PKGDEST}
-PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
-SRCDEST=${_SRCDEST:-$SRCDEST}
-SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
-
# Parse Command Line Options.
OPT_SHORT="AbcCdefFghiLmop:rRsV"
OPT_LONG="allsource,asroot,ignorearch,builddeps,clean,cleancache,nodeps"
OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source"
-OPT_LONG="$OPT_LONG,syncdeps,version"
+OPT_LONG="$OPT_LONG,syncdeps,version,config:"
# Pacman Options
OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename "$0")" -- "$@" || echo 'GETOPT GO BANG!')"
@@ -1205,6 +1202,7 @@ while true; do
-A|--ignorearch) IGNOREARCH=1 ;;
-c|--clean) CLEANUP=1 ;;
-C|--cleancache) CLEANCACHE=1 ;;
+ --config) shift; MAKEPKG_CONF=$1 ;;
-d|--nodeps) NODEPS=1 ;;
-e|--noextract) NOEXTRACT=1 ;;
-f|--force) FORCE=1 ;;
@@ -1232,6 +1230,34 @@ while true; do
shift
done
+#preserve environment variables
+_PKGDEST=${PKGDEST}
+_SRCDEST=${SRCDEST}
+
+# default config is makepkg.conf
+MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
+
+# Source the config file; fail if it is not found
+if [ -r "$MAKEPKG_CONF" ]; then
+ source "$MAKEPKG_CONF"
+else
+ error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
+ plain "$(gettext "Aborting...")"
+ exit 1 # $E_CONFIG_ERROR
+fi
+
+# Source user-specific makepkg.conf overrides
+if [ -r ~/.makepkg.conf ]; then
+ source ~/.makepkg.conf
+fi
+
+# override settings with an environment variable for batch processing
+PKGDEST=${_PKGDEST:-$PKGDEST}
+PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
+SRCDEST=${_SRCDEST:-$SRCDEST}
+SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
+
+
if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
# The '\\0' is here to prevent gettext from thinking --holdver is an option
error "$(gettext "\\0--holdver and --forcever cannot both be specified" )"
@@ -1263,14 +1289,14 @@ if [ "$CLEANCACHE" = "1" ]; then
fi
else
# $SRCDEST is $startdir, two possibilities
- error "$(gettext "Source destination must be defined in makepkg.conf.")"
+ error "$(gettext "Source destination must be defined in %s.")" "$MAKEPKG_CONF"
plain "$(gettext "In addition, please run makepkg -C outside of your cache directory.")"
exit 1
fi
fi
if [ -z $BUILDSCRIPT ]; then
- error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$confdir/makepkg.conf"
+ error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$MAKEPKG_CONF"
exit 1
fi
@@ -1289,13 +1315,13 @@ if [ "$INFAKEROOT" = "0" ]; then
elif [ "$(check_buildenv fakeroot)" = "y" -a $EUID -gt 0 ]; then
if [ ! $(type -p fakeroot) ]; then
error "$(gettext "Fakeroot must be installed if using the 'fakeroot' option")"
- plain "$(gettext "in the BUILDENV array in %s.")" "$confdir/makepkg.conf"
+ plain "$(gettext "in the BUILDENV array in %s.")" "$MAKEPKG_CONF"
exit 1
fi
elif [ $EUID -gt 0 ]; then
warning "$(gettext "Running makepkg as an unprivileged user will result in non-root")"
plain "$(gettext "ownership of the packaged files. Try using the fakeroot environment by")"
- plain "$(gettext "placing 'fakeroot' in the BUILDENV array in makepkg.conf.")"
+ plain "$(gettext "placing 'fakeroot' in the BUILDENV array in %s.")" "$MAKEPKG_CONF"
sleep 1
fi
else
@@ -1321,8 +1347,13 @@ unset replaces depends conflicts backup source install build makedepends
unset optdepends options noextract
if [ ! -f "$BUILDSCRIPT" ]; then
- error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
- exit 1
+ if [ -t 0 ]; then
+ error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
+ exit 1
+ else
+ # PKGBUILD passed through a pipe
+ BUILDSCRIPT=/dev/stdin
+ fi
fi
source "$BUILDSCRIPT"
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index be0859ea..4f9639ca 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -305,18 +305,6 @@ else
exit 1 # $E_MISSING_PROGRAM
fi
-# source system and user makepkg.conf
-if [ -r "$confdir/makepkg.conf" ]; then
- source "$confdir/makepkg.conf"
-else
- error "$(gettext "%s not found. Cannot continue.")" "$confdir/makepkg.conf"
- exit 1 # $E_CONFIG_ERROR
-fi
-
-if [ -r ~/.makepkg.conf ]; then
- source ~/.makepkg.conf
-fi
-
# main routine
gstmpdir=$(mktemp -d /tmp/repo-tools.XXXXXXXXXX) || (\
error "$(gettext "Cannot create temp directory for database building.")"; \
@@ -387,10 +375,11 @@ if [ $success -eq 1 ]; then
[ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old"
[ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old"
- case "$DB_COMPRESSION" in
- gz) TAR_OPT="z" ;;
- bz2) TAR_OPT="j" ;;
- *) warning "$(gettext "No compression set.")" ;;
+ case "$REPO_DB_FILE" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' does not have a valid archive extension.")" \
+ "$REPO_DB_FILE" ;;
esac
bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" *
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 82dabae3..92a31f16 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -201,7 +201,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
(char *)alpm_pkg_get_name(data1),
(char *)alpm_pkg_get_version(data2),
(char *)alpm_pkg_get_version(data1));
- display_optdepends(data1);
+ display_new_optdepends(data2,data1);
break;
case PM_TRANS_EVT_INTEGRITY_START:
printf(_("checking package integrity...\n"));
@@ -224,9 +224,6 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
case PM_TRANS_EVT_SCRIPTLET_INFO:
printf("%s", (char*)data1);
break;
- case PM_TRANS_EVT_PRINTURI:
- printf("%s/%s\n", (char*)data1, (char*)data2);
- break;
case PM_TRANS_EVT_RETRIEVE_START:
printf(_(":: Retrieving packages from %s...\n"), (char*)data1);
break;
@@ -253,33 +250,33 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
case PM_TRANS_CONV_INSTALL_IGNOREPKG:
if(data2) {
/* TODO we take this route based on data2 being not null? WTF */
- *response = yesno(1, _(":: %s requires installing %s from IgnorePkg/IgnoreGroup. Install anyway?"),
+ *response = yesno(_(":: %s requires installing %s from IgnorePkg/IgnoreGroup. Install anyway?"),
alpm_pkg_get_name(data2),
alpm_pkg_get_name(data1));
} else {
- *response = yesno(1, _(":: %s is in IgnorePkg/IgnoreGroup. Install anyway?"),
+ *response = yesno(_(":: %s is in IgnorePkg/IgnoreGroup. Install anyway?"),
alpm_pkg_get_name(data1));
}
break;
case PM_TRANS_CONV_REMOVE_HOLDPKG:
- *response = yesno(1, _(":: %s is designated as a HoldPkg. Remove anyway?"),
+ *response = yesno(_(":: %s is designated as a HoldPkg. Remove anyway?"),
alpm_pkg_get_name(data1));
break;
case PM_TRANS_CONV_REPLACE_PKG:
- *response = yesno(1, _(":: Replace %s with %s/%s?"),
+ *response = yesno(_(":: Replace %s with %s/%s?"),
alpm_pkg_get_name(data1),
(char *)data3,
alpm_pkg_get_name(data2));
break;
case PM_TRANS_CONV_CONFLICT_PKG:
- *response = yesno(1, _(":: %s conflicts with %s. Remove %s?"),
+ *response = yesno(_(":: %s conflicts with %s. Remove %s?"),
(char *)data1,
(char *)data2,
(char *)data2);
break;
case PM_TRANS_CONV_LOCAL_NEWER:
if(!config->op_s_downloadonly) {
- *response = yesno(1, _(":: %s-%s: local version is newer. Upgrade anyway?"),
+ *response = yesno(_(":: %s-%s: local version is newer. Upgrade anyway?"),
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
} else {
@@ -287,7 +284,7 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
}
break;
case PM_TRANS_CONV_CORRUPTED_PKG:
- *response = yesno(1, _(":: File %s is corrupted. Do you want to delete it?"),
+ *response = yesno(_(":: File %s is corrupted. Do you want to delete it?"),
(char *)data1);
break;
}
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 48c927bf..5853facc 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -44,10 +44,6 @@ config_t *config_new(void)
newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
/* CONFFILE is defined at compile-time */
newconfig->configfile = strdup(CONFFILE);
- newconfig->rootdir = NULL;
- newconfig->dbpath = NULL;
- newconfig->logfile = NULL;
- newconfig->syncfirst = NULL;
return(newconfig);
}
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 9d2318df..8ea66629 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -57,6 +57,7 @@ typedef struct __config_t {
unsigned short op_s_sync;
unsigned short op_s_search;
unsigned short op_s_upgrade;
+ unsigned short op_s_printuris;
unsigned short group;
pmtransflag_t flags;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 0e133df6..a71381fa 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -113,7 +113,7 @@ static void usage(int op, const char * const myname)
printf(_(" -p, --file <package> query a package file instead of the database\n"));
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
printf(_(" -t, --unrequired list all packages not required by any package\n"));
- printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
+ printf(_(" -u, --upgrades list all outdated packages\n"));
printf(_(" -q, --quiet show less information for query and search\n"));
} else if(op == PM_OP_SYNC) {
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
@@ -478,7 +478,8 @@ static int parseargs(int argc, char *argv[])
case 'o': config->op_q_owns = 1; break;
case 'p':
config->op_q_isfile = 1;
- config->flags |= PM_TRANS_FLAG_PRINTURIS;
+ config->op_s_printuris = 1;
+ config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
break;
case 'q':
config->quiet = 1;
diff --git a/src/pacman/query.c b/src/pacman/query.c
index d899539f..0d48638f 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -103,7 +103,7 @@ static int query_fileowner(alpm_list_t *targets)
root = alpm_option_get_root();
- for(i = alpm_db_getpkgcache(db_local); i && !found; i = alpm_list_next(i)) {
+ for(i = alpm_db_get_pkgcache(db_local); i && !found; i = alpm_list_next(i)) {
pmpkg_t *info = alpm_list_getdata(i);
for(j = alpm_pkg_get_files(info); j && !found; j = alpm_list_next(j)) {
@@ -154,7 +154,7 @@ static int query_search(alpm_list_t *targets)
searchlist = alpm_db_search(db_local, targets);
freelist = 1;
} else {
- searchlist = alpm_db_getpkgcache(db_local);
+ searchlist = alpm_db_get_pkgcache(db_local);
freelist = 0;
}
if(searchlist == NULL) {
@@ -215,7 +215,7 @@ static int query_group(alpm_list_t *targets)
char *grpname = NULL;
int ret = 0;
if(targets == NULL) {
- for(j = alpm_db_getgrpcache(db_local); j; j = alpm_list_next(j)) {
+ for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) {
pmgrp_t *grp = alpm_list_getdata(j);
const alpm_list_t *p, *packages;
const char *grpname;
@@ -251,24 +251,6 @@ static int query_group(alpm_list_t *targets)
return ret;
}
-static int query_upgrades(void)
-{
- alpm_list_t *syncpkgs = NULL;
- printf(_("Checking for package upgrades... \n"));
-
- alpm_list_t *syncdbs = alpm_option_get_syncdbs();
- if(alpm_sync_sysupgrade(db_local, syncdbs, &syncpkgs) == -1) {
- return(-1);
- }
- if(syncpkgs) {
- display_synctargets(syncpkgs);
- return(0);
- }
-
- printf(_("no upgrades found.\n"));
- return(1);
-}
-
static int is_foreign(pmpkg_t *pkg)
{
const char *pkgname = alpm_pkg_get_name(pkg);
@@ -320,6 +302,10 @@ static int filter(pmpkg_t *pkg)
if(config->op_q_unrequired && !is_unrequired(pkg)) {
return(0);
}
+ /* check if this pkg is outdated */
+ if(config->op_q_upgrade && (alpm_sync_newversion(pkg, alpm_option_get_syncdbs()) == NULL)) {
+ return(0);
+ }
return(1);
}
@@ -361,12 +347,6 @@ int pacman_query(alpm_list_t *targets)
return(ret);
}
- /* check for package upgrades */
- if(config->op_q_upgrade) {
- ret = query_upgrades();
- return(ret);
- }
-
/* looking for groups */
if(config->group) {
ret = query_group(targets);
@@ -391,7 +371,7 @@ int pacman_query(alpm_list_t *targets)
return(1);
}
- for(i = alpm_db_getpkgcache(db_local); i; i = alpm_list_next(i)) {
+ for(i = alpm_db_get_pkgcache(db_local); i; i = alpm_list_next(i)) {
pmpkg_t *pkg = alpm_list_getdata(i);
if(filter(pkg)) {
display(pkg);
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index f091fa4d..b70f7035 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -75,10 +75,10 @@ int pacman_remove(alpm_list_t *targets)
}
printf(_(":: group %s:\n"), targ);
list_display(" ", pkgnames);
- int all = yesno(1, _(" Remove whole content?"));
+ int all = yesno(_(" Remove whole content?"));
for(p = pkgnames; p; p = alpm_list_next(p)) {
char *pkgn = alpm_list_getdata(p);
- if(all || yesno(1, _(":: Remove %s from group %s?"), pkgn, targ)) {
+ if(all || yesno(_(":: Remove %s from group %s?"), pkgn, targ)) {
if(alpm_trans_addtarget(pkgn) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ,
alpm_strerrorlast());
@@ -131,7 +131,7 @@ int pacman_remove(alpm_list_t *targets)
printf("\n");
/* get confirmation */
- if(yesno(1, _("Do you want to remove these packages?")) == 0) {
+ if(yesno(_("Do you want to remove these packages?")) == 0) {
retval = 1;
goto cleanup;
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 8d0c529a..63397aa3 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -85,7 +85,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {
/* We have a directory that doesn't match any syncdb.
* Ask the user if he wants to remove it. */
if(!found) {
- if(!yesno(1, _("Do you want to remove %s?"), path)) {
+ if(!yesno(_("Do you want to remove %s?"), path)) {
continue;
}
@@ -105,7 +105,7 @@ static int sync_cleandb_all(void) {
char newdbpath[PATH_MAX];
printf(_("Database directory: %s\n"), dbpath);
- if(!yesno(1, _("Do you want to remove unused repositories?"))) {
+ if(!yesno(_("Do you want to remove unused repositories?"))) {
return(0);
}
/* The sync dbs were previously put in dbpath/, but are now in dbpath/sync/,
@@ -135,12 +135,12 @@ static int sync_cleancache(int level)
printf(_("Cache directory: %s\n"), cachedir);
switch(config->cleanmethod) {
case PM_CLEAN_KEEPINST:
- if(!yesno(1, _("Do you want to remove uninstalled packages from cache?"))) {
+ if(!yesno(_("Do you want to remove uninstalled packages from cache?"))) {
return(0);
}
break;
case PM_CLEAN_KEEPCUR:
- if(!yesno(1, _("Do you want to remove outdated packages from cache?"))) {
+ if(!yesno(_("Do you want to remove outdated packages from cache?"))) {
return(0);
}
break;
@@ -215,7 +215,7 @@ static int sync_cleancache(int level)
} else {
/* full cleanup */
printf(_("Cache directory: %s\n"), cachedir);
- if(!yesno(0, _("Do you want to remove ALL packages from cache?"))) {
+ if(!noyes(_("Do you want to remove ALL packages from cache?"))) {
return(0);
}
printf(_("removing all packages from cache... "));
@@ -286,7 +286,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
ret = alpm_db_search(db, targets);
freelist = 1;
} else {
- ret = alpm_db_getpkgcache(db);
+ ret = alpm_db_get_pkgcache(db);
freelist = 0;
}
if(ret == NULL) {
@@ -371,7 +371,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
- for(j = alpm_db_getgrpcache(db); j; j = alpm_list_next(j)) {
+ for(j = alpm_db_get_grpcache(db); j; j = alpm_list_next(j)) {
pmgrp_t *grp = alpm_list_getdata(j);
const char *grpname = alpm_grp_get_name(grp);
@@ -425,7 +425,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
return(1);
}
- for(k = alpm_db_getpkgcache(db); k; k = alpm_list_next(k)) {
+ for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) {
pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
@@ -446,7 +446,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(j = syncs; j; j = alpm_list_next(j)) {
pmdb_t *db = alpm_list_getdata(j);
- for(k = alpm_db_getpkgcache(db); k; k = alpm_list_next(k)) {
+ for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) {
pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
@@ -467,7 +467,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
- for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db));
}
}
@@ -510,7 +510,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
for(i = ls; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
- for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j);
if (!config->quiet) {
printf("%s %s %s\n", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
@@ -604,14 +604,14 @@ static int sync_trans(alpm_list_t *targets)
(char*)alpm_pkg_get_name(k->data));
}
list_display(" ", pkgnames);
- if(yesno(1, _(":: Install whole content?"))) {
+ if(yesno(_(":: Install whole content?"))) {
for(k = pkgnames; k; k = alpm_list_next(k)) {
targets = alpm_list_add(targets, strdup(alpm_list_getdata(k)));
}
} else {
for(k = pkgnames; k; k = alpm_list_next(k)) {
char *pkgname = alpm_list_getdata(k);
- if(yesno(1, _(":: Install %s from group %s?"), pkgname, targ)) {
+ if(yesno(_(":: Install %s from group %s?"), pkgname, targ)) {
targets = alpm_list_add(targets, strdup(pkgname));
}
}
@@ -666,23 +666,32 @@ static int sync_trans(alpm_list_t *targets)
goto cleanup;
}
- if(!(alpm_trans_get_flags() & PM_TRANS_FLAG_PRINTURIS)) {
- int confirm;
+ /* Step 3: actually perform the operation */
+ if(config->op_s_printuris) {
+ /* print uris */
+ alpm_list_t *i;
+ for(i = packages; i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_sync_get_pkg((pmsyncpkg_t *)alpm_list_getdata(i));
+ pmdb_t *db = alpm_pkg_get_db(pkg);
+ printf("%s/%s\n", alpm_db_get_url(db), alpm_pkg_get_filename(pkg));
+ }
+ /* we are done */
+ goto cleanup;
+ }
- display_synctargets(packages);
- printf("\n");
+ display_synctargets(packages);
+ printf("\n");
- if(config->op_s_downloadonly) {
- confirm = yesno(1, _("Proceed with download?"));
- } else {
- confirm = yesno(1, _("Proceed with installation?"));
- }
- if(!confirm) {
- goto cleanup;
- }
- }/* else 'print uris' requested. We're done at this point */
+ int confirm;
+ if(config->op_s_downloadonly) {
+ confirm = yesno(_("Proceed with download?"));
+ } else {
+ confirm = yesno(_("Proceed with installation?"));
+ }
+ if(!confirm) {
+ goto cleanup;
+ }
- /* Step 3: actually perform the installation */
if(alpm_trans_commit(&data) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerrorlast());
@@ -739,7 +748,7 @@ int pacman_sync(alpm_list_t *targets)
alpm_list_t *sync_dbs = NULL;
/* Display only errors with -Sp and -Sw operations */
- if(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS)) {
+ if((config->flags & PM_TRANS_FLAG_DOWNLOADONLY) || config->op_s_printuris) {
config->logmask &= ~PM_LOG_WARNING;
}
@@ -811,13 +820,13 @@ int pacman_sync(alpm_list_t *targets)
}
alpm_list_t *targs = alpm_list_strdup(targets);
- if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
+ if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY) && !config->op_s_printuris) {
/* check for newer versions of packages to be upgraded first */
alpm_list_t *packages = syncfirst();
if(packages) {
printf(_(":: The following packages should be upgraded first :\n"));
list_display(" ", packages);
- if(yesno(1, _(":: Do you want to cancel the current operation\n"
+ if(yesno(_(":: Do you want to cancel the current operation\n"
":: and upgrade these packages now?"))) {
FREELIST(targs);
targs = packages;
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8cfa675a..b80b09ad 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -610,6 +610,25 @@ void display_synctargets(const alpm_list_t *syncpkgs)
alpm_list_free(rpkglist);
}
+/* Helper function for comparing strings using the
+ * alpm "compare func" signature */
+int str_cmp(const void *s1, const void *s2)
+{
+ return(strcmp(s1, s2));
+}
+
+void display_new_optdepends(pmpkg_t *oldpkg, pmpkg_t *newpkg)
+{
+ alpm_list_t *old = alpm_pkg_get_optdepends(oldpkg);
+ alpm_list_t *new = alpm_pkg_get_optdepends(newpkg);
+ alpm_list_t *optdeps = alpm_list_diff(new,old,str_cmp);
+ if(optdeps) {
+ printf(_("New optional dependencies for %s\n"), alpm_pkg_get_name(newpkg));
+ list_display_linebreak(" ", optdeps);
+ }
+ alpm_list_free(optdeps);
+}
+
void display_optdepends(pmpkg_t *pkg)
{
alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg);
@@ -620,10 +639,9 @@ void display_optdepends(pmpkg_t *pkg)
}
/* presents a prompt and gets a Y/N answer */
-int yesno(short preset, char *fmt, ...)
+static int question(short preset, char *fmt, va_list args)
{
char response[32];
- va_list args;
FILE *stream;
if(config->noconfirm) {
@@ -633,9 +651,7 @@ int yesno(short preset, char *fmt, ...)
stream = stderr;
}
- va_start(args, fmt);
vfprintf(stream, fmt, args);
- va_end(args);
if(preset) {
fprintf(stream, " %s ", _("[Y/n]"));
@@ -663,6 +679,30 @@ int yesno(short preset, char *fmt, ...)
return(0);
}
+int yesno(char *fmt, ...)
+{
+ int ret;
+ va_list args;
+
+ va_start(args, fmt);
+ ret = question(1, fmt, args);
+ va_end(args);
+
+ return(ret);
+}
+
+int noyes(char *fmt, ...)
+{
+ int ret;
+ va_list args;
+
+ va_start(args, fmt);
+ ret = question(0, fmt, args);
+ va_end(args);
+
+ return(ret);
+}
+
int pm_printf(pmloglevel_t level, const char *format, ...)
{
int ret;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 5eeec8d2..64168587 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -54,8 +54,10 @@ void list_display(const char *title, const alpm_list_t *list);
void list_display_linebreak(const char *title, const alpm_list_t *list);
void display_targets(const alpm_list_t *pkgs, int install);
void display_synctargets(const alpm_list_t *syncpkgs);
+void display_new_optdepends(pmpkg_t *oldpkg, pmpkg_t *newpkg);
void display_optdepends(pmpkg_t *pkg);
-int yesno(short preset, char *fmt, ...);
+int yesno(char *fmt, ...);
+int noyes(char *fmt, ...);
int pm_printf(pmloglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));
int pm_vfprintf(FILE *stream, pmloglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 87bfcf96..8a66819f 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -56,7 +56,7 @@ void output_cb(pmloglevel_t level, char *fmt, va_list args)
}
}
-static int db_test(char *dbpath)
+static int db_test(char *dbpath, int local)
{
struct dirent *ent;
char path[PATH_MAX];
@@ -70,7 +70,8 @@ static int db_test(char *dbpath)
}
while ((ent = readdir(dir)) != NULL) {
- if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
+ if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")
+ || ent->d_name[0] == '.') {
continue;
}
/* check for desc, depends, and files */
@@ -84,36 +85,133 @@ static int db_test(char *dbpath)
printf("%s: dependency file is missing\n", ent->d_name);
ret++;
}
- snprintf(path, PATH_MAX, "%s/%s/files", dbpath, ent->d_name);
- if(access(path, F_OK)) {
- printf("%s: file list is missing\n", ent->d_name);
- ret++;
+ if(local) {
+ snprintf(path, PATH_MAX, "%s/%s/files", dbpath, ent->d_name);
+ if(access(path, F_OK)) {
+ printf("%s: file list is missing\n", ent->d_name);
+ ret++;
+ }
}
}
return(ret);
}
-int main(int argc, char **argv)
+int checkdeps(alpm_list_t *pkglist)
{
- int retval = 0; /* default = false */
- pmdb_t *db = NULL;
- char *dbpath;
- char localdbpath[PATH_MAX];
- alpm_list_t *i;
+ alpm_list_t *data, *i;
+ int ret = 0;
+ /* check dependencies */
+ data = alpm_checkdeps(pkglist, 0, NULL, pkglist);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
+ pmdepend_t *dep = alpm_miss_get_dep(miss);
+ char *depstring = alpm_dep_get_string(dep);
+ printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss),
+ depstring);
+ free(depstring);
+ ret++;
+ }
+ return(ret);
+}
- if(argc == 1) {
- dbpath = DBPATH;
- } else if(argc == 3 && strcmp(argv[1], "-b") == 0) {
- dbpath = argv[2];
- } else {
- fprintf(stderr, "usage: %s -b <pacman db>\n", BASENAME);
- return(1);
+int checkconflicts(alpm_list_t *pkglist)
+{
+ alpm_list_t *data, *i;
+ int ret = 0;
+ /* check conflicts */
+ data = alpm_checkconflicts(pkglist);
+ for(i = data; i; i = i->next) {
+ pmconflict_t *conflict = alpm_list_getdata(i);
+ printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict),
+ alpm_conflict_get_package2(conflict));
+ ret++;
}
+ return(ret);
+}
+
+int check_localdb(char *dbpath) {
+ char localdbpath[PATH_MAX];
+ int ret = 0;
+ pmdb_t *db = NULL;
+ alpm_list_t *pkglist;
snprintf(localdbpath, PATH_MAX, "%s/local", dbpath);
- retval = db_test(localdbpath);
- if(retval) {
- return(retval);
+ ret = db_test(localdbpath, 1);
+ if(ret) {
+ return(ret);
+ }
+
+ db = alpm_db_register_local();
+ if(db == NULL) {
+ fprintf(stderr, "error: could not register 'local' database (%s)\n",
+ alpm_strerrorlast());
+ cleanup(EXIT_FAILURE);
+ }
+ pkglist = alpm_db_get_pkgcache(db);
+ ret += checkdeps(pkglist);
+ ret += checkconflicts(pkglist);
+ return(ret);
+}
+
+int check_syncdbs(char *dbpath, alpm_list_t *dbnames) {
+ char syncdbpath[PATH_MAX];
+ int ret = 0;
+ pmdb_t *db = NULL;
+ alpm_list_t *i, *pkglist, *syncpkglist = NULL;
+
+ for(i = dbnames; i; i = alpm_list_next(i)) {
+ char *dbname = alpm_list_getdata(i);
+ snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname);
+ ret = db_test(syncdbpath, 0);
+ if(ret) {
+ return(ret);
+ }
+ db = alpm_db_register_sync(dbname);
+ if(db == NULL) {
+ fprintf(stderr, "error: could not register sync database (%s)\n",
+ alpm_strerrorlast());
+ cleanup(EXIT_FAILURE);
+ }
+ pkglist = alpm_db_get_pkgcache(db);
+ syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
+ }
+ ret += checkdeps(syncpkglist);
+ alpm_list_free(syncpkglist);
+
+ alpm_db_unregister_all();
+ return(ret);
+}
+
+void usage() {
+ fprintf(stderr, "usage:\n");
+ fprintf(stderr,
+ "\t%s [-b <pacman db>] : check the local database\n", BASENAME);
+ fprintf(stderr,
+ "\t%s [-b <pacman db>] core extra ... : check the listed sync databases\n", BASENAME);
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+ char *dbpath = DBPATH;
+ int a = 1;
+ alpm_list_t *dbnames = NULL;
+
+ while(a < argc) {
+ if(strcmp(argv[a], "-b") == 0) {
+ if(++a < argc) {
+ dbpath = argv[a];
+ } else {
+ usage();
+ }
+ } else if(strcmp(argv[a], "-h") == 0 ||
+ strcmp(argv[a], "--help") == 0 ) {
+ usage();
+ } else {
+ dbnames = alpm_list_add(dbnames, argv[a]);
+ }
+ a++;
}
if(alpm_initialize() == -1) {
@@ -126,34 +224,15 @@ int main(int argc, char **argv)
alpm_option_set_dbpath(dbpath);
- db = alpm_db_register_local();
- if(db == NULL) {
- fprintf(stderr, "error: could not register 'local' database (%s)\n",
- alpm_strerrorlast());
- cleanup(EXIT_FAILURE);
- }
-
- /* check dependencies */
- alpm_list_t *data;
- data = alpm_checkdeps(db, 0, NULL, alpm_db_getpkgcache(db));
- for(i = data; i; i = alpm_list_next(i)) {
- pmdepmissing_t *miss = alpm_list_getdata(i);
- pmdepend_t *dep = alpm_miss_get_dep(miss);
- char *depstring = alpm_dep_get_string(dep);
- printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss),
- depstring);
- free(depstring);
- }
-
- /* check conflicts */
- data = alpm_checkdbconflicts(db);
- for(i = data; i; i = i->next) {
- pmconflict_t *conflict = alpm_list_getdata(i);
- printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict),
- alpm_conflict_get_package2(conflict));
+ if(!dbnames) {
+ printf("Checking the integrity of the local database in %s\n",dbpath);
+ ret = check_localdb(dbpath);
+ } else {
+ printf("Checking the integrity of the sync databases in %s\n",dbpath);
+ ret = check_syncdbs(dbpath,dbnames);
}
- cleanup(retval);
+ cleanup(ret);
}
/* vim: set ts=2 sw=2 noet: */