]> pd.if.org Git - zpackage/blobdiff - lib/integ.c
add dependencies to package hash
[zpackage] / lib / integ.c
index 6abfcf340cff7087ea82a75c9e83cffd215fa130..13a2505bf53b7bf5b1454392c0885a8c279777d7 100644 (file)
@@ -127,6 +127,10 @@ static void hash_query(struct zpm *zpm, const char *zSql, struct sha256_state *h
                                        hash_byte(h, 'B');
                                        hash_int(h, bytes);
                                        break;
+                               default:
+                                       hash_byte(h, 'U');
+                                       continue;
+                                       break;
                        }
                        sha256_process(h, data, bytes);
                }
@@ -144,9 +148,10 @@ int zpm_package_hash(struct zpm *zpm, char *pkgid, char *hash) {
                return 0;
        }
 
-       sha256_init(&d);
        /* find package */
 
+       sha256_init(&d);
+
        sql = sqlite3_mprintf("select package,version,release,description,architecture,url,licenses,packager,build_time from packages_pkgid where pkgid = %Q", pkgid);
 
        hash_query(zpm, sql, &d);
@@ -155,12 +160,20 @@ int zpm_package_hash(struct zpm *zpm, char *pkgid, char *hash) {
        /* hash package files */
 
        sql = sqlite3_mprintf("select path, mode, username, groupname, configuration, "
-               "filetype, target, devmajor, devminor, mtime, hash "
+               "filetype, target, device, mtime, hash "
                "from packagefiles_pkgid where pkgid = %Q order by path",
                pkgid);
        hash_query(zpm, sql, &d);
        sqlite3_free(sql);
 
+       /* package dependencies */
+       sql = sqlite3_mprintf("dselect requires from packagedeps"
+               " where printf('%%q-%%q-%%d',package,version,release) = %Q"
+              "order by requires",
+               pkgid);
+       hash_query(zpm, sql, &d);
+       sqlite3_free(sql);
+
        sha256_done(&d, tmp);
        for (i=0; i<32; i++) {
                sprintf(hash+i*2, "%02x", (unsigned)tmp[i]);
@@ -168,7 +181,6 @@ int zpm_package_hash(struct zpm *zpm, char *pkgid, char *hash) {
        hash[64] = 0;
 
        return 1;
-
 }
 
 int zpm_package_sethash(struct zpm *zpm, char *pkgid, char *hash) {