Pacman-dev
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- 1 participants
- 7322 discussions
Hi,
I tried to clean up lib/libalpm/util.[ch]. It's not yet complete, I
would like to have some comments on it first.
Some notes:
There has to be a proper way handling out-of-memory. The lib
can't do anything anymore without memory - am I right?
_alpm_runscriptlet is really long and I'm going to split it.
So, here goes the patch:
Signed-off-by: Johannes Weiner <hannes(a)saeurebad.de>
diff -Naur pacman-lib.old/lib/libalpm/util.c pacman-lib/lib/libalpm/util.c
--- pacman-lib.old/lib/libalpm/util.c 2007-01-24 16:09:16.000000000 +0100
+++ pacman-lib/lib/libalpm/util.c 2007-01-24 16:10:13.000000000 +0100
@@ -64,9 +64,49 @@
#include "package.h"
#include "alpm.h"
+/* Memory allocation frontends with return value check.
+ * TODO: Think about an elegant way to die on failure */
+static void *safe_mem(void *r)
+{
+ if (r) {
+ return (r);
+ }
+
+ _alpm_log(PM_LOG_ERROR, "Memory exhausted.\n");
+
+ /* TODO: This is probably the wrong way */
+ alpm_release();
+ exit(2);
+}
+
+void *pmalloc(size_t s)
+{
+ return (safe_mem(malloc(s)));
+}
+
+void *pcalloc(size_t e, size_t s)
+{
+ return (safe_mem(calloc(e, s)));
+}
+
+void *prealloc(void *p, size_t s)
+{
+ return (safe_mem(realloc(p, s)));
+}
+
+char *pstrdup(const char *s)
+{
+ return (safe_mem((char *) strdup(s)));
+}
+
+void *palloca(size_t s)
+{
+ return (safe_mem(alloca(s)));
+}
+
#ifdef __sun__
/* This is a replacement for strsep which is not portable (missing on Solaris).
- * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
+ * Copyright (c) 2001 by Fran�ois Gouget <fgouget_at_codeweavers.com> */
char* strsep(char** str, const char* delims)
{
char* token;
@@ -92,13 +132,12 @@
/* Backported from Solaris Express 4/06
* Copyright (c) 2006 Sun Microsystems, Inc. */
-char * mkdtemp(char *template)
+char * mkdtemp(const char *template)
{
- char *t = alloca(strlen(template) + 1);
- char *r;
+ char *r, *t = palloca(strlen(template) + 1);
/* Save template */
- (void) strcpy(t, template);
+ strcpy(t, template);
for (; ; ) {
r = mktemp(template);
@@ -113,7 +152,7 @@
return (NULL);
/* Reset template */
- (void) strcpy(template, t);
+ strcpy(template, t);
}
}
#endif
@@ -121,14 +160,16 @@
/* does the same thing as 'mkdir -p' */
int _alpm_makepath(char *path)
{
- char *orig, *str, *ptr;
- char full[PATH_MAX] = "";
mode_t oldmask;
+ char *orig, *str, *ptr, full[PATH_MAX];
oldmask = umask(0000);
- orig = strdup(path);
+ memset(full, 0, sizeof(full));
+
+ orig = pstrdup(path);
str = orig;
+
while((ptr = strsep(&str, "/"))) {
if(strlen(ptr)) {
struct stat buf;
@@ -149,32 +190,46 @@
return(0);
}
-int _alpm_copyfile(char *src, char *dest)
+int _alpm_copyfile(const char *src, const char *dest)
{
- FILE *in, *out;
- size_t len;
- char buf[4097];
+ FILE *fp;
+ char *buf;
+ struct stat sbuf;
- in = fopen(src, "r");
- if(in == NULL) {
+ if (stat(src, &sbuf)) {
return(1);
}
- out = fopen(dest, "w");
- if(out == NULL) {
- fclose(in);
+
+ if (!(fp = fopen(src, "r"))) {
return(1);
}
- while((len = fread(buf, 1, 4096, in))) {
- fwrite(buf, 1, len, out);
+ buf = pmalloc(sbuf.st_size);
+
+ if (fread(buf, sbuf.st_size, 1, fp) != 1) {
+ FREE(buf);
+ return(1);
+ }
+
+ fclose(fp);
+
+ if (!(fp = fopen(dest, "w"))) {
+ FREE(buf);
+ return(1);
+ }
+
+ if (fwrite(buf, sbuf.st_size, 1, fp) != 1) {
+ FREE(buf);
+ fclose(fp);
+ return(1);
}
- fclose(in);
- fclose(out);
+ FREE(buf);
+ fclose(fp);
return(0);
}
-/* Convert a string to uppercase
+/* Convert a string to uppercase destructively
*/
char *_alpm_strtoupper(char *str)
{
@@ -187,7 +242,7 @@
return str;
}
-/* Trim whitespace and newlines from a string
+/* Trim whitespace and newlines from a string destructively
*/
char *_alpm_strtrim(char *str)
{
@@ -210,8 +265,8 @@
return(str);
}
- pch = (char *)(str + (strlen(str) - 1));
- while(isspace((int)*pch)) {
+ pch = (str + (strlen(str) - 1));
+ while(isspace(*pch)) {
pch--;
}
*++pch = '\0';
@@ -221,35 +276,36 @@
/* Create a lock file
*/
-int _alpm_lckmk(char *file)
+int _alpm_lckmk(const char *file)
{
int fd, count = 0;
char *dir, *ptr;
/* create the dir of the lockfile first */
- dir = strdup(file);
+ dir = pstrdup(file);
ptr = strrchr(dir, '/');
if(ptr) {
*ptr = '\0';
}
_alpm_makepath(dir);
- while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000)) == -1 && errno == EACCES) {
+ while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000) == -1) &&
+ (errno == EACCES)) {
if(++count < 1) {
sleep(1);
- } else {
+ } else {
return(-1);
}
}
- free(dir);
+ FREE(dir);
return(fd > 0 ? fd : -1);
}
/* Remove a lock file
*/
-int _alpm_lckrm(char *file)
+int _alpm_lckrm(const char *file)
{
if(unlink(file) == -1 && errno != ENOENT) {
return(-1);
@@ -272,8 +328,12 @@
archive_read_support_compression_all(_archive);
archive_read_support_format_all(_archive);
- if(archive_read_open_file(_archive, archive, ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
- _alpm_log(PM_LOG_ERROR, _("could not open %s: %s\n"), archive, archive_error_string(_archive));
+ if(archive_read_open_file(_archive,
+ archive,
+ ARCHIVE_DEFAULT_BYTES_PER_BLOCK)
+ != ARCHIVE_OK) {
+ _alpm_log(PM_LOG_ERROR, _("could not open %s: %s\n"), archive,
+ archive_error_string(_archive));
RET_ERR(PM_ERR_PKG_OPEN, -1);
}
@@ -283,10 +343,18 @@
return(1);
continue;
}
- snprintf(expath, PATH_MAX, "%s/%s", prefix, archive_entry_pathname(entry));
+
+ snprintf(expath, PATH_MAX, "%s/%s", prefix,
+ archive_entry_pathname(entry));
archive_entry_set_pathname(entry, expath);
- if(archive_read_extract(_archive, entry, ARCHIVE_EXTRACT_FLAGS) != ARCHIVE_OK) {
- _alpm_log(PM_LOG_ERROR, _("could not extract %s: %s\n"), archive_entry_pathname(entry), archive_error_string(_archive));
+
+ if(archive_read_extract(_archive,
+ entry,
+ ARCHIVE_EXTRACT_FLAGS)
+ != ARCHIVE_OK) {
+ _alpm_log(PM_LOG_ERROR, _("could not extract %s: %s\n"),
+ archive_entry_pathname(entry),
+ archive_error_string(_archive));
return(1);
}
@@ -300,49 +368,53 @@
}
/* does the same thing as 'rm -rf' */
-int _alpm_rmrf(char *path)
+int _alpm_rmrf(const char *path)
{
int errflag = 0;
struct dirent *dp;
DIR *dirp;
char name[PATH_MAX];
- struct stat st;
+ struct stat st;
- if(stat(path, &st) == 0) {
- if(S_ISREG(st.st_mode)) {
- if(!unlink(path)) {
- return(0);
- } else {
- if(errno == ENOENT) {
- return(0);
- } else {
- /* not a directory */
- return(1);
- }
- }
- } else if(S_ISDIR(st.st_mode)) {
- if((dirp = opendir(path)) == (DIR *)-1) {
- return(1);
- }
- for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if(dp->d_ino) {
- sprintf(name, "%s/%s", path, dp->d_name);
- if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) {
- errflag += _alpm_rmrf(name);
- }
+ if(stat(path, &st)) {
+ return(0);
+ }
+
+ if(S_ISREG(st.st_mode)) {
+ if(!unlink(path)) {
+ return(0);
+ }
+
+ if(errno == ENOENT) {
+ return(0);
+ } else {
+ /* not a directory */
+ return(1);
+ }
+ } else if(S_ISDIR(st.st_mode)) {
+ if(!(dirp = opendir(path))) {
+ return(1);
+ }
+ for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ if(dp->d_ino) {
+ sprintf(name, "%s/%s", path, dp->d_name);
+ if(strcmp(dp->d_name, "..") &&
+ strcmp(dp->d_name, ".")) {
+ errflag += _alpm_rmrf(name);
}
}
- closedir(dirp);
- if(rmdir(path)) {
- errflag++;
- }
}
- return(errflag);
+ closedir(dirp);
+
+ if(rmdir(path)) {
+ errflag++;
+ }
}
- return(0);
+
+ return(errflag);
}
-int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
+int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str)
{
_alpm_log(PM_LOG_DEBUG, _("logaction called: %s"), str);
@@ -387,37 +459,39 @@
/* A cheap grep for text files, returns 1 if a substring
* was found in the text file fn, 0 if it wasn't
+ *
+ * TODO: Remove hardcoded buffersize
*/
static int grep(const char *fn, const char *needle)
{
FILE *fp;
+ char line[1024];
if((fp = fopen(fn, "r")) == NULL) {
return(0);
}
- while(!feof(fp)) {
- char line[1024];
- fgets(line, 1024, fp);
- if(feof(fp)) {
- continue;
- }
+
+ while(fgets(line, 1024, fp)) {
if(strstr(line, needle)) {
fclose(fp);
return(1);
}
}
+
fclose(fp);
return(0);
}
-int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans)
+/*
+ * TODO: This function is WAY too complex and long!!!
+ */
+int _alpm_runscriptlet(const char *root, const char *installfn,
+ const char *script, const char *ver,
+ const char *oldver, pmtrans_t *trans)
{
- char scriptfn[PATH_MAX];
- char cmdline[PATH_MAX];
- char tmpdir[PATH_MAX] = "";
- char *scriptpath;
+ char scriptfn[PATH_MAX], cmdline[PATH_MAX], tmpdir[PATH_MAX];
+ char *scriptpath, cwd[PATH_MAX] = "";
struct stat buf;
- char cwd[PATH_MAX] = "";
pid_t pid;
int retval = 0;
@@ -433,7 +507,8 @@
}
snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root);
if(mkdtemp(tmpdir) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not create temp directory"));
+ _alpm_log(PM_LOG_ERROR,
+ _("could not create temp directory"));
return(1);
}
_alpm_unpack(installfn, tmpdir, ".INSTALL");
@@ -453,14 +528,18 @@
/* save the cwd so we can restore it later */
if(getcwd(cwd, PATH_MAX) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not get current working directory"));
- /* in case of error, cwd content is undefined: so we set it to something */
+ _alpm_log(PM_LOG_ERROR,
+ _("could not get current working directory"));
+ /* in case of error, cwd content is undefined:
+ * so we set it to something */
cwd[0] = 0;
}
/* just in case our cwd was removed in the upgrade operation */
if(chdir(root) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)"), root, strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("could not change directory to %s (%s)"),
+ root, strerror(errno));
}
_alpm_log(PM_LOG_FLOW2, _("executing %s script..."), script);
@@ -476,52 +555,70 @@
pid = fork();
if(pid == -1) {
- _alpm_log(PM_LOG_ERROR, _("could not fork a new process (%s)"), strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("could not fork a new process (%s)"),
+ strerror(errno));
retval = 1;
goto cleanup;
}
if(pid == 0) {
FILE *pp;
+ char line[1024];
_alpm_log(PM_LOG_DEBUG, _("chrooting in %s"), root);
if(chroot(root) != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change the root directory (%s)"), strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("could not change the root directory (%s)"),
+ strerror(errno));
return(1);
}
if(chdir("/") != 0) {
- _alpm_log(PM_LOG_ERROR, _("could not change directory to / (%s)"), strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("could not change directory to / (%s)"),
+ strerror(errno));
return(1);
}
umask(0022);
_alpm_log(PM_LOG_DEBUG, _("executing \"%s\""), cmdline);
pp = popen(cmdline, "r");
if(!pp) {
- _alpm_log(PM_LOG_ERROR, _("call to popen failed (%s)"), strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("call to popen failed (%s)"),
+ strerror(errno));
retval = 1;
goto cleanup;
}
- while(!feof(pp)) {
- char line[1024];
- if(fgets(line, 1024, pp) == NULL)
- break;
+ while(fgets(line, 1024, pp)) {
+ size_t slen, dlen;
+ slen = strlen(SCRIPTLET_START);
+ dlen = strlen(SCRIPTLET_DONE);
+
/* "START <event desc>" */
- if((strlen(line) > strlen(SCRIPTLET_START)) && !strncmp(line, SCRIPTLET_START, strlen(SCRIPTLET_START))) {
- EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START, _alpm_strtrim(line + strlen(SCRIPTLET_START)), NULL);
+ if((strlen(line) > slen) &&
+ !strncmp(line, SCRIPTLET_START, slen)) {
+ EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START,
+ _alpm_strtrim(line + slen), NULL);
/* "DONE <ret code>" */
- } else if((strlen(line) > strlen(SCRIPTLET_DONE)) && !strncmp(line, SCRIPTLET_DONE, strlen(SCRIPTLET_DONE))) {
- EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE, (void*)atol(_alpm_strtrim(line + strlen(SCRIPTLET_DONE))), NULL);
+ } else if((strlen(line) > dlen) &&
+ !strncmp(line, SCRIPTLET_DONE, dlen)) {
+ EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE,
+ (void *)atol(_alpm_strtrim(line + dlen)),
+ NULL);
} else {
_alpm_strtrim(line);
/* log our script output */
alpm_logaction(line);
- EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL);
+ EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO,
+ line, NULL);
}
}
pclose(pp);
exit(0);
} else {
if(waitpid(pid, 0, 0) == -1) {
- _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)"), strerror(errno));
+ _alpm_log(PM_LOG_ERROR,
+ _("call to waitpid failed (%s)"),
+ strerror(errno));
retval = 1;
goto cleanup;
}
@@ -529,14 +626,16 @@
cleanup:
if(strlen(tmpdir) && _alpm_rmrf(tmpdir)) {
- _alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s"), tmpdir);
+ _alpm_log(PM_LOG_WARNING,
+ _("could not remove tmpdir %s"),
+ tmpdir);
}
if(strlen(cwd)) {
chdir(cwd);
}
return(retval);
-}
+} /* Thank goddess, I'm through. */
#ifndef __sun__
static long long get_freespace()
@@ -584,23 +683,16 @@
}
}
freespace = get_freespace();
- _alpm_log(PM_LOG_DEBUG, _("check_freespace: total pkg size: %lld, disk space: %lld"), pkgsize, freespace);
+ _alpm_log(PM_LOG_DEBUG,
+ _("check_freespace: total pkg size: %lld, disk space: %lld"),
+ pkgsize, freespace);
if(pkgsize > freespace) {
if(data) {
- long long *ptr;
- if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
- _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
- pm_errno = PM_ERR_MEMORY;
- return(-1);
- }
+ long long *ptr = pmalloc(sizeof(long long));
*ptr = pkgsize;
*data = alpm_list_add(*data, ptr);
- if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
- _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
- FREELIST(*data);
- pm_errno = PM_ERR_MEMORY;
- return(-1);
- }
+
+ ptr = pmalloc(sizeof(long long));
*ptr = freespace;
*data = alpm_list_add(*data, ptr);
}
@@ -621,8 +713,8 @@
struct tm *lt;
lt = localtime(&t);
sprintf(buffer, "%4d%02d%02d%02d%02d%02d",
- lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
- lt->tm_hour, lt->tm_min, lt->tm_sec);
+ lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
+ lt->tm_hour, lt->tm_min, lt->tm_sec);
buffer[14] = '\0';
}
}
diff -Naur pacman-lib.old/lib/libalpm/util.h pacman-lib/lib/libalpm/util.h
--- pacman-lib.old/lib/libalpm/util.h 2007-01-24 16:09:16.000000000 +0100
+++ pacman-lib/lib/libalpm/util.h 2007-01-24 16:10:13.000000000 +0100
@@ -43,7 +43,9 @@
s1[(len)-1] = 0; \
} while(0)
-#define ARCHIVE_EXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME
+#define ARCHIVE_EXTRACT_FLAGS (ARCHIVE_EXTRACT_OWNER \
+ | ARCHIVE_EXTRACT_PERM \
+ | ARCHIVE_EXTRACT_TIME)
#ifdef ENABLE_NLS
#define _(str) dgettext ("libalpm", str)
@@ -54,18 +56,25 @@
#define SCRIPTLET_START "START "
#define SCRIPTLET_DONE "DONE "
+void *pmalloc(size_t s);
+void *pcalloc(size_t e, size_t s);
+void *prealloc(void *p, size_t s);
+char *pstrdup(const char *s);
+void *palloca(size_t s);
int _alpm_makepath(char *path);
-int _alpm_copyfile(char *src, char *dest);
+int _alpm_copyfile(const char *src, const char *dest);
char *_alpm_strtoupper(char *str);
char *_alpm_strtrim(char *str);
-int _alpm_lckmk(char *file);
-int _alpm_lckrm(char *file);
+int _alpm_lckmk(const char *file);
+int _alpm_lckrm(const char *file);
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
-int _alpm_rmrf(char *path);
-int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
+int _alpm_rmrf(const char *path);
+int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str);
int _alpm_ldconfig(char *root);
#ifdef _ALPM_TRANS_H
-int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
+int _alpm_runscriptlet(const char *util, const char *installfn,
+ const char *script, const char *ver,
+ const char *oldver, pmtrans_t *trans);
#ifndef __sun__
int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data);
#endif
2
1
So, there's been a handful of changes recently. Most have been code
cleanup, but there were some performance improvements and all that
jazz too.
New RC has pkgrel 5 and is here: http://archlinux.org/~aaron/pacman/
In case you haven't been following, this DOES install side-by-side
with the existing pacman. You should have nothing to fear (except
fear itself?)
For the record, this has a changelog in it now, so if you install it
with pacman3 you can then pacman3 -Qc pacman-rc to see the changelog
(currently, abysmally empty - I suck at documentation).
If you guys can, please please test this out.
Here are the pending bugs still:
http://bugs.archlinux.org/index.php?cat=6&type=1
I'd like to get the "Critical" and "High" ones complete and pushed out
of there before giving this URL to the masses (soon, I swear it this
time!) for better testing. All-in-all, I'd like to have nothing but
"Low" / "Very Low" (excepting Feature Requests) before pushing this
out.
Thanks everyone, and special thanks to all the new contributors. We
currently have 5 people stepping up to the plate and helping out with
this, which is great, and highly appreciated.
7
18
I'm just curious why the -w argument was removed from makepkg? It
apparently was removed in rev 1.23:
http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/scripts/makepkg.diff?r1=1.22&r…
I know that aurbuild is currently making use of it, for example.
Scott
7
18
Date: Tuesday, January 23, 2007 @ 22:02:55
Author: aaron
Path: /home/cvs-pacman/pacman-lib
Modified: lib/libalpm/add.c (1.102 -> 1.103)
lib/libalpm/alpm.c (1.104 -> 1.105)
lib/libalpm/alpm.h (1.66 -> 1.67)
lib/libalpm/be_files.c (1.20 -> 1.21)
lib/libalpm/cache.c (1.25 -> 1.26)
lib/libalpm/cache.h (1.9 -> 1.10)
lib/libalpm/conflict.c (1.30 -> 1.31)
lib/libalpm/conflict.h (1.10 -> 1.11)
lib/libalpm/db.c (1.55 -> 1.56) lib/libalpm/db.h (1.22 -> 1.23)
lib/libalpm/deps.c (1.57 -> 1.58) lib/libalpm/deps.h (1.16 -> 1.17)
lib/libalpm/handle.c (1.27 -> 1.28)
lib/libalpm/handle.h (1.13 -> 1.14) lib/libalpm/log.c (1.8 -> 1.9)
lib/libalpm/log.h (1.7 -> 1.8) lib/libalpm/package.c (1.49 -> 1.50)
lib/libalpm/package.h (1.23 -> 1.24)
lib/libalpm/sync.c (1.91 -> 1.92) lib/libalpm/sync.h (1.16 -> 1.17)
lib/libalpm/trans.c (1.30 -> 1.31)
lib/libalpm/trans.h (1.21 -> 1.22)
lib/libalpm/util.c (1.39 -> 1.40) lib/libalpm/util.h (1.18 -> 1.19)
lib/libalpm/versioncmp.c (1.8 -> 1.9)
src/pacman/add.c (1.23 -> 1.24) src/pacman/deptest.c (1.10 -> 1.11)
src/pacman/sync.c (1.97 -> 1.98) src/pacman/trans.c (1.27 -> 1.28)
src/pacman/trans.h (1.5 -> 1.6)
This mainly deals with code clarity- removing currently unneeded
optimizations in order to make the code much more readable and
type-checkable. Every enum in the library now has it's own type that
should be used instead of the generic 'unsigned char'. In addition,
several #define statements dealing with constants were converted to
enums.
Signed-off-by: Dan McGee <dpmcgee(a)gmail.com>
--------------------------+
lib/libalpm/add.c | 2
lib/libalpm/alpm.c | 6 +-
lib/libalpm/alpm.h | 132 +++++++++++++++++++++++++--------------------
lib/libalpm/be_files.c | 2
lib/libalpm/cache.c | 8 +-
lib/libalpm/cache.h | 6 +-
lib/libalpm/conflict.c | 2
lib/libalpm/conflict.h | 2
lib/libalpm/db.c | 2
lib/libalpm/db.h | 20 +++---
lib/libalpm/deps.c | 39 ++++++++-----
lib/libalpm/deps.h | 17 +++--
lib/libalpm/handle.c | 32 ++++++++--
lib/libalpm/handle.h | 4 -
lib/libalpm/log.c | 2
lib/libalpm/log.h | 4 +
lib/libalpm/package.c | 4 -
lib/libalpm/package.h | 15 ++---
lib/libalpm/sync.c | 2
lib/libalpm/sync.h | 2
lib/libalpm/trans.c | 6 +-
lib/libalpm/trans.h | 28 +++++----
lib/libalpm/util.c | 4 -
lib/libalpm/util.h | 2
lib/libalpm/versioncmp.c | 14 ++--
src/pacman/add.c | 14 +++-
src/pacman/deptest.c | 14 +++-
src/pacman/sync.c | 19 ++++--
src/pacman/trans.c | 78 ++++++++++++++------------
src/pacman/trans.h | 8 +-
30 files changed, 290 insertions(+), 200 deletions(-)
Index: pacman-lib/lib/libalpm/add.c
diff -u pacman-lib/lib/libalpm/add.c:1.102 pacman-lib/lib/libalpm/add.c:1.103
--- pacman-lib/lib/libalpm/add.c:1.102 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/add.c Tue Jan 23 22:02:53 2007
@@ -332,7 +332,7 @@
register struct archive *archive;
struct archive_entry *entry;
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
- unsigned char cb_state;
+ pmtransprog_t cb_state;
time_t t;
alpm_list_t *targ, *lp;
Index: pacman-lib/lib/libalpm/alpm.c
diff -u pacman-lib/lib/libalpm/alpm.c:1.104 pacman-lib/lib/libalpm/alpm.c:1.105
--- pacman-lib/lib/libalpm/alpm.c:1.104 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/alpm.c Tue Jan 23 22:02:54 2007
@@ -63,7 +63,7 @@
/* Globals */
pmhandle_t *handle = NULL;
-enum __pmerrno_t pm_errno;
+enum _pmerrno_t pm_errno;
/** \addtogroup alpm_interface Interface Functions
* @brief Functions to initialize and release libalpm
@@ -622,7 +622,9 @@
* @param progress progress callback function pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
char path[PATH_MAX];
Index: pacman-lib/lib/libalpm/alpm.h
diff -u pacman-lib/lib/libalpm/alpm.h:1.66 pacman-lib/lib/libalpm/alpm.h:1.67
--- pacman-lib/lib/libalpm/alpm.h:1.66 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/alpm.h Tue Jan 23 22:02:54 2007
@@ -71,13 +71,15 @@
*/
/* Levels */
-#define PM_LOG_DEBUG 0x01
-#define PM_LOG_ERROR 0x02
-#define PM_LOG_WARNING 0x04
-#define PM_LOG_FLOW1 0x08
-#define PM_LOG_FLOW2 0x10
-#define PM_LOG_FUNCTION 0x20
-#define PM_LOG_DOWNLOAD 0x40
+typedef enum _pmloglevel_t {
+ PM_LOG_DEBUG = 0x01,
+ PM_LOG_ERROR = 0x02,
+ PM_LOG_WARNING = 0x04,
+ PM_LOG_FLOW1 = 0x08,
+ PM_LOG_FLOW2 = 0x10,
+ PM_LOG_FUNCTION = 0x20,
+ PM_LOG_DOWNLOAD = 0x40
+} pmloglevel_t;
typedef void (*alpm_cb_log)(unsigned short, char *);
int alpm_logaction(char *fmt, ...);
@@ -100,8 +102,8 @@
alpm_cb_download alpm_option_get_dlcb();
void alpm_option_set_dlcb(alpm_cb_download cb);
-unsigned char alpm_option_get_logmask();
-void alpm_option_set_logmask(unsigned char mask);
+unsigned short alpm_option_get_logmask();
+void alpm_option_set_logmask(unsigned short mask);
const char *alpm_option_get_root();
void alpm_option_set_root(const char *root);
@@ -115,8 +117,8 @@
const char *alpm_option_get_logfile();
void alpm_option_set_logfile(const char *logfile);
-unsigned char alpm_option_get_usesyslog();
-void alpm_option_set_usesyslog(unsigned char usesyslog);
+unsigned short alpm_option_get_usesyslog();
+void alpm_option_set_usesyslog(unsigned short usesyslog);
alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(char *pkg);
@@ -188,19 +190,26 @@
/* Info parameters */
/* reasons -- ie, why the package was installed */
-#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */
-#define PM_PKG_REASON_DEPEND 1 /* installed as a dependency for another package */
+typedef enum _pmpkgreason_t {
+ PM_PKG_REASON_EXPLICIT = 0, /* explicitly requested by the user */
+ PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */
+} pmpkgreason_t;
/* package name formats */
-#define PM_PKG_WITHOUT_ARCH 0 /* pkgname-pkgver-pkgrel, used under PM_DBPATH */
-#define PM_PKG_WITH_ARCH 1 /* ie, pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR */
+/*
+typedef enum _pmpkghasarch_t {
+ PM_PKG_WITHOUT_ARCH = 0, / pkgname-pkgver-pkgrel, used under PM_DBPATH /
+ PM_PKG_WITH_ARCH = 1 / pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR /
+} pmpkghasarch_t;
+*/
int alpm_pkg_load(char *filename, pmpkg_t **pkg);
int alpm_pkg_free(pmpkg_t *pkg);
int alpm_pkg_checkmd5sum(pmpkg_t *pkg);
int alpm_pkg_checksha1sum(pmpkg_t *pkg);
char *alpm_fetch_pkgurl(char *url);
-int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this_section);
+int alpm_parse_config(char *file, alpm_cb_db_register callback,
+ const char *this_section);
int alpm_pkg_vercmp(const char *ver1, const char *ver2);
char *alpm_pkg_name_hasarch(char *pkgname);
@@ -218,7 +227,7 @@
const char *alpm_pkg_get_arch(pmpkg_t *pkg);
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
@@ -229,7 +238,7 @@
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);
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/*
* Groups
@@ -242,13 +251,13 @@
*/
/* Types */
-enum {
+typedef enum _pmsynctype_t {
PM_SYNC_TYPE_REPLACE = 1,
PM_SYNC_TYPE_UPGRADE,
PM_SYNC_TYPE_DEPEND
-};
+} pmsynctype_t;
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync);
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync);
pmpkg_t *alpm_sync_get_package(pmsyncpkg_t *sync);
void *alpm_sync_get_data(pmsyncpkg_t *sync);
@@ -257,30 +266,32 @@
*/
/* Types */
-enum {
+typedef enum _pmtranstype_t {
PM_TRANS_TYPE_ADD = 1,
PM_TRANS_TYPE_REMOVE,
PM_TRANS_TYPE_UPGRADE,
PM_TRANS_TYPE_SYNC
-};
+} pmtranstype_t;
/* Flags */
-#define PM_TRANS_FLAG_NODEPS 0x01
-#define PM_TRANS_FLAG_FORCE 0x02
-#define PM_TRANS_FLAG_NOSAVE 0x04
-#define PM_TRANS_FLAG_FRESHEN 0x08
-#define PM_TRANS_FLAG_CASCADE 0x10
-#define PM_TRANS_FLAG_RECURSE 0x20
-#define PM_TRANS_FLAG_DBONLY 0x40
-#define PM_TRANS_FLAG_DEPENDSONLY 0x80
-#define PM_TRANS_FLAG_ALLDEPS 0x100
-#define PM_TRANS_FLAG_DOWNLOADONLY 0x200
-#define PM_TRANS_FLAG_NOSCRIPTLET 0x400
-#define PM_TRANS_FLAG_NOCONFLICTS 0x800
-#define PM_TRANS_FLAG_PRINTURIS 0x1000
+typedef enum _pmtransflag_t {
+ PM_TRANS_FLAG_NODEPS = 0x01,
+ PM_TRANS_FLAG_FORCE = 0x02,
+ PM_TRANS_FLAG_NOSAVE = 0x04,
+ PM_TRANS_FLAG_FRESHEN = 0x08,
+ PM_TRANS_FLAG_CASCADE = 0x10,
+ PM_TRANS_FLAG_RECURSE = 0x20,
+ PM_TRANS_FLAG_DBONLY = 0x40,
+ PM_TRANS_FLAG_DEPENDSONLY = 0x80,
+ PM_TRANS_FLAG_ALLDEPS = 0x100,
+ PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
+ PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
+ PM_TRANS_FLAG_NOCONFLICTS = 0x800,
+ PM_TRANS_FLAG_PRINTURIS = 0x1000
+} pmtransflag_t;
/* Transaction Events */
-enum {
+typedef enum _pmtransevt_t {
PM_TRANS_EVT_CHECKDEPS_START = 1,
PM_TRANS_EVT_CHECKDEPS_DONE,
PM_TRANS_EVT_FILECONFLICTS_START,
@@ -306,10 +317,10 @@
PM_TRANS_EVT_PRINTURI,
PM_TRANS_EVT_RETRIEVE_START,
PM_TRANS_EVT_RETRIEVE_LOCAL
-};
+} pmtransevt_t;
/* Transaction Conversations (ie, questions) */
-enum {
+typedef enum _pmtransconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
@@ -317,30 +328,33 @@
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
-};
+} pmtransconv_t;
/* Transaction Progress */
-enum {
+typedef enum _pmtransprog_t {
PM_TRANS_PROGRESS_ADD_START,
PM_TRANS_PROGRESS_UPGRADE_START,
PM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START
-};
+} pmtransprog_t;
/* Transaction Event callback */
-typedef void (*alpm_trans_cb_event)(unsigned char, void *, void *);
+typedef void (*alpm_trans_cb_event)(pmtransevt_t, void *, void *);
/* Transaction Conversation callback */
-typedef void (*alpm_trans_cb_conv)(unsigned char, void *, void *, void *, int *);
+typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
+ void *, int *);
/* Transaction Progress callback */
-typedef void (*alpm_trans_cb_progress)(unsigned char, char *, int, int, int);
+typedef void (*alpm_trans_cb_progress)(pmtransprog_t, char *, int, int, int);
-unsigned char alpm_trans_get_type();
+pmtranstype_t alpm_trans_get_type();
unsigned int alpm_trans_get_flags();
alpm_list_t * alpm_trans_get_targets();
alpm_list_t * alpm_trans_get_packages();
-int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv, alpm_trans_cb_progress cb_progress);
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress cb_progress);
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
int alpm_trans_prepare(alpm_list_t **data);
@@ -351,21 +365,22 @@
* Dependencies and conflicts
*/
-enum {
+typedef enum _pmdepmod_t {
PM_DEP_MOD_ANY = 1,
PM_DEP_MOD_EQ,
PM_DEP_MOD_GE,
PM_DEP_MOD_LE
-};
-enum {
+} pmdepmod_t;
+
+typedef enum _pmdeptype_t {
PM_DEP_TYPE_DEPEND = 1,
PM_DEP_TYPE_REQUIRED,
PM_DEP_TYPE_CONFLICT
-};
+} pmdeptype_t;
const char *alpm_dep_get_target(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss);
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
const char *alpm_dep_get_name(pmdepmissing_t *miss);
const char *alpm_dep_get_version(pmdepmissing_t *miss);
@@ -373,19 +388,20 @@
* File conflicts
*/
-enum {
+typedef enum _pmconflicttype_t {
PM_CONFLICT_TYPE_TARGET = 1,
PM_CONFLICT_TYPE_FILE
-};
+} pmconflicttype_t;
const char *alpm_conflict_get_target(pmconflict_t *conflict);
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict);
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict);
const char *alpm_conflict_get_file(pmconflict_t *conflict);
const char *alpm_conflict_get_ctarget(pmconflict_t *conflict);
/*
* Helpers
*/
+
/* md5sums */
char *alpm_get_md5sum(char *name);
@@ -394,7 +410,7 @@
/*
* Errors
*/
-enum __pmerrno_t {
+enum _pmerrno_t {
PM_ERR_MEMORY = 1,
PM_ERR_SYSTEM,
PM_ERR_BADPERMS,
@@ -466,7 +482,7 @@
PM_ERR_FORK_FAILED
};
-extern enum __pmerrno_t pm_errno;
+extern enum _pmerrno_t pm_errno;
char *alpm_strerror(int err);
Index: pacman-lib/lib/libalpm/be_files.c
diff -u pacman-lib/lib/libalpm/be_files.c:1.20 pacman-lib/lib/libalpm/be_files.c:1.21
--- pacman-lib/lib/libalpm/be_files.c:1.20 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/be_files.c Tue Jan 23 22:02:54 2007
@@ -98,7 +98,7 @@
rewinddir(db->handle);
}
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq)
{
struct dirent *ent = NULL;
struct stat sbuf;
Index: pacman-lib/lib/libalpm/cache.c
diff -u pacman-lib/lib/libalpm/cache.c:1.25 pacman-lib/lib/libalpm/cache.c:1.26
--- pacman-lib/lib/libalpm/cache.c:1.25 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/cache.c Tue Jan 23 22:02:54 2007
@@ -41,12 +41,12 @@
/* Returns a new package cache from db.
* It frees the cache if it already exists.
*/
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
pmpkg_t *info;
int count = 0;
/* The group cache needs INFRQ_DESC as well */
- /*unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
+ /* pmdbinfrq_t infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
if(db == NULL) {
return(-1);
@@ -86,7 +86,7 @@
}
}
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
if(db == NULL) {
return(NULL);
@@ -101,7 +101,7 @@
return(db->pkgcache);
}
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
int reloaded = 0;
/* for each pkg, check and reload if the requested
Index: pacman-lib/lib/libalpm/cache.h
diff -u pacman-lib/lib/libalpm/cache.h:1.9 pacman-lib/lib/libalpm/cache.h:1.10
--- pacman-lib/lib/libalpm/cache.h:1.9 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/cache.h Tue Jan 23 22:02:54 2007
@@ -27,12 +27,12 @@
#include "package.h"
/* packages */
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
/* groups */
int _alpm_db_load_grpcache(pmdb_t *db);
Index: pacman-lib/lib/libalpm/conflict.c
diff -u pacman-lib/lib/libalpm/conflict.c:1.30 pacman-lib/lib/libalpm/conflict.c:1.31
--- pacman-lib/lib/libalpm/conflict.c:1.30 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/conflict.c Tue Jan 23 22:02:54 2007
@@ -368,7 +368,7 @@
return conflict->target;
}
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict)
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
Index: pacman-lib/lib/libalpm/conflict.h
diff -u pacman-lib/lib/libalpm/conflict.h:1.10 pacman-lib/lib/libalpm/conflict.h:1.11
--- pacman-lib/lib/libalpm/conflict.h:1.10 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/conflict.h Tue Jan 23 22:02:54 2007
@@ -28,7 +28,7 @@
struct __pmconflict_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmconflicttype_t type;
char file[CONFLICT_FILE_LEN];
char ctarget[PKG_NAME_LEN];
};
Index: pacman-lib/lib/libalpm/db.c
diff -u pacman-lib/lib/libalpm/db.c:1.55 pacman-lib/lib/libalpm/db.c:1.56
--- pacman-lib/lib/libalpm/db.c:1.55 Mon Jan 22 20:34:58 2007
+++ pacman-lib/lib/libalpm/db.c Tue Jan 23 22:02:54 2007
@@ -110,7 +110,7 @@
char *matched = NULL;
regex_t reg;
- if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) {
+ if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
RET_ERR(PM_ERR_INVALID_REGEX, NULL);
}
Index: pacman-lib/lib/libalpm/db.h
diff -u pacman-lib/lib/libalpm/db.h:1.22 pacman-lib/lib/libalpm/db.h:1.23
--- pacman-lib/lib/libalpm/db.h:1.22 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/db.h Tue Jan 23 22:02:54 2007
@@ -27,12 +27,14 @@
#include <limits.h>
/* Database entries */
-#define INFRQ_NONE 0x00
-#define INFRQ_DESC 0x01
-#define INFRQ_DEPENDS 0x02
-#define INFRQ_FILES 0x04
-#define INFRQ_SCRIPTLET 0x08
-#define INFRQ_ALL 0xFF
+typedef enum _pmdbinfrq_t {
+ INFRQ_NONE = 0x00,
+ INFRQ_DESC = 0x01,
+ INFRQ_DEPENDS = 0x02,
+ INFRQ_FILES = 0x04,
+ INFRQ_SCRIPTLET = 0x08,
+ INFRQ_ALL = 0xFF
+} pmdbinfrq_t;
/* Database */
struct __pmdb_t {
@@ -55,9 +57,9 @@
int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db);
void _alpm_db_rewind(pmdb_t *db);
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq);
-int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info);
-int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq);
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq);
+int _alpm_db_read(pmdb_t *db, pmdbinfrq_t inforeq, pmpkg_t *info);
+int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
int _alpm_db_getlastupdate(pmdb_t *db, char *ts);
int _alpm_db_setlastupdate(pmdb_t *db, char *ts);
Index: pacman-lib/lib/libalpm/deps.c
diff -u pacman-lib/lib/libalpm/deps.c:1.57 pacman-lib/lib/libalpm/deps.c:1.58
--- pacman-lib/lib/libalpm/deps.c:1.57 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/deps.c Tue Jan 23 22:02:54 2007
@@ -44,8 +44,9 @@
extern pmhandle_t *handle;
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
- const char *depname, const char *depversion)
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion)
{
pmdepmissing_t *miss;
@@ -187,7 +188,8 @@
* dependencies can include versions with depmod operators.
*
*/
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages)
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages)
{
pmdepend_t depend;
alpm_list_t *i, *j, *k;
@@ -224,7 +226,7 @@
continue;
}
if(_alpm_pkg_isin(p->name, packages)) {
- /* this package is also in the upgrade list, so don't worry about it */
+ /* this package also in the upgrade list, so don't worry about it */
continue;
}
_alpm_db_read(db, INFRQ_DEPENDS, p);
@@ -246,8 +248,10 @@
FREELISTPTR(provides);
}
if(!_alpm_depcmp(tp, &depend)) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
- miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ depend.name, p->name);
+ miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -278,7 +282,8 @@
_alpm_splitdep((char *)j->data, &depend);
found = 0;
/* check database for literal packages */
- for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); k && !found; k = k->next) {
+ for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS);
+ k && !found; k = k->next) {
pmpkg_t *p = (pmpkg_t *)k->data;
found = _alpm_depcmp(p, &depend);
}
@@ -316,8 +321,9 @@
/* else if still not found... */
if(!found) {
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
- depend.name, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
+ depend.name, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -363,8 +369,10 @@
}
}
if(!found) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), reqname, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ reqname, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED,
+ PM_DEP_MOD_ANY, j->data, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -512,8 +520,9 @@
*
* make sure *list and *trail are already initialized
*/
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data)
{
alpm_list_t *i, *j;
alpm_list_t *targ;
@@ -647,7 +656,7 @@
return miss->target;
}
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -656,7 +665,7 @@
return miss->type;
}
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss)
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
Index: pacman-lib/lib/libalpm/deps.h
diff -u pacman-lib/lib/libalpm/deps.h:1.16 pacman-lib/lib/libalpm/deps.h:1.17
--- pacman-lib/lib/libalpm/deps.h:1.16 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/deps.h Tue Jan 23 22:02:54 2007
@@ -30,7 +30,7 @@
/* Dependency */
struct __pmdepend_t {
- unsigned char mod;
+ pmdepmod_t mod;
char name[PKG_NAME_LEN];
char version[PKG_VERSION_LEN];
};
@@ -38,19 +38,22 @@
/* Missing dependency */
struct __pmdepmissing_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmdeptype_t type;
pmdepend_t depend;
};
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
- const char *depname, const char *depversion);
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion);
int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages);
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data);
#endif /* _ALPM_DEPS_H */
Index: pacman-lib/lib/libalpm/handle.c
diff -u pacman-lib/lib/libalpm/handle.c:1.27 pacman-lib/lib/libalpm/handle.c:1.28
--- pacman-lib/lib/libalpm/handle.c:1.27 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/handle.c Tue Jan 23 22:02:54 2007
@@ -117,12 +117,12 @@
alpm_cb_log alpm_option_get_logcb() { return handle->logcb; }
alpm_cb_download alpm_option_get_dlcb() { return handle->dlcb; }
-unsigned char alpm_option_get_logmask() { return handle->logmask; }
+unsigned short alpm_option_get_logmask() { return handle->logmask; }
const char *alpm_option_get_root() { return handle->root; }
const char *alpm_option_get_dbpath() { return handle->dbpath; }
const char *alpm_option_get_cachedir() { return handle->cachedir; }
const char *alpm_option_get_logfile() { return handle->logfile; }
-unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
+unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
@@ -135,13 +135,16 @@
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
-alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
+alpm_list_t *alpm_option_get_syncdbs()
+{
+ return handle->dbs_sync;
+}
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
void alpm_option_set_dlcb(alpm_cb_download cb) { handle->dlcb = cb; }
-void alpm_option_set_logmask(unsigned char mask) { handle->logmask = mask; }
+void alpm_option_set_logmask(unsigned short mask) { handle->logmask = mask; }
void alpm_option_set_root(const char *root)
{
@@ -176,12 +179,16 @@
}
}
-void alpm_option_set_usesyslog(unsigned char usesyslog) { handle->usesyslog = usesyslog; }
+void alpm_option_set_usesyslog(unsigned short usesyslog)
+{
+ handle->usesyslog = usesyslog;
+}
void alpm_option_add_noupgrade(char *pkg)
{
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
+
void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
if(handle->noupgrade) FREELIST(handle->noupgrade);
@@ -218,7 +225,10 @@
if(holdpkgs) handle->holdpkg = holdpkgs;
}
-void alpm_option_set_upgradedelay(time_t delay) { handle->upgradedelay = delay; }
+void alpm_option_set_upgradedelay(time_t delay)
+{
+ handle->upgradedelay = delay;
+}
void alpm_option_set_xfercommand(const char *cmd)
{
@@ -226,7 +236,10 @@
if(cmd) handle->xfercommand = strdup(cmd);
}
-void alpm_option_set_nopassiveftp(unsigned short nopasv) { handle->nopassiveftp = nopasv; }
+void alpm_option_set_nopassiveftp(unsigned short nopasv)
+{
+ handle->nopassiveftp = nopasv;
+}
void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
@@ -239,6 +252,9 @@
if(handle->needles) FREELIST(handle->needles);
if(needles) handle->needles = needles;
}
-void alpm_option_set_usecolor(unsigned short usecolor) { handle->use_color = usecolor; }
+void alpm_option_set_usecolor(unsigned short usecolor)
+{
+ handle->use_color = usecolor;
+}
/* vim: set ts=2 sw=2 et: */
Index: pacman-lib/lib/libalpm/handle.h
diff -u pacman-lib/lib/libalpm/handle.h:1.13 pacman-lib/lib/libalpm/handle.h:1.14
--- pacman-lib/lib/libalpm/handle.h:1.13 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/handle.h Tue Jan 23 22:02:54 2007
@@ -45,12 +45,12 @@
/* options */
alpm_cb_log logcb; /* Log callback function */
alpm_cb_download dlcb; /* Download callback function */
- unsigned char logmask; /* Output mask for logging functions */
+ unsigned short logmask; /* Output mask for logging functions */
char *root; /* Root path, default '/' */
char *dbpath; /* Base path to pacman's DBs */
char *cachedir; /* Base path to pacman's cache */
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
- unsigned char usesyslog; /* Use syslog instead of logfile? */
+ unsigned short usesyslog; /* Use syslog instead of logfile? */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
alpm_list_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
Index: pacman-lib/lib/libalpm/log.c
diff -u pacman-lib/lib/libalpm/log.c:1.8 pacman-lib/lib/libalpm/log.c:1.9
--- pacman-lib/lib/libalpm/log.c:1.8 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/log.c Tue Jan 23 22:02:54 2007
@@ -27,7 +27,7 @@
#include "alpm.h"
#include "log.h"
-void _alpm_log(unsigned char flag, char *fmt, ...)
+void _alpm_log(pmloglevel_t flag, char *fmt, ...)
{
alpm_cb_log logcb = alpm_option_get_logcb();
if(logcb == NULL) {
Index: pacman-lib/lib/libalpm/log.h
diff -u pacman-lib/lib/libalpm/log.h:1.7 pacman-lib/lib/libalpm/log.h:1.8
--- pacman-lib/lib/libalpm/log.h:1.7 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/log.h Tue Jan 23 22:02:54 2007
@@ -21,9 +21,11 @@
#ifndef _ALPM_LOG_H
#define _ALPM_LOG_H
+#include "alpm.h"
+
#define LOG_STR_LEN 1024
-void _alpm_log(unsigned char flag, char *fmt, ...);
+void _alpm_log(pmloglevel_t flag, char *fmt, ...);
#endif /* _ALPM_LOG_H */
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.49 pacman-lib/lib/libalpm/package.c:1.50
--- pacman-lib/lib/libalpm/package.c:1.49 Mon Jan 22 11:16:51 2007
+++ pacman-lib/lib/libalpm/package.c Tue Jan 23 22:02:54 2007
@@ -606,7 +606,7 @@
return pkg->isize;
}
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg)
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -741,7 +741,7 @@
return pkg->backup;
}
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg)
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
Index: pacman-lib/lib/libalpm/package.h
diff -u pacman-lib/lib/libalpm/package.h:1.23 pacman-lib/lib/libalpm/package.h:1.24
--- pacman-lib/lib/libalpm/package.h:1.23 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/package.h Tue Jan 23 22:02:54 2007
@@ -30,11 +30,12 @@
#endif
#include "alpm.h"
+#include "db.h"
-enum {
+typedef enum _pmpkgfrom_t {
PKG_FROM_CACHE = 1,
PKG_FROM_FILE
-};
+} pmpkgfrom_t;
/* Packages */
#define PKG_FILENAME_LEN 512
@@ -65,10 +66,10 @@
char arch[PKG_ARCH_LEN];
unsigned long size;
unsigned long isize;
- unsigned char scriptlet;
- unsigned char force;
+ unsigned short scriptlet;
+ unsigned short force;
time_t date;
- unsigned char reason;
+ pmpkgreason_t reason;
alpm_list_t *desc_localized;
alpm_list_t *license;
alpm_list_t *replaces;
@@ -81,9 +82,9 @@
alpm_list_t *conflicts;
alpm_list_t *provides;
/* internal */
- unsigned char origin;
+ unsigned short origin;
void *data;
- unsigned char infolevel;
+ pmdbinfrq_t infolevel;
};
#define FREEPKG(p) do { if(p){_alpm_pkg_free(p); p = NULL;}} while(0)
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.91 pacman-lib/lib/libalpm/sync.c:1.92
--- pacman-lib/lib/libalpm/sync.c:1.91 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/sync.c Tue Jan 23 22:02:54 2007
@@ -1069,7 +1069,7 @@
return(-1);
}
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync)
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync)
{
/* Sanity checks */
ASSERT(sync != NULL, return(-1));
Index: pacman-lib/lib/libalpm/sync.h
diff -u pacman-lib/lib/libalpm/sync.h:1.16 pacman-lib/lib/libalpm/sync.h:1.17
--- pacman-lib/lib/libalpm/sync.h:1.16 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/sync.h Tue Jan 23 22:02:54 2007
@@ -27,7 +27,7 @@
/* Sync package */
struct __pmsyncpkg_t {
- unsigned char type;
+ pmsynctype_t type;
pmpkg_t *pkg;
void *data;
};
Index: pacman-lib/lib/libalpm/trans.c
diff -u pacman-lib/lib/libalpm/trans.c:1.30 pacman-lib/lib/libalpm/trans.c:1.31
--- pacman-lib/lib/libalpm/trans.c:1.30 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/trans.c Tue Jan 23 22:02:54 2007
@@ -85,7 +85,9 @@
FREE(trans);
}
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
/* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -226,7 +228,7 @@
return(0);
}
-unsigned char alpm_trans_get_type()
+pmtranstype_t alpm_trans_get_type()
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
Index: pacman-lib/lib/libalpm/trans.h
diff -u pacman-lib/lib/libalpm/trans.h:1.21 pacman-lib/lib/libalpm/trans.h:1.22
--- pacman-lib/lib/libalpm/trans.h:1.21 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/trans.h Tue Jan 23 22:02:54 2007
@@ -26,11 +26,21 @@
#include "alpm.h"
+typedef enum _pmtransstate_t {
+ STATE_IDLE = 0,
+ STATE_INITIALIZED,
+ STATE_PREPARED,
+ STATE_DOWNLOADING,
+ STATE_COMMITING,
+ STATE_COMMITED,
+ STATE_INTERRUPTED
+} pmtransstate_t;
+
/* Transaction */
struct __pmtrans_t {
- unsigned char type;
+ pmtranstype_t type;
unsigned int flags;
- unsigned char state;
+ pmtransstate_t state;
alpm_list_t *targets; /* alpm_list_t of (char *) */
alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
alpm_list_t *skiplist; /* alpm_list_t of (char *) */
@@ -39,16 +49,6 @@
alpm_trans_cb_progress cb_progress;
};
-enum {
- STATE_IDLE = 0,
- STATE_INITIALIZED,
- STATE_PREPARED,
- STATE_DOWNLOADING,
- STATE_COMMITING,
- STATE_COMMITED,
- STATE_INTERRUPTED
-};
-
#define FREETRANS(p) \
do { \
if(p) { \
@@ -77,7 +77,9 @@
pmtrans_t *_alpm_trans_new(void);
void _alpm_trans_free(void *data);
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress);
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int 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);
Index: pacman-lib/lib/libalpm/util.c
diff -u pacman-lib/lib/libalpm/util.c:1.39 pacman-lib/lib/libalpm/util.c:1.40
--- pacman-lib/lib/libalpm/util.c:1.39 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/util.c Tue Jan 23 22:02:54 2007
@@ -66,7 +66,7 @@
#ifdef __sun__
/* This is a replacement for strsep which is not portable (missing on Solaris).
- * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
+ * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
char* strsep(char** str, const char* delims)
{
char* token;
@@ -342,7 +342,7 @@
return(0);
}
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str)
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
{
_alpm_log(PM_LOG_DEBUG, _("logaction called: %s"), str);
Index: pacman-lib/lib/libalpm/util.h
diff -u pacman-lib/lib/libalpm/util.h:1.18 pacman-lib/lib/libalpm/util.h:1.19
--- pacman-lib/lib/libalpm/util.h:1.18 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/util.h Tue Jan 23 22:02:54 2007
@@ -62,7 +62,7 @@
int _alpm_lckrm(char *file);
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(char *path);
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str);
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
int _alpm_ldconfig(char *root);
#ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
Index: pacman-lib/lib/libalpm/versioncmp.c
diff -u pacman-lib/lib/libalpm/versioncmp.c:1.8 pacman-lib/lib/libalpm/versioncmp.c:1.9
--- pacman-lib/lib/libalpm/versioncmp.c:1.8 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/versioncmp.c Tue Jan 23 22:02:54 2007
@@ -253,17 +253,19 @@
} else {
int cmp = _alpm_versioncmp(pkg->version, dep->version);
switch(dep->mod) {
- case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
- case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
- case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
+ case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ default: equal = 1; break;
}
}
char *mod = "~=";
switch(dep->mod) {
- case PM_DEP_MOD_EQ: mod = "=="; break;
- case PM_DEP_MOD_GE: mod = ">="; break;
- case PM_DEP_MOD_LE: mod = "<="; break;
+ case PM_DEP_MOD_EQ: mod = "=="; break;
+ case PM_DEP_MOD_GE: mod = ">="; break;
+ case PM_DEP_MOD_LE: mod = "<="; break;
+ default: break;
}
if(strlen(dep->version) > 0) {
Index: pacman-lib/src/pacman/add.c
diff -u pacman-lib/src/pacman/add.c:1.23 pacman-lib/src/pacman/add.c:1.24
--- pacman-lib/src/pacman/add.c:1.23 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/add.c Tue Jan 23 22:02:55 2007
@@ -96,9 +96,17 @@
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
Index: pacman-lib/src/pacman/deptest.c
diff -u pacman-lib/src/pacman/deptest.c:1.10 pacman-lib/src/pacman/deptest.c:1.11
--- pacman-lib/src/pacman/deptest.c:1.10 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/deptest.c Tue Jan 23 22:02:55 2007
@@ -114,9 +114,17 @@
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.97 pacman-lib/src/pacman/sync.c:1.98
--- pacman-lib/src/pacman/sync.c:1.97 Tue Jan 23 15:09:18 2007
+++ pacman-lib/src/pacman/sync.c Tue Jan 23 22:02:55 2007
@@ -579,12 +579,21 @@
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
- alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"),
- alpm_dep_get_name(miss));
+ alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ?
+ _("requires") : _("is required by"),
+ alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
Index: pacman-lib/src/pacman/trans.c
diff -u pacman-lib/src/pacman/trans.c:1.27 pacman-lib/src/pacman/trans.c:1.28
--- pacman-lib/src/pacman/trans.c:1.27 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/trans.c Tue Jan 23 22:02:55 2007
@@ -44,7 +44,7 @@
/* Callback to handle transaction events
*/
-void cb_trans_evt(unsigned char event, void *data1, void *data2)
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
{
char str[LOG_STR_LEN] = "";
char out[PATH_MAX];
@@ -53,38 +53,42 @@
switch(event) {
case PM_TRANS_EVT_CHECKDEPS_START:
pm_fprintf(stderr, NL, _("checking dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) {
MSG(NL, _("checking for file conflicts... "));
}
- break;
+ break;
+ case PM_TRANS_EVT_CLEANUP_START:
+ pm_fprintf(stderr, NL, _("resolving dependencies... "));
+ break;
case PM_TRANS_EVT_RESOLVEDEPS_START:
pm_fprintf(stderr, NL, _("resolving dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_INTERCONFLICTS_START:
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_CHECKDEPS_DONE:
+ case PM_TRANS_EVT_CLEANUP_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
pm_fprintf(stderr, CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_EXTRACT_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_START:
if(config->noprogressbar) {
MSG(NL, _("installing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -93,12 +97,12 @@
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_REMOVE_START:
if(config->noprogressbar) {
MSG(NL, _("removing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_REMOVE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -107,12 +111,12 @@
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_START:
if(config->noprogressbar) {
MSG(NL, _("upgrading %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -122,34 +126,34 @@
(char *)alpm_pkg_get_version(data2),
(char *)alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_START:
MSG(NL, _("checking package integrity... "));
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_DONE:
MSG(CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_INFO:
MSG(NL, "%s\n", (char*)data1);
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_START:
MSG(NL, (char*)data1);
MSG(CL, "...");
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_DONE:
if(!(long)data1) {
MSG(CL, _(" done.\n"));
} else {
MSG(CL, _(" failed.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_PRINTURI:
MSG(NL, "%s/%s\n", (char*)data1, (char*)data2);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_START:
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
fflush(stdout);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_LOCAL:
MSG(NL, " %s [", (char*)data1);
unsigned int maxcols = getcols();
@@ -159,11 +163,12 @@
MSG(CL, " ");
}
fputs(_("] 100% LOCAL "), stdout);
- break;
+ break;
}
}
-void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response)
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response)
{
char str[LOG_STR_LEN] = "";
@@ -181,7 +186,7 @@
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REMOVE_HOLDPKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REMOVE_HOLDPKG) {
@@ -190,11 +195,11 @@
*response = 0;
}
} else {
- snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
+ snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
alpm_pkg_get_name(data1));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REPLACE_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REPLACE_PKG) {
@@ -209,7 +214,7 @@
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_CONFLICT_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CONFLICT_PKG) {
@@ -224,7 +229,7 @@
(char *)data2);
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_NEWER:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_NEWER) {
@@ -242,7 +247,7 @@
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_UPTODATE:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_UPTODATE) {
@@ -260,7 +265,7 @@
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_CORRUPTED_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CORRUPTED_PKG) {
@@ -277,11 +282,12 @@
*response = 1;
}
}
- break;
+ break;
}
}
-void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain)
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain)
{
static int lasthash = 0, mouth = 0;
int i, hash;
@@ -311,19 +317,19 @@
switch (event) {
case PM_TRANS_PROGRESS_ADD_START:
ptr = _("installing");
- break;
+ break;
case PM_TRANS_PROGRESS_UPGRADE_START:
ptr = _("upgrading");
- break;
+ break;
case PM_TRANS_PROGRESS_REMOVE_START:
ptr = _("removing");
- break;
+ break;
case PM_TRANS_PROGRESS_CONFLICTS_START:
ptr = _("checking for file conflicts");
- break;
+ break;
}
hash=percent*progresslen/100;
Index: pacman-lib/src/pacman/trans.h
diff -u pacman-lib/src/pacman/trans.h:1.5 pacman-lib/src/pacman/trans.h:1.6
--- pacman-lib/src/pacman/trans.h:1.5 Sun Oct 15 15:34:53 2006
+++ pacman-lib/src/pacman/trans.h Tue Jan 23 22:02:55 2007
@@ -22,12 +22,14 @@
#define _PM_TRANS_H
/* callback to handle messages/notifications from pacman transactions */
-void cb_trans_evt(unsigned char event, void *data1, void *data2);
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2);
/* callback to handle questions from pacman transactions (yes/no) */
-void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response);
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response);
-void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain);
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain);
#endif /* _PM_TRANS_H */
1
0
Okay...blame wizzomafizzo :P. Because of the new way makepkg deals with files
(not using the extension), files that are actually zipfiles but called something
else that do not need to be extracted will be extracted (this is wizz's
example). Best example I can think of is like a .pk3 file for some games
(which I think is really just a zipfile). Anyway....we came up with the idea of
a noextract=(...) field in the PKGBUILD and the patch is below.
I'm not entirely too sure on whether or not this is entirely necessary...but oh
well.
Patch is below.
~ Jamie / yankees26
Signed-off-by: James Rosten <seinfeld90(a)gmail.com>
Index: makepkg
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/scripts/makepkg,v
retrieving revision 1.33
diff -u -r1.33 makepkg
--- makepkg 22 Jan 2007 19:26:23 -0000 1.33
+++ makepkg 23 Jan 2007 05:34:25 -0000
@@ -425,7 +425,7 @@
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
unset replaces depends conflicts backup source install build makedepends
-unset options
+unset options noextract
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
@@ -680,7 +680,17 @@
msg "Extracting Sources..."
for netfile in "${source[@]}"; do
unziphack=0
+ NoExtract=0
file=$(strip_url "$netfile")
+ for skipfile in "${noextract[@]}"; do
+ if [ "$skipfile" = "$file" ]; then
+ NoExtract=1
+ break;
+ fi
+ done
+ if [ $NoExtract -eq 1 ]; then
+ continue;
+ fi
# fix flyspray #6246
file_type=$(file -biz "$file")
unset cmd
7
9
[pacman-dev] [patch] remove use of unsigned char for enums, convert #define constants to enums
by Dan McGee 23 Jan '07
by Dan McGee 23 Jan '07
23 Jan '07
This mainly deals with code clarity- removing currently unneeded
optimizations in order to make the code much more readable and
type-checkable. Every enum in the library now has it's own type that
should be used instead of the generic 'unsigned char'. In addition,
several #define statements dealing with constants were converted to
enums.
Signed-off-by: Dan McGee <dpmcgee(a)gmail.com>
diff -uarp pacman-lib.orig/lib/libalpm/add.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/add.c
--- pacman-lib.orig/lib/libalpm/add.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/add.c 2007-01-19
20:26:21.000000000 -0500
@@ -332,7 +332,7 @@ int _alpm_add_commit(pmtrans_t *trans, p
register struct archive *archive;
struct archive_entry *entry;
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
- unsigned char cb_state;
+ pmtransprog_t cb_state;
time_t t;
alpm_list_t *targ, *lp;
diff -uarp pacman-lib.orig/lib/libalpm/alpm.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/alpm.c
--- pacman-lib.orig/lib/libalpm/alpm.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/alpm.c 2007-01-19
20:26:21.000000000 -0500
@@ -63,7 +63,7 @@
/* Globals */
pmhandle_t *handle = NULL;
-enum __pmerrno_t pm_errno;
+enum _pmerrno_t pm_errno;
/** \addtogroup alpm_interface Interface Functions
* @brief Functions to initialize and release libalpm
@@ -622,7 +622,9 @@ alpm_list_t *alpm_db_search(pmdb_t *db)
* @param progress progress callback function pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(unsigned char type, unsigned int flags,
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress progress)
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
char path[PATH_MAX];
diff -uarp pacman-lib.orig/lib/libalpm/alpm.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/alpm.h
--- pacman-lib.orig/lib/libalpm/alpm.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/alpm.h 2007-01-19
20:54:46.000000000 -0500
@@ -71,13 +71,15 @@ int alpm_release(void);
*/
/* Levels */
-#define PM_LOG_DEBUG 0x01
-#define PM_LOG_ERROR 0x02
-#define PM_LOG_WARNING 0x04
-#define PM_LOG_FLOW1 0x08
-#define PM_LOG_FLOW2 0x10
-#define PM_LOG_FUNCTION 0x20
-#define PM_LOG_DOWNLOAD 0x40
+typedef enum _pmloglevel_t {
+ PM_LOG_DEBUG = 0x01,
+ PM_LOG_ERROR = 0x02,
+ PM_LOG_WARNING = 0x04,
+ PM_LOG_FLOW1 = 0x08,
+ PM_LOG_FLOW2 = 0x10,
+ PM_LOG_FUNCTION = 0x20,
+ PM_LOG_DOWNLOAD = 0x40
+} pmloglevel_t;
typedef void (*alpm_cb_log)(unsigned short, char *);
int alpm_logaction(char *fmt, ...);
@@ -100,8 +102,8 @@ void alpm_option_set_logcb(alpm_cb_log c
alpm_cb_download alpm_option_get_dlcb();
void alpm_option_set_dlcb(alpm_cb_download cb);
-unsigned char alpm_option_get_logmask();
-void alpm_option_set_logmask(unsigned char mask);
+unsigned short alpm_option_get_logmask();
+void alpm_option_set_logmask(unsigned short mask);
const char *alpm_option_get_root();
void alpm_option_set_root(const char *root);
@@ -115,8 +117,8 @@ void alpm_option_set_cachedir(const char
const char *alpm_option_get_logfile();
void alpm_option_set_logfile(const char *logfile);
-unsigned char alpm_option_get_usesyslog();
-void alpm_option_set_usesyslog(unsigned char usesyslog);
+unsigned short alpm_option_get_usesyslog();
+void alpm_option_set_usesyslog(unsigned short usesyslog);
alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(char *pkg);
@@ -188,19 +190,26 @@ alpm_list_t *alpm_db_search(pmdb_t *db);
/* Info parameters */
/* reasons -- ie, why the package was installed */
-#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */
-#define PM_PKG_REASON_DEPEND 1 /* installed as a dependency for
another package */
+typedef enum _pmpkgreason_t {
+ PM_PKG_REASON_EXPLICIT = 0, /* explicitly requested by the user */
+ PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */
+} pmpkgreason_t;
/* package name formats */
-#define PM_PKG_WITHOUT_ARCH 0 /* pkgname-pkgver-pkgrel, used under PM_DBPATH */
-#define PM_PKG_WITH_ARCH 1 /* ie, pkgname-pkgver-pkgrel-arch, used
under PM_CACHEDIR */
+/*
+typedef enum _pmpkghasarch_t {
+ PM_PKG_WITHOUT_ARCH = 0, / pkgname-pkgver-pkgrel, used under PM_DBPATH /
+ PM_PKG_WITH_ARCH = 1 / pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR /
+} pmpkghasarch_t;
+*/
int alpm_pkg_load(char *filename, pmpkg_t **pkg);
int alpm_pkg_free(pmpkg_t *pkg);
int alpm_pkg_checkmd5sum(pmpkg_t *pkg);
int alpm_pkg_checksha1sum(pmpkg_t *pkg);
char *alpm_fetch_pkgurl(char *url);
-int alpm_parse_config(char *file, alpm_cb_db_register callback, const
char *this_section);
+int alpm_parse_config(char *file, alpm_cb_db_register callback,
+ const char *this_section);
int alpm_pkg_vercmp(const char *ver1, const char *ver2);
char *alpm_pkg_name_hasarch(char *pkgname);
@@ -218,7 +227,7 @@ const char *alpm_pkg_get_sha1sum(pmpkg_t
const char *alpm_pkg_get_arch(pmpkg_t *pkg);
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
@@ -229,7 +238,7 @@ alpm_list_t *alpm_pkg_get_provides(pmpkg
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);
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/*
* Groups
@@ -242,13 +251,13 @@ alpm_list_t *alpm_grp_get_packages(pmgrp
*/
/* Types */
-enum {
+typedef enum _pmsynctype_t {
PM_SYNC_TYPE_REPLACE = 1,
PM_SYNC_TYPE_UPGRADE,
PM_SYNC_TYPE_DEPEND
-};
+} pmsynctype_t;
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync);
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync);
pmpkg_t *alpm_sync_get_package(pmsyncpkg_t *sync);
void *alpm_sync_get_data(pmsyncpkg_t *sync);
@@ -257,30 +266,32 @@ void *alpm_sync_get_data(pmsyncpkg_t *sy
*/
/* Types */
-enum {
+typedef enum _pmtranstype_t {
PM_TRANS_TYPE_ADD = 1,
PM_TRANS_TYPE_REMOVE,
PM_TRANS_TYPE_UPGRADE,
PM_TRANS_TYPE_SYNC
-};
+} pmtranstype_t;
/* Flags */
-#define PM_TRANS_FLAG_NODEPS 0x01
-#define PM_TRANS_FLAG_FORCE 0x02
-#define PM_TRANS_FLAG_NOSAVE 0x04
-#define PM_TRANS_FLAG_FRESHEN 0x08
-#define PM_TRANS_FLAG_CASCADE 0x10
-#define PM_TRANS_FLAG_RECURSE 0x20
-#define PM_TRANS_FLAG_DBONLY 0x40
-#define PM_TRANS_FLAG_DEPENDSONLY 0x80
-#define PM_TRANS_FLAG_ALLDEPS 0x100
-#define PM_TRANS_FLAG_DOWNLOADONLY 0x200
-#define PM_TRANS_FLAG_NOSCRIPTLET 0x400
-#define PM_TRANS_FLAG_NOCONFLICTS 0x800
-#define PM_TRANS_FLAG_PRINTURIS 0x1000
+typedef enum _pmtransflag_t {
+ PM_TRANS_FLAG_NODEPS = 0x01,
+ PM_TRANS_FLAG_FORCE = 0x02,
+ PM_TRANS_FLAG_NOSAVE = 0x04,
+ PM_TRANS_FLAG_FRESHEN = 0x08,
+ PM_TRANS_FLAG_CASCADE = 0x10,
+ PM_TRANS_FLAG_RECURSE = 0x20,
+ PM_TRANS_FLAG_DBONLY = 0x40,
+ PM_TRANS_FLAG_DEPENDSONLY = 0x80,
+ PM_TRANS_FLAG_ALLDEPS = 0x100,
+ PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
+ PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
+ PM_TRANS_FLAG_NOCONFLICTS = 0x800,
+ PM_TRANS_FLAG_PRINTURIS = 0x1000
+} pmtransflag_t;
/* Transaction Events */
-enum {
+typedef enum _pmtransevt_t {
PM_TRANS_EVT_CHECKDEPS_START = 1,
PM_TRANS_EVT_CHECKDEPS_DONE,
PM_TRANS_EVT_FILECONFLICTS_START,
@@ -306,10 +317,10 @@ enum {
PM_TRANS_EVT_PRINTURI,
PM_TRANS_EVT_RETRIEVE_START,
PM_TRANS_EVT_RETRIEVE_LOCAL
-};
+} pmtransevt_t;
/* Transaction Conversations (ie, questions) */
-enum {
+typedef enum _pmtransconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
@@ -317,30 +328,33 @@ enum {
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
-};
+} pmtransconv_t;
/* Transaction Progress */
-enum {
+typedef enum _pmtransprog_t {
PM_TRANS_PROGRESS_ADD_START,
PM_TRANS_PROGRESS_UPGRADE_START,
PM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START
-};
+} pmtransprog_t;
/* Transaction Event callback */
-typedef void (*alpm_trans_cb_event)(unsigned char, void *, void *);
+typedef void (*alpm_trans_cb_event)(pmtransevt_t, void *, void *);
/* Transaction Conversation callback */
-typedef void (*alpm_trans_cb_conv)(unsigned char, void *, void *,
void *, int *);
+typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
+ void *, int *);
/* Transaction Progress callback */
-typedef void (*alpm_trans_cb_progress)(unsigned char, char *, int, int, int);
+typedef void (*alpm_trans_cb_progress)(pmtransprog_t, char *, int, int, int);
-unsigned char alpm_trans_get_type();
+pmtranstype_t alpm_trans_get_type();
unsigned int alpm_trans_get_flags();
alpm_list_t * alpm_trans_get_targets();
alpm_list_t * alpm_trans_get_packages();
-int alpm_trans_init(unsigned char type, unsigned int flags,
alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress cb_progress);
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress cb_progress);
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
int alpm_trans_prepare(alpm_list_t **data);
@@ -351,21 +365,22 @@ int alpm_trans_release(void);
* Dependencies and conflicts
*/
-enum {
+typedef enum _pmdepmod_t {
PM_DEP_MOD_ANY = 1,
PM_DEP_MOD_EQ,
PM_DEP_MOD_GE,
PM_DEP_MOD_LE
-};
-enum {
+} pmdepmod_t;
+
+typedef enum _pmdeptype_t {
PM_DEP_TYPE_DEPEND = 1,
PM_DEP_TYPE_REQUIRED,
PM_DEP_TYPE_CONFLICT
-};
+} pmdeptype_t;
const char *alpm_dep_get_target(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss);
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
const char *alpm_dep_get_name(pmdepmissing_t *miss);
const char *alpm_dep_get_version(pmdepmissing_t *miss);
@@ -373,19 +388,20 @@ const char *alpm_dep_get_version(pmdepmi
* File conflicts
*/
-enum {
+typedef enum _pmconflicttype_t {
PM_CONFLICT_TYPE_TARGET = 1,
PM_CONFLICT_TYPE_FILE
-};
+} pmconflicttype_t;
const char *alpm_conflict_get_target(pmconflict_t *conflict);
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict);
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict);
const char *alpm_conflict_get_file(pmconflict_t *conflict);
const char *alpm_conflict_get_ctarget(pmconflict_t *conflict);
/*
* Helpers
*/
+
/* md5sums */
char *alpm_get_md5sum(char *name);
@@ -394,7 +410,7 @@ char *alpm_get_sha1sum(char *name);
/*
* Errors
*/
-enum __pmerrno_t {
+enum _pmerrno_t {
PM_ERR_MEMORY = 1,
PM_ERR_SYSTEM,
PM_ERR_BADPERMS,
@@ -466,7 +482,7 @@ enum __pmerrno_t {
PM_ERR_FORK_FAILED
};
-extern enum __pmerrno_t pm_errno;
+extern enum _pmerrno_t pm_errno;
char *alpm_strerror(int err);
diff -uarp pacman-lib.orig/lib/libalpm/be_files.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/be_files.c
--- pacman-lib.orig/lib/libalpm/be_files.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/be_files.c 2007-01-19
20:26:21.000000000 -0500
@@ -98,7 +98,7 @@ void _alpm_db_rewind(pmdb_t *db)
rewinddir(db->handle);
}
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq)
{
struct dirent *ent = NULL;
struct stat sbuf;
diff -uarp pacman-lib.orig/lib/libalpm/cache.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/cache.c
--- pacman-lib.orig/lib/libalpm/cache.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/cache.c 2007-01-19
20:26:21.000000000 -0500
@@ -41,12 +41,12 @@
/* Returns a new package cache from db.
* It frees the cache if it already exists.
*/
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
pmpkg_t *info;
int count = 0;
/* The group cache needs INFRQ_DESC as well */
- /*unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
+ /* pmdbinfrq_t infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
if(db == NULL) {
return(-1);
@@ -86,7 +86,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
}
}
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
if(db == NULL) {
return(NULL);
@@ -101,7 +101,7 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_
return(db->pkgcache);
}
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
int reloaded = 0;
/* for each pkg, check and reload if the requested
diff -uarp pacman-lib.orig/lib/libalpm/cache.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/cache.h
--- pacman-lib.orig/lib/libalpm/cache.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/cache.h 2007-01-19
20:26:21.000000000 -0500
@@ -27,12 +27,12 @@
#include "package.h"
/* packages */
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
/* groups */
int _alpm_db_load_grpcache(pmdb_t *db);
diff -uarp pacman-lib.orig/lib/libalpm/conflict.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/conflict.c
--- pacman-lib.orig/lib/libalpm/conflict.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/conflict.c 2007-01-19
20:26:21.000000000 -0500
@@ -368,7 +368,7 @@ const char *alpm_conflict_get_target(pmc
return conflict->target;
}
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict)
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff -uarp pacman-lib.orig/lib/libalpm/conflict.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/conflict.h
--- pacman-lib.orig/lib/libalpm/conflict.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/conflict.h 2007-01-19
20:26:21.000000000 -0500
@@ -28,7 +28,7 @@
struct __pmconflict_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmconflicttype_t type;
char file[CONFLICT_FILE_LEN];
char ctarget[PKG_NAME_LEN];
};
diff -uarp pacman-lib.orig/lib/libalpm/db.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/db.h
--- pacman-lib.orig/lib/libalpm/db.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/db.h 2007-01-19
20:26:21.000000000 -0500
@@ -27,12 +27,14 @@
#include <limits.h>
/* Database entries */
-#define INFRQ_NONE 0x00
-#define INFRQ_DESC 0x01
-#define INFRQ_DEPENDS 0x02
-#define INFRQ_FILES 0x04
-#define INFRQ_SCRIPTLET 0x08
-#define INFRQ_ALL 0xFF
+typedef enum _pmdbinfrq_t {
+ INFRQ_NONE = 0x00,
+ INFRQ_DESC = 0x01,
+ INFRQ_DEPENDS = 0x02,
+ INFRQ_FILES = 0x04,
+ INFRQ_SCRIPTLET = 0x08,
+ INFRQ_ALL = 0xFF
+} pmdbinfrq_t;
/* Database */
struct __pmdb_t {
@@ -55,9 +57,9 @@ int _alpm_db_install(pmdb_t *db, const c
int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db);
void _alpm_db_rewind(pmdb_t *db);
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq);
-int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info);
-int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq);
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq);
+int _alpm_db_read(pmdb_t *db, pmdbinfrq_t inforeq, pmpkg_t *info);
+int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
int _alpm_db_getlastupdate(pmdb_t *db, char *ts);
int _alpm_db_setlastupdate(pmdb_t *db, char *ts);
diff -uarp pacman-lib.orig/lib/libalpm/deps.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/deps.c
--- pacman-lib.orig/lib/libalpm/deps.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/deps.c 2007-01-19
20:26:21.000000000 -0500
@@ -44,8 +44,9 @@
extern pmhandle_t *handle;
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char
type, unsigned char depmod,
- const char *depname, const char *depversion)
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion)
{
pmdepmissing_t *miss;
@@ -187,7 +188,8 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_
* dependencies can include versions with depmod operators.
*
*/
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned
char op, alpm_list_t *packages)
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages)
{
pmdepend_t depend;
alpm_list_t *i, *j, *k;
@@ -224,7 +226,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
continue;
}
if(_alpm_pkg_isin(p->name, packages)) {
- /* this package is also in the upgrade list, so don't worry about it */
+ /* this package also in the upgrade list, so don't worry about it */
continue;
}
_alpm_db_read(db, INFRQ_DEPENDS, p);
@@ -246,8 +248,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
FREELISTPTR(provides);
}
if(!_alpm_depcmp(tp, &depend)) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by
%s"), depend.name, p->name);
- miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED,
depend.mod, depend.name, depend.version);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ depend.name, p->name);
+ miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -278,7 +282,8 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
_alpm_splitdep((char *)j->data, &depend);
found = 0;
/* check database for literal packages */
- for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); k &&
!found; k = k->next) {
+ for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS);
+ k && !found; k = k->next) {
pmpkg_t *p = (pmpkg_t *)k->data;
found = _alpm_depcmp(p, &depend);
}
@@ -316,8 +321,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
/* else if still not found... */
if(!found) {
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
- depend.name, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND,
depend.mod, depend.name, depend.version);
+ depend.name, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -363,8 +369,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
}
}
if(!found) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by
%s"), reqname, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED,
PM_DEP_MOD_ANY, j->data, NULL);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ reqname, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED,
+ PM_DEP_MOD_ANY, j->data, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -512,8 +520,9 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db
*
* make sure *list and *trail are already initialized
*/
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t
*syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data)
{
alpm_list_t *i, *j;
alpm_list_t *targ;
@@ -647,7 +656,7 @@ const char *alpm_dep_get_target(pmdepmis
return miss->target;
}
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -656,7 +665,7 @@ unsigned char alpm_dep_get_type(pmdepmis
return miss->type;
}
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss)
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff -uarp pacman-lib.orig/lib/libalpm/deps.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/deps.h
--- pacman-lib.orig/lib/libalpm/deps.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/deps.h 2007-01-19
20:26:21.000000000 -0500
@@ -30,7 +30,7 @@
/* Dependency */
struct __pmdepend_t {
- unsigned char mod;
+ pmdepmod_t mod;
char name[PKG_NAME_LEN];
char version[PKG_VERSION_LEN];
};
@@ -38,19 +38,22 @@ struct __pmdepend_t {
/* Missing dependency */
struct __pmdepmissing_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmdeptype_t type;
pmdepend_t depend;
};
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char
type, unsigned char depmod,
- const char *depname, const char *depversion);
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion);
int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned
char op, alpm_list_t *packages);
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t
*syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data);
#endif /* _ALPM_DEPS_H */
diff -uarp pacman-lib.orig/lib/libalpm/handle.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/handle.c
--- pacman-lib.orig/lib/libalpm/handle.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/handle.c 2007-01-19
20:26:21.000000000 -0500
@@ -117,12 +117,12 @@ int _alpm_handle_free(pmhandle_t *handle
alpm_cb_log alpm_option_get_logcb() { return handle->logcb; }
alpm_cb_download alpm_option_get_dlcb() { return handle->dlcb; }
-unsigned char alpm_option_get_logmask() { return handle->logmask; }
+unsigned short alpm_option_get_logmask() { return handle->logmask; }
const char *alpm_option_get_root() { return handle->root; }
const char *alpm_option_get_dbpath() { return handle->dbpath; }
const char *alpm_option_get_cachedir() { return handle->cachedir; }
const char *alpm_option_get_logfile() { return handle->logfile; }
-unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
+unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
@@ -134,14 +134,17 @@ unsigned short alpm_option_get_chomp() {
alpm_list_t *alpm_option_get_needles() { return handle->needles; }
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
-pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
-alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
+pmdb_t *alpm_option_get_localdb(pmhandle_t *handle) { return
handle->db_local; }
+alpm_list_t *alpm_option_get_syncdbs(pmhandle_t *handle)
+{
+ return handle->dbs_sync;
+}
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
void alpm_option_set_dlcb(alpm_cb_download cb) { handle->dlcb = cb; }
-void alpm_option_set_logmask(unsigned char mask) { handle->logmask = mask; }
+void alpm_option_set_logmask(unsigned short mask) { handle->logmask = mask; }
void alpm_option_set_root(const char *root)
{
@@ -176,12 +179,16 @@ void alpm_option_set_logfile(const char
}
}
-void alpm_option_set_usesyslog(unsigned char usesyslog) {
handle->usesyslog = usesyslog; }
+void alpm_option_set_usesyslog(unsigned short usesyslog)
+{
+ handle->usesyslog = usesyslog;
+}
void alpm_option_add_noupgrade(char *pkg)
{
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
+
void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
if(handle->noupgrade) FREELIST(handle->noupgrade);
@@ -218,7 +225,10 @@ void alpm_option_set_holdpkgs(alpm_list_
if(holdpkgs) handle->holdpkg = holdpkgs;
}
-void alpm_option_set_upgradedelay(time_t delay) {
handle->upgradedelay = delay; }
+void alpm_option_set_upgradedelay(time_t delay)
+{
+ handle->upgradedelay = delay;
+}
void alpm_option_set_xfercommand(const char *cmd)
{
@@ -226,7 +236,10 @@ void alpm_option_set_xfercommand(const c
if(cmd) handle->xfercommand = strdup(cmd);
}
-void alpm_option_set_nopassiveftp(unsigned short nopasv) {
handle->nopassiveftp = nopasv; }
+void alpm_option_set_nopassiveftp(unsigned short nopasv)
+{
+ handle->nopassiveftp = nopasv;
+}
void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
@@ -239,6 +252,9 @@ void alpm_option_set_needles(alpm_list_t
if(handle->needles) FREELIST(handle->needles);
if(needles) handle->needles = needles;
}
-void alpm_option_set_usecolor(unsigned short usecolor) {
handle->use_color = usecolor; }
+void alpm_option_set_usecolor(unsigned short usecolor)
+{
+ handle->use_color = usecolor;
+}
/* vim: set ts=2 sw=2 et: */
diff -uarp pacman-lib.orig/lib/libalpm/handle.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/handle.h
--- pacman-lib.orig/lib/libalpm/handle.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/handle.h 2007-01-19
20:26:21.000000000 -0500
@@ -45,12 +45,12 @@ typedef struct _pmhandle_t {
/* options */
alpm_cb_log logcb; /* Log callback function */
alpm_cb_download dlcb; /* Download callback function */
- unsigned char logmask; /* Output mask for logging functions */
+ unsigned short logmask; /* Output mask for logging functions */
char *root; /* Root path, default '/' */
char *dbpath; /* Base path to pacman's DBs */
char *cachedir; /* Base path to pacman's cache */
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
- unsigned char usesyslog; /* Use syslog instead of logfile? */
+ unsigned short usesyslog; /* Use syslog instead of logfile? */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
alpm_list_t *noextract; /* List of packages NOT to extrace */
/*TODO is this used?*/
diff -uarp pacman-lib.orig/lib/libalpm/log.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/log.c
--- pacman-lib.orig/lib/libalpm/log.c 2006-11-20 04:10:24.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/log.c 2007-01-19
20:26:21.000000000 -0500
@@ -27,7 +27,7 @@
#include "alpm.h"
#include "log.h"
-void _alpm_log(unsigned char flag, char *fmt, ...)
+void _alpm_log(pmloglevel_t flag, char *fmt, ...)
{
alpm_cb_log logcb = alpm_option_get_logcb();
if(logcb == NULL) {
diff -uarp pacman-lib.orig/lib/libalpm/log.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/log.h
--- pacman-lib.orig/lib/libalpm/log.h 2006-11-20 04:10:24.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/log.h 2007-01-19
20:49:42.000000000 -0500
@@ -21,9 +21,11 @@
#ifndef _ALPM_LOG_H
#define _ALPM_LOG_H
+#include "alpm.h"
+
#define LOG_STR_LEN 1024
-void _alpm_log(unsigned char flag, char *fmt, ...);
+void _alpm_log(pmloglevel_t flag, char *fmt, ...);
#endif /* _ALPM_LOG_H */
diff -uarp pacman-lib.orig/lib/libalpm/package.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/package.c
--- pacman-lib.orig/lib/libalpm/package.c 2007-01-19 19:25:20.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/package.c 2007-01-19
20:26:21.000000000 -0500
@@ -603,7 +603,7 @@ unsigned long alpm_pkg_get_isize(pmpkg_t
return pkg->isize;
}
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg)
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -738,7 +738,7 @@ alpm_list_t *alpm_pkg_get_backup(pmpkg_t
return pkg->backup;
}
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg)
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff -uarp pacman-lib.orig/lib/libalpm/package.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/package.h
--- pacman-lib.orig/lib/libalpm/package.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/package.h 2007-01-19
20:26:21.000000000 -0500
@@ -30,11 +30,12 @@
#endif
#include "alpm.h"
+#include "db.h"
-enum {
+typedef enum _pmpkgfrom_t {
PKG_FROM_CACHE = 1,
PKG_FROM_FILE
-};
+} pmpkgfrom_t;
/* Packages */
#define PKG_FILENAME_LEN 512
@@ -65,10 +66,10 @@ struct __pmpkg_t {
char arch[PKG_ARCH_LEN];
unsigned long size;
unsigned long isize;
- unsigned char scriptlet;
- unsigned char force;
+ unsigned short scriptlet;
+ unsigned short force;
time_t date;
- unsigned char reason;
+ pmpkgreason_t reason;
alpm_list_t *desc_localized;
alpm_list_t *license;
alpm_list_t *replaces;
@@ -81,9 +82,9 @@ struct __pmpkg_t {
alpm_list_t *conflicts;
alpm_list_t *provides;
/* internal */
- unsigned char origin;
+ unsigned short origin;
void *data;
- unsigned char infolevel;
+ pmdbinfrq_t infolevel;
};
#define FREEPKG(p) do { if(p){_alpm_pkg_free(p); p = NULL;}} while(0)
diff -uarp pacman-lib.orig/lib/libalpm/sync.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/sync.c
--- pacman-lib.orig/lib/libalpm/sync.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/sync.c 2007-01-19
20:26:21.000000000 -0500
@@ -1069,7 +1069,7 @@ error:
return(-1);
}
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync)
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync)
{
/* Sanity checks */
ASSERT(sync != NULL, return(-1));
diff -uarp pacman-lib.orig/lib/libalpm/sync.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/sync.h
--- pacman-lib.orig/lib/libalpm/sync.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/sync.h 2007-01-19
20:26:21.000000000 -0500
@@ -27,7 +27,7 @@
/* Sync package */
struct __pmsyncpkg_t {
- unsigned char type;
+ pmsynctype_t type;
pmpkg_t *pkg;
void *data;
};
diff -uarp pacman-lib.orig/lib/libalpm/trans.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/trans.c
--- pacman-lib.orig/lib/libalpm/trans.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/trans.c 2007-01-19
20:26:21.000000000 -0500
@@ -85,7 +85,9 @@ void _alpm_trans_free(void *data)
FREE(trans);
}
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned
int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress progress)
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
/* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -226,7 +228,7 @@ int _alpm_trans_commit(pmtrans_t *trans,
return(0);
}
-unsigned char alpm_trans_get_type()
+pmtranstype_t alpm_trans_get_type()
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff -uarp pacman-lib.orig/lib/libalpm/trans.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/trans.h
--- pacman-lib.orig/lib/libalpm/trans.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/trans.h 2007-01-19
20:26:21.000000000 -0500
@@ -26,11 +26,21 @@
#include "alpm.h"
+typedef enum _pmtransstate_t {
+ STATE_IDLE = 0,
+ STATE_INITIALIZED,
+ STATE_PREPARED,
+ STATE_DOWNLOADING,
+ STATE_COMMITING,
+ STATE_COMMITED,
+ STATE_INTERRUPTED
+} pmtransstate_t;
+
/* Transaction */
struct __pmtrans_t {
- unsigned char type;
+ pmtranstype_t type;
unsigned int flags;
- unsigned char state;
+ pmtransstate_t state;
alpm_list_t *targets; /* alpm_list_t of (char *) */
alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
alpm_list_t *skiplist; /* alpm_list_t of (char *) */
@@ -39,16 +49,6 @@ struct __pmtrans_t {
alpm_trans_cb_progress cb_progress;
};
-enum {
- STATE_IDLE = 0,
- STATE_INITIALIZED,
- STATE_PREPARED,
- STATE_DOWNLOADING,
- STATE_COMMITING,
- STATE_COMMITED,
- STATE_INTERRUPTED
-};
-
#define FREETRANS(p) \
do { \
if(p) { \
@@ -77,7 +77,9 @@ do { \
pmtrans_t *_alpm_trans_new(void);
void _alpm_trans_free(void *data);
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned
int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress progress);
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int 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);
diff -uarp pacman-lib.orig/lib/libalpm/util.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/util.c
--- pacman-lib.orig/lib/libalpm/util.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/util.c 2007-01-19
21:24:13.000000000 -0500
@@ -66,7 +66,7 @@
#ifdef __sun__
/* This is a replacement for strsep which is not portable (missing on Solaris).
- * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
+ * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
char* strsep(char** str, const char* delims)
{
char* token;
@@ -342,7 +342,7 @@ int _alpm_rmrf(char *path)
return(0);
}
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str)
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
{
_alpm_log(PM_LOG_DEBUG, _("logaction called: %s"), str);
diff -uarp pacman-lib.orig/lib/libalpm/util.h
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/util.h
--- pacman-lib.orig/lib/libalpm/util.h 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/util.h 2007-01-19
20:26:21.000000000 -0500
@@ -62,7 +62,7 @@ int _alpm_lckmk(char *file);
int _alpm_lckrm(char *file);
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(char *path);
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str);
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
int _alpm_ldconfig(char *root);
#ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(char *util, char *installfn, char *script,
char *ver, char *oldver, pmtrans_t *trans);
diff -uarp pacman-lib.orig/lib/libalpm/versioncmp.c
pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/versioncmp.c
--- pacman-lib.orig/lib/libalpm/versioncmp.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/lib/libalpm/versioncmp.c 2007-01-19
20:26:21.000000000 -0500
@@ -253,17 +253,19 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_
} else {
int cmp = _alpm_versioncmp(pkg->version, dep->version);
switch(dep->mod) {
- case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
- case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
- case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
+ case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ default: equal = 1; break;
}
}
char *mod = "~=";
switch(dep->mod) {
- case PM_DEP_MOD_EQ: mod = "=="; break;
- case PM_DEP_MOD_GE: mod = ">="; break;
- case PM_DEP_MOD_LE: mod = "<="; break;
+ case PM_DEP_MOD_EQ: mod = "=="; break;
+ case PM_DEP_MOD_GE: mod = ">="; break;
+ case PM_DEP_MOD_LE: mod = "<="; break;
+ default: break;
}
if(strlen(dep->version) > 0) {
diff -uarp pacman-lib.orig/src/pacman/add.c
pacman-lib-monotone/org.archlinux.pacman/src/pacman/add.c
--- pacman-lib.orig/src/pacman/add.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/add.c 2007-01-19
20:26:21.000000000 -0500
@@ -96,9 +96,17 @@ int pacman_add(alpm_list_t *targets)
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff -uarp pacman-lib.orig/src/pacman/deptest.c
pacman-lib-monotone/org.archlinux.pacman/src/pacman/deptest.c
--- pacman-lib.orig/src/pacman/deptest.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/deptest.c 2007-01-19
20:26:21.000000000 -0500
@@ -114,9 +114,17 @@ int pacman_deptest(alpm_list_t *targets)
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff -uarp pacman-lib.orig/src/pacman/package.c
pacman-lib-monotone/org.archlinux.pacman/src/pacman/package.c
--- pacman-lib.orig/src/pacman/package.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/package.c 2007-01-19
19:46:16.000000000 -0500
@@ -30,7 +30,6 @@
/* pacman */
#include "log.h"
#include "util.h"
-#include "list.h"
#include "package.h"
/* Display the content of an installed package
diff -uarp pacman-lib.orig/src/pacman/sync.c
pacman-lib-monotone/org.archlinux.pacman/src/pacman/sync.c
--- pacman-lib.orig/src/pacman/sync.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/sync.c 2007-01-19
20:26:21.000000000 -0500
@@ -572,12 +572,21 @@ int pacman_sync(alpm_list_t *targets)
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
- alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ?
_("requires") : _("is required by"),
- alpm_dep_get_name(miss));
+ alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ?
+ _("requires") : _("is required by"),
+ alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff -uarp pacman-lib.orig/src/pacman/trans.c
pacman-lib-monotone/org.archlinux.pacman/src/pacman/trans.c
--- pacman-lib.orig/src/pacman/trans.c 2007-01-19 18:09:55.000000000 -0500
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/trans.c 2007-01-19
20:26:21.000000000 -0500
@@ -44,7 +44,7 @@ static int prevpercent=0; /* for less pr
/* Callback to handle transaction events
*/
-void cb_trans_evt(unsigned char event, void *data1, void *data2)
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
{
char str[LOG_STR_LEN] = "";
char out[PATH_MAX];
@@ -53,38 +53,42 @@ void cb_trans_evt(unsigned char event, v
switch(event) {
case PM_TRANS_EVT_CHECKDEPS_START:
pm_fprintf(stderr, NL, _("checking dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) {
MSG(NL, _("checking for file conflicts... "));
}
- break;
+ break;
+ case PM_TRANS_EVT_CLEANUP_START:
+ pm_fprintf(stderr, NL, _("resolving dependencies... "));
+ break;
case PM_TRANS_EVT_RESOLVEDEPS_START:
pm_fprintf(stderr, NL, _("resolving dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_INTERCONFLICTS_START:
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_CHECKDEPS_DONE:
+ case PM_TRANS_EVT_CLEANUP_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
pm_fprintf(stderr, CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_EXTRACT_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_START:
if(config->noprogressbar) {
MSG(NL, _("installing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -93,12 +97,12 @@ void cb_trans_evt(unsigned char event, v
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_REMOVE_START:
if(config->noprogressbar) {
MSG(NL, _("removing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_REMOVE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -107,12 +111,12 @@ void cb_trans_evt(unsigned char event, v
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_START:
if(config->noprogressbar) {
MSG(NL, _("upgrading %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -122,34 +126,34 @@ void cb_trans_evt(unsigned char event, v
(char *)alpm_pkg_get_version(data2),
(char *)alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_START:
MSG(NL, _("checking package integrity... "));
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_DONE:
MSG(CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_INFO:
MSG(NL, "%s\n", (char*)data1);
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_START:
MSG(NL, (char*)data1);
MSG(CL, "...");
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_DONE:
if(!(long)data1) {
MSG(CL, _(" done.\n"));
} else {
MSG(CL, _(" failed.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_PRINTURI:
MSG(NL, "%s/%s\n", (char*)data1, (char*)data2);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_START:
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
fflush(stdout);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_LOCAL:
MSG(NL, " %s [", (char*)data1);
unsigned int maxcols = getcols();
@@ -159,11 +163,12 @@ void cb_trans_evt(unsigned char event, v
MSG(CL, " ");
}
fputs(_("] 100% LOCAL "), stdout);
- break;
+ break;
}
}
-void cb_trans_conv(unsigned char event, void *data1, void *data2,
void *data3, int *response)
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response)
{
char str[LOG_STR_LEN] = "";
@@ -181,7 +186,7 @@ void cb_trans_conv(unsigned char event,
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REMOVE_HOLDPKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REMOVE_HOLDPKG) {
@@ -190,11 +195,11 @@ void cb_trans_conv(unsigned char event,
*response = 0;
}
} else {
- snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg.
Remove anyway? [Y/n] "),
+ snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg.
Remove anyway? [Y/n] "),
alpm_pkg_get_name(data1));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REPLACE_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REPLACE_PKG) {
@@ -209,7 +214,7 @@ void cb_trans_conv(unsigned char event,
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_CONFLICT_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CONFLICT_PKG) {
@@ -224,7 +229,7 @@ void cb_trans_conv(unsigned char event,
(char *)data2);
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_NEWER:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_NEWER) {
@@ -242,7 +247,7 @@ void cb_trans_conv(unsigned char event,
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_UPTODATE:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_UPTODATE) {
@@ -260,7 +265,7 @@ void cb_trans_conv(unsigned char event,
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_CORRUPTED_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CORRUPTED_PKG) {
@@ -277,11 +282,12 @@ void cb_trans_conv(unsigned char event,
*response = 1;
}
}
- break;
+ break;
}
}
-void cb_trans_progress(unsigned char event, char *pkgname, int
percent, int howmany, int remain)
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain)
{
static int lasthash = 0, mouth = 0;
int i, hash;
@@ -311,19 +317,19 @@ void cb_trans_progress(unsigned char eve
switch (event) {
case PM_TRANS_PROGRESS_ADD_START:
ptr = _("installing");
- break;
+ break;
case PM_TRANS_PROGRESS_UPGRADE_START:
ptr = _("upgrading");
- break;
+ break;
case PM_TRANS_PROGRESS_REMOVE_START:
ptr = _("removing");
- break;
+ break;
case PM_TRANS_PROGRESS_CONFLICTS_START:
ptr = _("checking for file conflicts");
- break;
+ break;
}
hash=percent*progresslen/100;
diff -uarp pacman-lib.orig/src/pacman/trans.h
pacman-lib-monotone/org.archlinux.pacman/src/pacman/trans.h
--- pacman-lib.orig/src/pacman/trans.h 2006-10-15 15:34:53.000000000 -0400
+++ pacman-lib-monotone/org.archlinux.pacman/src/pacman/trans.h 2007-01-19
20:26:21.000000000 -0500
@@ -22,12 +22,14 @@
#define _PM_TRANS_H
/* callback to handle messages/notifications from pacman transactions */
-void cb_trans_evt(unsigned char event, void *data1, void *data2);
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2);
/* callback to handle questions from pacman transactions (yes/no) */
-void cb_trans_conv(unsigned char event, void *data1, void *data2,
void *data3, int *response);
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response);
-void cb_trans_progress(unsigned char event, char *pkgname, int
percent, int howmany, int remain);
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain);
#endif /* _PM_TRANS_H */
3
3
Date: Tuesday, January 23, 2007 @ 15:09:18
Author: aaron
Path: /home/cvs-pacman/pacman-lib/src/pacman
Modified: sync.c (1.96 -> 1.97)
Removed some debugging cruft left in in the last commit
--------+
sync.c | 2 --
1 file changed, 2 deletions(-)
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.96 pacman-lib/src/pacman/sync.c:1.97
--- pacman-lib/src/pacman/sync.c:1.96 Mon Jan 22 20:34:58 2007
+++ pacman-lib/src/pacman/sync.c Tue Jan 23 15:09:18 2007
@@ -289,8 +289,6 @@
char *grpname = alpm_list_getdata(i);
for(j = syncs; j; j = alpm_list_next(j)) {
pmdb_t *db = alpm_list_getdata(j);
- printf("searching '%s' for groups '%s'\n", alpm_db_get_name(db), grpname);
- fflush(stdout);
pmgrp_t *grp = alpm_db_readgrp(db, grpname);
if(grp) {
1
0
Date: Monday, January 22, 2007 @ 20:34:58
Author: aaron
Path: /home/cvs-pacman/pacman-lib
Modified: lib/libalpm/alpm_list.c (1.2 -> 1.3)
lib/libalpm/db.c (1.54 -> 1.55) lib/libalpm/group.c (1.11 -> 1.12)
src/pacman/sync.c (1.95 -> 1.96)
* Added some calloc calls to replace the malloc-then-set-to-zero functionality
* Fixed -Ss output so as not to call alpm_list_getdata with a NULl list
* Added a NULL check in alpm_list_getdata
* Fixed alpm_list_add_sorted to properly handle a new / beginning insertions
-------------------------+
lib/libalpm/alpm_list.c | 5 ++++-
lib/libalpm/db.c | 8 ++------
lib/libalpm/group.c | 5 +----
src/pacman/sync.c | 23 ++++++++++++++++-------
4 files changed, 23 insertions(+), 18 deletions(-)
Index: pacman-lib/lib/libalpm/alpm_list.c
diff -u pacman-lib/lib/libalpm/alpm_list.c:1.2 pacman-lib/lib/libalpm/alpm_list.c:1.3
--- pacman-lib/lib/libalpm/alpm_list.c:1.2 Mon Jan 22 04:27:00 2007
+++ pacman-lib/lib/libalpm/alpm_list.c Mon Jan 22 20:34:58 2007
@@ -145,8 +145,10 @@
if(prev != NULL) {
prev->next = add; /* In middle. */
+ } else {
+ list = add; /* At beginning, or new list */
}
-
+
return(list);
}
}
@@ -369,6 +371,7 @@
*/
void *alpm_list_getdata(const alpm_list_t *entry)
{
+ if(entry == NULL) return(NULL);
return(entry->data);
}
Index: pacman-lib/lib/libalpm/db.c
diff -u pacman-lib/lib/libalpm/db.c:1.54 pacman-lib/lib/libalpm/db.c:1.55
--- pacman-lib/lib/libalpm/db.c:1.54 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/db.c Mon Jan 22 20:34:58 2007
@@ -55,14 +55,14 @@
{
pmdb_t *db;
- db = (pmdb_t *)malloc(sizeof(pmdb_t));
+ db = calloc(1, sizeof(pmdb_t));
if(db == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
sizeof(pmdb_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}
- db->path = (char *)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2);
+ db->path = calloc(1, strlen(root)+strlen(dbpath)+strlen(treename)+2);
if(db->path == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
strlen(root)+strlen(dbpath)+strlen(treename)+2);
@@ -73,10 +73,6 @@
STRNCPY(db->treename, treename, PATH_MAX);
- db->pkgcache = NULL;
- db->grpcache = NULL;
- db->servers = NULL;
-
return(db);
}
Index: pacman-lib/lib/libalpm/group.c
diff -u pacman-lib/lib/libalpm/group.c:1.11 pacman-lib/lib/libalpm/group.c:1.12
--- pacman-lib/lib/libalpm/group.c:1.11 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/group.c Mon Jan 22 20:34:58 2007
@@ -36,16 +36,13 @@
{
pmgrp_t* grp;
- grp = (pmgrp_t *)malloc(sizeof(pmgrp_t));
+ grp = calloc(1, sizeof(pmgrp_t));
if(grp == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"),
sizeof(pmgrp_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}
- grp->name[0] = '\0';
- grp->packages = NULL;
-
return(grp);
}
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.95 pacman-lib/src/pacman/sync.c:1.96
--- pacman-lib/src/pacman/sync.c:1.95 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/sync.c Mon Jan 22 20:34:58 2007
@@ -248,14 +248,20 @@
continue;
}
for(j = ret; j; j = alpm_list_next(j)) {
+ char *group = NULL;
+ alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(j);
- char *group = (char *)alpm_list_getdata(alpm_pkg_get_groups(pkg));
- printf("%s/%s %s %s%s%s\n ",
- alpm_db_get_name(db),
- alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg),
- (group ? " (" : ""), (group ? group : ""), (group ? ") " : ""));
+ printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
+ alpm_pkg_get_version(pkg));
+
+ if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
+ group = alpm_list_getdata(grp);
+ printf(" (%s)\n ", (char *)alpm_list_getdata(grp));
+ } else {
+ printf("\n ");
+ }
+
indentprint(alpm_pkg_get_desc(pkg), 4);
printf("\n\n");
}
@@ -280,9 +286,12 @@
if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
+ char *grpname = alpm_list_getdata(i);
for(j = syncs; j; j = alpm_list_next(j)) {
pmdb_t *db = alpm_list_getdata(j);
- pmgrp_t *grp = alpm_db_readgrp(db, alpm_list_getdata(i));
+ printf("searching '%s' for groups '%s'\n", alpm_db_get_name(db), grpname);
+ fflush(stdout);
+ pmgrp_t *grp = alpm_db_readgrp(db, grpname);
if(grp) {
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
3
2
I noticed that even after moving it to *.pacsave it will still try to delete the
original file which fails and causes an error message which will only 'cause the
user to worry about this (possibly), which they don't need to.
Patch is below.
~ Jamie / yankees26
Signed-off-by: James Rosten <seinfeld90(a)gmail.com>
2
1
Date: Tuesday, January 23, 2007 @ 11:05:21
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: remove.c (1.56 -> 1.57)
James Rosten <seinfeld90(a)gmail.com>
* attempt to unlink file AFTER moving to .pacsave always fails
----------+
remove.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: pacman-lib/lib/libalpm/remove.c
diff -u pacman-lib/lib/libalpm/remove.c:1.56 pacman-lib/lib/libalpm/remove.c:1.57
--- pacman-lib/lib/libalpm/remove.c:1.56 Fri Jan 19 04:28:45 2007
+++ pacman-lib/lib/libalpm/remove.c Tue Jan 23 11:05:21 2007
@@ -225,9 +225,10 @@
int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
++(*position);
- }
- if (unlink(line) == -1) {
- _alpm_log(PM_LOG_ERROR, _("cannot remove file %s: %s"), file, strerror(errno));
+
+ if (unlink(line) == -1) {
+ _alpm_log(PM_LOG_ERROR, _("cannot remove file %s: %s"), file, strerror(errno));
+ }
}
}
}
1
0
Date: Tuesday, January 23, 2007 @ 11:02:37
Author: aaron
Path: /home/cvs-pacman/pacman-lib/scripts
Modified: makepkg (1.33 -> 1.34)
James Rosten <seinfeld90(a)gmail.com>
* noextract PKGBUILD option to NOT extract source files
- implemented with existing in_array function
---------+
makepkg | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.33 pacman-lib/scripts/makepkg:1.34
--- pacman-lib/scripts/makepkg:1.33 Mon Jan 22 14:26:23 2007
+++ pacman-lib/scripts/makepkg Tue Jan 23 11:02:37 2007
@@ -425,7 +425,7 @@
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
unset replaces depends conflicts backup source install build makedepends
-unset options
+unset options noextract
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
@@ -681,6 +681,11 @@
for netfile in "${source[@]}"; do
unziphack=0
file=$(strip_url "$netfile")
+ if in_array "$file" ${noextract[@]}; then
+ #skip source files in the noextract=() array
+ # these are marked explicitly to NOT be extracted
+ continue
+ fi
# fix flyspray #6246
file_type=$(file -biz "$file")
unset cmd
1
0
[pacman-dev] FS #6246 - makepkg fails if the extensions is wrong on the archive
by James Rosten 22 Jan '07
by James Rosten 22 Jan '07
22 Jan '07
This is a fix for FS #6246 ( http://bugs.archlinux.org/task/6246 ).
Instead of using the extension of the source archive, I make use of
file -biz (the z allows use to know if it is just a bzip2 or a tar.bzip2).
As usual the patch is below.
~ Jamie / yankees26
Signed-off-by: James Rosten <seinfeld90(a)gmail.com>
4
9
Date: Monday, January 22, 2007 @ 14:26:23
Author: aaron
Path: /home/cvs-pacman/pacman-lib/scripts
Modified: makepkg (1.32 -> 1.33)
Lowercase "changelog" in output message
---------+
makepkg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.32 pacman-lib/scripts/makepkg:1.33
--- pacman-lib/scripts/makepkg:1.32 Mon Jan 22 12:53:56 2007
+++ pacman-lib/scripts/makepkg Mon Jan 22 14:26:23 2007
@@ -898,7 +898,7 @@
# do we have a changelog?
have_changelog=0
if [ -f "$startdir/ChangeLog" ]; then
- msg "Copying package ChangeLog"
+ msg "Copying package changelog"
cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
have_changelog=1
fi
1
0
Newlines were included in both setting the string variable and in the
printf, remove the extra ones.
Signed-off-by: Dan McGee <dpmcgee(a)gmail.com>
--- pacman-lib.orig/src/pacman/package.c 2007-01-21 17:42:14.000000000 -0500
+++ pacman-lib/src/pacman/package.c 2007-01-21 17:40:50.000000000 -0500
@@ -49,13 +49,13 @@ void dump_pkg_full(pmpkg_t *pkg, int lev
switch((long)alpm_pkg_get_reason(pkg)) {
case PM_PKG_REASON_EXPLICIT:
- reason = _("Explicitly installed\n");
+ reason = _("Explicitly installed");
break;
case PM_PKG_REASON_DEPEND:
- reason = _("Installed as a dependency for another package\n");
+ reason = _("Installed as a dependency for another package");
break;
default:
- reason = _("Unknown\n");
+ reason = _("Unknown");
break;
}
5
7
Date: Monday, January 22, 2007 @ 04:57:21
Author: aaron
Path: /home/cvs-pacman/pacman-lib/scripts
Modified: makepkg (1.30 -> 1.31)
Changelog support for makepkg - this has been in pacman itself for some time,
but I don't know why I never crammed the changes for makepkg in.
* Adds a "Changelog" file next to a PKGBUILD as part of the package
(viewed with pacman -Qc)
---------+
makepkg | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.30 pacman-lib/scripts/makepkg:1.31
--- pacman-lib/scripts/makepkg:1.30 Mon Jan 22 03:45:12 2007
+++ pacman-lib/scripts/makepkg Mon Jan 22 04:57:20 2007
@@ -892,27 +892,36 @@
# check for an install script
if [ "$install" != "" ]; then
msg "Copying install script..."
- cp $startdir/$install $startdir/pkg/.INSTALL
+ cp "$startdir/$install" "$startdir/pkg/.INSTALL"
+fi
+
+# do we have a changelog?
+have_changelog=0
+if [ -f "$startdir/Changelog" ]; then
+ msg "Copying package Changelog"
+ cp "$startdir/Changelog" "$startdir/pkg/.CHANGELOG"
+ have_changelog=1
fi
# build a filelist
msg "Generating .FILELIST file..."
-cd $startdir/pkg
+cd "$startdir/pkg"
tar cvf /dev/null * | sort >.FILELIST
# tar it up
msg "Compressing package..."
-cd $startdir/pkg
+cd "$startdir/pkg"
pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
+[ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
if ! tar czf $pkg_file $comp_files *; then
error "Failed to create package file."
exit 1
fi
-cd $startdir
+cd "$startdir"
if [ "$CLEANUP" = "1" ]; then
msg "Cleaning up..."
rm -rf src pkg
4
5
Date: Monday, January 22, 2007 @ 12:53:57
Author: aaron
Path: /home/cvs-pacman/pacman-lib/scripts
Modified: makepkg (1.31 -> 1.32)
Rename Changelog -> ChangeLog (the standard way of casing a ChangeLog)
---------+
makepkg | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.31 pacman-lib/scripts/makepkg:1.32
--- pacman-lib/scripts/makepkg:1.31 Mon Jan 22 04:57:20 2007
+++ pacman-lib/scripts/makepkg Mon Jan 22 12:53:56 2007
@@ -897,9 +897,9 @@
# do we have a changelog?
have_changelog=0
-if [ -f "$startdir/Changelog" ]; then
- msg "Copying package Changelog"
- cp "$startdir/Changelog" "$startdir/pkg/.CHANGELOG"
+if [ -f "$startdir/ChangeLog" ]; then
+ msg "Copying package ChangeLog"
+ cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
have_changelog=1
fi
1
0
22 Jan '07
Date: Monday, January 22, 2007 @ 11:16:52
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: package.c (1.48 -> 1.49)
* Added a check for .FILELIST for package validity in addition to .PKGINFO
-----------+
package.c | 3 +++
1 file changed, 3 insertions(+)
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.48 pacman-lib/lib/libalpm/package.c:1.49
--- pacman-lib/lib/libalpm/package.c:1.48 Fri Jan 19 18:44:50 2007
+++ pacman-lib/lib/libalpm/package.c Mon Jan 22 11:16:51 2007
@@ -339,6 +339,9 @@
if(!config) {
_alpm_log(PM_LOG_ERROR, _("missing package info file in %s"), pkgfile);
goto error;
+ } else if(!filelist) {
+ _alpm_log(PM_LOG_ERROR, _("missing package filelist in %s"), pkgfile);
+ goto error;
}
/* internal */
1
0
22 Jan '07
Date: Monday, January 22, 2007 @ 04:27:01
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: alpm_list.c (1.1 -> 1.2)
Introduced an infinite loop during the pmlist -> alpm_list transition, whoops
-------------+
alpm_list.c | 1 +
1 file changed, 1 insertion(+)
Index: pacman-lib/lib/libalpm/alpm_list.c
diff -u pacman-lib/lib/libalpm/alpm_list.c:1.1 pacman-lib/lib/libalpm/alpm_list.c:1.2
--- pacman-lib/lib/libalpm/alpm_list.c:1.1 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/alpm_list.c Mon Jan 22 04:27:00 2007
@@ -420,6 +420,7 @@
if(lp->data && strcmp((const char *)lp->data, needle) == 0) {
return(1);
}
+ lp = lp->next;
}
return(0);
}
1
0
Date: Monday, January 22, 2007 @ 03:52:18
Author: aaron
Path: /home/cvs-pacman/pacman-lib/src/pacman
Modified: package.c (1.22 -> 1.23)
* Dan McGee <dpmcgee(a)gmail.com>
Newlines were included in both setting the string
variable and in the printf, remove the extra ones.
-----------+
package.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: pacman-lib/src/pacman/package.c
diff -u pacman-lib/src/pacman/package.c:1.22 pacman-lib/src/pacman/package.c:1.23
--- pacman-lib/src/pacman/package.c:1.22 Mon Jan 22 03:46:12 2007
+++ pacman-lib/src/pacman/package.c Mon Jan 22 03:52:18 2007
@@ -50,13 +50,13 @@
switch((long)alpm_pkg_get_reason(pkg)) {
case PM_PKG_REASON_EXPLICIT:
- reason = _("Explicitly installed\n");
+ reason = _("Explicitly installed");
break;
case PM_PKG_REASON_DEPEND:
- reason = _("Installed as a dependency for another package\n");
+ reason = _("Installed as a dependency for another package");
break;
default:
- reason = _("Unknown\n");
+ reason = _("Unknown");
break;
}
1
0
Date: Monday, January 22, 2007 @ 03:46:12
Author: aaron
Path: /home/cvs-pacman/pacman-lib/src/pacman
Modified: package.c (1.21 -> 1.22)
Removed list.h
-----------+
package.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: pacman-lib/src/pacman/package.c
diff -u pacman-lib/src/pacman/package.c:1.21 pacman-lib/src/pacman/package.c:1.22
--- pacman-lib/src/pacman/package.c:1.21 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/package.c Mon Jan 22 03:46:12 2007
@@ -27,10 +27,10 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "log.h"
#include "util.h"
-#include "list.h"
#include "package.h"
/* Display the content of an installed package
1
0
Date: Monday, January 22, 2007 @ 03:45:12
Author: aaron
Path: /home/cvs-pacman/pacman-lib/scripts
Modified: makepkg (1.29 -> 1.30)
makepkg file-type detection changes from James Rosten <seinfeld90(a)gmail.com>
and Johannes Weiner <hannes(a)saeurebad.de>
This should fix FS#6246
---------+
makepkg | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.29 pacman-lib/scripts/makepkg:1.30
--- pacman-lib/scripts/makepkg:1.29 Wed Jan 17 00:29:54 2007
+++ pacman-lib/scripts/makepkg Mon Jan 22 03:45:12 2007
@@ -681,24 +681,20 @@
for netfile in "${source[@]}"; do
unziphack=0
file=$(strip_url "$netfile")
+ # fix flyspray #6246
+ file_type=$(file -biz "$file")
unset cmd
- case "$(echo $file |tr "A-Z" "a-z")" in
- *.tar.gz|*.tar.z|*.tgz)
- cmd="tar --use-compress-program=gzip -xf $file" ;;
- *.tar.bz2|*.tbz2)
- cmd="tar --use-compress-program=bzip2 -xf $file" ;;
- *.tar)
+ case "$file_type" in
+ *application/x-tar*)
cmd="tar -xf $file" ;;
- *.zip)
+ *application/x-zip*)
unziphack=1
cmd="unzip -qqo $file" ;;
- *.cpio.gz)
+ *application/x-cpio*)
cmd="bsdtar -x -f $file" ;;
- *.cpio.bz2)
- cmd="bsdtar -x -f $file" ;;
- *.gz)
+ *application/x-gzip*)
cmd="gunzip -f $file" ;;
- *.bz2)
+ *application/x-bzip*)
cmd="bunzip2 -f $file" ;;
esac
if [ "$cmd" != "" ]; then
1
0
Hello pacman-hackers,
I am quite new to this list and to ArchLinux in general,
so if I'm talking crap, please correct me and don't take
all this as an offence.
The problem I'm concerned about is the general style of
writing code in the library. There are some inconsistencies
I found and I would like to discuss them with you.
* Casting of return values
Not needed in general, sometimes done - especially on
malloc() calls.
Since it's not needed, it would be better to leave it
out, because its syntax decreases readability.
* More defense return value checking
I found unchecked strdup() value using e.g.
* Better use of library functions
In the attached patch you can see what I mean.
Using one memset call to nullify a region instead of ~30
assignments.
* Linewidth and indentation
This is a hot topic. Some people's argument is, that
they don't want to code on 80 char wide terminals when
there is a 2048x1024 resolution on a 20" screen.
However, I think that
/usr/src/linux/Documentation/CodingStyle has a good
point on that. It's not just an optical problem, it's
design.
I'm not trying to piss anyone or just rant without doing something.
If you agree that a coding standard would be an overall benefit, I will
help creating one and applying it to the code base.
Chaotic greetings,
Hannes
Index: lib/libalpm/package.c
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/lib/libalpm/package.c,v
retrieving revision 1.42
diff -r1.42 package.c
45c45
< pmpkg_t* pkg = NULL;
---
> pmpkg_t* pkg;
47c47,51
< if((pkg = (pmpkg_t *)malloc(sizeof(pmpkg_t))) == NULL) {
---
> /* Use calloc to nullify the region at once */
> pkg = calloc(sizeof(*pkg));
> if (pkg == NULL) {
> _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate "
> "%d bytes"), sizeof(*pkg));
53,54d56
< } else {
< pkg->name[0] = '\0';
55a58
>
58,59d60
< } else {
< pkg->version[0] = '\0';
61,90d61
< pkg->filename[0] = '\0';
< pkg->desc[0] = '\0';
< pkg->url[0] = '\0';
< pkg->license = NULL;
< pkg->desc_localized = NULL;
< pkg->builddate[0] = '\0';
< pkg->buildtype[0] = '\0';
< pkg->installdate[0] = '\0';
< pkg->packager[0] = '\0';
< pkg->md5sum[0] = '\0';
< pkg->sha1sum[0] = '\0';
< pkg->arch[0] = '\0';
< pkg->size = 0;
< pkg->isize = 0;
< pkg->scriptlet = 0;
< pkg->force = 0;
< pkg->reason = PM_PKG_REASON_EXPLICIT;
< pkg->requiredby = NULL;
< pkg->conflicts = NULL;
< pkg->files = NULL;
< pkg->backup = NULL;
< pkg->depends = NULL;
< pkg->removes = NULL;
< pkg->groups = NULL;
< pkg->provides = NULL;
< pkg->replaces = NULL;
< /* internal */
< pkg->origin = 0;
< pkg->data = NULL;
< pkg->infolevel = 0;
97c68
< pmpkg_t* newpkg = NULL;
---
> pmpkg_t* newpkg;
99c70
< newpkg = (pmpkg_t *)malloc(sizeof(pmpkg_t));
---
> newpkg = malloc(sizeof(*newpkg));
101c72,73
< _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmpkg_t));
---
> _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate "
> "%d bytes"), sizeof(*pkg));
105,121c77,80
< STRNCPY(newpkg->filename, pkg->filename, PKG_FILENAME_LEN);
< STRNCPY(newpkg->name, pkg->name, PKG_NAME_LEN);
< STRNCPY(newpkg->version, pkg->version, PKG_VERSION_LEN);
< STRNCPY(newpkg->desc, pkg->desc, PKG_DESC_LEN);
< STRNCPY(newpkg->url, pkg->url, PKG_URL_LEN);
< STRNCPY(newpkg->builddate, pkg->builddate, PKG_DATE_LEN);
< STRNCPY(newpkg->buildtype, pkg->buildtype, PKG_DATE_LEN);
< STRNCPY(newpkg->installdate, pkg->installdate, PKG_DATE_LEN);
< STRNCPY(newpkg->packager, pkg->packager, PKG_PACKAGER_LEN);
< STRNCPY(newpkg->md5sum, pkg->md5sum, PKG_MD5SUM_LEN);
< STRNCPY(newpkg->sha1sum, pkg->sha1sum, PKG_SHA1SUM_LEN);
< STRNCPY(newpkg->arch, pkg->arch, PKG_ARCH_LEN);
< newpkg->size = pkg->size;
< newpkg->isize = pkg->isize;
< newpkg->force = pkg->force;
< newpkg->scriptlet = pkg->scriptlet;
< newpkg->reason = pkg->reason;
---
> /* Copy over the whole regions but take care of the
> lists manually. */
> memcpy(newpkg, pkg, sizeof(*newpkg));
>
132a92
>
134c94
< newpkg->origin = pkg->origin;
---
> /* XXX: strdup return value? */
136d95
< newpkg->infolevel = pkg->infolevel;
324,328c283
< pm_errno = PM_ERR_PKG_INVALID;
< unlink(descfile);
< FREE(descfile);
< close(fd);
< goto error;
---
> goto pkg_invalid;
332,336c287
< pm_errno = PM_ERR_PKG_INVALID;
< unlink(descfile);
< FREE(descfile);
< close(fd);
< goto error;
---
> goto pkg_invalid;
340,344c291
< pm_errno = PM_ERR_PKG_INVALID;
< unlink(descfile);
< FREE(descfile);
< close(fd);
< goto error;
---
> goto pkg_invalid;
413a361,366
> pkg_invalid:
> pm_errno = PM_ERR_PKG_INVALID;
> unlink(descfile);
> FREE(descfile);
> close(fd);
>
5
14
Date: Friday, January 19, 2007 @ 04:28:47
Author: aaron
Path: /home/cvs-pacman/pacman-lib
Added: lib/libalpm/alpm_list.c (1.1) lib/libalpm/alpm_list.h (1.1)
Modified: AUTHORS (1.5 -> 1.6) bindings/alpm.i (1.3 -> 1.4)
lib/libalpm/Makefile.am (1.12 -> 1.13)
lib/libalpm/add.c (1.101 -> 1.102) lib/libalpm/add.h (1.6 -> 1.7)
lib/libalpm/alpm.c (1.103 -> 1.104)
lib/libalpm/alpm.h (1.65 -> 1.66) lib/libalpm/backup.c (1.8 -> 1.9)
lib/libalpm/backup.h (1.4 -> 1.5)
lib/libalpm/be_files.c (1.19 -> 1.20)
lib/libalpm/cache.c (1.24 -> 1.25) lib/libalpm/cache.h (1.8 -> 1.9)
lib/libalpm/conflict.c (1.29 -> 1.30)
lib/libalpm/conflict.h (1.9 -> 1.10)
lib/libalpm/db.c (1.53 -> 1.54) lib/libalpm/db.h (1.21 -> 1.22)
lib/libalpm/deps.c (1.56 -> 1.57) lib/libalpm/deps.h (1.15 -> 1.16)
lib/libalpm/group.c (1.10 -> 1.11) lib/libalpm/group.h (1.8 -> 1.9)
lib/libalpm/handle.c (1.26 -> 1.27)
lib/libalpm/handle.h (1.12 -> 1.13)
lib/libalpm/package.c (1.43 -> 1.44)
lib/libalpm/package.h (1.22 -> 1.23)
lib/libalpm/provide.c (1.7 -> 1.8)
lib/libalpm/provide.h (1.4 -> 1.5)
lib/libalpm/remove.c (1.55 -> 1.56)
lib/libalpm/remove.h (1.6 -> 1.7)
lib/libalpm/server.c (1.15 -> 1.16)
lib/libalpm/server.h (1.8 -> 1.9) lib/libalpm/sync.c (1.90 -> 1.91)
lib/libalpm/sync.h (1.15 -> 1.16)
lib/libalpm/trans.c (1.29 -> 1.30)
lib/libalpm/trans.h (1.20 -> 1.21)
lib/libalpm/util.c (1.38 -> 1.39) lib/libalpm/util.h (1.17 -> 1.18)
lib/libalpm/versioncmp.c (1.7 -> 1.8)
src/pacman/Makefile.am (1.10 -> 1.11)
src/pacman/add.c (1.22 -> 1.23) src/pacman/add.h (1.2 -> 1.3)
src/pacman/conf.c (1.20 -> 1.21) src/pacman/conf.h (1.12 -> 1.13)
src/pacman/deptest.c (1.9 -> 1.10)
src/pacman/deptest.h (1.1 -> 1.2)
src/pacman/downloadprog.c (1.5 -> 1.6)
src/pacman/log.c (1.22 -> 1.23) src/pacman/package.c (1.20 -> 1.21)
src/pacman/package.h (1.5 -> 1.6)
src/pacman/pacman.c (1.81 -> 1.82)
src/pacman/query.c (1.17 -> 1.18) src/pacman/query.h (1.2 -> 1.3)
src/pacman/remove.c (1.23 -> 1.24) src/pacman/remove.h (1.2 -> 1.3)
src/pacman/sync.c (1.94 -> 1.95) src/pacman/sync.h (1.4 -> 1.5)
src/pacman/trans.c (1.26 -> 1.27) src/pacman/upgrade.c (1.5 -> 1.6)
src/pacman/upgrade.h (1.2 -> 1.3) src/pacman/util.c (1.21 -> 1.22)
src/pacman/util.h (1.12 -> 1.13)
Removed: lib/libalpm/list.c (1.19) lib/libalpm/list.h (1.19)
src/pacman/list.c (1.9) src/pacman/list.h (1.9)
Preliminary checkin for alpm_list conversion
* renamed pmlist_t -> alpm_list_t
* made alpm_list_t a public type (alpm_list.h header)
* removed additional storage for registered DBs in pacman source
* some code cleanup
* removed duplicate (pm)list_display functions from pacman source
* misc code cleanup
---------------------------+
AUTHORS | 1
bindings/alpm.i | 2
lib/libalpm/Makefile.am | 4
lib/libalpm/add.c | 44 ++--
lib/libalpm/add.h | 4
lib/libalpm/alpm.c | 103 +---------
lib/libalpm/alpm.h | 73 +++----
lib/libalpm/alpm_list.c | 429 ++++++++++++++++++++++++++++++++++++++++++++
lib/libalpm/alpm_list.h | 71 +++++++
lib/libalpm/backup.c | 4
lib/libalpm/backup.h | 4
lib/libalpm/be_files.c | 26 +-
lib/libalpm/cache.c | 36 +--
lib/libalpm/cache.h | 6
lib/libalpm/conflict.c | 62 +++---
lib/libalpm/conflict.h | 4
lib/libalpm/db.c | 10 -
lib/libalpm/db.h | 8
lib/libalpm/deps.c | 86 ++++----
lib/libalpm/deps.h | 12 -
lib/libalpm/group.c | 4
lib/libalpm/group.h | 2
lib/libalpm/handle.c | 36 +--
lib/libalpm/handle.h | 14 -
lib/libalpm/list.c | 361 -------------------------------------
lib/libalpm/list.h | 60 ------
lib/libalpm/package.c | 72 +++----
lib/libalpm/package.h | 24 +-
lib/libalpm/provide.c | 14 -
lib/libalpm/provide.h | 4
lib/libalpm/remove.c | 36 +--
lib/libalpm/remove.h | 4
lib/libalpm/server.c | 30 +--
lib/libalpm/server.h | 8
lib/libalpm/sync.c | 128 ++++++-------
lib/libalpm/sync.h | 8
lib/libalpm/trans.c | 16 -
lib/libalpm/trans.h | 10 -
lib/libalpm/util.c | 10 -
lib/libalpm/util.h | 2
lib/libalpm/versioncmp.c | 4
src/pacman/Makefile.am | 2
src/pacman/add.c | 29 +-
src/pacman/add.h | 4
src/pacman/conf.c | 14 -
src/pacman/conf.h | 5
src/pacman/deptest.c | 41 ++--
src/pacman/deptest.h | 4
src/pacman/downloadprog.c | 1
src/pacman/list.c | 197 --------------------
src/pacman/list.h | 53 -----
src/pacman/log.c | 1
src/pacman/package.c | 34 +--
src/pacman/package.h | 2
src/pacman/pacman.c | 27 --
src/pacman/query.c | 101 ++++------
src/pacman/query.h | 4
src/pacman/remove.c | 57 ++---
src/pacman/remove.h | 4
src/pacman/sync.c | 286 +++++++++++++----------------
src/pacman/sync.h | 8
src/pacman/trans.c | 1
src/pacman/upgrade.c | 4
src/pacman/upgrade.h | 4
src/pacman/util.c | 45 +++-
src/pacman/util.h | 10 -
66 files changed, 1252 insertions(+), 1522 deletions(-)
Index: pacman-lib/AUTHORS
diff -u pacman-lib/AUTHORS:1.5 pacman-lib/AUTHORS:1.6
--- pacman-lib/AUTHORS:1.5 Thu Jan 11 15:30:58 2007
+++ pacman-lib/AUTHORS Fri Jan 19 04:28:44 2007
@@ -10,3 +10,4 @@
Dan McGee <dpmcgee(a)gmail.com>
James Rosten <seinfeld90(a)gmail.com>
+Roman Kyrylych <Roman.Kyrylych(a)gmail.com>
Index: pacman-lib/bindings/alpm.i
diff -u pacman-lib/bindings/alpm.i:1.3 pacman-lib/bindings/alpm.i:1.4
--- pacman-lib/bindings/alpm.i:1.3 Mon Nov 20 04:10:23 2006
+++ pacman-lib/bindings/alpm.i Fri Jan 19 04:28:44 2007
@@ -13,7 +13,7 @@
%pointer_cast(void *, long *, void_to_long);
%pointer_cast(void *, char *, void_to_char);
%pointer_cast(void *, unsigned long, void_to_unsigned_long);
-%pointer_cast(void *, pmlist_t *, void_to_pmlist);
+%pointer_cast(void *, alpm_list_t *, void_to_pmlist);
%pointer_cast(void *, pmpkg_t *, void_to_pmpkg);
%pointer_cast(void *, pmgrp_t *, void_to_pmgrp);
%pointer_cast(void *, pmsyncpkg_t *, void_to_pmsyncpkg);
Index: pacman-lib/lib/libalpm/Makefile.am
diff -u pacman-lib/lib/libalpm/Makefile.am:1.12 pacman-lib/lib/libalpm/Makefile.am:1.13
--- pacman-lib/lib/libalpm/Makefile.am:1.12 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/Makefile.am Fri Jan 19 04:28:44 2007
@@ -12,7 +12,7 @@
md5.c \
sha1.c \
util.c \
- list.c \
+ alpm_list.c \
log.c \
error.c \
package.c \
@@ -35,7 +35,7 @@
lib_LTLIBRARIES = libalpm.la
-include_HEADERS = alpm.h
+include_HEADERS = alpm_list.h alpm.h
libalpm_la_SOURCES = $(TARGETS)
Index: pacman-lib/lib/libalpm/add.c
diff -u pacman-lib/lib/libalpm/add.c:1.101 pacman-lib/lib/libalpm/add.c:1.102
--- pacman-lib/lib/libalpm/add.c:1.101 Thu Jan 18 11:09:34 2007
+++ pacman-lib/lib/libalpm/add.c Fri Jan 19 04:28:44 2007
@@ -39,7 +39,7 @@
#include <limits.h>
#include <libintl.h>
/* pacman */
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -88,7 +88,7 @@
} else if(strncmp("version", p, q-p) == 0) {
STRNCPY(dummy->version, q+1, PKG_VERSION_LEN);
} else if(strncmp("depend", p, q-p) == 0) {
- dummy->depends = _alpm_list_add(dummy->depends, strdup(q+1));
+ dummy->depends = alpm_list_add(dummy->depends, strdup(q+1));
} else {
_alpm_log(PM_LOG_ERROR, _("could not parse token %s"), p);
}
@@ -100,7 +100,7 @@
}
/* add the package to the transaction */
- trans->packages = _alpm_list_add(trans->packages, dummy);
+ trans->packages = alpm_list_add(trans->packages, dummy);
return(0);
}
@@ -110,7 +110,7 @@
pmpkg_t *info = NULL;
pmpkg_t *dummy;
char pkgname[PKG_NAME_LEN], pkgver[PKG_VERSION_LEN];
- pmlist_t *i;
+ alpm_list_t *i;
struct stat buf;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -201,7 +201,7 @@
}
/* add the package to the transaction */
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
return(0);
@@ -216,10 +216,10 @@
return(strcmp(((pmpkg_t *)p1)->name, (const char *)p2));
}
-int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
+int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
{
- pmlist_t *lp = NULL, *i = NULL;
- pmlist_t *rmlist = NULL;
+ alpm_list_t *lp = NULL, *i = NULL;
+ alpm_list_t *rmlist = NULL;
char rm_fname[PATH_MAX];
pmpkg_t *info = NULL;
@@ -254,7 +254,7 @@
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this);
if(skip_this) {
pmpkg_t **pkg = NULL;
- lp = _alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg);
+ lp = alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg);
FREEPKG(*pkg);
}
}
@@ -293,7 +293,7 @@
/* Check for file conflicts
*/
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
- pmlist_t *skiplist = NULL;
+ alpm_list_t *skiplist = NULL;
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
@@ -334,7 +334,7 @@
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
unsigned char cb_state;
time_t t;
- pmlist_t *targ, *lp;
+ alpm_list_t *targ, *lp;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -375,7 +375,7 @@
_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), local->name);
_alpm_db_read(db, INFRQ_FILES, local);
}
- oldpkg->backup = _alpm_list_strdup(local->backup);
+ oldpkg->backup = alpm_list_strdup(local->backup);
strncpy(oldpkg->name, local->name, PKG_NAME_LEN);
strncpy(oldpkg->version, local->version, PKG_VERSION_LEN);
}
@@ -408,7 +408,7 @@
RET_ERR(PM_ERR_TRANS_ABORT, -1);
}
/* copy the skiplist over */
- tr->skiplist = _alpm_list_strdup(trans->skiplist);
+ tr->skiplist = alpm_list_strdup(trans->skiplist);
if(_alpm_remove_commit(tr, db) == -1) {
FREETRANS(tr);
RET_ERR(PM_ERR_TRANS_ABORT, -1);
@@ -475,7 +475,7 @@
if (info->size != 0)
percent = (double)archive_position_uncompressed(archive) / info->size;
if (needdisp == 0) {
- PROGRESS(trans, cb_state, what, (int)(percent * 100), _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, cb_state, what, (int)(percent * 100), alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
}
if(!strcmp(pathname, ".PKGINFO") || !strcmp(pathname, ".FILELIST")) {
@@ -507,7 +507,7 @@
* eg, /home/httpd/html/index.html may be removed so index.php
* could be used.
*/
- if(_alpm_list_is_strin(pathname, handle->noextract)) {
+ if(alpm_list_is_strin(pathname, handle->noextract)) {
alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname);
archive_read_data_skip (archive);
continue;
@@ -516,7 +516,7 @@
if(!stat(expath, &buf) && !S_ISDIR(buf.st_mode)) {
/* file already exists */
if(!pmo_upgrade || oldpkg == NULL) {
- nb = _alpm_list_is_strin(pathname, info->backup);
+ nb = alpm_list_is_strin(pathname, info->backup);
} else {
/* op == PM_TRANS_TYPE_UPGRADE */
md5_orig = _alpm_needbackup(pathname, oldpkg->backup);
@@ -525,7 +525,7 @@
nb = 1;
}
}
- if(_alpm_list_is_strin(pathname, handle->noupgrade)) {
+ if(alpm_list_is_strin(pathname, handle->noupgrade)) {
notouch = 1;
nb = 0;
}
@@ -753,7 +753,7 @@
* looking for packages depending on the package to add */
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
pmpkg_t *tmpp = lp->data;
- pmlist_t *tmppm = NULL;
+ alpm_list_t *tmppm = NULL;
if(tmpp == NULL) {
continue;
}
@@ -764,7 +764,7 @@
}
if(tmppm->data && !strcmp(depend.name, info->name)) {
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), tmpp->name, info->name);
- info->requiredby = _alpm_list_add(info->requiredby, strdup(tmpp->name));
+ info->requiredby = alpm_list_add(info->requiredby, strdup(tmpp->name));
}
}
}
@@ -800,7 +800,7 @@
depinfo = _alpm_db_get_pkgfromcache(db, depend.name);
if(depinfo == NULL) {
/* look for a provides package */
- pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) {
/* TODO: should check _all_ packages listed in provides, not just
* the first one.
@@ -820,14 +820,14 @@
_alpm_db_read(db, INFRQ_DEPENDS, depinfo);
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), info->name, depinfo->name);
- depinfo->requiredby = _alpm_list_add(depinfo->requiredby, strdup(info->name));
+ depinfo->requiredby = alpm_list_add(depinfo->requiredby, strdup(info->name));
if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) {
_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"),
depinfo->name, depinfo->version);
}
}
- PROGRESS(trans, cb_state, what, 100, _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, cb_state, what, 100, alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
needdisp = 0;
EVENT(trans, PM_TRANS_EVT_EXTRACT_DONE, NULL, NULL);
FREE(what);
Index: pacman-lib/lib/libalpm/add.h
diff -u pacman-lib/lib/libalpm/add.h:1.6 pacman-lib/lib/libalpm/add.h:1.7
--- pacman-lib/lib/libalpm/add.h:1.6 Mon Nov 20 04:10:23 2006
+++ pacman-lib/lib/libalpm/add.h Fri Jan 19 04:28:44 2007
@@ -22,11 +22,11 @@
#define _ALPM_ADD_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
-int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data);
+int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data);
int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db);
#endif /* _ALPM_ADD_H */
Index: pacman-lib/lib/libalpm/alpm.c
diff -u pacman-lib/lib/libalpm/alpm.c:1.103 pacman-lib/lib/libalpm/alpm.c:1.104
--- pacman-lib/lib/libalpm/alpm.c:1.103 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/alpm.c Fri Jan 19 04:28:44 2007
@@ -42,7 +42,7 @@
#include "versioncmp.h"
#include "md5.h"
#include "sha1.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "group.h"
#include "util.h"
@@ -169,7 +169,7 @@
found = 1;
} else {
void *data;
- handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, &data);
+ handle->dbs_sync = alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, &data);
if(data) {
found = 1;
}
@@ -209,7 +209,7 @@
found = 1;
}
} else {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = handle->dbs_sync; i && !found; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(db->treename, sdb->treename) == 0) {
@@ -227,7 +227,7 @@
/* pm_errno is set by _alpm_server_new */
return(-1);
}
- db->servers = _alpm_list_add(db->servers, server);
+ db->servers = alpm_list_add(db->servers, server);
_alpm_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
db->treename, server->s_url->scheme, server->s_url->host, server->s_url->doc);
} else {
@@ -247,9 +247,9 @@
*/
int alpm_db_update(int force, pmdb_t *db)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
char path[PATH_MAX];
- pmlist_t *files = NULL;
+ alpm_list_t *files = NULL;
char newmtime[16] = "";
char lastupdate[16] = "";
int ret;
@@ -265,7 +265,7 @@
ASSERT(handle->trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
ASSERT(handle->trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
- if(!_alpm_list_is_in(db, handle->dbs_sync)) {
+ if(!alpm_list_is_in(db, handle->dbs_sync)) {
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
}
@@ -279,7 +279,7 @@
/* build a one-element list */
snprintf(path, PATH_MAX, "%s" PM_EXT_DB, db->treename);
- files = _alpm_list_add(files, strdup(path));
+ files = alpm_list_add(files, strdup(path));
snprintf(path, PATH_MAX, "%s%s", handle->root, handle->dbpath);
@@ -344,7 +344,7 @@
* @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error
*/
-pmlist_t *alpm_db_getpkgcache(pmdb_t *db)
+alpm_list_t *alpm_db_getpkgcache(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -358,7 +358,7 @@
* @param name name of the package
* @return the list of packages on success, NULL on error
*/
-pmlist_t *alpm_db_whatprovides(pmdb_t *db, char *name)
+alpm_list_t *alpm_db_whatprovides(pmdb_t *db, char *name)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -387,7 +387,7 @@
* @param db pointer to the package database to get the group from
* @return the list of groups on success, NULL on error
*/
-pmlist_t *alpm_db_getgrpcache(pmdb_t *db)
+alpm_list_t *alpm_db_getgrpcache(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -596,7 +596,7 @@
* @param db pointer to the package database to search in
* @return the list of packages on success, NULL on error
*/
-pmlist_t *alpm_db_search(pmdb_t *db)
+alpm_list_t *alpm_db_search(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -687,7 +687,7 @@
* of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_prepare(pmlist_t **data)
+int alpm_trans_prepare(alpm_list_t **data)
{
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -704,7 +704,7 @@
* of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_commit(pmlist_t **data)
+int alpm_trans_commit(alpm_list_t **data)
{
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -801,81 +801,6 @@
}
/** @} */
-/** \addtogroup alpm_list List Functions
- * @brief Functions to manipulate libalpm linked lists
- * @{
- */
-
-/** Get the first element of a list.
- * @param list the list
- * @return the first element
- */
-pmlist_t *alpm_list_first(pmlist_t *list)
-{
- return(list);
-}
-
-/** Get the next element of a list.
- * @param entry the list entry
- * @return the next element on success, NULL on error
- */
-pmlist_t *alpm_list_next(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(NULL));
-
- return(entry->next);
-}
-
-/** Get the data of a list entry.
- * @param entry the list entry
- * @return the data on success, NULL on error
- */
-void *alpm_list_getdata(const pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(NULL));
-
- return(entry->data);
-}
-
-/** Free a list.
- * @param entry list to free
- * @return 0 on success, -1 on error
- */
-int alpm_list_free(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(-1));
-
- FREELIST(entry);
-
- return(0);
-}
-
-/** Free the outer list, but not the contained data
- * @param entry list to free
- * @return 0 on success, -1 on error
- */
-int alpm_list_free_outer(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(-1));
-
- _FREELIST(entry, NULL);
-
- return(0);
-}
-
-/** Count the entries in a list.
- * @param list the list to count
- * @return number of entries on success, NULL on error
- */
-int alpm_list_count(const pmlist_t *list)
-{
- ASSERT(list != NULL, return(-1));
-
- return(_alpm_list_count(list));
-}
-
-/** @} */
-
/** \addtogroup alpm_misc Miscellaneous Functions
* @brief Various libalpm functions
* @{
Index: pacman-lib/lib/libalpm/alpm.h
diff -u pacman-lib/lib/libalpm/alpm.h:1.65 pacman-lib/lib/libalpm/alpm.h:1.66
--- pacman-lib/lib/libalpm/alpm.h:1.65 Fri Dec 22 14:38:55 2006
+++ pacman-lib/lib/libalpm/alpm.h Fri Jan 19 04:28:44 2007
@@ -47,7 +47,8 @@
* Structures
*/
-typedef struct __pmlist_t pmlist_t;
+typedef struct __alpm_list_t alpm_list_t;
+
typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmgrp_t pmgrp_t;
@@ -117,21 +118,21 @@
unsigned char alpm_option_get_usesyslog();
void alpm_option_set_usesyslog(unsigned char usesyslog);
-pmlist_t *alpm_option_get_noupgrades();
+alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(char *pkg);
-void alpm_option_set_noupgrades(pmlist_t *noupgrade);
+void alpm_option_set_noupgrades(alpm_list_t *noupgrade);
-pmlist_t *alpm_option_get_noextracts();
+alpm_list_t *alpm_option_get_noextracts();
void alpm_option_add_noextract(char *pkg);
-void alpm_option_set_noextracts(pmlist_t *noextract);
+void alpm_option_set_noextracts(alpm_list_t *noextract);
-pmlist_t *alpm_option_get_ignorepkgs();
+alpm_list_t *alpm_option_get_ignorepkgs();
void alpm_option_add_ignorepkg(char *pkg);
-void alpm_option_set_ignorepkgs(pmlist_t *ignorepkgs);
+void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
-pmlist_t *alpm_option_get_holdpkgs();
+alpm_list_t *alpm_option_get_holdpkgs();
void alpm_option_add_holdpkg(char *pkg);
-void alpm_option_set_holdpkgs(pmlist_t *holdpkgs);
+void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs);
time_t alpm_option_get_upgradedelay();
void alpm_option_set_upgradedelay(time_t delay);
@@ -145,13 +146,16 @@
unsigned short alpm_option_get_chomp();
void alpm_option_set_chomp(unsigned short chomp);
-pmlist_t *alpm_option_get_needles();
+alpm_list_t *alpm_option_get_needles();
void alpm_option_add_needle(char *needle);
-void alpm_option_set_needles(pmlist_t *needles);
+void alpm_option_set_needles(alpm_list_t *needles);
unsigned short alpm_option_get_usecolor();
void alpm_option_set_usecolor(unsigned short usecolor);
+pmdb_t *alpm_option_get_localdb();
+alpm_list_t *alpm_option_get_syncdbs();
+
/*
* Databases
*/
@@ -170,12 +174,12 @@
int alpm_db_update(int level, pmdb_t *db);
pmpkg_t *alpm_db_readpkg(pmdb_t *db, char *name);
-pmlist_t *alpm_db_getpkgcache(pmdb_t *db);
-pmlist_t *alpm_db_whatprovides(pmdb_t *db, char *name);
+alpm_list_t *alpm_db_getpkgcache(pmdb_t *db);
+alpm_list_t *alpm_db_whatprovides(pmdb_t *db, char *name);
pmgrp_t *alpm_db_readgrp(pmdb_t *db, char *name);
-pmlist_t *alpm_db_getgrpcache(pmdb_t *db);
-pmlist_t *alpm_db_search(pmdb_t *db);
+alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
+alpm_list_t *alpm_db_search(pmdb_t *db);
/*
* Packages
@@ -215,23 +219,23 @@
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_groups(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_depends(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_removes(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_requiredby(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_conflicts(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_provides(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_files(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_backup(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_removes(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_requiredby(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_conflicts(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_provides(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);
unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/*
* Groups
*/
const char *alpm_grp_get_name(pmgrp_t *grp);
-pmlist_t *alpm_grp_get_packages(pmgrp_t *grp);
+alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp);
/*
* Sync
@@ -334,13 +338,13 @@
unsigned char alpm_trans_get_type();
unsigned int alpm_trans_get_flags();
-pmlist_t * alpm_trans_get_targets();
-pmlist_t * alpm_trans_get_packages();
+alpm_list_t * alpm_trans_get_targets();
+alpm_list_t * alpm_trans_get_packages();
int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv, alpm_trans_cb_progress cb_progress);
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
-int alpm_trans_prepare(pmlist_t **data);
-int alpm_trans_commit(pmlist_t **data);
+int alpm_trans_prepare(alpm_list_t **data);
+int alpm_trans_commit(alpm_list_t **data);
int alpm_trans_release(void);
/*
@@ -382,15 +386,6 @@
/*
* Helpers
*/
-
-/* pmlist_t */
-pmlist_t *alpm_list_first(pmlist_t *list);
-pmlist_t *alpm_list_next(pmlist_t *entry);
-#define alpm_list_data(type, list) (type)alpm_list_getdata((list))
-void *alpm_list_getdata(const pmlist_t *entry);
-int alpm_list_free(pmlist_t *entry);
-int alpm_list_free_outer(pmlist_t *entry);
-int alpm_list_count(const pmlist_t *list);
/* md5sums */
char *alpm_get_md5sum(char *name);
Index: pacman-lib/lib/libalpm/alpm_list.c
diff -u /dev/null pacman-lib/lib/libalpm/alpm_list.c:1.1
--- /dev/null Fri Jan 19 04:28:47 2007
+++ pacman-lib/lib/libalpm/alpm_list.c Fri Jan 19 04:28:44 2007
@@ -0,0 +1,429 @@
+/*
+ * alpm_list.c
+ *
+ * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include "alpm_list.h"
+#include "util.h"
+
+/** \defgroup alpm_list functions */
+/*\@{*/
+
+/* Allocation */
+
+/** Allocate a new alpm_list_t
+ * @return a new alpm_list_t item, or NULL on failure
+ */
+alpm_list_t *alpm_list_new()
+{
+ alpm_list_t *list = NULL;
+
+ list = (alpm_list_t *)malloc(sizeof(alpm_list_t));
+ if(list) {
+ list->data = NULL;
+ list->prev = NULL;
+ list->next = NULL;
+ }
+ return(list);
+}
+
+/** Free a list structure and possibly the internal data as well
+ * @param list the list to free
+ * @param fn a free function for the internal data, or NULL for none
+ */
+void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn)
+{
+ alpm_list_t *it = list;
+
+ while(it) {
+ alpm_list_t *ptr = it->next;
+ if(fn && it->data) {
+ fn(it->data);
+ }
+ FREE(it);
+ it = ptr;
+ }
+}
+
+/** Free the outer list, but not the contained data
+ * A minor simplification of alpm_list_free
+ * @param list the list to free
+ */
+void alpm_list_free_outer(alpm_list_t *list)
+{
+ alpm_list_free(list, NULL);
+}
+
+/* Mutators */
+
+/** Add a new item to the list
+ * @param list the list to add to
+ * @param data the new item to be added to the list
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
+{
+ alpm_list_t *ptr, *lp;
+
+ ptr = list;
+ if(ptr == NULL) {
+ ptr = alpm_list_new();
+ if(ptr == NULL) {
+ return(NULL);
+ }
+ }
+
+ lp = alpm_list_last(ptr);
+ if(lp == ptr && lp->data == NULL) {
+ /* nada */
+ } else {
+ lp->next = alpm_list_new();
+ if(lp->next == NULL) {
+ return(NULL);
+ }
+ lp->next->prev = lp;
+ lp = lp->next;
+ }
+
+ lp->data = data;
+
+ return(ptr);
+}
+
+/** Add items to a list in sorted order.
+ * @param list the list to add to
+ * @param data the new item to be added to the list
+ * @param fn the comparison function to use to determine order
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn)
+{
+ if(!fn) {
+ return alpm_list_add(list, data);
+ } else {
+ alpm_list_t *add = NULL, *prev = NULL, *next = list;
+
+ add = alpm_list_new();
+ add->data = data;
+
+ /* Find insertion point. */
+ while(next) {
+ if(fn(add->data, next->data) <= 0) break;
+ prev = next;
+ next = next->next;
+ }
+
+ /* Insert node before insertion point. */
+ add->prev = prev;
+ add->next = next;
+
+ if(next != NULL) {
+ next->prev = add; /* Not at end. */
+ }
+
+ if(prev != NULL) {
+ prev->next = add; /* In middle. */
+ }
+
+ return(list);
+ }
+}
+
+/** Merge the two sorted sublists into one sorted list
+ * @param left the first list
+ * @param right the second list
+ * @param fn comparison function for determining merge order
+ */
+alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn)
+{
+ alpm_list_t *newlist, *lp;
+
+ if (left == NULL)
+ return right;
+ if (right == NULL)
+ return left;
+
+ if (fn(left->data, right->data) <= 0) {
+ newlist = left;
+ left = left->next;
+ }
+ else {
+ newlist = right;
+ right = right->next;
+ }
+ newlist->prev = NULL;
+ newlist->next = NULL;
+ lp = newlist;
+
+ while ((left != NULL) && (right != NULL)) {
+ if (fn(left->data, right->data) <= 0) {
+ lp->next = left;
+ left->prev = lp;
+ left = left->next;
+ }
+ else {
+ lp->next = right;
+ right->prev = lp;
+ right = right->next;
+ }
+ lp = lp->next;
+ lp->next = NULL;
+ }
+ if (left != NULL) {
+ lp->next = left;
+ left->prev = lp;
+ }
+ else if (right != NULL) {
+ lp->next = right;
+ right->prev = lp;
+ }
+ return(newlist);
+}
+
+/** Sort a list of size `n` using mergesort algorithm
+ * @param list the list to sort
+ * @param n the size of the list
+ * @param fn the comparison function for determining order
+ */
+alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn)
+{
+ if (n > 1) {
+ alpm_list_t *left = list;
+ alpm_list_t *lastleft = alpm_list_nth(list, n/2 - 1);
+ alpm_list_t *right = lastleft->next;
+ /* terminate first list */
+ lastleft->next = NULL;
+
+ left = alpm_list_msort(left, n/2, fn);
+ right = alpm_list_msort(right, n - (n/2), fn);
+ list = alpm_list_mmerge(left, right, fn);
+ }
+ return(list);
+}
+
+/** Remove an item from the list
+ * @param haystack the list to remove the item from
+ * @param needle the data member of the item we're removing
+ * @param fn the comparison function for searching
+ * @param data output parameter containing the data member of the item removed
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data)
+{ /* TODO I modified this to remove ALL matching items. Do we need a remove_first? */
+ alpm_list_t *i = haystack, *tmp = NULL;
+
+ if(data) {
+ *data = NULL;
+ }
+
+ while(i) {
+ if(i->data == NULL) {
+ continue;
+ }
+ tmp = i->next;
+ if(fn(needle, i->data) == 0) {
+ /* we found a matching item */
+ if(i->next) {
+ i->next->prev = i->prev;
+ }
+ if(i->prev) {
+ i->prev->next = i->next;
+ }
+
+ if(i == haystack) {
+ /* The item found is the first in the chain */
+ haystack = haystack->next;
+ }
+
+ if(data) {
+ *data = i->data;
+ }
+ i->data = NULL;
+ free(i);
+ }
+ i = tmp;
+ }
+
+ return(haystack);
+}
+
+/** Create a new list without any duplicates
+ * @note DOES NOT copy data members
+ * @param list the list to copy
+ * @return a NEW list containing non-duplicated items
+ */
+alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list)
+{ /* TODO does removing the strdup here cause invalid free's anywhere? */
+ alpm_list_t *lp = list, *newlist = NULL;
+ while(lp) {
+ if(!alpm_list_is_in(lp->data, newlist)) {
+ newlist = alpm_list_add(newlist, lp->data);
+ }
+ lp = lp->next;
+ }
+ return(newlist);
+}
+
+/** Copy a string list, including data
+ * @note this is gross, assumes string data members
+ * @param list the list to copy
+ * @return a copy of the original list
+ */
+alpm_list_t *alpm_list_strdup(alpm_list_t *list)
+{
+ alpm_list_t *lp = list, *newlist = NULL;
+ while(lp) {
+ newlist = alpm_list_add(newlist, strdup(lp->data));
+ lp = lp->next;
+ }
+ return(newlist);
+}
+
+/** Create a new list in reverse order
+ * @param list the list to copy
+ * @return a NEW list in reverse order of the first
+ */
+alpm_list_t *alpm_list_reverse(alpm_list_t *list)
+{ /* TODO any invalid free's from NOT duplicating data here? */
+ alpm_list_t *lp, *newlist = NULL;
+
+ lp = alpm_list_last(list);
+ while(lp) {
+ newlist = alpm_list_add(newlist, lp->data);
+ lp = lp->prev;
+ }
+ return(newlist);
+}
+
+/* Accessors */
+
+/** Get the first element of a list.
+ * @param list the list
+ * @return the first element in the list
+ */
+alpm_list_t *alpm_list_first(alpm_list_t *list)
+{
+ return(list);
+}
+
+/** Return nth element from list (starting with 0)
+ * @param list the list to access
+ * @param n the index of the item to find
+ * @return an alpm_list_t node for index `n`
+ */
+alpm_list_t *alpm_list_nth(alpm_list_t *list, int n)
+{
+ alpm_list_t *i = list;
+ while(n--) {
+ i = i->next;
+ }
+ return(i);
+}
+
+/** Get the next element of a list.
+ * @param entry the list entry
+ * @return the next element, or NULL when no more elements exist
+ */
+alpm_list_t *alpm_list_next(alpm_list_t *entry)
+{
+ return(entry->next);
+}
+/** Get the last item in the list.
+ * @param list the list to operate on
+ * @return the last element in the list
+ */
+alpm_list_t *alpm_list_last(alpm_list_t *list)
+{
+ alpm_list_t *i = list;
+ while(i && i->next) {
+ i = i->next;
+ }
+ return(i);
+}
+
+/** Get the data member of a list entry.
+ * @param entry the list entry
+ * @return the contained data, or NULL if none
+ */
+void *alpm_list_getdata(const alpm_list_t *entry)
+{
+ return(entry->data);
+}
+
+/* Misc */
+
+/** Count the list items
+ * @param list the list to operate on
+ * @return the number of list items
+ */
+int alpm_list_count(const alpm_list_t *list)
+{
+ unsigned int i = 0;
+ const alpm_list_t *lp = list;
+ while(lp) {
+ ++i;
+ lp = lp->next;
+ }
+ return(i);
+}
+
+/** Is an item in the list
+ * @param needle the data to compare to (== comparison)
+ * @param haystack the list to search
+ * @return 1 if `needle` is found, 0 otherwise
+ */
+int alpm_list_is_in(const void *needle, alpm_list_t *haystack)
+{
+ alpm_list_t *lp = haystack;
+ while(lp) {
+ if(lp->data == needle) {
+ return(1);
+ }
+ lp = lp->next;
+ }
+ return(0);
+}
+
+/* Test for existence of a string in a alpm_list_t
+*/
+/** Is a _string_ in the list (optimization of alpm_list_is_in for strings)
+ * @param needle the string to compare
+ * @param haystack the list to search
+ * @return 1 if `needle` is found, 0 otherwise
+ */
+int alpm_list_is_strin(const char *needle, alpm_list_t *haystack)
+{
+ alpm_list_t *lp = haystack;
+ while(lp) {
+ if(lp->data && strcmp((const char *)lp->data, needle) == 0) {
+ return(1);
+ }
+ }
+ return(0);
+}
+
+/** @} */
+
+/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/lib/libalpm/alpm_list.h
diff -u /dev/null pacman-lib/lib/libalpm/alpm_list.h:1.1
--- /dev/null Fri Jan 19 04:28:47 2007
+++ pacman-lib/lib/libalpm/alpm_list.h Fri Jan 19 04:28:44 2007
@@ -0,0 +1,71 @@
+/*
+ * alpm_alpm_list.h
+ *
+ * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#ifndef _ALPM_LIST_H
+#define _ALPM_LIST_H
+
+#include "alpm.h"
+
+/* Chained list struct */
+struct __alpm_list_t {
+ void *data;
+ struct __alpm_list_t *prev;
+ struct __alpm_list_t *next;
+};
+
+/* TODO we should do away with these... they're messy */
+#define _FREELIST(p, f) do { if(p) { alpm_list_free(p, f); p = NULL; } } while(0)
+#define FREELIST(p) _FREELIST(p, free)
+#define FREELISTPTR(p) _FREELIST(p, NULL)
+
+typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */
+typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */
+
+/* allocation */
+alpm_list_t *alpm_list_new(void);
+void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn);
+void alpm_list_free_outer(alpm_list_t *list);
+
+/* item mutators */
+alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
+alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn);
+alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data);
+alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list);
+alpm_list_t *alpm_list_strdup(alpm_list_t *list);
+alpm_list_t *alpm_list_reverse(alpm_list_t *list);
+
+/* item accessors */
+alpm_list_t *alpm_list_first(alpm_list_t *list);
+alpm_list_t* alpm_list_nth(alpm_list_t *list, int n);
+alpm_list_t *alpm_list_next(alpm_list_t *list);
+alpm_list_t *alpm_list_last(alpm_list_t *list);
+void *alpm_list_getdata(const alpm_list_t *entry);
+#define alpm_list_data(type, list) (type)alpm_list_getdata((list))
+
+/* misc */
+int alpm_list_count(const alpm_list_t *list);
+int alpm_list_is_in(const void *needle, alpm_list_t *haystack);
+int alpm_list_is_strin(const char *needle, alpm_list_t *haystack);
+
+#endif /* _ALPM_LIST_H */
+
+/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/lib/libalpm/backup.c
diff -u pacman-lib/lib/libalpm/backup.c:1.8 pacman-lib/lib/libalpm/backup.c:1.9
--- pacman-lib/lib/libalpm/backup.c:1.8 Fri Dec 22 14:38:55 2006
+++ pacman-lib/lib/libalpm/backup.c Fri Jan 19 04:28:44 2007
@@ -32,9 +32,9 @@
/* Look for a filename in a pmpkg_t.backup list. If we find it,
* then we return the md5 or sha1 hash (parsed from the same line)
*/
-char *_alpm_needbackup(char *file, pmlist_t *backup)
+char *_alpm_needbackup(char *file, alpm_list_t *backup)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(file == NULL || backup == NULL) {
return(NULL);
Index: pacman-lib/lib/libalpm/backup.h
diff -u pacman-lib/lib/libalpm/backup.h:1.4 pacman-lib/lib/libalpm/backup.h:1.5
--- pacman-lib/lib/libalpm/backup.h:1.4 Fri Oct 20 02:26:55 2006
+++ pacman-lib/lib/libalpm/backup.h Fri Jan 19 04:28:44 2007
@@ -21,9 +21,9 @@
#ifndef _ALPM_BACKUP_H
#define _ALPM_BACKUP_H
-#include "list.h"
+#include "alpm_list.h"
-char *_alpm_needbackup(char *file, pmlist_t *backup);
+char *_alpm_needbackup(char *file, alpm_list_t *backup);
#endif /* _ALPM_BACKUP_H */
Index: pacman-lib/lib/libalpm/be_files.c
diff -u pacman-lib/lib/libalpm/be_files.c:1.19 pacman-lib/lib/libalpm/be_files.c:1.20
--- pacman-lib/lib/libalpm/be_files.c:1.19 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/be_files.c Fri Jan 19 04:28:44 2007
@@ -181,7 +181,7 @@
struct stat buf;
char path[PATH_MAX+1];
char line[513];
- pmlist_t *tmplist;
+ alpm_list_t *tmplist;
char *locale;
if(db == NULL) {
@@ -238,7 +238,7 @@
_alpm_strtrim(info->filename);
} else if(!strcmp(line, "%DESC%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->desc_localized = _alpm_list_add(info->desc_localized, strdup(line));
+ info->desc_localized = alpm_list_add(info->desc_localized, strdup(line));
}
if((locale = setlocale(LC_ALL, "")) == NULL) { /* To fix segfault when locale invalid */
@@ -263,7 +263,7 @@
_alpm_strtrim(info->desc);
} else if(!strcmp(line, "%GROUPS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->groups = _alpm_list_add(info->groups, strdup(line));
+ info->groups = alpm_list_add(info->groups, strdup(line));
}
} else if(!strcmp(line, "%URL%")) {
if(fgets(info->url, sizeof(info->url), fp) == NULL) {
@@ -272,7 +272,7 @@
_alpm_strtrim(info->url);
} else if(!strcmp(line, "%LICENSE%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->license = _alpm_list_add(info->license, strdup(line));
+ info->license = alpm_list_add(info->license, strdup(line));
}
} else if(!strcmp(line, "%ARCH%")) {
if(fgets(info->arch, sizeof(info->arch), fp) == NULL) {
@@ -347,7 +347,7 @@
/* the REPLACES tag is special -- it only appears in sync repositories,
* not the local one. */
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->replaces = _alpm_list_add(info->replaces, strdup(line));
+ info->replaces = alpm_list_add(info->replaces, strdup(line));
}
} else if(!strcmp(line, "%FORCE%")) {
/* FORCE tag only appears in sync repositories,
@@ -371,11 +371,11 @@
_alpm_strtrim(line);
if(!strcmp(line, "%FILES%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->files = _alpm_list_add(info->files, strdup(line));
+ info->files = alpm_list_add(info->files, strdup(line));
}
} else if(!strcmp(line, "%BACKUP%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->backup = _alpm_list_add(info->backup, strdup(line));
+ info->backup = alpm_list_add(info->backup, strdup(line));
}
}
}
@@ -396,25 +396,25 @@
_alpm_strtrim(line);
if(!strcmp(line, "%DEPENDS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->depends = _alpm_list_add(info->depends, strdup(line));
+ info->depends = alpm_list_add(info->depends, strdup(line));
}
} else if(!strcmp(line, "%REQUIREDBY%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->requiredby = _alpm_list_add(info->requiredby, strdup(line));
+ info->requiredby = alpm_list_add(info->requiredby, strdup(line));
}
} else if(!strcmp(line, "%CONFLICTS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->conflicts = _alpm_list_add(info->conflicts, strdup(line));
+ info->conflicts = alpm_list_add(info->conflicts, strdup(line));
}
} else if(!strcmp(line, "%PROVIDES%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->provides = _alpm_list_add(info->provides, strdup(line));
+ info->provides = alpm_list_add(info->provides, strdup(line));
}
} else if(!strcmp(line, "%REPLACES%")) {
/* the REPLACES tag is special -- it only appears in sync repositories,
* not the local one. */
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->replaces = _alpm_list_add(info->replaces, strdup(line));
+ info->replaces = alpm_list_add(info->replaces, strdup(line));
}
} else if(!strcmp(line, "%FORCE%")) {
/* FORCE tag only appears in sync repositories,
@@ -451,7 +451,7 @@
FILE *fp = NULL;
char path[PATH_MAX];
mode_t oldmask;
- pmlist_t *lp = NULL;
+ alpm_list_t *lp = NULL;
int retval = 0;
int local = 0;
Index: pacman-lib/lib/libalpm/cache.c
diff -u pacman-lib/lib/libalpm/cache.c:1.24 pacman-lib/lib/libalpm/cache.c:1.25
--- pacman-lib/lib/libalpm/cache.c:1.24 Thu Jan 11 12:44:39 2007
+++ pacman-lib/lib/libalpm/cache.c Fri Jan 19 04:28:44 2007
@@ -30,7 +30,7 @@
/* pacman */
#include "log.h"
#include "alpm.h"
-#include "list.h"
+#include "alpm_list.h"
#include "util.h"
#include "error.h"
#include "package.h"
@@ -62,11 +62,11 @@
info->origin = PKG_FROM_CACHE;
info->data = db;
/* add to the collection */
- db->pkgcache = _alpm_list_add(db->pkgcache, info);
+ db->pkgcache = alpm_list_add(db->pkgcache, info);
count++;
}
- db->pkgcache = _alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
return(0);
}
@@ -86,7 +86,7 @@
}
}
-pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
{
if(db == NULL) {
return(NULL);
@@ -108,7 +108,7 @@
* info is not already cached
*/
- pmlist_t *p;
+ alpm_list_t *p;
for(p = db->pkgcache; p; p = p->next) {
pmpkg_t *pkg = (pmpkg_t *)p->data;
if(infolevel != INFRQ_NONE && !(pkg->infolevel & infolevel)) {
@@ -136,7 +136,7 @@
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("adding entry '%s' in '%s' cache"), newpkg->name, db->treename);
- db->pkgcache = _alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
_alpm_db_free_grpcache(db);
@@ -152,7 +152,7 @@
return(-1);
}
- db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata);
+ db->pkgcache = alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata);
data = vdata;
if(data == NULL) {
/* package not found */
@@ -180,7 +180,7 @@
*/
int _alpm_db_load_grpcache(pmdb_t *db)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(db == NULL) {
return(-1);
@@ -193,25 +193,25 @@
_alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename);
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DESC); lp; lp = lp->next) {
- pmlist_t *i;
+ alpm_list_t *i;
pmpkg_t *pkg = lp->data;
for(i = pkg->groups; i; i = i->next) {
- if(!_alpm_list_is_strin(i->data, db->grpcache)) {
+ if(!alpm_list_is_strin(i->data, db->grpcache)) {
pmgrp_t *grp = _alpm_grp_new();
STRNCPY(grp->name, (char *)i->data, GRP_NAME_LEN);
- grp->packages = _alpm_list_add_sorted(grp->packages, pkg->name, _alpm_grp_cmp);
- db->grpcache = _alpm_list_add_sorted(db->grpcache, grp, _alpm_grp_cmp);
+ grp->packages = alpm_list_add_sorted(grp->packages, pkg->name, _alpm_grp_cmp);
+ db->grpcache = alpm_list_add_sorted(db->grpcache, grp, _alpm_grp_cmp);
} else {
- pmlist_t *j;
+ alpm_list_t *j;
for(j = db->grpcache; j; j = j->next) {
pmgrp_t *grp = j->data;
if(strcmp(grp->name, i->data) == 0) {
- if(!_alpm_list_is_strin(pkg->name, grp->packages)) {
- grp->packages = _alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
+ if(!alpm_list_is_strin(pkg->name, grp->packages)) {
+ grp->packages = alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
}
}
}
@@ -224,7 +224,7 @@
void _alpm_db_free_grpcache(pmdb_t *db)
{
- pmlist_t *lg;
+ alpm_list_t *lg;
if(db == NULL || db->grpcache == NULL) {
return;
@@ -239,7 +239,7 @@
FREELIST(db->grpcache);
}
-pmlist_t *_alpm_db_get_grpcache(pmdb_t *db)
+alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db)
{
if(db == NULL) {
return(NULL);
@@ -254,7 +254,7 @@
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target)
{
- pmlist_t *i;
+ alpm_list_t *i;
if(db == NULL || target == NULL || strlen(target) == 0) {
return(NULL);
Index: pacman-lib/lib/libalpm/cache.h
diff -u pacman-lib/lib/libalpm/cache.h:1.8 pacman-lib/lib/libalpm/cache.h:1.9
--- pacman-lib/lib/libalpm/cache.h:1.8 Mon Nov 20 04:10:23 2006
+++ pacman-lib/lib/libalpm/cache.h Fri Jan 19 04:28:44 2007
@@ -22,7 +22,7 @@
#define _ALPM_CACHE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "group.h"
#include "package.h"
@@ -31,13 +31,13 @@
void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
-pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
/* groups */
int _alpm_db_load_grpcache(pmdb_t *db);
void _alpm_db_free_grpcache(pmdb_t *db);
-pmlist_t *_alpm_db_get_grpcache(pmdb_t *db);
+alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db);
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target);
#endif /* _ALPM_CACHE_H */
Index: pacman-lib/lib/libalpm/conflict.c
diff -u pacman-lib/lib/libalpm/conflict.c:1.29 pacman-lib/lib/libalpm/conflict.c:1.30
--- pacman-lib/lib/libalpm/conflict.c:1.29 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/conflict.c Fri Jan 19 04:28:44 2007
@@ -37,7 +37,7 @@
#include <libintl.h>
/* pacman */
#include "handle.h"
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -46,15 +46,15 @@
#include "deps.h"
#include "conflict.h"
-/* Returns a pmlist_t* of pmdepmissing_t pointers.
+/* Returns a alpm_list_t* of pmdepmissing_t pointers.
*
* conflicts are always name only
*/
-pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
+alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages)
{
pmpkg_t *info = NULL;
- pmlist_t *i, *j, *k;
- pmlist_t *baddeps = NULL;
+ alpm_list_t *i, *j, *k;
+ alpm_list_t *baddeps = NULL;
pmdepmissing_t *miss = NULL;
if(db == NULL) {
@@ -86,13 +86,13 @@
dp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if dp provides something in tp's conflict list */
- pmlist_t *m;
+ alpm_list_t *m;
for(m = dp->provides; m; m = m->next) {
if(!strcmp(m->data, j->data)) {
/* confict */
@@ -100,7 +100,7 @@
dp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -122,20 +122,20 @@
otp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if otp provides something in tp's conflict list */
- pmlist_t *m;
+ alpm_list_t *m;
for(m = otp->provides; m; m = m->next) {
if(!strcmp(m->data, j->data)) {
_alpm_log(PM_LOG_DEBUG, _("targs vs targs: found %s as a conflict for %s"),
otp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -147,7 +147,7 @@
/* CHECK 3: check database against targets */
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name);
for(k = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); k; k = k->next) {
- pmlist_t *conflicts = NULL;
+ alpm_list_t *conflicts = NULL;
int usenewconflicts = 0;
info = k->data;
@@ -155,7 +155,7 @@
/* a package cannot conflict with itself -- that's just not nice */
continue;
}
- /* If this package (*info) is also in our packages pmlist_t, use the
+ /* If this package (*info) is also in our packages alpm_list_t, use the
* conflicts list from the new package, not the old one (*info)
*/
for(j = packages; j; j = j->next) {
@@ -176,22 +176,22 @@
info->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if the db package conflicts with something we provide */
- pmlist_t *m;
+ alpm_list_t *m;
for(m = conflicts; m; m = m->next) {
- pmlist_t *n;
+ alpm_list_t *n;
for(n = tp->provides; n; n = n->next) {
if(!strcmp(m->data, n->data)) {
_alpm_log(PM_LOG_DEBUG, _("db vs targs: found %s as a conflict for %s"),
info->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -206,18 +206,18 @@
return(baddeps);
}
-/* Returns a pmlist_t* of file conflicts.
+/* Returns a alpm_list_t* of file conflicts.
*
- * adds list of files to skip to pmlist_t** skip_list.
+ * adds list of files to skip to alpm_list_t** skip_list.
*/
-pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list)
+alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, alpm_list_t **skip_list)
{
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
char *filestr = NULL;
char path[PATH_MAX+1];
struct stat buf, buf2;
- pmlist_t *conflicts = NULL;
- pmlist_t *targets = trans->packages;
+ alpm_list_t *conflicts = NULL;
+ alpm_list_t *targets = trans->packages;
double percent;
if(db == NULL || targets == NULL || root == NULL) {
@@ -226,8 +226,8 @@
/* CHECK 1: check every target against every target */
for(i = targets; i; i = i->next) {
pmpkg_t *p1 = (pmpkg_t*)i->data;
- percent = (double)(_alpm_list_count(targets) - _alpm_list_count(i) + 1) / _alpm_list_count(targets);
- PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), _alpm_list_count(targets), (_alpm_list_count(targets) - _alpm_list_count(i) +1));
+ percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1) / alpm_list_count(targets);
+ PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), alpm_list_count(targets), (alpm_list_count(targets) - alpm_list_count(i) +1));
for(j = i; j; j = j->next) {
pmpkg_t *p2 = (pmpkg_t*)j->data;
if(strcmp(p1->name, p2->name)) {
@@ -240,7 +240,7 @@
if(strcmp(filestr, ".INSTALL") == 0) {
continue;
}
- if(_alpm_list_is_strin(filestr, p2->files)) {
+ if(alpm_list_is_strin(filestr, p2->files)) {
pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
if(conflict == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"),
@@ -251,7 +251,7 @@
STRNCPY(conflict->target, p1->name, PKG_NAME_LEN);
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
STRNCPY(conflict->ctarget, p2->name, PKG_NAME_LEN);
- conflicts = _alpm_list_add(conflicts, conflict);
+ conflicts = alpm_list_add(conflicts, conflict);
}
}
}
@@ -284,7 +284,7 @@
_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg->name);
_alpm_db_read(db, INFRQ_FILES, dbpkg);
}
- if(dbpkg && _alpm_list_is_strin(j->data, dbpkg->files)) {
+ if(dbpkg && alpm_list_is_strin(j->data, dbpkg->files)) {
ok = 1;
}
/* Make sure that the supposedly-conflicting file is not actually just
@@ -315,7 +315,7 @@
_alpm_db_read(db, INFRQ_FILES, dbpkg2);
}
/* If it used to exist in there, but doesn't anymore */
- if(dbpkg2 && !_alpm_list_is_strin(filestr, p1->files) && _alpm_list_is_strin(filestr, dbpkg2->files)) {
+ if(dbpkg2 && !alpm_list_is_strin(filestr, p1->files) && alpm_list_is_strin(filestr, dbpkg2->files)) {
ok = 1;
/* Add to the "skip list" of files that we shouldn't remove during an upgrade.
*
@@ -333,7 +333,7 @@
* Our workaround is to scan through all "old" packages and all "new"
* ones, looking for files that jump to different packages.
*/
- *skip_list = _alpm_list_add(*skip_list, strdup(filestr));
+ *skip_list = alpm_list_add(*skip_list, strdup(filestr));
}
}
}
@@ -350,7 +350,7 @@
STRNCPY(conflict->target, p->name, PKG_NAME_LEN);
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
conflict->ctarget[0] = 0;
- conflicts = _alpm_list_add(conflicts, conflict);
+ conflicts = alpm_list_add(conflicts, conflict);
}
}
}
Index: pacman-lib/lib/libalpm/conflict.h
diff -u pacman-lib/lib/libalpm/conflict.h:1.9 pacman-lib/lib/libalpm/conflict.h:1.10
--- pacman-lib/lib/libalpm/conflict.h:1.9 Mon Nov 20 04:10:23 2006
+++ pacman-lib/lib/libalpm/conflict.h Fri Jan 19 04:28:44 2007
@@ -33,8 +33,8 @@
char ctarget[PKG_NAME_LEN];
};
-pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages);
-pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list);
+alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages);
+alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, alpm_list_t **skip_list);
#endif /* _ALPM_CONFLICT_H */
Index: pacman-lib/lib/libalpm/db.c
diff -u pacman-lib/lib/libalpm/db.c:1.53 pacman-lib/lib/libalpm/db.c:1.54
--- pacman-lib/lib/libalpm/db.c:1.53 Tue Jan 16 22:57:53 2007
+++ pacman-lib/lib/libalpm/db.c Fri Jan 19 04:28:44 2007
@@ -96,9 +96,9 @@
return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
}
-pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
+alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles)
{
- pmlist_t *i, *j, *k, *ret = NULL;
+ alpm_list_t *i, *j, *k, *ret = NULL;
for(i = needles; i; i = i->next) {
char *targ;
@@ -139,7 +139,7 @@
if(matched != NULL) {
_alpm_log(PM_LOG_DEBUG, " search target '%s' matched '%s'", targ, matched);
- ret = _alpm_list_add(ret, pkg);
+ ret = alpm_list_add(ret, pkg);
}
}
}
@@ -159,7 +159,7 @@
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
} else {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
@@ -197,7 +197,7 @@
if(strcmp(treename, "local") == 0) {
handle->db_local = db;
} else {
- handle->dbs_sync = _alpm_list_add(handle->dbs_sync, db);
+ handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
}
return(db);
Index: pacman-lib/lib/libalpm/db.h
diff -u pacman-lib/lib/libalpm/db.h:1.21 pacman-lib/lib/libalpm/db.h:1.22
--- pacman-lib/lib/libalpm/db.h:1.21 Fri Dec 22 14:38:55 2006
+++ pacman-lib/lib/libalpm/db.h Fri Jan 19 04:28:44 2007
@@ -39,15 +39,15 @@
char *path;
char treename[PATH_MAX];
void *handle;
- pmlist_t *pkgcache;
- pmlist_t *grpcache;
- pmlist_t *servers;
+ alpm_list_t *pkgcache;
+ alpm_list_t *grpcache;
+ alpm_list_t *servers;
};
/* db.c, database general calls */
pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename);
void _alpm_db_free(void *data);
int _alpm_db_cmp(const void *db1, const void *db2);
-pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
+alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles);
pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback);
/* be.c, backend specific calls */
Index: pacman-lib/lib/libalpm/deps.c
diff -u pacman-lib/lib/libalpm/deps.c:1.56 pacman-lib/lib/libalpm/deps.c:1.57
--- pacman-lib/lib/libalpm/deps.c:1.56 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/deps.c Fri Jan 19 04:28:44 2007
@@ -33,7 +33,7 @@
#include "util.h"
#include "log.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "cache.h"
@@ -68,9 +68,9 @@
return(miss);
}
-int _alpm_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack)
+int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack)
{
- pmlist_t *i;
+ alpm_list_t *i;
for(i = haystack; i; i = i->next) {
pmdepmissing_t *miss = i->data;
@@ -95,13 +95,13 @@
* mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This
* affects the dependency order sortbydeps() will use.
*
- * This function returns the new pmlist_t* target list.
+ * This function returns the new alpm_list_t* target list.
*
*/
-pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
+alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
{
- pmlist_t *newtargs = NULL;
- pmlist_t *i, *j, *k, *l;
+ alpm_list_t *newtargs = NULL;
+ alpm_list_t *i, *j, *k, *l;
int change = 1;
int numscans = 0;
int numtargs = 0;
@@ -111,13 +111,13 @@
}
for(i = targets; i; i = i->next) {
- newtargs = _alpm_list_add(newtargs, i->data);
+ newtargs = alpm_list_add(newtargs, i->data);
numtargs++;
}
_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
while(change) {
- pmlist_t *tmptargs = NULL;
+ alpm_list_t *tmptargs = NULL;
change = 0;
/* TODO only use of a math.h function in entire libalpm,
* can we get rid of it? Former code line:
@@ -147,7 +147,7 @@
if(!strcmp(dep.name, q->name)) {
if(!_alpm_pkg_isin(q->name, tmptargs)) {
change = 1;
- tmptargs = _alpm_list_add(tmptargs, q);
+ tmptargs = alpm_list_add(tmptargs, q);
}
break;
}
@@ -155,7 +155,7 @@
if(!strcmp(dep.name, (char*)l->data)) {
if(!_alpm_pkg_isin((char*)l->data, tmptargs)) {
change = 1;
- tmptargs = _alpm_list_add(tmptargs, q);
+ tmptargs = alpm_list_add(tmptargs, q);
}
break;
}
@@ -163,7 +163,7 @@
}
}
if(!_alpm_pkg_isin(p->name, tmptargs)) {
- tmptargs = _alpm_list_add(tmptargs, p);
+ tmptargs = alpm_list_add(tmptargs, p);
}
}
FREELISTPTR(newtargs);
@@ -173,7 +173,7 @@
if(mode == PM_TRANS_TYPE_REMOVE) {
/* we're removing packages, so reverse the order */
- pmlist_t *tmptargs = _alpm_list_reverse(newtargs);
+ alpm_list_t *tmptargs = alpm_list_reverse(newtargs);
/* free the old one */
FREELISTPTR(newtargs);
newtargs = tmptargs;
@@ -182,17 +182,17 @@
return(newtargs);
}
-/* Returns a pmlist_t* of missing_t pointers.
+/* Returns a alpm_list_t* of missing_t pointers.
*
* dependencies can include versions with depmod operators.
*
*/
-pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages)
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages)
{
pmdepend_t depend;
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
int found = 0;
- pmlist_t *baddeps = NULL;
+ alpm_list_t *baddeps = NULL;
pmdepmissing_t *miss = NULL;
if(db == NULL) {
@@ -237,7 +237,7 @@
}
if(found == 0) {
/* look for packages that list depend.name as a "provide" */
- pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides == NULL) {
/* not found */
continue;
@@ -249,7 +249,7 @@
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -284,7 +284,7 @@
}
/* check database for provides matches */
if(!found) {
- pmlist_t *m;
+ alpm_list_t *m;
k = _alpm_db_whatprovides(db, depend.name);
for(m = k; m && !found; m = m->next) {
/* look for a match that isn't one of the packages we're trying
@@ -292,7 +292,7 @@
* package, we'll defer to the NEW one, not the one already
* installed. */
pmpkg_t *p = m->data;
- pmlist_t *n;
+ alpm_list_t *n;
int skip = 0;
for(n = packages; n && !skip; n = n->next) {
pmpkg_t *ptp = n->data;
@@ -319,7 +319,7 @@
depend.name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -338,7 +338,7 @@
for(j = tp->requiredby; j; j = j->next) {
/* Search for 'reqname' in packages for removal */
char *reqname = j->data;
- pmlist_t *x = NULL;
+ alpm_list_t *x = NULL;
for(x = packages; x; x = x->next) {
pmpkg_t *xp = x->data;
if(strcmp(reqname, xp->name) == 0) {
@@ -357,7 +357,7 @@
spkg = k->data;
}
if(spkg) {
- if(_alpm_list_is_strin(tp->name, spkg->provides)) {
+ if(alpm_list_is_strin(tp->name, spkg->provides)) {
found = 1;
}
}
@@ -366,7 +366,7 @@
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), reqname, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -422,15 +422,15 @@
return(0);
}
-/* return a new pmlist_t target list containing all packages in the original
+/* return a new alpm_list_t target list containing all packages in the original
* target list, as well as all their un-needed dependencies. By un-needed,
* I mean dependencies that are *only* required for packages in the target
* list, so they can be safely removed. This function is recursive.
*/
-pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
+alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
{
- pmlist_t *i, *j, *k;
- pmlist_t *newtargs = targs;
+ alpm_list_t *i, *j, *k;
+ alpm_list_t *newtargs = targs;
if(db == NULL) {
return(newtargs);
@@ -497,7 +497,7 @@
/* add it to the target list */
_alpm_log(PM_LOG_DEBUG, _("loading ALL info for '%s'"), pkg->name);
_alpm_db_read(db, INFRQ_ALL, pkg);
- newtargs = _alpm_list_add(newtargs, pkg);
+ newtargs = alpm_list_add(newtargs, pkg);
_alpm_log(PM_LOG_FLOW2, _("adding '%s' to the targets"), pkg->name);
newtargs = _alpm_removedeps(db, newtargs);
}
@@ -512,19 +512,19 @@
*
* make sure *list and *trail are already initialized
*/
-int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list,
- pmlist_t *trail, pmtrans_t *trans, pmlist_t **data)
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
+ alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
{
- pmlist_t *i, *j;
- pmlist_t *targ;
- pmlist_t *deps = NULL;
+ alpm_list_t *i, *j;
+ alpm_list_t *targ;
+ alpm_list_t *deps = NULL;
if(local == NULL || dbs_sync == NULL || syncpkg == NULL) {
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("started resolving dependencies"));
- targ = _alpm_list_add(NULL, syncpkg);
+ targ = alpm_list_add(NULL, syncpkg);
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
FREELISTPTR(targ);
@@ -540,7 +540,7 @@
/* check if one of the packages in *list already provides this dependency */
for(j = list; j && !found; j = j->next) {
pmpkg_t *sp = (pmpkg_t *)j->data;
- if(_alpm_list_is_strin(miss->depend.name, sp->provides)) {
+ if(alpm_list_is_strin(miss->depend.name, sp->provides)) {
_alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"),
sp->name, miss->depend.name);
found = 1;
@@ -558,7 +558,7 @@
}
/* check provides */
for(j = dbs_sync; !sync && j; j = j->next) {
- pmlist_t *provides;
+ alpm_list_t *provides;
provides = _alpm_db_whatprovides(j->data, miss->depend.name);
if(provides) {
sync = provides->data;
@@ -576,7 +576,7 @@
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
@@ -593,19 +593,19 @@
* something we're not supposed to.
*/
int usedep = 1;
- if(_alpm_list_is_strin(sync->name, handle->ignorepkg)) {
+ if(alpm_list_is_strin(sync->name, handle->ignorepkg)) {
pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
FREEPKG(dummypkg);
}
if(usedep) {
- trail = _alpm_list_add(trail, sync);
+ trail = alpm_list_add(trail, sync);
if(_alpm_resolvedeps(local, dbs_sync, sync, list, trail, trans, data)) {
goto error;
}
_alpm_log(PM_LOG_DEBUG, _("pulling dependency %s (needed by %s)"),
sync->name, syncpkg->name);
- list = _alpm_list_add(list, sync);
+ list = alpm_list_add(list, sync);
} else {
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\""), miss->target);
if(data) {
@@ -616,7 +616,7 @@
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
Index: pacman-lib/lib/libalpm/deps.h
diff -u pacman-lib/lib/libalpm/deps.h:1.15 pacman-lib/lib/libalpm/deps.h:1.16
--- pacman-lib/lib/libalpm/deps.h:1.15 Wed Nov 22 04:03:42 2006
+++ pacman-lib/lib/libalpm/deps.h Fri Jan 19 04:28:45 2007
@@ -44,13 +44,13 @@
pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
const char *depname, const char *depversion);
-int _alpm_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack);
-pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode);
-pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages);
+int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
+alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
-pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs);
-int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list,
- pmlist_t *trail, pmtrans_t *trans, pmlist_t **data);
+alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
+ alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
#endif /* _ALPM_DEPS_H */
Index: pacman-lib/lib/libalpm/group.c
diff -u pacman-lib/lib/libalpm/group.c:1.10 pacman-lib/lib/libalpm/group.c:1.11
--- pacman-lib/lib/libalpm/group.c:1.10 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/group.c Fri Jan 19 04:28:45 2007
@@ -29,7 +29,7 @@
#include "error.h"
#include "log.h"
#include "group.h"
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
pmgrp_t *_alpm_grp_new()
@@ -81,7 +81,7 @@
return grp->name;
}
-pmlist_t *alpm_grp_get_packages(pmgrp_t *grp)
+alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp)
{
/* Sanity checks */
ASSERT(grp != NULL, return(NULL));
Index: pacman-lib/lib/libalpm/group.h
diff -u pacman-lib/lib/libalpm/group.h:1.8 pacman-lib/lib/libalpm/group.h:1.9
--- pacman-lib/lib/libalpm/group.h:1.8 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/group.h Fri Jan 19 04:28:45 2007
@@ -28,7 +28,7 @@
struct __pmgrp_t {
char name[GRP_NAME_LEN];
- pmlist_t *packages; /* List of strings */
+ alpm_list_t *packages; /* List of strings */
};
#define FREEGRP(p) do { if(p) { _alpm_grp_free(p); p = NULL; } } while(0)
Index: pacman-lib/lib/libalpm/handle.c
diff -u pacman-lib/lib/libalpm/handle.c:1.26 pacman-lib/lib/libalpm/handle.c:1.27
--- pacman-lib/lib/libalpm/handle.c:1.26 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/handle.c Fri Jan 19 04:28:45 2007
@@ -33,7 +33,7 @@
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "error.h"
#include "trans.h"
#include "alpm.h"
@@ -123,19 +123,19 @@
const char *alpm_option_get_cachedir() { return handle->cachedir; }
const char *alpm_option_get_logfile() { return handle->logfile; }
unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
-pmlist_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
-pmlist_t *alpm_option_get_noextracts() { return handle->noextract; }
-pmlist_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
-pmlist_t *alpm_option_get_holdpkgs() { return handle->holdpkg; }
+alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
+alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
+alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
+alpm_list_t *alpm_option_get_holdpkgs() { return handle->holdpkg; }
time_t alpm_option_get_upgradedelay() { return handle->upgradedelay; }
const char *alpm_option_get_xfercommand() { return handle->xfercommand; }
unsigned short alpm_option_get_nopassiveftp() { return handle->nopassiveftp; }
unsigned short alpm_option_get_chomp() { return handle->chomp; }
-pmlist_t *alpm_option_get_needles() { return handle->needles; }
+alpm_list_t *alpm_option_get_needles() { return handle->needles; }
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
-pmdb_t *alpm_option_get_localdb(pmhandle_t *handle) { return handle->db_local; }
-pmlist_t *alpm_option_get_syncdbs(pmhandle_t *handle) { return handle->dbs_sync; }
+pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
+alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
@@ -180,9 +180,9 @@
void alpm_option_add_noupgrade(char *pkg)
{
- handle->noupgrade = _alpm_list_add(handle->noupgrade, strdup(pkg));
+ handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
-void alpm_option_set_noupgrades(pmlist_t *noupgrade)
+void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
if(handle->noupgrade) FREELIST(handle->noupgrade);
if(noupgrade) handle->noupgrade = noupgrade;
@@ -190,9 +190,9 @@
void alpm_option_add_noextract(char *pkg)
{
- handle->noextract = _alpm_list_add(handle->noextract, strdup(pkg));
+ handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
}
-void alpm_option_set_noextracts(pmlist_t *noextract)
+void alpm_option_set_noextracts(alpm_list_t *noextract)
{
if(handle->noextract) FREELIST(handle->noextract);
if(noextract) handle->noextract = noextract;
@@ -200,9 +200,9 @@
void alpm_option_add_ignorepkg(char *pkg)
{
- handle->ignorepkg = _alpm_list_add(handle->ignorepkg, strdup(pkg));
+ handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
}
-void alpm_option_set_ignorepkgs(pmlist_t *ignorepkgs)
+void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
{
if(handle->ignorepkg) FREELIST(handle->ignorepkg);
if(ignorepkgs) handle->ignorepkg = ignorepkgs;
@@ -210,9 +210,9 @@
void alpm_option_add_holdpkg(char *pkg)
{
- handle->holdpkg = _alpm_list_add(handle->holdpkg, strdup(pkg));
+ handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
}
-void alpm_option_set_holdpkgs(pmlist_t *holdpkgs)
+void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
{
if(handle->holdpkg) FREELIST(handle->holdpkg);
if(holdpkgs) handle->holdpkg = holdpkgs;
@@ -232,9 +232,9 @@
void alpm_option_add_needle(char *needle)
{
- handle->needles = _alpm_list_add(handle->needles, strdup(needle));
+ handle->needles = alpm_list_add(handle->needles, strdup(needle));
}
-void alpm_option_set_needles(pmlist_t *needles)
+void alpm_option_set_needles(alpm_list_t *needles)
{
if(handle->needles) FREELIST(handle->needles);
if(needles) handle->needles = needles;
Index: pacman-lib/lib/libalpm/handle.h
diff -u pacman-lib/lib/libalpm/handle.h:1.12 pacman-lib/lib/libalpm/handle.h:1.13
--- pacman-lib/lib/libalpm/handle.h:1.12 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/handle.h Fri Jan 19 04:28:45 2007
@@ -23,7 +23,7 @@
#include "db.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
#include "trans.h"
@@ -37,7 +37,7 @@
pmaccess_t access;
uid_t uid;
pmdb_t *db_local;
- pmlist_t *dbs_sync; /* List of (pmdb_t *) */
+ alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
FILE *logfd;
int lckfd;
pmtrans_t *trans;
@@ -52,17 +52,17 @@
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
unsigned char usesyslog; /* Use syslog instead of logfile? */
- pmlist_t *noupgrade; /* List of packages NOT to be upgraded */
- pmlist_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
- pmlist_t *ignorepkg; /* List of packages to ignore */
- pmlist_t *holdpkg; /* List of packages which 'hold' pacman */
+ alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
+ alpm_list_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
+ alpm_list_t *ignorepkg; /* List of packages to ignore */
+ alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
time_t upgradedelay; /* Amount of time to wait before upgrading a package*/
/* servers */
char *xfercommand; /* External download command */
unsigned short nopassiveftp; /* Don't use PASV ftp connections */
unsigned short chomp; /* I Love Candy! */
- pmlist_t *needles; /* needles for searching */ /* TODO why is this here? */
+ alpm_list_t *needles; /* needles for searching */ /* TODO why is this here? */
unsigned short use_color; /* enable colorful output */
} pmhandle_t;
Index: pacman-lib/lib/libalpm/list.c
diff -u pacman-lib/lib/libalpm/list.c:1.19 pacman-lib/lib/libalpm/list.c:removed
--- pacman-lib/lib/libalpm/list.c:1.19 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/list.c Fri Jan 19 04:28:47 2007
@@ -1,361 +0,0 @@
-/*
- * list.c
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-/* pacman */
-#include "list.h"
-#include "util.h"
-
-pmlist_t *_alpm_list_new()
-{
- pmlist_t *list = NULL;
-
- list = (pmlist_t *)malloc(sizeof(pmlist_t));
- if(list == NULL) {
- return(NULL);
- }
- list->data = NULL;
- list->prev = NULL;
- list->next = NULL;
- list->last = list;
- return(list);
-}
-
-void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn)
-{
- pmlist_t *ptr, *it = list;
-
- while(it) {
- ptr = it->next;
- if(fn && it->data) {
- fn(it->data);
- }
- FREE(it);
- it = ptr;
- }
-}
-
-pmlist_t *_alpm_list_add(pmlist_t *list, void *data)
-{
- pmlist_t *ptr, *lp;
-
- ptr = list;
- if(ptr == NULL) {
- ptr = _alpm_list_new();
- if(ptr == NULL) {
- return(NULL);
- }
- }
-
- lp = _alpm_list_last(ptr);
- if(lp == ptr && lp->data == NULL) {
- /* nada */
- } else {
- lp->next = _alpm_list_new();
- if(lp->next == NULL) {
- return(NULL);
- }
- lp->next->prev = lp;
- lp->last = NULL;
- lp = lp->next;
- }
-
- lp->data = data;
- ptr->last = lp;
-
- return(ptr);
-}
-
-/* Add items to a list in sorted order. Use the given comparision func to
- * determine order.
- */
-pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn)
-{
- pmlist_t *add;
- pmlist_t *prev = NULL;
- pmlist_t *iter = list;
-
- add = _alpm_list_new();
- add->data = data;
-
- /* Find insertion point. */
- while(iter) {
- if(fn(add->data, iter->data) <= 0) break;
- prev = iter;
- iter = iter->next;
- }
-
- /* Insert node before insertion point. */
- add->prev = prev;
- add->next = iter;
-
- if(iter != NULL) {
- iter->prev = add; /* Not at end. */
- } else {
- if (list != NULL) {
- list->last = add; /* Added new to end, so update the link to last. */
- }
- }
-
- if(prev != NULL) {
- prev->next = add; /* In middle. */
- } else {
- if(list == NULL) {
- add->last = add;
- } else {
- add->last = list->last;
- list->last = NULL;
- }
- list = add; /* Start or empty, new list head. */
- }
-
- return(list);
-}
-
-/* return nth element from list (starting with 0) */
-pmlist_t* _alpm_list_nth(pmlist_t *list, int n) {
- while (n--)
- list = list->next;
- return list;
-}
-
-/* merge the two sorted sublists into one sorted list */
-pmlist_t* _alpm_list_mmerge(pmlist_t *left, pmlist_t *right, _alpm_fn_cmp fn) {
- pmlist_t *newlist;
- pmlist_t *lp;
-
- if (left == NULL)
- return right;
- if (right == NULL)
- return left;
-
- if (fn(left->data, right->data) <= 0) {
- newlist = left;
- left = left->next;
- }
- else {
- newlist = right;
- right = right->next;
- }
- newlist->prev = NULL;
- newlist->next = NULL;
- newlist->last = NULL;
- lp = newlist;
-
- while ((left != NULL) && (right != NULL)) {
- if (fn(left->data, right->data) <= 0) {
- lp->next = left;
- left->prev = lp;
- left = left->next;
- }
- else {
- lp->next = right;
- right->prev = lp;
- right = right->next;
- }
- lp = lp->next;
- lp->next = NULL;
- newlist->last = lp;
- }
- if (left != NULL) {
- lp->next = left;
- left->prev = lp;
- newlist->last = left->last;
- }
- else if (right != NULL) {
- lp->next = right;
- right->prev = lp;
- newlist->last = right->last;
- }
- return newlist;
-}
-
-/* sort an list of size n using mergesort algorithm */
-pmlist_t* _alpm_list_msort(pmlist_t *list, int len, _alpm_fn_cmp fn) {
- if (len > 1 ) {
- pmlist_t *left = list;
- pmlist_t *lastleft = _alpm_list_nth(list, len/2 - 1);
- pmlist_t *right = lastleft->next;
- /* update rights last element, to previous last element*/
- right->last = left->last;
- /* update lefts last element */
- left->last = lastleft;
- /* terminate first list */
- lastleft->next = NULL;
-
- left = _alpm_list_msort(left, len/2, fn);
- right = _alpm_list_msort(right, len - (len/2), fn);
- list = _alpm_list_mmerge(left, right, fn);
- }
- return list;
-}
-
-/* Remove an item in a list. Use the given comparaison function to find the
- * item.
- * If the item is found, 'data' is pointing to the removed element.
- * Otherwise, it is set to NULL.
- * Return the new list (without the removed element).
- */
-pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data)
-{
- pmlist_t *i = haystack;
-
- if(data) {
- *data = NULL;
- }
-
- while(i) {
- if(i->data == NULL) {
- continue;
- }
- if(fn(needle, i->data) == 0) {
- break;
- }
- i = i->next;
- }
-
- if(i) {
- /* we found a matching item */
- if(i->next) {
- i->next->prev = i->prev;
- }
- if(i->prev) {
- i->prev->next = i->next;
- }
- if(i == haystack) {
- /* The item found is the first in the chain */
- if(haystack->next) {
- haystack->next->last = haystack->last;
- }
- haystack = haystack->next;
- } else if(i == haystack->last) {
- /* The item found is the last in the chain */
- haystack->last = i->prev;
- }
-
- if(data) {
- *data = i->data;
- }
- i->data = NULL;
- FREE(i);
- }
-
- return(haystack);
-}
-
-int _alpm_list_count(const pmlist_t *list)
-{
- int i;
- const pmlist_t *lp;
-
- for(lp = list, i = 0; lp; lp = lp->next, i++);
-
- return(i);
-}
-
-int _alpm_list_is_in(void *needle, pmlist_t *haystack)
-{
- pmlist_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data == needle) {
- return(1);
- }
- }
- return(0);
-}
-
-/* Test for existence of a string in a pmlist_t
-*/
-int _alpm_list_is_strin(char *needle, pmlist_t *haystack)
-{
- pmlist_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data && !strcmp(lp->data, needle)) {
- return(1);
- }
- }
- return(0);
-}
-
-pmlist_t *_alpm_list_last(pmlist_t *list)
-{
- if(list == NULL) {
- return(NULL);
- }
-
- return(list->last);
-}
-
-/* Filter out any duplicate strings in a list.
- *
- * Not the most efficient way, but simple to implement -- we assemble
- * a new list, using is_in() to check for dupes at each iteration.
- *
- */
-pmlist_t *_alpm_list_remove_dupes(pmlist_t *list)
-{
- pmlist_t *i, *newlist = NULL;
-
- for(i = list; i; i = i->next) {
- if(!_alpm_list_is_strin(i->data, newlist)) {
- newlist = _alpm_list_add(newlist, strdup(i->data));
- }
- }
- return newlist;
-}
-
-/* Reverse the order of a list
- *
- * The caller is responsible for freeing the old list
- */
-pmlist_t *_alpm_list_reverse(pmlist_t *list)
-{
- /* simple but functional -- we just build a new list, starting
- * with the old list's tail
- */
- pmlist_t *newlist = NULL;
- pmlist_t *lp;
-
- for(lp = list->last; lp; lp = lp->prev) {
- newlist = _alpm_list_add(newlist, lp->data);
- }
-
- return(newlist);
-}
-
-pmlist_t *_alpm_list_strdup(pmlist_t *list)
-{
- pmlist_t *newlist = NULL;
- pmlist_t *lp;
-
- for(lp = list; lp; lp = lp->next) {
- newlist = _alpm_list_add(newlist, strdup(lp->data));
- }
-
- return(newlist);
-}
-
-/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/lib/libalpm/list.h
diff -u pacman-lib/lib/libalpm/list.h:1.19 pacman-lib/lib/libalpm/list.h:removed
--- pacman-lib/lib/libalpm/list.h:1.19 Thu Jan 11 12:44:39 2007
+++ pacman-lib/lib/libalpm/list.h Fri Jan 19 04:28:47 2007
@@ -1,60 +0,0 @@
-/*
- * list.h
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-#ifndef _ALPM_LIST_H
-#define _ALPM_LIST_H
-
-#include "alpm.h"
-
-/* Chained list struct */
-struct __pmlist_t {
- void *data;
- struct __pmlist_t *prev;
- struct __pmlist_t *next;
- struct __pmlist_t *last; /* Quick access to last item in list */
-};
-
-#define _FREELIST(p, f) do { if(p) { _alpm_list_free(p, f); p = NULL; } } while(0)
-#define FREELIST(p) _FREELIST(p, free)
-#define FREELISTPTR(p) _FREELIST(p, NULL)
-
-typedef void (*_alpm_fn_free)(void *);
-/* Sort comparison callback function declaration */
-typedef int (*_alpm_fn_cmp)(const void *, const void *);
-
-pmlist_t *_alpm_list_new(void);
-void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn);
-pmlist_t *_alpm_list_add(pmlist_t *list, void *data);
-pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn);
-pmlist_t* _alpm_list_mmerge(pmlist_t *left, pmlist_t *right, _alpm_fn_cmp fn);
-pmlist_t* _alpm_list_msort(pmlist_t *list, int len, _alpm_fn_cmp fn);
-pmlist_t* _alpm_list_nth(pmlist_t *list, int n);
-pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data);
-int _alpm_list_count(const pmlist_t *list);
-int _alpm_list_is_in(void *needle, pmlist_t *haystack);
-int _alpm_list_is_strin(char *needle, pmlist_t *haystack);
-pmlist_t *_alpm_list_last(pmlist_t *list);
-pmlist_t *_alpm_list_remove_dupes(pmlist_t *list);
-pmlist_t *_alpm_list_reverse(pmlist_t *list);
-pmlist_t *_alpm_list_strdup(pmlist_t *list);
-
-#endif /* _ALPM_LIST_H */
-
-/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.43 pacman-lib/lib/libalpm/package.c:1.44
--- pacman-lib/lib/libalpm/package.c:1.43 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/package.c Fri Jan 19 04:28:45 2007
@@ -33,7 +33,7 @@
#include "log.h"
#include "util.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "handle.h"
@@ -118,17 +118,17 @@
newpkg->force = pkg->force;
newpkg->scriptlet = pkg->scriptlet;
newpkg->reason = pkg->reason;
- newpkg->license = _alpm_list_strdup(pkg->license);
- newpkg->desc_localized = _alpm_list_strdup(pkg->desc_localized);
- newpkg->requiredby = _alpm_list_strdup(pkg->requiredby);
- newpkg->conflicts = _alpm_list_strdup(pkg->conflicts);
- newpkg->files = _alpm_list_strdup(pkg->files);
- newpkg->backup = _alpm_list_strdup(pkg->backup);
- newpkg->depends = _alpm_list_strdup(pkg->depends);
- newpkg->removes = _alpm_list_strdup(pkg->removes);
- newpkg->groups = _alpm_list_strdup(pkg->groups);
- newpkg->provides = _alpm_list_strdup(pkg->provides);
- newpkg->replaces = _alpm_list_strdup(pkg->replaces);
+ newpkg->license = alpm_list_strdup(pkg->license);
+ newpkg->desc_localized = alpm_list_strdup(pkg->desc_localized);
+ newpkg->requiredby = alpm_list_strdup(pkg->requiredby);
+ newpkg->conflicts = alpm_list_strdup(pkg->conflicts);
+ newpkg->files = alpm_list_strdup(pkg->files);
+ newpkg->backup = alpm_list_strdup(pkg->backup);
+ newpkg->depends = alpm_list_strdup(pkg->depends);
+ newpkg->removes = alpm_list_strdup(pkg->removes);
+ newpkg->groups = alpm_list_strdup(pkg->groups);
+ newpkg->provides = alpm_list_strdup(pkg->provides);
+ newpkg->replaces = alpm_list_strdup(pkg->replaces);
/* internal */
newpkg->origin = pkg->origin;
newpkg->data = (newpkg->origin == PKG_FROM_FILE) ? strdup(pkg->data) : pkg->data;
@@ -214,7 +214,7 @@
STRNCPY(info->version, ptr, sizeof(info->version));
} else if(!strcmp(key, "PKGDESC")) {
char *lang_tmp;
- info->desc_localized = _alpm_list_add(info->desc_localized, strdup(ptr));
+ info->desc_localized = alpm_list_add(info->desc_localized, strdup(ptr));
if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
@@ -226,11 +226,11 @@
}
FREE(lang_tmp);
} else if(!strcmp(key, "GROUP")) {
- info->groups = _alpm_list_add(info->groups, strdup(ptr));
+ info->groups = alpm_list_add(info->groups, strdup(ptr));
} else if(!strcmp(key, "URL")) {
STRNCPY(info->url, ptr, sizeof(info->url));
} else if(!strcmp(key, "LICENSE")) {
- info->license = _alpm_list_add(info->license, strdup(ptr));
+ info->license = alpm_list_add(info->license, strdup(ptr));
} else if(!strcmp(key, "BUILDDATE")) {
STRNCPY(info->builddate, ptr, sizeof(info->builddate));
} else if(!strcmp(key, "BUILDTYPE")) {
@@ -250,17 +250,17 @@
STRNCPY(tmp, ptr, sizeof(tmp));
info->isize = atol(ptr);
} else if(!strcmp(key, "DEPEND")) {
- info->depends = _alpm_list_add(info->depends, strdup(ptr));
+ info->depends = alpm_list_add(info->depends, strdup(ptr));
} else if(!strcmp(key, "REMOVE")) {
- info->removes = _alpm_list_add(info->removes, strdup(ptr));
+ info->removes = alpm_list_add(info->removes, strdup(ptr));
} else if(!strcmp(key, "CONFLICT")) {
- info->conflicts = _alpm_list_add(info->conflicts, strdup(ptr));
+ info->conflicts = alpm_list_add(info->conflicts, strdup(ptr));
} else if(!strcmp(key, "REPLACES")) {
- info->replaces = _alpm_list_add(info->replaces, strdup(ptr));
+ info->replaces = alpm_list_add(info->replaces, strdup(ptr));
} else if(!strcmp(key, "PROVIDES")) {
- info->provides = _alpm_list_add(info->provides, strdup(ptr));
+ info->provides = alpm_list_add(info->provides, strdup(ptr));
} else if(!strcmp(key, "BACKUP")) {
- info->backup = _alpm_list_add(info->backup, strdup(ptr));
+ info->backup = alpm_list_add(info->backup, strdup(ptr));
} else {
_alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
info->name[0] != '\0' ? info->name : "error", linenum);
@@ -369,7 +369,7 @@
continue;
}
_alpm_strtrim(str);
- info->files = _alpm_list_add(info->files, strdup(str));
+ info->files = alpm_list_add(info->files, strdup(str));
}
FREE(str);
fclose(fp);
@@ -386,7 +386,7 @@
/* no .FILELIST present in this package.. build the filelist the */
/* old-fashioned way, one at a time */
expath = strdup(archive_entry_pathname (entry));
- info->files = _alpm_list_add(info->files, expath);
+ info->files = alpm_list_add(info->files, expath);
}
}
@@ -417,12 +417,12 @@
return(NULL);
}
-/* Test for existence of a package in a pmlist_t*
+/* Test for existence of a package in a alpm_list_t*
* of pmpkg_t*
*/
-pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack)
+pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(needle == NULL || haystack == NULL) {
return(NULL);
@@ -668,7 +668,7 @@
return pkg->reason;
}
-pmlist_t *alpm_pkg_get_licenses(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -680,7 +680,7 @@
return pkg->license;
}
-pmlist_t *alpm_pkg_get_groups(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -693,7 +693,7 @@
}
/* depends */
-pmlist_t *alpm_pkg_get_depends(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -705,7 +705,7 @@
return pkg->depends;
}
-pmlist_t *alpm_pkg_get_removes(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_removes(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -717,7 +717,7 @@
return pkg->removes;
}
-pmlist_t *alpm_pkg_get_requiredby(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_requiredby(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -729,7 +729,7 @@
return pkg->requiredby;
}
-pmlist_t *alpm_pkg_get_conflicts(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_conflicts(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -741,7 +741,7 @@
return pkg->conflicts;
}
-pmlist_t *alpm_pkg_get_provides(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -753,7 +753,7 @@
return pkg->provides;
}
-pmlist_t *alpm_pkg_get_replaces(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -765,7 +765,7 @@
return pkg->replaces;
}
-pmlist_t *alpm_pkg_get_files(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -778,7 +778,7 @@
return pkg->files;
}
-pmlist_t *alpm_pkg_get_backup(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
Index: pacman-lib/lib/libalpm/package.h
diff -u pacman-lib/lib/libalpm/package.h:1.22 pacman-lib/lib/libalpm/package.h:1.23
--- pacman-lib/lib/libalpm/package.h:1.22 Wed Nov 22 04:03:42 2006
+++ pacman-lib/lib/libalpm/package.h Fri Jan 19 04:28:45 2007
@@ -69,17 +69,17 @@
unsigned char force;
time_t date;
unsigned char reason;
- pmlist_t *desc_localized;
- pmlist_t *license;
- pmlist_t *replaces;
- pmlist_t *groups;
- pmlist_t *files;
- pmlist_t *backup;
- pmlist_t *depends;
- pmlist_t *removes;
- pmlist_t *requiredby;
- pmlist_t *conflicts;
- pmlist_t *provides;
+ alpm_list_t *desc_localized;
+ alpm_list_t *license;
+ alpm_list_t *replaces;
+ alpm_list_t *groups;
+ alpm_list_t *files;
+ alpm_list_t *backup;
+ alpm_list_t *depends;
+ alpm_list_t *removes;
+ alpm_list_t *requiredby;
+ alpm_list_t *conflicts;
+ alpm_list_t *provides;
/* internal */
unsigned char origin;
void *data;
@@ -94,7 +94,7 @@
void _alpm_pkg_free(void *data);
int _alpm_pkg_cmp(const void *p1, const void *p2);
pmpkg_t *_alpm_pkg_load(char *pkgfile);
-pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack);
+pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack);
int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch);
Index: pacman-lib/lib/libalpm/provide.c
diff -u pacman-lib/lib/libalpm/provide.c:1.7 pacman-lib/lib/libalpm/provide.c:1.8
--- pacman-lib/lib/libalpm/provide.c:1.7 Tue Oct 31 01:39:59 2006
+++ pacman-lib/lib/libalpm/provide.c Fri Jan 19 04:28:45 2007
@@ -24,16 +24,16 @@
#include <string.h>
/* pacman */
#include "cache.h"
-#include "list.h"
+#include "alpm_list.h"
#include "db.h"
#include "provide.h"
-/* return a pmlist_t of packages in "db" that provide "package"
+/* return a alpm_list_t of packages in "db" that provide "package"
*/
-pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
+alpm_list_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
{
- pmlist_t *pkgs = NULL;
- pmlist_t *lp;
+ alpm_list_t *pkgs = NULL;
+ alpm_list_t *lp;
if(db == NULL || package == NULL || strlen(package) == 0) {
return(NULL);
@@ -42,8 +42,8 @@
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
pmpkg_t *info = lp->data;
- if(_alpm_list_is_strin(package, info->provides)) {
- pkgs = _alpm_list_add(pkgs, info);
+ if(alpm_list_is_strin(package, info->provides)) {
+ pkgs = alpm_list_add(pkgs, info);
}
}
Index: pacman-lib/lib/libalpm/provide.h
diff -u pacman-lib/lib/libalpm/provide.h:1.4 pacman-lib/lib/libalpm/provide.h:1.5
--- pacman-lib/lib/libalpm/provide.h:1.4 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/provide.h Fri Jan 19 04:28:45 2007
@@ -22,10 +22,10 @@
#define _ALPM_PROVIDE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "config.h"
-pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package);
+alpm_list_t *_alpm_db_whatprovides(pmdb_t *db, char *package);
#endif /* _ALPM_PROVIDE_H */
Index: pacman-lib/lib/libalpm/remove.c
diff -u pacman-lib/lib/libalpm/remove.c:1.55 pacman-lib/lib/libalpm/remove.c:1.56
--- pacman-lib/lib/libalpm/remove.c:1.55 Thu Jan 18 12:04:25 2007
+++ pacman-lib/lib/libalpm/remove.c Fri Jan 19 04:28:45 2007
@@ -41,7 +41,7 @@
#include <errno.h>
#include <libintl.h>
/* pacman */
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -78,7 +78,7 @@
}
/* ignore holdpkgs on upgrade */
- if((trans == handle->trans) && _alpm_list_is_strin(info->name, handle->holdpkg)) {
+ if((trans == handle->trans) && alpm_list_is_strin(info->name, handle->holdpkg)) {
int resp = 0;
QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
if(!resp) {
@@ -87,14 +87,14 @@
}
_alpm_log(PM_LOG_FLOW2, _("adding %s in the targets list"), info->name);
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
return(0);
}
-int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
+int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -107,13 +107,13 @@
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
while(lp) {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = lp; i; i = i->next) {
pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
pmpkg_t *info = _alpm_db_scan(db, miss->depend.name, INFRQ_ALL);
if(info) {
_alpm_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), info->name);
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
} else {
_alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping"),
miss->depend.name);
@@ -160,7 +160,7 @@
/* Helper function for iterating through a package's file and deleting them
* Used by _alpm_remove_commit
*/
-static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
+static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
pmtrans_t *trans, int filenum, int *position)
{
struct stat buf;
@@ -177,7 +177,7 @@
FREE(checksum);
} if ( !nb && trans->type == PM_TRANS_TYPE_UPGRADE ) {
/* check noupgrade */
- if ( _alpm_list_is_strin(file, handle->noupgrade) ) {
+ if ( alpm_list_is_strin(file, handle->noupgrade) ) {
nb = 1;
}
}
@@ -198,7 +198,7 @@
* see the big comment block in db_find_conflicts() for an
* explanation. */
int skipit = 0;
- pmlist_t *j;
+ alpm_list_t *j;
for ( j = trans->skiplist; j; j = j->next ) {
if ( !strcmp(file, (char*)j->data) ) {
skipit = 1;
@@ -222,8 +222,8 @@
}
} else {
_alpm_log(PM_LOG_FLOW2, _("unlinking %s"), line);
- int list_count = _alpm_list_count(trans->packages); /* this way we don't have to call _alpm_list_count twice during PROGRESS */
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - _alpm_list_count(targ) + 1));
+ int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
+ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
++(*position);
}
if (unlink(line) == -1) {
@@ -236,7 +236,7 @@
int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
{
pmpkg_t *info;
- pmlist_t *targ, *lp;
+ alpm_list_t *targ, *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -262,11 +262,11 @@
}
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
- int filenum = _alpm_list_count(info->files);
+ int filenum = alpm_list_count(info->files);
_alpm_log(PM_LOG_FLOW1, _("removing files"));
/* iterate through the list backwards, unlinking files */
- for(lp = _alpm_list_last(info->files); lp; lp = lp->prev) {
+ for(lp = alpm_list_last(info->files); lp; lp = lp->prev) {
unlink_file(info, lp, targ, trans, filenum, &position);
}
}
@@ -309,7 +309,7 @@
depinfo = _alpm_db_get_pkgfromcache(db, depend.name);
if(depinfo == NULL) {
/* look for a provides package */
- pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) {
/* TODO: should check _all_ packages listed in provides, not just
* the first one.
@@ -327,7 +327,7 @@
/* Ensure package has the appropriate data */
_alpm_db_read(db, INFRQ_DEPENDS, depinfo);
/* splice out this entry from requiredby */
- depinfo->requiredby = _alpm_list_remove(depinfo->requiredby, info->name, str_cmp, &vdata);
+ depinfo->requiredby = alpm_list_remove(depinfo->requiredby, info->name, str_cmp, &vdata);
data = vdata;
FREE(data);
_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), depinfo->name);
@@ -337,7 +337,7 @@
}
}
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 100, _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 100, alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
EVENT(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL);
}
Index: pacman-lib/lib/libalpm/remove.h
diff -u pacman-lib/lib/libalpm/remove.h:1.6 pacman-lib/lib/libalpm/remove.h:1.7
--- pacman-lib/lib/libalpm/remove.h:1.6 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/remove.h Fri Jan 19 04:28:45 2007
@@ -22,11 +22,11 @@
#define _ALPM_REMOVE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
-int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data);
+int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data);
int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db);
#endif /* _ALPM_REMOVE_H */
Index: pacman-lib/lib/libalpm/server.c
diff -u pacman-lib/lib/libalpm/server.c:1.15 pacman-lib/lib/libalpm/server.c:1.16
--- pacman-lib/lib/libalpm/server.c:1.15 Thu Jan 18 11:53:00 2007
+++ pacman-lib/lib/libalpm/server.c Fri Jan 19 04:28:45 2007
@@ -94,7 +94,7 @@
*
* RETURN: 0 for successful download, 1 on error
*/
-int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files)
+int _alpm_downloadfiles(alpm_list_t *servers, const char *localpath, alpm_list_t *files)
{
return(_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL));
}
@@ -112,14 +112,14 @@
* 1 if the mtimes are identical
* -1 on error
*/
-int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
- pmlist_t *files, const char *mtime1, char *mtime2)
+int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
+ alpm_list_t *files, const char *mtime1, char *mtime2)
{
int dltotal_bytes = 0;
- pmlist_t *lp;
+ alpm_list_t *lp;
int done = 0;
- pmlist_t *complete = NULL;
- pmlist_t *i;
+ alpm_list_t *complete = NULL;
+ alpm_list_t *i;
if(files == NULL) {
return(0);
@@ -137,7 +137,7 @@
snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn);
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
- if(_alpm_list_is_strin(fn, complete)) {
+ if(alpm_list_is_strin(fn, complete)) {
continue;
}
@@ -196,7 +196,7 @@
_alpm_time2string(ust.mtime, strtime);
if(strcmp(mtime1, strtime) == 0) {
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s"), fn);
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
if(localf != NULL) {
fclose(localf);
}
@@ -246,7 +246,7 @@
fclose(localf);
fclose(dlf);
rename(output, realfile);
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
} else {
int ret;
int usepart = 0;
@@ -298,7 +298,7 @@
_alpm_log(PM_LOG_DEBUG, _("XferCommand command returned non-zero status code (%d)"), ret);
} else {
/* download was successful */
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
if(usepart) {
char fnpart[PATH_MAX];
/* rename "output.part" file to "output" file */
@@ -310,7 +310,7 @@
}
}
- if(_alpm_list_count(complete) == _alpm_list_count(files)) {
+ if(alpm_list_count(complete) == alpm_list_count(files)) {
done = 1;
}
}
@@ -344,8 +344,8 @@
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory"), s_url->doc);
} else {
pmserver_t *server;
- pmlist_t *servers = NULL;
- pmlist_t *files;
+ alpm_list_t *servers = NULL;
+ alpm_list_t *files;
if((server = (pmserver_t *)malloc(sizeof(pmserver_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));
@@ -357,9 +357,9 @@
server->s_url = s_url;
server->path = strdup(s_url->doc);
- servers = _alpm_list_add(servers, server);
+ servers = alpm_list_add(servers, server);
- files = _alpm_list_add(NULL, strdup(p));
+ files = alpm_list_add(NULL, strdup(p));
if(_alpm_downloadfiles(servers, ".", files)) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s"), target);
return(NULL);
Index: pacman-lib/lib/libalpm/server.h
diff -u pacman-lib/lib/libalpm/server.h:1.8 pacman-lib/lib/libalpm/server.h:1.9
--- pacman-lib/lib/libalpm/server.h:1.8 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/server.h Fri Jan 19 04:28:45 2007
@@ -21,7 +21,7 @@
#ifndef _ALPM_SERVER_H
#define _ALPM_SERVER_H
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
#include <time.h>
@@ -40,9 +40,9 @@
pmserver_t *_alpm_server_new(const char *url);
void _alpm_server_free(void *data);
-int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files);
-int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
- pmlist_t *files, const char *mtime1, char *mtime2);
+int _alpm_downloadfiles(alpm_list_t *servers, const char *localpath, alpm_list_t *files);
+int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
+ alpm_list_t *files, const char *mtime1, char *mtime2);
char *_alpm_fetch_pkgurl(char *target);
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.90 pacman-lib/lib/libalpm/sync.c:1.91
--- pacman-lib/lib/libalpm/sync.c:1.90 Thu Jan 18 11:53:01 2007
+++ pacman-lib/lib/libalpm/sync.c Fri Jan 19 04:28:45 2007
@@ -36,7 +36,7 @@
/* pacman */
#include "log.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "cache.h"
@@ -87,12 +87,12 @@
FREE(sync);
}
-/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
+/* Test for existence of a package in a alpm_list_t* of pmsyncpkg_t*
* If found, return a pointer to the respective pmsyncpkg_t*
*/
-static pmsyncpkg_t *find_pkginsync(char *needle, pmlist_t *haystack)
+static pmsyncpkg_t *find_pkginsync(char *needle, alpm_list_t *haystack)
{
- pmlist_t *i;
+ alpm_list_t *i;
pmsyncpkg_t *sync = NULL;
int found = 0;
@@ -122,9 +122,9 @@
* (refactored from _alpm_sync_prepare)
*/
static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
- pmlist_t *dbs_sync)
+ alpm_list_t *dbs_sync)
{
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
@@ -132,12 +132,12 @@
for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DESC); j; j = j->next) {
pmpkg_t *spkg = j->data;
for(k = spkg->replaces; k; k = k->next) {
- pmlist_t *m;
+ alpm_list_t *m;
for(m = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); m; m = m->next) {
pmpkg_t *lpkg = m->data;
if(strcmp(k->data, lpkg->name) == 0) {
_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
- if(_alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
+ if(alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
lpkg->name, lpkg->version, spkg->name, spkg->version);
} else {
@@ -155,12 +155,12 @@
pm_errno = PM_ERR_MEMORY;
goto error;
}
- dummy->requiredby = _alpm_list_strdup(lpkg->requiredby);
+ dummy->requiredby = alpm_list_strdup(lpkg->requiredby);
/* check if spkg->name is already in the packages list. */
sync = find_pkginsync(spkg->name, trans->packages);
if(sync) {
/* found it -- just append to the replaces list */
- sync->data = _alpm_list_add(sync->data, dummy);
+ sync->data = alpm_list_add(sync->data, dummy);
} else {
/* none found -- enter pkg into the final sync list */
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
@@ -169,8 +169,8 @@
pm_errno = PM_ERR_MEMORY;
goto error;
}
- sync->data = _alpm_list_add(NULL, dummy);
- trans->packages = _alpm_list_add(trans->packages, sync);
+ sync->data = alpm_list_add(NULL, dummy);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (to be replaced by %s-%s)"),
lpkg->name, lpkg->version, spkg->name, spkg->version);
@@ -187,9 +187,9 @@
return(-1);
}
-int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync)
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
- pmlist_t *i, *j;
+ alpm_list_t *i, *j;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
@@ -235,7 +235,7 @@
local->name, local->version, db->treename, spkg->version);
} else if(cmp == 0) {
/* versions are identical */
- } else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
+ } else if(alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
@@ -257,7 +257,7 @@
FREEPKG(dummy);
goto error;
}
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
} else {
/* spkg->name is already in the packages list -- just ignore it */
}
@@ -271,11 +271,11 @@
return(-1);
}
-int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name)
+int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name)
{
char targline[PKG_FULLNAME_LEN];
char *targ;
- pmlist_t *j;
+ alpm_list_t *j;
pmpkg_t *local;
pmpkg_t *spkg = NULL;
pmsyncpkg_t *sync;
@@ -298,7 +298,7 @@
spkg = _alpm_db_get_pkgfromcache(dbs, targ);
if(spkg == NULL) {
/* Search provides */
- pmlist_t *p;
+ alpm_list_t *p;
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
p = _alpm_db_whatprovides(dbs, targ);
if(p == NULL) {
@@ -325,7 +325,7 @@
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
for(j = dbs_sync; j && !spkg; j = j->next) {
pmdb_t *dbs = j->data;
- pmlist_t *p = _alpm_db_whatprovides(dbs, targ);
+ alpm_list_t *p = _alpm_db_whatprovides(dbs, targ);
if(p) {
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ);
spkg = _alpm_db_get_pkgfromcache(dbs, p->data);
@@ -375,13 +375,13 @@
RET_ERR(PM_ERR_MEMORY, -1);
}
_alpm_log(PM_LOG_FLOW2, _("adding target '%s' to the transaction set"), spkg->name);
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
return(0);
}
-/* Helper functions for _alpm_list_remove
+/* Helper functions for alpm_list_remove
*/
/* removed - use pkg_cmp all of the time
static int ptr_cmp(const void *s1, const void *s2)
@@ -394,13 +394,13 @@
return(strcmp(((pmpkg_t *)p1)->name, ((pmsyncpkg_t *)p2)->pkg->name));
}
-int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, pmlist_t **data)
+int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
{
- pmlist_t *deps = NULL;
- pmlist_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */
- pmlist_t *trail = NULL; /* breadcrumb list to avoid running into circles */
- pmlist_t *asked = NULL;
- pmlist_t *i, *j, *k, *l;
+ alpm_list_t *deps = NULL;
+ alpm_list_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */
+ alpm_list_t *trail = NULL; /* breadcrumb list to avoid running into circles */
+ alpm_list_t *asked = NULL;
+ alpm_list_t *i, *j, *k, *l;
int ret = 0;
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -412,11 +412,11 @@
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
- list = _alpm_list_add(list, sync->pkg);
+ list = alpm_list_add(list, sync->pkg);
}
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
- trail = _alpm_list_new();
+ trail = alpm_list_new();
/* Resolve targets dependencies */
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
@@ -439,7 +439,7 @@
ret = -1;
goto cleanup;
}
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
_alpm_log(PM_LOG_FLOW2, _("adding package %s-%s to the transaction targets"),
spkg->name, spkg->version);
} else {
@@ -447,7 +447,7 @@
if((trans->flags & PM_TRANS_FLAG_DEPENDSONLY)) {
void *vp;
pmpkg_t *p;
- trans->packages = _alpm_list_remove(trans->packages, spkg, pkg_cmp, &vp);
+ trans->packages = alpm_list_remove(trans->packages, spkg, pkg_cmp, &vp);
p = vp;
FREEPKG(p);
}
@@ -458,14 +458,14 @@
k = l = NULL;
for(i=trans->packages; i; i=i->next) {
pmsyncpkg_t *s = (pmsyncpkg_t*)i->data;
- k = _alpm_list_add(k, s->pkg);
+ k = alpm_list_add(k, s->pkg);
}
k = _alpm_sortbydeps(k, PM_TRANS_TYPE_ADD);
for(i=k; i; i=i->next) {
for(j=trans->packages; j; j=j->next) {
pmsyncpkg_t *s = (pmsyncpkg_t*)j->data;
if(s->pkg==i->data) {
- l = _alpm_list_add(l, s);
+ l = alpm_list_add(l, s);
}
}
}
@@ -535,7 +535,7 @@
local = _alpm_db_get_pkgfromcache(db_local, miss->depend.name);
/* check if this package also "provides" the package it's conflicting with
*/
- if(_alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
+ if(alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
/* so just treat it like a "replaces" item so the REQUIREDBY
* fields are inherited properly.
*/
@@ -559,8 +559,8 @@
/* figure out which one was requested in targets. If they both were,
* then it's still an unresolvable conflict. */
- target = _alpm_list_is_strin(miss->target, trans->targets);
- depend = _alpm_list_is_strin(miss->depend.name, trans->targets);
+ target = alpm_list_is_strin(miss->target, trans->targets);
+ depend = alpm_list_is_strin(miss->depend.name, trans->targets);
if(depend && !target) {
_alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"),
miss->depend.name);
@@ -580,7 +580,7 @@
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
- trans->packages = _alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
continue;
}
@@ -591,9 +591,9 @@
_alpm_log(PM_LOG_DEBUG, _("resolving package '%s' conflict"), miss->target);
if(local) {
int doremove = 0;
- if(!_alpm_list_is_strin(miss->depend.name, asked)) {
+ if(!alpm_list_is_strin(miss->depend.name, asked)) {
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
- asked = _alpm_list_add(asked, strdup(miss->depend.name));
+ asked = alpm_list_add(asked, strdup(miss->depend.name));
if(doremove) {
pmsyncpkg_t *rsync = find_pkginsync(miss->depend.name, trans->packages);
pmpkg_t *q = _alpm_pkg_new(miss->depend.name, NULL);
@@ -604,7 +604,7 @@
ret = -1;
goto cleanup;
}
- q->requiredby = _alpm_list_strdup(local->requiredby);
+ q->requiredby = alpm_list_strdup(local->requiredby);
if(sync->type != PM_SYNC_TYPE_REPLACE) {
/* switch this sync type to REPLACE */
sync->type = PM_SYNC_TYPE_REPLACE;
@@ -612,12 +612,12 @@
}
/* append to the replaces list */
_alpm_log(PM_LOG_FLOW2, _("electing '%s' for removal"), miss->depend.name);
- sync->data = _alpm_list_add(sync->data, q);
+ sync->data = alpm_list_add(sync->data, q);
if(rsync) {
/* remove it from the target list */
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name);
- trans->packages = _alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
}
} else {
@@ -633,7 +633,7 @@
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -649,7 +649,7 @@
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -685,7 +685,7 @@
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
for(j = sync->data; j; j = j->next) {
- list = _alpm_list_add(list, j->data);
+ list = alpm_list_add(list, j->data);
}
}
}
@@ -698,7 +698,7 @@
pmdepmissing_t *miss = i->data;
if(!find_pkginsync(miss->depend.name, trans->packages)) {
int pfound = 0;
- pmlist_t *k;
+ alpm_list_t *k;
/* If miss->depend.name depends on something that miss->target and a
* package in final both provide, then it's okay... */
pmpkg_t *leavingp = _alpm_db_get_pkgfromcache(db_local, miss->target);
@@ -711,13 +711,13 @@
/* Look through the upset package's dependencies and try to match one up
* to a provisio from the package we want to remove */
for(k = conflictp->depends; k && !pfound; k = k->next) {
- pmlist_t *m;
+ alpm_list_t *m;
for(m = leavingp->provides; m && !pfound; m = m->next) {
if(!strcmp(k->data, m->data)) {
/* Found a match -- now look through final for a package that
* provides the same thing. If none are found, then it truly
* is an unresolvable conflict. */
- pmlist_t *n, *o;
+ alpm_list_t *n, *o;
for(n = trans->packages; n && !pfound; n = n->next) {
pmsyncpkg_t *sp = n->data;
for(o = sp->pkg->provides; o && !pfound; o = o->next) {
@@ -745,7 +745,7 @@
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -780,9 +780,9 @@
return(ret);
}
-int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
+int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{
- pmlist_t *i, *j, *files = NULL;
+ alpm_list_t *i, *j, *files = NULL;
pmtrans_t *tr = NULL;
int replaces = 0, retval = 0;
char ldir[PATH_MAX];
@@ -815,7 +815,7 @@
snprintf(path, PATH_MAX, "%s/%s", ldir, fname);
if(stat(path, &buf)) {
/* file is not in the cache dir, so add it to the list */
- files = _alpm_list_add(files, strdup(fname));
+ files = alpm_list_add(files, strdup(fname));
} else {
_alpm_log(PM_LOG_DEBUG, _("%s is already in the cache\n"), fname);
}
@@ -872,7 +872,7 @@
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
continue;
}
@@ -884,7 +884,7 @@
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
continue;
}
@@ -906,7 +906,7 @@
} else {
snprintf(ptr, 512, _("archive %s is corrupted (bad MD5 or SHA1 checksum)\n"), pkgname);
}
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
}
FREE(md5sum2);
@@ -938,7 +938,7 @@
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j;
+ alpm_list_t *j;
for(j = sync->data; j; j = j->next) {
pmpkg_t *pkg = j->data;
if(!_alpm_pkg_isin(pkg->name, tr->packages)) {
@@ -989,9 +989,9 @@
if(_alpm_trans_addtarget(tr, str) == -1) {
goto error;
}
- /* using _alpm_list_last() is ok because addtarget() adds the new target at the
+ /* using alpm_list_last() is ok because addtarget() adds the new target at the
* end of the tr->packages list */
- spkg = _alpm_list_last(tr->packages)->data;
+ spkg = alpm_list_last(tr->packages)->data;
if(sync->type == PM_SYNC_TYPE_DEPEND) {
spkg->reason = PM_PKG_REASON_DEPEND;
}
@@ -1013,16 +1013,16 @@
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j;
+ alpm_list_t *j;
pmpkg_t *new = _alpm_db_get_pkgfromcache(db_local, sync->pkg->name);
for(j = sync->data; j; j = j->next) {
- pmlist_t *k;
+ alpm_list_t *k;
pmpkg_t *old = j->data;
/* merge lists */
for(k = old->requiredby; k; k = k->next) {
- if(!_alpm_list_is_strin(k->data, new->requiredby)) {
+ if(!alpm_list_is_strin(k->data, new->requiredby)) {
/* replace old's name with new's name in the requiredby's dependency list */
- pmlist_t *m;
+ alpm_list_t *m;
pmpkg_t *depender = _alpm_db_get_pkgfromcache(db_local, k->data);
if(depender == NULL) {
/* If the depending package no longer exists in the local db,
@@ -1042,7 +1042,7 @@
new->name, new->version);
}
/* add the new requiredby */
- new->requiredby = _alpm_list_add(new->requiredby, strdup(k->data));
+ new->requiredby = alpm_list_add(new->requiredby, strdup(k->data));
}
}
}
Index: pacman-lib/lib/libalpm/sync.h
diff -u pacman-lib/lib/libalpm/sync.h:1.15 pacman-lib/lib/libalpm/sync.h:1.16
--- pacman-lib/lib/libalpm/sync.h:1.15 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/sync.h Fri Jan 19 04:28:45 2007
@@ -37,10 +37,10 @@
pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data);
void _alpm_sync_free(void *data);
-int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync);
-int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name);
-int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, pmlist_t **data);
-int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data);
+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);
+int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data);
#endif /* _ALPM_SYNC_H */
Index: pacman-lib/lib/libalpm/trans.c
diff -u pacman-lib/lib/libalpm/trans.c:1.29 pacman-lib/lib/libalpm/trans.c:1.30
--- pacman-lib/lib/libalpm/trans.c:1.29 Wed Nov 22 04:03:42 2006
+++ pacman-lib/lib/libalpm/trans.c Fri Jan 19 04:28:45 2007
@@ -32,7 +32,7 @@
#include "package.h"
#include "util.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "handle.h"
#include "add.h"
#include "remove.h"
@@ -71,7 +71,7 @@
FREELIST(trans->targets);
if(trans->type == PM_TRANS_TYPE_SYNC) {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = trans->packages; i; i = i->next) {
FREESYNC(i->data);
}
@@ -114,7 +114,7 @@
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- if(_alpm_list_is_strin(target, trans->targets)) {
+ if(alpm_list_is_strin(target, trans->targets)) {
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
}
@@ -140,12 +140,12 @@
break;
}
- trans->targets = _alpm_list_add(trans->targets, strdup(target));
+ trans->targets = alpm_list_add(trans->targets, strdup(target));
return(0);
}
-int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data)
+int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data)
{
*data = NULL;
@@ -184,7 +184,7 @@
return(0);
}
-int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data)
+int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data)
{
if(data!=NULL)
*data = NULL;
@@ -244,7 +244,7 @@
return handle->trans->flags;
}
-pmlist_t * alpm_trans_get_targets()
+alpm_list_t * alpm_trans_get_targets()
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -253,7 +253,7 @@
return handle->trans->targets;
}
-pmlist_t * alpm_trans_get_packages()
+alpm_list_t * alpm_trans_get_packages()
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
Index: pacman-lib/lib/libalpm/trans.h
diff -u pacman-lib/lib/libalpm/trans.h:1.20 pacman-lib/lib/libalpm/trans.h:1.21
--- pacman-lib/lib/libalpm/trans.h:1.20 Mon Nov 20 04:10:24 2006
+++ pacman-lib/lib/libalpm/trans.h Fri Jan 19 04:28:45 2007
@@ -31,9 +31,9 @@
unsigned char type;
unsigned int flags;
unsigned char state;
- pmlist_t *targets; /* pmlist_t of (char *) */
- pmlist_t *packages; /* pmlist_t of (pmpkg_t *) or (pmsyncpkg_t *) */
- pmlist_t *skiplist; /* pmlist_t of (char *) */
+ alpm_list_t *targets; /* alpm_list_t of (char *) */
+ alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
+ alpm_list_t *skiplist; /* alpm_list_t of (char *) */
alpm_trans_cb_event cb_event;
alpm_trans_cb_conv cb_conv;
alpm_trans_cb_progress cb_progress;
@@ -80,8 +80,8 @@
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int 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, pmlist_t **data);
-int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data);
+int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
+int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
#endif /* _ALPM_TRANS_H */
Index: pacman-lib/lib/libalpm/util.c
diff -u pacman-lib/lib/libalpm/util.c:1.38 pacman-lib/lib/libalpm/util.c:1.39
--- pacman-lib/lib/libalpm/util.c:1.38 Thu Jan 18 11:53:01 2007
+++ pacman-lib/lib/libalpm/util.c Fri Jan 19 04:28:45 2007
@@ -55,8 +55,8 @@
#endif
/* pacman */
+#include "alpm_list.h"
#include "log.h"
-#include "list.h"
#include "trans.h"
#include "sync.h"
#include "util.h"
@@ -563,9 +563,9 @@
return(ret);
}
-int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
+int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data)
{
- pmlist_t *i;
+ alpm_list_t *i;
long long pkgsize=0, freespace;
for(i = trans->packages; i; i = i->next) {
@@ -594,7 +594,7 @@
return(-1);
}
*ptr = pkgsize;
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
FREELIST(*data);
@@ -602,7 +602,7 @@
return(-1);
}
*ptr = freespace;
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
}
pm_errno = PM_ERR_DISK_FULL;
return(-1);
Index: pacman-lib/lib/libalpm/util.h
diff -u pacman-lib/lib/libalpm/util.h:1.17 pacman-lib/lib/libalpm/util.h:1.18
--- pacman-lib/lib/libalpm/util.h:1.17 Wed Jan 17 02:21:07 2007
+++ pacman-lib/lib/libalpm/util.h Fri Jan 19 04:28:45 2007
@@ -67,7 +67,7 @@
#ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
#ifndef __sun__
-int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data);
+int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data);
#endif
#endif
void _alpm_time2string(time_t t, char *buffer);
Index: pacman-lib/lib/libalpm/versioncmp.c
diff -u pacman-lib/lib/libalpm/versioncmp.c:1.7 pacman-lib/lib/libalpm/versioncmp.c:1.8
--- pacman-lib/lib/libalpm/versioncmp.c:1.7 Wed Nov 22 15:03:52 2006
+++ pacman-lib/lib/libalpm/versioncmp.c Fri Jan 19 04:28:45 2007
@@ -31,7 +31,7 @@
#include "alpm.h"
#include "log.h"
#include "util.h"
-#include "list.h"
+#include "alpm_list.h"
#include "versioncmp.h"
#ifndef HAVE_STRVERSCMP
@@ -247,7 +247,7 @@
{
int equal = 0;
- if(strcmp(pkg->name, dep->name) == 0 || _alpm_list_is_strin(dep->name, pkg->provides)) {
+ if(strcmp(pkg->name, dep->name) == 0 || alpm_list_is_strin(dep->name, pkg->provides)) {
if(dep->mod == PM_DEP_MOD_ANY) {
equal = 1;
} else {
Index: pacman-lib/src/pacman/Makefile.am
diff -u pacman-lib/src/pacman/Makefile.am:1.10 pacman-lib/src/pacman/Makefile.am:1.11
--- pacman-lib/src/pacman/Makefile.am:1.10 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/Makefile.am Fri Jan 19 04:28:46 2007
@@ -11,7 +11,7 @@
AM_CFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/lib/libalpm $(CFLAGS)
-pacman_SOURCES = util.c log.c list.c package.c downloadprog.c trans.c add.c \
+pacman_SOURCES = util.c log.c package.c downloadprog.c trans.c add.c \
remove.c upgrade.c query.c sync.c conf.c deptest.c pacman.c
pacman_static_SOURCES = $(pacman_SOURCES)
Index: pacman-lib/src/pacman/add.c
diff -u pacman-lib/src/pacman/add.c:1.22 pacman-lib/src/pacman/add.c:1.23
--- pacman-lib/src/pacman/add.c:1.22 Wed Nov 22 04:03:42 2006
+++ pacman-lib/src/pacman/add.c Fri Jan 19 04:28:46 2007
@@ -25,9 +25,9 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "log.h"
-#include "list.h"
#include "downloadprog.h"
#include "trans.h"
#include "add.h"
@@ -36,10 +36,9 @@
extern config_t *config;
-int pacman_add(list_t *targets)
+int pacman_add(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
+ alpm_list_t *i = targets, *data;
int retval = 0;
if(targets == NULL) {
@@ -48,7 +47,7 @@
/* Check for URL targets and process them
*/
- for(i = targets; i; i = i->next) {
+ while(i) {
if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(i->data);
if(str == NULL) {
@@ -58,6 +57,7 @@
i->data = str;
}
}
+ i = i->next;
}
/* Step 1: create a new transaction
@@ -67,7 +67,7 @@
ERR(NL, "%s\n", alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
- " you can remove %s%s\n"), config->root, PM_LOCK);
+ " you can remove %s%s\n"), config->root, PM_LOCK);
}
return(1);
}
@@ -87,12 +87,11 @@
*/
if(alpm_trans_prepare(&data) == -1) {
long long *pkgsize, *freespace;
- pmlist_t *i;
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
@@ -105,14 +104,14 @@
}
break;
case PM_ERR_CONFLICTING_DEPS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: conflicts with %s"),
alpm_dep_get_target(miss), alpm_dep_get_name(miss));
}
break;
case PM_ERR_FILE_CONFLICTS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmconflict_t *conflict = alpm_list_getdata(i);
switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET:
@@ -132,13 +131,16 @@
}
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
+ /* TODO This is gross... we should not return these values in the same list we
+ * would get conflicts and such with... it's just silly
+ */
case PM_ERR_DISK_FULL:
- i = alpm_list_first(data);
+ i = data;
pkgsize = alpm_list_getdata(i);
i = alpm_list_next(i);
freespace = alpm_list_getdata(i);
MSG(NL, _(":: %.1f MB required, have %.1f MB"),
- (double)(*pkgsize / 1048576.0), (double)(*freespace / 1048576.0));
+ (double)(*pkgsize / (1024.0*1024.0)), (double)(*freespace / (1024.0*1024.0)));
break;
default:
break;
@@ -157,8 +159,7 @@
cleanup:
if(data) {
- alpm_list_free(data);
- data = NULL;
+ alpm_list_free(data, NULL);
}
if(alpm_trans_release() == -1) {
ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno));
Index: pacman-lib/src/pacman/add.h
diff -u pacman-lib/src/pacman/add.h:1.2 pacman-lib/src/pacman/add.h:1.3
--- pacman-lib/src/pacman/add.h:1.2 Mon Jan 2 14:55:36 2006
+++ pacman-lib/src/pacman/add.h Fri Jan 19 04:28:46 2007
@@ -21,7 +21,9 @@
#ifndef _PM_ADD_H
#define _PM_ADD_H
-int pacman_add(list_t *targets);
+#include <alpm.h>
+
+int pacman_add(alpm_list_t *targets);
#endif /* _PM_ADD_H */
Index: pacman-lib/src/pacman/conf.c
diff -u pacman-lib/src/pacman/conf.c:1.20 pacman-lib/src/pacman/conf.c:1.21
--- pacman-lib/src/pacman/conf.c:1.20 Fri Dec 8 03:17:41 2006
+++ pacman-lib/src/pacman/conf.c Fri Jan 19 04:28:46 2007
@@ -26,16 +26,14 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "sync.h"
#include "downloadprog.h"
#include "conf.h"
-extern list_t *pmc_syncs;
-
config_t *config_new()
{
config_t *config;
@@ -61,14 +59,4 @@
return(0);
}
-void cb_db_register(char *section, pmdb_t *db)
-{
- sync_t *sync;
-
- MALLOC(sync, sizeof(sync_t));
- sync->treename = strdup(section);
- sync->db = db;
- pmc_syncs = list_add(pmc_syncs, sync);
-}
-
/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/src/pacman/conf.h
diff -u pacman-lib/src/pacman/conf.h:1.12 pacman-lib/src/pacman/conf.h:1.13
--- pacman-lib/src/pacman/conf.h:1.12 Fri Dec 8 03:17:41 2006
+++ pacman-lib/src/pacman/conf.h Fri Jan 19 04:28:46 2007
@@ -21,6 +21,8 @@
#ifndef _PM_CONF_H
#define _PM_CONF_H
+#include <alpm.h>
+
typedef struct __config_t {
/* command line options */
char *root;
@@ -47,7 +49,7 @@
unsigned short op_s_clean;
unsigned short op_s_dependsonly;
unsigned short op_s_downloadonly;
- list_t *op_s_ignore;
+ alpm_list_t *op_s_ignore;
unsigned short op_s_info;
unsigned short op_s_sync;
unsigned short op_s_search;
@@ -63,7 +65,6 @@
config_t *config_new(void);
int config_free(config_t *config);
-void cb_db_register(char *section, pmdb_t *db);
#endif /* _PM_CONF_H */
Index: pacman-lib/src/pacman/deptest.c
diff -u pacman-lib/src/pacman/deptest.c:1.9 pacman-lib/src/pacman/deptest.c:1.10
--- pacman-lib/src/pacman/deptest.c:1.9 Wed Nov 22 04:03:42 2006
+++ pacman-lib/src/pacman/deptest.c Fri Jan 19 04:28:46 2007
@@ -26,9 +26,9 @@
#include <string.h>
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
-#include "list.h"
#include "conf.h"
#include "log.h"
#include "sync.h"
@@ -36,10 +36,12 @@
extern config_t *config;
-int pacman_deptest(list_t *targets)
+/* TODO this function is fairly messy, with the obscure return codes and the odd
+ * 'dummy' packages and all these messy FREELISTs of synctargs
+ */
+int pacman_deptest(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
+ alpm_list_t *data, *i;
char *str;
int retval = 0;
@@ -48,8 +50,11 @@
}
if(config->op_d_vertest) {
- if(targets->data && targets->next && targets->next->data) {
- int ret = alpm_pkg_vercmp(targets->data, targets->next->data);
+ const char *pkga, *pkgb;
+ pkga = alpm_list_getdata(targets);
+ i = alpm_list_next(targets);
+ if(pkga && i && (pkgb = alpm_list_getdata(i))) {
+ int ret = alpm_pkg_vercmp(pkga, pkgb);
printf("%d\n", ret);
return(ret);
}
@@ -79,10 +84,11 @@
goto cleanup;
}
strcpy(str, "name=dummy|version=1.0-1");
- for(i = targets; i; i = i->next) {
- str = (char *)realloc(str, strlen(str)+8+strlen(i->data)+1);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ const char *targ = alpm_list_getdata(i);
+ str = (char *)realloc(str, strlen(str)+8+strlen(targ)+1);
strcat(str, "|depend=");
- strcat(str, i->data);
+ strcat(str, targ);
}
vprint(_("add target %s\n"), str);
if(alpm_trans_addtarget(str) == -1) {
@@ -94,8 +100,7 @@
FREE(str);
if(alpm_trans_prepare(&data) == -1) {
- pmlist_t *lp;
- list_t *synctargs = NULL;
+ alpm_list_t *synctargs = NULL;
retval = 126;
/* return 126 = deps were missing, but successfully resolved
* return 127 = deps were missing, and failed to resolve; OR
@@ -104,8 +109,8 @@
*/
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
@@ -115,18 +120,18 @@
}
MSG(CL, "\n");
}
- synctargs = list_add(synctargs, strdup(alpm_dep_get_name(miss)));
+ synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss)));
}
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
case PM_ERR_CONFLICTING_DEPS:
/* we can't auto-resolve conflicts */
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
}
retval = 127;
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
default:
retval = 127;
Index: pacman-lib/src/pacman/deptest.h
diff -u pacman-lib/src/pacman/deptest.h:1.1 pacman-lib/src/pacman/deptest.h:1.2
--- pacman-lib/src/pacman/deptest.h:1.1 Fri Jan 6 17:19:14 2006
+++ pacman-lib/src/pacman/deptest.h Fri Jan 19 04:28:46 2007
@@ -21,7 +21,9 @@
#ifndef _PM_DEPTEST_H
#define _PM_DEPTEST_H
-int pacman_deptest(list_t *targets);
+#include <alpm.h>
+
+int pacman_deptest(alpm_list_t *targets);
#endif /* _PM_DEPTEST_H */
Index: pacman-lib/src/pacman/downloadprog.c
diff -u pacman-lib/src/pacman/downloadprog.c:1.5 pacman-lib/src/pacman/downloadprog.c:1.6
--- pacman-lib/src/pacman/downloadprog.c:1.5 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/downloadprog.c Fri Jan 19 04:28:46 2007
@@ -34,7 +34,6 @@
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "downloadprog.h"
#include "conf.h"
Index: pacman-lib/src/pacman/list.c
diff -u pacman-lib/src/pacman/list.c:1.9 pacman-lib/src/pacman/list.c:removed
--- pacman-lib/src/pacman/list.c:1.9 Tue Nov 21 23:53:10 2006
+++ pacman-lib/src/pacman/list.c Fri Jan 19 04:28:47 2007
@@ -1,197 +0,0 @@
-/*
- * list.c
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <libintl.h>
-/* pacman */
-#include "util.h"
-#include "list.h"
-
-static list_t *list_last(list_t *list);
-
-list_t *list_new()
-{
- list_t *list = NULL;
-
- list = (list_t *)malloc(sizeof(list_t));
- if(list == NULL) {
- return(NULL);
- }
- list->data = NULL;
- list->next = NULL;
- return(list);
-}
-
-void list_free(list_t *list)
-{
- list_t *ptr, *it = list;
-
- while(it) {
- ptr = it->next;
- free(it->data);
- free(it);
- it = ptr;
- }
- return;
-}
-
-list_t *list_add(list_t *list, void *data)
-{
- list_t *ptr, *lp;
-
- ptr = list;
- if(ptr == NULL) {
- ptr = list_new();
- }
-
- lp = list_last(ptr);
- if(lp == ptr && lp->data == NULL) {
- /* nada */
- } else {
- lp->next = list_new();
- if(lp->next == NULL) {
- return(NULL);
- }
- lp = lp->next;
- }
- lp->data = data;
- return(ptr);
-}
-
-int list_count(list_t *list)
-{
- int i;
- list_t *lp;
-
- for(lp = list, i = 0; lp; lp = lp->next, i++);
-
- return(i);
-}
-
-static list_t *list_last(list_t *list)
-{
- list_t *ptr;
-
- for(ptr = list; ptr && ptr->next; ptr = ptr->next);
- return(ptr);
-}
-
-/* Test for existence of a string in a list_t
- */
-int list_is_strin(const char *needle, list_t *haystack)
-{
- list_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data && !strcmp(lp->data, needle)) {
- return(1);
- }
- }
- return(0);
-}
-
-/* Display the content of a list_t struct of strings
- */
-
-void list_display(const char *title, list_t *list)
-{
- list_t *lp;
- int cols, len;
-
- len = strlen(title);
- printf("%s ", title);
-
- if(list) {
- for(lp = list, cols = len; lp; lp = lp->next) {
- int s = strlen((char *)lp->data)+1;
- unsigned int maxcols = getcols();
- if(s+cols >= maxcols) {
- int i;
- cols = len;
- printf("\n");
- for (i = 0; i < len+1; i++) {
- printf(" ");
- }
- }
- printf("%s ", (char *)lp->data);
- cols += s;
- }
- printf("\n");
- } else {
- printf(_("None\n"));
- }
-}
-
-void pmlist_display(const char *title, pmlist_t *list)
-{
- pmlist_t *lp;
- int cols, len;
-
- len = strlen(title);
- printf("%s ", title);
-
- if(list) {
- for(lp = list, cols = len; lp; lp = alpm_list_next(lp)) {
- int s = strlen(alpm_list_getdata(lp))+1;
- unsigned int maxcols = getcols();
- if(s+cols >= maxcols) {
- int i;
- cols = len;
- printf("\n");
- for (i = 0; i < len+1; i++) {
- printf(" ");
- }
- }
- printf("%s ", (char *)alpm_list_getdata(lp));
- cols += s;
- }
- printf("\n");
- } else {
- printf(_("None\n"));
- }
-}
-
-/* Filter out any duplicate strings in a pmlist_t
- *
- * Not the most efficient way, but simple to implement -- we assemble
- * a new list, using is_in() to check for dupes at each iteration.
- *
- * This function takes a pmlist_t* and returns a list_t*
- *
- */
-list_t *pmlist_remove_dupes(pmlist_t *list)
-{
- pmlist_t *i;
- list_t *newlist = NULL;
-
- for(i = alpm_list_first(list); i; i = alpm_list_next(i)) {
- char *data = alpm_list_getdata(i);
- if(!list_is_strin(data, newlist)) {
- newlist = list_add(newlist, strdup(data));
- }
- }
- return newlist;
-}
-
-/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/src/pacman/list.h
diff -u pacman-lib/src/pacman/list.h:1.9 pacman-lib/src/pacman/list.h:removed
--- pacman-lib/src/pacman/list.h:1.9 Mon Nov 20 04:10:25 2006
+++ pacman-lib/src/pacman/list.h Fri Jan 19 04:28:47 2007
@@ -1,53 +0,0 @@
-/*
- * list.h
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet(a)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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-#ifndef _LIST_H
-#define _LIST_H
-
-#include <alpm.h>
-
-/* Chained list struct */
-typedef struct __list_t {
- void *data;
- struct __list_t *next;
-} list_t;
-
-#define FREELIST(p) do { if(p) { list_free(p); p = NULL; } } while(0)
-#define FREELISTPTR(p) do { \
- list_t *i; \
- for(i = p; i; i = i->next) { \
- i->data = NULL; \
- } \
- FREELIST(p); \
-} while(0)
-
-list_t *list_new(void);
-void list_free(list_t *list);
-list_t *list_add(list_t *list, void *data);
-int list_count(list_t *list);
-int list_is_strin(const char *needle, list_t *haystack);
-void list_display(const char *title, list_t *list);
-
-void pmlist_display(const char *title, pmlist_t *list);
-list_t *pmlist_remove_dupes(pmlist_t *list);
-
-#endif /*_LIST_H*/
-
-/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/src/pacman/log.c
diff -u pacman-lib/src/pacman/log.c:1.22 pacman-lib/src/pacman/log.c:1.23
--- pacman-lib/src/pacman/log.c:1.22 Thu Jan 18 15:13:34 2007
+++ pacman-lib/src/pacman/log.c Fri Jan 19 04:28:46 2007
@@ -30,7 +30,6 @@
#include <alpm.h>
/* pacman */
#include "log.h"
-#include "list.h"
#include "conf.h"
#include "util.h"
Index: pacman-lib/src/pacman/package.c
diff -u pacman-lib/src/pacman/package.c:1.20 pacman-lib/src/pacman/package.c:1.21
--- pacman-lib/src/pacman/package.c:1.20 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/package.c Fri Jan 19 04:28:46 2007
@@ -63,10 +63,10 @@
/* actual output */
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
+ list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
printf(_("URL : %s\n"), (char *)alpm_pkg_get_url(pkg));
- pmlist_display(_("License :"), alpm_pkg_get_licenses(pkg));
+ list_display(_("License :"), alpm_pkg_get_licenses(pkg));
printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
printf(_("Installed Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
printf(_("Build Date : %s %s\n"), bdate, strlen(bdate) ? "UTC" : "");
@@ -75,12 +75,12 @@
printf(_("Install Date : %s %s\n"), idate, strlen(idate) ? "UTC" : "");
printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
printf(_("Reason : %s\n"), reason);
- pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
- pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
+ list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
+ list_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
+ list_display(_("Removes :"), alpm_pkg_get_removes(pkg));
/* TODO only applicable if querying installed package, not a file */
- pmlist_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
- pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+ list_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
+ list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
printf(_("Description : "));
indentprint(alpm_pkg_get_desc(pkg), 17);
@@ -98,7 +98,7 @@
/* Display the content of a sync package
*/
-void dump_pkg_sync(pmpkg_t *pkg, char *treename)
+void dump_pkg_sync(pmpkg_t *pkg, const char *treename)
{
char *md5sum, *sha1sum;
if(pkg == NULL) {
@@ -111,12 +111,12 @@
printf(_("Repository : %s\n"), treename);
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
- pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
- pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
- pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
- pmlist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
+ list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
+ list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
+ list_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
+ list_display(_("Removes :"), alpm_pkg_get_removes(pkg));
+ list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+ list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
printf(_("Download Size : %ld\n"), (long)alpm_pkg_get_size(pkg));
printf(_("Installed Size : %ld\n"), (long)alpm_pkg_get_isize(pkg));
@@ -137,10 +137,10 @@
*/
void dump_pkg_backups(pmpkg_t *pkg)
{
- pmlist_t *i;
+ alpm_list_t *i;
const char *root = alpm_option_get_root();
printf("\nBackup Files :\n");
- for(i = alpm_list_first(alpm_pkg_get_backup(pkg)); i; i = alpm_list_next(i)) {
+ for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
struct stat buf;
char path[PATH_MAX];
char *str = strdup(alpm_list_getdata(i));
@@ -190,7 +190,7 @@
void dump_pkg_files(pmpkg_t *pkg)
{
const char *pkgname;
- pmlist_t *i, *pkgfiles;
+ alpm_list_t *i, *pkgfiles;
pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(pkg);
Index: pacman-lib/src/pacman/package.h
diff -u pacman-lib/src/pacman/package.h:1.5 pacman-lib/src/pacman/package.h:1.6
--- pacman-lib/src/pacman/package.h:1.5 Wed Jan 17 00:25:32 2007
+++ pacman-lib/src/pacman/package.h Fri Jan 19 04:28:46 2007
@@ -22,7 +22,7 @@
#define _PM_PACKAGE_H
void dump_pkg_full(pmpkg_t *pkg, int level);
-void dump_pkg_sync(pmpkg_t *pkg, char *treename);
+void dump_pkg_sync(pmpkg_t *pkg, const char *treename);
void dump_pkg_backups(pmpkg_t *pkg);
void dump_pkg_files(pmpkg_t *pkg);
Index: pacman-lib/src/pacman/pacman.c
diff -u pacman-lib/src/pacman/pacman.c:1.81 pacman-lib/src/pacman/pacman.c:1.82
--- pacman-lib/src/pacman/pacman.c:1.81 Thu Jan 18 15:13:34 2007
+++ pacman-lib/src/pacman/pacman.c Fri Jan 19 04:28:46 2007
@@ -43,8 +43,8 @@
#include <time.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "util.h"
#include "log.h"
#include "downloadprog.h"
@@ -75,10 +75,8 @@
config_t *config;
pmdb_t *db_local;
-/* list of (sync_t *) structs for sync locations */
-list_t *pmc_syncs;
/* list of targets specified on command line */
-static list_t *pm_targets;
+static alpm_list_t *pm_targets;
extern int neednl;
@@ -177,8 +175,6 @@
static void cleanup(int signum)
{
- list_t *lp;
-
if(signum==SIGSEGV)
{
fprintf(stderr, "Internal pacman error: Segmentation fault\n"
@@ -198,11 +194,6 @@
}
/* free memory */
- for(lp = pmc_syncs; lp; lp = lp->next) {
- sync_t *sync = lp->data;
- FREE(sync->treename);
- }
- FREELIST(pmc_syncs);
FREELIST(pm_targets);
FREECONF(config);
@@ -294,7 +285,7 @@
config->configfile = strndup(optarg, PATH_MAX);
#endif
break;
- case 1002: config->op_s_ignore = list_add(config->op_s_ignore, strdup(optarg)); break;
+ case 1002: config->op_s_ignore = alpm_list_add(config->op_s_ignore, strdup(optarg)); break;
case 1003: config->debug = atoi(optarg); break;
case 1004: config->noprogressbar = 1; break;
case 1005: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break;
@@ -392,7 +383,7 @@
while(optind < argc) {
/* add the target to our target array */
- pm_targets = list_add(pm_targets, strdup(argv[optind]));
+ pm_targets = alpm_list_add(pm_targets, strdup(argv[optind]));
optind++;
}
@@ -406,7 +397,6 @@
#ifndef CYGWIN
uid_t myuid;
#endif
- list_t *lp;
#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
/*setenv("MALLOC_TRACE","pacman.mtrace", 0);*/
@@ -500,7 +490,7 @@
config->configfile = strdup(PACCONF);
}
- if(alpm_parse_config(config->configfile, cb_db_register, "") != 0) {
+ if(alpm_parse_config(config->configfile, NULL, "") != 0) {
ERR(NL, _("failed to parse config (%s)\n"), alpm_strerror(pm_errno));
cleanup(1);
}
@@ -511,8 +501,9 @@
config->dbpath = alpm_option_get_dbpath();
config->cachedir = alpm_option_get_cachedir();
- for(lp = config->op_s_ignore; lp; lp = lp->next) {
- alpm_option_add_ignorepkg(lp->data);
+ alpm_list_t *i;
+ for(i = config->op_s_ignore; i; i = alpm_list_next(i)) {
+ alpm_option_add_ignorepkg(alpm_list_getdata(i));
}
if(config->verbose > 0) {
@@ -528,7 +519,7 @@
cleanup(1);
}
- if(list_count(pm_targets) == 0 && !(config->op == PM_OP_QUERY || (config->op == PM_OP_SYNC
+ if(alpm_list_count(pm_targets) == 0 && !(config->op == PM_OP_QUERY || (config->op == PM_OP_SYNC
&& (config->op_s_sync || config->op_s_upgrade || config->op_s_clean || config->group
|| config->op_q_list)))) {
ERR(NL, _("no targets specified (use -h for help)\n"));
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.17 pacman-lib/src/pacman/query.c:1.18
--- pacman-lib/src/pacman/query.c:1.17 Wed Nov 22 04:03:42 2006
+++ pacman-lib/src/pacman/query.c Fri Jan 19 04:28:46 2007
@@ -27,8 +27,8 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "package.h"
#include "query.h"
#include "log.h"
@@ -38,15 +38,13 @@
extern config_t *config;
extern pmdb_t *db_local;
-extern list_t *pmc_syncs;
static int query_fileowner(pmdb_t *db, char *filename)
{
struct stat buf;
int gotcha = 0;
char rpath[PATH_MAX];
- pmlist_t *lp;
- const char *root;
+ alpm_list_t *i, *j;
if(db == NULL) {
return(0);
@@ -61,22 +59,16 @@
return(1);
}
- root = alpm_option_get_root();
+ for(i = alpm_db_getpkgcache(db); i && !gotcha; i = alpm_list_next(i)) {
+ pmpkg_t *info = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) {
- pmpkg_t *info;
- pmlist_t *i;
-
- info = alpm_list_getdata(lp);
-
- for(i = alpm_pkg_get_files(info); i && !gotcha; i = alpm_list_next(i)) {
+ for(j = alpm_pkg_get_files(info); j && !gotcha; j = alpm_list_next(j)) {
char path[PATH_MAX];
+ char *filename = alpm_list_getdata(j);
+ snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), filename);
- char *filename = (char *)alpm_list_getdata(i);
- snprintf(path, PATH_MAX, "%s%s", root, filename);
- if(!strcmp(path, rpath)) {
- printf(_("%s is owned by %s %s\n"), path, (char *)alpm_pkg_get_name(info),
- (char *)alpm_pkg_get_version(info));
+ if(strcmp(path, rpath) == 0) {
+ printf(_("%s is owned by %s %s\n"), path, alpm_pkg_get_name(info), alpm_pkg_get_version(info));
gotcha = 1;
break;
}
@@ -90,25 +82,23 @@
return(0);
}
-int pacman_query(list_t *targets)
+int pacman_query(alpm_list_t *targets)
{
+ alpm_list_t *sync_dbs = NULL, *i, *j;;
pmpkg_t *info = NULL;
- list_t *targ;
- list_t *i;
- pmlist_t *j, *ret;
char *package = NULL;
int done = 0;
if(config->op_q_search) {
- for(i = targets; i; i = i->next) {
- alpm_option_add_needle(i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ alpm_option_add_needle(alpm_list_getdata(i));
}
- ret = alpm_db_search(db_local);
+ alpm_list_t *ret = alpm_db_search(db_local);
if(ret == NULL) {
return(1);
}
- for(j = ret; j; j = alpm_list_next(j)) {
- pmpkg_t *pkg = alpm_list_getdata(j);
+ for(i = ret; i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_list_getdata(i);
printf("local/%s/%s %s\n ",
(char *)alpm_list_getdata(alpm_pkg_get_groups(pkg)),
@@ -122,44 +112,45 @@
}
if(config->op_q_foreign) {
- if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
+ sync_dbs = alpm_option_get_syncdbs();
+
+ if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
ERR(NL, _("no usable package repositories configured.\n"));
return(1);
}
}
- for(targ = targets; !done; targ = (targ ? targ->next : NULL)) {
+ for(i = targets; !done; i = (i ? alpm_list_next(i) : NULL)) {
if(targets == NULL) {
done = 1;
} else {
- if(targ->next == NULL) {
+ if(alpm_list_next(i) == NULL) {
done = 1;
}
- package = targ->data;
+ package = alpm_list_getdata(i);
}
/* looking for groups */
if(config->group) {
- pmlist_t *lp;
if(targets == NULL) {
- for(lp = alpm_db_getgrpcache(db_local); lp; lp = alpm_list_next(lp)) {
- pmgrp_t *grp = alpm_list_getdata(lp);
- pmlist_t *i, *pkgnames;
+ for(j = alpm_db_getgrpcache(db_local); j; j = alpm_list_next(j)) {
+ pmgrp_t *grp = alpm_list_getdata(j);
+ alpm_list_t *p, *pkgnames;
const char *grpname;
grpname = alpm_grp_get_name(grp);
pkgnames = alpm_grp_get_packages(grp);
- for(i = pkgnames; i; i = alpm_list_next(i)) {
- MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(i));
+ for(p = pkgnames; p; p = alpm_list_next(p)) {
+ MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(p));
}
}
} else {
pmgrp_t *grp = alpm_db_readgrp(db_local, package);
if(grp) {
- pmlist_t *i, *pkgnames = alpm_grp_get_packages(grp);
- for(i = pkgnames; i; i = alpm_list_next(i)) {
- MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(i));
+ alpm_list_t *p, *pkgnames = alpm_grp_get_packages(grp);
+ for(p = pkgnames; p; p = alpm_list_next(p)) {
+ MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(p));
}
} else {
ERR(NL, _("group \"%s\" was not found\n"), package);
@@ -202,10 +193,9 @@
/* find packages in the db */
if(package == NULL) {
- pmlist_t *lp;
/* no target */
- for(lp = alpm_db_getpkgcache(db_local); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *tmpp = alpm_list_getdata(lp);
+ for(i = alpm_db_getpkgcache(db_local); i; i = alpm_list_next(i)) {
+ pmpkg_t *tmpp = alpm_list_getdata(i);
const char *pkgname, *pkgver;
pkgname = alpm_pkg_get_name(tmpp);
@@ -222,19 +212,13 @@
}
if(config->op_q_foreign) {
int match = 0;
- for(i = pmc_syncs; i; i = i->next) {
- sync_t *sync = (sync_t *)i->data;
- for(j = alpm_db_getpkgcache(sync->db); j; j = alpm_list_next(j)) {
+ for(i = sync_dbs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j);
- char *haystack;
- char *needle;
- haystack = strdup(alpm_pkg_get_name(pkg));
- needle = strdup(alpm_pkg_get_name(info));
- if(!strcmp(haystack, needle)) {
+ if(strcmp(alpm_pkg_get_name(pkg), alpm_pkg_get_name(info)) == 0) {
match = 1;
}
- FREE(haystack);
- FREE(needle);
}
}
if(match==0) {
@@ -255,8 +239,6 @@
}
}
} else {
- const char *pkgname = NULL, *pkgver = NULL;
- char changelog[PATH_MAX];
info = alpm_db_readpkg(db_local, package);
if(info == NULL) {
@@ -269,10 +251,9 @@
/* find a target */
if(config->op_q_changelog || config->op_q_info || config->op_q_list) {
if(config->op_q_changelog) {
- const char *dbpath;
- dbpath = alpm_option_get_dbpath();
+ char changelog[PATH_MAX];
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
- config->root, dbpath,
+ config->root, alpm_option_get_dbpath(),
alpm_db_get_name(db_local),
alpm_pkg_get_name(info),
alpm_pkg_get_version(info));
@@ -286,12 +267,10 @@
}
} else if(config->op_q_orphans) {
if(alpm_pkg_get_requiredby(info) == NULL) {
- MSG(NL, "%s %s\n", pkgname, pkgver);
+ MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
}
} else {
- pkgname = alpm_pkg_get_name(info);
- pkgver = alpm_pkg_get_version(info);
- MSG(NL, "%s %s\n", pkgname, pkgver);
+ MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
}
}
}
Index: pacman-lib/src/pacman/query.h
diff -u pacman-lib/src/pacman/query.h:1.2 pacman-lib/src/pacman/query.h:1.3
--- pacman-lib/src/pacman/query.h:1.2 Mon Jan 2 14:55:36 2006
+++ pacman-lib/src/pacman/query.h Fri Jan 19 04:28:46 2007
@@ -21,7 +21,9 @@
#ifndef _PM_QUERY_H
#define _PM_QUERY_H
-int pacman_query(list_t *targets);
+#include <alpm.h>
+
+int pacman_query(alpm_list_t *targets);
#endif /* _PM_QUERY_H */
Index: pacman-lib/src/pacman/remove.c
diff -u pacman-lib/src/pacman/remove.c:1.23 pacman-lib/src/pacman/remove.c:1.24
--- pacman-lib/src/pacman/remove.c:1.23 Fri Dec 1 04:51:54 2006
+++ pacman-lib/src/pacman/remove.c Fri Jan 19 04:28:46 2007
@@ -25,10 +25,10 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "trans.h"
#include "remove.h"
#include "conf.h"
@@ -37,11 +37,9 @@
extern pmdb_t *db_local;
-int pacman_remove(list_t *targets)
+int pacman_remove(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
- list_t *finaltargs = NULL;
+ alpm_list_t *data, *i, *j, *finaltargs = NULL;
int retval = 0;
if(targets == NULL) {
@@ -51,27 +49,25 @@
/* If the target is a group, ask if its packages should be removed
* (the library can't remove groups for now)
*/
- for(i = targets; i; i = i->next) {
- pmgrp_t *grp;
-
- grp = alpm_db_readgrp(db_local, i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i));
if(grp) {
- pmlist_t *lp, *pkgnames;
int all;
-
- pkgnames = alpm_grp_get_packages(grp);
+ alpm_list_t *pkgnames = alpm_grp_get_packages(grp);
MSG(NL, _(":: group %s:\n"), alpm_grp_get_name(grp));
- pmlist_display(" ", pkgnames);
+ list_display(" ", pkgnames);
all = yesno(_(" Remove whole content? [Y/n] "));
- for(lp = alpm_list_first(pkgnames); lp; lp = alpm_list_next(lp)) {
- if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), (char *)alpm_list_getdata(lp), i->data)) {
- finaltargs = list_add(finaltargs, strdup(alpm_list_getdata(lp)));
+
+ for(j = pkgnames; j; j = alpm_list_next(j)) {
+ char *pkg = alpm_list_getdata(j);
+ if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, (char *)alpm_list_getdata(i))) {
+ finaltargs = alpm_list_add(finaltargs, strdup(pkg));
}
}
} else {
/* not a group, so add it to the final targets */
- finaltargs = list_add(finaltargs, strdup(i->data));
+ finaltargs = alpm_list_add(finaltargs, strdup(alpm_list_getdata(i)));
}
}
@@ -87,9 +83,10 @@
return(1);
}
/* and add targets to it */
- for(i = finaltargs; i; i = i->next) {
- if(alpm_trans_addtarget(i->data) == -1) {
- ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno));
+ for(i = finaltargs; i; i = alpm_list_next(i)) {
+ char *targ = alpm_list_getdata(i);
+ if(alpm_trans_addtarget(targ) == -1) {
+ ERR(NL, _("failed to add target '%s' (%s)\n"), targ, alpm_strerror(pm_errno));
retval = 1;
goto cleanup;
}
@@ -98,16 +95,15 @@
/* Step 2: prepare the transaction based on its type, targets and flags
*/
if(alpm_trans_prepare(&data) == -1) {
- pmlist_t *lp;
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s is required by %s\n"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
}
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
default:
break;
@@ -119,15 +115,14 @@
/* Warn user in case of dangerous operation
*/
if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) {
- pmlist_t *lp;
/* list transaction targets */
- i = NULL;
- for(lp = alpm_list_first(alpm_trans_get_packages()); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
- i = list_add(i, strdup(alpm_pkg_get_name(pkg)));
+ alpm_list_t *lst = NULL;
+ for(i = alpm_trans_get_packages(); i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_list_getdata(i);
+ lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
}
- list_display(_("\nTargets:"), i);
- FREELIST(i);
+ list_display(_("\nTargets:"), lst);
+ FREELIST(lst);
/* get confirmation */
if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) {
retval = 1;
Index: pacman-lib/src/pacman/remove.h
diff -u pacman-lib/src/pacman/remove.h:1.2 pacman-lib/src/pacman/remove.h:1.3
--- pacman-lib/src/pacman/remove.h:1.2 Mon Jan 2 14:55:36 2006
+++ pacman-lib/src/pacman/remove.h Fri Jan 19 04:28:46 2007
@@ -21,7 +21,9 @@
#ifndef _PM_REMOVE_H
#define _PM_REMOVE_H
-int pacman_remove(list_t *targets);
+#include <alpm.h>
+
+int pacman_remove(alpm_list_t *targets);
#endif /* _PM_REMOVE_H */
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.94 pacman-lib/src/pacman/sync.c:1.95
--- pacman-lib/src/pacman/sync.c:1.94 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/sync.c Fri Jan 19 04:28:46 2007
@@ -37,12 +37,12 @@
#endif
#include <alpm.h>
+#include <alpm_list.h>
#include <download.h> /* downloadLastErrString */
/* pacman */
#include "util.h"
#include "log.h"
#include "downloadprog.h"
-#include "list.h"
#include "package.h"
#include "trans.h"
#include "sync.h"
@@ -50,9 +50,6 @@
extern config_t *config;
-extern list_t *pmc_syncs;
-
-
/* splits package name into its respective parts */
static int split_pkgname(char *target, char *name, char *version)
{
@@ -111,9 +108,7 @@
/* incomplete cleanup: we keep latest packages and partial downloads */
DIR *dir;
struct dirent *ent;
- list_t *cache = NULL;
- list_t *clean = NULL;
- list_t *i, *j;
+ alpm_list_t *cache = NULL, *clean = NULL, *i, *j;
if(!yesno(_("Do you want to remove old packages from cache? [Y/n] ")))
return(0);
@@ -128,16 +123,16 @@
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
continue;
}
- cache = list_add(cache, strdup(ent->d_name));
+ cache = alpm_list_add(cache, strdup(ent->d_name));
}
closedir(dir);
- for(i = cache; i; i = i->next) {
- char *str = i->data;
+ for(i = cache; i; i = alpm_list_next(i)) {
+ char *str = alpm_list_getdata(i);
char name[256], version[64];
if(strstr(str, PM_EXT_PKG) == NULL) {
- clean = list_add(clean, strdup(str));
+ clean = alpm_list_add(clean, strdup(str));
continue;
}
/* we keep partially downloaded files */
@@ -145,11 +140,11 @@
continue;
}
if(split_pkgname(str, name, version) != 0) {
- clean = list_add(clean, strdup(str));
+ clean = alpm_list_add(clean, strdup(str));
continue;
}
- for(j = i->next; j; j = j->next) {
- char *s = j->data;
+ for(j = alpm_list_next(i); j; j = alpm_list_next(j)) {
+ char *s = alpm_list_getdata(j);
char n[256], v[64];
if(strstr(s, PM_EXT_PKG) == NULL) {
@@ -164,18 +159,18 @@
/* TODO Do not remove the currently installed version EITHER */
if(!strcmp(name, n)) {
char *ptr = (alpm_pkg_vercmp(version, v) < 0) ? str : s;
- if(!list_is_strin(ptr, clean)) {
- clean = list_add(clean, strdup(ptr));
+ if(!alpm_list_is_strin(ptr, clean)) {
+ clean = alpm_list_add(clean, strdup(ptr));
}
}
}
}
FREELIST(cache);
- for(i = clean; i; i = i->next) {
+ for(i = clean; i; i = alpm_list_next(i)) {
char path[PATH_MAX];
- snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)i->data);
+ snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)alpm_list_getdata(i));
unlink(path);
}
FREELIST(clean);
@@ -200,15 +195,15 @@
return(0);
}
-static int sync_synctree(int level, list_t *syncs)
+static int sync_synctree(int level, alpm_list_t *syncs)
{
- list_t *i;
+ alpm_list_t *i;
int success = 0, ret;
- for(i = syncs; i; i = i->next) {
- sync_t *sync = (sync_t *)i->data;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- ret = alpm_db_update((level < 2 ? 0 : 1), sync->db);
+ ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) {
if(pm_errno == PM_ERR_DB_SYNC) {
/* use libdownload error */
@@ -218,12 +213,12 @@
* Yes. This will be here until we add a nice pacman "pm_errstr" or
* something, OR add all libdownload error codes into the pm_error enum
*/
- ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, downloadLastErrString);
+ ERR(NL, _("failed to synchronize %s: %s\n"), alpm_db_get_name(db), downloadLastErrString);
} else {
- ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno));
+ ERR(NL, _("failed to update %s (%s)\n"), alpm_db_get_name(db), alpm_strerror(pm_errno));
}
} else if(ret == 1) {
- MSG(NL, _(" %s is up to date\n"), sync->treename);
+ MSG(NL, _(" %s is up to date\n"), alpm_db_get_name(db));
success++;
} else {
success++;
@@ -237,29 +232,27 @@
return(success > 0);
}
-static int sync_search(list_t *syncs, list_t *targets)
+static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i;
- pmlist_t *ret;
+ alpm_list_t *i, *j, *ret;
- for(i = targets; i; i = i->next) {
- alpm_option_add_needle(i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ alpm_option_add_needle(alpm_list_getdata(i));
}
- for(i = syncs; i; i = i->next) {
- sync_t *sync = i->data;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
if(targets) {
- pmlist_t *lp;
- ret = alpm_db_search(sync->db);
+ ret = alpm_db_search(db);
if(ret == NULL) {
continue;
}
- for(lp = ret; lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
+ for(j = ret; j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
char *group = (char *)alpm_list_getdata(alpm_pkg_get_groups(pkg));
printf("%s/%s %s %s%s%s\n ",
- alpm_db_get_name(sync->db),
+ alpm_db_get_name(db),
alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg),
(group ? " (" : ""), (group ? group : ""), (group ? ") " : ""));
@@ -268,12 +261,10 @@
}
alpm_list_free_outer(ret);
} else {
- pmlist_t *lp;
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
-
- MSG(NL, "%s/%s %s\n ", sync->treename, alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ MSG(NL, "%s/%s %s\n ", alpm_db_get_name(db), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
indentprint(alpm_pkg_get_desc(pkg), 4);
MSG(NL, "\n");
}
@@ -283,33 +274,32 @@
return(0);
}
-static int sync_group(int level, list_t *syncs, list_t *targets)
+static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i, *j;
+ alpm_list_t *i, *j;
if(targets) {
- for(i = targets; i; i = i->next) {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmgrp_t *grp = alpm_db_readgrp(sync->db, i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ for(j = syncs; j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ pmgrp_t *grp = alpm_db_readgrp(db, alpm_list_getdata(i));
if(grp) {
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
- pmlist_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_packages(grp));
}
}
}
} else {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getgrpcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmgrp_t *grp = alpm_list_getdata(lp);
+ for(j = alpm_db_getgrpcache(db); j; j = alpm_list_next(j)) {
+ pmgrp_t *grp = alpm_list_getdata(j);
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
if(grp && level > 1) {
- pmlist_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_packages(grp));
}
}
}
@@ -318,23 +308,22 @@
return(0);
}
-static int sync_info(list_t *syncs, list_t *targets)
+static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i, *j;
+ alpm_list_t *i, *j, *k;
if(targets) {
- for(i = targets; i; i = i->next) {
+ for(i = targets; i; i = alpm_list_next(i)) {
int found = 0;
- for(j = syncs; j && !found; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(j = syncs; j && !found; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
- for(lp = alpm_db_getpkgcache(sync->db); !found && lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
+ for(k = alpm_db_getpkgcache(db); !found && k; k = alpm_list_next(k)) {
+ pmpkg_t *pkg = alpm_list_getdata(k);
- if(!strcmp(alpm_pkg_get_name(pkg), i->data)) {
- dump_pkg_sync(pkg, sync->treename);
+ if(!strcmp(alpm_pkg_get_name(pkg), alpm_list_getdata(i))) {
+ dump_pkg_sync(pkg, alpm_db_get_name(db));
MSG(NL, "\n");
found = 1;
}
@@ -346,12 +335,11 @@
}
}
} else {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- dump_pkg_sync(alpm_list_getdata(lp), sync->treename);
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db));
MSG(NL, "\n");
}
}
@@ -360,44 +348,42 @@
return(0);
}
-static int sync_list(list_t *syncs, list_t *targets)
+static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i;
- list_t *ls = NULL;
+ alpm_list_t *i, *j, *ls = NULL;
if(targets) {
- for(i = targets; i; i = i->next) {
- list_t *j;
- sync_t *sync = NULL;
+ for(i = targets; i; i = alpm_list_next(i)) {
+ const char *repo = alpm_list_getdata(i);
+ pmdb_t *db = NULL;
- for(j = syncs; j && !sync; j = j->next) {
- sync_t *s = j->data;
+ for(j = syncs; j; j = alpm_list_next(j)) {
+ pmdb_t *d = alpm_list_getdata(j);
- if(strcmp(i->data, s->treename) == 0) {
- sync = s;
+ if(strcmp(repo, alpm_db_get_name(d)) == 0) {
+ db = d;
+ break;
}
}
- if(sync == NULL) {
- ERR(NL, _("repository \"%s\" was not found.\n"), (char *)i->data);
+ if(db == NULL) {
+ ERR(NL, _("repository \"%s\" was not found.\n"),repo);
FREELISTPTR(ls);
return(1);
}
- ls = list_add(ls, sync);
+ ls = alpm_list_add(ls, db);
}
} else {
ls = syncs;
}
- for(i = ls; i; i = i->next) {
- pmlist_t *lp;
- sync_t *sync = i->data;
+ for(i = ls; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
-
- MSG(NL, "%s %s %s\n", (char *)sync->treename, alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
+ MSG(NL, "%s %s %s\n", alpm_db_get_name(db), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
}
}
@@ -408,14 +394,14 @@
return(0);
}
-int pacman_sync(list_t *targets)
+int pacman_sync(alpm_list_t *targets)
{
int confirm = 0;
int retval = 0;
- list_t *i = NULL;
- pmlist_t *packages = NULL, *data = NULL, *lp = NULL;
+ alpm_list_t *packages, *data, *i, *j, *k, *sync_dbs;
- if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
+ sync_dbs = alpm_option_get_syncdbs();
+ if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
ERR(NL, _("no usable package repositories configured.\n"));
return(1);
}
@@ -425,19 +411,19 @@
}
if(config->op_s_search) {
- return(sync_search(pmc_syncs, targets));
+ return(sync_search(sync_dbs, targets));
}
if(config->group) {
- return(sync_group(config->group, pmc_syncs, targets));
+ return(sync_group(config->group, sync_dbs, targets));
}
if(config->op_s_info) {
- return(sync_info(pmc_syncs, targets));
+ return(sync_info(sync_dbs, targets));
}
if(config->op_q_list) {
- return(sync_list(pmc_syncs, targets));
+ return(sync_list(sync_dbs, targets));
}
/* Step 1: create a new transaction...
@@ -455,13 +441,12 @@
/* grab a fresh package list */
MSG(NL, _(":: Synchronizing package databases...\n"));
alpm_logaction(_("synchronizing package lists"));
- if(!sync_synctree(config->op_s_sync, pmc_syncs)) {
+ if(!sync_synctree(config->op_s_sync, sync_dbs)) {
ERR(NL, _("failed to synchronize any databases"));
return(1);
}
}
-
if(config->op_s_upgrade) {
MSG(NL, _(":: Starting full system upgrade...\n"));
alpm_logaction(_("starting full system upgrade"));
@@ -478,10 +463,10 @@
* when sysupgrade'ing with an older version of pacman.
*/
data = alpm_trans_get_packages();
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmsyncpkg_t *sync = alpm_list_getdata(lp);
+ for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ pmsyncpkg_t *sync = alpm_list_getdata(i);
pmpkg_t *spkg = alpm_sync_get_package(sync);
- if(!strcmp("pacman", alpm_pkg_get_name(spkg)) && alpm_list_count(data) > 1) {
+ if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0 && alpm_list_count(data) > 1) {
MSG(NL, _("\n:: pacman has detected a newer version of the \"pacman\" package.\n"));
MSG(NL, _(":: It is recommended that you allow pacman to upgrade itself\n"));
MSG(NL, _(":: first, then you can re-run the operation with the newer version.\n"));
@@ -501,7 +486,7 @@
return(1);
}
if(alpm_trans_addtarget("pacman") == -1) {
- ERR(NL, _("'%s': %s\n"), (char *)i->data, alpm_strerror(pm_errno));
+ ERR(NL, _("pacman: %s\n"), alpm_strerror(pm_errno));
retval = 1;
goto cleanup;
}
@@ -511,11 +496,10 @@
}
} else {
/* process targets */
- for(i = targets; i; i = i->next) {
- char *targ = i->data;
+ for(i = targets; i; i = alpm_list_next(i)) {
+ char *targ = alpm_list_getdata(i);
if(alpm_trans_addtarget(targ) == -1) {
pmgrp_t *grp = NULL;
- list_t *j;
int found=0;
if(pm_errno == PM_ERR_TRANS_DUP_TARGET) {
/* just ignore duplicate targets */
@@ -527,28 +511,26 @@
goto cleanup;
}
/* target not found: check if it's a group */
- for(j = pmc_syncs; j; j = j->next) {
- sync_t *sync = j->data;
- grp = alpm_db_readgrp(sync->db, targ);
+
+ for(j = alpm_option_get_syncdbs(); j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ grp = alpm_db_readgrp(db, targ);
if(grp) {
- pmlist_t *pmpkgs;
- list_t *k, *pkgs;
found++;
MSG(NL, _(":: group %s:\n"), targ);
- pmpkgs = alpm_grp_get_packages(grp);
/* remove dupe entries in case a package exists in multiple repos */
/* (the dupe function takes a pmlist_t* and returns a list_t*) */
- pkgs = pmlist_remove_dupes(pmpkgs);
+ alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_packages(grp));
list_display(" ", pkgs);
if(yesno(_(":: Install whole content? [Y/n] "))) {
- for(k = pkgs; k; k = k->next) {
- targets = list_add(targets, strdup(k->data));
+ for(k = pkgs; k; k = alpm_list_next(k)) {
+ targets = alpm_list_add(targets, strdup(alpm_list_getdata(k)));
}
} else {
- for(k = pkgs; k; k = k->next) {
- char *pkgname = k->data;
+ for(k = pkgs; k; k = alpm_list_next(k)) {
+ char *pkgname = alpm_list_getdata(k);
if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) {
- targets = list_add(targets, strdup(pkgname));
+ targets = alpm_list_add(targets, strdup(pkgname));
}
}
}
@@ -557,18 +539,19 @@
}
if(!found) {
/* targ not found in sync db, searching for providers... */
- pmlist_t *k = NULL;
- pmpkg_t *pkg;
const char *pname = NULL;
- for(j = pmc_syncs; j && !k; j = j->next) {
- sync_t *sync = j->data;
- k = alpm_db_whatprovides(sync->db, targ);
- pkg = (pmpkg_t*)alpm_list_getdata(alpm_list_first(k));
- pname = alpm_pkg_get_name(pkg);
+ for(j = alpm_option_get_syncdbs(); j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ alpm_list_t *prov = alpm_db_whatprovides(db, targ);
+ if(prov) {
+ pmpkg_t *pkg = alpm_list_getdata(prov);
+ pname = alpm_pkg_get_name(pkg);
+ break;
+ }
}
if(pname != NULL) {
/* targ is provided by pname */
- targets = list_add(targets, strdup(pname));
+ targets = alpm_list_add(targets, strdup(pname));
} else {
ERR(NL, _("'%s': not found in sync db\n"), targ);
retval = 1;
@@ -586,8 +569,8 @@
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"),
alpm_dep_get_name(miss));
@@ -600,18 +583,16 @@
}
break;
case PM_ERR_CONFLICTING_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: conflicts with %s"),
alpm_dep_get_target(miss), alpm_dep_get_name(miss));
}
break;
case PM_ERR_DISK_FULL:
- lp = alpm_list_first(data);
- pkgsize = alpm_list_getdata(lp);
- lp = alpm_list_next(lp);
- freespace = alpm_list_getdata(lp);
+ pkgsize = alpm_list_getdata(data);
+ freespace = alpm_list_getdata(alpm_list_next(data));
MSG(NL, _(":: %.1f MB required, have %.1f MB"),
(double)(*pkgsize / 1048576.0), (double)(*freespace / 1048576.0));
break;
@@ -631,26 +612,25 @@
/* list targets and get confirmation */
if(!(alpm_trans_get_flags() & PM_TRANS_FLAG_PRINTURIS)) {
- list_t *list_install = NULL;
- list_t *list_remove = NULL;
+ alpm_list_t *list_install = NULL, *list_remove = NULL;
+
char *str;
unsigned long totalsize = 0;
unsigned long totalisize = 0;
double mb, umb;
- for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) {
- pmsyncpkg_t *sync = alpm_list_getdata(lp);
+ for(i = packages; i; i = alpm_list_next(i)) {
+ pmsyncpkg_t *sync = alpm_list_getdata(i);
pmpkg_t *pkg = alpm_sync_get_package(sync);
const char *pkgname, *pkgver;
if(alpm_sync_get_type(sync) == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j, *data;
- data = alpm_sync_get_data(sync);
- for(j = alpm_list_first(data); j; j = alpm_list_next(j)) {
+ alpm_list_t *data = alpm_sync_get_data(sync);
+ for(j = data; j; j = alpm_list_next(j)) {
pmpkg_t *p = alpm_list_getdata(j);
const char *pkgname = alpm_pkg_get_name(p);
- if(!list_is_strin(pkgname, list_remove)) {
- list_remove = list_add(list_remove, strdup(pkgname));
+ if(!alpm_list_is_strin(pkgname, list_remove)) {
+ list_remove = alpm_list_add(list_remove, strdup(pkgname));
}
}
}
@@ -661,7 +641,7 @@
totalisize += alpm_pkg_get_isize(pkg);
asprintf(&str, "%s-%s", pkgname, pkgver);
- list_install = list_add(list_install, str);
+ list_install = alpm_list_add(list_install, str);
}
if(list_remove) {
MSG(NL, _("\nRemove: "));
@@ -723,12 +703,12 @@
ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_FILE_CONFLICTS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmconflict_t *conflict = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmconflict_t *conflict = alpm_list_getdata(i);
switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET:
MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"),
- config->root,
+ alpm_option_get_root(),
alpm_conflict_get_file(conflict),
alpm_conflict_get_target(conflict),
alpm_conflict_get_ctarget(conflict));
@@ -736,7 +716,7 @@
case PM_CONFLICT_TYPE_FILE:
MSG(NL, _("%s: %s%s exists in filesystem"),
alpm_conflict_get_target(conflict),
- config->root,
+ alpm_option_get_root(),
alpm_conflict_get_file(conflict));
break;
}
@@ -744,8 +724,8 @@
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
case PM_ERR_PKG_CORRUPTED:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- MSG(NL, "%s", (char*)alpm_list_getdata(lp));
+ for(i = data; i; i = alpm_list_next(i)) {
+ MSG(NL, "%s", (char*)alpm_list_getdata(i));
}
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
@@ -760,7 +740,7 @@
*/
cleanup:
if(data) {
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
data = NULL;
}
if(alpm_trans_release() == -1) {
Index: pacman-lib/src/pacman/sync.h
diff -u pacman-lib/src/pacman/sync.h:1.4 pacman-lib/src/pacman/sync.h:1.5
--- pacman-lib/src/pacman/sync.h:1.4 Mon Nov 20 04:10:25 2006
+++ pacman-lib/src/pacman/sync.h Fri Jan 19 04:28:46 2007
@@ -21,13 +21,9 @@
#ifndef _PM_SYNC_H
#define _PM_SYNC_H
-/* Repositories */
-typedef struct __sync_t {
- char *treename;
- pmdb_t *db;
-} sync_t;
+#include <alpm.h>
-int pacman_sync(list_t *targets);
+int pacman_sync(alpm_list_t *targets);
#endif /* _PM_SYNC_H */
Index: pacman-lib/src/pacman/trans.c
diff -u pacman-lib/src/pacman/trans.c:1.26 pacman-lib/src/pacman/trans.c:1.27
--- pacman-lib/src/pacman/trans.c:1.26 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/trans.c Fri Jan 19 04:28:46 2007
@@ -34,7 +34,6 @@
#include "util.h"
#include "log.h"
#include "trans.h"
-#include "list.h"
#include "conf.h"
#define LOG_STR_LEN 256
Index: pacman-lib/src/pacman/upgrade.c
diff -u pacman-lib/src/pacman/upgrade.c:1.5 pacman-lib/src/pacman/upgrade.c:1.6
--- pacman-lib/src/pacman/upgrade.c:1.5 Mon Jan 2 14:55:36 2006
+++ pacman-lib/src/pacman/upgrade.c Fri Jan 19 04:28:46 2007
@@ -24,15 +24,15 @@
#include <string.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "add.h"
#include "upgrade.h"
#include "conf.h"
extern config_t *config;
-int pacman_upgrade(list_t *targets)
+int pacman_upgrade(alpm_list_t *targets)
{
/* this is basically just a remove-then-add process. pacman_add() will */
/* handle it */
Index: pacman-lib/src/pacman/upgrade.h
diff -u pacman-lib/src/pacman/upgrade.h:1.2 pacman-lib/src/pacman/upgrade.h:1.3
--- pacman-lib/src/pacman/upgrade.h:1.2 Mon Jan 2 14:55:36 2006
+++ pacman-lib/src/pacman/upgrade.h Fri Jan 19 04:28:47 2007
@@ -21,7 +21,9 @@
#ifndef _PM_UPGRADE_H
#define _PM_UPGRADE_H
-int pacman_upgrade(list_t *targets);
+#include <alpm.h>
+
+int pacman_upgrade(alpm_list_t *targets);
#endif /* _PM_UPGRADE_H */
Index: pacman-lib/src/pacman/util.c
diff -u pacman-lib/src/pacman/util.c:1.21 pacman-lib/src/pacman/util.c:1.22
--- pacman-lib/src/pacman/util.c:1.21 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/util.c Fri Jan 19 04:28:47 2007
@@ -41,9 +41,10 @@
#include <limits.h> /* PATH_MAX */
#endif
+#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
-#include "list.h"
#include "conf.h"
#include "log.h"
@@ -196,22 +197,22 @@
/* Condense a list of strings into one long (space-delimited) string
*/
-char *buildstring(list_t *strlist)
+char *buildstring(alpm_list_t *strlist)
{
char *str;
size_t size = 1;
- list_t *lp;
+ alpm_list_t *i;
- for(lp = strlist; lp; lp = lp->next) {
- size += strlen(lp->data) + 1;
+ for(i = strlist; i; i = alpm_list_next(i)) {
+ size += strlen(alpm_list_getdata(i)) + 1;
}
str = (char *)malloc(size);
if(str == NULL) {
ERR(NL, _("failed to allocate %d bytes\n"), size);
}
str[0] = '\0';
- for(lp = strlist; lp; lp = lp->next) {
- strcat(str, lp->data);
+ for(i = strlist; i; i = alpm_list_next(i)) {
+ strcat(str, alpm_list_getdata(i));
strcat(str, " ");
}
/* shave off the last space */
@@ -254,4 +255,34 @@
return str;
}
+void list_display(const char *title, alpm_list_t *list)
+{
+ alpm_list_t *i;
+ int cols, len;
+
+ len = strlen(title);
+ printf("%s ", title);
+
+ if(list) {
+ for(i = list, cols = len; i; i = alpm_list_next(i)) {
+ char *str = alpm_list_getdata(i);
+ int s = strlen(str)+1;
+ unsigned int maxcols = getcols();
+ if(s + cols >= maxcols) {
+ int i;
+ cols = len;
+ printf("\n");
+ for (i = 0; i < len+1; ++i) {
+ printf(" ");
+ }
+ }
+ printf("%s ", str);
+ cols += s;
+ }
+ printf("\n");
+ } else {
+ printf(_("None\n"));
+ }
+}
+
/* vim: set ts=2 sw=2 noet: */
Index: pacman-lib/src/pacman/util.h
diff -u pacman-lib/src/pacman/util.h:1.12 pacman-lib/src/pacman/util.h:1.13
--- pacman-lib/src/pacman/util.h:1.12 Thu Jan 18 11:53:04 2007
+++ pacman-lib/src/pacman/util.h Fri Jan 19 04:28:47 2007
@@ -21,7 +21,12 @@
#ifndef _PM_UTIL_H
#define _PM_UTIL_H
-#include "list.h"
+#include <stdlib.h>
+#include <string.h>
+#include <libintl.h>
+
+#include <alpm.h>
+#include <alpm_list.h>
#define MALLOC(p, b) do { \
if((b) > 0) { \
@@ -47,10 +52,11 @@
int makepath(char *path);
int rmrf(char *path);
void indentprint(const char *str, unsigned int indent);
-char *buildstring(list_t *strlist);
+char *buildstring(alpm_list_t *strlist);
char *strtoupper(char *str);
char *strtrim(char *str);
int reg_match(char *string, char *pattern);
+void list_display(const char *title, alpm_list_t *list);
#endif /* _PM_UTIL_H */
3
2
19 Jan '07
Date: Friday, January 19, 2007 @ 18:44:50
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: package.c (1.47 -> 1.48)
Moved some decls to make the "pkg_invalid" patch compile again.
-----------+
package.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.47 pacman-lib/lib/libalpm/package.c:1.48
--- pacman-lib/lib/libalpm/package.c:1.47 Fri Jan 19 13:06:37 2007
+++ pacman-lib/lib/libalpm/package.c Fri Jan 19 18:44:50 2007
@@ -235,6 +235,8 @@
register struct archive *archive;
struct archive_entry *entry;
pmpkg_t *info = NULL;
+ char *descfile = NULL;
+ int fd = -1;
if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(PM_ERR_WRONG_ARGS, NULL);
@@ -261,9 +263,6 @@
break;
}
if(!strcmp(archive_entry_pathname (entry), ".PKGINFO")) {
- char *descfile;
- int fd;
-
/* extract this file into /tmp. it has info for us */
descfile = strdup("/tmp/alpm_XXXXXX");
fd = mkstemp(descfile);
@@ -351,9 +350,13 @@
pkg_invalid:
pm_errno = PM_ERR_PKG_INVALID;
- unlink(descfile);
- FREE(descfile);
- close(fd);
+ if(descfile) {
+ unlink(descfile);
+ FREE(descfile);
+ }
+ if(fd != -1) {
+ close(fd);
+ }
error:
FREEPKG(info);
archive_read_finish (archive);
1
0
19 Jan '07
Date: Friday, January 19, 2007 @ 13:06:37
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: package.c (1.46 -> 1.47)
Whoops. There's a 0 where there should be a 1.
-----------+
package.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.46 pacman-lib/lib/libalpm/package.c:1.47
--- pacman-lib/lib/libalpm/package.c:1.46 Fri Jan 19 13:05:19 2007
+++ pacman-lib/lib/libalpm/package.c Fri Jan 19 13:06:37 2007
@@ -65,7 +65,7 @@
{
pmpkg_t* newpkg;
- if((newpkg = calloc(0, sizeof(pmpkg_t))) == NULL) {
+ if((newpkg = calloc(1, sizeof(pmpkg_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmpkg_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}
1
0