summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c294
1 files changed, 231 insertions, 63 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 66c36b8a..a4c5a557 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -2,6 +2,10 @@
* add.c
*
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+ * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
+ * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
+ * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
+ * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.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
@@ -19,6 +23,27 @@
* USA.
*/
+#if defined(__APPLE__) || defined(__OpenBSD__)
+#include <sys/syslimits.h>
+#endif
+#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__sun__)
+#include <sys/stat.h>
+#endif
+
+#if defined(__APPLE__) || defined(__OpenBSD__)
+#include <sys/syslimits.h>
+#endif
+#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__sun__)
+#include <sys/stat.h>
+#endif
+
+#if defined(__APPLE__) || defined(__OpenBSD__)
+#include <sys/syslimits.h>
+#endif
+#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__sun__)
+#include <sys/stat.h>
+#endif
+
#include "config.h"
#include <stdlib.h>
#include <errno.h>
@@ -28,19 +53,20 @@
#include <limits.h>
#include <libintl.h>
/* pacman */
+#include "list.h"
+#include "trans.h"
#include "util.h"
#include "error.h"
-#include "list.h"
#include "cache.h"
#include "versioncmp.h"
#include "md5.h"
+#include "sha1.h"
#include "log.h"
#include "backup.h"
#include "package.h"
#include "db.h"
#include "provide.h"
#include "conflict.h"
-#include "trans.h"
#include "deps.h"
#include "add.h"
#include "remove.h"
@@ -199,6 +225,9 @@ error:
int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
{
PMList *lp;
+ PMList *rmlist = NULL;
+ char rm_fname[PATH_MAX];
+ pmpkg_t *info = NULL;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -209,8 +238,8 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
/* look for unsatisfied dependencies */
- _alpm_log(PM_LOG_FLOW1,_( "looking for unsatisfied dependencies"));
- lp = _alpm_checkdeps(db, trans->type, trans->packages);
+ _alpm_log(PM_LOG_FLOW1, _("looking for unsatisfied dependencies"));
+ lp = _alpm_checkdeps(trans, db, trans->type, trans->packages);
if(lp != NULL) {
if(data) {
*data = lp;
@@ -242,6 +271,45 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
+ /* Cleaning up
+ */
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_START, NULL, NULL);
+ _alpm_log(PM_LOG_FLOW1, _("cleaning up"));
+ for (lp=trans->packages; lp!=NULL; lp=lp->next) {
+ info=(pmpkg_t *)lp->data;
+ for (rmlist=info->removes; rmlist!=NULL; rmlist=rmlist->next) {
+ snprintf(rm_fname, PATH_MAX, "%s%s", handle->root, (char *)rmlist->data);
+ remove(rm_fname);
+ }
+ }
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_DONE, NULL, NULL);
+
+ /* Cleaning up
+ */
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_START, NULL, NULL);
+ _alpm_log(PM_LOG_FLOW1, _("cleaning up"));
+ for (lp=trans->packages; lp!=NULL; lp=lp->next) {
+ info=(pmpkg_t *)lp->data;
+ for (rmlist=info->removes; rmlist!=NULL; rmlist=rmlist->next) {
+ snprintf(rm_fname, PATH_MAX, "%s%s", handle->root, (char *)rmlist->data);
+ remove(rm_fname);
+ }
+ }
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_DONE, NULL, NULL);
+
+ /* Cleaning up
+ */
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_START, NULL, NULL);
+ _alpm_log(PM_LOG_FLOW1, _("cleaning up"));
+ for (lp=trans->packages; lp!=NULL; lp=lp->next) {
+ info=(pmpkg_t *)lp->data;
+ for (rmlist=info->removes; rmlist!=NULL; rmlist=rmlist->next) {
+ snprintf(rm_fname, PATH_MAX, "%s%s", handle->root, (char *)rmlist->data);
+ remove(rm_fname);
+ }
+ }
+ EVENT(trans, PM_TRANS_EVT_CLEANUP_DONE, NULL, NULL);
+
/* Check for file conflicts
*/
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
@@ -267,15 +335,24 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
}
+#ifndef __sun__
+ if(_alpm_check_freespace(trans, data) == -1) {
+ /* pm_errno is set by check_freespace */
+ return(-1);
+ }
+#endif
+
return(0);
}
int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
{
- int i, ret = 0, errors = 0;
+ int i, ret = 0, errors = 0, needdisp = 0;
+ double percent;
register struct archive *archive;
struct archive_entry *entry;
- char expath[PATH_MAX];
+ char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
+ unsigned char cb_state;
time_t t;
PMList *targ, *lp;
@@ -304,7 +381,12 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
pmpkg_t *local = _alpm_db_get_pkgfromcache(db, info->name);
if(local) {
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
+ cb_state = PM_TRANS_PROGRESS_UPGRADE_START;
_alpm_log(PM_LOG_FLOW1, _("upgrading package %s-%s"), info->name, info->version);
+ if((what = (char *)malloc(strlen(info->name)+1)) == NULL) {
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ STRNCPY(what, info->name, strlen(info->name)+1);
/* we'll need to save some record for backup checks later */
oldpkg = _alpm_pkg_new(local->name, local->version);
@@ -314,6 +396,8 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
_alpm_db_read(db, INFRQ_FILES, local);
}
oldpkg->backup = _alpm_list_strdup(local->backup);
+ strncpy(oldpkg->name, local->name, PKG_NAME_LEN);
+ strncpy(oldpkg->version, local->version, PKG_VERSION_LEN);
}
/* copy over the install reason */
@@ -325,7 +409,8 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
/* pre_upgrade scriptlet */
if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
- _alpm_runscriptlet(handle->root, info->data, "pre_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
+ _alpm_runscriptlet(handle->root, info->data, "pre_upgrade", info->version, oldpkg ? oldpkg->version : NULL,
+ trans);
}
if(oldpkg) {
@@ -335,7 +420,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(tr == NULL) {
RET_ERR(PM_ERR_TRANS_ABORT, -1);
}
- if(_alpm_trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags, NULL, NULL) == -1) {
+ if(_alpm_trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags, NULL, NULL, NULL) == -1) {
FREETRANS(tr);
RET_ERR(PM_ERR_TRANS_ABORT, -1);
}
@@ -359,11 +444,16 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
}
if(!pmo_upgrade) {
EVENT(trans, PM_TRANS_EVT_ADD_START, info, NULL);
+ cb_state = PM_TRANS_PROGRESS_ADD_START;
_alpm_log(PM_LOG_FLOW1, _("adding package %s-%s"), info->name, info->version);
+ if((what = (char *)malloc(strlen(info->name)+1)) == NULL) {
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ STRNCPY(what, info->name, strlen(info->name)+1);
/* pre_install scriptlet */
if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
- _alpm_runscriptlet(handle->root, info->data, "pre_install", info->version, NULL);
+ _alpm_runscriptlet(handle->root, info->data, "pre_install", info->version, NULL, trans);
}
} else {
_alpm_log(PM_LOG_FLOW1, _("adding new package %s-%s"), info->name, info->version);
@@ -372,35 +462,62 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
_alpm_log(PM_LOG_FLOW1, _("extracting files"));
- /* Extract the .tar.gz package */
- if((archive = archive_read_new()) == NULL) {
+ /* Extract the package */
+ if ((archive = archive_read_new ()) == NULL)
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, -1);
- }
- archive_read_support_compression_all(archive);
- archive_read_support_format_all(archive);
- if(archive_read_open_file(archive, info->data, 10240) != ARCHIVE_OK) {
+ archive_read_support_compression_all (archive);
+ archive_read_support_format_all (archive);
+
+ if (archive_read_open_file (archive, info->data, ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
RET_ERR(PM_ERR_PKG_OPEN, -1);
}
+ /* 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 */
+ cwd[0] = 0;
+ }
+
+ /* libarchive requires this for extracting hard links */
chdir(handle->root);
- for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
+
+ for(i = 0; archive_read_next_header (archive, &entry) == ARCHIVE_OK; i++) {
int nb = 0;
int notouch = 0;
char *md5_orig = NULL;
+ char *sha1_orig = NULL;
char pathname[PATH_MAX];
struct stat buf;
- STRNCPY(pathname, archive_entry_pathname(entry), PATH_MAX);
+ STRNCPY(pathname, archive_entry_pathname (entry), PATH_MAX);
+
+ 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));
+ }
if(!strcmp(pathname, ".PKGINFO") || !strcmp(pathname, ".FILELIST")) {
- archive_read_data_skip(archive);
+ archive_read_data_skip (archive);
continue;
}
- if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL")) {
- /* the install script goes inside the db */
- snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version);
+ /*if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL")) {
+ * the install script goes inside the db
+ * snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version); */
+ if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL") ||
+ !strcmp(pathname, ".CHANGELOG")) {
+ if(!strcmp(pathname, ".CHANGELOG")) {
+ /* the changelog goes inside the db */
+ snprintf(expath, PATH_MAX, "%s/%s-%s/changelog", db->path,
+ info->name, info->version);
+ } else {
+ /* the install script goes inside the db */
+ snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path,
+ info->name, info->version);
+ }
} else {
/* build the new pathname relative to handle->root */
snprintf(expath, PATH_MAX, "%s%s", handle->root, pathname);
@@ -413,7 +530,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
*/
if(_alpm_list_is_strin(pathname, handle->noextract)) {
alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname);
- archive_read_data_skip(archive);
+ archive_read_data_skip (archive);
continue;
}
@@ -427,7 +544,8 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
} else {
/* op == PM_TRANS_TYPE_UPGRADE */
md5_orig = _alpm_needbackup(pathname, oldpkg->backup);
- if(md5_orig) {
+ sha1_orig = _alpm_needbackup(pathname, oldpkg->backup);
+ if(md5_orig || sha1_orig) {
nb = 1;
}
}
@@ -437,98 +555,128 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(nb) {
char *temp;
char *md5_local, *md5_pkg;
+ char *sha1_local, *sha1_pkg;
int fd;
/* extract the package's version to a temporary file and md5 it */
temp = strdup("/tmp/alpm_XXXXXX");
fd = mkstemp(temp);
- archive_entry_set_pathname(entry, temp);
- if(archive_read_extract(archive, entry, ARCHIVE_EXTRACT_FLAGS) != ARCHIVE_OK) {
+
+ archive_entry_set_pathname (entry, temp);
+
+ if(archive_read_extract (archive, entry, ARCHIVE_EXTRACT_FLAGS) != ARCHIVE_OK) {
alpm_logaction(_("could not extract %s (%s)"), pathname, strerror(errno));
errors++;
unlink(temp);
FREE(temp);
FREE(md5_orig);
+ FREE(sha1_orig);
close(fd);
continue;
}
- md5_local = MDFile(expath);
- md5_pkg = MDFile(temp);
- /* append the new md5 hash to it's respective entry in info->backup
+ md5_local = _alpm_MDFile(expath);
+ md5_pkg = _alpm_MDFile(temp);
+ sha1_local = _alpm_SHAFile(expath);
+ sha1_pkg = _alpm_SHAFile(temp);
+ /* append the new md5 or sha1 hash to it's respective entry in info->backup
* (it will be the new orginal)
*/
for(lp = info->backup; lp; lp = lp->next) {
+ char *fn;
char *file = lp->data;
- if(!file) {
- continue;
- }
+
+ if(!file) continue;
if(!strcmp(file, pathname)) {
- char *fn;
+ if(info->sha1sum != NULL && info->sha1sum != '\0') {
/* 32 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
- fn = (char *)malloc(strlen(file)+34);
- if(fn == NULL) {
+ if((fn = (char *)malloc(strlen(file)+34)) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
sprintf(fn, "%s\t%s", file, md5_pkg);
FREE(file);
lp->data = fn;
+ } else {
+ /* 41 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
+ if((fn = (char *)malloc(strlen(file)+43)) == NULL) {
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ sprintf(fn, "%s\t%s", file, sha1_pkg);
+ FREE(file);
+ lp->data = fn;
+ }
}
}
+ if (info->sha1sum != NULL && info->sha1sum != '\0') {
_alpm_log(PM_LOG_DEBUG, _("checking md5 hashes for %s"), pathname);
_alpm_log(PM_LOG_DEBUG, _("current: %s"), md5_local);
_alpm_log(PM_LOG_DEBUG, _("new: %s"), md5_pkg);
if(md5_orig) {
_alpm_log(PM_LOG_DEBUG, _("original: %s"), md5_orig);
}
+ } else {
+ _alpm_log(PM_LOG_DEBUG, _("checking sha1 hashes for %s"), pathname);
+ _alpm_log(PM_LOG_DEBUG, _("current: %s"), sha1_local);
+ _alpm_log(PM_LOG_DEBUG, _("new: %s"), sha1_pkg);
+ if(sha1_orig) {
+ _alpm_log(PM_LOG_DEBUG, _("original: %s"), sha1_orig);
+ }
+ }
if(!pmo_upgrade) {
/* PM_ADD */
- /* if a file already exists with a different md5 hash,
+ /* if a file already exists with a different md5 or sha1 hash,
* then we rename it to a .pacorig extension and continue */
- if(strcmp(md5_local, md5_pkg)) {
+ if(strcmp(md5_local, md5_pkg) || strcmp(sha1_local, sha1_pkg)) {
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s.pacorig", expath);
if(rename(expath, newpath)) {
- archive_entry_set_pathname(entry, expath);
+ archive_entry_set_pathname (entry, expath);
_alpm_log(PM_LOG_ERROR, _("could not rename %s (%s)"), pathname, strerror(errno));
alpm_logaction(_("error: could not rename %s (%s)"), expath, strerror(errno));
}
- archive_entry_set_pathname(entry, expath);
if(_alpm_copyfile(temp, expath)) {
+ archive_entry_set_pathname (entry, expath);
_alpm_log(PM_LOG_ERROR, _("could not copy %s to %s (%s)"), temp, pathname, strerror(errno));
alpm_logaction(_("error: could not copy %s to %s (%s)"), temp, expath, strerror(errno));
errors++;
} else {
+ archive_entry_set_pathname (entry, expath);
_alpm_log(PM_LOG_WARNING, _("%s saved as %s.pacorig"), pathname, pathname);
alpm_logaction(_("warning: %s saved as %s"), expath, newpath);
}
}
- } else if(md5_orig) {
+ } else if(md5_orig || sha1_orig) {
/* PM_UPGRADE */
int installnew = 0;
/* the fun part */
- if(!strcmp(md5_orig, md5_local)) {
- if(!strcmp(md5_local, md5_pkg)) {
+ if(!strcmp(md5_orig, md5_local)|| !strcmp(sha1_orig, sha1_local)) {
+ if(!strcmp(md5_local, md5_pkg) || !strcmp(sha1_local, sha1_pkg)) {
_alpm_log(PM_LOG_DEBUG, _("action: installing new file"));
installnew = 1;
} else {
_alpm_log(PM_LOG_DEBUG, _("action: installing new file"));
installnew = 1;
}
- } else if(!strcmp(md5_orig, md5_pkg)) {
+ } else if(!strcmp(md5_orig, md5_pkg) || !strcmp(sha1_orig, sha1_pkg)) {
_alpm_log(PM_LOG_DEBUG, _("action: leaving existing file in place"));
- } else if(!strcmp(md5_local, md5_pkg)) {
+ } else if(!strcmp(md5_local, md5_pkg) || !strcmp(sha1_local, sha1_pkg)) {
_alpm_log(PM_LOG_DEBUG, _("action: installing new file"));
installnew = 1;
} else {
- _alpm_log(PM_LOG_DEBUG, _("action: leaving file in place, installing new one as .pacnew"));
- strncat(expath, ".pacnew", PATH_MAX);
- installnew = 1;
- _alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew"), pathname, pathname);
- alpm_logaction(_("warning: extracting %s%s as %s"), handle->root, pathname, expath);
+ char newpath[PATH_MAX];
+ _alpm_log(PM_LOG_DEBUG, _("action: keeping current file and installing new one with .pacnew ending"));
+ installnew = 0;
+ snprintf(newpath, PATH_MAX, "%s.pacnew", expath);
+ if(_alpm_copyfile(temp, newpath)) {
+ _alpm_log(PM_LOG_ERROR, _("could not install %s as %s: %s"), expath, newpath, strerror(errno));
+ alpm_logaction(_("error: could not install %s as %s: %s"), expath, newpath, strerror(errno));
+ } else {
+ _alpm_log(PM_LOG_WARNING, _("%s installed as %s"), expath, newpath);
+ alpm_logaction(_("warning: %s installed as %s"), expath, newpath);
+ }
}
if(installnew) {
@@ -537,13 +685,16 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
_alpm_log(PM_LOG_ERROR, _("could not copy %s to %s (%s)"), temp, pathname, strerror(errno));
errors++;
}
- archive_entry_set_pathname(entry, expath);
+ archive_entry_set_pathname (entry, expath);
}
}
FREE(md5_local);
FREE(md5_pkg);
FREE(md5_orig);
+ FREE(sha1_local);
+ FREE(sha1_pkg);
+ FREE(sha1_orig);
unlink(temp);
FREE(temp);
close(fd);
@@ -565,15 +716,15 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
*/
unlink(expath);
}
- archive_entry_set_pathname(entry, expath);
- if(archive_read_extract(archive, entry, ARCHIVE_EXTRACT_FLAGS) != ARCHIVE_OK) {
+ 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)"), expath, strerror(errno));
alpm_logaction(_("error: could not extract %s (%s)"), expath, strerror(errno));
errors++;
}
- /* calculate an md5 hash if this is in info->backup */
+ /* calculate an md5 or sha1 hash if this is in info->backup */
for(lp = info->backup; lp; lp = lp->next) {
- char *fn, *md5;
+ char *fn, *md5, *sha1;
char path[PATH_MAX];
char *file = lp->data;
@@ -581,21 +732,33 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(!strcmp(file, pathname)) {
_alpm_log(PM_LOG_DEBUG, _("appending backup entry"));
snprintf(path, PATH_MAX, "%s%s", handle->root, file);
- md5 = MDFile(path);
- /* 32 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
- fn = (char *)malloc(strlen(file)+34);
- if(fn == NULL) {
- RET_ERR(PM_ERR_MEMORY, -1);
+ if (info->sha1sum != NULL && info->sha1sum != '\0') {
+ md5 = _alpm_MDFile(path);
+ /* 32 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
+ if((fn = (char *)malloc(strlen(file)+34)) == NULL) {
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ sprintf(fn, "%s\t%s", file, md5);
+ FREE(md5);
+ } else {
+ /* 41 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
+ sha1 = _alpm_SHAFile(path);
+ if((fn = (char *)malloc(strlen(file)+43)) == NULL) {
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ sprintf(fn, "%s\t%s", file, sha1);
+ FREE(sha1);
}
- sprintf(fn, "%s\t%s", file, md5);
- FREE(md5);
FREE(file);
lp->data = fn;
}
}
}
}
- archive_read_finish(archive);
+ if(strlen(cwd)) {
+ chdir(cwd);
+ }
+ archive_read_finish (archive);
if(errors) {
ret = 1;
@@ -682,13 +845,18 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
}
}
+ 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);
+
/* run the post-install script if it exists */
if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", handle->root, handle->dbpath, db->treename, info->name, info->version);
if(pmo_upgrade) {
- _alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
+ _alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL, trans);
} else {
- _alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL);
+ _alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL, trans);
}
}