Commit dc667087 authored by Bernhard Link's avatar Bernhard Link

[refactor] call filelist_addpackage with struct package

parent 38bf8063
......@@ -23,8 +23,8 @@
#include <string.h>
#include <ctype.h>
#include "error.h"
#include "strlist.h"
#include "mprintf.h"
#include "chunks.h"
#include "dirs.h"
#include "names.h"
#include "release.h"
......@@ -163,24 +163,8 @@ retvalue contentsoptions_parse(struct distribution *distribution, struct configi
static retvalue addpackagetocontents(struct package *package, void *data) {
struct filelist_list *contents = data;
retvalue r;
char *section, *filekey;
r = chunk_getvalue(package->control, "Section", &section);
/* Ignoring packages without section, as they should not exist anyway */
if (!RET_IS_OK(r))
return r;
r = chunk_getvalue(package->control, "Filename", &filekey);
/* dito with filekey */
if (!RET_IS_OK(r)) {
free(section);
return r;
}
r = filelist_addpackage(contents, package->name, section, filekey);
free(filekey);
free(section);
return r;
return filelist_addpackage(contents, package);
}
static retvalue gentargetcontents(struct target *target, struct release *release, bool onlyneeded, bool symlink) {
......
/* This file is part of "reprepro"
* Copyright (C) 2006,2007 Bernhard R. Link
* Copyright (C) 2006,2007,2016 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -23,6 +23,8 @@
#include "error.h"
#include "database_p.h"
#include "files.h"
#include "chunks.h"
#include "package.h"
#include "debfile.h"
#include "filelist.h"
......@@ -427,25 +429,43 @@ static retvalue filelist_addfiles(struct filelist_list *list, const struct filel
return RET_OK;
}
retvalue filelist_addpackage(struct filelist_list *list, const char *packagename, const char *section, const char *filekey) {
retvalue filelist_addpackage(struct filelist_list *list, struct package *pkg) {
const struct filelist_package *package;
char *debfilename, *contents = NULL;
retvalue r;
const char *c;
size_t len;
char *section, *filekey;
r = filelist_newpackage(list, packagename, section, &package);
r = chunk_getvalue(pkg->control, "Section", &section);
/* Ignoring packages without section, as they should not exist anyway */
if (!RET_IS_OK(r))
return r;
r = chunk_getvalue(pkg->control, "Filename", &filekey);
/* dito with filekey */
if (!RET_IS_OK(r)) {
free(section);
return r;
}
r = filelist_newpackage(list, pkg->name, section, &package);
assert (r != RET_NOTHING);
if (RET_WAS_ERROR(r))
if (RET_WAS_ERROR(r)) {
free(filekey);
free(section);
return r;
}
r = table_gettemprecord(rdb_contents, filekey, &c, &len);
if (r == RET_NOTHING) {
if (verbose > 3)
printf("Reading filelist for %s\n", filekey);
debfilename = files_calcfullfilename(filekey);
if (FAILEDTOALLOC(debfilename))
if (FAILEDTOALLOC(debfilename)) {
free(filekey);
free(section);
return RET_ERROR_OOM;
}
r = getfilelist(&contents, &len, debfilename);
len--;
free(debfilename);
......@@ -458,6 +478,8 @@ retvalue filelist_addpackage(struct filelist_list *list, const char *packagename
contents, len + 1, true, false);
}
free(contents);
free(filekey);
free(section);
return r;
}
......
......@@ -6,10 +6,11 @@
#endif
struct filelist_list;
struct package;
retvalue filelist_init(struct filelist_list **list);
retvalue filelist_addpackage(struct filelist_list *, const char *package, const char *section, const char *filekey);
retvalue filelist_addpackage(struct filelist_list *, struct package *);
retvalue filelist_write(struct filelist_list *list, struct filetorelease *file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment