6 #include <sys/utsname.h>
14 #include "repoinfo_cache.h"
15 #include "repoinfo_download.h"
16 #include "repoinfo_type_debian.h"
19 debian_find_component(struct repoinfo *cinfo, FILE *fp, char *comp, const unsigned char **chksump, Id *chksumtypep)
23 unsigned char *chksum;
28 static char *basearch;
40 basearch = strdup(un.machine);
41 if (basearch[0] == 'i' && basearch[1] && !strcmp(basearch + 2, "86"))
44 binarydir = solv_dupjoin("binary-", basearch, "/");
45 lbinarydir = strlen(binarydir);
50 chksum = solv_malloc(32);
52 while(fgets(buf, sizeof(buf), fp))
57 while (l && (buf[l - 1] == '\n' || buf[l - 1] == ' ' || buf[l - 1] == '\t'))
59 if (!strncasecmp(buf, "MD5Sum:", 7))
61 curchksumtype = REPOKEY_TYPE_MD5;
64 if (!strncasecmp(buf, "SHA1:", 5))
66 curchksumtype = REPOKEY_TYPE_SHA1;
69 if (!strncasecmp(buf, "SHA256:", 7))
71 curchksumtype = REPOKEY_TYPE_SHA256;
83 while (*bp && *bp != ' ' && *bp != '\t')
88 while (*bp == ' ' || *bp == '\t')
90 while (*bp && *bp != ' ' && *bp != '\t')
94 while (*bp == ' ' || *bp == '\t')
97 if (strncmp(fn, comp, compl) != 0 || fn[compl] != '/')
100 if (strncmp(bp, binarydir, lbinarydir))
103 if (!strcmp(bp, "Packages") || !strcmp(bp, "Packages.gz"))
105 unsigned char curchksum[32];
107 if (filename && !strcmp(bp, "Packages"))
109 curl = solv_chksum_len(curchksumtype);
110 if (!curl || (chksumtype && solv_chksum_len(chksumtype) > curl))
112 if (solv_hex2bin((const char **)&ch, curchksum, sizeof(curchksum)) != curl)
115 filename = strdup(fn);
116 chksumtype = curchksumtype;
117 memcpy(chksum, curchksum, curl);
123 fn = solv_dupjoin("/", filename, 0);
125 filename = solv_dupjoin("dists/", cinfo->name, fn);
129 chksum = solv_free(chksum);
131 *chksumtypep = chksumtype;
136 debian_load(struct repoinfo *cinfo, Pool **sigpoolp)
138 Repo *repo = cinfo->repo;
139 Pool *pool = repo->pool;
140 const char *filename;
141 const unsigned char *filechksum;
146 printf("debian repo '%s':", cinfo->alias);
148 filename = solv_dupjoin("dists/", cinfo->name, "/Release");
149 if ((fpr = curlfopen(cinfo, filename, 0, 0, 0, 0)) == 0)
151 printf(" no Release file\n");
152 free((char *)filename);
153 cinfo->incomplete = 1;
156 solv_free((char *)filename);
157 if (cinfo->repo_gpgcheck)
159 filename = solv_dupjoin("dists/", cinfo->name, "/Release.gpg");
160 if (!downloadchecksig(cinfo, fpr, filename, sigpoolp))
163 solv_free((char *)filename);
164 cinfo->incomplete = 1;
167 solv_free((char *)filename);
169 calc_cookie_fp(fpr, REPOKEY_TYPE_SHA256, cinfo->cookie);
170 cinfo->cookieset = 1;
171 if (usecachedrepo(cinfo, 0, 1))
177 printf(" fetching\n");
178 for (j = 0; j < cinfo->ncomponents; j++)
180 if (!(filename = debian_find_component(cinfo, fpr, cinfo->components[j], &filechksum, &filechksumtype)))
182 printf("[component %s not found]\n", cinfo->components[j]);
185 if ((fp = curlfopen(cinfo, filename, 1, filechksum, filechksumtype, 1)) != 0)
187 if (repo_add_debpackages(repo, fp, 0))
189 printf("component %s: %s\n", cinfo->components[j], pool_errstr(pool));
190 cinfo->incomplete = 1;
194 solv_free((char *)filechksum);
195 solv_free((char *)filename);
198 writecachedrepo(cinfo, 0, 0);