FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-03-2011, 10:41 PM
Dan McGee
 
Default Update utilities for new initialize/release methods

Signed-off-by: Dan McGee <dan@archlinux.org>
---
src/util/cleanupdelta.c | 14 ++++++++------
src/util/pactree.c | 23 +++++++----------------
src/util/testdb.c | 17 ++++++++---------
src/util/testpkg.c | 11 +++++++----
4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index ae36d2a..9247c2c 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -29,9 +29,11 @@

#define BASENAME "cleanupdelta"

+pmhandle_t *handle = NULL;
+
static void cleanup(int signum) {
- if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s
", alpm_strerrorlast());
+ if(handle && alpm_release(handle) == -1) {
+ fprintf(stderr, "error releasing alpm
");
}

exit(signum);
@@ -94,6 +96,7 @@ static void usage(void) {
int main(int argc, char *argv[])
{
const char *dbpath = DBPATH;
+ enum _pmerrno_t err;
int a = 1;
alpm_list_t *dbnames = NULL;

@@ -117,16 +120,15 @@ int main(int argc, char *argv[])
usage();
}

- if(alpm_initialize() == -1) {
- fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerrorlast());
+ handle = alpm_initialize(ROOTDIR, dbpath, &err);
+ if(!handle) {
+ fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerror(err));
return 1;
}

/* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb);

- alpm_option_set_dbpath(dbpath);
-
checkdbs(dbpath,dbnames);
alpm_list_free(dbnames);

diff --git a/src/util/pactree.c b/src/util/pactree.c
index e9a2816..23e0562 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -74,6 +74,7 @@ static struct color_choices no_color = {
};

/* globals */
+pmhandle_t *handle = NULL;
pmdb_t *db_local;
alpm_list_t *walked = NULL;
alpm_list_t *provisions = NULL;
@@ -87,23 +88,13 @@ int reverse = 0;
int unique = 0;
const char *dbpath = DBPATH;

-static int alpm_local_init(void)
+static int alpm_local_init()
{
- int ret;
-
- ret = alpm_initialize();
- if(ret != 0) {
- return ret;
- }
+ enum _pmerrno_t err;

- ret = alpm_option_set_root(ROOTDIR);
- if(ret != 0) {
- return ret;
- }
-
- ret = alpm_option_set_dbpath(dbpath);
- if(ret != 0) {
- return ret;
+ handle = alpm_initialize(ROOTDIR, dbpath, &err);
+ if(!handle) {
+ return -1;
}

db_local = alpm_option_get_localdb();
@@ -196,7 +187,7 @@ static void cleanup(void)
{
alpm_list_free(walked);
alpm_list_free(provisions);
- alpm_release();
+ alpm_release(handle);
}

/* pkg provides provision */
diff --git a/src/util/testdb.c b/src/util/testdb.c
index d8a2fb4..06c01f8 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -31,9 +31,11 @@

#define BASENAME "testdb"

+pmhandle_t *handle = NULL;
+
static void cleanup(int signum) {
- if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s
", alpm_strerrorlast());
+ if(handle && alpm_release(handle) == -1) {
+ fprintf(stderr, "error releasing alpm
");
}

exit(signum);
@@ -184,6 +186,7 @@ static void usage(void) {
int main(int argc, char *argv[])
{
int ret = 0;
+ enum _pmerrno_t err;
const char *dbpath = DBPATH;
int a = 1;
alpm_list_t *dbnames = NULL;
@@ -204,19 +207,15 @@ int main(int argc, char *argv[])
a++;
}

- if(alpm_initialize() == -1) {
- fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerrorlast());
+ handle = alpm_initialize(ROOTDIR, dbpath, &err);
+ if(!handle) {
+ fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerror(err));
return EXIT_FAILURE;
}

/* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb);

- if(alpm_option_set_dbpath(dbpath) != 0) {
- fprintf(stderr, "cannot set dbpath: %s
", alpm_strerrorlast());
- return EXIT_FAILURE;
- }
-
if(!dbnames) {
ret = check_localdb();
} else {
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index ad6ec30..20920ff 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -40,6 +40,8 @@ static void output_cb(pmloglevel_t level, const char *fmt, va_list args)
int main(int argc, char *argv[])
{
int retval = 1; /* default = false */
+ pmhandle_t *handle;
+ enum _pmerrno_t err;
pmpkg_t *pkg = NULL;

if(argc != 2) {
@@ -47,8 +49,9 @@ int main(int argc, char *argv[])
return 1;
}

- if(alpm_initialize() == -1) {
- fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerrorlast());
+ handle = alpm_initialize(ROOTDIR, DBPATH, &err);
+ if(!handle) {
+ fprintf(stderr, "cannot initialize alpm: %s
", alpm_strerror(err));
return 1;
}

@@ -76,8 +79,8 @@ int main(int argc, char *argv[])
retval = 0;
}

- if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s
", alpm_strerrorlast());
+ if(alpm_release(handle) == -1) {
+ fprintf(stderr, "error releasing alpm
");
}

return retval;
--
1.7.5.2
 
Old 06-03-2011, 11:05 PM
Allan McRae
 
Default Update utilities for new initialize/release methods

On 04/06/11 08:41, Dan McGee wrote:

Signed-off-by: Dan McGee<dan@archlinux.org>
---
src/util/cleanupdelta.c | 14 ++++++++------
src/util/pactree.c | 23 +++++++----------------
src/util/testdb.c | 17 ++++++++---------
src/util/testpkg.c | 11 +++++++----
4 files changed, 30 insertions(+), 35 deletions(-)


<snip>


diff --git a/src/util/pactree.c b/src/util/pactree.c
index e9a2816..23e0562 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -74,6 +74,7 @@ static struct color_choices no_color = {
};

/* globals */
+pmhandle_t *handle = NULL;
pmdb_t *db_local;
alpm_list_t *walked = NULL;
alpm_list_t *provisions = NULL;
@@ -87,23 +88,13 @@ int reverse = 0;
int unique = 0;
const char *dbpath = DBPATH;

-static int alpm_local_init(void)
+static int alpm_local_init()



pactree.c:91:12: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
 

Thread Tools




All times are GMT. The time now is 12:01 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org