opkg: fix gpg enabled builds and fix one compiler warning
[oweals/opkg-lede.git] / opkg_download.c
index c3fa44cc209a38adc9c0a12ff8da812c636eb235..bbd6efef868bf9deab58b6a58e703df96bd807d2 100644 (file)
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.
 */
-
+#include "config.h"
 #include <curl/curl.h>
+#ifdef HAVE_GPGME
 #include <gpgme.h>
+#endif
 
 #include "opkg.h"
 #include "opkg_download.h"
 #include "opkg_message.h"
+#include "opkg_state.h"
 
 #include "sprintf_alloc.h"
 #include "xsystem.h"
@@ -201,6 +204,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
 {
     int err;
     char *url;
+    char *pkgid;
 
     if (pkg->src == NULL) {
        opkg_message(conf,OPKG_ERROR, "ERROR: Package %s (parent %s) is not available from any configured src.\n",
@@ -208,6 +212,10 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
        return -1;
     }
 
+    sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture);
+    opkg_set_current_state (OPKG_STATE_DOWNLOADING_PKG, pkgid);
+    free (pkgid);
+
     sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
 
     /* XXX: BUG: The pkg->filename might be something like
@@ -219,6 +227,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
     err = opkg_download(conf, url, pkg->local_filename);
     free(url);
 
+    opkg_set_current_state (OPKG_STATE_NONE, NULL);
     return err;
 }
 
@@ -290,6 +299,7 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name
 int
 opkg_verify_file (char *text_file, char *sig_file)
 {
+#ifdef HAVE_GPGME
     int status = -1;
     gpgme_ctx_t ctx;
     gpgme_data_t sig, text;
@@ -329,4 +339,8 @@ opkg_verify_file (char *text_file, char *sig_file)
     gpgme_release (ctx);
 
     return status;
+#else
+    printf ("Signature check skipped because GPG support was not enabled in this build\n");
+    return 0;
+#endif
 }