Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--lib/libalpm/alpm.h11
-rw-r--r--lib/libalpm/be_local.c8
-rw-r--r--lib/libalpm/be_sync.c5
-rw-r--r--lib/libalpm/deps.c6
-rw-r--r--lib/libalpm/package.c7
-rw-r--r--lib/libalpm/package.h6
-rw-r--r--src/pacman/package.c7
-rw-r--r--src/pacman/package.h9
-rw-r--r--src/pacman/query.c4
-rw-r--r--src/pacman/sync.c4
11 files changed, 44 insertions, 27 deletions
diff --git a/README b/README
index d5071a96..c14fd3c7 100644
--- a/README
+++ b/README
@@ -429,13 +429,13 @@ API CHANGES BETWEEN 3.5 AND 4.0
alpm_option_get_default_siglevel(), alpm_option_set_default_siglevel(),
alpm_option_get_gpgdir(), alpm_option_set_gpgdir(), alpm_db_get_siglevel(),
alpm_sigresult_cleanup(), alpm_db_check_pgp_signature(), alpm_pkg_check_pgp_signature(),
- alpm_pkg_get_sha256sum(), alpm_pkg_get_base64_sig()
+ alpm_pkg_get_origin(), alpm_pkg_get_sha256sum(), alpm_pkg_get_base64_sig()
- list functions:
alpm_list_to_array(), alpm_list_previous()
- structs:
alpm_backup_t, alpm_file_t, alpm_filelist_t
- enums:
- alpm_siglevel_t, alpm_sigstatus_t, alpm_sigvalidity_t
+ alpm_siglevel_t, alpm_sigstatus_t, alpm_sigvalidity_t, alpm_pkgfrom_t
- error codes:
ALPM_ERR_DB_INVALID, ALPM_ERR_DB_INVALID_SIG, ALPM_ERR_GPGME,
ALPM_ERR_PKG_INVALID_CHECKSUM, ALPM_ERR_PKG_INVALID_SIG, ALPM_ERR_SIG_INVALID,
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index c94cdf7f..42e60385 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -60,6 +60,12 @@ typedef enum _alpm_pkgreason_t {
ALPM_PKG_REASON_DEPEND = 1
} alpm_pkgreason_t;
+typedef enum _alpm_pkgfrom_t {
+ PKG_FROM_FILE = 1,
+ PKG_FROM_LOCALDB,
+ PKG_FROM_SYNCDB
+} alpm_pkgfrom_t;
+
/** Types of version constraints in dependency specs. */
typedef enum _alpm_depmod_t {
/** No version constraint */
@@ -592,6 +598,11 @@ const char *alpm_pkg_get_name(alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_version(alpm_pkg_t *pkg);
+/** Returns the origin of the package.
+ * @return a #alpm_pkgfrom_t constant, -1 on error
+ */
+alpm_pkgfrom_t alpm_pkg_get_origin(alpm_pkg_t *pkg);
+
/** Returns the package description.
* @param pkg a pointer to package
* @return a reference to an internal string
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 1a46dfdf..be02bb50 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -580,7 +580,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
goto error;
}
while(!feof(fp)) {
- READ_NEXT();
+ if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) {
+ goto error;
+ }
+ if(_alpm_strip_newline(line) == 0) {
+ /* length of stripped line was zero */
+ continue;
+ }
if(strcmp(line, "%NAME%") == 0) {
READ_NEXT();
if(strcmp(line, info->name) != 0) {
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index ac99e05e..12d5b7fe 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -526,7 +526,10 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
int ret;
while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) {
char *line = buf.line;
- _alpm_strip_newline(line);
+ if(_alpm_strip_newline(line) == 0) {
+ /* length of stripped line was zero */
+ continue;
+ }
if(strcmp(line, "%NAME%") == 0) {
READ_NEXT();
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 47b7637a..e268157a 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -441,7 +441,11 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
}
/* copy the right parts to the right places */
- STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
+ if(ptr) {
+ STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
+ } else {
+ STRDUP(depend->name, depstring, return NULL);
+ }
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
STRDUP(depend->version, version, return NULL);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 3d73a433..487b56d9 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -185,6 +185,13 @@ const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg)
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;
+ return pkg->origin;
+}
+
const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 707405dd..5962b1d0 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -34,12 +34,6 @@
#include "db.h"
#include "signing.h"
-typedef enum _alpm_pkgfrom_t {
- PKG_FROM_FILE = 1,
- PKG_FROM_LOCALDB,
- PKG_FROM_SYNCDB
-} alpm_pkgfrom_t;
-
/** Package operations struct. This struct contains function pointers to
* all methods used to access data in a package to allow for things such
* as lazy package intialization (such as used by the file backend). Each
diff --git a/src/pacman/package.c b/src/pacman/package.c
index a8c15eb8..5654944c 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -61,7 +61,7 @@ static void deplist_display(const char *title,
* @param from the type of package we are dealing with
* @param extra should we show extra information
*/
-void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
+void dump_pkg_full(alpm_pkg_t *pkg, int extra)
{
const char *reason;
time_t bdate, idate;
@@ -69,10 +69,9 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
const char *label;
double size;
alpm_list_t *requiredby = NULL;
+ alpm_pkgfrom_t from;
- if(pkg == NULL) {
- return;
- }
+ from = alpm_pkg_get_origin(pkg);
/* set variables here, do all output below */
bdate = alpm_pkg_get_builddate(pkg);
diff --git a/src/pacman/package.h b/src/pacman/package.h
index 6f71d20e..890b4fe1 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -22,14 +22,7 @@
#include <alpm.h>
-/* TODO it would be nice if we didn't duplicate a backend type */
-enum pkg_from {
- PKG_FROM_FILE = 1,
- PKG_FROM_LOCALDB,
- PKG_FROM_SYNCDB
-};
-
-void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra);
+void dump_pkg_full(alpm_pkg_t *pkg, int extra);
void dump_pkg_backups(alpm_pkg_t *pkg);
void dump_pkg_files(alpm_pkg_t *pkg, int quiet);
diff --git a/src/pacman/query.c b/src/pacman/query.c
index ec98c999..5f2b37eb 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -460,9 +460,9 @@ static int display(alpm_pkg_t *pkg)
if(config->op_q_info) {
if(config->op_q_isfile) {
- dump_pkg_full(pkg, PKG_FROM_FILE, 0);
+ dump_pkg_full(pkg, 0);
} else {
- dump_pkg_full(pkg, PKG_FROM_LOCALDB, config->op_q_info > 1);
+ dump_pkg_full(pkg, config->op_q_info > 1);
}
}
if(config->op_q_list) {
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index a7fe5be9..e97da37a 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -469,7 +469,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
alpm_pkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
- dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1);
+ dump_pkg_full(pkg, config->op_s_info > 1);
foundpkg = 1;
break;
}
@@ -494,7 +494,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
alpm_pkg_t *pkg = alpm_list_getdata(j);
- dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1);
+ dump_pkg_full(pkg, config->op_s_info > 1);
}
}
}