Switch to rpm 4 and cmake build tool

This commit is contained in:
Silvan Calarco 2020-06-18 13:55:52 +02:00
parent 8083cad05b
commit 51cf5cacb6
21 changed files with 333 additions and 264 deletions

5
.gitignore vendored
View File

@ -6,9 +6,8 @@ config.log
config.status
configure
aclocal.m4
src/include/config.h*
src/distromatic
src/distroquery
src/include/globaldefs.h
src/include/stamp-h1
src/.deps
src/.deps
build/

7
CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
project(distromatic)
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
add_subdirectory(src)

65
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,65 @@
find_package(ZLIB REQUIRED)
find_package(PkgConfig)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
pkg_check_modules(RPM REQUIRED rpm)
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
find_library(LIBIBERTY NAMES iberty)
include_directories(include)
string(REPLACE "." ";" VERSION_LIST ${RPM_VERSION})
list(GET VERSION_LIST 0 RPM_VERSION_MAJOR)
list(GET VERSION_LIST 1 RPM_VERSION_MINOR)
list(GET VERSION_LIST 2 RPM_VERSION_MICRO)
add_compile_definitions(
PACKAGE="Distromatic"
PACKAGE_VERSION="1.5.0"
DEFAULT_CONFIGFILE="/etc/distromatic.conf"
off64_t=__off64_t
RPM_VERSION_MAJOR=${RPM_VERSION_MAJOR}
RPM_VERSION_MINOR=${RPM_VERSION_MINOR}
RPM_VERSION_MICRO=${RPM_VERSION_MICRO}
LOCALEDIR="${LOCALEDIR}"
)
add_executable(distromatic
buildtools.c
changelog.c
distromatic.c
functions.c
reports.c
headerlist.c
requirelist.c
rpmfunctions.c
backend-sqlite3.c
)
target_link_libraries(distromatic
Threads::Threads
${RPM_LIBRARIES}
${ZLIB_LIBRARIES}
${SQLITE3_LIBRARIES}
${LIBIBERTY}
)
target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS})
target_compile_options(distromatic PUBLIC ${RPM_CFLAGS_OTHER})
add_executable(distroquery
distroquery.c
functions.c
headerlist.c
requirelist.c
rpmfunctions.c
changelog.c
)
target_link_libraries(distroquery
Threads::Threads
${RPM_LIBRARIES}
${ZLIB_LIBRARIES}
${SQLITE3_LIBRARIES}
${LIBIBERTY}
)
target_include_directories(distroquery PUBLIC ${RPM_INCLUDE_DIRS})

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2013-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2013-2020 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
@ -18,7 +18,6 @@
*/
#include <sqlite3.h>
#include "config.h"
#include "headerlist.h"
#include "changelog.h"
#include "backend-sqlite3.h"
@ -56,7 +55,7 @@ int SQLite_begin_transaction(sqlite3 *db) {
int SQLite_commit_transaction(sqlite3 *db) {
if (sqlite3_exec(db, "COMMIT;", 0, 0, 0)) {
fprintf(stderr, "ERROR: SQLite: (COMMIT) %s\n", sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (COMMIT) %s\n", sqlite3_errmsg(db));
return 1;
}
sqlite3_transaction_size = 0;
@ -64,8 +63,8 @@ int SQLite_commit_transaction(sqlite3 *db) {
}
int SQLite_print_contents_subtree(sqlite3 *db,
struct fileTree* ft,
struct configTag* ct,
struct fileTree* ft,
struct configTag* ct,
int arch) {
int thisrep, i;
@ -268,7 +267,7 @@ int generateSQLite_packagers(sqlite3 *db) {
packager->packages_count);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
}
sqlite3_bind_text(stmt, 1, packager->name, -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) {
@ -295,7 +294,7 @@ long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog,
changelog->pkg->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
}
sqlite3_bind_text(stmt, 1, changelog->release, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, changelog->text, -1, SQLITE_STATIC);
@ -468,7 +467,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
currsource->size,
(currsource->changelog?nextchangelogid:0));
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
}
sqlite3_bind_text(stmt, 1, currsource->name, -1, SQLITE_STATIC);
@ -518,7 +517,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
currsource->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
}
sqlite3_bind_text(stmt, 1, currsource->patch[i], -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) {
@ -555,7 +554,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
currsource->required[i]->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
}
if (sqlite3_step(stmt) != SQLITE_DONE) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2006 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
@ -44,6 +40,7 @@
#endif
#include "distromatic.h"
#include "config.h"
#include "changelog.h"
#include "functions.h"
@ -85,7 +82,7 @@ getPackagerByName(char *name, int create)
i++;
}
}
if (!match) {
lastpackager = currpackager;
currpackager = currpackager->next;
@ -127,7 +124,7 @@ getPackageChangelog(Header h, struct headerSourceList* headersource)
struct Packager *currpackager = NULL;
char **changelogtext, **changelogrelease;
char *endp;
int_32 *changelogtime;
uint_32 *changelogtime;
char changelogname[255];
changelogtime = headerGetUIntArrayEntry(h, RPMTAG_CHANGELOGTIME, &count);
@ -254,7 +251,7 @@ printChangelogSince(FILE *fout, struct configTag *ct,
changeLogTimeStr(strdate, changelogfull->changelog));
lasttime=changelogfull->changelog->time;
}
fprintf(fout,"<p><a href=\"%stag=%s&amp;pkg=%s.source\">%s</a> %s - ",
fprintf(fout,"<p><a href=\"%stag=%s&amp;pkg=%s.source\">%s</a> %s - ",
ct->configdefaults->url_prefix,
ct->tag,
changelogfull->source->name,

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,8 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
/* Tell glibc's <time.h> to provide a prototype for strptime() */
#ifndef __USE_XOPEN
# define __USE_XOPEN
@ -114,8 +112,8 @@ int compareRequiredList(const void *ptr1, const void *ptr2);
int handleObsoletedPackages(struct configTag *ct, int arch);
static const char *copyright[] = {
PROGRAMNAME " version " PROGRAMVERSION,
"Copyright (C) 2004-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>",
PACKAGE " version " PACKAGE_VERSION,
"Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>",
"Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>",
(char *)0
};
@ -228,10 +226,10 @@ compareRequiredList(const void *ptr1, const void *ptr2)
if (!require1 && !require2) return 0;
if (!require1 || !require1->name) return 1;
if (!require2 || !require2->name) return -1;
/* if (require1->resolved->numproviders != require2->resolved->numproviders)
/* if (require1->resolved->numproviders != require2->resolved->numproviders)
return require2->resolved->numproviders - require1->resolved->numproviders;
if (require1->resolved->numproviders == 1)
if (require1->resolved->numproviders == 1)
return strcmp(require1->resolved->provider[0]->name,require2->resolved->provider[0]->name);
else*/
return strcmp(require1->name,require2->name);
@ -371,7 +369,7 @@ handleObsoletedPackages(struct configTag *ct, int archidx)
prov->provider[i]->arch,
ct->repository[prov->provider[i]->altrepository]->tag);
} else {
snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s)",
snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s provided by %s(%s,%s)",
currheader->name,
currheader->arch,
ct->repository[currheader->altrepository]->tag,
@ -590,7 +588,7 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
}
if (provided->numproviders > 0) {
if (strcmp(currheader->require[i]->version,"") &&
if (strcmp(currheader->require[i]->version,"") &&
(currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
found = 0;
@ -663,7 +661,7 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
ct->repository[currheader->altrepository]->tag);
logmsg(LOG_WARNING,"%s", warning);
for (k = 0; k < provided->numproviders; k++) {
if (provided->provider[k]->sourceheader &&
if (provided->provider[k]->sourceheader &&
(provided->provider[k]->altrepository == ct->repository_level)) {
addWarning(provided->provider[k]->sourceheader, warning);
}
@ -674,7 +672,7 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
}
}
}
}
}
currheader->require[i]->resolved=provided;
@ -721,7 +719,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
currsourceheader->require[i]->name,1,archidx);
if (provided->numbuildproviders == 0) {
// check if require[i]->name requirement is met
// check if require[i]->name requirement is met
if ((currsourceheader->require[i]->name)[0] == '/') {
/* requirement is a file, find who provides it */
@ -768,7 +766,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
}
if (provided->numbuildproviders > 0) {
if (strcmp(currsourceheader->require[i]->version,"") &&
if (strcmp(currsourceheader->require[i]->version,"") &&
(currsourceheader->require[i]->flags & (RPMSENSE_LESS+RPMSENSE_GREATER+RPMSENSE_EQUAL))) {
found = 0;
for (j = 0; j < provided->numproviders; j++) {
@ -790,7 +788,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
if (currsourceheader->require[i]->flags & RPMSENSE_EQUAL) fprintf(stderr,"=");
fprintf(stderr," %s (failing build provider(s):", currsourceheader->require[i]->version);
for (j = 0; j < provided->numbuildproviders; j++) {
fprintf(stderr," %s#%s",
fprintf(stderr," %s#%s",
provided->provider[j]->name, provided->buildprovider[j]->version);
/* printrpmversion(buffer,PATH_MAX,
provided->provider[j]->epoch,
@ -800,7 +798,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
fprintf(stderr,")\n");
}
}
}
}
currsourceheader->require[i]->resolved=provided;
@ -1174,7 +1172,7 @@ main(int argc, char *argv[])
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
pthread_join(pth[i], NULL);
}
if (!passed_arch) { // can't do missing builds and ports check in single arch mode
if (!quietmode)
fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n");

View File

@ -1,7 +1,7 @@
/*
* distroquery - tool for querying data generated by distromatic
*
* Copyright (C) 2013-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2013-2020 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
@ -17,8 +17,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
@ -36,6 +34,9 @@
#include <dirent.h>
#include <sys/stat.h>
#include <ctype.h>
#include <malloc.h>
#include <string.h>
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
@ -73,6 +74,8 @@
#include <sqlite3.h>
#include "distromatic.h"
#include "config.h"
#include "rpmfunctions.h"
#include "functions.h"
// must be as big as ARCHS_MAX (5)
@ -115,11 +118,11 @@ char to_hex(char code) {
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 == '~')
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
*pbuf++ = *pstr;
else if (*pstr == ' ')
else if (*pstr == ' ')
*pbuf++ = '+';
else
else
*pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
pstr++;
}
@ -138,7 +141,7 @@ char *url_decode(char *str) {
*pbuf++ = from_hex(pstr[1]) << 4 | from_hex(pstr[2]);
pstr += 2;
}
} else if (*pstr == '+') {
} else if (*pstr == '+') {
*pbuf++ = ' ';
} else {
*pbuf++ = *pstr;
@ -157,7 +160,7 @@ int sqlite3_find_column_id(sqlite3_stmt *stmt, const char* table, const char* na
if (!strcmp(colname, name)) {
if (table) {
if (!strcmp(sqlite3_column_table_name(stmt, id), table)) return id;
} else {
} else {
return id;
}
}
@ -313,7 +316,7 @@ void detachRepositoryDatabases(struct configTag* ct, sqlite3 *db, char* arch, in
void printInputForm() {
struct configTag *ct = firstconfigtag;
const char ajax_call[] = "distroquery_request("
// "'repository='+getElementById('repository').value"
"'query='+getElementById('query').value+"
@ -467,7 +470,7 @@ void printFileBrowser() {
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>",
"<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),
@ -855,7 +858,7 @@ void printQueryResponse() {
printf("%s '%s' :: %s", _("Search results for"), query, firstconfigtag->configdefaults->distribution_name);
printf("]]></title>");
}
for (i = 0; query_repositories[i] != NULL; i++) {
for (a = 0; a <= ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
if (query_repositories[i]->db[a]) {
@ -1321,7 +1324,7 @@ void printPackageData() {
" packages_files_rel.id_group=filegroups.id", query_package);
if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
while (sqlite3_step(stmt1) == SQLITE_ROW) {
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>",
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>",
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),
@ -1659,7 +1662,7 @@ main(int argc, char *argv[])
} else if (query_path) {
printFileBrowser();
}
if (!responsed || (responsed && searchbox)) printInputForm();
if (!reply_plain) printf("</distroquery>\n");

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
@ -50,10 +46,6 @@
# include <libiberty.h>
#endif
#ifndef FUNCTIONS_H
# include "functions.h"
#endif
/* Tell glibc's <time.h> to provide a prototype for strptime() */
#ifndef __USE_XOPEN
# define __USE_XOPEN
@ -70,8 +62,9 @@
# endif
#endif
#include "functions.h"
#include "distromatic.h"
#include "config.h"
#include "functions.h"
#include "changelog.h"
#include <execinfo.h>
@ -496,22 +489,22 @@ char *humanSize(long long sbytes, sizeString *s) {
if (sbytes < 1024) {
snprintf((char *)s, SSSIZE, "%lld B", sbytes);
return (char *)s;
return (char *)s;
}
if ((sbytes / 1024) < 1024) {
snprintf((char *)s, SSSIZE, "%.2f KB", sbytes / 1024.0);
return (char*)s;
return (char*)s;
}
if ((sbytes / 1024 / 1024 ) < 1024) {
snprintf((char *)s, SSSIZE, "%.2f MB", sbytes / 1024.0 / 1024.0);
return (char*)s;
return (char*)s;
}
if ((sbytes / 1024 / 1024 / 1024 ) < 1024) {
snprintf((char *)s, SSSIZE, "%.2f GB", sbytes / 1024.0 / 1024.0 / 1024.0);
return (char*)s;
return (char*)s;
}
snprintf((char *)s, SSSIZE, "%.2f TB", sbytes / 1024.0 / 1024.0 / 1024.0 / 1024.0);
return (char*)s;
return (char*)s;
}
@ -519,7 +512,7 @@ const char *htmlclean(const char *source,char *dest,unsigned int max)
{
unsigned int i=0,j=0;
char subst[10];
while (source[i] && i<max) {
switch (source[i]) {
case '<': strcpy(subst,"&lt;"); break;
@ -535,7 +528,7 @@ const char *htmlclean(const char *source,char *dest,unsigned int max)
} else {
fprintf(stderr,"Warning: can't tidy HTML string due to limited buffer.\n");
return source;
}
}
i++;
}
return dest;
@ -545,7 +538,7 @@ const char *htmlcleanNoBr(const char *source,char *dest,unsigned int max)
{
unsigned int i=0,j=0;
char subst[10];
while (source[i] && i<max) {
switch (source[i]) {
case '<': strcpy(subst,"&lt;"); break;
@ -560,7 +553,7 @@ const char *htmlcleanNoBr(const char *source,char *dest,unsigned int max)
} else {
fprintf(stderr,"Warning: can't tidy HTML string due to limited buffer.\n");
return source;
}
}
i++;
}
return dest;
@ -569,7 +562,7 @@ const char *htmlcleanNoBr(const char *source,char *dest,unsigned int max)
/*
scansdir is like scandir with the difference that it uses stat()
to get entry file types
*/
int scansdir(const char *dir, struct dirent ***namelist,
int (*sel)(const struct dirent *),
@ -618,7 +611,7 @@ int scansdir(const char *dir, struct dirent ***namelist,
if (closedir(d)) return(-1);
// if (i == 0) return(-1);
if (compar != NULL)
qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *),
qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *),
(__compar_fn_t) compar);
return(i);

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,7 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <assert.h>
#include <dirent.h>
@ -52,6 +51,7 @@
#endif
#include "distromatic.h"
#include "config.h"
#include "changelog.h"
#include "functions.h"
#include "headerlist.h"
@ -165,13 +165,13 @@ findSourcePackage(struct headerSourceList *list, char *name, char *version,
while (currheaderlist) {
if (!strcmp(name, currheaderlist->name)) {
if (((!release) || !strcmp(release, currheaderlist->release)) &&
((!version) || !strcmp(version, currheaderlist->version)) &&
((!version) || !strcmp(version, currheaderlist->version)) &&
((altrepository < 0) || (altrepository == currheaderlist->altrepository)))
return currheaderlist;
oldheaderlist = currheaderlist->old;
while (oldheaderlist) {
if (((!release) || !strcmp(release, oldheaderlist->release)) &&
((!version) || !strcmp(version, oldheaderlist->version)) &&
((!version) || !strcmp(version, oldheaderlist->version)) &&
((altrepository < 0) || (altrepository == oldheaderlist->altrepository)))
return oldheaderlist;
oldheaderlist = oldheaderlist->old;
@ -338,7 +338,7 @@ generateHeaderSourceStats(struct configTag *ct)
if (currheadersourcelist->altrepository == altrepository) {
stats->headersourcelistvec[c] = currheadersourcelist;
c++;
if (currheadersourcelist->packager &&
if (currheadersourcelist->packager &&
(currheadersourcelist->packager->role & PACKAGER_ROLE_MAINTAINER)) {
currheadersourcelist->packager->packages_count++;
}
@ -394,7 +394,7 @@ sourcerpmselector(const struct dirent *entry)
ptr = strstr(entry->d_name, ".src.rpm");
if (entry->d_type != DT_REG) return 0; /* skip if not a file */
if (ptr == NULL) {
logmsg(LOG_WARNING,"file %s has not src.rpm extension; skipping.",entry->d_name);
return 0;
@ -541,7 +541,7 @@ findOrCreateFileTreeEntry(struct fileTree* *first,char* findname, int arch)
pstart = findname+1; /* skip trailing slash */
pend = findname+1;
l = strlen(findname);
while (pend-findname < l) {
pend=strchr(pstart,'/');
if (pend == 0) pend=findname+l; /* not final slash, it should be a file */
@ -555,7 +555,7 @@ findOrCreateFileTreeEntry(struct fileTree* *first,char* findname, int arch)
}
else
currdir = findOrCreateFileTreeBrother(first,f,arch);
if (!*first)
*first = currdir;
prevdir = currdir;
@ -629,7 +629,7 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
char **requireversion, **requirename;
uint_32 *requireflags;
char warning[PATH_MAX];
#if RPM_VERSION >= 0x040100
#if RPM_VERSION >= 0x050000
rpmts ts = rpmtsCreate();
#else
rpmts ts = NULL;
@ -720,7 +720,7 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
newheadersourcelist->require[j]->resolved = NULL;
}
newheadersourcelist->requirecount = requirecount;
if (mode & GENHEADER_CHANGELOG) {
changelog = getPackageChangelog(h, newheadersourcelist);
while (changelog) {
@ -813,7 +813,9 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
} // for
free(namelist);
#if RPM_VERSION >= 0x050000
rpmtsFree(ts);
#endif
return 0;
}
@ -868,18 +870,18 @@ addToHeaderList(struct configTag *ct,
char filepath[bufsize + 1], currname[bufsize + 1];
char *filename=NULL;
long i ,j , k, n, altn[ALT_REPS_MAX];
int altrepository=0, obsoletecount, providecount, requirecount,
int altrepository=0, obsoletecount, providecount, requirecount,
filenamecount, dirnamecount,
*dirindex;
int_16 *fileflags;
char **obsoletename, **obsoleteversion,
**providename, **provideversion,
char **obsoletename, **obsoleteversion,
**providename, **provideversion,
**requirename, **requireversion,
**basename, **dirname, **newversion,
**fileusername, **filegroupname;
const char* errstr;
uint_32 *requireflags, *obsoleteflags, *provideflags;
#if RPM_VERSION >= 0x040100
#if RPM_VERSION >= 0x050000
rpmts ts = rpmtsCreate();
#else
rpmts ts = NULL;
@ -959,7 +961,7 @@ addToHeaderList(struct configTag *ct,
altrepository=i+1;
altcnt[i]++;
/* check for duplicates in alternate repository */
if ((altcnt[i] < altn[i] - 1) &&
if ((altcnt[i] < altn[i] - 1) &&
(!rpmnamecmp(altnamelist[i][altcnt[i]]->d_name,altnamelist[i][altcnt[i]+1]->d_name,0))) {
if (i == ct->repository_level-1) {
logmsg(LOG_WARNING, "%s: duplicated RPM package (skipped)",
@ -973,9 +975,10 @@ addToHeaderList(struct configTag *ct,
/* break while loop when no more packages are found */
if (currname[0] == '\0') { break; }
/* process package */
/* process package */
logmsg(LOG_DEBUG, "getting header for %s", filepath);
sem_t rpm_mutex;
sem_wait(&rpm_mutex);
if (getHeader(&ts, filepath, &h)) {
sem_post(&rpm_mutex);
@ -1011,7 +1014,7 @@ addToHeaderList(struct configTag *ct,
(void) headerFree(h);
free(newheaderlist);
continue;
} else {
} else {
if (getPackageNameFromFile(newheaderlist->sourcename)) {
logmsg(LOG_WARNING,
"file %s doesn't have a standard format; skipping package.");
@ -1046,14 +1049,14 @@ addToHeaderList(struct configTag *ct,
currheaderlist->next = newheaderlist;
}
currheaderlist = newheaderlist;
if (!ct->headerlist[arch]) {
/* set first pointer of the list */
ct->headerlist[arch] = newheaderlist;
}
} else if (newheaderlist->sourcename) /* missing source header */ {
if ((!newheaderlist->sourceheader) ||
(newheaderlist->sourceheader->altrepository) <= altrepository)
{
@ -1173,7 +1176,9 @@ addToHeaderList(struct configTag *ct,
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]); }
else free(namelist[cnt-1]);
} // main while
#if RPM_VERSION >= 0x050000
rpmtsFree(ts);
#endif
free(namelist);
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
return 0;

View File

@ -8,9 +8,7 @@
#ifndef BUILDTOOLS_H
#define BUILDTOOLS_H
#ifndef DISTROMATIC_H
# include "distromatic.h"
#endif
#include "config.h"
int generateBuildInfo(struct configTag *configtag, int arch);

View File

@ -1,17 +1,13 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*/
#ifndef CHANGELOG_H
#define CHANGELOG_H
#ifndef RPMFUNCTIONS_H
# include "rpmfunctions.h"
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
@ -23,8 +19,9 @@
# endif
#endif
#define PACKAGER_MAXALIASES 5
#define PACKAGER_ROLE_MAINTAINER 1
#include "distromatic.h"
#include "config.h"
#include "rpmfunctions.h"
struct changeLog {
long time;

48
src/include/config.h Normal file
View File

@ -0,0 +1,48 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "distromatic.h"
#include "headerlist.h"
struct configDefaults {
char *html_basedir;
char *distribution_name;
char *url_address;
char *url_prefix;
char *url_search_prefix;
char *url_dir;
char *favicon_search_prefix;
char *arch[ARCHS_MAX];
};
struct configTag {
struct configDefaults *configdefaults;
char *tag;
char *description;
char *repository_dir;
char *repository_source_dir;
struct configTag *repository[ALT_REPS_MAX+1];
int repository_level;
char *html_dir;
char *download_prefix;
char *download_dir;
char *showfile_prefix;
char *arch[ARCHS_MAX];
struct headerList *headerlist[ARCHS_MAX];
struct headerSourceList *headersourcelist;
struct providedList *providedlist_idx[ARCHS_MAX][PROVIDEDLIST_IDX_SIZE];
struct fileTree *filetree[ARCHS_MAX];
struct fileUserList *fileuserlist[ARCHS_MAX];
struct fileGroupList *filegrouplist[ARCHS_MAX];
struct headerStats stats;
struct configTag *next;
void *db[ARCHS_MAX + 1];
};
#endif

View File

@ -1,51 +1,27 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*/
#ifndef DISTROMATIC_H
#define DISTROMATIC_H
#include "globaldefs.h"
#include "headerlist.h"
#define PACKAGE_BUGREPORT "silvan.calarco@mambasoft.it"
#define ARCHS_MAX 5
#define OBSOLETE_MAX 16384
struct configDefaults {
char *html_basedir;
char *distribution_name;
char *url_address;
char *url_prefix;
char *url_search_prefix;
char *url_dir;
char *favicon_search_prefix;
char *arch[ARCHS_MAX];
};
struct configTag {
struct configDefaults *configdefaults;
char *tag;
char *description;
char *repository_dir;
char *repository_source_dir;
struct configTag *repository[ALT_REPS_MAX+1];
int repository_level;
char *html_dir;
char *download_prefix;
char *download_dir;
char *showfile_prefix;
char *arch[ARCHS_MAX];
struct headerList *headerlist[ARCHS_MAX];
struct headerSourceList *headersourcelist;
struct providedList *providedlist_idx[ARCHS_MAX][PROVIDEDLIST_IDX_SIZE];
struct fileTree *filetree[ARCHS_MAX];
struct fileUserList *fileuserlist[ARCHS_MAX];
struct fileGroupList *filegrouplist[ARCHS_MAX];
struct headerStats stats;
struct configTag *next;
void *db[ARCHS_MAX + 1];
};
#define DEFAULT_ARCH "i586"
#define CONF_DEFAULTS_SECTION 1
#define CONF_REP_SECTION 0
#define CONF_MAINTAINERS_SECTION 2
#define GENHEADER_CHANGELOG 1
#define GENHEADER_BASE 2
#define GENHEADER_REQUIREMENTS 4
#define GENHEADER_STATS 8
#define ALT_REPS_MAX 10
#define PACKAGER_MAXALIASES 5
#define PACKAGER_ROLE_MAINTAINER 1
#endif

View File

@ -1,13 +1,15 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*/
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <dirent.h>
#define HDSIZE 16
#define SSSIZE 16

View File

@ -1,20 +0,0 @@
/*
* globaldefs.h - global definitions for distromatic
*
* Copyright (C) 2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
*/
#ifndef GLOBALDEFS_H
#define GLOBALDEFS_H
#define PROGRAMNAME "@PACKAGE_NAME@"
#define PROGRAMVERSION "@PACKAGE_VERSION@"
#define DEFAULT_CONFIGFILE "@sysconfdir@/@PACKAGE_NAME@.conf"
#define DEFAULT_ARCH "@DEFAULT_ARCH@"
#define ARCHS_MAX 5
#define CONF_REP_SECTION 0
#define CONF_DEFAULTS_SECTION 1
#define CONF_MAINTAINERS_SECTION 2
#endif

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*/
@ -10,17 +10,11 @@
#define PROVIDEDLIST_IDX_SIZE 20
#include "globaldefs.h"
#ifndef RPMFUNCTIONS_H
# include "rpmfunctions.h"
#include "rpmfunctions.h"
#endif
#define GENHEADER_CHANGELOG 1
#define GENHEADER_BASE 2
#define GENHEADER_REQUIREMENTS 4
#define GENHEADER_STATS 8
#define ALT_REPS_MAX 10
#include "distromatic.h"
struct providedList {
char *name;

View File

@ -1,19 +1,40 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*/
#ifndef RPMFUNCTIONS_H
#define RPMFUNCTIONS_H
/* Define to the RPM version */
#define RPM_VERSION ((RPM_VERSION_MAJOR<<16)|(RPM_VERSION_MINOR<<8)|RPM_VERSION_MICRO)
#if RPM_VERSION_MAJOR == 4
#define uint_32 uint32_t
#define int_16 rpmFlags
#define HE_t rpmTagVal
#endif
#ifndef H_RPMLIB
# include <rpm/rpmlib.h>
#endif
#if RPM_VERSION >= 0x040100
#include <rpm/rpmts.h>
#else
#define rpmReadPackageFile(a,b,c,d) rpmReadPackageHeader(b,d,0,NULL,NULL)
#endif
#if RPM_VERSION >= 0x050000
#ifndef H_RPMEVR
#include <rpm/rpmevr.h>
#endif
#endif
#include <semaphore.h>
#include "headerlist.h"
#include <dirent.h>
#define HEADERS_BUFFER_SIZE 2000000
@ -21,8 +42,6 @@ unsigned int checkVersionWithFlags(const char* cmp1, const uint_32 flags, const
void rpminit(void);
//int myHeaderGetEntry(Header h, int_32 tag, int *type, void** p, int *c);
char *headerGetStringEntry(Header h, const int tag);
char **headerGetStringArrayEntry(Header h, const int tag, int* count);
@ -58,6 +77,4 @@ int scanrpmnamecmp(const struct dirent **f1, const struct dirent **f2);
char* printrpmversion(char *s, int bufsize, long epoch, char *version, char *release);
sem_t rpm_mutex;
#endif // RPMFUNCTIONS_H

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
@ -32,6 +28,7 @@
# include <strings.h>
#endif
#include "distromatic.h"
#include "changelog.h"
#include "reports.h"
#include "rpmfunctions.h"
@ -71,7 +68,7 @@ comparePackagers(const void *ptr1, const void *ptr2)
else {
ret=strcasecmp((*(struct headerSourceList **)ptr1)->packager->name,
(*(struct headerSourceList **)ptr2)->packager->name);
if (!ret) {
ret=strcasecmp((*(struct headerSourceList **)ptr1)->name,
(*(struct headerSourceList **)ptr2)->name);
@ -235,7 +232,7 @@ generateMaintainersPages(struct configTag *configtag)
comparePackagers);
snprintf(outfile, PATH_MAX, "%smaintainers", configtag->html_dir);
if (stat(outfile,&buf)) {
if (stat(outfile,&buf)) {
if (mkdir(outfile,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
logmsg(LOG_ERROR,"cannot create %s directory; aborting.",outfile);
exit(1);
@ -263,7 +260,7 @@ generateMaintainersPages(struct configTag *configtag)
if ((unmaint = fopen(unmaintfile, "w")) == NULL) {
perror(unmaintfile);
return 1;
return 1;
}
fprintf(unmaint,
@ -279,7 +276,7 @@ generateMaintainersPages(struct configTag *configtag)
if ((i == 0) ||
((configtag->stats.headersourcelistvec[i-1])->packager != (configtag->stats.headersourcelistvec[i])->packager)) {
if ((configtag->stats.headersourcelistvec[i])->packager->role &
PACKAGER_ROLE_MAINTAINER) {
@ -289,7 +286,7 @@ generateMaintainersPages(struct configTag *configtag)
if ((out = fopen(outfile, "w")) == NULL) {
perror(outfile);
return 1;
return 1;
}
fprintf(out,
@ -299,7 +296,7 @@ generateMaintainersPages(struct configTag *configtag)
} // new maintainer file created
} // check for changed packager
if ((configtag->stats.headersourcelistvec[i])->packager->role & PACKAGER_ROLE_MAINTAINER) {
fprintf(out,
"<a href=\"%stag=%s&amp;pkg=%s.source\">%s</a>: %s<br>\n",
@ -311,7 +308,7 @@ generateMaintainersPages(struct configTag *configtag)
pkgnum++;
if ((i+1 >= configtag->stats.headersourcecount) ||
((configtag->stats.headersourcelistvec[i])->packager !=
((configtag->stats.headersourcelistvec[i])->packager !=
(configtag->stats.headersourcelistvec[i+1])->packager)) {
fprintf(idx,
@ -419,7 +416,7 @@ generateStats(struct configTag *configtag,int arch)
/* create groups directory */
snprintf(outfile, PATH_MAX, "%sgroups",configtag->html_dir);
if (stat(outfile,&buf)) {
if (stat(outfile,&buf)) {
if (mkdir(outfile,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
logmsg(LOG_ERROR,"cannot create %s directory; aborting.",outfile);
exit(1);
@ -442,13 +439,13 @@ generateStats(struct configTag *configtag,int arch)
if (pkgnum==0) {
snprintf(outfile, PATH_MAX, "%sgroups/%s",
configtag->html_dir,
snprintf(outfile, PATH_MAX, "%sgroups/%s",
configtag->html_dir,
groupdirname(configtag->stats.headersourcelistvec[i]->group,buffer,PATH_MAX));
if (stat(outfile,&buf)) {
if (stat(outfile,&buf)) {
if (mkdir(outfile,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
logmsg(LOG_ERROR,"cannot create %s directory; aborting.",outfile);
logmsg(LOG_ERROR,"cannot create %s directory; aborting.",outfile);
exit(1);
}
} else {
@ -505,7 +502,7 @@ generateStats(struct configTag *configtag,int arch)
if ((htmlout = fopen(outfile, "w")) == NULL) {
perror(outfile);
return 1;
}
}
/*else {
fprintf(htmlout, "<a href=\"%s/%s/recent.rss\">"
"<img src=\"%s/feed-icon.png\" "
@ -543,7 +540,7 @@ generateStats(struct configTag *configtag,int arch)
//fprintf(rssout," <description></description>\n");
fprintf(rssout," <language>en-us</language>\n");
fprintf(rssout," <docs>http://blogs.law.harvard.edu/tech/rss</docs>");
fprintf(rssout," <generator>Distromatic %s</generator>\n",VERSION);
fprintf(rssout," <generator>Distromatic %s</generator>\n",PACKAGE_VERSION);
}
/* sort headersourcelistvec by BuildDate */
@ -613,7 +610,7 @@ generateStats(struct configTag *configtag,int arch)
(configtag->stats.headersourcelistvec)[configtag->stats.headersourcecount-1-i]->version,
(configtag->stats.headersourcelistvec)[configtag->stats.headersourcecount-1-i]->release);
}
if (i < RSSSTATS_NUM) {
// RSS recent packages
fprintf(rssout," <item>\n");
@ -652,7 +649,7 @@ generateStats(struct configTag *configtag,int arch)
perror(outfile);
return 1;
} else {
/* remove final slashes from download_prefix as required by apt */
strncpy(buffer, configtag->download_dir, PATH_MAX);
@ -882,7 +879,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
// create warnings directory
snprintf(warningsdir,PATH_MAX,"%swarnings",configtag->html_dir);
if (stat(warningsdir,&buf)) {
if (stat(warningsdir,&buf)) {
if (mkdir(warningsdir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
logmsg(LOG_ERROR,"cannot create %s directory; aborting.",warningsdir);
exit(1);
@ -964,7 +961,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
buffer2,
currheadersourcelist->name,
htmlclean(currheadersourcelist->summary,buffer,PATH_MAX));
fprintf(fout,"<p>");
printHTMLWarnings(fout,configtag,currheadersourcelist,1);
@ -996,7 +993,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
fprintf(fout,
"<tr><td>Maintainer:</td><td>");
if (currheadersourcelist->packager &&
if (currheadersourcelist->packager &&
(currheadersourcelist->packager->role & PACKAGER_ROLE_MAINTAINER)) {
fprintf(fout,
"<a href=\"%stag=%s&amp;maintainer=%s\">%s</a></td></tr>\n",
@ -1010,7 +1007,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
"<a href=\"%stag=%s&amp;maintainer=unmaintained\"><b>unmaintained</b></a></td></tr>\n",
configtag->configdefaults->url_prefix,
configtag->tag);
fprintf(fout,
"<tr><td>Description:</td><td><font size=\"-1\">%s</font></td></tr>\n",
htmlclean(currheadersourcelist->description,buffer,PATH_MAX));
@ -1061,7 +1058,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
fprintf(fout,"</font></td></tr>\n");
}
if (currheadersourcelist->patch) {
fprintf(fout,"<tr><td>Patches:</td><td><font size=\"-1\">");
@ -1196,7 +1193,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
}
} else {
// multiple providers
if (i == 0 ||
if (i == 0 ||
strcmp(currheadersourcelist->require[i-1]->resolved->name,
currheadersourcelist->require[i]->resolved->name))
fprintf(fout,"<i>%s</i>(",currheadersourcelist->require[i]->resolved->name);
@ -1236,9 +1233,9 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
(humanDate *) & strdate);
if (currchangelog->pkg) {
if ((currchangelog->pkg->role & PACKAGER_ROLE_MAINTAINER) &&
if ((currchangelog->pkg->role & PACKAGER_ROLE_MAINTAINER) &&
(currchangelog->pkg->packages_count)) {
fprintf(fout, "%s - <a href=\"%stag=%s&amp;maintainer=%s\">%s</a> (%s)<br>%s<br>",
fprintf(fout, "%s - <a href=\"%stag=%s&amp;maintainer=%s\">%s</a> (%s)<br>%s<br>",
&strdate[0],
configtag->configdefaults->url_prefix,
configtag->tag,
@ -1248,15 +1245,15 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
htmlclean(currchangelog->text,buffer,PATH_MAX));
// currchangelog->pkg->changes_count++;
} else {
fprintf(fout, "%s - %s (%s)<br>%s<br>",
fprintf(fout, "%s - %s (%s)<br>%s<br>",
&strdate[0],
currchangelog->pkg->name,
currchangelog->release,
htmlclean(currchangelog->text,buffer,PATH_MAX));
htmlclean(currchangelog->text,buffer,PATH_MAX));
// currchangelog->pkg->changes_count++;
}
} else
fprintf(fout, "%s - (noname) (%s)<br>%s<br>",
fprintf(fout, "%s - (noname) (%s)<br>%s<br>",
&strdate[0],
currchangelog->release,
htmlclean(currchangelog->text,buffer,PATH_MAX));
@ -1585,7 +1582,7 @@ generateHTMLFiles(struct configTag *ct, int arch)
fprintf(fout,"<b>%s(unresolved)</b> ",currheaderlist->require[i]->resolved->name);
} else if (currheaderlist->require[i]->resolved->numproviders == 1) {
// single provider
if ((i == 0 ||
if ((i == 0 ||
!currheaderlist->require[i-1]->resolved ||
!currheaderlist->require[i-1]->resolved->numproviders ||
strcmp(currheaderlist->require[i-1]->resolved->provider[0]->name,
@ -1613,7 +1610,7 @@ generateHTMLFiles(struct configTag *ct, int arch)
}
} else {
// multiple providers
if (i == 0 ||
if (i == 0 ||
!currheaderlist->require[i-1]->resolved ||
!currheaderlist->require[i-1]->resolved->numproviders ||
strcmp(currheaderlist->require[i-1]->resolved->name,
@ -1699,7 +1696,7 @@ generateHTMLFiles(struct configTag *ct, int arch)
fprintf(fout,
"<tr><td>Filenames:</td><td><font size=\"-1\">");
for (i = 0; i < currheaderlist->filenamecount; i++) {
ftname((currheaderlist->file)[i],
ftname((currheaderlist->file)[i],
buffer, PATH_MAX);
fprintf(fout, "/%s ",buffer);
@ -1735,9 +1732,9 @@ char *ftname(struct fileTree* ft, char* buf, unsigned int bufsize) {
return buf;
}
void print_contents_subtree(FILE *f,
struct fileTree* ft,
struct configTag* ct,
void print_contents_subtree(FILE *f,
struct fileTree* ft,
struct configTag* ct,
char* buf, int bufsize) {
int i,j,k;
@ -2145,7 +2142,7 @@ generateSrcPkgList(struct configTag *ct)
currheadersourcelist = ct->headersourcelist;
while (currheadersourcelist != NULL) {
fprintf(fd, "%s %s %s %s %ld %s ",
fprintf(fd, "%s %s %s %s %ld %s ",
currheadersourcelist->name,
currheadersourcelist->version,
(char *)simpleTimeToTemplate(currheadersourcelist->buildtime,"%Y%m%d",&strdate),

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>

View File

@ -1,7 +1,7 @@
/*
* distromatic - tool for RPM based repositories
*
* Copyright (C) 2004-2006 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2004-2020 by Silvan Calarco <silvan.calarco@mambasoft.it>
* Copyright (C) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it under
@ -18,10 +18,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
@ -34,22 +30,6 @@
#include <fcntl.h>
#ifndef H_RPMLIB
# include <rpm/rpmlib.h>
#endif
#if RPM_VERSION >= 0x040100
#include <rpm/rpmts.h>
#else
#define rpmReadPackageFile(a,b,c,d) rpmReadPackageHeader(b,d,0,NULL,NULL)
#endif
#if RPM_VERSION >= 0x040409
#ifndef H_RPMEVR
#include <rpm/rpmevr.h>
#endif
#endif
#include <zlib.h>
#include <libiberty/libiberty.h>
#include "functions.h"
@ -64,9 +44,9 @@
* char **summary); */
unsigned int checkVersionWithFlags(const char* cmp1, uint_32 flags, const char* cmp2) {
int vercmp = 0;
#if RPM_VERSION_MAJOR >= 5
struct EVR_s evr1, evr2;
int vercmp = 0;
sem_wait(&rpm_mutex);
rpmEVRparse(cmp1, &evr1);
@ -79,6 +59,9 @@ unsigned int checkVersionWithFlags(const char* cmp1, uint_32 flags, const char*
if (!vercmp) vercmp=rpmvercmp(evr1.F[RPMEVR_V], evr2.F[RPMEVR_V]);
if (!vercmp && strlen(evr1.F[RPMEVR_R]) && strlen(evr2.F[RPMEVR_R])) vercmp=rpmvercmp(evr1.F[RPMEVR_R], evr2.F[RPMEVR_R]);
#else
vercmp=rpmvercmp(cmp1, cmp2);
#endif
if ((vercmp == 0) && (flags & RPMSENSE_EQUAL)) return 1;
else if ((vercmp == 1) && (flags & RPMSENSE_LESS)) return 1;
@ -126,13 +109,14 @@ getHeader(rpmts* ts, char *headerFile, Header * h)
#if RPM_VERSION >= 0x040100
rc = rpmReadPackageFile(*ts, fd, headerFile, h);
Fclose(fd);
#else
rc = rpmReadPackageHeader(fd, h, NULL, NULL, NULL);
#endif
fdClose(fd);
#endif
#if RPM_VERSION >= 0x040100
if (rc != RPMRC_OK && rc != RPMRC_NOTTRUSTED && rc != RPMRC_NOKEY) {
// fprintf(stderr, "Error: Failed reading file %s\n", headerFile);
// fprintf(stderr, "Error: Failed reading file %s\n", headerFile);
#else
if (rc != 0) {
#endif
@ -146,8 +130,9 @@ getHeader(rpmts* ts, char *headerFile, Header * h)
char *
headerGetStringEntry(Header h, const int tag)
{
char *st = NULL;
const char *st = NULL;
#if RPM_VERSION_MAJOR >= 0x050000
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
he->tag = tag;
@ -157,7 +142,10 @@ headerGetStringEntry(Header h, const int tag)
st = NULL;
//printf(" headerGetStringEntry tag:%d st:%s\n", he->tag, st);
he->p.ptr = _free(he->p.ptr);
he->p.ptr = _free(he->p.ptr);
#else
st = headerGetString(h, tag);
#endif
return st;
}
@ -166,6 +154,7 @@ headerGetStringArrayEntry(Header h, const int tag, int* count)
{
char **st;
#if RPM_VERSION_MAJOR >= 0x050000
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
he->tag = tag;
@ -180,15 +169,20 @@ headerGetStringArrayEntry(Header h, const int tag, int* count)
//for (i=0; i < he->c; i++) {
//fprintf(stderr," headerGetStringArrayEntry tag:%d string %d/%d:%s\n", he->tag, i+1, he->c, st[i]);
//}
he->p.ptr = _free(he->p.ptr);
he->p.ptr = _free(he->p.ptr);
#else
st = headerGetString(h, tag);
#endif
return st;
}
long long headerGetUIntEntry(Header h, const int tag) {
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
unsigned long long ret = -1;
#if RPM_VERSION_MAJOR >= 0x050000
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
he->tag = tag;
if (headerGet(h, he, 0) && he->c == 1) {
switch (he->t) {
@ -212,15 +206,19 @@ long long headerGetUIntEntry(Header h, const int tag) {
//fprintf(stderr," headerGetUIntEntry tag:%d uint %lld\n", he->tag, ret);
he->p.ptr = _free(he->p.ptr);
he->p.ptr = _free(he->p.ptr);
#else
ret = headerGetNumber(h, tag);
#endif
return ret;
}
void *headerGetUIntArrayEntry(Header h, const int tag, int *count) {
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
void *ret = NULL;
#if RPM_VERSION_MAJOR >= 0x050000
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
he->tag = tag;
if (headerGet(h, he, 0) && he->c >= 1) {
*count = he->c;
@ -233,7 +231,7 @@ void *headerGetUIntArrayEntry(Header h, const int tag, int *count) {
break;
case RPM_UINT32_TYPE:
ret = memndup(he->p.ui32p, *count * 4);
//int i;
//int i;
//for (i=0; i<he->c; i++) {
// printf("%d ",((int_32 *)ret)[i]);
//}
@ -251,7 +249,10 @@ void *headerGetUIntArrayEntry(Header h, const int tag, int *count) {
for (i=0; i < he->c; i++) {
fprintf(stderr," headerGetUIntArrayEntry tag:%d value:%ld\n", he->tag, ((rpmuint32_t*)ret)[i]);
}*/
he->p.ptr = _free(he->p.ptr);
he->p.ptr = _free(he->p.ptr);
#else
ret = headerGetNumber(h, tag);
#endif
return ret;
}
@ -316,15 +317,15 @@ int rpmnamecmp(char *filename1, char *filename2, int checkver) {
/* find name end position assuming a "name-version-release" scheme */
for (i = strlen(filename1)-1; (i > 0) && (f < 2); i--) {
if (filename1[i] == '-') {
f++;
if (filename1[i] == '-') {
f++;
end1=i-1;
}
}
f=0;
for (i = strlen(filename2)-1; (i > 0) && (f < 2); i--) {
if (filename2[i] == '-') {
if (filename2[i] == '-') {
f++;
end2=i-1;
}
@ -339,12 +340,12 @@ int rpmnamecmp(char *filename1, char *filename2, int checkver) {
if (c1 < c2) return -1;
else if (c1 > c2) return 1;
}
if (end1 < end2) return -1;
else if (end1 > end2) return 1;
/* same name, sort by version */
if (checkver)
if (checkver)
i=rpmvercmp(&filename2[i+1],&filename1[i+1]) * -1;
else
i=0;
@ -357,7 +358,7 @@ int scanrpmnamecmp(const struct dirent **f1, const struct dirent **f2) {
}
char* printrpmversion(char *s, int bufsize, long epoch, char *version, char *release) {
if (strcmp(release,"")) {
if (epoch)
snprintf(s,bufsize,"%ld:%s-%s",epoch,version,release);
@ -378,5 +379,6 @@ void rpminit() {
// ts = rpmtsCreate();
// rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
#endif
sem_t rpm_mutex;
sem_init(&rpm_mutex, 0, 1);
}