cli: implement --force-checksum
[oweals/opkg-lede.git] / libopkg / opkg_install.c
index 74a2ce115a62e8496baaa2d3af1c3e57890f1705..2c61a5fccd7b12f8d1598098030aaa702cf1b792 100644 (file)
@@ -274,6 +274,7 @@ unpack_pkg_control_files(pkg_t *pkg)
      while (1) {
          char *cf_name;
          char *cf_name_in_dest;
+         int i;
 
          cf_name = file_read_line_alloc(conffiles_file);
          if (cf_name == NULL) {
@@ -282,6 +283,12 @@ unpack_pkg_control_files(pkg_t *pkg)
          if (cf_name[0] == '\0') {
               continue;
          }
+         for (i = strlen(cf_name) - 1;
+              (i >= 0) && (cf_name[i] == ' ' || cf_name[i] == '\t');
+              i--
+         ) {
+              cf_name[i] = '\0';
+         }
 
          /* Prepend dest->root_dir to conffile name.
             Take pains to avoid multiple slashes. */
@@ -1320,12 +1327,19 @@ opkg_install_pkg(pkg_t *pkg, int from_upgrade)
          file_md5 = file_md5sum_alloc(pkg->local_filename);
          if (file_md5 && strcmp(file_md5, pkg->md5sum))
          {
-              opkg_msg(ERROR, "Package %s md5sum mismatch. "
-                       "Either the opkg or the package index are corrupt. "
-                       "Try 'opkg update'.\n",
-                       pkg->name);
-              free(file_md5);
-              return -1;
+              if (!conf->force_checksum)
+              {
+                  opkg_msg(ERROR, "Package %s md5sum mismatch. "
+                           "Either the opkg or the package index are corrupt. "
+                           "Try 'opkg update'.\n",
+                           pkg->name);
+                  free(file_md5);
+                  return -1;
+              }
+              else
+              {
+                  opkg_msg(NOTICE, "Ignored %s md5sum mismatch.\n", pkg->name);
+              }
          }
         if (file_md5)
               free(file_md5);