From 39711f383a80c6daa64876877adc39b8b6c25b58 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 14 Mar 1996 16:54:08 +0000 Subject: [PATCH] Added NLS support CVS patchset: 471 CVS date: 1996/03/14 16:54:08 --- rpm.c | 305 +++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 164 insertions(+), 141 deletions(-) diff --git a/rpm.c b/rpm.c index 6c788d9..2670790 100755 --- a/rpm.c +++ b/rpm.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -14,6 +16,8 @@ #include "rpmlib.h" #include "build/build.h" +#define _(String) gettext(String) + char * version = VERSION; enum modes { MODE_QUERY, MODE_INSTALL, MODE_UNINSTALL, MODE_VERIFY, @@ -33,13 +37,13 @@ void printUsage(void); int build(char * arg, int buildAmount, char *passPhrase); void printVersion(void) { - printf("RPM version %s\n", version); + printf(_("RPM version %s\n"), version); } void printBanner(void) { - puts("Copyright (C) 1995 - Red Hat Software"); - puts("This may be freely redistributed under the terms of the GNU " - "Public License"); + puts(_("Copyright (C) 1995 - Red Hat Software")); + puts(_("This may be freely redistributed under the terms of the GNU " + "Public License")); } void printUsage(void) { @@ -47,99 +51,99 @@ void printUsage(void) { printBanner(); puts(""); - puts("usage: rpm {--help}"); - puts(" rpm {--version}"); - puts(" rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]"); - puts(" [--replacepkgs] [--replacefiles] [--search]"); - puts(" [--root ] file1.rpm ... filen.rpm"); - puts(" rpm {--upgrage -U} [-v] [--hash -h] [--percent] [--force] [--test]"); - puts(" [--search] [--oldpackage] [--root ]"); - puts(" file1.rpm ... fileN.rpm"); - puts(" rpm {--query -q} [-afFpP] [-i] [-l] [-s] [-d] [-c] [-v] "); - puts(" [--root ] [targets]"); - puts(" rpm {--verify -V -y] [-afFpP] [--root ] [targets]"); - puts(" rpm {--erase -e] [--root ] package1 package2 ... packageN"); - puts(" rpm {-b}[plciba] [-v] [--short-circuit] [--clean] [--keep-temps]"); - puts(" [--sign] [--test] [--time-check ] specfile"); - puts(" rpm {--rebuild} [-v] source1.rpm source2.rpm ... sourceN.rpm"); - puts(" rpm {--where} package1 package2 ... packageN"); - puts(" rpm {--checksig} package1 package2 ... packageN"); + puts(_("usage: rpm {--help}")); + puts(_(" rpm {--version}")); + puts(_(" rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]")); + puts(_(" [--replacepkgs] [--replacefiles] [--search]")); + puts(_(" [--root ] file1.rpm ... filen.rpm")); + puts(_(" rpm {--upgrage -U} [-v] [--hash -h] [--percent] [--force] [--test]")); + puts(_(" [--search] [--oldpackage] [--root ]")); + puts(_(" file1.rpm ... fileN.rpm")); + puts(_(" rpm {--query -q} [-afFpP] [-i] [-l] [-s] [-d] [-c] [-v] ")); + puts(_(" [--root ] [targets]")); + puts(_(" rpm {--verify -V -y] [-afFpP] [--root ] [targets]")); + puts(_(" rpm {--erase -e] [--root ] package1 package2 ... packageN")); + puts(_(" rpm {-b}[plciba] [-v] [--short-circuit] [--clean] [--keep-temps]")); + puts(_(" [--sign] [--test] [--time-check ] specfile")); + puts(_(" rpm {--rebuild} [-v] source1.rpm source2.rpm ... sourceN.rpm")); + puts(_(" rpm {--where} package1 package2 ... packageN")); + puts(_(" rpm {--checksig} package1 package2 ... packageN")); } void printHelp(void) { printVersion(); printBanner(); - puts(""); - - puts("usage:"); - puts(" --help - print this message"); - puts(" --version - print the version of rpm being used"); - puts(" -q - query mode"); - puts(" --root - use as the top level directory"); - puts(" Package specification options:"); - puts(" -a - query all packages"); - puts(" -f + - query package owning "); - puts(" -F - like -f, but read file names from stdin"); - puts(" -p + - query (uninstalled) package "); - puts(" -P - like -f, but read package names from stdin"); - puts(" Information selection options:"); - puts(" -i - display package information"); - puts(" -l - display package file list"); - puts(" -s - show file states (implies -l)"); - puts(" -d - list only documentation files (implies -l)"); - puts(" -c - list only configuration files (implies -l)"); - puts(""); - puts(" -V"); - puts(" -y"); - puts(" --verify - verify a package installation"); - puts(" same package specification options as -q"); - puts(" --root - use as the top level directory"); - puts(""); - puts(" --install "); - puts(" -i - install package"); - puts(" -v - be a little verbose "); - puts(" -h"); - puts(" --hash - print hash marks as package installs (good with -v)"); - puts(" --percent - print percentages as package installs"); - puts(" --replacepkgs - reinstall if the package is already present"); - puts(" --replacefiles - install even if the package replaces installed files"); - puts(" --force - short hand for --replacepkgs --replacefiles"); - puts(" --test - don't install, but tell if it would work or not"); - puts(" --search - search the paths listed in /etc/rpmrc for rpms"); - puts(" --root - use as the top level directory"); - puts(""); - puts(" --upgrade "); - puts(" -U - upgrade package (same options as --install, plus)"); - puts(" --oldpackage - upgrade to an old version of the package (--force"); - puts(" on upgrades does this automatically)"); - puts(""); - puts(" --erase "); - puts(" -e - uninstall (erase) package"); - puts(" --root - use as the top level directory"); - puts(""); - puts(" -b - build package, where is one of:"); - puts(" p - prep (unpack sources and apply patches)"); - puts(" l - list check (do some cursory checks on %files)"); - puts(" c - compile (prep and compile)"); - puts(" i - install (prep, compile, install)"); - puts(" b - binary package (prep, compile, install, package)"); - puts(" a - bin/src package (prep, compile, install, package)"); - puts(" --short-circuit - skip straight to specified stage (only for c,i)"); - puts(" --clean - remove build tree when done"); - puts(" --sign - generate PGP signature"); - puts(" --keep-temps - do not delete scripts (or any temp files) in /tmp"); - puts(" --test - do not execute any stages, implies --keep-temps"); - puts(" in /tmp - useful for testing"); - puts(" --time-check - set the time check to S seconds (0 disables it)"); - puts(""); - puts(" --where + - search paths listed in /etc/rpmrc for rpms"); - puts(" matching "); - puts(""); - puts(" --rebuild "); - puts(" - install source package, build binary package,"); - puts(" and remove spec file, sources, patches, and icons."); - puts(" -K"); - puts(" --checksig + - verify PGP signature"); + puts(_("")); + + puts(_("usage:")); + puts(_(" --help - print this message")); + puts(_(" --version - print the version of rpm being used")); + puts(_(" -q - query mode")); + puts(_(" --root - use as the top level directory")); + puts(_(" Package specification options:")); + puts(_(" -a - query all packages")); + puts(_(" -f + - query package owning ")); + puts(_(" -F - like -f, but read file names from stdin")); + puts(_(" -p + - query (uninstalled) package ")); + puts(_(" -P - like -f, but read package names from stdin")); + puts(_(" Information selection options:")); + puts(_(" -i - display package information")); + puts(_(" -l - display package file list")); + puts(_(" -s - show file states (implies -l)")); + puts(_(" -d - list only documentation files (implies -l)")); + puts(_(" -c - list only configuration files (implies -l)")); + puts(_("")); + puts(_(" -V")); + puts(_(" -y")); + puts(_(" --verify - verify a package installation")); + puts(_(" same package specification options as -q")); + puts(_(" --root - use as the top level directory")); + puts(_("")); + puts(_(" --install ")); + puts(_(" -i - install package")); + puts(_(" -v - be a little verbose ")); + puts(_(" -h")); + puts(_(" --hash - print hash marks as package installs (good with -v)")); + puts(_(" --percent - print percentages as package installs")); + puts(_(" --replacepkgs - reinstall if the package is already present")); + puts(_(" --replacefiles - install even if the package replaces installed files")); + puts(_(" --force - short hand for --replacepkgs --replacefiles")); + puts(_(" --test - don't install, but tell if it would work or not")); + puts(_(" --search - search the paths listed in /etc/rpmrc for rpms")); + puts(_(" --root - use as the top level directory")); + puts(_("")); + puts(_(" --upgrade ")); + puts(_(" -U - upgrade package (same options as --install, plus)")); + puts(_(" --oldpackage - upgrade to an old version of the package (--force")); + puts(_(" on upgrades does this automatically)")); + puts(_("")); + puts(_(" --erase ")); + puts(_(" -e - uninstall (erase) package")); + puts(_(" --root - use as the top level directory")); + puts(_("")); + puts(_(" -b - build package, where is one of:")); + puts(_(" p - prep (unpack sources and apply patches)")); + puts(_(" l - list check (do some cursory checks on %files)")); + puts(_(" c - compile (prep and compile)")); + puts(_(" i - install (prep, compile, install)")); + puts(_(" b - binary package (prep, compile, install, package)")); + puts(_(" a - bin/src package (prep, compile, install, package)")); + puts(_(" --short-circuit - skip straight to specified stage (only for c,i)")); + puts(_(" --clean - remove build tree when done")); + puts(_(" --sign - generate PGP signature")); + puts(_(" --keep-temps - do not delete scripts (or any temp files) in /tmp")); + puts(_(" --test - do not execute any stages, implies --keep-temps")); + puts(_(" in /tmp - useful for testing")); + puts(_(" --time-check - set the time check to S seconds (0 disables it)")); + puts(_("")); + puts(_(" --where + - search paths listed in /etc/rpmrc for rpms")); + puts(_(" matching ")); + puts(_("")); + puts(_(" --rebuild ")); + puts(_(" - install source package, build binary package,")); + puts(_(" and remove spec file, sources, patches, and icons.")); + puts(_(" -K")); + puts(_(" --checksig + - verify PGP signature")); } int build(char * arg, int buildAmount, char *passPhrase) { @@ -159,14 +163,14 @@ int build(char * arg, int buildAmount, char *passPhrase) { } if (!(f = fopen(specfile, "r"))) { - fprintf(stderr, "unable to open: %s\n", specfile); + fprintf(stderr, _("unable to open: %s\n"), specfile); return 1; } s = parseSpec(f, specfile); fclose(f); if (s) { if (doBuild(s, buildAmount, passPhrase)) { - fprintf(stderr, "Build failed.\n"); + fprintf(stderr, _("Build failed.\n")); res = 1; } freeSpec(s); @@ -174,9 +178,9 @@ int build(char * arg, int buildAmount, char *passPhrase) { /* Spec parse failed -- could be Exclude: Exclusive: */ res = 1; if (errCode() == RPMERR_BADARCH) { - fprintf(stderr, "%s doesn't build on this architecture\n", arg); + fprintf(stderr, _("%s doesn't build on this architecture\n"), arg); } else { - fprintf(stderr, "Build failed.\n"); + fprintf(stderr, _("Build failed.\n")); } } @@ -250,6 +254,12 @@ int main(int argc, char ** argv) { { 0, 0, 0, 0 } } ; + /* set up the correct locale via the LANG environment variable */ + setlocale(LC_ALL, "" ); + + bindtextdomain(NLSPACKAGE, "/usr/lib/locale"); + textdomain(NLSPACKAGE); + if (readConfigFiles()) /* reading this early makes it easy to override */ exit(-1); @@ -267,57 +277,59 @@ int main(int argc, char ** argv) { case 'K': if (bigMode != MODE_UNKNOWN && bigMode != MODE_CHECKSIG) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_CHECKSIG; break; case 'Q': if (querySource != QUERY_PACKAGE && querySource != QUERY_SPACKAGE) - argerror("only one type of query may be performed at a time"); + argerror(_("only one type of query may be performed at a " + "time")); querySource = QUERY_SPACKAGE; /* fallthrough */ case 'q': if (bigMode != MODE_UNKNOWN && bigMode != MODE_QUERY) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_QUERY; break; case 'Y': if (verifySource != VERIFY_PACKAGE && verifySource != VERIFY_SPACKAGE) - argerror("only one type of verify may be performed at a time"); + argerror(_("only one type of verify may be performed at a " + "time")); verifySource = VERIFY_SPACKAGE; /* fallthrough */ case 'V': case 'y': if (bigMode != MODE_UNKNOWN && bigMode != MODE_VERIFY) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_VERIFY; break; case 'u': if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_UNINSTALL; - message(MESS_WARNING, "-u and --uninstall are depricated and will" - " be removed soon.\n"); - message(MESS_WARNING, "Use -e or --erase instead.\n"); + message(MESS_WARNING, _("-u and --uninstall are depricated and will" + " be removed soon.\n")); + message(MESS_WARNING, _("Use -e or --erase instead.\n")); break; case 'e': if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_UNINSTALL; break; case 'b': if (bigMode != MODE_UNKNOWN && bigMode != MODE_BUILD) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_BUILD; if (strlen(optarg) > 1) - argerror("--build (-b) requires one of a,b,i,c,p,l as " - "its sole argument"); + argerror(_("--build (-b) requires one of a,b,i,c,p,l as " + "its sole argument")); switch (optarg[0]) { /* these fallthroughs are intentional */ @@ -362,7 +374,7 @@ int main(int argc, char ** argv) { case 'U': if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_INSTALL; installFlags |= INSTALL_UPGRADE; break; @@ -385,27 +397,31 @@ int main(int argc, char ** argv) { case 'P': if (querySource != QUERY_PACKAGE && querySource != QUERY_SRPM) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " + "time")); querySource = QUERY_SRPM; verifySource = VERIFY_SRPM; break; case 'p': if (querySource != QUERY_PACKAGE && querySource != QUERY_RPM) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " "time")); querySource = QUERY_RPM; verifySource = VERIFY_RPM; break; case 'G': if (querySource != QUERY_PACKAGE && querySource != QUERY_SGROUP) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " + "time")); querySource = QUERY_SGROUP; verifySource = VERIFY_SGROUP; break; case 'g': if (querySource != QUERY_PACKAGE && querySource != QUERY_GROUP) + argerror(_("one type of query/verify may be performed at a " + "time")); argerror("one type of query/verify may be performed at a time"); querySource = QUERY_GROUP; verifySource = VERIFY_GRP; @@ -413,21 +429,24 @@ int main(int argc, char ** argv) { case 'F': if (querySource != QUERY_PACKAGE && querySource != QUERY_SPATH) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " + "time")); querySource = QUERY_SPATH; verifySource = VERIFY_SPATH; break; case 'f': if (querySource != QUERY_PACKAGE && querySource != QUERY_PATH) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " + "time")); querySource = QUERY_PATH; verifySource = VERIFY_PATH; break; case 'a': if (querySource != QUERY_PACKAGE && querySource != QUERY_ALL) - argerror("one type of query/verify may be performed at a time"); + argerror(_("one type of query/verify may be performed at a " + "time")); querySource = QUERY_ALL; verifySource = VERIFY_EVERY; break; @@ -438,7 +457,7 @@ int main(int argc, char ** argv) { case 'r': if (optarg[0] != '/') - argerror("arguments to --root (-r) must begin with a /"); + argerror(_("arguments to --root (-r) must begin with a /")); prefix = optarg; break; @@ -447,7 +466,7 @@ int main(int argc, char ** argv) { *options[long_index].flag = 1; else if (!strcmp(options[long_index].name, "rebuild")) { if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILD) - argerror("only one major mode may be specified"); + argerror(_("only one major mode may be specified")); bigMode = MODE_REBUILD; } } @@ -463,41 +482,45 @@ int main(int argc, char ** argv) { exit(1); if (bigMode != MODE_QUERY && queryFor) - argerror("unexpected query specifiers"); + argerror(_("unexpected query specifiers")); if (bigMode != MODE_QUERY && bigMode != MODE_VERIFY && querySource != QUERY_PACKAGE) - argerror("unexpected query source"); + argerror(_("unexpected query source")); if (bigMode != MODE_INSTALL && force) - argerror("only installation and upgrading may be forced"); + argerror(_("only installation and upgrading may be forced")); if (bigMode != MODE_INSTALL && showHash) - argerror("--hash (-h) may only be specified during package installation"); + argerror(_("--hash (-h) may only be specified during package " + "installation")); if (bigMode != MODE_INSTALL && showPercents) - argerror("--percent may only be specified during package installation"); + argerror(_("--percent may only be specified during package " + "installation")); if (bigMode != MODE_INSTALL && replaceFiles) - argerror("--replacefiles may only be specified during package installation"); + argerror(_("--replacefiles may only be specified during package " + "installation")); if (bigMode != MODE_INSTALL && replacePackages) - argerror("--replacepkgs may only be specified during package installation"); + argerror(_("--replacepkgs may only be specified during package " + "installation")); if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL && test) - argerror("--test may only be specified during package installation " - "and uninstallation"); + argerror(_("--test may only be specified during package installation " + "and uninstallation")); if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL && bigMode != MODE_QUERY && prefix[1]) - argerror("--root (-r) may only be specified during " - "installation, uninstallation, and querying"); + argerror(_("--root (-r) may only be specified during " + "installation, uninstallation, and querying")); if (bigMode != MODE_BUILD && clean) - argerror("--clean may only be used during package building"); + argerror(_("--clean may only be used during package building")); if (oldPackage && !(installFlags & INSTALL_UPGRADE)) - argerror("--oldpackage may only be used during upgrades"); + argerror(_("--oldpackage may only be used during upgrades")); if (oldPackage || (force && (installFlags & INSTALL_UPGRADE))) installFlags |= INSTALL_UPGRADETOOLD; @@ -506,15 +529,15 @@ int main(int argc, char ** argv) { if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD) { if ((optind != argc) && (sigLookupType() == RPMSIG_PGP262_1024)) { if (!(passPhrase = getPassPhrase("Enter pass phrase: "))) { - fprintf(stderr, "Pass phrase check failed\n"); + fprintf(stderr, _("Pass phrase check failed\n")); exit(1); } else { - fprintf(stderr, "Pass phrase is good.\n"); + fprintf(stderr, _("Pass phrase is good.\n")); passPhrase = strdup(passPhrase); } } } else { - argerror("--sign may only be used during package building"); + argerror(_("--sign may only be used during package building")); } } else { /* Override any rpmrc setting */ @@ -528,7 +551,7 @@ int main(int argc, char ** argv) { case MODE_CHECKSIG: if (optind == argc) - argerror("no packages given for signature check"); + argerror(_("no packages given for signature check")); exit(doCheckSig(argv + optind)); case MODE_REBUILD: @@ -536,7 +559,7 @@ int main(int argc, char ** argv) { setVerbosity(MESS_VERBOSE); if (optind == argc) - argerror("no packages files given for rebuild"); + argerror(_("no packages files given for rebuild")); while (optind < argc) { buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | @@ -559,7 +582,7 @@ int main(int argc, char ** argv) { buildAmount |= RPMBUILD_SWEEP; if (optind == argc) - argerror("no spec files given for build"); + argerror(_("no spec files given for build")); while (optind < argc) if (build(argv[optind++], buildAmount, passPhrase)) { @@ -569,7 +592,7 @@ int main(int argc, char ** argv) { case MODE_UNINSTALL: if (optind == argc) - argerror("no packages given for uninstall"); + argerror(_("no packages given for uninstall")); while (optind < argc) doUninstall(prefix, argv[optind++], test, 0); @@ -585,7 +608,7 @@ int main(int argc, char ** argv) { if (showHash) interfaceFlags |= RPMINSTALL_HASH; if (optind == argc) - argerror("no packages given for install"); + argerror(_("no packages given for install")); while (optind < argc) doInstall(prefix, argv[optind++], installFlags, interfaceFlags); @@ -608,7 +631,7 @@ int main(int argc, char ** argv) { } } else { if (optind == argc) - argerror("no arguments given for query"); + argerror(_("no arguments given for query")); while (optind < argc) doQuery(prefix, querySource, queryFor, argv[optind++]); } @@ -632,7 +655,7 @@ int main(int argc, char ** argv) { } } else { if (optind == argc) - argerror("no arguments given for verify"); + argerror(_("no arguments given for verify")); doVerify(prefix, verifySource, argv + optind); } break; -- 2.7.4