distroquery: add 'required by' entries in package page
This commit is contained in:
parent
95d368a12a
commit
80dfdb190c
@ -597,21 +597,33 @@ void printPackageData() {
|
|||||||
sqlite3_stmt *statement, *stmt1, *stmt2;
|
sqlite3_stmt *statement, *stmt1, *stmt2;
|
||||||
char sql[PATH_MAX];
|
char sql[PATH_MAX];
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
|
char *errmsg;
|
||||||
struct configTag* ct = findRepositoryByTag(query_repository);
|
struct configTag* ct = findRepositoryByTag(query_repository);
|
||||||
humanDate strdate;
|
humanDate strdate;
|
||||||
sizeString strsize;
|
sizeString strsize;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
int query_arch_num = find_query_arch(query_arch);
|
||||||
|
|
||||||
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, query_arch);
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, query_arch);
|
||||||
if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READONLY, NULL)) {
|
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
|
||||||
if (db) sqlite3_close(db);
|
if (db) sqlite3_close(db);
|
||||||
db = NULL;
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
|
||||||
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
while (ct->repository[i]) {
|
||||||
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository[i]->repository_dir, ct->repository[i]->tag, query_arch);
|
||||||
|
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s'", dbname, ct->repository[i]->tag);
|
||||||
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
||||||
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
||||||
|
|
||||||
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE name = '%s'", query_package);
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE name = '%s'", query_package);
|
||||||
if (db &&
|
if (db &&
|
||||||
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
||||||
@ -704,6 +716,7 @@ void printPackageData() {
|
|||||||
printf("<br>%s: %s", _("Build date"),
|
printf("<br>%s: %s", _("Build date"),
|
||||||
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
|
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
|
||||||
|
|
||||||
|
/* obsoletes */
|
||||||
printf("<br><br>%s:", _("Obsoletes"));
|
printf("<br><br>%s:", _("Obsoletes"));
|
||||||
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
|
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
|
||||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||||
@ -718,6 +731,8 @@ void printPackageData() {
|
|||||||
}
|
}
|
||||||
sqlite3_finalize(stmt1);
|
sqlite3_finalize(stmt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* provides */
|
||||||
printf("<br><br>%s:",_("Provides"));
|
printf("<br><br>%s:",_("Provides"));
|
||||||
snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided "
|
snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided "
|
||||||
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
||||||
@ -733,6 +748,8 @@ void printPackageData() {
|
|||||||
}
|
}
|
||||||
sqlite3_finalize(stmt1);
|
sqlite3_finalize(stmt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* requires */
|
||||||
printf("<br><br>%s:", _("Requires"));
|
printf("<br><br>%s:", _("Requires"));
|
||||||
snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided "
|
snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided "
|
||||||
"WHERE requires.id_package=%d AND provided.id=requires.id_provided "
|
"WHERE requires.id_package=%d AND provided.id=requires.id_provided "
|
||||||
@ -749,6 +766,36 @@ void printPackageData() {
|
|||||||
sqlite3_finalize(stmt1);
|
sqlite3_finalize(stmt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* required by */
|
||||||
|
i=0;
|
||||||
|
while (ct->repository[i]) {
|
||||||
|
snprintf(sql, PATH_MAX,
|
||||||
|
"SELECT * FROM '%s'.packages AS packagesup,'%s'.requires AS requiresup,"
|
||||||
|
"'%s'.provided AS providedup,provided,provides "
|
||||||
|
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
||||||
|
"AND packagesup.id=requiresup.id_package "
|
||||||
|
"AND requiresup.id_provided=providedup.id "
|
||||||
|
"AND providedup.name=provided.name "
|
||||||
|
"AND NOT packagesup.name='%s' "
|
||||||
|
"GROUP BY packagesup.name "
|
||||||
|
"ORDER BY packagesup.name",
|
||||||
|
ct->repository[i]->tag, ct->repository[i]->tag, ct->repository[i]->tag,
|
||||||
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")), query_package);
|
||||||
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||||
|
j=0;
|
||||||
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||||
|
if (j++ == 0) printf("<br><br>%s %s %s:",_("Required in"),ct->repository[i]->tag,_("by"));
|
||||||
|
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s</a>",
|
||||||
|
ct->repository[i]->tag,
|
||||||
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
||||||
|
query_arch,
|
||||||
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
||||||
|
}
|
||||||
|
sqlite3_finalize(stmt1);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
/* files list */
|
/* files list */
|
||||||
snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", ct->repository_dir, ct->tag, query_arch);
|
snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", ct->repository_dir, ct->tag, query_arch);
|
||||||
if (!sqlite3_open_v2(dbname, &dbf, SQLITE_OPEN_READONLY, NULL)) {
|
if (!sqlite3_open_v2(dbname, &dbf, SQLITE_OPEN_READONLY, NULL)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user