diff options
-rw-r--r-- | src/pacman/add.c | 14 | ||||
-rw-r--r-- | src/pacman/output.c | 3 | ||||
-rw-r--r-- | src/pacman/package.c | 5 | ||||
-rw-r--r-- | src/pacman/pacman.c | 41 | ||||
-rw-r--r-- | src/pacman/query.c | 25 | ||||
-rw-r--r-- | src/pacman/remove.c | 16 | ||||
-rw-r--r-- | src/pacman/sync.c | 49 |
7 files changed, 88 insertions, 65 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c index 20c7fd68..a42d2286 100644 --- a/src/pacman/add.c +++ b/src/pacman/add.c @@ -92,7 +92,7 @@ int pacman_add(alpm_list_t *targets) if(alpm_trans_init(transtype, config->flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) { /* TODO: error messages should be in the front end, not the back */ - ERR(NL, "%s\n", alpm_strerror(pm_errno)); + fprintf(stderr, _("error: %s\n"), alpm_strerror(pm_errno)); if(pm_errno == PM_ERR_HANDLE_LOCK) { /* TODO this and the 2 other places should probably be on stderr */ printf(_(" if you're sure a package manager is not already\n" @@ -107,9 +107,8 @@ int pacman_add(alpm_list_t *targets) for(i = targets; i; i = alpm_list_next(i)) { char *targ = alpm_list_getdata(i); if(alpm_trans_addtarget(targ) == -1) { - /* TODO: glad this output is hacky */ - ERR(NL, _("failed to add target '%s' (%s)"), targ, - alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to add target '%s' (%s)"), targ, + alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -121,7 +120,8 @@ int pacman_add(alpm_list_t *targets) if(alpm_trans_prepare(&data) == -1) { long long *pkgsize, *freespace; - ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to prepare transaction (%s)\n"), + alpm_strerror(pm_errno)); switch(pm_errno) { case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { @@ -195,7 +195,7 @@ int pacman_add(alpm_list_t *targets) /* Step 3: perform the installation */ if(alpm_trans_commit(NULL) == -1) { - ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); retval=1; goto cleanup; } @@ -205,7 +205,7 @@ cleanup: alpm_list_free(data); } if(alpm_trans_release() == -1) { - ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); retval=1; } diff --git a/src/pacman/output.c b/src/pacman/output.c index 36f0aa65..4c970b2e 100644 --- a/src/pacman/output.c +++ b/src/pacman/output.c @@ -62,9 +62,6 @@ int yesno(char *fmt, ...) strtrim(response); } - /* User hits 'enter', forcing a newline here */ - neednl = 0; - if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || strlen(response) == 0) { return(1); } diff --git a/src/pacman/package.c b/src/pacman/package.c index 9e95a0f3..81bcad17 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -177,7 +177,8 @@ void dump_pkg_backups(pmpkg_t *pkg) char *sha1sum = alpm_get_sha1sum(path); if(md5sum == NULL || sha1sum == NULL) { - ERR(NL, _("error calculating checksums for %s\n"), path); + fprintf(stderr, _("error: could not calculate checksums for %s\n"), + path); free(str); continue; } @@ -243,7 +244,7 @@ void dump_pkg_changelog(char *clfile, const char *pkgname) if((fp = fopen(clfile, "r")) == NULL) { - ERR(NL, _("No changelog available for '%s'.\n"), pkgname); + fprintf(stderr, _("error: no changelog available for '%s'.\n"), pkgname); return; } else diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index c4dc848f..409cf2ef 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -212,7 +212,7 @@ static void cleanup(int signum) /* free alpm library resources */ if(alpm_release() == -1) { - ERR(NL, "%s\n", alpm_strerror(pm_errno)); + fprintf(stderr, _("error: %s\n"), alpm_strerror(pm_errno)); } /* free memory */ @@ -309,11 +309,16 @@ static int parseargs(int argc, char *argv[]) if(optarg) { unsigned short debug = atoi(optarg); switch(debug) { - case 3: logmask |= PM_LOG_FUNCTION; /* fall through */ - case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */ - case 1: logmask |= PM_LOG_DEBUG; break; + case 3: + logmask |= PM_LOG_FUNCTION; /* fall through */ + case 2: + logmask |= PM_LOG_DOWNLOAD; /*fall through */ + case 1: + logmask |= PM_LOG_DEBUG; + break; default: - ERR(NL, _("'%s' is not a valid debug level"), optarg); + fprintf(stderr, _("error: '%s' is not a valid debug level"), + optarg); return(1); } } else { @@ -328,7 +333,8 @@ static int parseargs(int argc, char *argv[]) case 1006: config->noask = 1; config->ask = atoi(optarg); break; case 1007: if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { - ERR(NL, _("'%s' is not a valid cache directory\n"), optarg); + fprintf(stderr, _("error: '%s' is not a valid cache directory\n"), + optarg); return(1); } alpm_option_set_cachedir(optarg); @@ -346,7 +352,8 @@ static int parseargs(int argc, char *argv[]) case 'V': config->version = 1; break; case 'b': if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { - ERR(NL, _("'%s' is not a valid db path\n"), optarg); + fprintf(stderr, _("error: '%s' is not a valid db path\n"), + optarg); return(1); } alpm_option_set_dbpath(optarg); @@ -376,7 +383,8 @@ static int parseargs(int argc, char *argv[]) break; case 'r': if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { - ERR(NL, _("'%s' is not a valid root path\n"), optarg); + fprintf(stderr, _("error: '%s' is not a valid root path\n"), + optarg); return(1); } alpm_option_set_root(optarg); @@ -403,7 +411,7 @@ static int parseargs(int argc, char *argv[]) } if(config->op == 0) { - ERR(NL, _("only one operation may be used at a time\n")); + fprintf(stderr, _("error: only one operation may be used at a time\n")); return(1); } @@ -464,7 +472,8 @@ int main(int argc, char *argv[]) /* initialize pm library */ if(alpm_initialize() == -1) { - ERR(NL, _("failed to initialize alpm library (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to initialize alpm library (%s)\n"), + alpm_strerror(pm_errno)); cleanup(1); } @@ -490,7 +499,7 @@ int main(int argc, char *argv[]) /* special case: ignore root user check if -r is specified, fall back on * normal FS checking */ } else { - ERR(NL, _("you cannot perform this operation unless you are root.\n")); + fprintf(stderr, _("error: you cannot perform this operation unless you are root.\n")); config_free(config); exit(EXIT_FAILURE); } @@ -505,7 +514,8 @@ int main(int argc, char *argv[]) } if(alpm_parse_config(config->configfile, NULL, "") != 0) { - ERR(NL, _("failed to parse config (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to parse config (%s)\n"), + alpm_strerror(pm_errno)); cleanup(1); } @@ -522,7 +532,8 @@ int main(int argc, char *argv[]) /* 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)); + fprintf(stderr, _("error: could not register 'local' database (%s)\n"), + alpm_strerror(pm_errno)); cleanup(1); } @@ -534,7 +545,7 @@ int main(int argc, char *argv[]) && (config->op_s_sync || config->op_s_upgrade || config->op_s_search || config->op_s_clean || config->group || config->op_q_list)))) { - ERR(NL, _("no targets specified (use -h for help)\n")); + fprintf(stderr, _("error: no targets specified (use -h for help)\n")); cleanup(1); } @@ -559,7 +570,7 @@ int main(int argc, char *argv[]) ret = pacman_deptest(pm_targets); break; default: - ERR(NL, _("no operation specified (use -h for help)\n")); + fprintf(stderr, _("error: no operation specified (use -h for help)\n")); ret = 1; } diff --git a/src/pacman/query.c b/src/pacman/query.c index 3f46da34..93da5480 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -85,22 +85,24 @@ static void query_fileowner(pmdb_t *db, char *filename) return; } if(filename == NULL || strlen(filename) == 0) { - ERR(NL, _("no file was specified for --owns\n")); + fprintf(stderr, _("error: no file was specified for --owns\n")); return; } if(stat(filename, &buf) == -1) { - ERR(NL, _("failed to read file '%s': %s"), filename, strerror(errno)); + fprintf(stderr, _("error: failed to read file '%s': %s"), + filename, strerror(errno)); return; } if(S_ISDIR(buf.st_mode)) { - ERR(NL, _("cannot determine ownership of a directory")); + fprintf(stderr, _("error: cannot determine ownership of a directory")); return; } if(!(rpath = resolve_path(filename))) { - ERR(NL, _("cannot determine real path for '%s': %s"), filename, strerror(errno)); + fprintf(stderr, _("error: cannot determine real path for '%s': %s"), + filename, strerror(errno)); return; } @@ -122,7 +124,7 @@ static void query_fileowner(pmdb_t *db, char *filename) } } if(!gotcha) { - ERR(NL, _("No package owns %s\n"), filename); + fprintf(stderr, _("error: No package owns %s\n"), filename); } free(rpath); @@ -165,7 +167,7 @@ int pacman_query(alpm_list_t *targets) sync_dbs = alpm_option_get_syncdbs(); if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) { - ERR(NL, _("no usable package repositories configured.\n")); + fprintf(stderr, _("error: no usable package repositories configured.\n")); return(1); } } @@ -216,7 +218,7 @@ int pacman_query(alpm_list_t *targets) printf("%s %s\n", package, (char *)alpm_list_getdata(p)); } } else { - ERR(NL, _("group \"%s\" was not found\n"), package); + fprintf(stderr, _("error: group \"%s\" was not found\n"), package); /* do not return on query operations - let's just carry on */ /*return(2);*/ } @@ -227,11 +229,12 @@ int pacman_query(alpm_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")); + fprintf(stderr, _("error: 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)); + fprintf(stderr, _("error: failed to load package '%s' (%s)\n"), + package, alpm_strerror(pm_errno)); return(1); } if(config->op_q_info) { @@ -269,7 +272,7 @@ int pacman_query(alpm_list_t *targets) info = alpm_db_get_pkg(db_local, (char *)pkgname); if(info == NULL) { /* something weird happened */ - ERR(NL, _("package \"%s\" not found\n"), pkgname); + fprintf(stderr, _("error: package \"%s\" not found\n"), pkgname); continue; } } @@ -301,7 +304,7 @@ int pacman_query(alpm_list_t *targets) } else { info = alpm_db_get_pkg(db_local, package); if(info == NULL) { - ERR(NL, _("package \"%s\" not found\n"), package); + fprintf(stderr, _("error: package \"%s\" not found\n"), package); continue; } diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 32570927..aef30144 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -83,7 +83,8 @@ int pacman_remove(alpm_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, cb_trans_progress) == -1) { - ERR(NL, _("failed to init transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to init transaction (%s)\n"), + alpm_strerror(pm_errno)); if(pm_errno == PM_ERR_HANDLE_LOCK) { printf(_(" if you're sure a package manager is not already\n" " running, you can remove %s%s.\n"), @@ -99,8 +100,8 @@ int pacman_remove(alpm_list_t *targets) char *targ = alpm_list_getdata(i); if(alpm_trans_addtarget(targ) == -1) { printf("failed.\n"); - ERR(NL, _("failed to add target '%s' (%s)\n"), targ, - alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to add target '%s' (%s)\n"), targ, + alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -108,7 +109,8 @@ int pacman_remove(alpm_list_t *targets) /* Step 2: prepare the transaction based on its type, targets and flags */ if(alpm_trans_prepare(&data) == -1) { - ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to prepare transaction (%s)\n"), + alpm_strerror(pm_errno)); switch(pm_errno) { case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { @@ -148,7 +150,8 @@ int pacman_remove(alpm_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)); + fprintf(stderr, _("error: failed to commit transaction (%s)\n"), + alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -157,7 +160,8 @@ int pacman_remove(alpm_list_t *targets) cleanup: FREELIST(finaltargs); if(alpm_trans_release() == -1) { - ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: 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 b2a8958e..06936172 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -109,7 +109,7 @@ static int sync_cleancache(int level) printf(_("removing old packages from cache... ")); dir = opendir(dirpath); if(dir == NULL) { - ERR(NL, _("could not access cache directory\n")); + fprintf(stderr, _("error: could not access cache directory\n")); return(1); } rewinddir(dir); @@ -175,12 +175,12 @@ static int sync_cleancache(int level) printf(_("removing all packages from cache... ")); if(rmrf(dirpath)) { - ERR(NL, _("could not remove cache directory\n")); + fprintf(stderr, _("error: could not remove cache directory\n")); return(1); } if(makepath(dirpath)) { - ERR(NL, _("could not create new cache directory\n")); + fprintf(stderr, _("error: could not create new cache directory\n")); return(1); } } @@ -207,9 +207,11 @@ static int sync_synctree(int level, alpm_list_t *syncs) * Yes. This will be here until we add a nice pacman "pm_errstr" or * something, OR add all libdownload error codes into the pm_error enum */ - ERR(NL, _("failed to synchronize %s: %s\n"), alpm_db_get_name(db), downloadLastErrString); + fprintf(stderr, _("error: failed to synchronize %s: %s\n"), + alpm_db_get_name(db), downloadLastErrString); } else { - ERR(NL, _("failed to update %s (%s)\n"), alpm_db_get_name(db), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to update %s (%s)\n"), + alpm_db_get_name(db), alpm_strerror(pm_errno)); } } else if(ret == 1) { printf(_(" %s is up to date\n"), alpm_db_get_name(db)); @@ -338,7 +340,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) } if(!db) { - ERR(NL, _("repository '%s' does not exist\n"), repo); + fprintf(stderr, _("error: repository '%s' does not exist\n"), repo); return(1); } @@ -354,7 +356,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) } if(!foundpkg) { - ERR(NL, _("package '%s' was not found in repository '%s'\n"), pkgstr, repo); + fprintf(stderr, _("error: package '%s' was not found in repository '%s'\n"), pkgstr, repo); } } else { pkgstr = target; @@ -374,7 +376,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) } } if(!foundpkg) { - ERR(NL, _("package '%s' was not found\n"), pkgstr); + fprintf(stderr, _("error: package '%s' was not found\n"), pkgstr); } } } @@ -411,7 +413,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) } if(db == NULL) { - ERR(NL, _("repository \"%s\" was not found.\n"),repo); + fprintf(stderr, _("error: repository \"%s\" was not found.\n"),repo); alpm_list_free(ls); return(1); } @@ -447,7 +449,7 @@ int pacman_sync(alpm_list_t *targets) sync_dbs = alpm_option_get_syncdbs(); if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) { - ERR(NL, _("no usable package repositories configured.\n")); + fprintf(stderr, _("error: no usable package repositories configured.\n")); return(1); } @@ -473,7 +475,8 @@ int pacman_sync(alpm_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, cb_trans_progress) == -1) { - ERR(NL, _("failed to init transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to init transaction (%s)\n"), + alpm_strerror(pm_errno)); if(pm_errno == PM_ERR_HANDLE_LOCK) { printf(_(" if you're sure a package manager is not already\n" " running, you can remove %s%s.\n"), @@ -487,7 +490,7 @@ int pacman_sync(alpm_list_t *targets) printf(_(":: Synchronizing package databases...\n")); alpm_logaction(_("synchronizing package lists")); if(!sync_synctree(config->op_s_sync, sync_dbs)) { - ERR(NL, _("failed to synchronize any databases")); + fprintf(stderr, _("error: failed to synchronize any databases\n")); return(1); } } @@ -496,7 +499,7 @@ int pacman_sync(alpm_list_t *targets) printf(_(":: Starting full system upgrade...\n")); alpm_logaction(_("starting full system upgrade")); if(alpm_trans_sysupgrade() == -1) { - ERR(NL, "%s\n", alpm_strerror(pm_errno)); + fprintf(stderr, _("error: %s\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -521,19 +524,19 @@ int pacman_sync(alpm_list_t *targets) ":: not upgrade pacman seperately, answer no.\n")); if(yesno(_(":: Cancel current operation? [Y/n] "))) { if(alpm_trans_release() == -1) { - ERR(NL, _("failed to release transaction (%s)\n"), + fprintf(stderr, _("error: 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, cb_trans_progress) == -1) { - ERR(NL, _("failed to init transaction (%s)\n"), + fprintf(stderr, _("error: failed to init transaction (%s)\n"), alpm_strerror(pm_errno)); return(1); } if(alpm_trans_addtarget("pacman") == -1) { - ERR(NL, _("pacman: %s\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: pacman: %s\n"), alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -553,7 +556,8 @@ int pacman_sync(alpm_list_t *targets) continue; } if(pm_errno != PM_ERR_PKG_NOT_FOUND) { - ERR(NL, "'%s': %s\n", (char *)i->data, alpm_strerror(pm_errno)); + fprintf(stderr, _("'error: %s': %s\n"), + (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } @@ -599,7 +603,7 @@ int pacman_sync(alpm_list_t *targets) /* targ is provided by pname */ targets = alpm_list_add(targets, strdup(pname)); } else { - ERR(NL, _("'%s': not found in sync db\n"), targ); + fprintf(stderr, _("error: '%s': not found in sync db\n"), targ); retval = 1; goto cleanup; } @@ -611,7 +615,8 @@ int pacman_sync(alpm_list_t *targets) /* Step 2: "compute" the transaction based on targets and flags */ if(alpm_trans_prepare(&data) == -1) { long long *pkgsize, *freespace; - ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to prepare transaction (%s)\n"), + alpm_strerror(pm_errno)); switch(pm_errno) { case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { @@ -693,7 +698,8 @@ int pacman_sync(alpm_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)); + fprintf(stderr, _("error: failed to commit transaction (%s)\n"), + alpm_strerror(pm_errno)); switch(pm_errno) { case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { @@ -733,7 +739,8 @@ cleanup: alpm_list_free(data); } if(alpm_trans_release() == -1) { - ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); + fprintf(stderr, _("error: failed to release transaction (%s)\n"), + alpm_strerror(pm_errno)); retval = 1; } |