add passPhrase stuff and --sign

CVS patchset: 354
CVS date: 1996/02/20 15:59:10
This commit is contained in:
root 1996-02-20 15:59:10 +00:00
parent 46a977012a
commit b3769faaa3
1 changed files with 23 additions and 6 deletions

29
rpm.c
View File

@ -7,6 +7,7 @@
#include "install.h" #include "install.h"
#include "lib/rpmerr.h" #include "lib/rpmerr.h"
#include "lib/messages.h" #include "lib/messages.h"
#include "lib/signature.h"
#include "query.h" #include "query.h"
#include "verify.h" #include "verify.h"
#include "rpmlib.h" #include "rpmlib.h"
@ -28,7 +29,7 @@ void printHelp(void);
void printVersion(void); void printVersion(void);
void printBanner(void); void printBanner(void);
void printUsage(void); void printUsage(void);
void build(char * arg, int buildAmount); void build(char * arg, int buildAmount, char *passPhrase);
void printVersion(void) { void printVersion(void) {
printf("RPM version %s\n", version); printf("RPM version %s\n", version);
@ -133,11 +134,11 @@ void printHelp(void) {
puts(" and remove spec file, sources, patches, and icons."); puts(" and remove spec file, sources, patches, and icons.");
} }
void build(char * arg, int buildAmount) { void build(char * arg, int buildAmount, char *passPhrase) {
FILE *f; FILE *f;
Spec s; Spec s;
char * specfile; char * specfile;
if (arg[0] == '/') { if (arg[0] == '/') {
specfile = arg; specfile = arg;
} else { } else {
@ -152,7 +153,7 @@ void build(char * arg, int buildAmount) {
s = parseSpec(f, specfile); s = parseSpec(f, specfile);
fclose(f); fclose(f);
if (s) { if (s) {
if (doBuild(s, buildAmount)) { if (doBuild(s, buildAmount, passPhrase)) {
fprintf(stderr, "Build failed.\n"); fprintf(stderr, "Build failed.\n");
} }
freeSpec(s); freeSpec(s);
@ -186,8 +187,10 @@ int main(int argc, char ** argv) {
int interfaceFlags = 0; int interfaceFlags = 0;
int buildAmount = 0; int buildAmount = 0;
int clean = 0; int clean = 0;
int signIt = 0;
char * prefix = "/"; char * prefix = "/";
char * specFile; char * specFile;
char *passPhrase = "";
struct option options[] = { struct option options[] = {
{ "all", 0, 0, 'a' }, { "all", 0, 0, 'a' },
{ "build", 1, 0, 'b' }, { "build", 1, 0, 'b' },
@ -210,6 +213,7 @@ int main(int argc, char ** argv) {
{ "replacefiles", 0, &replaceFiles, 0 }, { "replacefiles", 0, &replaceFiles, 0 },
{ "replacepkgs", 0, &replacePackages, 0 }, { "replacepkgs", 0, &replacePackages, 0 },
{ "root", 1, 0, 'r' }, { "root", 1, 0, 'r' },
{ "sign", 0, &signIt, 0 },
{ "state", 0, 0, 's' }, { "state", 0, 0, 's' },
{ "stdin-files", 0, 0, 'F' }, { "stdin-files", 0, 0, 'F' },
{ "stdin-group", 0, 0, 'G' }, { "stdin-group", 0, 0, 'G' },
@ -438,6 +442,19 @@ int main(int argc, char ** argv) {
if (bigMode != MODE_BUILD && clean) if (bigMode != MODE_BUILD && clean)
argerror("--clean may only be used during package building"); argerror("--clean may only be used during package building");
if (signIt) {
if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD) {
if ((optind != argc) && (sigLookupType() == RPMSIG_PGP262_1024)) {
passPhrase = strdup(getPassPhrase("Enter pass phrase:"));
}
} else {
argerror("--sign may only be used during package building");
}
} else {
/* Override any rpmrc setting */
setVar(RPMVAR_SIGTYPE, "none");
}
switch (bigMode) { switch (bigMode) {
case MODE_UNKNOWN: case MODE_UNKNOWN:
if (!version && !help) printUsage(); if (!version && !help) printUsage();
@ -457,7 +474,7 @@ int main(int argc, char ** argv) {
if (doSourceInstall("/", argv[optind++], &specFile)) if (doSourceInstall("/", argv[optind++], &specFile))
exit(-1); exit(-1);
build(specFile, buildAmount); build(specFile, buildAmount, passPhrase);
} }
break; break;
@ -472,7 +489,7 @@ int main(int argc, char ** argv) {
argerror("no spec files given for build"); argerror("no spec files given for build");
while (optind < argc) while (optind < argc)
build(argv[optind++], buildAmount); build(argv[optind++], buildAmount, passPhrase);
break; break;
case MODE_UNINSTALL: case MODE_UNINSTALL: