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)
14 #include "repo_autopattern.h"
19 #include "repoinfo_cache.h"
21 #if defined(SUSE) || defined(FEDORA) || defined(MAGEIA)
22 #include "repoinfo_config_yum.h"
25 #include "repoinfo_config_debian.h"
28 #include "repoinfo_config_urpmi.h"
31 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
32 #include "repoinfo_system_rpm.h"
34 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
35 #include "repoinfo_system_debian.h"
39 #include "repoinfo_type_rpmmd.h"
41 #ifdef ENABLE_SUSEREPO
42 #include "repoinfo_type_susetags.h"
45 #include "repoinfo_type_debian.h"
48 #include "repoinfo_type_mdk.h"
50 #include "repoinfo_type_plaindir.h"
53 repoinfos_sort_cmp(const void *ap, const void *bp)
55 const struct repoinfo *a = ap;
56 const struct repoinfo *b = bp;
57 return strcmp(a->alias, b->alias);
61 sort_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
63 qsort(repoinfos, nrepoinfos, sizeof(*repoinfos), repoinfos_sort_cmp);
67 free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
70 for (i = 0; i < nrepoinfos; i++)
72 struct repoinfo *cinfo = repoinfos + i;
73 solv_free(cinfo->name);
74 solv_free(cinfo->alias);
75 solv_free(cinfo->path);
76 solv_free(cinfo->metalink);
77 solv_free(cinfo->mirrorlist);
78 solv_free(cinfo->baseurl);
79 for (j = 0; j < cinfo->ncomponents; j++)
80 solv_free(cinfo->components[j]);
81 solv_free(cinfo->components);
84 #if defined(SUSE) || defined(FEDORA) || defined(MAGEIA)
85 yum_substitute((Pool *)0, 0); /* free data */
90 read_repoinfos(Pool *pool, int *nrepoinfosp)
92 struct repoinfo *repoinfos = 0;
93 #if defined(SUSE) || defined(FEDORA) || defined(MAGEIA)
94 repoinfos = read_repoinfos_yum(pool, nrepoinfosp);
97 repoinfos = read_repoinfos_urpmi(pool, nrepoinfosp);
100 repoinfos = read_repoinfos_debian(pool, nrepoinfosp);
106 read_installed_repo(struct repoinfo *cinfo, Pool *pool)
109 cinfo->type = TYPE_INSTALLED;
110 cinfo->repo = repo_create(pool, "@System");
111 cinfo->repo->appdata = cinfo;
112 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
113 r = read_installed_rpm(cinfo);
115 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
116 r = read_installed_debian(cinfo);
119 repo_add_autopattern(cinfo->repo, 0);
121 pool_set_installed(pool, cinfo->repo);
126 is_cmdline_package(const char *filename)
128 int l = strlen(filename);
129 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
130 if (l > 4 && !strcmp(filename + l - 4, ".rpm"))
133 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
134 if (l > 4 && !strcmp(filename + l - 4, ".deb"))
141 add_cmdline_package(Repo *repo, const char *filename)
143 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
144 return repo_add_rpm(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
146 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
147 return repo_add_deb(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
153 commit_transactionelement(Pool *pool, Id type, Id p, FILE *fp)
155 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
156 commit_transactionelement_rpm(pool, type, p, fp);
158 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
159 commit_transactionelement_debian(pool, type, p, fp);
164 add_ext_keys(Repodata *data, Id handle, const char *ext)
166 static Id langtags[] = {
167 SOLVABLE_SUMMARY, REPOKEY_TYPE_STR,
168 SOLVABLE_DESCRIPTION, REPOKEY_TYPE_STR,
169 SOLVABLE_EULA, REPOKEY_TYPE_STR,
170 SOLVABLE_MESSAGEINS, REPOKEY_TYPE_STR,
171 SOLVABLE_MESSAGEDEL, REPOKEY_TYPE_STR,
172 SOLVABLE_CATEGORY, REPOKEY_TYPE_ID,
175 if (!strcmp(ext, "DL"))
177 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOSITORY_DELTAINFO);
178 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_FLEXARRAY);
180 else if (!strcmp(ext, "FL"))
182 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_FILELIST);
183 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRSTRARRAY);
185 else if (!strcmp(ext, "DU"))
187 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_DISKUSAGE);
188 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRNUMNUMARRAY);
192 Pool *pool = data->repo->pool;
194 for (i = 0; langtags[i]; i += 2)
196 repodata_add_idarray(data, handle, REPOSITORY_KEYS, pool_id2langid(pool, langtags[i], ext, 1));
197 repodata_add_idarray(data, handle, REPOSITORY_KEYS, langtags[i + 1]);
203 load_stub(Pool *pool, Repodata *data, void *dp)
205 struct repoinfo *cinfo = data->repo->appdata;
208 #ifdef ENABLE_SUSEREPO
210 return susetags_load_ext(data->repo, data);
214 return repomd_load_ext(data->repo, data);
216 #ifdef ENABLE_MDKREPO
218 return mdk_load_ext(data->repo, data);
221 /* debian does not have any ext data yet */
227 read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
233 for (i = 0; i < nrepoinfos; i++)
235 struct repoinfo *cinfo = repoinfos + i;
239 repo = repo_create(pool, cinfo->alias);
241 repo->appdata = cinfo;
242 repo->priority = 99 - cinfo->priority;
244 if ((!cinfo->autorefresh || cinfo->metadata_expire) && usecachedrepo(cinfo, 0, 0))
247 repo_add_autopattern(cinfo->repo, 0);
249 printf("repo '%s':", cinfo->alias);
256 #if defined(ENABLE_RPMDB) || defined(ENABLE_RPMPKG)
258 plaindir_load(cinfo, &sigpool);
263 repomd_load(cinfo, &sigpool);
266 #ifdef ENABLE_SUSEREPO
268 susetags_load(cinfo, &sigpool);
273 debian_load(cinfo, &sigpool);
276 #ifdef ENABLE_MDKREPO
278 mdk_load(cinfo, &sigpool);
282 printf("unsupported repo '%s': skipped\n", cinfo->alias);
289 repo_add_autopattern(cinfo->repo, 0);