Rip the useless %_signature macro and everything around it

This commit is contained in:
Panu Matilainen 2010-09-28 16:28:21 +03:00
parent c0aad81e9b
commit 8f14d6455a
4 changed files with 7 additions and 50 deletions

View File

@ -382,12 +382,10 @@ extern struct poptOption rpmInstallPoptTable[];
* Create/delete package signatures.
* @param argv array of package path arguments (NULL terminated)
* @param deleting adding or deleting signature(s)
* @param sigTag signature tag (ignored when deleting)
* @param passPhrase passphrase (ignored when deleting)
* @return 0 on success
*/
int rpmcliSign(ARGV_const_t argv, int deleting,
rpmSigTag sigTag, const char *passPhrase);
int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase);
/** Import public key(s) to rpm keyring
* @param ts transaction set

View File

@ -179,12 +179,10 @@ static int replaceSignature(Header sigh, const char *sigtarget,
* Create/modify elements in signature header.
* @param rpm path to package
* @param deleting adding or deleting signature?
* @param sigtag signature to generate (ignored when deleting)
* @param passPhrase passPhrase (ignored when deleting)
* @return 0 on success, -1 on error
*/
static int rpmSign(const char *rpm, int deleting,
rpmSigTag sigtag, const char *passPhrase)
static int rpmSign(const char *rpm, int deleting, const char *passPhrase)
{
FD_t fd = NULL;
FD_t ofd = NULL;
@ -287,7 +285,7 @@ static int rpmSign(const char *rpm, int deleting,
if (deleting) { /* Nuke all the signature tags. */
deleteSigs(sigh);
} else if (sigtag > 0) {
} else {
res = replaceSignature(sigh, sigtarget, passPhrase);
if (res != 0) {
if (res == 1) {
@ -366,12 +364,11 @@ exit:
return res;
}
int rpmcliSign(ARGV_const_t argv, int deleting,
rpmSigTag sigtag, const char *passPhrase)
int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase)
{
int res = 0;
for (ARGV_const_t arg = argv; arg && *arg; arg++) {
res += rpmSign(*arg, deleting, sigtag, passPhrase);
res += rpmSign(*arg, deleting, passPhrase);
}
return res;
}

View File

@ -209,9 +209,6 @@ package or when debugging this package.\
# (legacy).
%_rpmfilename %{_build_name_fmt}
# The default signature type.
%_signature gpg
# The directory where sources/patches from a source package will be
# installed. This is also where sources/patches are found when building.
%_sourcedir %{_topdir}/SOURCES

View File

@ -34,28 +34,6 @@ static struct poptOption optionsTable[] = {
POPT_TABLEEND
};
static rpmSigTag lookupSignatureType(void)
{
rpmSigTag rc = 0;
char *name = rpmExpand("%{?_signature}", NULL);
if (!(name && *name != '\0'))
rc = 0;
else if (!rstrcasecmp(name, "none"))
rc = 0;
else if (!rstrcasecmp(name, "pgp"))
rc = RPMSIGTAG_PGP;
else if (!rstrcasecmp(name, "pgp5")) /* XXX legacy */
rc = RPMSIGTAG_PGP;
else if (!rstrcasecmp(name, "gpg"))
rc = RPMSIGTAG_GPG;
else
rc = -1; /* Invalid %_signature spec in macro file */
name = _free(name);
return rc;
}
static int checkPassPhrase(const char * passPhrase)
{
int passPhrasePipe[2];
@ -116,7 +94,6 @@ static int checkPassPhrase(const char * passPhrase)
static int doSign(ARGV_const_t args)
{
int rc = EXIT_FAILURE;
int sigTag = lookupSignatureType();
char * passPhrase = NULL;
char * name = rpmExpand("%{?_gpg_name}", NULL);
@ -125,24 +102,12 @@ static int doSign(ARGV_const_t args)
goto exit;
}
switch (sigTag) {
case RPMSIGTAG_PGP:
case RPMSIGTAG_GPG:
case RPMSIGTAG_DSA:
case RPMSIGTAG_RSA:
break;
default:
fprintf(stderr, _("Invalid %%_signature spec in macro file.\n"));
goto exit;
break;
}
/* XXX FIXME: eliminate obsolete getpass() usage */
passPhrase = getpass(_("Enter pass phrase: "));
passPhrase = (passPhrase != NULL) ? rstrdup(passPhrase) : NULL;
if (checkPassPhrase(passPhrase) == 0) {
fprintf(stderr, _("Pass phrase is good.\n"));
rc = rpmcliSign(args, 0, sigTag, passPhrase);
rc = rpmcliSign(args, 0, passPhrase);
} else {
fprintf(stderr, _("Pass phrase check failed\n"));
}
@ -174,7 +139,7 @@ int main(int argc, char *argv[])
ec = doSign(args);
break;
case MODE_DELSIGN:
ec = rpmcliSign(args, 1, 0, NULL);
ec = rpmcliSign(args, 1, NULL);
break;
default:
argerror(_("only one major mode may be specified"));