7 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
8 #include "repo_rpmdb.h"
10 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
15 #include "repoinfo_cache.h"
17 #if defined(SUSE) || defined(FEDORA)
18 #include "repoinfo_config_yum.h"
21 #include "repoinfo_config_debian.h"
23 #if defined(MANDRIVA) || defined(MAGEIA)
24 #include "repoinfo_config_urpmi.h"
27 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
28 #include "repoinfo_system_rpm.h"
30 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
31 #include "repoinfo_system_debian.h"
35 #include "repoinfo_type_rpmmd.h"
37 #ifdef ENABLE_SUSEREPO
38 #include "repoinfo_type_susetags.h"
41 #include "repoinfo_type_debian.h"
44 #include "repoinfo_type_mdk.h"
48 repoinfos_sort_cmp(const void *ap, const void *bp)
50 const struct repoinfo *a = ap;
51 const struct repoinfo *b = bp;
52 return strcmp(a->alias, b->alias);
56 sort_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
58 qsort(repoinfos, nrepoinfos, sizeof(*repoinfos), repoinfos_sort_cmp);
62 free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
65 for (i = 0; i < nrepoinfos; i++)
67 struct repoinfo *cinfo = repoinfos + i;
68 solv_free(cinfo->name);
69 solv_free(cinfo->alias);
70 solv_free(cinfo->path);
71 solv_free(cinfo->metalink);
72 solv_free(cinfo->mirrorlist);
73 solv_free(cinfo->baseurl);
74 for (j = 0; j < cinfo->ncomponents; j++)
75 solv_free(cinfo->components[j]);
76 solv_free(cinfo->components);
79 #if defined(SUSE) || defined(FEDORA)
80 yum_substitute((Pool *)0, 0); /* free data */
85 read_repoinfos(Pool *pool, int *nrepoinfosp)
87 struct repoinfo *repoinfos = 0;
88 #if defined(SUSE) || defined(FEDORA)
89 repoinfos = read_repoinfos_yum(pool, nrepoinfosp);
91 #if defined(MANDRIVA) || defined(MAGEIA)
92 repoinfos = read_repoinfos_urpmi(pool, nrepoinfosp);
95 repoinfos = read_repoinfos_debian(pool, nrepoinfosp);
101 read_installed_repo(struct repoinfo *cinfo, Pool *pool)
104 cinfo->type = TYPE_INSTALLED;
105 cinfo->repo = repo_create(pool, "@System");
106 cinfo->repo->appdata = cinfo;
107 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
108 r = read_installed_rpm(cinfo);
110 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
111 r = read_installed_debian(cinfo);
113 pool_set_installed(pool, cinfo->repo);
118 is_cmdline_package(const char *filename)
120 int l = strlen(filename);
121 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
122 if (l > 4 && !strcmp(filename + l - 4, ".rpm"))
125 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
126 if (l > 4 && !strcmp(filename + l - 4, ".deb"))
133 add_cmdline_package(Repo *repo, const char *filename)
135 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
136 return repo_add_rpm(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
138 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
139 return repo_add_deb(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
145 commit_transactionelement(Pool *pool, Id type, Id p, FILE *fp)
147 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
148 commit_transactionelement_rpm(pool, type, p, fp);
150 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
151 commit_transactionelement_debian(pool, type, p, fp);
156 add_ext_keys(Repodata *data, Id handle, const char *ext)
158 static Id langtags[] = {
159 SOLVABLE_SUMMARY, REPOKEY_TYPE_STR,
160 SOLVABLE_DESCRIPTION, REPOKEY_TYPE_STR,
161 SOLVABLE_EULA, REPOKEY_TYPE_STR,
162 SOLVABLE_MESSAGEINS, REPOKEY_TYPE_STR,
163 SOLVABLE_MESSAGEDEL, REPOKEY_TYPE_STR,
164 SOLVABLE_CATEGORY, REPOKEY_TYPE_ID,
167 if (!strcmp(ext, "DL"))
169 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOSITORY_DELTAINFO);
170 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_FLEXARRAY);
172 else if (!strcmp(ext, "FL"))
174 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_FILELIST);
175 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRSTRARRAY);
177 else if (!strcmp(ext, "DU"))
179 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_DISKUSAGE);
180 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRNUMNUMARRAY);
184 Pool *pool = data->repo->pool;
186 for (i = 0; langtags[i]; i += 2)
188 repodata_add_idarray(data, handle, REPOSITORY_KEYS, pool_id2langid(pool, langtags[i], ext, 1));
189 repodata_add_idarray(data, handle, REPOSITORY_KEYS, langtags[i + 1]);
195 load_stub(Pool *pool, Repodata *data, void *dp)
197 struct repoinfo *cinfo = data->repo->appdata;
200 #ifdef ENABLE_SUSEREPO
202 return susetags_load_ext(data->repo, data);
206 return repomd_load_ext(data->repo, data);
208 #ifdef ENABLE_MDKREPO
210 return mdk_load_ext(data->repo, data);
213 /* debian does not have any ext data yet */
219 read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
225 for (i = 0; i < nrepoinfos; i++)
227 struct repoinfo *cinfo = repoinfos + i;
231 repo = repo_create(pool, cinfo->alias);
233 repo->appdata = cinfo;
234 repo->priority = 99 - cinfo->priority;
236 if ((!cinfo->autorefresh || cinfo->metadata_expire) && usecachedrepo(cinfo, 0, 0))
238 printf("repo '%s':", cinfo->alias);
247 repomd_load(cinfo, &sigpool);
250 #ifdef ENABLE_SUSEREPO
252 susetags_load(cinfo, &sigpool);
257 debian_load(cinfo, &sigpool);
260 #ifdef ENABLE_MDKREPO
262 mdk_load(cinfo, &sigpool);
266 printf("unsupported repo '%s': skipped\n", cinfo->alias);