return olddeps;
}
+static Id
+repodata_str2dir_rooted(Repodata *data, char *str, int create)
+{
+ char buf[256], *bp;
+ int l = strlen(str);
+ Id id;
+
+ if (l + 2 <= sizeof(buf))
+ bp = buf;
+ else
+ bp = solv_malloc(l + 2);
+ bp[0] = '/';
+ strcpy(bp + 1, str);
+ id = repodata_str2dir(data, bp, create);
+ if (bp != buf)
+ solv_free(bp);
+ return id;
+}
static void
adddudata(Repodata *data, Id handle, RpmHead *rpmhead, char **dn, unsigned int *di, int fc, int dc)
{
if (!fn[i])
continue;
- did = repodata_str2dir(data, dn[i], 1);
- if (!did)
+ if (dn[i][0] != '/')
{
Solvable *s = data->repo->pool->solvables + handle;
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
did = repodata_str2dir(data, "/usr/src", 1);
else
- continue; /* work around rpm bug */
+ did = repodata_str2dir_rooted(data, dn[i], 1);
}
+ else
+ did = repodata_str2dir(data, dn[i], 1);
repodata_add_dirnumnum(data, handle, SOLVABLE_DISKUSAGE, did, fkb[i], fn[i]);
}
solv_free(fn);
unsigned int *di;
int bnc, dnc, dic;
int i;
- Id lastdid = 0;
+ Id did;
unsigned int lastdii = -1;
int lastfiltered = 0;
adddudata(data, handle, rpmhead, dn, di, bnc, dnc);
+ did = -1;
for (i = 0; i < bnc; i++)
{
- Id did;
char *b = bn[i];
- if (lastdid && di[i] == lastdii)
- did = lastdid;
- else
+ if (did < 0 || di[i] != lastdii)
{
if (di[i] >= dnc)
continue; /* corrupt entry */
+ did = 0;
lastdii = di[i];
if ((flags & RPM_ADD_FILTERED_FILELIST) != 0)
{
if (lastfiltered == 1)
continue;
}
- did = repodata_str2dir(data, dn[lastdii], 1);
- if (!did)
- did = repodata_str2dir(data, "/", 1);
- lastdid = did;
+ if (dn[lastdii][0] != '/')
+ did = repodata_str2dir_rooted(data, dn[lastdii], 1);
+ else
+ did = repodata_str2dir(data, dn[lastdii], 1);
}
- if (b && *b == '/') /* work around rpm bug */
+ if (!b)
+ continue;
+ if (*b == '/') /* work around rpm bug */
b++;
- if (lastfiltered)
- {
- if (lastfiltered != 2 || strcmp(b, "sendmail"))
- continue;
- }
+ if (lastfiltered && (lastfiltered != 2 || strcmp(b, "sendmail")))
+ continue;
repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, b);
}
solv_free(bn);
}
if (*str != '/')
{
- int l = strlen(str) + 2;
- if (l > pd->acontent)
+ if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
+ str = "/usr/src";
+ else
{
- pd->content = solv_realloc(pd->content, l + 256);
- pd->acontent = l + 256;
- }
- *pd->content = '/';
- strcpy(pd->content + 1, str);
- str = pd->content;
+ int l = strlen(str) + 2;
+ if (l > pd->acontent)
+ {
+ pd->acontent = l + 256;
+ pd->content = solv_realloc(pd->content, pd->acontent);
+ }
+ pd->content[0] = '/';
+ memcpy(pd->content + 1, str, l - 1);
+ str = pd->content;
+ }
}
dirid = repodata_str2dir(pd->data, str, 1);
if ((str = find_attr("size", atts)) != 0)
break;
}
case STATE_FILE:
-#if 0
- id = pool_str2id(pool, pd->content, 1);
- s->provides = repo_addid_dep(repo, s->provides, id, SOLVABLE_FILEMARKER);
-#endif
if ((p = strrchr(pd->content, '/')) != 0)
{
*p++ = 0;
}
else
{
- int l;
- id = repodata_str2dir(pd->data, pd->content, 1);
- l = strlen(pd->content) + 1;
- if (l > pd->lastdirstrl)
+ int l = p - pd->content;
+ if (l + 1 > pd->lastdirstrl) /* + 1 for the possible leading / we need to insert */
{
pd->lastdirstrl = l + 128;
pd->lastdirstr = solv_realloc(pd->lastdirstr, pd->lastdirstrl);
}
- strcpy(pd->lastdirstr, pd->content);
+ if (pd->content[0] != '/')
+ {
+ pd->lastdirstr[0] = '/';
+ memcpy(pd->lastdirstr + 1, pd->content, l);
+ id = repodata_str2dir(pd->data, pd->lastdirstr, 1);
+ }
+ else
+ id = repodata_str2dir(pd->data, pd->content, 1);
pd->lastdir = id;
+ memcpy(pd->lastdirstr, pd->content, l);
}
}
else
{
p = pd->content;
- id = 0;
+ id = repodata_str2dir(pd->data, "/", 1);
}
- if (!id)
- id = repodata_str2dir(pd->data, "/", 1);
repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, id, p);
break;
case STATE_SUMMARY:
case CTAG('=', 'F', 'l', 's'):
{
- char *p = strrchr(line + 6, '/');
+ char *p, *file = line + 6;
Id did;
- /* strip trailing slash */
- if (p && p != line + 6 && !p[1])
+
+ if (*file != '/')
+ *--file = '/'; /* hack: we know there is room */
+ p = strrchr(file, '/');
+ /* strip trailing slashes */
+ while (p != file && !p[1])
{
*p = 0;
- p = strrchr(line + 6, '/');
- }
- if (p)
- {
- *p++ = 0;
- did = repodata_str2dir(data, line + 6, 1);
- }
- else
- {
- p = line + 6;
- did = 0;
+ p = strrchr(file, '/');
}
- if (!did)
- did = repodata_str2dir(data, "/", 1);
+ *p++ = 0;
+ did = repodata_str2dir(data, *file ? file : "/", 1);
repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
+ line[5] = ' ';
break;
}
case CTAG('=', 'H', 'd', 'r'):