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

3
.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
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"

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"
@ -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);

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
};

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)

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>

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"
@ -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;
@ -813,7 +813,9 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
} // for
free(namelist);
#if RPM_VERSION >= 0x050000
rpmtsFree(ts);
#endif
return 0;
}
@ -879,7 +881,7 @@ addToHeaderList(struct configTag *ct,
**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;
@ -976,6 +978,7 @@ addToHeaderList(struct configTag *ct,
/* 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);
@ -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"
#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"
@ -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 */

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) {
struct EVR_s evr1, evr2;
int vercmp = 0;
#if RPM_VERSION_MAJOR >= 5
struct EVR_s evr1, evr2;
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,10 +109,11 @@ 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);
@ -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;
@ -158,6 +143,9 @@ headerGetStringEntry(Header h, const int tag)
//printf(" headerGetStringEntry tag:%d st:%s\n", he->tag, st);
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;
@ -181,14 +170,19 @@ headerGetStringArrayEntry(Header h, const int tag, int* count)
//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);
#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) {
@ -213,14 +207,18 @@ 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);
#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;
@ -252,6 +250,9 @@ 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);
#else
ret = headerGetNumber(h, tag);
#endif
return ret;
}
@ -378,5 +379,6 @@ void rpminit() {
// ts = rpmtsCreate();
// rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
#endif
sem_t rpm_mutex;
sem_init(&rpm_mutex, 0, 1);
}