From: Panu Matilainen Date: Wed, 13 Oct 2010 10:11:54 +0000 (+0300) Subject: Add beginnings of a real API to librpmsign X-Git-Tag: rpm-4.9.0-beta1~208 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4816d8819343677f810816ca1ef3ff66d8086e9;p=platform%2Fupstream%2Frpm.git Add beginnings of a real API to librpmsign --- diff --git a/lib/rpmgensig.c b/lib/rpmgensig.c index 88946e5..aa0fb7f 100644 --- a/lib/rpmgensig.c +++ b/lib/rpmgensig.c @@ -608,6 +608,29 @@ exit: return res; } +int rpmPkgSign(const char *path, + const struct rpmSignArgs * args, const char *passPhrase) +{ + int rc; + + if (args && args->keyid) { + addMacro(NULL, "_gpg_name", NULL, args->keyid, RMIL_GLOBAL); + } + + rc = rpmSign(path, 0, passPhrase); + + if (args && args->keyid) { + delMacro(NULL, "_gpg_name"); + } + + return rc; +} + +int rpmPkgDelSign(const char *path) +{ + return rpmSign(path, 1, NULL); +} + int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase) { int res = 0; diff --git a/lib/rpmsign.h b/lib/rpmsign.h index f961b19..43b9654 100644 --- a/lib/rpmsign.h +++ b/lib/rpmsign.h @@ -2,6 +2,7 @@ #define _RPMSIGN_H #include +#include #ifdef __cplusplus extern "C" { @@ -16,6 +17,29 @@ extern "C" { */ int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase); +struct rpmSignArgs { + char *keyid; + pgpHashAlgo hashalgo; + /* ... what else? */ +}; + +/** \ingroup rpmsign + * Sign a package + * @param path path to package + * @param args signing parameters (or NULL for defaults) + * @param passphrase passphrase for the signing key + * @return 0 on success + */ +int rpmPkgSign(const char *path, + const struct rpmSignArgs * args, const char *passPhrase); + +/** \ingroup rpmsign + * Delete signature(s) from a package + * @param path path to package + * @return 0 on success + */ +int rpmPkgDelSign(const char *path); + #ifdef __cplusplus } #endif