diff options
-rw-r--r-- | lib/libalpm/add.c | 119 | ||||
-rw-r--r-- | lib/libalpm/alpm.c | 35 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 9 | ||||
-rw-r--r-- | lib/libalpm/cache.c | 11 | ||||
-rw-r--r-- | lib/libalpm/conflict.c | 27 | ||||
-rw-r--r-- | lib/libalpm/db.c | 5 | ||||
-rw-r--r-- | lib/libalpm/deps.c | 37 | ||||
-rw-r--r-- | lib/libalpm/error.c | 76 | ||||
-rw-r--r-- | lib/libalpm/group.c | 3 | ||||
-rw-r--r-- | lib/libalpm/handle.c | 27 | ||||
-rw-r--r-- | lib/libalpm/md5driver.c | 4 | ||||
-rw-r--r-- | lib/libalpm/package.c | 17 | ||||
-rw-r--r-- | lib/libalpm/remove.c | 57 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 101 | ||||
-rw-r--r-- | lib/libalpm/trans.c | 3 | ||||
-rw-r--r-- | lib/libalpm/util.c | 27 | ||||
-rw-r--r-- | lib/libalpm/util.h | 2 | ||||
-rw-r--r-- | src/pacman/add.c | 28 | ||||
-rw-r--r-- | src/pacman/conf.c | 81 | ||||
-rw-r--r-- | src/pacman/deptest.c | 19 | ||||
-rw-r--r-- | src/pacman/download.c | 59 | ||||
-rw-r--r-- | src/pacman/list.c | 6 | ||||
-rw-r--r-- | src/pacman/log.c | 17 | ||||
-rw-r--r-- | src/pacman/package.c | 71 | ||||
-rw-r--r-- | src/pacman/pacman.c | 157 | ||||
-rw-r--r-- | src/pacman/query.c | 21 | ||||
-rw-r--r-- | src/pacman/remove.c | 29 | ||||
-rw-r--r-- | src/pacman/sync.c | 127 | ||||
-rw-r--r-- | src/pacman/trans.c | 39 | ||||
-rw-r--r-- | src/pacman/util.c | 5 | ||||
-rw-r--r-- | src/pacman/util.h | 2 |
31 files changed, 629 insertions, 592 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 687774db..7b96cf08 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -27,6 +27,7 @@ #include <string.h> #include <limits.h> #include <zlib.h> +#include <libintl.h> #include <libtar.h> /* pacman */ #include "util.h" @@ -81,7 +82,7 @@ static int add_faketarget(pmtrans_t *trans, char *name) } else if(strncmp("depend", p, q-p) == 0) { dummy->depends = _alpm_list_add(dummy->depends, strdup(q+1)); } else { - _alpm_log(PM_LOG_ERROR, "could not parse token %s", p); + _alpm_log(PM_LOG_ERROR, _("could not parse token %s"), p); } } FREE(str); @@ -113,7 +114,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) return(add_faketarget(trans, name)); } - _alpm_log(PM_LOG_FLOW2, "loading target '%s'", name); + _alpm_log(PM_LOG_FLOW2, _("loading target '%s'"), name); if(stat(name, &buf)) { pm_errno = PM_ERR_NOT_A_FILE; @@ -155,7 +156,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) if(strcmp(pkg->name, pkgname) == 0) { if(_alpm_versioncmp(pkg->version, pkgver) < 0) { pmpkg_t *newpkg; - _alpm_log(PM_LOG_WARNING, "replacing older version %s-%s by %s in target list", + _alpm_log(PM_LOG_WARNING, _("replacing older version %s-%s by %s in target list"), pkg->name, pkg->version, pkgver); if((newpkg = _alpm_pkg_load(name)) == NULL) { /* pm_errno is already set by pkg_load() */ @@ -164,14 +165,14 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) FREEPKG(i->data); i->data = newpkg; } else { - _alpm_log(PM_LOG_WARNING, "newer version %s-%s is in the target list -- skipping", + _alpm_log(PM_LOG_WARNING, _("newer version %s-%s is in the target list -- skipping"), pkg->name, pkg->version, pkgver); } return(0); } } - _alpm_log(PM_LOG_FLOW2, "reading '%s' metadata", pkgname); + _alpm_log(PM_LOG_FLOW2, _("reading '%s' metadata"), pkgname); info = _alpm_pkg_load(name); if(info == NULL) { /* pm_errno is already set by pkg_load() */ @@ -210,7 +211,7 @@ 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"); + _alpm_log(PM_LOG_FLOW1,_( "looking for unsatisfied dependencies")); lp = _alpm_checkdeps(db, trans->type, trans->packages); if(lp != NULL) { if(data) { @@ -222,7 +223,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) } /* no unsatisfied deps, so look for conflicts */ - _alpm_log(PM_LOG_FLOW1, "looking for conflicts"); + _alpm_log(PM_LOG_FLOW1, _("looking for conflicts")); lp = _alpm_checkconflicts(db, trans->packages); if(lp != NULL) { if(data) { @@ -234,7 +235,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) } /* re-order w.r.t. dependencies */ - _alpm_log(PM_LOG_FLOW1, "sorting by dependencies"); + _alpm_log(PM_LOG_FLOW1, _("sorting by dependencies")); lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD); /* free the old alltargs */ FREELISTPTR(trans->packages); @@ -250,7 +251,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); - _alpm_log(PM_LOG_FLOW1, "looking for file conflicts"); + _alpm_log(PM_LOG_FLOW1, _("looking for file conflicts")); lp = _alpm_db_find_conflicts(db, trans->packages, handle->root, &skiplist); if(lp != NULL) { if(data) { @@ -306,13 +307,13 @@ 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); - _alpm_log(PM_LOG_FLOW1, "upgrading package %s-%s", info->name, info->version); + _alpm_log(PM_LOG_FLOW1, _("upgrading package %s-%s"), info->name, info->version); /* we'll need to save some record for backup checks later */ oldpkg = _alpm_pkg_new(local->name, local->version); if(oldpkg) { if(!(local->infolevel & INFRQ_FILES)) { - _alpm_log(PM_LOG_DEBUG, "loading FILES info for '%s'", local->name); + _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); @@ -320,7 +321,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) /* copy over the install reason */ if(!(local->infolevel & INFRQ_DESC)) { - _alpm_log(PM_LOG_DEBUG, "loading DESC info for '%s'", local->name); + _alpm_log(PM_LOG_DEBUG, _("loading DESC info for '%s'"), local->name); _alpm_db_read(db, INFRQ_DESC, local); } info->reason = local->reason; @@ -332,7 +333,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) if(oldpkg) { pmtrans_t *tr; - _alpm_log(PM_LOG_FLOW1, "removing old package first (%s-%s)", oldpkg->name, oldpkg->version); + _alpm_log(PM_LOG_FLOW1, _("removing old package first (%s-%s)"), oldpkg->name, oldpkg->version); tr = _alpm_trans_new(); if(tr == NULL) { RET_ERR(PM_ERR_TRANS_ABORT, -1); @@ -361,18 +362,18 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) } if(!pmo_upgrade) { EVENT(trans, PM_TRANS_EVT_ADD_START, info, NULL); - _alpm_log(PM_LOG_FLOW1, "adding package %s-%s", info->name, info->version); + _alpm_log(PM_LOG_FLOW1, _("adding package %s-%s"), info->name, info->version); /* pre_install scriptlet */ if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { _alpm_runscriptlet(handle->root, info->data, "pre_install", info->version, NULL); } } else { - _alpm_log(PM_LOG_FLOW1, "adding new package %s-%s", info->name, info->version); + _alpm_log(PM_LOG_FLOW1, _("adding new package %s-%s"), info->name, info->version); } if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { - _alpm_log(PM_LOG_FLOW1, "extracting files"); + _alpm_log(PM_LOG_FLOW1, _("extracting files")); /* Extract the .tar.gz package */ if(tar_open(&tar, info->data, &gztype, O_RDONLY, 0, TAR_GNU) == -1) { @@ -407,7 +408,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) * could be used. */ if(_alpm_list_is_strin(pathname, handle->noextract)) { - alpm_logaction("notice: %s is in NoExtract -- skipping extraction", pathname); + alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname); tar_skip_regfile(tar); continue; } @@ -438,7 +439,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) temp = strdup("/tmp/alpm_XXXXXX"); fd = mkstemp(temp); if(tar_extract_file(tar, temp)) { - alpm_logaction("could not extract %s (%s)", pathname, strerror(errno)); + alpm_logaction(_("could not extract %s (%s)"), pathname, strerror(errno)); errors++; unlink(temp); FREE(temp); @@ -469,11 +470,11 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) } } - _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); + _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); + _alpm_log(PM_LOG_DEBUG, _("original: %s"), md5_orig); } if(!pmo_upgrade) { @@ -485,16 +486,16 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) char newpath[PATH_MAX]; snprintf(newpath, PATH_MAX, "%s.pacorig", expath); if(rename(expath, newpath)) { - _alpm_log(PM_LOG_ERROR, "could not rename %s (%s)", pathname, strerror(errno)); - alpm_logaction("error: could not rename %s (%s)", expath, strerror(errno)); + _alpm_log(PM_LOG_ERROR, _("could not rename %s (%s)"), pathname, strerror(errno)); + alpm_logaction(_("error: could not rename %s (%s)"), expath, strerror(errno)); } if(_alpm_copyfile(temp, 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)); + _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 { - _alpm_log(PM_LOG_WARNING, "%s saved as %s.pacorig", pathname, pathname); - alpm_logaction("warning: %s saved as %s", expath, newpath); + _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) { @@ -504,29 +505,29 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) /* the fun part */ if(!strcmp(md5_orig, md5_local)) { if(!strcmp(md5_local, md5_pkg)) { - _alpm_log(PM_LOG_DEBUG, "action: installing new file"); + _alpm_log(PM_LOG_DEBUG, _("action: installing new file")); installnew = 1; } else { - _alpm_log(PM_LOG_DEBUG, "action: installing new file"); + _alpm_log(PM_LOG_DEBUG, _("action: installing new file")); installnew = 1; } } else if(!strcmp(md5_orig, md5_pkg)) { - _alpm_log(PM_LOG_DEBUG, "action: leaving existing file in place"); + _alpm_log(PM_LOG_DEBUG, _("action: leaving existing file in place")); } else if(!strcmp(md5_local, md5_pkg)) { - _alpm_log(PM_LOG_DEBUG, "action: installing new file"); + _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"); + _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); + _alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew"), pathname, pathname); + alpm_logaction(_("warning: extracting %s%s as %s"), handle->root, pathname, expath); } if(installnew) { - _alpm_log(PM_LOG_FLOW2, "extracting %s", pathname); + _alpm_log(PM_LOG_FLOW2, _("extracting %s"), pathname); if(_alpm_copyfile(temp, expath)) { - _alpm_log(PM_LOG_ERROR, "could not copy %s to %s (%s)", temp, pathname, strerror(errno)); + _alpm_log(PM_LOG_ERROR, _("could not copy %s to %s (%s)"), temp, pathname, strerror(errno)); errors++; } } @@ -540,12 +541,12 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) close(fd); } else { if(!notouch) { - _alpm_log(PM_LOG_FLOW2, "extracting %s", pathname); + _alpm_log(PM_LOG_FLOW2, _("extracting %s"), pathname); } else { - _alpm_log(PM_LOG_FLOW2, "%s is in NoUpgrade -- skipping", pathname); + _alpm_log(PM_LOG_FLOW2, _("%s is in NoUpgrade -- skipping"), pathname); strncat(expath, ".pacnew", PATH_MAX); - _alpm_log(PM_LOG_WARNING, "extracting %s as %s.pacnew", pathname, pathname); - alpm_logaction("warning: extracting %s%s as %s", handle->root, pathname, expath); + _alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew"), pathname, pathname); + alpm_logaction(_("warning: extracting %s%s as %s"), handle->root, pathname, expath); /*tar_skip_regfile(tar);*/ } if(trans->flags & PM_TRANS_FLAG_FORCE) { @@ -557,8 +558,8 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) unlink(expath); } if(tar_extract_file(tar, expath)) { - _alpm_log(PM_LOG_ERROR, "could not extract %s (%s)", pathname, strerror(errno)); - alpm_logaction("error: could not extract %s (%s)", pathname, strerror(errno)); + _alpm_log(PM_LOG_ERROR, _("could not extract %s (%s)"), pathname, strerror(errno)); + alpm_logaction(_("error: could not extract %s (%s)"), pathname, strerror(errno)); errors++; } /* calculate an md5 hash if this is in info->backup */ @@ -569,7 +570,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) if(!file) continue; if(!strcmp(file, pathname)) { - _alpm_log(PM_LOG_DEBUG, "appending backup entry"); + _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 */ @@ -589,10 +590,10 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) if(errors) { ret = 1; - _alpm_log(PM_LOG_ERROR, "errors occurred while %s %s", - (pmo_upgrade ? "upgrading" : "installing"), info->name); - alpm_logaction("errors occurred while %s %s", - (pmo_upgrade ? "upgrading" : "installing"), info->name); + _alpm_log(PM_LOG_ERROR, _("errors occurred while %s %s"), + (pmo_upgrade ? _("upgrading") : _("installing")), info->name); + alpm_logaction(_("errors occurred while %s %s"), + (pmo_upgrade ? _("upgrading") : _("installing")), info->name); } } @@ -613,7 +614,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) continue; } if(tmppm->data && !strcmp(depend.name, info->name)) { - _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'", tmpp->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)); } } @@ -624,21 +625,21 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) /* remove the extra line feed appended by asctime() */ info->installdate[strlen(info->installdate)-1] = 0; - _alpm_log(PM_LOG_FLOW1, "updating database"); - _alpm_log(PM_LOG_FLOW2, "adding database entry '%s'", info->name); + _alpm_log(PM_LOG_FLOW1, _("updating database")); + _alpm_log(PM_LOG_FLOW2, _("adding database entry '%s'"), info->name); if(_alpm_db_write(db, info, INFRQ_ALL)) { - _alpm_log(PM_LOG_ERROR, "could not update database entry %s-%s", + _alpm_log(PM_LOG_ERROR, _("could not update database entry %s-%s"), info->name, info->version); - alpm_logaction(NULL, "error updating database for %s-%s!", info->name, info->version); + alpm_logaction(NULL, _("error updating database for %s-%s!"), info->name, info->version); RET_ERR(PM_ERR_DB_WRITE, -1); } if(_alpm_db_add_pkgincache(db, info) == -1) { - _alpm_log(PM_LOG_ERROR, "could not add entry '%s' in cache", info->name); + _alpm_log(PM_LOG_ERROR, _("could not add entry '%s' in cache"), info->name); } /* update dependency packages' REQUIREDBY fields */ if(info->depends) { - _alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields"); + _alpm_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields")); } for(lp = info->depends; lp; lp = lp->next) { pmpkg_t *depinfo; @@ -659,15 +660,15 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) FREELISTPTR(provides); } if(depinfo == NULL) { - _alpm_log(PM_LOG_ERROR, "could not find dependency '%s'", depend.name); + _alpm_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name); /* wtf */ continue; } } - _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'", info->name, depinfo->name); + _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)); if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) { - _alpm_log(PM_LOG_ERROR, "could not update 'requiredby' database entry %s-%s", + _alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), depinfo->name, depinfo->version); } } @@ -688,7 +689,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) } /* run ldconfig if it exists */ - _alpm_log(PM_LOG_FLOW1, "running \"ldconfig -r %s\"", handle->root); + _alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root); _alpm_ldconfig(handle->root); return(0); diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 70b1bb78..cffbfc46 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -31,6 +31,7 @@ #include <syslog.h> #include <limits.h> /* PATH_MAX */ #include <stdarg.h> +#include <libintl.h> /* pacman */ #include "log.h" #include "error.h" @@ -189,12 +190,12 @@ pmdb_t *alpm_db_register(char *treename) RET_ERR(PM_ERR_DB_NOT_NULL, NULL); } - _alpm_log(PM_LOG_FLOW1, "registering database '%s'", treename); + _alpm_log(PM_LOG_FLOW1, _("registering database '%s'"), treename); /* make sure the database directory exists */ snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename); if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { - _alpm_log(PM_LOG_FLOW1, "database directory '%s' does not exist -- try creating it", path); + _alpm_log(PM_LOG_FLOW1, _("database directory '%s' does not exist -- try creating it"), path); if(_alpm_makepath(path) != 0) { RET_ERR(PM_ERR_SYSTEM, NULL); } @@ -205,7 +206,7 @@ pmdb_t *alpm_db_register(char *treename) return(NULL); } - _alpm_log(PM_LOG_DEBUG, "opening database '%s'", db->treename); + _alpm_log(PM_LOG_DEBUG, _("opening database '%s'"), db->treename); if(_alpm_db_open(db, DB_O_CREATE) == -1) { _alpm_db_free(db); RET_ERR(PM_ERR_DB_OPEN, NULL); @@ -249,12 +250,12 @@ int alpm_db_unregister(pmdb_t *db) RET_ERR(PM_ERR_DB_NOT_FOUND, -1); } - _alpm_log(PM_LOG_FLOW1, "unregistering database '%s'", db->treename); + _alpm_log(PM_LOG_FLOW1, _("unregistering database '%s'"), db->treename); /* Cleanup */ _alpm_db_free_pkgcache(db); - _alpm_log(PM_LOG_DEBUG, "closing database '%s'", db->treename); + _alpm_log(PM_LOG_DEBUG, _("closing database '%s'"), db->treename); _alpm_db_close(db); _alpm_db_free(db); @@ -304,11 +305,11 @@ int alpm_db_update(PM_DB *db, char *archive) } /* remove the old dir */ - _alpm_log(PM_LOG_FLOW2, "flushing database %s/%s", handle->dbpath, db->treename); + _alpm_log(PM_LOG_FLOW2, _("flushing database %s/%s"), handle->dbpath, db->treename); for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { if(_alpm_db_remove(db, lp->data) == -1) { if(lp->data) { - _alpm_log(PM_LOG_ERROR, "could not remove database entry %s/%s", db->treename, + _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s/%s"), db->treename, ((pmpkg_t *)lp->data)->name); } RET_ERR(PM_ERR_DB_REMOVE, -1); @@ -322,7 +323,7 @@ int alpm_db_update(PM_DB *db, char *archive) /* ORE we should not simply unpack the archive, but better parse it and db_write each entry (see sync_load_dbarchive to get archive content) */ - _alpm_log(PM_LOG_FLOW2, "unpacking %s", archive); + _alpm_log(PM_LOG_FLOW2, _("unpacking %s"), archive); if(_alpm_unpack(archive, db->path, NULL)) { RET_ERR(PM_ERR_SYSTEM, -1); } @@ -423,7 +424,7 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm) case PM_PKG_REASON: case PM_PKG_MD5SUM: if(!(pkg->infolevel & INFRQ_DESC)) { - _alpm_log(PM_LOG_DEBUG, "loading DESC info for '%s'", pkg->name); + _alpm_log(PM_LOG_DEBUG, _("loading DESC info for '%s'"), pkg->name); _alpm_db_read(pkg->data, INFRQ_DESC, pkg); } break; @@ -443,14 +444,14 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm) case PM_PKG_FILES: case PM_PKG_BACKUP: if(pkg->data == handle->db_local && !(pkg->infolevel & INFRQ_FILES)) { - _alpm_log(PM_LOG_DEBUG, "loading FILES info for '%s'", pkg->name); + _alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), pkg->name); _alpm_db_read(pkg->data, INFRQ_FILES, pkg); } break; /* Scriptlet */ case PM_PKG_SCRIPLET: if(pkg->data == handle->db_local && !(pkg->infolevel & INFRQ_SCRIPLET)) { - _alpm_log(PM_LOG_DEBUG, "loading SCRIPLET info for '%s'", pkg->name); + _alpm_log(PM_LOG_DEBUG, _("loading SCRIPLET info for '%s'"), pkg->name); _alpm_db_read(pkg->data, INFRQ_SCRIPLET, pkg); } break; @@ -545,21 +546,21 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg) md5sum = MDFile(path); if(md5sum == NULL) { - _alpm_log(PM_LOG_ERROR, "could not get md5 checksum for package %s-%s\n", + _alpm_log(PM_LOG_ERROR, _("could not get md5 checksum for package %s-%s\n"), pkg->name, pkg->version); pm_errno = PM_ERR_NOT_A_FILE; retval = -1; } else { if(!(pkg->infolevel & INFRQ_DESC)) { - _alpm_log(PM_LOG_DEBUG, "loading DESC info for '%s'", pkg->name); + _alpm_log(PM_LOG_DEBUG, _("loading DESC info for '%s'"), pkg->name); _alpm_db_read(pkg->data, INFRQ_DESC, pkg); } if(strcmp(md5sum, pkg->md5sum) == 0) { - _alpm_log(PM_LOG_FLOW1, "checksums for package %s-%s are matching", + _alpm_log(PM_LOG_FLOW1, _("checksums for package %s-%s are matching"), pkg->name, pkg->version); } else { - _alpm_log(PM_LOG_ERROR, "md5sums do not match for package %s-%s\n", + _alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s\n"), pkg->name, pkg->version); pm_errno = PM_ERR_PKG_INVALID; retval = -1; @@ -806,8 +807,8 @@ int alpm_trans_release() handle->lckfd = -1; } if(_alpm_lckrm(PM_LOCK) == -1) { - _alpm_log(PM_LOG_WARNING, "could not remove lock file %s", PM_LOCK); - alpm_logaction("warning: could not remove lock file %s", 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); } return(0); diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 0a648223..1f18d71a 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -27,6 +27,7 @@ #include <string.h> #include <sys/stat.h> #include <dirent.h> +#include <libintl.h> #ifdef CYGWIN #include <limits.h> /* PATH_MAX */ #endif @@ -138,7 +139,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq) return(NULL); } if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version) == -1) { - _alpm_log(PM_LOG_ERROR, "invalid name for dabatase entry '%s'", ent->d_name); + _alpm_log(PM_LOG_ERROR, _("invalid name for dabatase entry '%s'"), ent->d_name); return(NULL); } if(_alpm_db_read(db, inforeq, pkg) == -1) { @@ -375,7 +376,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq) if(inforeq & INFRQ_DESC) { snprintf(path, PATH_MAX, "%s/%s-%s/desc", db->path, info->name, info->version); if((fp = fopen(path, "w")) == NULL) { - _alpm_log(PM_LOG_ERROR, "db_write: could not open file %s/desc", db->treename); + _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/desc"), db->treename); retval = 1; goto cleanup; } @@ -446,7 +447,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq) if(local && (inforeq & INFRQ_FILES)) { snprintf(path, PATH_MAX, "%s/%s-%s/files", db->path, info->name, info->version); if((fp = fopen(path, "w")) == NULL) { - _alpm_log(PM_LOG_ERROR, "db_write: could not open file %s/files", db->treename); + _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/files"), db->treename); retval = -1; goto cleanup; } @@ -472,7 +473,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq) if(inforeq & INFRQ_DEPENDS) { snprintf(path, PATH_MAX, "%s/%s-%s/depends", db->path, info->name, info->version); if((fp = fopen(path, "w")) == NULL) { - _alpm_log(PM_LOG_ERROR, "db_write: could not open file %s/depends", db->treename); + _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/depends"), db->treename); retval = -1; goto cleanup; } diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 2a98d886..3c844b49 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -26,6 +26,7 @@ #include <errno.h> #include <string.h> #include <sys/stat.h> +#include <libintl.h> /* pacman */ #include "log.h" #include "alpm.h" @@ -51,7 +52,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db) _alpm_db_free_pkgcache(db); - _alpm_log(PM_LOG_DEBUG, "loading package cache (infolevel=%#x) for repository '%s'", + _alpm_log(PM_LOG_DEBUG, _("loading package cache (infolevel=%#x) for repository '%s'"), infolevel, db->treename); _alpm_db_rewind(db); @@ -71,7 +72,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db) return; } - _alpm_log(PM_LOG_DEBUG, "freeing package cache for repository '%s'", + _alpm_log(PM_LOG_DEBUG, _("freeing package cache for repository '%s'"), db->treename); FREELISTPKGS(db->pkgcache); @@ -106,7 +107,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg) if(newpkg == NULL) { return(-1); } - _alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache", newpkg->name, db->treename); + _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); _alpm_db_free_grpcache(db); @@ -128,7 +129,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) return(-1); } - _alpm_log(PM_LOG_DEBUG, "removing entry '%s' from '%s' cache", pkg->name, db->treename); + _alpm_log(PM_LOG_DEBUG, _("removing entry '%s' from '%s' cache"), pkg->name, db->treename); FREEPKG(data); _alpm_db_free_grpcache(db); @@ -159,7 +160,7 @@ int _alpm_db_load_grpcache(pmdb_t *db) _alpm_db_load_pkgcache(db); } - _alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'", db->treename); + _alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename); for(lp = db->pkgcache; lp; lp = lp->next) { PMList *i; diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index f29a0779..2e9cc050 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -25,6 +25,7 @@ #include <string.h> #include <limits.h> #include <sys/stat.h> +#include <libintl.h> /* pacman */ #include "util.h" #include "log.h" @@ -59,7 +60,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) continue; } /* CHECK 1: check targets against database */ - _alpm_log(PM_LOG_DEBUG, "checkconflicts: targ '%s' vs db", tp->name); + _alpm_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name); for(k = _alpm_db_get_pkgcache(db); k; k = k->next) { pmpkg_t *dp = (pmpkg_t *)k->data; if(!strcmp(dp->name, tp->name)) { @@ -68,7 +69,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } if(!strcmp(j->data, dp->name)) { /* conflict */ - _alpm_log(PM_LOG_DEBUG, "targs vs db: found %s as a conflict for %s", + _alpm_log(PM_LOG_DEBUG, _("targs vs db: found %s as a conflict for %s"), 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)) { @@ -82,7 +83,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) for(m = dp->provides; m; m = m->next) { if(!strcmp(m->data, j->data)) { /* confict */ - _alpm_log(PM_LOG_DEBUG, "targs vs db: found %s as a conflict for %s", + _alpm_log(PM_LOG_DEBUG, _("targs vs db: found %s as a conflict for %s"), 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)) { @@ -95,7 +96,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } } /* CHECK 2: check targets against targets */ - _alpm_log(PM_LOG_DEBUG, "checkconflicts: targ '%s' vs targs", tp->name); + _alpm_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs targs"), tp->name); for(k = packages; k; k = k->next) { pmpkg_t *otp = (pmpkg_t *)k->data; if(!strcmp(otp->name, tp->name)) { @@ -104,7 +105,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } if(!strcmp(otp->name, (char *)j->data)) { /* otp is listed in tp's conflict list */ - _alpm_log(PM_LOG_DEBUG, "targs vs targs: found %s as a conflict for %s", + _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)) { @@ -117,7 +118,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) PMList *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", + _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)) { @@ -131,7 +132,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } } /* CHECK 3: check database against targets */ - _alpm_log(PM_LOG_DEBUG, "checkconflicts: db vs targ '%s'", tp->name); + _alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name); for(k = _alpm_db_get_pkgcache(db); k; k = k->next) { PMList *conflicts = NULL; int usenewconflicts = 0; @@ -158,7 +159,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } for(j = conflicts; j; j = j->next) { if(!strcmp((char *)j->data, tp->name)) { - _alpm_log(PM_LOG_DEBUG, "db vs targs: found %s as a conflict for %s", + _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)) { @@ -173,7 +174,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) PMList *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", + _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)) { @@ -222,7 +223,7 @@ PMList *_alpm_db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList 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", + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmconflict_t)); continue; } @@ -269,7 +270,7 @@ PMList *_alpm_db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList dbpkg = _alpm_db_get_pkgfromcache(db, p->name); } if(dbpkg && !(dbpkg->infolevel & INFRQ_FILES)) { - _alpm_log(PM_LOG_DEBUG, "loading FILES info for '%s'", dbpkg->name); + _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)) { @@ -299,7 +300,7 @@ PMList *_alpm_db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList pmpkg_t *dbpkg2 = NULL; dbpkg2 = _alpm_db_get_pkgfromcache(db, p1->name); if(dbpkg2 && !(dbpkg2->infolevel & INFRQ_FILES)) { - _alpm_log(PM_LOG_DEBUG, "loading FILES info for '%s'", dbpkg2->name); + _alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg2->name); _alpm_db_read(db, INFRQ_FILES, dbpkg2); } /* If it used to exist in there, but doesn't anymore */ @@ -331,7 +332,7 @@ donecheck: if(!ok) { pmconflict_t *conflict = malloc(sizeof(pmconflict_t)); if(conflict == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmconflict_t)); continue; } diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index ad50977c..0bdbbf73 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -27,6 +27,7 @@ #include <string.h> #include <sys/stat.h> #include <dirent.h> +#include <libintl.h> #ifdef CYGWIN #include <limits.h> /* PATH_MAX */ #endif @@ -43,14 +44,14 @@ pmdb_t *_alpm_db_new(char *root, char* dbpath, char *treename) db = (pmdb_t *)malloc(sizeof(pmdb_t)); if(db == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failed: could not allocate %d bytes", + _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); if(db->path == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failed: could not allocate %d bytes", + _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), strlen(root)+strlen(dbpath)+strlen(treename)+2); FREE(db); RET_ERR(PM_ERR_MEMORY, NULL); diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 2cd9e40f..3b4ea1d9 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> /* pacman */ #include "util.h" #include "log.h" @@ -44,7 +45,7 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsign miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t)); if(miss == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); RET_ERR(PM_ERR_MEMORY, NULL); } @@ -112,7 +113,7 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode) PMList *tmptargs = NULL; change = 0; if(numscans > numtargs) { - _alpm_log(PM_LOG_WARNING, "possible dependency cycle detected"); + _alpm_log(PM_LOG_WARNING, _("possible dependency cycle detected")); continue; } numscans++; @@ -239,7 +240,7 @@ PMList *_alpm_checkdeps(pmdb_t *db, unsigned char op, PMList *packages) FREE(ver); } if(!found) { - _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", depend.name, p->name); + _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); @@ -349,7 +350,7 @@ PMList *_alpm_checkdeps(pmdb_t *db, unsigned char op, PMList *packages) } /* else if still not found... */ if(!found) { - _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as a dependency for %s", + _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); if(!_alpm_depmiss_isin(miss, baddeps)) { @@ -370,7 +371,7 @@ PMList *_alpm_checkdeps(pmdb_t *db, unsigned char op, PMList *packages) for(j = tp->requiredby; j; j = j->next) { if(!_alpm_list_is_strin((char *)j->data, packages)) { - _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", (char *)j->data, tp->name); + _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), (char *)j->data, 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); @@ -457,12 +458,12 @@ PMList *_alpm_removedeps(pmdb_t *db, PMList *targs) /* package not found... look for a provisio instead */ k = _alpm_db_whatprovides(db, depend.name); if(k == NULL) { - _alpm_log(PM_LOG_WARNING, "cannot find package \"%s\" or anything that provides it!", depend.name); + _alpm_log(PM_LOG_WARNING, _("cannot find package \"%s\" or anything that provides it!"), depend.name); continue; } dep = _alpm_db_get_pkgfromcache(db, ((pmpkg_t *)k->data)->name); if(dep == NULL) { - _alpm_log(PM_LOG_ERROR, "dep is NULL!"); + _alpm_log(PM_LOG_ERROR, _("dep is NULL!")); /* wtf */ continue; } @@ -474,7 +475,7 @@ PMList *_alpm_removedeps(pmdb_t *db, PMList *targs) /* see if it was explicitly installed */ if(dep->reason == PM_PKG_REASON_EXPLICIT) { - _alpm_log(PM_LOG_FLOW2, "excluding %s -- explicitly installed", dep->name); + _alpm_log(PM_LOG_FLOW2, _("excluding %s -- explicitly installed"), dep->name); needed = 1; } @@ -491,10 +492,10 @@ PMList *_alpm_removedeps(pmdb_t *db, PMList *targs) continue; } /* add it to the target list */ - _alpm_log(PM_LOG_DEBUG, "loading ALL info for '%s'", pkg->name); + _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); - _alpm_log(PM_LOG_FLOW2, "adding '%s' to the targets", pkg->name); + _alpm_log(PM_LOG_FLOW2, _("adding '%s' to the targets"), pkg->name); newtargs = _alpm_removedeps(db, newtargs); } } @@ -536,7 +537,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList 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)) { - _alpm_log(PM_LOG_DEBUG, "%s provides dependency %s -- skipping", + _alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"), sp->name, miss->depend.name); found = 1; } @@ -560,11 +561,11 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList FREELISTPTR(provides); } if(sync == NULL) { - _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)", + _alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)"), miss->target, miss->depend.name); if(data) { if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); FREELIST(*data); pm_errno = PM_ERR_MEMORY; goto error; @@ -577,7 +578,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList } if(_alpm_pkg_isin(sync->name, list)) { /* this dep is already in the target list */ - _alpm_log(PM_LOG_DEBUG, "dependency %s is already in the target list -- skipping", + _alpm_log(PM_LOG_DEBUG, _("dependency %s is already in the target list -- skipping"), sync->name); continue; } @@ -597,14 +598,14 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList if(_alpm_resolvedeps(local, dbs_sync, sync, list, trail, trans, data)) { goto error; } - _alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)", + _alpm_log(PM_LOG_DEBUG, _("pulling dependency %s (needed by %s)"), sync->name, syncpkg->name); list = _alpm_list_add(list, sync); } else { - _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target); + _alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\""), miss->target); if(data) { if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); FREELIST(*data); pm_errno = PM_ERR_MEMORY; goto error; @@ -617,7 +618,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList } } else { /* cycle detected -- skip it */ - _alpm_log(PM_LOG_DEBUG, "dependency cycle detected: %s", sync->name); + _alpm_log(PM_LOG_DEBUG, _("dependency cycle detected: %s"), sync->name); } } diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 336b7152..24ca7476 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -19,6 +19,8 @@ * USA. */ +#include <libintl.h> +#include "util.h" #include "alpm.h" char *alpm_strerror(int err) @@ -26,91 +28,91 @@ char *alpm_strerror(int err) switch(err) { /* System */ case PM_ERR_MEMORY: - return "out of memory!"; + return _("out of memory!"); case PM_ERR_SYSTEM: - return "unexpected error"; + return _("unexpected error"); case PM_ERR_BADPERMS: - return "insufficient privileges"; + return _("insufficient privileges"); case PM_ERR_WRONG_ARGS: - return "wrong or NULL argument passed"; + return _("wrong or NULL argument passed"); case PM_ERR_NOT_A_FILE: - return "could not find or read file"; + return _("could not find or read file"); /* Interface */ case PM_ERR_HANDLE_NULL: - return "library not initialized"; + return _("library not initialized"); case PM_ERR_HANDLE_NOT_NULL: - return "library already initialized"; + return _("library already initialized"); case PM_ERR_HANDLE_LOCK: - return "unable to lock database"; + return _("unable to lock database"); /* Databases */ case PM_ERR_DB_OPEN: - return "could not open database"; + return _("could not open database"); case PM_ERR_DB_CREATE: - return "could not create database"; + return _("could not create database"); case PM_ERR_DB_NULL: - return "database not initialized"; + return _("database not initialized"); case PM_ERR_DB_NOT_NULL: - return "database already registered"; + return _("database already registered"); case PM_ERR_DB_NOT_FOUND: - return "could not find database"; + return _("could not find database"); case PM_ERR_DB_WRITE: - return "could not update database"; + return _("could not update database"); case PM_ERR_DB_REMOVE: - return "could not remove database entry"; + return _("could not remove database entry"); /* Configuration */ case PM_ERR_OPT_LOGFILE: case PM_ERR_OPT_DBPATH: case PM_ERR_OPT_LOCALDB: case PM_ERR_OPT_SYNCDB: case PM_ERR_OPT_USESYSLOG: - return "could not set parameter"; + return _("could not set parameter"); /* Transactions */ case PM_ERR_TRANS_NULL: - return "transaction not initialized"; + return _("transaction not initialized"); case PM_ERR_TRANS_NOT_NULL: - return "transaction already initialized"; + return _("transaction already initialized"); case PM_ERR_TRANS_DUP_TARGET: - return "duplicate target"; + return _("duplicate target"); case PM_ERR_TRANS_NOT_INITIALIZED: - return "transaction not initialized"; + return _("transaction not initialized"); case PM_ERR_TRANS_NOT_PREPARED: - return "transaction not prepared"; + return _("transaction not prepared"); case PM_ERR_TRANS_ABORT: - return "transaction aborted"; + return _("transaction aborted"); case PM_ERR_TRANS_TYPE: - return "operation not compatible with the transaction type"; + return _("operation not compatible with the transaction type"); /* Packages */ case PM_ERR_PKG_NOT_FOUND: - return "could not find or read package"; + return _("could not find or read package"); case PM_ERR_PKG_INVALID: - return "invalid or corrupted package"; + return _("invalid or corrupted package"); case PM_ERR_PKG_OPEN: - return "cannot open package file"; + return _("cannot open package file"); case PM_ERR_PKG_LOAD: - return "cannot load package data"; + return _("cannot load package data"); case PM_ERR_PKG_INSTALLED: - return "package already installed"; + return _("package already installed"); case PM_ERR_PKG_CANT_FRESH: - return "package not installed or lesser version"; + return _("package not installed or lesser version"); case PM_ERR_PKG_INVALID_NAME: - return "package name is not valid"; + return _("package name is not valid"); /* Groups */ case PM_ERR_GRP_NOT_FOUND: - return "group not found"; + return _("group not found"); /* Dependencies */ case PM_ERR_UNSATISFIED_DEPS: - return "could not satisfy dependencies"; + return _("could not satisfy dependencies"); case PM_ERR_CONFLICTING_DEPS: - return "conflicting dependencies"; + return _("conflicting dependencies"); case PM_ERR_FILE_CONFLICTS: - return "conflicting files"; + return _("conflicting files"); /* Miscellaenous */ case PM_ERR_USER_ABORT: - return "user aborted"; + return _("user aborted"); case PM_ERR_INTERNAL_ERROR: - return "internal error"; + return _("internal error"); default: - return "unexpected error"; + return _("unexpected error"); } } diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c index af769575..4df56484 100644 --- a/lib/libalpm/group.c +++ b/lib/libalpm/group.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> /* pacman */ #include "util.h" #include "error.h" @@ -36,7 +37,7 @@ pmgrp_t *_alpm_grp_new() grp = (pmgrp_t *)malloc(sizeof(pmgrp_t)); if(grp == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmgrp_t)); RET_ERR(PM_ERR_MEMORY, NULL); } diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 5300fa13..9c5d971b 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -27,6 +27,7 @@ #include <sys/types.h> #include <stdarg.h> #include <syslog.h> +#include <libintl.h> /* pacman */ #include "util.h" #include "log.h" @@ -46,7 +47,7 @@ pmhandle_t *handle_new() handle = (pmhandle_t *)malloc(sizeof(pmhandle_t)); if(handle == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmhandle_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmhandle_t)); RET_ERR(PM_ERR_MEMORY, NULL); } @@ -123,14 +124,14 @@ int handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long data) FREE(handle->dbpath); } handle->dbpath = strdup((data && strlen((char *)data) != 0) ? (char *)data : PM_DBPATH); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_DBPATH set to '%s'", handle->dbpath); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_DBPATH set to '%s'"), handle->dbpath); break; case PM_OPT_CACHEDIR: if(handle->cachedir) { FREE(handle->cachedir); } handle->cachedir = strdup((data && strlen((char *)data) != 0) ? (char *)data : PM_CACHEDIR); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_CACHEDIR set to '%s'", handle->cachedir); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_CACHEDIR set to '%s'"), handle->cachedir); break; case PM_OPT_LOGFILE: if((char *)data == NULL || handle->uid != 0) { @@ -147,37 +148,37 @@ int handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long data) handle->logfd = NULL; } if((handle->logfd = fopen((char *)data, "a")) == NULL) { - _alpm_log(PM_LOG_ERROR, "can't open log file %s", (char *)data); + _alpm_log(PM_LOG_ERROR, _("can't open log file %s"), (char *)data); RET_ERR(PM_ERR_OPT_LOGFILE, -1); } handle->logfile = strdup((char *)data); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_LOGFILE set to '%s'", (char *)data); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_LOGFILE set to '%s'"), (char *)data); break; case PM_OPT_NOUPGRADE: if((char *)data && strlen((char *)data) != 0) { handle->noupgrade = _alpm_list_add(handle->noupgrade, strdup((char *)data)); - _alpm_log(PM_LOG_FLOW2, "'%s' added to PM_OPT_NOUPGRADE", (char *)data); + _alpm_log(PM_LOG_FLOW2, _("'%s' added to PM_OPT_NOUPGRADE"), (char *)data); } else { FREELIST(handle->noupgrade); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_NOUPGRADE flushed"); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_NOUPGRADE flushed")); } break; case PM_OPT_NOEXTRACT: if((char *)data && strlen((char *)data) != 0) { handle->noextract = _alpm_list_add(handle->noextract, strdup((char *)data)); - _alpm_log(PM_LOG_FLOW2, "'%s' added to PM_OPT_NOEXTRACT", (char *)data); + _alpm_log(PM_LOG_FLOW2, _("'%s' added to PM_OPT_NOEXTRACT"), (char *)data); } else { FREELIST(handle->noextract); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_NOEXTRACT flushed"); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_NOEXTRACT flushed")); } break; case PM_OPT_IGNOREPKG: if((char *)data && strlen((char *)data) != 0) { handle->ignorepkg = _alpm_list_add(handle->ignorepkg, strdup((char *)data)); - _alpm_log(PM_LOG_FLOW2, "'%s' added to PM_OPT_IGNOREPKG", (char *)data); + _alpm_log(PM_LOG_FLOW2, _("'%s' added to PM_OPT_IGNOREPKG"), (char *)data); } else { FREELIST(handle->ignorepkg); - _alpm_log(PM_LOG_FLOW2, "PM_OPT_IGNOREPKG flushed"); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_IGNOREPKG flushed")); } break; case PM_OPT_USESYSLOG: @@ -193,14 +194,14 @@ int handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long data) openlog("alpm", 0, LOG_USER); } handle->usesyslog = (unsigned short)data; - _alpm_log(PM_LOG_FLOW2, "PM_OPT_USESYSLOG set to '%d'", handle->usesyslog); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_USESYSLOG set to '%d'"), handle->usesyslog); break; case PM_OPT_LOGCB: pm_logcb = (alpm_cb_log)data; break; case PM_OPT_LOGMASK: pm_logmask = (unsigned char)data; - _alpm_log(PM_LOG_FLOW2, "PM_OPT_LOGMASK set to '%02x'", (unsigned char)data); + _alpm_log(PM_LOG_FLOW2, _("PM_OPT_LOGMASK set to '%02x'"), (unsigned char)data); break; default: RET_ERR(PM_ERR_WRONG_ARGS, -1); diff --git a/lib/libalpm/md5driver.c b/lib/libalpm/md5driver.c index 30b37051..b6ebfa83 100644 --- a/lib/libalpm/md5driver.c +++ b/lib/libalpm/md5driver.c @@ -23,6 +23,8 @@ documentation and/or software. #include <stdio.h> #include <time.h> #include <string.h> +#include <libintl.h> +#include "util.h" #include "md5.h" /* Length of test block, number of test blocks. @@ -43,7 +45,7 @@ char* MDFile(char *filename) unsigned char buffer[1024], digest[16]; if((file = fopen(filename, "rb")) == NULL) { - printf ("%s can't be opened\n", filename); + printf (_("%s can't be opened\n"), filename); } else { char *ret; int i; diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index ab654aee..277b3946 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -25,6 +25,7 @@ #include <limits.h> #include <fcntl.h> #include <string.h> +#include <libintl.h> #include <libtar.h> #include <zlib.h> /* pacman */ @@ -89,7 +90,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg = (pmpkg_t *)malloc(sizeof(pmpkg_t)); if(newpkg == NULL) { - _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(pmpkg_t)); RET_ERR(PM_ERR_MEMORY, NULL); } @@ -169,7 +170,7 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output) int linenum = 0; if((fp = fopen(descfile, "r")) == NULL) { - _alpm_log(PM_LOG_ERROR, "could not open file %s", descfile); + _alpm_log(PM_LOG_ERROR, _("could not open file %s"), descfile); return(-1); } @@ -186,7 +187,7 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output) ptr = line; key = strsep(&ptr, "="); if(key == NULL || ptr == NULL) { - _alpm_log(PM_LOG_ERROR, "%s: syntax error in description file line %d", + _alpm_log(PM_LOG_ERROR, _("%s: syntax error in description file line %d"), info->name[0] != '\0' ? info->name : "error", linenum); } else { _alpm_strtrim(key); @@ -227,7 +228,7 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output) } else if(!strcmp(key, "BACKUP")) { info->backup = _alpm_list_add(info->backup, strdup(ptr)); } else { - _alpm_log(PM_LOG_ERROR, "%s: syntax error in description file line %d", + _alpm_log(PM_LOG_ERROR, _("%s: syntax error in description file line %d"), info->name[0] != '\0' ? info->name : "error", linenum); } } @@ -287,7 +288,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile) tar_extract_file(tar, descfile); /* parse the info file */ if(parse_descfile(descfile, info, 0) == -1) { - _alpm_log(PM_LOG_ERROR, "could not parse the package description file"); + _alpm_log(PM_LOG_ERROR, _("could not parse the package description file")); pm_errno = PM_ERR_PKG_INVALID; unlink(descfile); FREE(descfile); @@ -327,7 +328,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile) FREE(str); fclose(fp); if(unlink(fn)) { - _alpm_log(PM_LOG_WARNING, "could not remove tempfile %s", fn); + _alpm_log(PM_LOG_WARNING, _("could not remove tempfile %s"), fn); } FREE(fn); close(fd); @@ -344,7 +345,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile) } if(TH_ISREG(tar) && tar_skip_regfile(tar)) { - _alpm_log(PM_LOG_ERROR, "bad package file in %s", pkgfile); + _alpm_log(PM_LOG_ERROR, _("bad package file in %s"), pkgfile); goto error; } expath = NULL; @@ -353,7 +354,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile) tar = NULL; if(!config) { - _alpm_log(PM_LOG_ERROR, "missing package info file in %s", pkgfile); + _alpm_log(PM_LOG_ERROR, _("missing package info file in %s"), pkgfile); goto error; } diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index f8afa3a1..f675eda1 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -27,6 +27,7 @@ #include <string.h> #include <limits.h> #include <zlib.h> +#include <libintl.h> #include <libtar.h> /* pacman */ #include "util.h" @@ -59,11 +60,11 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) } if((info = _alpm_db_scan(db, name, INFRQ_ALL)) == NULL) { - _alpm_log(PM_LOG_ERROR, "could not find %s in database", name); + _alpm_log(PM_LOG_ERROR, _("could not find %s in database"), name); RET_ERR(PM_ERR_PKG_NOT_FOUND, -1); } - _alpm_log(PM_LOG_FLOW2, "adding %s in the targets list", info->name); + _alpm_log(PM_LOG_FLOW2, _("adding %s in the targets list"), info->name); trans->packages = _alpm_list_add(trans->packages, info); return(0); @@ -79,7 +80,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) if(!(trans->flags & (PM_TRANS_FLAG_NODEPS)) && (trans->type != PM_TRANS_TYPE_UPGRADE)) { EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); - _alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies"); + _alpm_log(PM_LOG_FLOW1, _("looking for unsatisfied dependencies")); lp = _alpm_checkdeps(db, trans->type, trans->packages); if(lp != NULL) { if(trans->flags & PM_TRANS_FLAG_CASCADE) { @@ -89,10 +90,10 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) 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); + _alpm_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), info->name); trans->packages = _alpm_list_add(trans->packages, info); } else { - _alpm_log(PM_LOG_ERROR, "could not find %s in database -- skipping", + _alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping"), miss->depend.name); } } @@ -110,12 +111,12 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) } if(trans->flags & PM_TRANS_FLAG_RECURSE) { - _alpm_log(PM_LOG_FLOW1, "finding removable dependencies"); + _alpm_log(PM_LOG_FLOW1, _("finding removable dependencies")); trans->packages = _alpm_removedeps(db, trans->packages); } /* re-order w.r.t. dependencies */ - _alpm_log(PM_LOG_FLOW1, "sorting by dependencies"); + _alpm_log(PM_LOG_FLOW1, _("sorting by dependencies")); lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE); /* free the old alltargs */ FREELISTPTR(trans->packages); @@ -150,7 +151,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) if(trans->type != PM_TRANS_TYPE_UPGRADE) { EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL); - _alpm_log(PM_LOG_FLOW1, "removing package %s-%s", info->name, info->version); + _alpm_log(PM_LOG_FLOW1, _("removing package %s-%s"), info->name, info->version); /* run the pre-remove scriptlet if it exists */ if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { @@ -160,7 +161,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) } if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { - _alpm_log(PM_LOG_FLOW1, "removing 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) { @@ -179,15 +180,15 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) } snprintf(line, PATH_MAX, "%s%s", handle->root, file); if(lstat(line, &buf)) { - _alpm_log(PM_LOG_DEBUG, "file %s does not exist", file); + _alpm_log(PM_LOG_DEBUG, _("file %s does not exist"), file); continue; } if(S_ISDIR(buf.st_mode)) { if(rmdir(line)) { /* this is okay, other packages are probably using it. */ - _alpm_log(PM_LOG_DEBUG, "keeping directory %s", file); + _alpm_log(PM_LOG_DEBUG, _("keeping directory %s"), file); } else { - _alpm_log(PM_LOG_FLOW2, "removing directory %s", file); + _alpm_log(PM_LOG_FLOW2, _("removing directory %s"), file); } } else { /* check the "skip list" before removing the file. @@ -201,7 +202,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) } } if(skipit) { - _alpm_log(PM_LOG_FLOW2, "skipping removal of %s as it has moved to another package", + _alpm_log(PM_LOG_FLOW2, _("skipping removal of %s as it has moved to another package"), file); } else { /* if the file is flagged, back it up to .pacsave */ @@ -213,19 +214,19 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) char newpath[PATH_MAX]; snprintf(newpath, PATH_MAX, "%s.pacsave", line); rename(line, newpath); - _alpm_log(PM_LOG_WARNING, "%s saved as %s", file, newpath); - alpm_logaction("%s saved as %s", line, newpath); + _alpm_log(PM_LOG_WARNING, _("%s saved as %s"), file, newpath); + alpm_logaction(_("%s saved as %s"), line, newpath); } else { - _alpm_log(PM_LOG_FLOW2, "unlinking %s", file); + _alpm_log(PM_LOG_FLOW2, _("unlinking %s"), file); if(unlink(line)) { - _alpm_log(PM_LOG_ERROR, "cannot remove file %s", file); + _alpm_log(PM_LOG_ERROR, _("cannot remove file %s"), file); } } } } else { - _alpm_log(PM_LOG_FLOW2, "unlinking %s", file); + _alpm_log(PM_LOG_FLOW2, _("unlinking %s"), file); if(unlink(line)) { - _alpm_log(PM_LOG_ERROR, "cannot remove file %s", file); + _alpm_log(PM_LOG_ERROR, _("cannot remove file %s"), file); } } } @@ -243,17 +244,17 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) } /* remove the package from the database */ - _alpm_log(PM_LOG_FLOW1, "updating database"); - _alpm_log(PM_LOG_FLOW2, "removing database entry '%s'", info->name); + _alpm_log(PM_LOG_FLOW1, _("updating database")); + _alpm_log(PM_LOG_FLOW2, _("removing database entry '%s'"), info->name); if(_alpm_db_remove(db, info) == -1) { - _alpm_log(PM_LOG_ERROR, "could not remove database entry %s-%s", info->name, info->version); + _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s"), info->name, info->version); } if(_alpm_db_remove_pkgfromcache(db, info) == -1) { - _alpm_log(PM_LOG_ERROR, "could not remove entry '%s' from cache", info->name); + _alpm_log(PM_LOG_ERROR, _("could not remove entry '%s' from cache"), info->name); } /* update dependency packages' REQUIREDBY fields */ - _alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields"); + _alpm_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields")); for(lp = info->depends; lp; lp = lp->next) { pmpkg_t *depinfo = NULL; pmdepend_t depend; @@ -281,7 +282,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) FREELISTPTR(provides); } if(depinfo == NULL) { - _alpm_log(PM_LOG_ERROR, "could not find dependency '%s'", depend.name); + _alpm_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name); /* wtf */ continue; } @@ -289,9 +290,9 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) /* splice out this entry from requiredby */ depinfo->requiredby = _alpm_list_remove(depinfo->requiredby, info->name, str_cmp, (void **)&data); FREE(data); - _alpm_log(PM_LOG_DEBUG, "updating 'requiredby' field for package '%s'", depinfo->name); + _alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), depinfo->name); if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) { - _alpm_log(PM_LOG_ERROR, "could not update 'requiredby' database entry %s-%s", + _alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), depinfo->name, depinfo->version); } } @@ -303,7 +304,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) /* run ldconfig if it exists */ if(trans->type != PM_TRANS_TYPE_UPGRADE) { - _alpm_log(PM_LOG_FLOW1, "running \"ldconfig -r %s\"", handle->root); + _alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root); _alpm_ldconfig(handle->root); } diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index a3553c27..3223c916 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -28,6 +28,7 @@ #include <limits.h> /* PATH_MAX */ #endif #include <dirent.h> +#include <libintl.h> #include <libtar.h> #include <zlib.h> /* pacman */ @@ -54,7 +55,7 @@ pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data) pmsyncpkg_t *sync; if((sync = (pmsyncpkg_t *)malloc(sizeof(pmsyncpkg_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmsyncpkg_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmsyncpkg_t)); return(NULL); } @@ -138,7 +139,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) PMList *i, *j, *k; /* check for "recommended" package replacements */ - _alpm_log(PM_LOG_FLOW1, "checking for package replacements"); + _alpm_log(PM_LOG_FLOW1, _("checking for package replacements")); for(i = dbs_sync; i; i = i->next) { for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) { pmpkg_t *spkg = j->data; @@ -147,9 +148,9 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) for(m = _alpm_db_get_pkgcache(db_local); m; m = m->next) { pmpkg_t *lpkg = m->data; if(!strcmp(k->data, lpkg->name)) { - _alpm_log(PM_LOG_DEBUG, "checking replacement '%s' for package '%s'", k->data, spkg->name); + _alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name); 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)", + _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 { /* get confirmation for the replacement */ @@ -183,7 +184,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_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)", + _alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (to be replaced by %s-%s)"), lpkg->name, lpkg->version, spkg->name, spkg->version); } } @@ -195,7 +196,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) } /* match installed packages with the sync dbs and compare versions */ - _alpm_log(PM_LOG_FLOW1, "checking for package upgrades"); + _alpm_log(PM_LOG_FLOW1, _("checking for package upgrades")); for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) { int cmp; int replace = 0; @@ -207,7 +208,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) spkg = _alpm_db_get_pkgfromcache(j->data, local->name); } if(spkg == NULL) { - _alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db -- skipping", local->name); + _alpm_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name); continue; } @@ -221,7 +222,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) } } if(replace) { - _alpm_log(PM_LOG_DEBUG, "'%s' is already elected for removal -- skipping", + _alpm_log(PM_LOG_DEBUG, _("'%s' is already elected for removal -- skipping"), spkg->name); continue; } @@ -230,16 +231,16 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) cmp = _alpm_versioncmp(local->version, spkg->version); if(cmp > 0 && !spkg->force) { /* local version is newer */ - _alpm_log(PM_LOG_WARNING, "%s-%s: local version is newer", + _alpm_log(PM_LOG_WARNING, _("%s-%s: local version is newer"), local->name, local->version); } else if(cmp == 0) { /* versions are identical */ } else if(_alpm_list_is_strin(i->data, handle->ignorepkg)) { /* package should be ignored (IgnorePkg) */ - _alpm_log(PM_LOG_WARNING, "%s-%s: ignoring package upgrade (%s)", + _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"), local->name, local->version, spkg->version); } else { - _alpm_log(PM_LOG_FLOW2, "%s-%s elected for upgrade (%s => %s)", + _alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"), local->name, local->version, local->version, spkg->version); if(!find_pkginsync(spkg->name, trans->packages)) { pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version); @@ -290,12 +291,12 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c if(spkg == NULL) { /* Search provides */ PMList *p; - _alpm_log(PM_LOG_FLOW2, "target '%s' not found -- looking for provisions", targ); + _alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); p = _alpm_db_whatprovides(dbs, targ); if(p == NULL) { RET_ERR(PM_ERR_PKG_NOT_FOUND, -1); } - _alpm_log(PM_LOG_DEBUG, "found '%s' as a provision for '%s'", p->data, targ); + _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); spkg = _alpm_db_get_pkgfromcache(dbs, p->data); FREELISTPTR(p); } @@ -309,12 +310,12 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c } if(spkg == NULL) { /* Search provides */ - _alpm_log(PM_LOG_FLOW2, "target '%s' not found -- looking for provisions", targ); + _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 *p = _alpm_db_whatprovides(dbs, targ); if(p) { - _alpm_log(PM_LOG_DEBUG, "found '%s' as a provision for '%s'", p->data, targ); + _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); spkg = _alpm_db_get_pkgfromcache(dbs, p->data); FREELISTPTR(p); } @@ -333,7 +334,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c int resp = 0; QUESTION(trans, PM_TRANS_CONV_LOCAL_NEWER, local, NULL, NULL, &resp); if(!resp) { - _alpm_log(PM_LOG_WARNING, "%s-%s: local version is newer -- skipping", local->name, local->version); + _alpm_log(PM_LOG_WARNING, _("%s-%s: local version is newer -- skipping"), local->name, local->version); return(0); } } else if(cmp == 0) { @@ -341,7 +342,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c int resp = 0; QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, &resp); if(!resp) { - _alpm_log(PM_LOG_WARNING, "%s-%s is up to date -- skipping", local->name, local->version); + _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping"), local->name, local->version); return(0); } } @@ -361,7 +362,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c FREEPKG(dummy); RET_ERR(PM_ERR_MEMORY, -1); } - _alpm_log(PM_LOG_FLOW2, "adding target '%s' to the transaction set", spkg->name); + _alpm_log(PM_LOG_FLOW2, _("adding target '%s' to the transaction set"), spkg->name); trans->packages = _alpm_list_add(trans->packages, sync); } @@ -401,7 +402,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML /* Resolve targets dependencies */ EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL); - _alpm_log(PM_LOG_FLOW1, "resolving targets dependencies"); + _alpm_log(PM_LOG_FLOW1, _("resolving targets dependencies")); for(i = trans->packages; i; i = i->next) { pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg; if(_alpm_resolvedeps(db_local, dbs_sync, spkg, list, trail, trans, data) == -1) { @@ -420,13 +421,13 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML goto cleanup; } trans->packages = _alpm_list_add(trans->packages, sync); - _alpm_log(PM_LOG_FLOW2, "adding package %s-%s to the transaction targets", + _alpm_log(PM_LOG_FLOW2, _("adding package %s-%s to the transaction targets"), spkg->name, spkg->version); } } EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL); - _alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies"); + _alpm_log(PM_LOG_FLOW1, _("looking for unresolvable dependencies")); deps = _alpm_checkdeps(db_local, PM_TRANS_TYPE_UPGRADE, list); if(deps) { if(data) { @@ -445,7 +446,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML /* check for inter-conflicts and whatnot */ EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL); - _alpm_log(PM_LOG_FLOW1, "looking for conflicts"); + _alpm_log(PM_LOG_FLOW1, _("looking for conflicts")); deps = _alpm_checkconflicts(db_local, list); if(deps) { int errorout = 0; @@ -456,7 +457,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML pmsyncpkg_t *sync; pmpkg_t *local; - _alpm_log(PM_LOG_FLOW2, "package '%s' is conflicting with '%s'", + _alpm_log(PM_LOG_FLOW2, _("package '%s' is conflicting with '%s'"), miss->target, miss->depend.name); /* check if the conflicting package is one that's about to be removed/replaced. @@ -490,7 +491,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML /* so just treat it like a "replaces" item so the REQUIREDBY * fields are inherited properly. */ - _alpm_log(PM_LOG_DEBUG, "package '%s' provides its own conflict", miss->target); + _alpm_log(PM_LOG_DEBUG, _("package '%s' provides its own conflict"), miss->target); if(local) { /* nothing to do for now: it will be handled later * (not the same behavior as in pacman 2.x) */ @@ -513,12 +514,12 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML 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", + _alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"), miss->depend.name); /* remove miss->target */ rmpkg = miss->target; } else if(target && !depend) { - _alpm_log(PM_LOG_DEBUG, "'%s' is in the target list -- keeping it", + _alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"), miss->target); /* remove miss->depend.name */ rmpkg = miss->depend.name; @@ -528,7 +529,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML if(rmpkg) { pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages); pmsyncpkg_t *spkg = NULL; - _alpm_log(PM_LOG_FLOW2, "removing '%s' from target list", rmpkg); + _alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg); trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, (void **)&spkg); FREESYNC(spkg); continue; @@ -538,7 +539,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML /* It's a conflict -- see if they want to remove it */ - _alpm_log(PM_LOG_DEBUG, "resolving package '%s' conflict", miss->target); + _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)) { @@ -561,22 +562,22 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML FREEPKG(sync->data); } /* append to the replaces list */ - _alpm_log(PM_LOG_FLOW2, "electing '%s' for removal", miss->depend.name); + _alpm_log(PM_LOG_FLOW2, _("electing '%s' for removal"), miss->depend.name); sync->data = _alpm_list_add(sync->data, q); if(rsync) { /* remove it from the target list */ pmsyncpkg_t *spkg = NULL; - _alpm_log(PM_LOG_FLOW2, "removing '%s' from target list", miss->depend.name); + _alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name); trans->packages = _alpm_list_remove(trans->packages, rsync, ptr_cmp, (void **)&spkg); FREESYNC(spkg); } } else { /* abort */ - _alpm_log(PM_LOG_ERROR, "unresolvable package conflicts detected"); + _alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected")); errorout = 1; if(data) { if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); FREELIST(*data); pm_errno = PM_ERR_MEMORY; ret = -1; @@ -588,11 +589,11 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML } } } else { - _alpm_log(PM_LOG_ERROR, "unresolvable package conflicts detected"); + _alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected")); errorout = 1; if(data) { if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); FREELIST(*data); pm_errno = PM_ERR_MEMORY; ret = -1; @@ -654,7 +655,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML pmpkg_t *leavingp = _alpm_db_get_pkgfromcache(db_local, miss->target); pmpkg_t *conflictp = _alpm_db_get_pkgfromcache(db_local, miss->depend.name); if(!leavingp || !conflictp) { - _alpm_log(PM_LOG_ERROR, "something has gone horribly wrong"); + _alpm_log(PM_LOG_ERROR, _("something has gone horribly wrong")); ret = -1; goto cleanup; } @@ -673,7 +674,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML for(o = sp->pkg->provides; o && !pfound; o = o->next) { if(!strcmp(m->data, o->data)) { /* found matching provisio -- we're good to go */ - _alpm_log(PM_LOG_FLOW2, "found '%s' as a provision for '%s' -- conflict aborted", + _alpm_log(PM_LOG_FLOW2, _("found '%s' as a provision for '%s' -- conflict aborted"), sp->pkg->name, (char *)o->data); pfound = 1; } @@ -688,7 +689,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML } if(data) { if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t)); FREELIST(*data); pm_errno = PM_ERR_MEMORY; ret = -1; @@ -732,14 +733,14 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) /* remove conflicting and to-be-replaced packages */ tr = _alpm_trans_new(); if(tr == NULL) { - _alpm_log(PM_LOG_ERROR, "could not create removal transaction"); + _alpm_log(PM_LOG_ERROR, _("could not create removal transaction")); pm_errno = PM_ERR_MEMORY; goto error; } if(_alpm_trans_init(tr, PM_TRANS_TYPE_REMOVE, PM_TRANS_FLAG_NODEPS, trans->cb_event, trans->cb_conv) == -1) { - _alpm_log(PM_LOG_ERROR, "could not initialize the removal transaction"); + _alpm_log(PM_LOG_ERROR, _("could not initialize the removal transaction")); goto error; } @@ -759,31 +760,31 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) } } if(replaces) { - _alpm_log(PM_LOG_FLOW1, "removing conflicting and to-be-replaced packages"); + _alpm_log(PM_LOG_FLOW1, _("removing conflicting and to-be-replaced packages")); if(_alpm_trans_prepare(tr, data) == -1) { - _alpm_log(PM_LOG_ERROR, "could not prepare removal transaction"); + _alpm_log(PM_LOG_ERROR, _("could not prepare removal transaction")); goto error; } /* we want the frontend to be aware of commit details */ tr->cb_event = trans->cb_event; if(_alpm_trans_commit(tr, NULL) == -1) { - _alpm_log(PM_LOG_ERROR, "could not commit removal transaction"); + _alpm_log(PM_LOG_ERROR, _("could not commit removal transaction")); goto error; } } FREETRANS(tr); /* install targets */ - _alpm_log(PM_LOG_FLOW1, "installing packages"); + _alpm_log(PM_LOG_FLOW1, _("installing packages")); tr = _alpm_trans_new(); if(tr == NULL) { - _alpm_log(PM_LOG_ERROR, "could not create transaction"); + _alpm_log(PM_LOG_ERROR, _("could not create transaction")); pm_errno = PM_ERR_MEMORY; goto error; } if(_alpm_trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags | PM_TRANS_FLAG_NODEPS, trans->cb_event, trans->cb_conv) == -1) { - _alpm_log(PM_LOG_ERROR, "could not initialize transaction"); + _alpm_log(PM_LOG_ERROR, _("could not initialize transaction")); goto error; } for(i = trans->packages; i; i = i->next) { @@ -802,18 +803,18 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) } } if(_alpm_trans_prepare(tr, data) == -1) { - _alpm_log(PM_LOG_ERROR, "could not prepare transaction"); + _alpm_log(PM_LOG_ERROR, _("could not prepare transaction")); goto error; } if(_alpm_trans_commit(tr, NULL) == -1) { - _alpm_log(PM_LOG_ERROR, "could not commit transaction"); + _alpm_log(PM_LOG_ERROR, _("could not commit transaction")); goto error; } FREETRANS(tr); /* propagate replaced packages' requiredby fields to their new owners */ if(replaces) { - _alpm_log(PM_LOG_FLOW1, "updating database for replaced packages dependencies"); + _alpm_log(PM_LOG_FLOW1, _("updating database for replaced packages dependencies")); for(i = trans->packages; i; i = i->next) { pmsyncpkg_t *sync = i->data; if(sync->type == PM_SYNC_TYPE_REPLACE) { @@ -842,7 +843,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) } } if(_alpm_db_write(db_local, depender, INFRQ_DEPENDS) == -1) { - _alpm_log(PM_LOG_ERROR, "could not update requiredby for database entry %s-%s", + _alpm_log(PM_LOG_ERROR, _("could not update requiredby for database entry %s-%s"), new->name, new->version); } /* add the new requiredby */ @@ -851,7 +852,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) } } if(_alpm_db_write(db_local, new, INFRQ_DEPENDS) == -1) { - _alpm_log(PM_LOG_ERROR, "could not update new database entry %s-%s", + _alpm_log(PM_LOG_ERROR, _("could not update new database entry %s-%s"), new->name, new->version); } } diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index ba1f2337..b0995fe4 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> /* pacman */ #include "error.h" #include "package.h" @@ -42,7 +43,7 @@ pmtrans_t *_alpm_trans_new() pmtrans_t *trans; if((trans = (pmtrans_t *)malloc(sizeof(pmtrans_t))) == NULL) { - _alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmtrans_t)); + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmtrans_t)); return(NULL); } diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 49580c36..f85f5ce3 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -32,6 +32,7 @@ #include <time.h> #include <syslog.h> #include <sys/wait.h> +#include <libintl.h> #ifdef CYGWIN #include <limits.h> /* PATH_MAX */ #endif @@ -223,7 +224,7 @@ int _alpm_unpack(char *archive, const char *prefix, const char *fn) while(!th_read(tar)) { if(fn && strcmp(fn, th_get_pathname(tar))) { if(TH_ISREG(tar) && tar_skip_regfile(tar)) { - _alpm_log(PM_LOG_ERROR, "bad tar archive: %s", archive); + _alpm_log(PM_LOG_ERROR, _("bad tar archive: %s"), archive); tar_close(tar); return(1); } @@ -231,7 +232,7 @@ int _alpm_unpack(char *archive, const char *prefix, const char *fn) } snprintf(expath, PATH_MAX, "%s/%s", prefix, th_get_pathname(tar)); if(tar_extract_file(tar, expath)) { - _alpm_log(PM_LOG_ERROR, "could not extract %s (%s)", th_get_pathname(tar), strerror(errno)); + _alpm_log(PM_LOG_ERROR, _("could not extract %s (%s)"), th_get_pathname(tar), strerror(errno)); } if(fn) break; } @@ -379,7 +380,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha } 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"); @@ -399,17 +400,17 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha /* 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"); + _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); + _alpm_log(PM_LOG_FLOW2, _("executing %s script..."), script); if(oldver) { snprintf(cmdline, PATH_MAX, "source %s %s %s %s", @@ -422,28 +423,28 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha 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) { - _alpm_log(PM_LOG_DEBUG, "chrooting in %s", root); + _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); + _alpm_log(PM_LOG_DEBUG, _("executing \"%s\""), cmdline); execl("/bin/sh", "sh", "-c", cmdline, (char *)0); 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; } @@ -451,7 +452,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha 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); diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 7b24961c..af8162b2 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -32,6 +32,8 @@ s1[(len)-1] = 0; \ } while(0) +#define _(str) dgettext("libalpm", str) + long _alpm_gzopen_frontend(char *pathname, int oflags, int mode); int _alpm_makepath(char *path); int _alpm_copyfile(char *src, char *dest); diff --git a/src/pacman/add.c b/src/pacman/add.c index c63e14b5..04182df9 100644 --- a/src/pacman/add.c +++ b/src/pacman/add.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -31,6 +32,7 @@ #include "trans.h" #include "add.h" #include "conf.h" +#include "util.h" extern config_t *config; @@ -64,34 +66,34 @@ int pacman_add(list_t *targets) config->flags, cb_trans_evt, cb_trans_conv) == -1) { 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\n", PM_LOCK); + MSG(NL, _(" if you're sure a package manager is not already running,\n" + " you can remove %s\n"), PM_LOCK); } return(1); } /* and add targets to it */ - MSG(NL, "loading package data... "); + MSG(NL, _("loading package data... ")); for(i = targets; 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)); + ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } } - MSG(CL, "done."); + MSG(CL, _("done.")); /* Step 2: "compute" the transaction based on targets and flags */ if(alpm_trans_prepare(&data) == -1) { PM_LIST *i; - ERR(NL, "failed to prepare transaction (%s)\n", alpm_strerror(pm_errno)); + 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)) { PM_DEPMISS *miss = alpm_list_getdata(i); - MSG(NL, ":: %s: requires %s", alpm_dep_getinfo(miss, PM_DEP_TARGET), + MSG(NL, _(":: %s: requires %s"), alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME)); switch((int)alpm_dep_getinfo(miss, PM_DEP_MOD)) { case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_getinfo(miss, PM_DEP_VERSION)); break; @@ -105,7 +107,7 @@ int pacman_add(list_t *targets) case PM_ERR_CONFLICTING_DEPS: for(i = alpm_list_first(data); i; i = alpm_list_next(i)) { PM_DEPMISS *miss = alpm_list_getdata(i); - MSG(NL, ":: %s: conflicts with %s", + MSG(NL, _(":: %s: conflicts with %s"), alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME)); } alpm_list_free(data); @@ -115,20 +117,20 @@ int pacman_add(list_t *targets) PM_CONFLICT *conflict = alpm_list_getdata(i); switch((int)alpm_conflict_getinfo(conflict, PM_CONFLICT_TYPE)) { case PM_CONFLICT_TYPE_TARGET: - MSG(NL, "%s exists in \"%s\" (target) and \"%s\" (target)", + MSG(NL, _("%s exists in \"%s\" (target) and \"%s\" (target)"), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_FILE), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_TARGET), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_CTARGET)); break; case PM_CONFLICT_TYPE_FILE: - MSG(NL, "%s: %s exists in filesystem", + MSG(NL, _("%s: %s exists in filesystem"), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_TARGET), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_FILE)); break; } } alpm_list_free(data); - MSG(NL, "\nerrors occurred, no packages were upgraded.\n"); + MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); break; default: break; @@ -140,7 +142,7 @@ int pacman_add(list_t *targets) /* Step 3: actually perform the installation */ if(alpm_trans_commit(NULL) == -1) { - ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -149,7 +151,7 @@ int pacman_add(list_t *targets) */ cleanup: if(alpm_trans_release() == -1) { - ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; } diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 2a49fadc..1caefd32 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <string.h> #include <limits.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -98,13 +99,13 @@ int parseconfig(char *file, config_t *config) ptr++; strncpy(section, ptr, min(255, strlen(ptr)-1)); section[min(255, strlen(ptr)-1)] = '\0'; - vprint("config: new section '%s'\n", section); + vprint(_("config: new section '%s'\n"), section); if(!strlen(section)) { - ERR(NL, "config: line %d: bad section name\n", linenum); + ERR(NL, _("config: line %d: bad section name\n"), linenum); return(1); } if(!strcmp(section, "local")) { - ERR(NL, "config: line %d: '%s' is reserved and cannot be used as a package tree\n", + ERR(NL, _("config: line %d: '%s' is reserved and cannot be used as a package tree\n"), linenum, section); return(1); } @@ -130,29 +131,29 @@ int parseconfig(char *file, config_t *config) ptr = line; key = strsep(&ptr, "="); if(key == NULL) { - ERR(NL, "config: line %d: syntax error\n", linenum); + ERR(NL, _("config: line %d: syntax error\n"), linenum); return(1); } strtrim(key); key = strtoupper(key); if(!strlen(section) && strcmp(key, "INCLUDE")) { - ERR(NL, "config: line %d: all directives must belong to a section\n", linenum); + ERR(NL, _("config: line %d: all directives must belong to a section\n"), linenum); return(1); } if(ptr == NULL) { if(!strcmp(key, "NOPASSIVEFTP")) { config->nopassiveftp = 1; - vprint("config: nopassiveftp\n"); + vprint(_("config: nopassiveftp\n")); } else if(!strcmp(key, "USESYSLOG")) { if(alpm_set_option(PM_OPT_USESYSLOG, (long)1) == -1) { - ERR(NL, "failed to set option USESYSLOG (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option USESYSLOG (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: usesyslog\n"); + vprint(_("config: usesyslog\n")); } else if(!strcmp(key, "ILOVECANDY")) { config->chomp = 1; } else { - ERR(NL, "config: line %d: syntax error\n", linenum); + ERR(NL, _("config: line %d: syntax error\n"), linenum); return(1); } } else { @@ -160,7 +161,7 @@ int parseconfig(char *file, config_t *config) if(!strcmp(key, "INCLUDE")) { char conf[PATH_MAX]; strncpy(conf, ptr, PATH_MAX); - vprint("config: including %s\n", conf); + vprint(_("config: including %s\n"), conf); parseconfig(conf, config); } else if(!strcmp(section, "options")) { if(!strcmp(key, "NOUPGRADE")) { @@ -169,66 +170,66 @@ int parseconfig(char *file, config_t *config) while((q = strchr(p, ' '))) { *q = '\0'; if(alpm_set_option(PM_OPT_NOUPGRADE, (long)p) == -1) { - ERR(NL, "failed to set option NOUPGRADE (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option NOUPGRADE (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: noupgrade: %s\n", p); + vprint(_("config: noupgrade: %s\n"), p); p = q; p++; } if(alpm_set_option(PM_OPT_NOUPGRADE, (long)p) == -1) { - ERR(NL, "failed to set option NOUPGRADE (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option NOUPGRADE (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: noupgrade: %s\n", p); + vprint(_("config: noupgrade: %s\n"), p); } else if(!strcmp(key, "NOEXTRACT")) { char *p = ptr; char *q; while((q = strchr(p, ' '))) { *q = '\0'; if(alpm_set_option(PM_OPT_NOEXTRACT, (long)p) == -1) { - ERR(NL, "failed to set option NOEXTRACT (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option NOEXTRACT (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: noextract: %s\n", p); + vprint(_("config: noextract: %s\n"), p); p = q; p++; } if(alpm_set_option(PM_OPT_NOEXTRACT, (long)p) == -1) { - ERR(NL, "failed to set option NOEXTRACT (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option NOEXTRACT (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: noextract: %s\n", p); + vprint(_("config: noextract: %s\n"), p); } else if(!strcmp(key, "IGNOREPKG")) { char *p = ptr; char *q; while((q = strchr(p, ' '))) { *q = '\0'; if(alpm_set_option(PM_OPT_IGNOREPKG, (long)p) == -1) { - ERR(NL, "failed to set option IGNOREPKG (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option IGNOREPKG (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: ignorepkg: %s\n", p); + vprint(_("config: ignorepkg: %s\n"), p); p = q; p++; } if(alpm_set_option(PM_OPT_IGNOREPKG, (long)p) == -1) { - ERR(NL, "failed to set option IGNOREPKG (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option IGNOREPKG (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: ignorepkg: %s\n", p); + vprint(_("config: ignorepkg: %s\n"), p); } else if(!strcmp(key, "HOLDPKG")) { char *p = ptr; char *q; while((q = strchr(p, ' '))) { *q = '\0'; config->holdpkg = list_add(config->holdpkg, strdup(p)); - vprint("config: holdpkg: %s\n", p); + vprint(_("config: holdpkg: %s\n"), p); p = q; p++; } config->holdpkg = list_add(config->holdpkg, strdup(p)); - vprint("config: holdpkg: %s\n", p); + vprint(_("config: holdpkg: %s\n"), p); } else if(!strcmp(key, "DBPATH")) { /* shave off the leading slash, if there is one */ if(*ptr == '/') { @@ -236,7 +237,7 @@ int parseconfig(char *file, config_t *config) } FREE(config->dbpath); config->dbpath = strdup(ptr); - vprint("config: dbpath: %s\n", ptr); + vprint(_("config: dbpath: %s\n"), ptr); } else if(!strcmp(key, "CACHEDIR")) { /* shave off the leading slash, if there is one */ if(*ptr == '/') { @@ -244,17 +245,17 @@ int parseconfig(char *file, config_t *config) } FREE(config->cachedir); config->cachedir = strdup(ptr); - vprint("config: cachedir: %s\n", ptr); + vprint(_("config: cachedir: %s\n"), ptr); } else if (!strcmp(key, "LOGFILE")) { if(alpm_set_option(PM_OPT_LOGFILE, (long)ptr) == -1) { - ERR(NL, "failed to set option LOGFILE (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option LOGFILE (%s)\n"), alpm_strerror(pm_errno)); return(1); } - vprint("config: log file: %s\n", ptr); + vprint(_("config: log file: %s\n"), ptr); } else if (!strcmp(key, "XFERCOMMAND")) { FREE(config->xfercommand); config->xfercommand = strndup(ptr, PATH_MAX); - vprint("config: xfercommand: %s\n", config->xfercommand); + vprint(_("config: xfercommand: %s\n"), config->xfercommand); } else if (!strcmp(key, "PROXYSERVER")) { char *p; if(config->proxyhost) { @@ -264,18 +265,18 @@ int parseconfig(char *file, config_t *config) if(p) { p += 3; if(p == NULL || *p == '\0') { - ERR(NL, "config: line %d: bad server location\n", linenum); + ERR(NL, _("config: line %d: bad server location\n"), linenum); return(1); } ptr = p; } config->proxyhost = strndup(ptr, PATH_MAX); - vprint("config: proxyserver: %s\n", config->proxyhost); + vprint(_("config: proxyserver: %s\n"), config->proxyhost); } else if (!strcmp(key, "PROXYPORT")) { config->proxyport = (unsigned short)atoi(ptr); - vprint("config: proxyport: %u\n", config->proxyport); + vprint(_("config: proxyport: %u\n"), config->proxyport); } else { - ERR(NL, "config: line %d: syntax error\n", linenum); + ERR(NL, _("config: line %d: syntax error\n"), linenum); return(1); } } else { @@ -290,13 +291,13 @@ int parseconfig(char *file, config_t *config) p = strstr(ptr, "://"); if(p == NULL) { - ERR(NL, "config: line %d: bad server location\n", linenum); + ERR(NL, _("config: line %d: bad server location\n"), linenum); return(1); } *p = '\0'; p++; p++; p++; if(p == NULL || *p == '\0') { - ERR(NL, "config: line %d: bad server location\n", linenum); + ERR(NL, _("config: line %d: bad server location\n"), linenum); return(1); } server->protocol = strdup(ptr); @@ -313,7 +314,7 @@ int parseconfig(char *file, config_t *config) server->path = strdup(slash); } else { if((server->path = (char *)malloc(strlen(slash)+2)) == NULL) { - ERR(NL, "could not allocate %d bytes\n", sizeof(strlen(slash+2))); + ERR(NL, _("could not allocate %d bytes\n"), sizeof(strlen(slash+2))); return(1); } sprintf(server->path, "%s/", slash); @@ -328,20 +329,20 @@ int parseconfig(char *file, config_t *config) } else { server->path = (char *)malloc(strlen(p)+2); if(server->path == NULL) { - ERR(NL, "could not allocate %d bytes\n", sizeof(strlen(p+2))); + ERR(NL, _("could not allocate %d bytes\n"), sizeof(strlen(p+2))); return(1); } sprintf(server->path, "%s/", p); } } else { - ERR(NL, "config: line %d: protocol %s is not supported\n", linenum, ptr); + ERR(NL, _("config: line %d: protocol %s is not supported\n"), linenum, ptr); return(1); } /* add to the list */ - vprint("config: %s: server: %s %s %s\n", section, server->protocol, server->server, server->path); + vprint(_("config: %s: server: %s %s %s\n"), section, server->protocol, server->server, server->path); sync->servers = list_add(sync->servers, server); } else { - ERR(NL, "config: line %d: syntax error\n", linenum); + ERR(NL, _("config: line %d: syntax error\n"), linenum); return(1); } } diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 1ed11aa0..425bd1da 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> #include <alpm.h> /* pacman */ #include "util.h" @@ -60,8 +61,8 @@ int pacman_deptest(list_t *targets) if(alpm_trans_init(PM_TRANS_TYPE_ADD, 0, NULL, NULL) == -1) { ERR(NL, "%s", 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\n", PM_LOCK); + MSG(NL, _(" if you're sure a package manager is not already running,\n" + " you can remove %s\n"), PM_LOCK); } return(1); } @@ -73,7 +74,7 @@ int pacman_deptest(list_t *targets) */ str = (char *)malloc(strlen("name=dummy|version=1.0-1")+1); if(str == NULL) { - ERR(NL, "memory allocation failure\n"); + ERR(NL, _("memory allocation failure\n")); retval = 1; goto cleanup; } @@ -83,10 +84,10 @@ int pacman_deptest(list_t *targets) strcat(str, "|depend="); strcat(str, i->data); } - vprint("add target %s\n", str); + vprint(_("add target %s\n"), str); if(alpm_trans_addtarget(str) == -1) { FREE(str); - ERR(NL, "could not add target (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("could not add target (%s)\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -106,7 +107,7 @@ int pacman_deptest(list_t *targets) for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { PM_DEPMISS *miss = alpm_list_getdata(lp); if(!config->op_d_resolve) { - MSG(NL, "requires: %s", alpm_dep_getinfo(miss, PM_DEP_NAME)); + MSG(NL, _("requires: %s"), alpm_dep_getinfo(miss, PM_DEP_NAME)); switch((int)alpm_dep_getinfo(miss, PM_DEP_MOD)) { case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_getinfo(miss, PM_DEP_VERSION)); break; case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_getinfo(miss, PM_DEP_VERSION)); break; @@ -122,7 +123,7 @@ int pacman_deptest(list_t *targets) /* we can't auto-resolve conflicts */ for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { PM_DEPMISS *miss = alpm_list_getdata(lp); - MSG(NL, "conflict: %s", alpm_dep_getinfo(miss, PM_DEP_NAME)); + MSG(NL, _("conflict: %s"), alpm_dep_getinfo(miss, PM_DEP_NAME)); } retval = 127; alpm_list_free(data); @@ -136,7 +137,7 @@ int pacman_deptest(list_t *targets) /* TODO: handle version comparators (eg, glibc>=2.2.5) */ if(retval == 126 && synctargs != NULL) { if(alpm_trans_release() == -1) { - ERR(NL, "could not release transaction (%s)", alpm_strerror(pm_errno)); + ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno)); FREELIST(synctargs); return(1); } @@ -153,7 +154,7 @@ int pacman_deptest(list_t *targets) cleanup: if(alpm_trans_release() == -1) { - ERR(NL, "could not release transaction (%s)", alpm_strerror(pm_errno)); + ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno)); retval = 1; } diff --git a/src/pacman/download.c b/src/pacman/download.c index 9a80e29e..b59aeada 100644 --- a/src/pacman/download.c +++ b/src/pacman/download.c @@ -29,6 +29,7 @@ #include <time.h> #include <sys/time.h> #include <ftplib.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -204,27 +205,27 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, if(!config->xfercommand && strcmp(server->protocol, "file")) { if(!strcmp(server->protocol, "ftp") && !config->proxyhost) { FtpInit(); - vprint("connecting to %s:21\n", server->server); + vprint(_("connecting to %s:21\n"), server->server); if(!FtpConnect(server->server, &control)) { - ERR(NL, "cannot connect to %s\n", server->server); + ERR(NL, _("cannot connect to %s\n"), server->server); continue; } if(!FtpLogin("anonymous", "arch@guest", control)) { - ERR(NL, "anonymous login failed\n"); + ERR(NL, _("anonymous login failed\n")); FtpQuit(control); continue; } if(!FtpChdir(server->path, control)) { - ERR(NL, "could not cwd to %s: %s\n", server->path, FtpLastResponse(control)); + ERR(NL, _("could not cwd to %s: %s\n"), server->path, FtpLastResponse(control)); FtpQuit(control); continue; } if(!config->nopassiveftp) { if(!FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, control)) { - WARN(NL, "failed to set passive mode\n"); + WARN(NL, _("failed to set passive mode\n")); } } else { - vprint("FTP passive mode not set\n"); + vprint(_("FTP passive mode not set\n")); } } else if(config->proxyhost) { char *host; @@ -232,12 +233,12 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, host = (config->proxyhost) ? config->proxyhost : server->server; port = (config->proxyport) ? config->proxyport : 80; if(strchr(host, ':')) { - vprint("connecting to %s\n", host); + vprint(_("connecting to %s\n"), host); } else { - vprint("connecting to %s:%u\n", host, port); + vprint(_("connecting to %s:%u\n"), host, port); } if(!HttpConnect(host, port, &control)) { - ERR(NL, "cannot connect to %s\n", host); + ERR(NL, _("cannot connect to %s\n"), host); continue; } } @@ -296,18 +297,18 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, /* cwd to the download directory */ getcwd(cwd, PATH_MAX); if(chdir(localpath)) { - ERR(NL, "could not chdir to %s\n", localpath); + ERR(NL, _("could not chdir to %s\n"), localpath); return(1); } /* execute the parsed command via /bin/sh -c */ - vprint("running command: %s\n", parsedCmd); + vprint(_("running command: %s\n"), parsedCmd); ret = system(parsedCmd); if(ret == -1) { - ERR(NL, "running XferCommand: fork failed!\n"); + ERR(NL, _("running XferCommand: fork failed!\n")); return(1); } else if(ret != 0) { /* download failed */ - vprint("XferCommand command returned non-zero status code (%d)\n", ret); + vprint(_("XferCommand command returned non-zero status code (%d)\n"), ret); } else { /* download was successful */ complete = list_add(complete, fn); @@ -352,18 +353,18 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, if(!strcmp(server->protocol, "ftp") && !config->proxyhost) { if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) { - WARN(NL, "failed to get filesize for %s\n", fn); + WARN(NL, _("failed to get filesize for %s\n"), fn); } /* check mtimes */ if(mtime1) { char fmtime[64]; if(!FtpModDate(fn, fmtime, sizeof(fmtime)-1, control)) { - WARN(NL, "failed to get mtime for %s\n", fn); + WARN(NL, _("failed to get mtime for %s\n"), fn); } else { strtrim(fmtime); if(mtime1 && !strcmp(mtime1, fmtime)) { /* mtimes are identical, skip this file */ - vprint("mtimes are identical, skipping %s\n", fn); + vprint(_("mtimes are identical, skipping %s\n"), fn); filedone = -1; complete = list_add(complete, fn); } else { @@ -378,14 +379,14 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, if(!stat(output, &st)) { offset = (int)st.st_size; if(!FtpRestart(offset, control)) { - WARN(NL, "failed to resume download -- restarting\n"); + WARN(NL, _("failed to resume download -- restarting\n")); /* can't resume: */ /* unlink the file in order to restart download from scratch */ unlink(output); } } if(!FtpGet(output, fn, FTPLIB_IMAGE, control)) { - ERR(NL, "\nfailed downloading %s from %s: %s\n", fn, server->server, FtpLastResponse(control)); + ERR(NL, _("\nfailed downloading %s from %s: %s\n"), fn, server->server, FtpLastResponse(control)); /* we leave the partially downloaded file in place so it can be resumed later */ } else { filedone = 1; @@ -406,12 +407,12 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, host = (config->proxyhost) ? config->proxyhost : server->server; port = (config->proxyhost) ? config->proxyport : 80; if(strchr(host, ':')) { - vprint("connecting to %s\n", host); + vprint(_("connecting to %s\n"), host); } else { - vprint("connecting to %s:%u\n", host, port); + vprint(_("connecting to %s:%u\n"), host, port); } if(!HttpConnect(host, port, &control)) { - ERR(NL, "cannot connect to %s\n", host); + ERR(NL, _("cannot connect to %s\n"), host); continue; } /* set up our progress bar's callback (and idle timeout) */ @@ -456,11 +457,11 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, if(!HttpGet(server->server, output, src, &fsz, control, offset, (mtime1) ? &fmtime1 : NULL, (mtime2) ? &fmtime2 : NULL)) { if(strstr(FtpLastResponse(control), "304")) { - vprint("mtimes are identical, skipping %s\n", fn); + vprint(_("mtimes are identical, skipping %s\n"), fn); filedone = -1; complete = list_add(complete, fn); } else { - ERR(NL, "\nfailed downloading %s from %s: %s\n", src, server->server, FtpLastResponse(control)); + ERR(NL, _("\nfailed downloading %s from %s: %s\n"), src, server->server, FtpLastResponse(control)); /* we leave the partially downloaded file in place so it can be resumed later */ } } else { @@ -471,7 +472,7 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, fmtime2.tm_year+1900, fmtime2.tm_mon+1, fmtime2.tm_mday, fmtime2.tm_hour, fmtime2.tm_min, fmtime2.tm_sec); } else { - WARN(NL, "failed to get mtime for %s\n", fn); + WARN(NL, _("failed to get mtime for %s\n"), fn); } } filedone = 1; @@ -479,10 +480,10 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, } else if(!strcmp(server->protocol, "file")) { char src[PATH_MAX]; snprintf(src, PATH_MAX, "%s%s", server->path, fn); - vprint("copying %s to %s/%s\n", src, localpath, fn); + vprint(_("copying %s to %s/%s\n"), src, localpath, fn); /* local repository, just copy the file */ if(copyfile(src, output)) { - ERR(NL, "failed copying %s\n", src); + ERR(NL, _("failed copying %s\n"), src); } else { filedone = 1; } @@ -498,7 +499,7 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, for(j = strlen(out); j < maxcols-64; j++) { printf(" "); } - fputs("] 100% LOCAL ", stdout); + fputs(_("] 100% LOCAL "), stdout); } else { log_progress(control, fsz-offset, &fsz); } @@ -560,7 +561,7 @@ char *fetch_pkgurl(char *target) /* do not download the file if it exists in the current dir */ if(stat(fn, &buf) == 0) { - vprint(" %s is already in the current directory\n", fn); + vprint(_(" %s is already in the current directory\n"), fn); } else { server_t *server; list_t *servers = NULL; @@ -574,7 +575,7 @@ char *fetch_pkgurl(char *target) files = list_add(NULL, fn); if(downloadfiles(servers, ".", files)) { - ERR(NL, "failed to download %s\n", target); + ERR(NL, _("failed to download %s\n"), target); return(NULL); } FREELISTPTR(files); diff --git a/src/pacman/list.c b/src/pacman/list.c index a7e9ce13..0a080373 100644 --- a/src/pacman/list.c +++ b/src/pacman/list.c @@ -23,7 +23,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <libintl.h> /* pacman */ +#include "util.h" #include "list.h" extern int maxcols; @@ -138,7 +140,7 @@ void list_display(const char *title, list_t *list) } printf("\n"); } else { - printf("None\n"); + printf(_("None\n")); } } @@ -166,7 +168,7 @@ void PM_LIST_display(const char *title, PM_LIST *list) } printf("\n"); } else { - printf("None\n"); + printf(_("None\n")); } } diff --git a/src/pacman/log.c b/src/pacman/log.c index f989a79c..35cef028 100644 --- a/src/pacman/log.c +++ b/src/pacman/log.c @@ -24,6 +24,7 @@ #include <string.h> #include <stdarg.h> #include <ctype.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -46,25 +47,25 @@ void cb_log(unsigned short level, char *msg) switch(level) { case PM_LOG_DEBUG: - sprintf(str, "debug"); + sprintf(str, _("debug")); break; case PM_LOG_ERROR: - sprintf(str, "error"); + sprintf(str, _("error")); break; case PM_LOG_WARNING: - sprintf(str, "warning"); + sprintf(str, _("warning")); break; case PM_LOG_FLOW1: - sprintf(str, "flow1"); + sprintf(str, _("flow1")); break; case PM_LOG_FLOW2: - sprintf(str, "flow2"); + sprintf(str, _("flow2")); break; case PM_LOG_FUNCTION: - sprintf(str, "function"); + sprintf(str, _("function")); break; default: - sprintf(str, "???"); + sprintf(str, _("???")); break; } @@ -147,7 +148,7 @@ int yesno(char *fmt, ...) *++pch = 0; strtrim(response); - if(!strcasecmp(response, "Y") || !strcasecmp(response, "YES") || !strlen(response)) { + if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || !strlen(response)) { return(1); } } diff --git a/src/pacman/package.c b/src/pacman/package.c index 3e2956c8..72cf3c83 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -24,6 +24,7 @@ #include <string.h> #include <limits.h> #include <sys/stat.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -42,43 +43,43 @@ void dump_pkg_full(PM_PKG *pkg, int level) return; } - printf("Name : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME)); - printf("Version : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); + printf(_("Name : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME)); + printf(_("Version : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); - PM_LIST_display("Groups :", alpm_pkg_getinfo(pkg, PM_PKG_GROUPS)); + PM_LIST_display(_("Groups :"), alpm_pkg_getinfo(pkg, PM_PKG_GROUPS)); - printf("Packager : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_PACKAGER)); - printf("URL : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_URL)); - PM_LIST_display("License :", alpm_pkg_getinfo(pkg, PM_PKG_LICENSE)); - printf("Architecture : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_ARCH)); - printf("Size : %ld\n", (long int)alpm_pkg_getinfo(pkg, PM_PKG_SIZE)); + printf(_("Packager : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_PACKAGER)); + printf(_("URL : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_URL)); + PM_LIST_display(_("License :"), alpm_pkg_getinfo(pkg, PM_PKG_LICENSE)); + printf(_("Architecture : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_ARCH)); + printf(_("Size : %ld\n"), (long int)alpm_pkg_getinfo(pkg, PM_PKG_SIZE)); date = alpm_pkg_getinfo(pkg, PM_PKG_BUILDDATE); - printf("Build Date : %s %s\n", date, strlen(date) ? "UTC" : ""); + printf(_("Build Date : %s %s\n"), date, strlen(date) ? "UTC" : ""); date = alpm_pkg_getinfo(pkg, PM_PKG_INSTALLDATE); - printf("Install Date : %s %s\n", date, strlen(date) ? "UTC" : ""); + printf(_("Install Date : %s %s\n"), date, strlen(date) ? "UTC" : ""); - printf("Install Script : %s\n", alpm_pkg_getinfo(pkg, PM_PKG_SCRIPLET) ? "Yes" : "No"); + printf(_("Install Script : %s\n"), alpm_pkg_getinfo(pkg, PM_PKG_SCRIPLET) ? "Yes" : "No"); - printf("Reason: : "); + printf(_("Reason: : ")); switch((int)alpm_pkg_getinfo(pkg, PM_PKG_REASON)) { case PM_PKG_REASON_EXPLICIT: - printf("Explicitly installed\n"); + printf(_("Explicitly installed\n")); break; case PM_PKG_REASON_DEPEND: - printf("Installed as a dependency for another package\n"); + printf(_("Installed as a dependency for another package\n")); break; default: - printf("Unknown\n"); + printf(_("Unknown\n")); break; } - PM_LIST_display("Provides :", alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES)); - PM_LIST_display("Depends On :", alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS)); - PM_LIST_display("Required By :", alpm_pkg_getinfo(pkg, PM_PKG_REQUIREDBY)); - PM_LIST_display("Conflicts With :", alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS)); + PM_LIST_display(_("Provides :"), alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES)); + PM_LIST_display(_("Depends On :"), alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS)); + PM_LIST_display(_("Required By :"), alpm_pkg_getinfo(pkg, PM_PKG_REQUIREDBY)); + PM_LIST_display(_("Conflicts With :"), alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS)); - printf("Description : "); + printf(_("Description : ")); indentprint(alpm_pkg_getinfo(pkg, PM_PKG_DESC), 17); printf("\n"); @@ -102,14 +103,14 @@ void dump_pkg_full(PM_PKG *pkg, int level) if(!stat(path, &buf)) { char *md5sum = alpm_get_md5sum(path); if(md5sum == NULL) { - ERR(NL, "error calculating md5sum for %s\n", path); + ERR(NL, _("error calculating md5sum for %s\n"), path); FREE(str); continue; } - printf("%sMODIFIED\t%s\n", strcmp(md5sum, ptr) ? "" : "NOT ", path); + printf(_("%sMODIFIED\t%s\n"), strcmp(md5sum, ptr) ? "" : "NOT ", path); FREE(md5sum); } else { - printf("MISSING\t\t%s\n", path); + printf(_("MISSING\t\t%s\n"), path); } FREE(str); } @@ -127,20 +128,20 @@ void dump_pkg_sync(PM_PKG *pkg, char *treename) return; } - printf("Repository : %s\n", treename); - printf("Name : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME)); - printf("Version : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); + printf(_("Repository : %s\n"), treename); + printf(_("Name : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME)); + printf(_("Version : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); - PM_LIST_display("Groups :", alpm_pkg_getinfo(pkg, PM_PKG_GROUPS)); - PM_LIST_display("Provides :", alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES)); - PM_LIST_display("Depends On :", alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS)); - PM_LIST_display("Conflicts With :", alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS)); - PM_LIST_display("Replaces :", alpm_pkg_getinfo(pkg, PM_PKG_REPLACES)); + PM_LIST_display(_("Groups :"), alpm_pkg_getinfo(pkg, PM_PKG_GROUPS)); + PM_LIST_display(_("Provides :"), alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES)); + PM_LIST_display(_("Depends On :"), alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS)); + PM_LIST_display(_("Conflicts With :"), alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS)); + PM_LIST_display(_("Replaces :"), alpm_pkg_getinfo(pkg, PM_PKG_REPLACES)); - printf("Size (compressed) : %ld\n", (long)alpm_pkg_getinfo(pkg, PM_PKG_SIZE)); - printf("Description : "); + printf(_("Size (compressed) : %ld\n"), (long)alpm_pkg_getinfo(pkg, PM_PKG_SIZE)); + printf(_("Description : ")); indentprint(alpm_pkg_getinfo(pkg, PM_PKG_DESC), 20); - printf("\nMD5 Sum : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_MD5SUM)); + printf(_("\nMD5 Sum : %s\n"), (char *)alpm_pkg_getinfo(pkg, PM_PKG_MD5SUM)); } void dump_pkg_files(PM_PKG *pkg) @@ -152,7 +153,7 @@ void dump_pkg_files(PM_PKG *pkg) pkgfiles = alpm_pkg_getinfo(pkg, PM_PKG_FILES); for(i = pkgfiles; i; i = alpm_list_next(i)) { - fprintf(stdout, "%s %s\n", (char *)pkgname, (char *)alpm_list_getdata(i)); + fprintf(stdout, _("%s %s\n"), (char *)pkgname, (char *)alpm_list_getdata(i)); } fflush(stdout); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index a2ff2604..3678f628 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -27,6 +27,7 @@ #include <string.h> #include <signal.h> #include <unistd.h> +#include <libintl.h> #ifndef CYGWIN #include <mcheck.h> /* debug */ #else @@ -77,12 +78,12 @@ extern int neednl; */ static void version() { - printf("\n"); - printf(" .--. Pacman v%s - libalpm v%s\n", PACKAGE_VERSION, PM_VERSION); - printf("/ _.-' .-. .-. .-. Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>\n"); - printf("\\ '-. '-' '-' '-' \n"); - printf(" '--' This program may be freely redistributed under\n"); - printf(" the terms of the GNU General Public License\n"); + printf(_("\n")); + printf(_(" .--. Pacman v%s - libalpm v%s\n"), PACKAGE_VERSION, PM_VERSION); + printf(_("/ _.-' .-. .-. .-. Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>\n")); + printf(_("\\ '-. '-' '-' '-' \n")); + printf(_(" '--' This program may be freely redistributed under\n")); + printf(_(" the terms of the GNU General Public License\n")); printf("\n"); } @@ -93,72 +94,72 @@ static void version() static void usage(int op, char *myname) { if(op == PM_OP_MAIN) { - printf("usage: %s {-h --help}\n", myname); - printf(" %s {-V --version}\n", myname); - printf(" %s {-A --add} [options] <file>\n", myname); - printf(" %s {-R --remove} [options] <package>\n", myname); - printf(" %s {-U --upgrade} [options] <file>\n", myname); - printf(" %s {-F --freshen} [options] <file>\n", myname); - printf(" %s {-Q --query} [options] [package]\n", myname); - printf(" %s {-S --sync} [options] [package]\n", myname); - printf("\nuse '%s --help' with other options for more syntax\n", myname); + printf(_("usage: %s {-h --help}\n"), myname); + printf(_(" %s {-V --version}\n"), myname); + printf(_(" %s {-A --add} [options] <file>\n"), myname); + printf(_(" %s {-R --remove} [options] <package>\n"), myname); + printf(_(" %s {-U --upgrade} [options] <file>\n"), myname); + printf(_(" %s {-F --freshen} [options] <file>\n"), myname); + printf(_(" %s {-Q --query} [options] [package]\n"), myname); + printf(_(" %s {-S --sync} [options] [package]\n"), myname); + printf(_("\nuse '%s --help' with other options for more syntax\n"), myname); } else { if(op == PM_OP_ADD) { - printf("usage: %s {-A --add} [options] <file>\n", myname); - printf("options:\n"); - printf(" -d, --nodeps skip dependency checks\n"); - printf(" -f, --force force install, overwrite conflicting files\n"); + printf(_("usage: %s {-A --add} [options] <file>\n"), myname); + printf(_("options:\n")); + printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -f, --force force install, overwrite conflicting files\n")); } else if(op == PM_OP_REMOVE) { - printf("usage: %s {-R --remove} [options] <package>\n", myname); - printf("options:\n"); - printf(" -c, --cascade remove packages and all packages that depend on them\n"); - printf(" -d, --nodeps skip dependency checks\n"); - printf(" -k, --dbonly only remove database entry, do not remove files\n"); - printf(" -n, --nosave remove configuration files as well\n"); - printf(" -s, --recursive remove dependencies also (that won't break packages)\n"); + printf(_("usage: %s {-R --remove} [options] <package>\n"), myname); + printf(_("options:\n")); + printf(_(" -c, --cascade remove packages and all packages that depend on them\n")); + printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -k, --dbonly only remove database entry, do not remove files\n")); + printf(_(" -n, --nosave remove configuration files as well\n")); + printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n")); } else if(op == PM_OP_UPGRADE) { if(config->flags & PM_TRANS_FLAG_FRESHEN) { - printf("usage: %s {-F --freshen} [options] <file>\n", myname); + printf(_("usage: %s {-F --freshen} [options] <file>\n"), myname); } else { - printf("usage: %s {-U --upgrade} [options] <file>\n", myname); + printf(_("usage: %s {-U --upgrade} [options] <file>\n"), myname); } - printf("options:\n"); - printf(" -d, --nodeps skip dependency checks\n"); - printf(" -f, --force force install, overwrite conflicting files\n"); + printf(_("options:\n")); + printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -f, --force force install, overwrite conflicting files\n")); } else if(op == PM_OP_QUERY) { - printf("usage: %s {-Q --query} [options] [package]\n", myname); - printf("options:\n"); - printf(" -e, --orphans list all packages that were explicitly installed\n"); - printf(" and are not required by any other packages\n"); - printf(" -g, --groups view all members of a package group\n"); - printf(" -i, --info view package information\n"); - printf(" -l, --list list the contents of the queried package\n"); - printf(" -m, --foreign list all packages that were not found in the sync repos\n"); - printf(" -o, --owns <file> query the package that owns <file>\n"); - printf(" -p, --file pacman will query the package file [package] instead of\n"); - printf(" looking in the database\n"); - printf(" -s, --search search locally-installed packages for matching strings\n"); + printf(_("usage: %s {-Q --query} [options] [package]\n"), myname); + printf(_("options:\n")); + printf(_(" -e, --orphans list all packages that were explicitly installed\n")); + printf(_(" and are not required by any other packages\n")); + printf(_(" -g, --groups view all members of a package group\n")); + printf(_(" -i, --info view package information\n")); + printf(_(" -l, --list list the contents of the queried package\n")); + printf(_(" -m, --foreign list all packages that were not found in the sync repos\n")); + printf(_(" -o, --owns <file> query the package that owns <file>\n")); + printf(_(" -p, --file pacman will query the package file [package] instead of\n")); + printf(_(" looking in the database\n")); + printf(_(" -s, --search search locally-installed packages for matching strings\n")); } else if(op == PM_OP_SYNC) { - printf("usage: %s {-S --sync} [options] [package]\n", myname); - printf("options:\n"); - printf(" -c, --clean remove old packages from cache directory (use -cc for all)\n"); - printf(" -d, --nodeps skip dependency checks\n"); - printf(" -f, --force force install, overwrite conflicting files\n"); - printf(" -g, --groups view all members of a package group\n"); - printf(" -p, --print-uris print out URIs for given packages and their dependencies\n"); - printf(" -s, --search search remote repositories for matching strings\n"); - printf(" -u, --sysupgrade upgrade all packages that are out of date\n"); - printf(" -w, --downloadonly download packages but do not install/upgrade anything\n"); - printf(" -y, --refresh download fresh package databases from the server\n"); - printf(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"); + printf(_("usage: %s {-S --sync} [options] [package]\n"), myname); + printf(_("options:\n")); + printf(_(" -c, --clean remove old packages from cache directory (use -cc for all)\n")); + printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -f, --force force install, overwrite conflicting files\n")); + printf(_(" -g, --groups view all members of a package group\n")); + printf(_(" -p, --print-uris print out URIs for given packages and their dependencies\n")); + printf(_(" -s, --search search remote repositories for matching strings\n")); + printf(_(" -u, --sysupgrade upgrade all packages that are out of date\n")); + printf(_(" -w, --downloadonly download packages but do not install/upgrade anything\n")); + printf(_(" -y, --refresh download fresh package databases from the server\n")); + printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); } - printf(" --config <path> set an alternate configuration file\n"); - printf(" --noconfirm do not ask for anything confirmation\n"); - printf(" --noprogressbar do not show a progress bar when downloading files\n"); - printf(" --noscriptlet do not execute the install scriptlet if there is any\n"); - printf(" -v, --verbose be verbose\n"); - printf(" -r, --root <path> set an alternate installation root\n"); - printf(" -b, --dbpath <path> set an alternate database location\n"); + printf(_(" --config <path> set an alternate configuration file\n")); + printf(_(" --noconfirm do not ask for anything confirmation\n")); + printf(_(" --noprogressbar do not show a progress bar when downloading files\n")); + printf(_(" --noscriptlet do not execute the install scriptlet if there is any\n")); + printf(_(" -v, --verbose be verbose\n")); + printf(_(" -r, --root <path> set an alternate installation root\n")); + printf(_(" -b, --dbpath <path> set an alternate database location\n")); } } @@ -284,7 +285,7 @@ static int parseargs(int argc, char *argv[]) break; case 'r': if(realpath(optarg, root) == NULL) { - perror("bad root path"); + perror(_("bad root path")); return(1); } if(config->root) { @@ -310,7 +311,7 @@ static int parseargs(int argc, char *argv[]) } if(config->op == 0) { - ERR(NL, "only one operation may be used at a time\n"); + ERR(NL, _("only one operation may be used at a time\n")); return(1); } @@ -342,7 +343,7 @@ static void cleanup(int signum) /* free alpm library resources */ if(alpm_release() == -1) { - ERR(NL, "%s\n", alpm_strerror(pm_errno)); + ERR(NL, _("%s\n"), alpm_strerror(pm_errno)); } /* free memory */ @@ -432,7 +433,7 @@ int main(int argc, char *argv[]) config->op_q_info)) || (config->op == PM_OP_DEPTEST && !config->op_d_resolve)) { /* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */ } else { - ERR(NL, "you cannot perform this operation unless you are root.\n"); + ERR(NL, _("you cannot perform this operation unless you are root.\n")); config_free(config); exit(1); } @@ -456,7 +457,7 @@ int main(int argc, char *argv[]) /* initialize pm library */ if(alpm_initialize(config->root) == -1) { - ERR(NL, "failed to initilize alpm library (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to initilize alpm library (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } @@ -469,11 +470,11 @@ int main(int argc, char *argv[]) /* set library parameters */ if(alpm_set_option(PM_OPT_LOGMASK, (long)config->debug) == -1) { - ERR(NL, "failed to set option LOGMASK (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option LOGMASK (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } if(alpm_set_option(PM_OPT_LOGCB, (long)cb_log) == -1) { - ERR(NL, "failed to set option LOGCB (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option LOGCB (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } if(config->dbpath == NULL) { @@ -481,39 +482,39 @@ int main(int argc, char *argv[]) } else { /* dbpath has been set by parseargs or parseconfig */ if(alpm_set_option(PM_OPT_DBPATH, (long)config->dbpath) == -1) { - ERR(NL, "failed to set option DBPATH (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option DBPATH (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } } if(alpm_set_option(PM_OPT_CACHEDIR, (long)config->cachedir) == -1) { - ERR(NL, "failed to set option CACHEDIR (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option CACHEDIR (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } for(lp = config->op_s_ignore; lp; lp = lp->next) { if(alpm_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) { - ERR(NL, "failed to set option IGNOREPKG (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option IGNOREPKG (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } } if(config->verbose > 0) { - printf("Root : %s\n", config->root); - printf("DBPath: %s\n", config->dbpath); - list_display("Targets:", pm_targets); + printf(_("Root : %s\n"), config->root); + printf(_("DBPath: %s\n"), config->dbpath); + list_display(_("Targets:"), pm_targets); } /* Opening local database */ db_local = alpm_db_register("local"); if(db_local == NULL) { - ERR(NL, "could not register 'local' database (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("could not register 'local' database (%s)\n"), alpm_strerror(pm_errno)); cleanup(1); } if(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"); + ERR(NL, _("no targets specified (use -h for help)\n")); cleanup(1); } @@ -526,7 +527,7 @@ int main(int argc, char *argv[]) case PM_OP_SYNC: ret = pacman_sync(pm_targets); break; case PM_OP_DEPTEST: ret = pacman_deptest(pm_targets); break; default: - ERR(NL, "no operation specified (use -h for help)\n"); + ERR(NL, _("no operation specified (use -h for help)\n")); ret = 1; } diff --git a/src/pacman/query.c b/src/pacman/query.c index 3981eedf..233e61e7 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -24,6 +24,7 @@ #include <limits.h> #include <string.h> #include <sys/stat.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -52,12 +53,12 @@ static int query_fileowner(PM_DB *db, char *filename) return(0); } if(filename == NULL || strlen(filename) == 0) { - ERR(NL, "no file was specified for --owns\n"); + ERR(NL, _("no file was specified for --owns\n")); return(1); } if(stat(filename, &buf) == -1 || S_ISDIR(buf.st_mode) || realpath(filename, rpath) == NULL) { - ERR(NL, "%s is not a file.\n", filename); + ERR(NL, _("%s is not a file.\n"), filename); return(1); } @@ -74,7 +75,7 @@ static int query_fileowner(PM_DB *db, char *filename) snprintf(path, PATH_MAX, "%s%s", root, (char *)alpm_list_getdata(i)); if(!strcmp(path, rpath)) { - printf("%s is owned by %s %s\n", filename, (char *)alpm_pkg_getinfo(info, PM_PKG_NAME), + printf(_("%s is owned by %s %s\n"), filename, (char *)alpm_pkg_getinfo(info, PM_PKG_NAME), (char *)alpm_pkg_getinfo(info, PM_PKG_VERSION)); gotcha = 1; break; @@ -82,7 +83,7 @@ static int query_fileowner(PM_DB *db, char *filename) } } if(!gotcha) { - ERR(NL, "No package owns %s\n", filename); + ERR(NL, _("No package owns %s\n"), filename); return(1); } @@ -107,7 +108,7 @@ int pacman_query(list_t *targets) if(config->op_q_foreign) { if(pmc_syncs == NULL || !list_count(pmc_syncs)) { - ERR(NL, "no usable package repositories configured.\n"); + ERR(NL, _("no usable package repositories configured.\n")); return(1); } @@ -156,7 +157,7 @@ int pacman_query(list_t *targets) MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(i)); } } else { - ERR(NL, "group \"%s\" was not found\n", package); + ERR(NL, _("group \"%s\" was not found\n"), package); return(2); } } @@ -166,11 +167,11 @@ int pacman_query(list_t *targets) /* output info for a .tar.gz package */ if(config->op_q_isfile) { if(package == NULL) { - ERR(NL, "no package file was specified for --file\n"); + ERR(NL, _("no package file was specified for --file\n")); return(1); } if(alpm_pkg_load(package, &info) == -1) { - ERR(NL, "failed to load package '%s' (%s)\n", package, alpm_strerror(pm_errno)); + ERR(NL, _("failed to load package '%s' (%s)\n"), package, alpm_strerror(pm_errno)); return(1); } if(config->op_q_info) { @@ -208,7 +209,7 @@ int pacman_query(list_t *targets) info = alpm_db_readpkg(db_local, pkgname); if(info == NULL) { /* something weird happened */ - ERR(NL, "package \"%s\" not found\n", pkgname); + ERR(NL, _("package \"%s\" not found\n"), pkgname); return(1); } if(config->op_q_foreign) { @@ -252,7 +253,7 @@ int pacman_query(list_t *targets) info = alpm_db_readpkg(db_local, package); if(info == NULL) { - ERR(NL, "package \"%s\" not found\n", package); + ERR(NL, _("package \"%s\" not found\n"), package); return(2); } diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 5c8568ca..2092ccf0 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -60,11 +61,11 @@ int pacman_remove(list_t *targets) pkgnames = alpm_grp_getinfo(grp, PM_GRP_PKGNAMES); - MSG(NL, ":: group %s:\n", alpm_grp_getinfo(grp, PM_GRP_NAME)); + MSG(NL, _(":: group %s:\n"), alpm_grp_getinfo(grp, PM_GRP_NAME)); PM_LIST_display(" ", pkgnames); - all = yesno(" Remove whole content? [Y/n] "); + 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)) { + 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))); } } @@ -77,10 +78,10 @@ int pacman_remove(list_t *targets) /* Step 1: create a new transaction */ if(alpm_trans_init(PM_TRANS_TYPE_REMOVE, config->flags, cb_trans_evt, cb_trans_conv) == -1) { - ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to init transaction (%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\n", PM_LOCK); + MSG(NL, _(" if you're sure a package manager is not already running,\n" + " you can remove %s\n"), PM_LOCK); } FREELIST(finaltargs); return(1); @@ -90,12 +91,12 @@ int pacman_remove(list_t *targets) /* check if the package is in the HoldPkg list. If so, ask * confirmation first */ if(list_is_strin(i->data, config->holdpkg)) { - if(!yesno(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] ", i->data)) { + if(!yesno(_(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "), i->data)) { return(1); } } if(alpm_trans_addtarget(i->data) == -1) { - ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno)); + ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -105,12 +106,12 @@ int pacman_remove(list_t *targets) */ if(alpm_trans_prepare(&data) == -1) { PM_LIST *lp; - ERR(NL, "failed to prepare transaction (%s)\n", alpm_strerror(pm_errno)); + 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)) { PM_DEPMISS *miss = alpm_list_getdata(lp); - MSG(NL, " %s: is required by %s\n", alpm_dep_getinfo(miss, PM_DEP_TARGET), + MSG(NL, _(" %s: is required by %s\n"), alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME)); } alpm_list_free(data); @@ -132,10 +133,10 @@ int pacman_remove(list_t *targets) PM_PKG *pkg = alpm_list_getdata(lp); i = list_add(i, strdup(alpm_pkg_getinfo(pkg, PM_PKG_NAME))); } - list_display("\nTargets:", i); + list_display(_("\nTargets:"), i); FREELIST(i); /* get confirmation */ - if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) { + if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) { retval = 1; goto cleanup; } @@ -145,7 +146,7 @@ int pacman_remove(list_t *targets) /* Step 3: actually perform the removal */ if(alpm_trans_commit(NULL) == -1) { - ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -156,7 +157,7 @@ cleanup: FREELIST(finaltargs); if(alpm_trans_release() == -1) { - ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index fc1ccfe3..c25ef17f 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -26,6 +26,7 @@ #include <sys/stat.h> #include <unistd.h> #include <dirent.h> +#include <libintl.h> #ifdef CYGWIN #include <limits.h> /* PATH_MAX */ #endif @@ -64,10 +65,10 @@ static int sync_cleancache(int level) list_t *clean = NULL; list_t *i, *j; - MSG(NL, "removing old packages from cache... "); + MSG(NL, _("removing old packages from cache... ")); dir = opendir(dirpath); if(dir == NULL) { - ERR(NL, "could not access cache directory\n"); + ERR(NL, _("could not access cache directory\n")); return(1); } rewinddir(dir); @@ -127,20 +128,20 @@ static int sync_cleancache(int level) FREELIST(clean); } else { /* full cleanup */ - MSG(NL, "removing all packages from cache... "); + MSG(NL, _("removing all packages from cache... ")); if(rmrf(dirpath)) { - ERR(NL, "could not remove cache directory\n"); + ERR(NL, _("could not remove cache directory\n")); return(1); } if(makepath(dirpath)) { - ERR(NL, "could not create new cache directory\n"); + ERR(NL, _("could not create new cache directory\n")); return(1); } } - MSG(CL, "done.\n"); + MSG(CL, _("done.\n")); return(0); } @@ -164,7 +165,7 @@ static int sync_synctree(int level, list_t *syncs) /* get the lastupdate time */ db_getlastupdate(sync->db, lastupdate); if(strlen(lastupdate) == 0) { - vprint("failed to get lastupdate time for %s (no big deal)\n", sync->treename); + vprint(_("failed to get lastupdate time for %s (no big deal)\n"), sync->treename); } } @@ -177,18 +178,18 @@ static int sync_synctree(int level, list_t *syncs) ret = downloadfiles_forreal(sync->servers, path, files, lastupdate, newmtime); FREELIST(files); if(ret > 0) { - ERR(NL, "failed to synchronize %s\n", sync->treename); + ERR(NL, _("failed to synchronize %s\n"), sync->treename); success--; } else if(ret < 0) { - MSG(NL, " %s is up to date\n", sync->treename); + MSG(NL, _(" %s is up to date\n"), sync->treename); } else { if(strlen(newmtime)) { - vprint("sync: new mtime for %s: %s\n", sync->treename, newmtime); + vprint(_("sync: new mtime for %s: %s\n"), sync->treename, newmtime); db_setlastupdate(sync->db, newmtime); } snprintf(path, PATH_MAX, "%s%s/%s" PM_EXT_DB, root, dbpath, sync->treename); if(alpm_db_update(sync->db, path) == -1) { - ERR(NL, "failed to update %s (%s)\n", sync->treename, alpm_strerror(pm_errno)); + ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno)); } /* remove the .tar.gz */ unlink(path); @@ -214,7 +215,7 @@ static int sync_search(list_t *syncs, list_t *targets) for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) { PM_PKG *pkg = alpm_list_getdata(lp); - MSG(NL, "%s/%s %s\n ", sync->treename, (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME), (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); + MSG(NL, _("%s/%s %s\n "), sync->treename, (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME), (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION)); indentprint(alpm_pkg_getinfo(pkg, PM_PKG_DESC), 4); MSG(NL, "\n"); } @@ -282,7 +283,7 @@ static int sync_info(list_t *syncs, list_t *targets) } } if(!found) { - ERR(NL, "package \"%s\" was not found.\n", (char *)i->data); + ERR(NL, _("package \"%s\" was not found.\n"), (char *)i->data); break; } } @@ -320,7 +321,7 @@ static int sync_list(list_t *syncs, list_t *targets) } if(sync == NULL) { - ERR(NL, "repository \"%s\" was not found.\n", (char *)i->data); + ERR(NL, _("repository \"%s\" was not found.\n"), (char *)i->data); FREELISTPTR(ls); return(1); } @@ -361,7 +362,7 @@ int pacman_sync(list_t *targets) list_t *files = NULL; if(pmc_syncs == NULL || !list_count(pmc_syncs)) { - ERR(NL, "no usable package repositories configured.\n"); + ERR(NL, _("no usable package repositories configured.\n")); return(1); } @@ -381,8 +382,8 @@ int pacman_sync(list_t *targets) if(config->op_s_sync) { /* grab a fresh package list */ - MSG(NL, ":: Synchronizing package databases...\n"); - alpm_logaction("synchronizing package lists"); + MSG(NL, _(":: Synchronizing package databases...\n")); + alpm_logaction(_("synchronizing package lists")); if(sync_synctree(config->op_s_sync, pmc_syncs)) { return(1); } @@ -407,17 +408,17 @@ int pacman_sync(list_t *targets) /* Step 1: create a new transaction... */ if(alpm_trans_init(PM_TRANS_TYPE_SYNC, config->flags, cb_trans_evt, cb_trans_conv) == -1) { - ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to init transaction (%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\n", PM_LOCK); + MSG(NL, _(" if you're sure a package manager is not already running,\n" + " you can remove %s\n"), PM_LOCK); } return(1); } if(config->op_s_upgrade) { - MSG(NL, ":: Starting local database upgrade...\n"); - alpm_logaction("starting full system upgrade"); + MSG(NL, _(":: Starting local database upgrade...\n")); + alpm_logaction(_("starting full system upgrade")); if(alpm_trans_sysupgrade() == -1) { ERR(NL, "%s\n", alpm_strerror(pm_errno)); retval = 1; @@ -435,26 +436,26 @@ int pacman_sync(list_t *targets) PM_SYNCPKG *sync = alpm_list_getdata(lp); PM_PKG *spkg = alpm_sync_getinfo(sync, PM_SYNC_PKG); if(!strcmp("pacman", alpm_pkg_getinfo(spkg, PM_PKG_NAME)) && 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"); - MSG(NL, "::\n"); - if(yesno(":: Upgrade pacman first? [Y/n] ")) { + 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")); + MSG(NL, _("::\n")); + if(yesno(_(":: Upgrade pacman first? [Y/n] "))) { if(alpm_trans_release() == -1) { - ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } if(alpm_trans_init(PM_TRANS_TYPE_SYNC, config->flags, cb_trans_evt, cb_trans_conv) == -1) { - ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to init transaction (%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\n", PM_LOCK); + MSG(NL, _(" if you're sure a package manager is not already running,\n" + " you can remove %s\n"), PM_LOCK); } return(1); } if(alpm_trans_addtarget("pacman") == -1) { - ERR(NL, "could not add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno)); + ERR(NL, _("could not add target '%s': %s\n"), (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -474,7 +475,7 @@ int pacman_sync(list_t *targets) continue; } if(pm_errno != PM_ERR_PKG_NOT_FOUND) { - ERR(NL, "could not add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno)); + ERR(NL, _("could not add target '%s': %s\n"), (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -485,20 +486,20 @@ int pacman_sync(list_t *targets) if(grp) { PM_LIST *pmpkgs; list_t *k, *pkgs; - MSG(NL, ":: group %s:\n", targ); + MSG(NL, _(":: group %s:\n"), targ); pmpkgs = alpm_grp_getinfo(grp, PM_GRP_PKGNAMES); /* remove dupe entries in case a package exists in multiple repos */ /* (the dupe function takes a PM_LIST* and returns a list_t*) */ pkgs = PM_LIST_remove_dupes(pmpkgs); list_display(" ", pkgs); - if(yesno(":: Install whole content? [Y/n] ")) { + if(yesno(_(":: Install whole content? [Y/n] "))) { for(k = pkgs; k; k = k->next) { targets = list_add(targets, strdup(k->data)); } } else { for(k = pkgs; k; k = k->next) { char *pkgname = k->data; - if(yesno(":: Install %s from group %s? [Y/n] ", pkgname, targ)) { + if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) { targets = list_add(targets, strdup(pkgname)); } } @@ -518,13 +519,13 @@ int pacman_sync(list_t *targets) /* Step 2: "compute" the transaction based on targets and flags */ if(alpm_trans_prepare(&data) == -1) { - ERR(NL, "failed to prepare transaction (%s)\n", alpm_strerror(pm_errno)); + 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)) { PM_DEPMISS *miss = alpm_list_getdata(lp); - MSG(NL, ":: %s: %s %s", alpm_dep_getinfo(miss, PM_DEP_TARGET), - (int)alpm_dep_getinfo(miss, PM_DEP_TYPE) == PM_DEP_TYPE_DEPEND ? "requires" : "is required by", + MSG(NL, _(":: %s: %s %s"), alpm_dep_getinfo(miss, PM_DEP_TARGET), + (int)alpm_dep_getinfo(miss, PM_DEP_TYPE) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"), alpm_dep_getinfo(miss, PM_DEP_NAME)); switch((int)alpm_dep_getinfo(miss, PM_DEP_MOD)) { case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_getinfo(miss, PM_DEP_VERSION)); break; @@ -589,7 +590,7 @@ int pacman_sync(list_t *targets) list_install = list_add(list_install, str); } if(list_remove) { - MSG(NL, "\nRemove: "); + MSG(NL, _("\nRemove: ")); str = buildstring(list_remove); indentprint(str, 9); MSG(CL, "\n"); @@ -601,20 +602,20 @@ int pacman_sync(list_t *targets) if(mb < 0.1) { mb = 0.1; } - MSG(NL, "\nTargets: "); + MSG(NL, _("\nTargets: ")); str = buildstring(list_install); indentprint(str, 9); - MSG(NL, "\nTotal Package Size: %.1f MB\n", mb); + MSG(NL, _("\nTotal Package Size: %.1f MB\n"), mb); FREELIST(list_install); FREE(str); if(config->op_s_downloadonly) { if(config->noconfirm) { - MSG(NL, "\nBeginning download...\n"); + MSG(NL, _("\nBeginning download...\n")); confirm = 1; } else { MSG(NL, "\n"); - confirm = yesno("Proceed with download? [Y/n] "); + confirm = yesno(_("Proceed with download? [Y/n] ")); } } else { /* don't get any confirmation if we're called from makepkg */ @@ -622,11 +623,11 @@ int pacman_sync(list_t *targets) confirm = 1; } else { if(config->noconfirm) { - MSG(NL, "\nBeginning upgrade process...\n"); + MSG(NL, _("\nBeginning upgrade process...\n")); confirm = 1; } else { MSG(NL, "\n"); - confirm = yesno("Proceed with upgrade? [Y/n] "); + confirm = yesno(_("Proceed with upgrade? [Y/n] ")); } } } @@ -672,7 +673,7 @@ int pacman_sync(list_t *targets) snprintf(path, PATH_MAX, "%s-%s" PM_EXT_PKG, pkgname, pkgver); files = list_add(files, strdup(path)); } else { - vprint(" %s-%s" PM_EXT_PKG " is already in the cache\n", pkgname, pkgver); + vprint(_(" %s-%s" PM_EXT_PKG " is already in the cache\n"), pkgname, pkgver); } } } @@ -680,28 +681,28 @@ int pacman_sync(list_t *targets) if(files) { struct stat buf; - MSG(NL, "\n:: Retrieving packages from %s...\n", current->treename); + MSG(NL, _("\n:: Retrieving packages from %s...\n"), current->treename); fflush(stdout); if(stat(ldir, &buf)) { /* no cache directory.... try creating it */ - WARN(NL, "no %s cache exists. creating...\n", ldir); - alpm_logaction("warning: no %s cache exists. creating...", ldir); + WARN(NL, _("no %s cache exists. creating...\n"), ldir); + alpm_logaction(_("warning: no %s cache exists. creating..."), ldir); if(makepath(ldir)) { /* couldn't mkdir the cache directory, so fall back to /tmp and unlink * the package afterwards. */ - WARN(NL, "couldn't create package cache, using /tmp instead"); - alpm_logaction("warning: couldn't create package cache, using /tmp instead"); + WARN(NL, _("couldn't create package cache, using /tmp instead")); + alpm_logaction(_("warning: couldn't create package cache, using /tmp instead")); snprintf(ldir, PATH_MAX, "/tmp"); if(alpm_set_option(PM_OPT_CACHEDIR, (long)ldir) == -1) { - ERR(NL, "failed to set option CACHEDIR (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to set option CACHEDIR (%s)\n"), alpm_strerror(pm_errno)); goto cleanup; } varcache = 0; } } if(downloadfiles(current->servers, ldir, files)) { - ERR(NL, "failed to retrieve some files from %s\n", current->treename); + ERR(NL, _("failed to retrieve some files from %s\n"), current->treename); retval = 1; goto cleanup; } @@ -714,16 +715,16 @@ int pacman_sync(list_t *targets) MSG(NL, "\n"); /* Check integrity of files */ - MSG(NL, "checking package integrity... "); + MSG(NL, _("checking package integrity... ")); for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) { PM_SYNCPKG *sync = alpm_list_getdata(lp); PM_PKG *spkg = alpm_sync_getinfo(sync, PM_SYNC_PKG); if(alpm_pkg_checkmd5sum(spkg) == -1) { if(pm_errno == PM_ERR_PKG_INVALID) { - ERR(NL, "archive %s is corrupted\n", alpm_pkg_getinfo(spkg, PM_PKG_NAME)); + ERR(NL, _("archive %s is corrupted\n"), alpm_pkg_getinfo(spkg, PM_PKG_NAME)); } else { - ERR(NL, "could not get checksum for package %s (%s)\n", + ERR(NL, _("could not get checksum for package %s (%s)\n"), alpm_pkg_getinfo(spkg, PM_PKG_NAME), alpm_strerror(pm_errno)); } retval = 1; @@ -732,7 +733,7 @@ int pacman_sync(list_t *targets) if(retval) { goto cleanup; } - MSG(CL, "done.\n"); + MSG(CL, _("done.\n")); if(config->op_s_downloadonly) { goto cleanup; @@ -741,27 +742,27 @@ int pacman_sync(list_t *targets) /* Step 3: actually perform the installation */ if(alpm_trans_commit(&data) == -1) { - ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno)); + 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)) { PM_CONFLICT *conflict = alpm_list_getdata(lp); switch((int)alpm_conflict_getinfo(conflict, PM_CONFLICT_TYPE)) { case PM_CONFLICT_TYPE_TARGET: - MSG(NL, "%s exists in \"%s\" (target) and \"%s\" (target)", + MSG(NL, _("%s exists in \"%s\" (target) and \"%s\" (target)"), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_FILE), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_TARGET), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_CTARGET)); break; case PM_CONFLICT_TYPE_FILE: - MSG(NL, "%s: %s exists in filesystem", + MSG(NL, _("%s: %s exists in filesystem"), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_TARGET), (char *)alpm_conflict_getinfo(conflict, PM_CONFLICT_FILE)); break; } } alpm_list_free(data); - MSG(NL, "\nerrors occurred, no packages were upgraded.\n"); + MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); break; default: break; @@ -781,7 +782,7 @@ int pacman_sync(list_t *targets) */ cleanup: if(alpm_trans_release() == -1) { - ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno)); + ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); retval = 1; } diff --git a/src/pacman/trans.c b/src/pacman/trans.c index 4f9f68e7..279d431a 100644 --- a/src/pacman/trans.c +++ b/src/pacman/trans.c @@ -26,6 +26,7 @@ #include <sys/stat.h> #include <unistd.h> #include <dirent.h> +#include <libintl.h> #include <alpm.h> /* pacman */ @@ -47,49 +48,49 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2) switch(event) { case PM_TRANS_EVT_CHECKDEPS_START: - MSG(NL, "checking dependencies... "); + MSG(NL, _("checking dependencies... ")); break; case PM_TRANS_EVT_FILECONFLICTS_START: - MSG(NL, "checking for file conflicts... "); + MSG(NL, _("checking for file conflicts... ")); break; case PM_TRANS_EVT_RESOLVEDEPS_START: - MSG(NL, "resolving dependencies... "); + MSG(NL, _("resolving dependencies... ")); break; case PM_TRANS_EVT_INTERCONFLICTS_START: - MSG(NL, "looking for inter-conflicts... "); + MSG(NL, _("looking for inter-conflicts... ")); break; case PM_TRANS_EVT_CHECKDEPS_DONE: case PM_TRANS_EVT_FILECONFLICTS_DONE: case PM_TRANS_EVT_RESOLVEDEPS_DONE: case PM_TRANS_EVT_INTERCONFLICTS_DONE: - MSG(CL, "done.\n"); + MSG(CL, _("done.\n")); break; case PM_TRANS_EVT_ADD_START: - MSG(NL, "installing %s... ", (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); + MSG(NL, _("installing %s... "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); break; case PM_TRANS_EVT_ADD_DONE: - MSG(CL, "done.\n"); - snprintf(str, LOG_STR_LEN, "installed %s (%s)", + MSG(CL, _("done.\n")); + snprintf(str, LOG_STR_LEN, _("installed %s (%s)"), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); alpm_logaction(str); break; case PM_TRANS_EVT_REMOVE_START: - MSG(NL, "removing %s... ", (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); + MSG(NL, _("removing %s... "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); break; case PM_TRANS_EVT_REMOVE_DONE: - MSG(CL, "done.\n"); - snprintf(str, LOG_STR_LEN, "removed %s (%s)", + MSG(CL, _("done.\n")); + snprintf(str, LOG_STR_LEN, _("removed %s (%s)"), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); alpm_logaction(str); break; case PM_TRANS_EVT_UPGRADE_START: - MSG(NL, "upgrading %s... ", (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); + MSG(NL, _("upgrading %s... "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME)); break; case PM_TRANS_EVT_UPGRADE_DONE: - MSG(CL, "done.\n"); - snprintf(str, LOG_STR_LEN, "upgraded %s (%s -> %s)", + MSG(CL, _("done.\n")); + snprintf(str, LOG_STR_LEN, _("upgraded %s (%s -> %s)"), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data2, PM_PKG_VERSION), (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); @@ -104,20 +105,20 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i switch(event) { case PM_TRANS_CONV_INSTALL_IGNOREPKG: - snprintf(str, LOG_STR_LEN, ":: %s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ", + snprintf(str, LOG_STR_LEN, _(":: %s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); *response = yesno(str); break; case PM_TRANS_CONV_REPLACE_PKG: - snprintf(str, LOG_STR_LEN, ":: Replace %s with %s/%s? [Y/n] ", + snprintf(str, LOG_STR_LEN, _(":: Replace %s with %s/%s? [Y/n] "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)data3, (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); *response = yesno(str); break; case PM_TRANS_CONV_CONFLICT_PKG: - snprintf(str, LOG_STR_LEN, ":: %s conflicts with %s. Remove %s? [Y/n] ", + snprintf(str, LOG_STR_LEN, _(":: %s conflicts with %s. Remove %s? [Y/n] "), (char *)data1, (char *)data2, (char *)data2); @@ -125,7 +126,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i break; case PM_TRANS_CONV_LOCAL_NEWER: if(!config->op_s_downloadonly) { - snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", + snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); *response = yesno(str); @@ -135,7 +136,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i break; case PM_TRANS_CONV_LOCAL_UPTODATE: if(!config->op_s_downloadonly) { - snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is up to date. Upgrade anyway? [Y/n] ", + snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is up to date. Upgrade anyway? [Y/n] "), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); *response = yesno(str); diff --git a/src/pacman/util.c b/src/pacman/util.c index ef6c0f82..aefdea9b 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -30,6 +30,7 @@ #include <dirent.h> #include <unistd.h> #include <regex.h> +#include <libintl.h> #ifdef CYGWIN #include <limits.h> /* PATH_MAX */ #endif @@ -168,7 +169,7 @@ char *buildstring(list_t *strlist) } str = (char *)malloc(size); if(str == NULL) { - ERR(NL, "failed to allocated %d bytes\n", size); + ERR(NL, _("failed to allocated %d bytes\n"), size); } str[0] = '\0'; for(lp = strlist; lp; lp = lp->next) { @@ -222,7 +223,7 @@ int reg_match(char *string, char *pattern) regex_t reg; if(regcomp(®, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) { - ERR(NL, "%s is not a valid regular expression.\n", pattern); + ERR(NL, _("%s is not a valid regular expression.\n"), pattern); return(-1); } result = regexec(®, string, 0, 0, 0); diff --git a/src/pacman/util.h b/src/pacman/util.h index 96b38736..51e05fd3 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -42,6 +42,8 @@ s1[(len)-1] = 0; \ } while(0) +#define _(str) gettext(str) + int makepath(char *path); int rmrf(char *path); void indentprint(char *str, int indent); |