INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
-FIND_PACKAGE (EXPAT REQUIRED)
-FIND_PACKAGE (ZLIB REQUIRED)
-IF (ENABLE_LZMA_COMPRESSION)
-FIND_PACKAGE (LZMA REQUIRED)
-ENDIF (ENABLE_LZMA_COMPRESSION)
+SET (have_system x)
IF (FEDORA)
MESSAGE(STATUS "Building for Fedora")
ADD_DEFINITIONS (-DFEDORA)
SET (ENABLE_RPMDB ON)
SET (ENABLE_RPMMD ON)
+SET (have_system ${have_system}x)
ENDIF (FEDORA)
IF (DEBIAN)
MESSAGE (STATUS "Building for Debian")
ADD_DEFINITIONS (-DDEBIAN)
SET (ENABLE_DEBIAN ON)
+SET (have_system ${have_system}x)
ENDIF (DEBIAN)
+IF (SUSE)
+MESSAGE (STATUS "Building for SUSE")
+ADD_DEFINITIONS (-DSUSE)
+SET (ENABLE_RPMDB ON)
+SET (ENABLE_RPMDB_PUBKEY ON)
+SET (ENABLE_RPMMD ON)
+SET (ENABLE_SUSEREPO ON)
+SET (ENABLE_HELIXREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (SUSE)
+
+IF (ARCHLINUX)
+MESSAGE (STATUS "Building for Archlinux")
+ADD_DEFINITIONS (-DARCHLINUX)
+SET (ENABLE_ARCHREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (ARCHLINUX)
+
+IF (MANDRIVA)
+MESSAGE (STATUS "Building for Mandriva/Mageia")
+ADD_DEFINITIONS (-DMANDRIVA)
+SET (ENABLE_MDKREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (MANDRIVA)
+
+IF (${have_system} STREQUAL x)
+ MESSAGE (STATUS "Building for no system")
+ ADD_DEFINITIONS (-DNOSYSTEM)
+ENDIF (${have_system} STREQUAL x)
+IF (${have_system} STRGREATER xx)
+ MESSAGE (FATAL_ERROR "Can only compile for one system type.")
+ENDIF (${have_system} STRGREATER xx)
+
+IF (ENABLE_ARCHREPO)
+SET (ENABLE_LZMA_COMPRESSION ON)
+ENDIF (ENABLE_ARCHREPO)
+
+FIND_PACKAGE (EXPAT REQUIRED)
+FIND_PACKAGE (ZLIB REQUIRED)
+IF (ENABLE_LZMA_COMPRESSION)
+FIND_PACKAGE (LZMA REQUIRED)
+ENDIF (ENABLE_LZMA_COMPRESSION)
+
IF (RPM5)
MESSAGE (STATUS "Enabling RPM 5 support")
ADD_DEFINITIONS (-DRPM5)
ADD_DEFINITIONS (-DMULTI_SEMANTICS)
ENDIF (MULTI_SEMANTICS)
-# compat: enable some database types
-IF (NOT ENABLE_RPMDB AND
- NOT ENABLE_RPMMD AND
- NOT ENABLE_SUSEREPO AND
- NOT ENABLE_HELIXREPO AND
- NOT ENABLE_MDKREPO AND
- NOT ENABLE_ARCHREPO AND
- NOT ENABLE_DEBIAN)
- SET (ENABLE_RPMDB ON)
- SET (ENABLE_RPMDB_PUBKEY ON)
- SET (ENABLE_RPMMD ON)
- SET (ENABLE_SUSEREPO ON)
- SET (ENABLE_HELIXREPO ON)
- SET (ENABLE_DEBIAN ON)
-ENDIF ()
-
IF (ENABLE_RPMDB)
FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
#ifdef FEDORA
# define REPOINFO_PATH "/etc/yum.repos.d"
-#else
+#endif
+#ifdef SUSE
# define REPOINFO_PATH "/etc/zypp/repos.d"
# define PRODUCTS_PATH "/etc/products.d"
# define SOFTLOCKS_PATH "/var/lib/zypp/SoftLocks"
#define TYPE_PLAINDIR 3
#define TYPE_DEBIAN 4
+#ifndef NOSYSTEM
static int
read_repoinfos_sort(const void *ap, const void *bp)
{
const struct repoinfo *b = bp;
return strcmp(a->alias, b->alias);
}
+#endif
-#ifndef DEBIAN
+#if defined(SUSE) || defined(FEDORA)
struct repoinfo *
-read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
+read_repoinfos(Pool *pool, int *nrepoinfosp)
{
+ const char *reposdir = REPOINFO_PATH;
char buf[4096];
char buf2[4096], *kp, *vp, *kpe;
DIR *dir;
return repoinfos;
}
-#else
+#endif
+
+#ifdef DEBIAN
struct repoinfo *
-read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
+read_repoinfos(Pool *pool, int *nrepoinfosp)
{
FILE *fp;
char buf[4096];
#endif
+#ifdef NOSYSTEM
+struct repoinfo *
+read_repoinfos(Pool *pool, int *nrepoinfosp)
+{
+ *nrepoinfosp = 0;
+ return 0;
+}
+#endif
+
+
void
free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
{
Repodata *data;
int badchecksum;
int dorefresh;
-#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+#if defined(ENABLE_DEBIAN)
FILE *fpr;
int j;
#endif
repo = repo_create(pool, "@System");
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
printf("rpm database:");
if (stat("/var/lib/rpm/Packages", &stb))
memset(&stb, 0, sizeof(&stb));
if (stat("/var/lib/dpkg/status", &stb))
memset(&stb, 0, sizeof(&stb));
#endif
+#ifdef NOSYSTEM
+ printf("no installed database:");
+ memset(&stb, 0, sizeof(&stb));
+#endif
calc_checksum_stat(&stb, REPOKEY_TYPE_SHA256, installedcookie);
if (usecachedrepo(repo, 0, installedcookie, 0))
printf(" cached\n");
else
{
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
FILE *ofp;
int done = 0;
#endif
printf(" reading\n");
-#if defined(ENABLE_SUSEREPO) && defined(PRODUCTS_PATH)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
+# if defined(ENABLE_SUSEREPO) && defined(PRODUCTS_PATH)
repo_add_products(repo, PRODUCTS_PATH, 0, REPO_NO_INTERNALIZE);
-#endif
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+# endif
if ((ofp = fopen(calccachepath(repo, 0), "r")) != 0)
{
Repo *ref = repo_create(pool, "@System.old");
}
if (!done)
repo_add_rpmdb(repo, 0, 0, REPO_REUSE_REPODATA);
-#else
-# if defined(ENABLE_DEBIAN) && defined(DEBIAN)
- repo_add_debdb(repo, 0, REPO_REUSE_REPODATA);
-# endif
+#endif
+#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+ repo_add_debdb(repo, 0, REPO_REUSE_REPODATA);
#endif
writecachedrepo(repo, 0, 0, installedcookie);
}
break;
#endif
-#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+#if defined(ENABLE_DEBIAN)
case TYPE_DEBIAN:
printf("debian repo '%s':", cinfo->alias);
fflush(stdout);
}
}
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
struct fcstate {
FILE **newpkgsfps;
pool->nscallback = nscallback;
// pool_setdebuglevel(pool, 2);
setarch(pool);
- repoinfos = read_repoinfos(pool, REPOINFO_PATH, &nrepoinfos);
+ repoinfos = read_repoinfos(pool, &nrepoinfos);
if (mainmode == MODE_REPOLIST)
{
{
int l;
l = strlen(argv[i]);
-#ifndef DEBIAN
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
if (l <= 4 || strcmp(argv[i] + l - 4, ".rpm"))
continue;
-#else
+#endif
+#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
if (l <= 4 || strcmp(argv[i] + l - 4, ".deb"))
continue;
#endif
if (!commandlinerepo)
commandlinerepo = repo_create(pool, "@commandline");
p = 0;
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
p = repo_add_rpm(commandlinerepo, (const char *)argv[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
#endif
#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
addsoftlocks(pool, &job);
#endif
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
rerunsolver:
#endif
for (;;)
printf("Transaction summary:\n\n");
transaction_print(trans);
-#if !defined(FEDORA) && !defined(DEBIAN)
+#if defined(SUSE)
if (1)
{
DUChanges duc[4];
putchar('\n');
}
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
if (newpkgs)
{
Queue conflicts;
transaction_order(trans, 0);
for (i = 0; i < trans->steps.count; i++)
{
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
const char *evr, *evrp, *nvra;
#endif
Solvable *s;
{
case SOLVER_TRANSACTION_ERASE:
printf("erase %s\n", pool_solvid2str(pool, p));
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
if (!s->repo->rpmdbid || !s->repo->rpmdbid[p - s->repo->start])
continue;
/* strip epoch from evr */
continue;
rewind(fp);
lseek(fileno(fp), 0, SEEK_SET);
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
runrpm(type == SOLVER_TRANSACTION_MULTIINSTALL ? "-i" : "-U", "/dev/fd/3", fileno(fp));
#endif
#if defined(ENABLE_DEBIAN) && defined(DEBIAN)