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)
22 #include "repoinfo_config_yum.h"
25 #include "repoinfo_config_debian.h"
27 #if defined(MANDRIVA) || defined(MAGEIA)
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"
52 repoinfos_sort_cmp(const void *ap, const void *bp)
54 const struct repoinfo *a = ap;
55 const struct repoinfo *b = bp;
56 return strcmp(a->alias, b->alias);
60 sort_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
62 qsort(repoinfos, nrepoinfos, sizeof(*repoinfos), repoinfos_sort_cmp);
66 free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
69 for (i = 0; i < nrepoinfos; i++)
71 struct repoinfo *cinfo = repoinfos + i;
72 solv_free(cinfo->name);
73 solv_free(cinfo->alias);
74 solv_free(cinfo->path);
75 solv_free(cinfo->metalink);
76 solv_free(cinfo->mirrorlist);
77 solv_free(cinfo->baseurl);
78 for (j = 0; j < cinfo->ncomponents; j++)
79 solv_free(cinfo->components[j]);
80 solv_free(cinfo->components);
83 #if defined(SUSE) || defined(FEDORA)
84 yum_substitute((Pool *)0, 0); /* free data */
89 read_repoinfos(Pool *pool, int *nrepoinfosp)
91 struct repoinfo *repoinfos = 0;
92 #if defined(SUSE) || defined(FEDORA)
93 repoinfos = read_repoinfos_yum(pool, nrepoinfosp);
95 #if defined(MANDRIVA) || defined(MAGEIA)
96 repoinfos = read_repoinfos_urpmi(pool, nrepoinfosp);
99 repoinfos = read_repoinfos_debian(pool, nrepoinfosp);
105 read_installed_repo(struct repoinfo *cinfo, Pool *pool)
108 cinfo->type = TYPE_INSTALLED;
109 cinfo->repo = repo_create(pool, "@System");
110 cinfo->repo->appdata = cinfo;
111 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
112 r = read_installed_rpm(cinfo);
114 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
115 r = read_installed_debian(cinfo);
118 repo_add_autopattern(cinfo->repo, 0);
120 pool_set_installed(pool, cinfo->repo);
125 is_cmdline_package(const char *filename)
127 int l = strlen(filename);
128 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
129 if (l > 4 && !strcmp(filename + l - 4, ".rpm"))
132 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
133 if (l > 4 && !strcmp(filename + l - 4, ".deb"))
140 add_cmdline_package(Repo *repo, const char *filename)
142 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
143 return repo_add_rpm(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
145 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
146 return repo_add_deb(repo, filename, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
152 commit_transactionelement(Pool *pool, Id type, Id p, FILE *fp)
154 #if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA) || defined(MANDRIVA) || defined(MAGEIA))
155 commit_transactionelement_rpm(pool, type, p, fp);
157 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
158 commit_transactionelement_debian(pool, type, p, fp);
163 add_ext_keys(Repodata *data, Id handle, const char *ext)
165 static Id langtags[] = {
166 SOLVABLE_SUMMARY, REPOKEY_TYPE_STR,
167 SOLVABLE_DESCRIPTION, REPOKEY_TYPE_STR,
168 SOLVABLE_EULA, REPOKEY_TYPE_STR,
169 SOLVABLE_MESSAGEINS, REPOKEY_TYPE_STR,
170 SOLVABLE_MESSAGEDEL, REPOKEY_TYPE_STR,
171 SOLVABLE_CATEGORY, REPOKEY_TYPE_ID,
174 if (!strcmp(ext, "DL"))
176 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOSITORY_DELTAINFO);
177 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_FLEXARRAY);
179 else if (!strcmp(ext, "FL"))
181 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_FILELIST);
182 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRSTRARRAY);
184 else if (!strcmp(ext, "DU"))
186 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_DISKUSAGE);
187 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRNUMNUMARRAY);
191 Pool *pool = data->repo->pool;
193 for (i = 0; langtags[i]; i += 2)
195 repodata_add_idarray(data, handle, REPOSITORY_KEYS, pool_id2langid(pool, langtags[i], ext, 1));
196 repodata_add_idarray(data, handle, REPOSITORY_KEYS, langtags[i + 1]);
202 load_stub(Pool *pool, Repodata *data, void *dp)
204 struct repoinfo *cinfo = data->repo->appdata;
207 #ifdef ENABLE_SUSEREPO
209 return susetags_load_ext(data->repo, data);
213 return repomd_load_ext(data->repo, data);
215 #ifdef ENABLE_MDKREPO
217 return mdk_load_ext(data->repo, data);
220 /* debian does not have any ext data yet */
226 read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
232 for (i = 0; i < nrepoinfos; i++)
234 struct repoinfo *cinfo = repoinfos + i;
238 repo = repo_create(pool, cinfo->alias);
240 repo->appdata = cinfo;
241 repo->priority = 99 - cinfo->priority;
243 if ((!cinfo->autorefresh || cinfo->metadata_expire) && usecachedrepo(cinfo, 0, 0))
246 repo_add_autopattern(cinfo->repo, 0);
248 printf("repo '%s':", cinfo->alias);
257 repomd_load(cinfo, &sigpool);
260 #ifdef ENABLE_SUSEREPO
262 susetags_load(cinfo, &sigpool);
267 debian_load(cinfo, &sigpool);
270 #ifdef ENABLE_MDKREPO
272 mdk_load(cinfo, &sigpool);
276 printf("unsupported repo '%s': skipped\n", cinfo->alias);
283 repo_add_autopattern(cinfo->repo, 0);