]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Implement verify step which verifies the downloaded archive
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 16:09:28 +0000 (17:09 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 16:14:03 +0000 (17:14 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/package.h
src/libpakfire/step.c

index b6835146c8235b862fa1e9aa0d86fc7910fc91e3..f53657291a1d1c62e1dfacf198b3965189498b69 100644 (file)
@@ -108,6 +108,8 @@ char* pakfire_package_get_location(PakfirePackage pkg);
 
 char* pakfire_package_dump(PakfirePackage pkg, int flags);
 
+PakfireArchive pakfire_package_get_archive(PakfirePackage pkg);
+
 int pakfire_package_is_cached(PakfirePackage pkg);
 char* pakfire_package_get_cache_path(PakfirePackage pkg);
 char* pakfire_package_get_cache_full_path(PakfirePackage pkg);
index 66e8f140464718ad5ca9d39941cc2666a1dd9094..108493a4b0fc46a8719ba5d742190f682cd500ba 100644 (file)
@@ -23,6 +23,7 @@
 #include <solv/pooltypes.h>
 #include <solv/transaction.h>
 
+#include <pakfire/archive.h>
 #include <pakfire/constants.h>
 #include <pakfire/logging.h>
 #include <pakfire/package.h>
@@ -217,9 +218,26 @@ static int pakfire_step_verify(PakfireStep step) {
        if (pakfire_step_needs_download(step))
                return 1;
 
-       // TODO verify package and signature
+       // Fetch the archive
+       PakfireArchive archive = pakfire_package_get_archive(step->package);
+       if (!archive) {
+               char* nevra = pakfire_package_get_nevra(step->package);
+               char* cache_path = pakfire_package_get_cache_path(step->package);
 
-       return 0;
+               ERROR("Could not open package archive for %s: %s\n", nevra, cache_path);
+
+               pakfire_free(nevra);
+               pakfire_free(cache_path);
+
+               return -1;
+       }
+
+       // Verify the archive
+       pakfire_archive_verify_status_t status = pakfire_archive_verify(archive);
+
+       pakfire_archive_unref(archive);
+
+       return status;
 }
 
 static int pakfire_step_run_script(PakfireStep step, pakfire_script_type script) {