2013-10-07 02:36:11 +02:00
|
|
|
/*
|
|
|
|
* distroquery - tool for querying data generated by distromatic
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of version 2 of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY, to the extent permitted by law; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
#include <libintl.h>
|
|
|
|
#include <locale.h>
|
|
|
|
#define _(x) gettext(x)
|
|
|
|
|
2013-10-07 02:36:11 +02:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#if HAVE_STRING_H
|
|
|
|
# if !STDC_HEADERS && HAVE_MEMORY_H
|
|
|
|
# include <memory.h>
|
|
|
|
# endif
|
|
|
|
/* Tell glibc's <string.h> to provide a prototype for strndup() */
|
|
|
|
# ifndef __USE_GNU
|
|
|
|
# define __USE_GNU
|
|
|
|
# endif
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Tell glibc's <time.h> to provide a prototype for strptime() */
|
|
|
|
#ifndef __USE_XOPEN
|
|
|
|
# define __USE_XOPEN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TIME_WITH_SYS_TIME
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <time.h>
|
|
|
|
#else
|
|
|
|
# if HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
# else
|
|
|
|
# include <time.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !HAVE_STRCHR
|
|
|
|
# define strchr index
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sqlite3.h>
|
|
|
|
#include "distromatic.h"
|
|
|
|
#include "functions.h"
|
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
// must be as big as ARCHS_MAX (5)
|
2013-10-15 11:40:22 +02:00
|
|
|
const char* ARCHS[ARCHS_MAX] = { "i586", "x86_64", "arm", "", "" };
|
2013-10-12 17:34:55 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
static struct configTag *firstconfigtag = NULL;
|
2013-10-14 00:03:07 +02:00
|
|
|
char *query = "";
|
2013-10-09 11:28:17 +02:00
|
|
|
char *query_package;
|
2013-10-20 22:16:25 +02:00
|
|
|
char *query_repository = "milestone2";
|
2013-10-21 14:33:37 +02:00
|
|
|
char *query_arch = NULL;
|
2013-10-20 03:20:01 +02:00
|
|
|
int query_compact = 0;
|
2013-10-15 00:12:47 +02:00
|
|
|
int query_limit = 10;
|
|
|
|
int query_offset = 0;
|
|
|
|
char query_next[PATH_MAX] = "";
|
2013-10-17 02:29:56 +02:00
|
|
|
char *reply_xmltag = "queryreply";
|
|
|
|
int reply_plain = 0;
|
2013-10-14 01:47:12 +02:00
|
|
|
char *lang = "";
|
2013-10-14 00:03:07 +02:00
|
|
|
int query_archs[ARCHS_MAX] = { 1, 0, 0, 0, 0 };
|
2013-10-21 21:48:37 +02:00
|
|
|
char *query_path = NULL;
|
2013-10-12 17:34:55 +02:00
|
|
|
|
2013-10-07 18:14:53 +02:00
|
|
|
struct configTag *query_repositories[100];
|
2013-10-07 22:21:36 +02:00
|
|
|
|
2013-10-07 18:14:53 +02:00
|
|
|
int search_milestone1 = 0, search_milestone2 = 1, search_devel = 1;
|
2013-10-14 00:03:07 +02:00
|
|
|
int search_sources = 0, searchbox = 0;
|
2013-10-15 11:40:22 +02:00
|
|
|
int search_files = 0;
|
2013-10-07 02:36:11 +02:00
|
|
|
|
2013-10-09 11:28:17 +02:00
|
|
|
/* Converts a hex character to its integer value */
|
|
|
|
char from_hex(char ch) {
|
|
|
|
return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Converts an integer value to its hex character*/
|
|
|
|
char to_hex(char code) {
|
|
|
|
static char hex[] = "0123456789abcdef";
|
|
|
|
return hex[code & 15];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns a url-encoded version of str */
|
|
|
|
/* IMPORTANT: be sure to free() the returned string after use */
|
|
|
|
char *url_encode(char *str) {
|
|
|
|
char *pstr = str, *buf = malloc(strlen(str) * 3 + 1), *pbuf = buf;
|
|
|
|
while (*pstr) {
|
|
|
|
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
|
|
|
|
*pbuf++ = *pstr;
|
|
|
|
else if (*pstr == ' ')
|
|
|
|
*pbuf++ = '+';
|
|
|
|
else
|
|
|
|
*pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
|
|
|
|
pstr++;
|
|
|
|
}
|
|
|
|
*pbuf = '\0';
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns a url-decoded version of str */
|
|
|
|
/* IMPORTANT: be sure to free() the returned string after use */
|
|
|
|
char *url_decode(char *str) {
|
2013-10-25 15:10:18 +02:00
|
|
|
if (!str) { char *buf=malloc(1); buf[0]=0; return buf; }
|
2013-10-09 11:28:17 +02:00
|
|
|
char *pstr = str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
|
|
|
|
while (*pstr) {
|
|
|
|
if (*pstr == '%') {
|
|
|
|
if (pstr[1] && pstr[2]) {
|
|
|
|
*pbuf++ = from_hex(pstr[1]) << 4 | from_hex(pstr[2]);
|
|
|
|
pstr += 2;
|
|
|
|
}
|
|
|
|
} else if (*pstr == '+') {
|
|
|
|
*pbuf++ = ' ';
|
|
|
|
} else {
|
|
|
|
*pbuf++ = *pstr;
|
|
|
|
}
|
|
|
|
pstr++;
|
|
|
|
}
|
|
|
|
*pbuf = '\0';
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2013-10-12 22:00:43 +02:00
|
|
|
int sqlite3_find_column_id(sqlite3_stmt *stmt, const char* table, const char* name) {
|
|
|
|
const char* colname;
|
|
|
|
int id = 0;
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
while ((colname = sqlite3_column_name(stmt, id))) {
|
2013-10-12 22:00:43 +02:00
|
|
|
if (!strcmp(colname, name)) {
|
|
|
|
if (table) {
|
|
|
|
if (!strcmp(sqlite3_column_table_name(stmt, id), table)) return id;
|
|
|
|
} else {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int find_query_arch(char* arch) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARCHS_MAX; i++) {
|
|
|
|
if (!strcmp(arch, ARCHS[i]) && query_archs[i]) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-13 14:45:56 +02:00
|
|
|
void printRPMFlags(int flags) {
|
|
|
|
if (flags & RPMSENSE_LESS) printf("<");
|
|
|
|
if (flags & RPMSENSE_GREATER) printf(">");
|
|
|
|
if (flags & RPMSENSE_EQUAL) printf("=");
|
|
|
|
}
|
|
|
|
|
|
|
|
void printTagsLine(const char* arch, const char* tag, const char* group, const char* license) {
|
|
|
|
if (!arch)
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<div style='display:inline;color:white;background-color:red'> %s </div> ", _("Source"));
|
2013-10-13 14:45:56 +02:00
|
|
|
else
|
|
|
|
printf("<div style='display:inline;color:white;background-color:green'> %s </div> ", arch);
|
|
|
|
printf("<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
|
|
|
"<div style='display:inline;color:black;background-color:lightblue'> %s </div> "
|
|
|
|
"<div style='display:inline;color:black;background-color:orange'> %s </div>",
|
|
|
|
tag, group, license);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:24:04 +02:00
|
|
|
char* expandFileFlags(long flags, char *buffer) {
|
|
|
|
int special = flags >> 9 & 7;
|
|
|
|
int type = flags >> 12;
|
|
|
|
|
|
|
|
sprintf(buffer,"----------");
|
|
|
|
if (special & 1) buffer[9]='t'; else if (flags & 1<<6) buffer[9]='x';
|
|
|
|
if (flags & 1<<1) buffer[8]='w';
|
|
|
|
if (flags & 1<<2) buffer[7]='r';
|
|
|
|
if (special & 2) buffer[6]='s'; else if (flags & 1<<6) buffer[6]='x';
|
|
|
|
if (flags & 1<<4) buffer[5]='w';
|
|
|
|
if (flags & 1<<5) buffer[4]='r';
|
|
|
|
if (special & 4) buffer[3]='s'; else if (flags & 1<<6) buffer[3]='x';
|
|
|
|
if (flags & 1<<7) buffer[2]='w';
|
|
|
|
if (flags & 1<<8) buffer[1]='r';
|
|
|
|
if (type & 4) buffer[0]='d';
|
|
|
|
else if (type & 2) buffer[0]='l';
|
|
|
|
else if (type != 8) buffer[0] = (flags >> 12) + '0';
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2013-10-15 00:12:47 +02:00
|
|
|
char* resolveFilePath(sqlite3 *db, long id, char *buffer) {
|
|
|
|
|
|
|
|
long currid = id;
|
|
|
|
sqlite3_stmt *stmt;
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
buffer[0]='\0';
|
|
|
|
|
|
|
|
do {
|
2013-10-20 13:42:55 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM files WHERE id=%ld", currid);
|
2013-10-15 00:12:47 +02:00
|
|
|
if (!sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL) == SQLITE_OK) return NULL;
|
|
|
|
if (sqlite3_step(stmt) != SQLITE_ROW) return NULL;
|
|
|
|
snprintf(sql, PATH_MAX, "/%s%s", sqlite3_column_text(stmt,1), buffer);
|
|
|
|
snprintf(buffer, PATH_MAX, "%s", sql);
|
|
|
|
currid = sqlite3_column_int(stmt,4); /* parent */
|
|
|
|
} while (currid >= 0);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
sqlite3* openRepositoryDatabase(struct configTag* ct, char* arch) {
|
|
|
|
char dbname[PATH_MAX];
|
|
|
|
sqlite3* db;
|
|
|
|
|
|
|
|
if (arch) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, arch);
|
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
if (db) sqlite3_close(db);
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
if (db) sqlite3_close(db);
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return db;
|
|
|
|
}
|
|
|
|
|
2013-10-20 22:16:25 +02:00
|
|
|
void attachCtDatabases(struct configTag* ct, sqlite3 *db, char* arch) {
|
|
|
|
char dbname[PATH_MAX];
|
|
|
|
int i=0;
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char *errmsg;
|
|
|
|
|
|
|
|
while (ct->repository[i]) {
|
2013-10-25 15:10:18 +02:00
|
|
|
if (arch) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository[i]->repository_dir, ct->repository[i]->tag, arch);
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s_%s'", dbname, ct->repository[i]->tag, arch);
|
2013-10-25 15:10:18 +02:00
|
|
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
|
|
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository[i]->repository_dir, ct->repository[i]->tag);
|
|
|
|
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s_sources'", 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);
|
|
|
|
}
|
2013-10-22 11:54:03 +02:00
|
|
|
}
|
2013-10-20 22:16:25 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
void attachRepositoryDatabases(struct configTag* ct, sqlite3 *db, char* arch, int source) {
|
2013-10-22 17:37:37 +02:00
|
|
|
char dbname[PATH_MAX];
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char *errmsg;
|
|
|
|
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, arch);
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s_%s'", dbname, ct->tag, arch);
|
2013-10-22 17:37:37 +02:00
|
|
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
|
|
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
|
|
|
}
|
2013-10-27 19:26:29 +01:00
|
|
|
if (source) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
|
|
|
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s_sources'", dbname, ct->tag);
|
|
|
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
|
|
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
|
|
|
}
|
2013-10-22 17:37:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
void detachRepositoryDatabases(struct configTag* ct, sqlite3 *db, char* arch, int source) {
|
2013-10-22 17:37:37 +02:00
|
|
|
char sql[PATH_MAX];
|
|
|
|
char *errmsg;
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(sql, PATH_MAX, "DETACH DATABASE '%s_%s'", ct->tag, arch);
|
2013-10-22 17:37:37 +02:00
|
|
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
|
|
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
|
|
|
}
|
2013-10-27 19:26:29 +01:00
|
|
|
if (source) {
|
|
|
|
snprintf(sql, PATH_MAX, "DETACH DATABASE '%s_sources'", ct->tag);
|
|
|
|
if (sqlite3_exec(db, sql, NULL, NULL, &errmsg)) {
|
|
|
|
fprintf(stderr, "ERROR: unable to exec statement for %s: %s\n", sql, errmsg);
|
|
|
|
}
|
2013-10-22 17:37:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-09 11:28:17 +02:00
|
|
|
void printInputForm() {
|
2013-10-07 02:36:11 +02:00
|
|
|
struct configTag *ct = firstconfigtag;
|
|
|
|
|
2013-10-09 11:28:17 +02:00
|
|
|
const char ajax_call[] = "distroquery_request("
|
2013-10-07 18:14:53 +02:00
|
|
|
// "'repository='+getElementById('repository').value"
|
|
|
|
"'query='+getElementById('query').value+"
|
|
|
|
"'&search_devel='+getElementById('search_devel').checked+"
|
|
|
|
"'&search_milestone2='+getElementById('search_milestone2').checked+"
|
2013-10-07 22:21:36 +02:00
|
|
|
"'&search_milestone1='+getElementById('search_milestone1').checked+"
|
|
|
|
"'&search_i586='+getElementById('search_i586').checked+"
|
|
|
|
"'&search_x86_64='+getElementById('search_x86_64').checked+"
|
|
|
|
"'&search_arm='+getElementById('search_arm').checked+"
|
2013-10-15 11:40:22 +02:00
|
|
|
"'&search_sources='+getElementById('search_sources').checked+"
|
|
|
|
"'&search_files='+getElementById('search_files').checked"
|
2013-10-07 18:14:53 +02:00
|
|
|
")";
|
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("<queryform><![CDATA[");
|
2013-10-14 00:03:07 +02:00
|
|
|
printf("<input id=query onkeyup=if(checkMinLength(this.value,3))%s value=\"%s\">", ajax_call, query);
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<button onclick=%s>%s</button>", ajax_call, _("Search"));
|
2013-10-07 18:14:53 +02:00
|
|
|
/* printf(" Repository: <select id=repository>");
|
2013-10-07 02:36:11 +02:00
|
|
|
while (ct) {
|
|
|
|
printf("<option>%s</option>",ct->tag);
|
|
|
|
ct = ct->next;
|
2013-10-07 22:21:36 +02:00
|
|
|
}
|
|
|
|
printf("</select>");*/
|
2013-10-14 00:03:07 +02:00
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_devel\" ");
|
|
|
|
if (search_devel) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>devel ", ajax_call);
|
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_milestone2\" ");
|
|
|
|
if (search_milestone2) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>milestone2 ", ajax_call);
|
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_milestone1\" ");
|
|
|
|
if (search_milestone1) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>milestone1 ", ajax_call);
|
|
|
|
|
|
|
|
printf(" <input type=checkbox id=\"search_i586\" ");
|
|
|
|
if (query_archs[0]) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>i586 ", ajax_call);
|
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_x86_64\" ");
|
|
|
|
if (query_archs[1]) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>x86_64 ", ajax_call);
|
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_arm\" ");
|
|
|
|
if (query_archs[2]) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>arm ", ajax_call);
|
|
|
|
|
|
|
|
printf("<input type=checkbox id=\"search_sources\" ");
|
|
|
|
if (search_sources) printf("checked=checked ");
|
2013-10-14 03:04:16 +02:00
|
|
|
printf("onclick=%s>%s ", ajax_call, _("sources"));
|
2013-10-14 00:03:07 +02:00
|
|
|
|
2013-10-15 11:40:22 +02:00
|
|
|
printf("<input type=checkbox id=\"search_files\" ");
|
|
|
|
if (search_files) printf("checked=checked ");
|
|
|
|
printf("onclick=%s>%s ", ajax_call, _("files"));
|
|
|
|
|
2013-10-07 18:14:53 +02:00
|
|
|
printf("<br>");
|
|
|
|
/* ct = firstconfigtag;
|
|
|
|
while (ct) {
|
|
|
|
printf("<div width=150px style=\"display:inline\"><input name=\"%s\" type=checkbox value=\"%s\">%s</div>",ct->tag, ct->tag, ct->tag);
|
|
|
|
ct = ct->next;
|
|
|
|
}*/
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("]]></queryform>");
|
|
|
|
if (!reply_plain) {
|
|
|
|
printf("<title><![CDATA[");
|
|
|
|
printf("%s :: %s", _("Search software packages"), ct->configdefaults->distribution_name);
|
|
|
|
printf("]]></title>");
|
|
|
|
}
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
|
|
|
|
2013-10-21 21:48:37 +02:00
|
|
|
int findFileIdFromPath(sqlite3 *db, char** path) {
|
2013-10-20 22:16:25 +02:00
|
|
|
int frompos = 1, topos;
|
|
|
|
int parent = -1;
|
|
|
|
char* pt;
|
|
|
|
char buffer[PATH_MAX];
|
|
|
|
char sql[PATH_MAX];
|
2013-10-21 21:48:37 +02:00
|
|
|
char* linkpath = calloc(strlen(*path),0);
|
2013-10-20 22:16:25 +02:00
|
|
|
sqlite3_stmt* stmt1;
|
|
|
|
|
2013-10-21 21:48:37 +02:00
|
|
|
printf("[<a href='javascript:distroquery_request(\"repository=%s&arch=%s&path=/\")'>ROOT</a>]",
|
2013-10-20 22:16:25 +02:00
|
|
|
query_repository, query_arch);
|
2013-10-21 21:48:37 +02:00
|
|
|
while (frompos < strlen(*path)) {
|
|
|
|
pt = strchr(*path + frompos, '/');
|
|
|
|
if (pt) topos = pt - *path; else topos = strlen(*path);
|
|
|
|
strncpy(buffer, *path + frompos, topos - frompos);
|
|
|
|
buffer[topos-frompos]=0;
|
2013-10-20 22:16:25 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT id FROM files WHERE parent=%d"
|
|
|
|
" AND name='%s'", parent, buffer);
|
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK && sqlite3_step(stmt1) == SQLITE_ROW) {
|
|
|
|
parent = sqlite3_column_int(stmt1,0);
|
|
|
|
sqlite3_finalize(stmt1);
|
2013-10-21 21:48:37 +02:00
|
|
|
strcat(linkpath, "/");
|
|
|
|
strncat(linkpath, buffer, strlen(*path) - strlen(linkpath));
|
|
|
|
printf("/<a href='javascript:distroquery_request(\"repository=%s&arch=%s&path=%s\")'>%s</a>",
|
|
|
|
query_repository, query_arch, linkpath, buffer);
|
2013-10-20 22:16:25 +02:00
|
|
|
}
|
|
|
|
frompos = topos + 1;
|
|
|
|
}
|
2013-10-21 21:48:37 +02:00
|
|
|
/* return clean path */
|
|
|
|
//free(path);
|
|
|
|
*path = linkpath;
|
2013-10-20 22:16:25 +02:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
void printFileBrowser() {
|
2013-10-20 22:16:25 +02:00
|
|
|
char dbname[PATH_MAX];
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
sqlite3 *dbf;
|
|
|
|
sqlite3_stmt *stmt1, *stmt2;
|
|
|
|
int flags, cnt, startid;
|
|
|
|
struct configTag* ct = findRepositoryByTag(query_repository);
|
2013-10-07 02:36:11 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
if (!query_arch) query_arch=strdup(ARCHS[0]);
|
2013-10-20 22:16:25 +02:00
|
|
|
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)) {
|
2013-10-21 21:48:37 +02:00
|
|
|
startid = findFileIdFromPath(dbf, &query_path);
|
2013-10-20 22:16:25 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM files WHERE"
|
|
|
|
" parent=%d"
|
|
|
|
" ORDER BY name", startid);
|
|
|
|
printf("<table>");
|
|
|
|
if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages_files_rel,fileusers,filegroups WHERE"
|
|
|
|
" packages_files_rel.id_file=%d AND"
|
|
|
|
" packages_files_rel.id_user=fileusers.id AND "
|
|
|
|
" packages_files_rel.id_group=filegroups.id",
|
|
|
|
sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id")));
|
|
|
|
cnt = 0;
|
|
|
|
if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt2, NULL) == SQLITE_OK) {
|
|
|
|
if (sqlite3_step(stmt2) == SQLITE_ROW) {
|
|
|
|
cnt++;
|
|
|
|
flags = sqlite3_column_int(stmt2,sqlite3_find_column_id(stmt2, "packages_files_rel", "flags"));
|
|
|
|
if (flags >> 12 & 4) {
|
|
|
|
printf("<tr><td style=\"font-family:courier\">%s</td><td style=\"font-family:courier\">%s</td>"
|
|
|
|
"<td style=\"font-family:courier\">%s</td>"
|
|
|
|
"<td width=50%% style=\"font-family:courier\">"
|
2013-10-21 21:48:37 +02:00
|
|
|
"<a href='javascript:distroquery_request(\"repository=%s&arch=%s&path=%s/%s\")'>%s</a></td>",
|
2013-10-20 22:16:25 +02:00
|
|
|
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "fileusers", "name")),
|
|
|
|
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "filegroups", "name")),
|
|
|
|
expandFileFlags(flags, sql),
|
|
|
|
query_repository,
|
|
|
|
query_arch,
|
2013-10-21 21:48:37 +02:00
|
|
|
query_path,
|
2013-10-20 22:16:25 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
|
|
|
} else {
|
|
|
|
printf("<tr><td style=\"font-family:courier\">%s</td><td style=\"font-family:courier\">%s</td>"
|
|
|
|
"<td style=\"font-family:courier\">%s</td><td width=50%% style=\"font-family:courier\">%s</td>",
|
|
|
|
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "fileusers", "name")),
|
|
|
|
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "filegroups", "name")),
|
|
|
|
expandFileFlags(flags, sql),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
|
|
|
}
|
|
|
|
printf("<td nowrap>%s: %s", _("Provider(s)"), sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "packages_files_rel", "name")));
|
|
|
|
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
|
|
|
printf(" %s", sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "packages_files_rel", "name")));
|
|
|
|
}
|
|
|
|
printf("</td></tr>");
|
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt2);
|
|
|
|
}
|
|
|
|
if (cnt == 0) {
|
|
|
|
printf("<tr><td></td><td></td><td></td>"
|
2013-10-21 21:48:37 +02:00
|
|
|
"<td width=50%% style=\"font-family:courier\"><a href='javascript:distroquery_request(\"repository=%s&arch=%s&path=%s/%s\")'>%s</a></td>"
|
2013-10-20 22:16:25 +02:00
|
|
|
"<td></td></tr>",
|
|
|
|
query_repository,
|
|
|
|
query_arch,
|
2013-10-21 21:48:37 +02:00
|
|
|
query_path,
|
2013-10-20 22:16:25 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
|
|
|
sqlite3_close(dbf);
|
|
|
|
printf("</table>");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reply_plain) printf("]]></%s>", reply_xmltag);
|
|
|
|
|
|
|
|
if (!reply_plain) printf("<querystatus><![CDATA[ ]]></querystatus>");
|
2013-10-20 13:42:55 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
int packageVerCmp(int e1, const char* v1, const char* r1, int e2, const char* v2, const char* r2) {
|
|
|
|
int vcmp = rpmvercmp(v1,v2);
|
|
|
|
int rcmp = rpmvercmp(r1,r2);
|
|
|
|
|
|
|
|
if ((e1 > e2) ||
|
|
|
|
((e1 == e2) && (vcmp > 0)) ||
|
|
|
|
((e1 == e2) && (vcmp == 0) && (rcmp >= 0)))
|
|
|
|
return 1;
|
|
|
|
else if ((e1 == e2) && (vcmp == 0) && (rcmp == 0))
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
void printQueryResponse() {
|
|
|
|
|
|
|
|
int a, i, j, k, numresults = 0, otherresults = 0, localresults = 0, localprovidesresults = 0, localsourceresults = 0;
|
2013-10-07 18:14:53 +02:00
|
|
|
char dbname[PATH_MAX];
|
2013-10-15 00:12:47 +02:00
|
|
|
sqlite3 *dbf;
|
2013-10-13 14:45:56 +02:00
|
|
|
sqlite3_stmt *statement, *stmt1;
|
2013-10-07 18:14:53 +02:00
|
|
|
char sql[PATH_MAX];
|
2013-10-13 14:45:56 +02:00
|
|
|
char buffer[PATH_MAX];
|
2013-10-14 00:03:07 +02:00
|
|
|
char queryenc[PATH_MAX];
|
2013-10-07 18:14:53 +02:00
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
2013-10-14 00:03:07 +02:00
|
|
|
strncpy(queryenc, query, PATH_MAX);
|
|
|
|
for (i = 0; i < strlen(queryenc); i++) {
|
|
|
|
if (queryenc[i] == ' ') queryenc[i] = '%';
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-20 13:42:55 +02:00
|
|
|
|
2013-10-07 18:14:53 +02:00
|
|
|
for (i = 0; query_repositories[i] != NULL; i++) {
|
|
|
|
for (a = 0; a < ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
|
2013-10-12 17:34:55 +02:00
|
|
|
if (find_query_arch(query_repositories[i]->arch[a]) >= 0) {
|
|
|
|
if (!query_repositories[i]->db[a]) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db",
|
|
|
|
query_repositories[i]->repository_dir, query_repositories[i]->tag, query_repositories[i]->arch[a]);
|
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[a], SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
if (query_repositories[i]->db) sqlite3_close(query_repositories[i]->db[a]);
|
|
|
|
query_repositories[i]->db[a] = NULL;
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
|
|
|
|
}
|
|
|
|
}
|
2013-10-13 14:45:56 +02:00
|
|
|
if (!query_repositories[i]->db[ARCHS_MAX]) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db",
|
|
|
|
query_repositories[i]->repository_dir, query_repositories[i]->tag);
|
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[ARCHS_MAX], SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
query_repositories[i]->db[ARCHS_MAX] = NULL;
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
if (query_repositories[i]->db[a]) {
|
2013-10-14 12:45:06 +02:00
|
|
|
localresults = 0;
|
2013-10-12 17:34:55 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM packages WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' OR version LIKE '%%%s%%' "
|
|
|
|
"ORDER BY name = '%s' DESC, name LIKE '%s%%' DESC, name LIKE '%%%s%%' DESC, "
|
|
|
|
"groupdescr LIKE 'Graphical Desktop/%%' DESC, groupdescr LIKE 'Applications/%%' DESC, "
|
|
|
|
"groupdescr LIKE 'Development/%%' ASC, groupdescr LIKE 'Documentation%%' ASC, groupdescr LIKE 'System/Libraries%%' ASC, "
|
|
|
|
"name LIKE '%%-devel' ASC, name LIKE '%%-debug' ASC "
|
2013-10-15 00:12:47 +02:00
|
|
|
"LIMIT %d OFFSET %d", queryenc, queryenc, queryenc, queryenc, queryenc, queryenc, queryenc, query_limit, query_offset);
|
2013-10-12 17:34:55 +02:00
|
|
|
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[a], sql, strlen(sql), &statement, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
|
numresults++;
|
2013-10-14 12:45:06 +02:00
|
|
|
localresults++;
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE id=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
|
|
|
|
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
sqlite3_step(stmt1);
|
2013-10-20 13:42:55 +02:00
|
|
|
get_favicon_from_url((const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
|
2013-10-20 03:20:01 +02:00
|
|
|
if (query_compact)
|
|
|
|
printf("<div style='position:relative'>");
|
|
|
|
else
|
|
|
|
printf("<div style='position:relative'><hr><br>");
|
2013-10-14 18:18:31 +02:00
|
|
|
printTagsLine(query_repositories[i]->arch[a],
|
|
|
|
query_repositories[i]->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
|
2013-10-14 18:18:31 +02:00
|
|
|
printf("<br><img src=\"%s\" width\"16\" height=\"16\"> ", buffer);
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-20 03:20:01 +02:00
|
|
|
if (query_compact) {
|
2013-10-25 15:10:18 +02:00
|
|
|
printf("<b><a href='/distribution/search.html?"
|
2013-10-20 03:20:01 +02:00
|
|
|
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
|
|
|
|
"%s</a></b> %s-%s - %s<br>",
|
|
|
|
query_repositories[i]->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
2013-10-20 03:20:01 +02:00
|
|
|
query_repositories[i]->arch[a],
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
} else {
|
|
|
|
printf("<b>%s</b> %s-%s<br>%s",
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
|
|
|
|
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
|
2013-10-20 13:42:55 +02:00
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
|
|
|
|
/* install */
|
|
|
|
/* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>"
|
|
|
|
"<div><object type=\"application/x-packagekit-plugin\" width=\"400\" height=\"50\">"
|
|
|
|
"<param name=\"displayname\" value=\"%s - %s\" />"
|
|
|
|
"<param name=\"packagenames\" value=\"%s\" /></object></div>",
|
|
|
|
sqlite3_column_text(statement,1),
|
|
|
|
sqlite3_column_text(statement,6),
|
|
|
|
sqlite3_column_text(statement,1));*/
|
|
|
|
|
|
|
|
/* download */
|
|
|
|
printf("<div style='display:inline;background-color:green'>"
|
|
|
|
" <a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a> </div>",
|
|
|
|
query_repositories[i]->download_prefix,
|
|
|
|
query_repositories[i]->download_dir,
|
2013-10-13 14:45:56 +02:00
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
2013-10-20 03:20:01 +02:00
|
|
|
_("Download"));
|
2013-10-13 12:25:46 +02:00
|
|
|
|
2013-10-20 03:20:01 +02:00
|
|
|
/* details */
|
|
|
|
printf(" <div style='display:inline;background-color:lightblue;font-weight:strong'>"
|
|
|
|
" <a href=#reply onclick='distroquery_request("
|
|
|
|
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black\">%s</a> </div>",
|
|
|
|
query_repositories[i]->tag,
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
query_repositories[i]->arch[a],
|
|
|
|
_("Details"));
|
|
|
|
printf("</div><br>");
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
}
|
2013-10-07 22:21:36 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(statement);
|
2013-10-14 12:45:06 +02:00
|
|
|
localprovidesresults = 0;
|
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM packages,provides,provided WHERE "
|
|
|
|
"(provides.id_package=packages.id AND provided.id=provides.id_provided) "
|
|
|
|
"AND provided.name LIKE '%%%s%%' "
|
|
|
|
"ORDER BY provided.name = '%s' DESC, provided.name LIKE '%s%%' DESC, provided.name LIKE '%%%s%%' DESC "
|
2013-10-15 00:12:47 +02:00
|
|
|
"LIMIT %d OFFSET %d", queryenc, queryenc, queryenc, queryenc, query_limit, query_offset);
|
2013-10-14 12:45:06 +02:00
|
|
|
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[a], sql, strlen(sql), &statement, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
|
numresults++;
|
|
|
|
if (++localprovidesresults == 1) {
|
|
|
|
printf("<div style='position:relative'><hr><b>");
|
|
|
|
if (localresults > 0) printf(_("Other results in "));
|
|
|
|
else printf(_("Results in"));
|
|
|
|
printf(" %s %s %s:</b><br>",
|
|
|
|
query_repositories[i]->tag,
|
|
|
|
_("for arch "),
|
|
|
|
query_repositories[i]->arch[a]);
|
|
|
|
}
|
2013-10-20 03:20:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (query_compact) {
|
2013-10-25 15:10:18 +02:00
|
|
|
printf("<a href='/distribution/search.html?"
|
2013-10-20 03:20:01 +02:00
|
|
|
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
|
2013-10-22 10:31:23 +02:00
|
|
|
"%s</a> (%s-%s) %s %s<br>",
|
2013-10-20 03:20:01 +02:00
|
|
|
query_repositories[i]->tag,
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
|
|
|
|
query_repositories[i]->arch[a],
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
|
2013-10-22 10:31:23 +02:00
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "version")),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "release")),
|
2013-10-20 03:20:01 +02:00
|
|
|
_("provides"),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name")));
|
|
|
|
} else {
|
|
|
|
printf("<a href=#reply onclick='distroquery_request("
|
2013-10-22 10:31:23 +02:00
|
|
|
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black;background-color:lightblue\">%s</a> (%s-%s) %s %s<br>",
|
|
|
|
query_repositories[i]->tag,
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
|
|
|
|
query_repositories[i]->arch[a],
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "version")),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "release")),
|
|
|
|
_("provides"),
|
|
|
|
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name")));
|
2013-10-20 03:20:01 +02:00
|
|
|
}
|
2013-10-14 12:45:06 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
|
|
|
|
/* files search */
|
2013-10-15 11:40:22 +02:00
|
|
|
if (search_files) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s-files.db",
|
|
|
|
query_repositories[i]->repository_dir,
|
|
|
|
query_repositories[i]->tag,
|
|
|
|
query_repositories[i]->arch[a]);
|
|
|
|
if (!sqlite3_open_v2(dbname, &dbf, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM files,packages_files_rel "
|
2013-10-15 00:12:47 +02:00
|
|
|
"WHERE files.name LIKE '%%%s%%' AND "
|
|
|
|
"packages_files_rel.id_file = files.id "
|
|
|
|
"ORDER BY files.name = '%s' DESC, files.name LIKE '%s%%' DESC, "
|
|
|
|
"files.name LIKE '%%%s%%' DESC LIMIT %d OFFSET %d",
|
2013-10-15 11:40:22 +02:00
|
|
|
queryenc, queryenc, queryenc, queryenc, query_limit, query_offset);
|
|
|
|
if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
|
|
|
numresults++;
|
|
|
|
if (++localprovidesresults == 1) {
|
|
|
|
printf("<div style='position:relative'><hr><b>");
|
|
|
|
if (localresults > 0) printf(_("Other results in "));
|
|
|
|
else printf(_("Results in"));
|
|
|
|
printf(" %s %s %s:</b><br>",
|
|
|
|
query_repositories[i]->tag,
|
|
|
|
_("for arch "),
|
|
|
|
query_repositories[i]->arch[a]);
|
|
|
|
}
|
2013-10-17 02:29:56 +02:00
|
|
|
printf("<a href=#reply onclick='distroquery_request("
|
2013-10-22 10:31:23 +02:00
|
|
|
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black;background-color:lightblue\">%s</a> (%s-%s)",
|
2013-10-15 11:40:22 +02:00
|
|
|
query_repositories[i]->tag,
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")),
|
|
|
|
query_repositories[i]->arch[a],
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")),
|
2013-10-22 10:31:23 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "version")),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "release")));
|
|
|
|
k = sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "flags"));
|
|
|
|
if (k >> 12 & 4)
|
|
|
|
printf(" %s ",_("provides directory"));
|
|
|
|
else if (k >> 12 & 2)
|
|
|
|
printf(" %s ",_("provides symbolic link"));
|
|
|
|
else
|
|
|
|
printf(" %s ",_("provides file"));
|
|
|
|
printf("%s<br>",
|
2013-10-15 11:40:22 +02:00
|
|
|
resolveFilePath(dbf, sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id_file")), buffer));
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
2013-10-15 11:40:22 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
2013-10-15 11:40:22 +02:00
|
|
|
sqlite3_close(dbf);
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-20 03:20:01 +02:00
|
|
|
if (localprovidesresults > 0) printf("</div><hr>");
|
2013-10-15 00:12:47 +02:00
|
|
|
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(statement);
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
2013-10-15 11:40:22 +02:00
|
|
|
if ((localresults >= query_limit) || (localprovidesresults >= query_limit)) otherresults = 1;
|
|
|
|
} /* if query_repository */
|
|
|
|
} /* archs loop */
|
|
|
|
} /* repositories loop */
|
2013-10-07 02:36:11 +02:00
|
|
|
|
2013-10-07 22:21:36 +02:00
|
|
|
if (search_sources) {
|
2013-10-09 13:24:10 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
2013-10-14 12:45:06 +02:00
|
|
|
"SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' OR version LIKE '%%%s%%' "
|
2013-10-15 00:12:47 +02:00
|
|
|
"ORDER BY name = '%s' DESC, name LIKE '%s%%' DESC, name LIKE '%%%s%%' DESC LIMIT %d OFFSET %d",
|
|
|
|
queryenc, queryenc, queryenc, queryenc, queryenc, queryenc, queryenc, query_limit, query_offset);
|
2013-10-07 22:21:36 +02:00
|
|
|
for (i = 0; query_repositories[i] != NULL; i++) {
|
2013-10-12 17:34:55 +02:00
|
|
|
if (!query_repositories[i]->db[ARCHS_MAX]) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", query_repositories[i]->repository_dir, query_repositories[i]->tag);
|
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[ARCHS_MAX], SQLITE_OPEN_READONLY, NULL)) {
|
2013-10-20 13:42:55 +02:00
|
|
|
if (query_repositories[i]->db[ARCHS_MAX]) sqlite3_close(query_repositories[i]->db[ARCHS_MAX]);
|
2013-10-12 17:34:55 +02:00
|
|
|
query_repositories[i]->db[ARCHS_MAX] = NULL;
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (query_repositories[i]->db[ARCHS_MAX] &&
|
|
|
|
(sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
2013-10-15 11:40:22 +02:00
|
|
|
localsourceresults = 0;
|
2013-10-07 22:21:36 +02:00
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
|
numresults++;
|
2013-10-15 11:40:22 +02:00
|
|
|
localsourceresults++;
|
2013-10-13 14:45:56 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
get_favicon_from_url((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
|
2013-10-13 14:45:56 +02:00
|
|
|
|
2013-10-20 03:20:01 +02:00
|
|
|
if (!query_compact) printf("<hr><br>");
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
printTagsLine(NULL,
|
|
|
|
query_repositories[i]->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
printf("<br><img src=\"%s\" width\"16\" height=\"16\"> ", buffer);
|
2013-10-20 03:20:01 +02:00
|
|
|
if (query_compact) {
|
2013-10-25 15:10:18 +02:00
|
|
|
printf("<b><a href='/distribution/search.html?"
|
2013-10-20 03:20:01 +02:00
|
|
|
"repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
|
|
|
|
"%s</a></b> %s-%s - %s<br>",
|
|
|
|
query_repositories[i]->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
} else {
|
|
|
|
printf("<b>%s</b> %s-%s<br>%s<br><br>",
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
|
|
|
|
printf("<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
|
2013-10-20 13:42:55 +02:00
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
2013-10-20 03:20:01 +02:00
|
|
|
/* source details */
|
|
|
|
printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>"
|
|
|
|
" <a href=#reply onclick='distroquery_request("
|
|
|
|
"\"repository=%s&package=%s\")' style=\"color:black\">Details</a> </div>",
|
|
|
|
query_repositories[i]->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
|
2013-10-20 03:20:01 +02:00
|
|
|
}
|
2013-10-07 22:21:36 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(statement);
|
2013-10-13 14:45:56 +02:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, "ERROR: SQLite: %s (%s)\n", sqlite3_errmsg(query_repositories[i]->db[ARCHS_MAX]), sql);
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
2013-10-15 11:40:22 +02:00
|
|
|
if (localsourceresults >= query_limit) otherresults = 1;
|
|
|
|
} /* repositories loop */
|
|
|
|
} /* search_sources */
|
2013-10-10 15:04:04 +02:00
|
|
|
printf("<hr>");
|
2013-10-07 22:21:36 +02:00
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("]]></%s><querystatus><![CDATA[", reply_xmltag);
|
2013-10-16 13:42:24 +02:00
|
|
|
k = query_offset / query_limit + 1; /* k = current shown page */
|
|
|
|
if (otherresults || k > 1)
|
2013-10-17 02:29:56 +02:00
|
|
|
printf("%d %s.", numresults, _("result(s) shown"));
|
2013-10-15 11:40:22 +02:00
|
|
|
else
|
2013-10-17 02:29:56 +02:00
|
|
|
printf("%d %s.", numresults, _("result(s) found"));
|
2013-10-20 03:20:01 +02:00
|
|
|
if (!reply_plain) {
|
|
|
|
if (k < 7) j=1; else j=k-5; /* j = start pages list from */
|
|
|
|
if (!otherresults) {
|
|
|
|
/* current page is last available */
|
|
|
|
a=k;
|
|
|
|
j=a-10;
|
|
|
|
if (j <= 0) j=1;
|
|
|
|
} else a=j+9; /* a = number of page links displayed */
|
|
|
|
if (a > 1) {
|
|
|
|
printf(" [ ");
|
|
|
|
for (i = j; i <= a; i++) {
|
|
|
|
if (i != k) printf("<a href=#reply onclick='distroquery_request(\"%s&limit=%d&offset=%d\")'>",
|
|
|
|
query_next, query_limit, query_limit * (i-1));
|
|
|
|
printf("%d", i);
|
|
|
|
printf("</a> ");
|
|
|
|
}
|
|
|
|
printf("]");
|
2013-10-15 11:40:22 +02:00
|
|
|
}
|
2013-10-20 03:20:01 +02:00
|
|
|
printf("]]></querystatus>");
|
2013-10-14 00:03:07 +02:00
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
printf("<title><![CDATA[");
|
|
|
|
printf("%s '%s' :: %s", _("Search results for"), query, firstconfigtag->configdefaults->distribution_name);
|
|
|
|
printf("]]></title>");
|
|
|
|
}
|
2013-10-07 18:14:53 +02:00
|
|
|
|
|
|
|
for (i = 0; query_repositories[i] != NULL; i++) {
|
2013-10-12 17:34:55 +02:00
|
|
|
for (a = 0; a <= ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
|
|
|
|
if (query_repositories[i]->db[a]) {
|
|
|
|
sqlite3_close((sqlite3*)query_repositories[i]->db[a]);
|
|
|
|
query_repositories[i]->db[a] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-10-07 18:14:53 +02:00
|
|
|
}
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:10:18 +02:00
|
|
|
void printSpecialQueryResponse() {
|
|
|
|
char *repository;
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char buffer[PATH_MAX];
|
|
|
|
sqlite3 *db;
|
2013-10-27 19:26:29 +01:00
|
|
|
sqlite3 *dbb = NULL;
|
2013-10-25 15:10:18 +02:00
|
|
|
sqlite3_stmt *statement, *stmt1;
|
|
|
|
struct configTag* ct;
|
2013-10-27 19:26:29 +01:00
|
|
|
int i,a, id, built_for_arch[ARCHS_MAX], built_for_arch_upstream[ARCHS_MAX];
|
2013-10-30 22:59:52 +01:00
|
|
|
int is_update;
|
2013-10-25 16:22:03 +02:00
|
|
|
long buildtime;
|
2013-10-25 15:10:18 +02:00
|
|
|
char updates[PATH_MAX];
|
2013-10-27 19:26:29 +01:00
|
|
|
char warning[PATH_MAX];
|
2013-10-25 16:22:03 +02:00
|
|
|
humanDate strdate;
|
|
|
|
|
|
|
|
struct tm *ytm;
|
|
|
|
time_t timesec;
|
|
|
|
|
|
|
|
timesec = time(×ec);
|
|
|
|
ytm = localtime((time_t *) ×ec);
|
|
|
|
ytm->tm_sec = 0;
|
|
|
|
ytm->tm_min = 0;
|
|
|
|
ytm->tm_hour = 0;
|
|
|
|
ytm->tm_mday = 1;
|
|
|
|
ytm->tm_mon = 0;
|
|
|
|
timesec = mktime(ytm);
|
2013-10-25 15:10:18 +02:00
|
|
|
|
|
|
|
if (strstr(query, "$latest$") == query) {
|
2013-10-27 19:26:29 +01:00
|
|
|
/* latest packages in a repository */
|
2013-10-25 15:10:18 +02:00
|
|
|
repository = query + 8;
|
|
|
|
ct = findRepositoryByTag(repository);
|
|
|
|
if (!ct) return;
|
2013-10-27 19:26:29 +01:00
|
|
|
db = openRepositoryDatabase(ct, NULL);
|
2013-10-25 15:10:18 +02:00
|
|
|
attachCtDatabases(ct, db, NULL);
|
2013-10-27 19:26:29 +01:00
|
|
|
|
|
|
|
if (ct->arch[0]) {
|
|
|
|
dbb = openRepositoryDatabase(ct, NULL);
|
|
|
|
if (!dbb) return;
|
|
|
|
for (a = 0; a < ARCHS_MAX && ct->arch[a]; a++) {
|
|
|
|
attachRepositoryDatabases(ct, dbb, ct->arch[a], 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:10:18 +02:00
|
|
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM sources ORDER BY buildtime DESC LIMIT 100");
|
|
|
|
if (db && (sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
2013-10-27 19:26:29 +01:00
|
|
|
/* loop packages in repository */
|
2013-10-25 15:10:18 +02:00
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW) {
|
2013-10-30 22:59:52 +01:00
|
|
|
is_update = 0;
|
2013-10-25 15:10:18 +02:00
|
|
|
i=0;
|
|
|
|
updates[0]=0;
|
2013-10-27 19:26:29 +01:00
|
|
|
warning[0]=0;
|
|
|
|
|
|
|
|
/* package in upstream repositories */
|
|
|
|
for (a = 0; a < ARCHS_MAX; a++) built_for_arch_upstream[a] = 0;
|
2013-10-25 15:10:18 +02:00
|
|
|
while (ct->repository[i]) {
|
|
|
|
if (ct->repository[i] == ct) break;
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM '%s_sources'.sources WHERE name='%s'",
|
|
|
|
ct->repository[i]->tag,
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
|
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
if (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-30 22:59:52 +01:00
|
|
|
is_update = 1;
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(updates, PATH_MAX, "%s %s(%s,%s-%s)\n", _("Updates"),
|
2013-10-25 15:10:18 +02:00
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
|
|
|
ct->repository[i]->tag,
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")));
|
2013-10-27 19:26:29 +01:00
|
|
|
id = sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id"));
|
|
|
|
a = packageVerCmp(
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "epoch")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "epoch")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")));
|
|
|
|
if (a <= 0) {
|
|
|
|
if (a < 0)
|
|
|
|
snprintf(warning + strlen(warning), PATH_MAX - strlen(warning),
|
|
|
|
"%s %s (%d:%s-%s <= %d:%s-%s)\n",
|
|
|
|
_("Has older version than upstream package in"),
|
|
|
|
ct->repository[i]->tag,
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "epoch")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "epoch")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")));
|
|
|
|
else
|
|
|
|
snprintf(warning + strlen(warning), PATH_MAX - strlen(warning), "%s %s",
|
|
|
|
_("Has same version as upstream package in"),
|
|
|
|
ct->repository[i]->tag);
|
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
/* upstream built for archs */
|
|
|
|
for (a = 0; a < ARCHS_MAX && ct->repository[i]->arch[a]; a++) {
|
|
|
|
attachRepositoryDatabases(ct->repository[i], dbb, ct->repository[i]->arch[a], 0);
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT id FROM '%s_%s'.packages WHERE id_source='%d'",
|
|
|
|
ct->repository[i]->tag, ct->repository[i]->arch[a], id);
|
|
|
|
if (sqlite3_prepare_v2(dbb, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) built_for_arch_upstream[a]++;
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
|
|
|
detachRepositoryDatabases(ct->repository[i], dbb, ct->repository[i]->arch[a], 0);
|
|
|
|
}
|
2013-10-25 15:10:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2013-10-25 16:22:03 +02:00
|
|
|
|
2013-10-27 19:26:29 +01:00
|
|
|
/* built for archs */
|
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "\n%s: ", _("Packages for"));
|
|
|
|
for (a = 0; a < ARCHS_MAX; a++) built_for_arch[a] = 0;
|
|
|
|
for (a = 0; a < ARCHS_MAX && ct->arch[a]; a++) {
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT id FROM '%s_%s'.packages WHERE id_source='%d'",
|
|
|
|
ct->repository[i]->tag, ct->arch[a],
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
|
|
|
if (sqlite3_prepare_v2(dbb, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) built_for_arch[a]++;
|
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
if (built_for_arch[a])
|
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "%s(%d) ", ct->arch[a], built_for_arch[a]);
|
|
|
|
}
|
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "\n");
|
|
|
|
|
|
|
|
for (a = 0; a < ARCHS_MAX; a++) {
|
|
|
|
if (built_for_arch_upstream[a] && ! built_for_arch[a])
|
|
|
|
snprintf(warning + strlen(warning), PATH_MAX - strlen(updates), "%s %s\n", _("Needs port to"), ct->arch[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* changelog */
|
2013-10-25 16:22:03 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM changelog,packagers "
|
|
|
|
"WHERE id_source=%d AND changelog.id_packager=packagers.id "
|
|
|
|
"ORDER BY changelog.time DESC LIMIT 2",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "\n%s", _("Latest changes:"));
|
2013-10-25 16:22:03 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "\n%s - %s (%s)\n%s",
|
|
|
|
(char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text")));
|
|
|
|
}
|
2013-10-27 19:26:29 +01:00
|
|
|
snprintf(updates + strlen(updates), PATH_MAX - strlen(updates), "\n");
|
2013-10-25 16:22:03 +02:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:10:18 +02:00
|
|
|
get_favicon_from_url((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
|
2013-10-30 22:59:52 +01:00
|
|
|
if (is_update) {
|
2013-10-27 19:26:29 +01:00
|
|
|
printf("<img src=\"%s/pkgup.png\" title=\"%s\" width=\"14\" height=\"14\"> ",
|
|
|
|
ct->configdefaults->url_dir, updates);
|
2013-10-25 15:10:18 +02:00
|
|
|
} else {
|
2013-10-27 19:26:29 +01:00
|
|
|
printf("<img src=\"%s/pkg.png\" width=\"14\" height=\"14\"> ", ct->configdefaults->url_dir);
|
2013-10-25 15:10:18 +02:00
|
|
|
}
|
2013-10-25 16:22:03 +02:00
|
|
|
|
|
|
|
buildtime = sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "buildtime"));
|
|
|
|
if (buildtime < timesec) {
|
|
|
|
simpleTimeToTemplate(buildtime,"%Y/%m/%d",&strdate);
|
|
|
|
} else {
|
|
|
|
simpleTimeToTemplate(buildtime,"%m/%d",&strdate);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s <img src=\"%s\" width\"12\" height=\"12\"> ", strdate, buffer);
|
2013-10-25 15:10:18 +02:00
|
|
|
printf("<b><a href='/distribution/search.html?"
|
|
|
|
"repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery' title=\"%s\">"
|
2013-10-27 19:26:29 +01:00
|
|
|
"%s</a></b> %s-%s",
|
2013-10-25 15:10:18 +02:00
|
|
|
ct->tag,
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")));
|
2013-10-27 19:26:29 +01:00
|
|
|
if (warning[0] != 0) {
|
|
|
|
printf("<img src=\"%s/warning-icon.png\" title=\"%s\" width=\"14\" height=\"14\">",
|
|
|
|
ct->configdefaults->url_dir, warning);
|
|
|
|
|
|
|
|
}
|
|
|
|
printf("<br>");
|
2013-10-25 15:10:18 +02:00
|
|
|
}
|
|
|
|
sqlite3_finalize(statement);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reply_plain) printf("]]></%s>", reply_xmltag);
|
|
|
|
if (!reply_plain) {
|
|
|
|
printf("<title><![CDATA[");
|
|
|
|
printf("%s :: %s", buffer, firstconfigtag->configdefaults->distribution_name);
|
|
|
|
printf("]]></title>");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printQueryResponse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-09 11:28:17 +02:00
|
|
|
void printPackageData() {
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
int i, j;
|
2013-10-09 11:28:17 +02:00
|
|
|
char dbname[PATH_MAX];
|
2013-10-15 00:12:47 +02:00
|
|
|
sqlite3 *db, *dbs, *dbf;
|
2013-10-13 03:31:46 +02:00
|
|
|
sqlite3_stmt *statement, *stmt1, *stmt2;
|
2013-10-09 11:28:17 +02:00
|
|
|
char sql[PATH_MAX];
|
2013-10-13 03:31:46 +02:00
|
|
|
char buffer[PATH_MAX];
|
2013-10-09 11:28:17 +02:00
|
|
|
struct configTag* ct = findRepositoryByTag(query_repository);
|
2013-10-13 14:45:56 +02:00
|
|
|
humanDate strdate;
|
2013-10-12 22:00:43 +02:00
|
|
|
sizeString strsize;
|
2013-10-15 14:36:10 +02:00
|
|
|
FILE *file;
|
2013-10-22 17:37:37 +02:00
|
|
|
int package_id;
|
|
|
|
char *package_name = NULL, *package_summary = NULL;
|
2013-10-09 11:28:17 +02:00
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, query_arch);
|
2013-10-20 01:03:47 +02:00
|
|
|
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
|
2013-10-12 17:34:55 +02:00
|
|
|
if (db) sqlite3_close(db);
|
2013-10-20 01:03:47 +02:00
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE name = '%s'", query_package);
|
|
|
|
if (db &&
|
|
|
|
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
2013-10-14 00:03:07 +02:00
|
|
|
if (sqlite3_step(statement) == SQLITE_ROW) {
|
2013-10-22 17:37:37 +02:00
|
|
|
|
|
|
|
package_id = sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id"));
|
|
|
|
package_name = strdup((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
|
|
|
|
package_summary = strdup((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
|
|
|
|
|
2013-10-13 02:17:31 +02:00
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_open_v2(dbname, &dbs, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
if (dbs) sqlite3_close(dbs);
|
|
|
|
dbs = NULL;
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM sources,packagers WHERE sources.id=%d AND sources.id_packager=packagers.id",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
|
|
|
|
if (!sqlite3_prepare_v2(dbs, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
fprintf(stderr, "ERROR: unable to prepare statement for %s; aborting.\n", sql);
|
|
|
|
return;
|
2013-10-13 02:17:31 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_step(stmt1);
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-13 14:45:56 +02:00
|
|
|
printf("<hr><br>");
|
|
|
|
printTagsLine(query_arch,
|
|
|
|
ct->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
|
2013-10-13 14:45:56 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
get_favicon_from_url((const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
printf("<br><br>"
|
|
|
|
"<h1><img src=\"%s\" width\"16\" height=\"16\"> "
|
2013-10-14 03:04:16 +02:00
|
|
|
"%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>%s: %s",
|
2013-10-13 14:45:56 +02:00
|
|
|
buffer,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
2013-10-14 01:47:12 +02:00
|
|
|
_("Version"),
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),
|
2013-10-14 03:04:16 +02:00
|
|
|
_("Size"),
|
2013-10-12 22:00:43 +02:00
|
|
|
humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize));
|
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br>%s:", _("Related packages"));
|
2013-10-13 03:31:46 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE id_source=%d AND NOT id=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")),
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt2, NULL) == SQLITE_OK) {
|
2013-10-13 03:31:46 +02:00
|
|
|
while (sqlite3_step(stmt2) == SQLITE_ROW)
|
2013-10-17 02:29:56 +02:00
|
|
|
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
|
2013-10-13 03:31:46 +02:00
|
|
|
ct->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")),
|
2013-10-13 03:31:46 +02:00
|
|
|
query_arch,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")),
|
2013-10-13 03:31:46 +02:00
|
|
|
query_arch);
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt2);
|
|
|
|
}
|
2013-10-13 02:17:31 +02:00
|
|
|
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
|
2013-10-20 13:42:55 +02:00
|
|
|
htmlclean((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-13 12:25:46 +02:00
|
|
|
/* download */
|
|
|
|
printf("<div style='display:inline;background-color:green'>"
|
2013-10-14 01:47:12 +02:00
|
|
|
" <a href=\"%s%s/RPMS.%s/%s-%s-%s.%s.rpm\" style=\"color:white\">%s</a> </div>",
|
2013-10-13 12:25:46 +02:00
|
|
|
ct->download_prefix,
|
|
|
|
ct->download_dir,
|
|
|
|
query_arch,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
2013-10-14 01:47:12 +02:00
|
|
|
query_arch,
|
|
|
|
_("Download"));
|
2013-10-13 12:25:46 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<hr><br><b>%s:</b>",_("Developers details"));
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br>%s:", _("Source package"));
|
2013-10-17 02:29:56 +02:00
|
|
|
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s\")'>%s</a>",
|
2013-10-13 02:17:31 +02:00
|
|
|
ct->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
|
|
|
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
2013-10-12 22:00:43 +02:00
|
|
|
|
2013-10-15 14:36:10 +02:00
|
|
|
snprintf(buffer, PATH_MAX, "%s/specs/%s.spec", ct->repository_dir, query_package);
|
2013-10-20 13:42:55 +02:00
|
|
|
if ((file = fopen(buffer, "r"))) {
|
2013-10-15 14:36:10 +02:00
|
|
|
fclose(file);
|
|
|
|
snprintf(buffer, PATH_MAX, "%s%s/specs/%s.spec", ct->showfile_prefix, ct->download_dir, query_package);
|
|
|
|
printf("<br>%s: <a href=\"%s\" target=_blank>%s.spec</a>", _("Specfile"), buffer, query_package);
|
|
|
|
} else {
|
|
|
|
printf("<br>%s: %s.spec", _("Specfile"), query_package);
|
|
|
|
}
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
printf("<br>%s: %s", _("Maintainer"), (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")));
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br>%s: %s", _("Build date"),
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
|
2013-10-13 14:45:56 +02:00
|
|
|
|
2013-10-20 01:03:47 +02:00
|
|
|
/* obsoletes */
|
2013-10-12 23:50:08 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-20 03:20:01 +02:00
|
|
|
j=0;
|
2013-10-12 23:50:08 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 03:20:01 +02:00
|
|
|
if (j++ == 0) printf("<br><br>%s:", _("Obsoletes"));
|
2013-10-20 13:42:55 +02:00
|
|
|
printf(" %s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename")));
|
2013-10-12 23:50:08 +02:00
|
|
|
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) {
|
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags")));
|
2013-10-20 13:42:55 +02:00
|
|
|
printf("%s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion")));
|
2013-10-12 23:50:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-20 01:03:47 +02:00
|
|
|
|
|
|
|
/* provides */
|
2013-10-13 02:17:31 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided "
|
|
|
|
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
|
|
|
"ORDER BY provided.name",
|
2013-10-12 23:50:08 +02:00
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-20 03:20:01 +02:00
|
|
|
j=0;
|
2013-10-12 23:50:08 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 03:20:01 +02:00
|
|
|
if (j++ == 0) printf("<br><br>%s:",_("Provides"));
|
2013-10-20 13:42:55 +02:00
|
|
|
printf(" %s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
2013-10-12 23:50:08 +02:00
|
|
|
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) {
|
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags")));
|
2013-10-20 13:42:55 +02:00
|
|
|
printf("%s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion")));
|
2013-10-12 23:50:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-20 01:03:47 +02:00
|
|
|
|
|
|
|
/* requires */
|
2013-10-13 02:17:31 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided "
|
|
|
|
"WHERE requires.id_package=%d AND provided.id=requires.id_provided "
|
|
|
|
"ORDER BY provided.name",
|
2013-10-12 23:50:08 +02:00
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-20 03:20:01 +02:00
|
|
|
j=0;
|
2013-10-12 23:50:08 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 03:20:01 +02:00
|
|
|
if (j++ == 0) printf("<br><br>%s:", _("Requires"));
|
2013-10-13 02:17:31 +02:00
|
|
|
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
2013-10-12 23:50:08 +02:00
|
|
|
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion"))) {
|
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireflags")));
|
|
|
|
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion")));
|
|
|
|
}
|
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
|
2013-10-22 17:37:37 +02:00
|
|
|
sqlite3_finalize(statement); /* need to finalize all statements before detaching databases */
|
2013-10-20 01:03:47 +02:00
|
|
|
/* required by */
|
2013-10-22 17:37:37 +02:00
|
|
|
for (i = 0; query_repositories[i] != NULL; i++) {
|
2013-10-27 19:26:29 +01:00
|
|
|
attachRepositoryDatabases(query_repositories[i], db, query_arch, 1);
|
2013-10-20 01:03:47 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
2013-10-22 11:54:03 +02:00
|
|
|
"SELECT packagesup.name AS requiredbyname, "
|
|
|
|
"requiresup.requireflags AS requiredflags, "
|
|
|
|
"requiresup.requireversion AS requiredversion "
|
2013-10-27 19:26:29 +01:00
|
|
|
"FROM '%s_%s'.packages AS packagesup,'%s_%s'.requires AS requiresup,"
|
|
|
|
"'%s_%s'.provided AS providedup,provided,provides "
|
2013-10-20 01:03:47 +02:00
|
|
|
"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",
|
2013-10-27 19:26:29 +01:00
|
|
|
query_repositories[i]->tag, query_arch,
|
|
|
|
query_repositories[i]->tag, query_arch,
|
|
|
|
query_repositories[i]->tag, query_arch,
|
2013-10-22 17:37:37 +02:00
|
|
|
package_id, query_package);
|
2013-10-20 01:03:47 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
j=0;
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-22 17:37:37 +02:00
|
|
|
if (j++ == 0) printf("<br><br>%s %s %s:",_("Required in"),query_repositories[i]->tag,_("by"));
|
|
|
|
printf(" <a href='javascript:distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s</a>",
|
|
|
|
query_repositories[i]->tag,
|
2013-10-22 11:54:03 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "requiredbyname")),
|
2013-10-20 01:03:47 +02:00
|
|
|
query_arch,
|
2013-10-22 11:54:03 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "requiredbyname")));
|
|
|
|
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requiredversion"))) {
|
|
|
|
printf("(%s %s", _("requires"), query_package);
|
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requiredflags")));
|
|
|
|
printf("%s)", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "requiredversion")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-27 19:26:29 +01:00
|
|
|
detachRepositoryDatabases(query_repositories[i], db, query_arch, 1);
|
2013-10-22 11:54:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* build required by */
|
2013-10-22 17:37:37 +02:00
|
|
|
for (i = 0; query_repositories[i] != NULL; i++) {
|
2013-10-27 19:26:29 +01:00
|
|
|
attachRepositoryDatabases(query_repositories[i], db, query_arch, 1);
|
2013-10-22 11:54:03 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT sourcesup.name as buildrequiredbyname, "
|
|
|
|
"buildrequiresup.buildrequireflags as buildrequireflags, "
|
|
|
|
"buildrequiresup.buildrequireversion as buildrequireversion "
|
|
|
|
"FROM '%s_sources'.sources AS sourcesup,'%s_sources'.buildrequires AS buildrequiresup,"
|
|
|
|
"provided,provides "
|
|
|
|
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
|
|
|
"AND sourcesup.id=buildrequiresup.id_source "
|
|
|
|
"AND buildrequiresup.buildrequirename=provided.name "
|
|
|
|
// "AND NOT packagesup.name='%s' "
|
|
|
|
// "GROUP BY packagesup.name "
|
|
|
|
"ORDER BY sourcesup.name",
|
2013-10-22 17:37:37 +02:00
|
|
|
query_repositories[i]->tag, query_repositories[i]->tag, package_id);
|
2013-10-22 11:54:03 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
j=0;
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-22 17:37:37 +02:00
|
|
|
if (j++ == 0) printf("<br><br>%s %s %s:",_("Build required in"),query_repositories[i]->tag,_("by"));
|
|
|
|
printf(" <a href='javascript:distroquery_request(\"repository=%s&package=%s\")'>%s</a>",
|
|
|
|
query_repositories[i]->tag,
|
2013-10-22 11:54:03 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequiredbyname")),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequiredbyname")));
|
|
|
|
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion"))) {
|
|
|
|
printf("(%s %s", _("requires"), query_package);
|
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireflags")));
|
|
|
|
printf("%s)", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")));
|
|
|
|
}
|
2013-10-20 01:03:47 +02:00
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-27 19:26:29 +01:00
|
|
|
detachRepositoryDatabases(query_repositories[i], db, query_arch, 1);
|
2013-10-20 01:03:47 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 00:12:47 +02:00
|
|
|
/* files list */
|
|
|
|
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)) {
|
2013-10-20 12:43:19 +02:00
|
|
|
printf("<br><br>%s:<br><table>", _("Files list"));
|
2013-10-19 19:24:04 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages_files_rel,fileusers,filegroups WHERE"
|
|
|
|
" packages_files_rel.name='%s' AND"
|
|
|
|
" packages_files_rel.id_user=fileusers.id AND "
|
|
|
|
" packages_files_rel.id_group=filegroups.id", query_package);
|
2013-10-15 00:12:47 +02:00
|
|
|
if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 12:43:19 +02:00
|
|
|
printf("<tr><td style=\"font-family:courier\">%s</td><td style=\"font-family:courier\">%s</td><td style=\"font-family:courier\">%s</td><td>%s</td></tr>",
|
2013-10-19 19:24:04 +02:00
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "fileusers", "name")),
|
|
|
|
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "filegroups", "name")),
|
|
|
|
expandFileFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "flags")), sql),
|
|
|
|
resolveFilePath(dbf, sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id_file")), buffer));
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
|
|
|
sqlite3_close(dbf);
|
2013-10-19 19:24:04 +02:00
|
|
|
printf("</table>");
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
2013-10-13 02:17:31 +02:00
|
|
|
sqlite3_close(dbs);
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-22 17:37:37 +02:00
|
|
|
snprintf(buffer, PATH_MAX, "%s - %s", package_name, package_summary);
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("]]></%s>", reply_xmltag);
|
|
|
|
if (!reply_plain) {
|
|
|
|
printf("<title><![CDATA[");
|
|
|
|
printf("%s :: %s", buffer, firstconfigtag->configdefaults->distribution_name);
|
|
|
|
printf("]]></title>");
|
|
|
|
}
|
2013-10-12 22:00:43 +02:00
|
|
|
sqlite3_close(db);
|
|
|
|
db = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void printSourcePackageData() {
|
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
int a;
|
2013-10-12 22:00:43 +02:00
|
|
|
char dbname[PATH_MAX];
|
|
|
|
sqlite3 *db, *dba;
|
|
|
|
sqlite3_stmt *statement, *stmt1;
|
|
|
|
char sql[PATH_MAX];
|
2013-10-13 03:31:46 +02:00
|
|
|
char buffer[PATH_MAX];
|
2013-10-12 22:00:43 +02:00
|
|
|
struct configTag* ct = findRepositoryByTag(query_repository);
|
|
|
|
humanDate strdate;
|
|
|
|
sizeString strsize;
|
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
|
2013-10-12 22:00:43 +02:00
|
|
|
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
|
|
|
if (sqlite3_open_v2(dbname, &db, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
if (db) sqlite3_close(db);
|
|
|
|
db = NULL;
|
|
|
|
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM sources,packagers WHERE sources.name = '%s' AND sources.id_packager=packagers.id", query_package);
|
|
|
|
if (db &&
|
|
|
|
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
2013-10-14 00:03:07 +02:00
|
|
|
if (sqlite3_step(statement) == SQLITE_ROW) {
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
printf("<hr><br>");
|
|
|
|
printTagsLine(NULL,
|
|
|
|
ct->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
|
2013-10-13 14:45:56 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
get_favicon_from_url((char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
|
2013-10-13 14:45:56 +02:00
|
|
|
|
|
|
|
printf("<br><br>"
|
|
|
|
"<h1><img src=\"%s\" width\"16\" height=\"16\"> "
|
2013-10-14 01:47:12 +02:00
|
|
|
"%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
|
2013-10-13 14:45:56 +02:00
|
|
|
buffer,
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
2013-10-14 01:47:12 +02:00
|
|
|
_("Version"),
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),
|
2013-10-13 02:17:31 +02:00
|
|
|
humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize));
|
2013-10-12 22:00:43 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br>%s:", _("Built packages"));
|
2013-10-12 22:00:43 +02:00
|
|
|
for (a = 0; a < ARCHS_MAX && ct->arch[a]; a++) {
|
|
|
|
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, ct->arch[a]);
|
|
|
|
if (!sqlite3_open_v2(dbname, &dba, SQLITE_OPEN_READONLY, NULL)) {
|
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE id_source=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(dba, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-12 22:00:43 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW)
|
2013-10-17 02:29:56 +02:00
|
|
|
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
|
2013-10-12 22:00:43 +02:00
|
|
|
ct->tag,
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
2013-10-12 22:00:43 +02:00
|
|
|
ct->arch[a],
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
2013-10-12 22:00:43 +02:00
|
|
|
ct->arch[a]);
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-12 22:00:43 +02:00
|
|
|
sqlite3_close(dba);
|
|
|
|
}
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-12 22:00:43 +02:00
|
|
|
|
2013-10-13 02:17:31 +02:00
|
|
|
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
|
2013-10-20 13:42:55 +02:00
|
|
|
htmlclean((char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-13 12:25:46 +02:00
|
|
|
/* download */
|
2013-10-13 14:45:56 +02:00
|
|
|
printf("<div style='display:inline;background-color:red'>"
|
2013-10-14 01:47:12 +02:00
|
|
|
" <a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a> </div>",
|
2013-10-13 12:25:46 +02:00
|
|
|
ct->download_prefix,
|
|
|
|
ct->download_dir,
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
|
2013-10-14 01:47:12 +02:00
|
|
|
_("Download"));
|
2013-10-13 12:25:46 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<hr><br><b>%s:</b>", _("Developers details"));
|
2013-10-15 14:36:10 +02:00
|
|
|
|
2013-10-20 13:42:55 +02:00
|
|
|
printf("<br>%s: %s", _("Maintainer"), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packagers", "name")));
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br>%s: %s", _("Build date"),
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)simpleTimeToHuman(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "buildtime")), (humanDate *) & strdate));
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br><br>%s:", _("Source files"));
|
2013-10-13 02:17:31 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM sources_source WHERE id_source=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-13 02:17:31 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 13:42:55 +02:00
|
|
|
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "source")));
|
2013-10-13 02:17:31 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br><br>%s:", _("Patches"));
|
2013-10-13 02:17:31 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM sources_patch WHERE id_source=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-13 02:17:31 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 13:42:55 +02:00
|
|
|
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "patch")));
|
2013-10-13 02:17:31 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-13 02:17:31 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br><br>%s:", _("Build requirements"));
|
2013-10-12 23:50:08 +02:00
|
|
|
snprintf(sql, PATH_MAX, "SELECT * FROM buildrequires WHERE id_source=%d",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-12 23:50:08 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
2013-10-20 13:42:55 +02:00
|
|
|
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequirename")));
|
|
|
|
if (strcmp("", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")))) {
|
2013-10-12 23:50:08 +02:00
|
|
|
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireflags")));
|
2013-10-20 13:42:55 +02:00
|
|
|
printf("%s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")));
|
2013-10-12 23:50:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-12 23:50:08 +02:00
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
printf("<br><br>%s:<br>", _("Changelog"));
|
2013-10-12 22:00:43 +02:00
|
|
|
snprintf(sql, PATH_MAX,
|
|
|
|
"SELECT * FROM changelog,packagers WHERE id_source=%d AND changelog.id_packager=packagers.id",
|
|
|
|
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
2013-10-14 18:18:31 +02:00
|
|
|
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
2013-10-12 22:00:43 +02:00
|
|
|
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
|
|
|
printf("%s - %s (%s)<br><pre>%s</pre>",
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
|
|
|
|
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text")));
|
2013-10-12 22:00:43 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(stmt1);
|
|
|
|
}
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-14 18:18:31 +02:00
|
|
|
snprintf(buffer, PATH_MAX, "%s - %s",
|
2013-10-20 13:42:55 +02:00
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
|
|
|
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
|
2013-10-14 18:18:31 +02:00
|
|
|
sqlite3_finalize(statement);
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("]]></%s>", reply_xmltag);
|
|
|
|
if (!reply_plain) {
|
|
|
|
printf("<title><![CDATA[");
|
|
|
|
printf("%s :: %s", buffer, firstconfigtag->configdefaults->distribution_name);
|
|
|
|
printf("]]></title>");
|
|
|
|
}
|
2013-10-12 17:34:55 +02:00
|
|
|
sqlite3_close(db);
|
|
|
|
db = NULL;
|
2013-10-09 11:28:17 +02:00
|
|
|
}
|
|
|
|
|
2013-10-07 18:14:53 +02:00
|
|
|
void parse_request_variables(char *data) {
|
2013-10-07 02:36:11 +02:00
|
|
|
char *vartok, *valuetok;
|
2013-10-07 18:14:53 +02:00
|
|
|
struct configTag *ct = firstconfigtag;
|
|
|
|
int i;
|
2013-10-07 02:36:11 +02:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
vartok = (char *) strtok(data, "=");
|
|
|
|
if (data) data = NULL;
|
|
|
|
if (!vartok || (vartok[0] == '\0') ) break;
|
|
|
|
valuetok = (char *) strtok(NULL, "&");
|
2013-10-09 11:28:17 +02:00
|
|
|
if (!strcmp(vartok, "repository")) {
|
|
|
|
query_repository = valuetok;
|
|
|
|
} else if (!strcmp(vartok, "package")) {
|
|
|
|
query_package = valuetok;
|
|
|
|
} else if (!strcmp(vartok, "arch")) {
|
|
|
|
query_arch = valuetok;
|
2013-10-15 00:12:47 +02:00
|
|
|
} else if (!strcmp(vartok, "offset")) {
|
|
|
|
query_offset = atoi(url_decode(valuetok));
|
|
|
|
if (query_offset < 0) query_offset = 0;
|
|
|
|
} else if (!strcmp(vartok, "limit")) {
|
|
|
|
query_limit = atoi(url_decode(valuetok));
|
|
|
|
if (query_limit < 0) query_limit = 10;
|
|
|
|
else if (query_limit > 20) query_limit = 20;
|
2013-10-14 00:03:07 +02:00
|
|
|
} else if (!strcmp(vartok, "searchbox")) {
|
|
|
|
searchbox = strstr(valuetok, "false") != valuetok;
|
2013-10-14 01:47:12 +02:00
|
|
|
} else if (!strcmp(vartok, "lang")) {
|
|
|
|
lang = valuetok;
|
2013-10-17 02:29:56 +02:00
|
|
|
} else if (!strcmp(vartok, "replytag")) {
|
|
|
|
reply_xmltag = valuetok;
|
|
|
|
} else if (!strcmp(vartok, "replyplain")) {
|
|
|
|
reply_plain = strstr(valuetok, "true") == valuetok;
|
2013-10-20 03:20:01 +02:00
|
|
|
} else if (!strcmp(vartok, "query_compact")) {
|
|
|
|
query_compact = strstr(valuetok, "true") == valuetok;
|
2013-10-21 21:48:37 +02:00
|
|
|
} else if (!strcmp(vartok, "path")) {
|
|
|
|
query_path = valuetok;
|
2013-10-15 00:12:47 +02:00
|
|
|
} else {
|
|
|
|
/* fields to make reusable query string for next pages */
|
|
|
|
if (!strcmp(vartok, "query")) {
|
|
|
|
query = url_decode(valuetok);
|
|
|
|
} else if (!strcmp(vartok, "search_milestone2")) {
|
|
|
|
search_milestone2 = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_milestone1")) {
|
|
|
|
search_milestone1 = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_devel")) {
|
|
|
|
search_devel = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_i586")) {
|
|
|
|
query_archs[0] = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_x86_64")) {
|
|
|
|
query_archs[1] = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_arm")) {
|
|
|
|
query_archs[2] = strstr(valuetok, "false") != valuetok;
|
|
|
|
} else if (!strcmp(vartok, "search_sources")) {
|
|
|
|
search_sources = strstr(valuetok, "false") != valuetok;
|
2013-10-15 11:40:22 +02:00
|
|
|
} else if (!strcmp(vartok, "search_files")) {
|
|
|
|
search_files = strstr(valuetok, "false") != valuetok;
|
|
|
|
}
|
|
|
|
if (vartok && valuetok) {
|
|
|
|
strcat(query_next, vartok);
|
|
|
|
strcat(query_next, "=");
|
|
|
|
strcat(query_next, valuetok);
|
|
|
|
strcat(query_next, "&");
|
2013-10-15 00:12:47 +02:00
|
|
|
}
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
if (query_next[strlen(query_next)] == '&') query_next[strlen(query_next)] = '\0';
|
|
|
|
ct = firstconfigtag;
|
2013-10-07 18:14:53 +02:00
|
|
|
i = 0;
|
2013-10-22 17:37:37 +02:00
|
|
|
if (query_package) {
|
|
|
|
if (strstr(query_repository, "devel") == query_repository) {
|
|
|
|
search_devel = 1;
|
|
|
|
search_milestone2 = 0;
|
|
|
|
search_milestone1 = 0;
|
|
|
|
searchbox = 1;
|
|
|
|
} else if (strstr(query_repository, "milestone2") == query_repository) {
|
|
|
|
search_devel = 0;
|
|
|
|
search_milestone2 = 1;
|
|
|
|
search_milestone1 = 0;
|
|
|
|
searchbox = 1;
|
|
|
|
} else if (strstr(query_repository, "milestone1") == query_repository) {
|
|
|
|
search_devel = 0;
|
|
|
|
search_milestone2 = 0;
|
|
|
|
search_milestone1 = 1;
|
|
|
|
searchbox = 1;
|
|
|
|
}
|
|
|
|
}
|
2013-10-09 13:24:10 +02:00
|
|
|
while (ct) {
|
|
|
|
if ((strstr(ct->tag, "devel") == ct->tag) && search_devel) query_repositories[i++] = ct;
|
|
|
|
ct = ct->next;
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
ct = firstconfigtag;
|
2013-10-09 13:24:10 +02:00
|
|
|
while (ct) {
|
|
|
|
if ((strstr(ct->tag, "milestone2") == ct->tag) && search_milestone2) query_repositories[i++] = ct;
|
|
|
|
ct = ct->next;
|
|
|
|
}
|
2013-10-15 00:12:47 +02:00
|
|
|
ct = firstconfigtag;
|
2013-10-07 18:14:53 +02:00
|
|
|
while (ct) {
|
|
|
|
if ((strstr(ct->tag, "milestone1") == ct->tag) && search_milestone1) query_repositories[i++] = ct;
|
|
|
|
ct = ct->next;
|
|
|
|
}
|
|
|
|
query_repositories[i++] = NULL;
|
|
|
|
}
|
2013-10-07 02:36:11 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2013-10-14 01:47:12 +02:00
|
|
|
|
2013-10-07 02:36:11 +02:00
|
|
|
char *data;
|
2013-10-20 13:42:55 +02:00
|
|
|
int responsed = 0;
|
2013-10-07 02:36:11 +02:00
|
|
|
|
2013-10-12 17:34:55 +02:00
|
|
|
// install backtrace handler
|
|
|
|
signal(SIGSEGV, backtraceHandler);
|
|
|
|
|
2013-10-14 01:47:12 +02:00
|
|
|
|
2013-10-07 02:36:11 +02:00
|
|
|
firstconfigtag = read_configuration(DEFAULT_CONFIGFILE);
|
|
|
|
if (!firstconfigtag) {
|
|
|
|
fprintf(stderr, "Fatal error while parsing config file " DEFAULT_CONFIGFILE "; aborting.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
data = getenv("QUERY_STRING");
|
2013-10-07 14:13:11 +02:00
|
|
|
if (data && strlen(data)) {
|
2013-10-07 18:14:53 +02:00
|
|
|
parse_request_variables(data);
|
|
|
|
}
|
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain)
|
|
|
|
printf("Content-Type: text/xml;charset=utf-8\n\n<distroquery>");
|
|
|
|
else
|
|
|
|
printf("Content-Type: text/html;charset=utf-8\n\n");
|
|
|
|
|
2013-10-14 03:04:16 +02:00
|
|
|
setlocale(LC_ALL, lang);
|
2013-10-14 01:47:12 +02:00
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
|
2013-10-09 11:28:17 +02:00
|
|
|
if (query_package && strlen(query_package)) {
|
2013-10-12 22:00:43 +02:00
|
|
|
if (query_arch)
|
|
|
|
printPackageData();
|
|
|
|
else
|
|
|
|
printSourcePackageData();
|
2013-10-20 13:42:55 +02:00
|
|
|
responsed = 1;
|
2013-10-09 11:28:17 +02:00
|
|
|
} else if (query && strlen(query)) {
|
2013-10-25 15:10:18 +02:00
|
|
|
if (query[0] == '$')
|
|
|
|
printSpecialQueryResponse();
|
|
|
|
else
|
|
|
|
printQueryResponse();
|
2013-10-20 13:42:55 +02:00
|
|
|
responsed = 1;
|
2013-10-21 21:48:37 +02:00
|
|
|
} else if (query_path) {
|
2013-10-20 13:42:55 +02:00
|
|
|
printFileBrowser();
|
2013-10-07 02:36:11 +02:00
|
|
|
}
|
2013-10-20 13:42:55 +02:00
|
|
|
|
|
|
|
if (!responsed || (responsed && searchbox)) printInputForm();
|
2013-10-07 02:36:11 +02:00
|
|
|
|
2013-10-17 02:29:56 +02:00
|
|
|
if (!reply_plain) printf("</distroquery>\n");
|
2013-10-07 02:36:11 +02:00
|
|
|
exit(0);
|
|
|
|
}
|