#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <syslog.h>
#include <limits.h>
#include <stdarg.h>
#include "log.h"
#include "error.h"
#include "rpmvercmp.h"
#include "md5.h"
#include "list.h"
#include "package.h"
#include "group.h"
#include "util.h"
#include "db.h"
#include "cache.h"
#include "deps.h"
#include "backup.h"
#include "add.h"
#include "remove.h"
#include "sync.h"
#include "handle.h"
#include "alpm.h"
pmhandle_t *handle = NULL;
enum __pmerrno_t pm_errno;
int alpm_initialize(char *root)
{
char str[PATH_MAX];
ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
handle = handle_new();
if(handle->access == PM_ACCESS_RW) {
if(_alpm_lckmk(PM_LOCK) == -1) {
FREE(handle);
RET_ERR(PM_ERR_HANDLE_LOCK, -1);
}
}
STRNCPY(str, (root) ? root : PM_ROOT, PATH_MAX);
if(str[strlen(str)-1] != '/') {
strcat(str, "/");
}
handle->root = strdup(str);
return(0);
}
int alpm_release()
{
PMList *i;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
if(handle->access == PM_ACCESS_RW) {
if(_alpm_lckrm(PM_LOCK)) {
_alpm_log(PM_LOG_WARNING, "could not remove lock file %s", PM_LOCK);
alpm_logaction("warning: could not remove lock file %s", PM_LOCK);
}
}
if(handle->db_local) {
db_close(handle->db_local);
handle->db_local = NULL;
|