libopkg: add some checks for NULL strings
[oweals/opkg-lede.git] / libopkg / opkg_cmd.c
index 2aab669cde642892a721b9fcc39cbb2123228591..42443a50d6748b9b9a9161bf1d5c1d5c86a40985 100644 (file)
@@ -1,4 +1,4 @@
-/* opkg_cmd.c - the itsy package management system
+/* opkg_cmd.c - the opkg package management system
 
    Carl D. Worth
 
    General Public License for more details.
 */
 
-#include <string.h>
 
-#include "opkg.h"
-#include <libgen.h>
-#include <glob.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
+#include "includes.h"
 #include <dirent.h>
+#include <glob.h>
 
 #include "opkg_conf.h"
 #include "opkg_cmd.h"
@@ -38,6 +31,8 @@
 #include "file_util.h"
 #include "str_util.h"
 #include "libbb/libbb.h"
+#include "opkg_utils.h"
+#include "opkg_defines.h"
 
 #include <fnmatch.h>
 
@@ -257,6 +252,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
          }
          free(url);
 
+#ifdef HAVE_GPGME
          /* download detached signitures to verify the package lists */
          /* get the url for the sig file */
          if (src->extra_data)  /* debian style? */
@@ -276,7 +272,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
                opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
          } else {
            int err;
-           err = opkg_verify_file (list_file_name, tmp_file_name);
+           err = opkg_verify_file (conf, list_file_name, tmp_file_name);
            if (err == 0)
                opkg_message (conf, OPKG_NOTICE, "Signature check passed\n");
            else
@@ -284,41 +280,17 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
          }
          unlink (tmp_file_name);
          free (tmp_file_name);
-
          free (url);
+#else
+         opkg_message (conf, OPKG_NOTICE, "Signiture check for %s skipped "
+              "because GPG support was not enabled in this build\n", src->name);
+#endif
          free(list_file_name);
      }
      rmdir (tmp);
      free (tmp);
      free(lists_dir);
 
-#ifdef CONFIG_CLEAR_SW_INSTALL_FLAG
-#warning here
-     /* clear SW_INSTALL on any package where state is SS_NOT_INSTALLED.
-      * this is a hack to work around poor bookkeeping in old opkg upgrade code 
-      * -Jamey 3/1/03
-      */
-     {
-         int i;
-         int changed = 0;
-         pkg_vec_t *available = pkg_vec_alloc();
-         pkg_hash_fetch_available(&conf->pkg_hash, available);
-         opkg_message(conf, OPKG_DEBUG, "Clearing SW_INSTALL for SS_NOT_INSTALLED packages.\n");
-         for (i = 0; i < available->len; i++) {
-              pkg_t *pkg = available->pkgs[i];
-              if (pkg->state_want == SW_INSTALL && pkg->state_status == SS_NOT_INSTALLED) {
-                   opkg_message(conf, OPKG_DEBUG, "Clearing SW_INSTALL on package %s.\n", pkg->name);
-                   pkg->state_want = SW_UNKNOWN;
-                   changed = 1;
-              }
-         }
-         pkg_vec_free(available);
-         if (changed) {
-              write_status_files_if_changed(conf);
-         }
-     }
-#endif
-
      return failures;
 }