Commit 7735cc64 authored by Timo Teräs's avatar Timo Teräs

pkg: write dependencies directly file instead of buffer

So we don't get artificial limits on the amount of dependencies
(fixes #8).
parent 57391d1e
...@@ -68,6 +68,7 @@ void apk_deps_parse(struct apk_database *db, ...@@ -68,6 +68,7 @@ void apk_deps_parse(struct apk_database *db,
apk_blob_t blob); apk_blob_t blob);
int apk_deps_format(char *buf, int size, int apk_deps_format(char *buf, int size,
struct apk_dependency_array *depends); struct apk_dependency_array *depends);
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os);
int apk_script_type(const char *name); int apk_script_type(const char *name);
struct apk_package *apk_pkg_new(void); struct apk_package *apk_pkg_new(void);
......
...@@ -725,8 +725,6 @@ struct write_ctx { ...@@ -725,8 +725,6 @@ struct write_ctx {
static int apk_db_write_config(struct apk_database *db) static int apk_db_write_config(struct apk_database *db)
{ {
struct apk_ostream *os; struct apk_ostream *os;
char buf[1024];
int n;
if (db->root == NULL) if (db->root == NULL)
return 0; return 0;
...@@ -741,10 +739,8 @@ static int apk_db_write_config(struct apk_database *db) ...@@ -741,10 +739,8 @@ static int apk_db_write_config(struct apk_database *db)
os = apk_ostream_to_file("var/lib/apk/world", 0644); os = apk_ostream_to_file("var/lib/apk/world", 0644);
if (os == NULL) if (os == NULL)
return -1; return -1;
n = apk_deps_format(buf, sizeof(buf), db->world); apk_deps_write(db->world, os);
if (n < sizeof(buf)) os->write(os, "\n", 1);
buf[n++] = '\n';
os->write(os, buf, n);
os->close(os); os->close(os);
os = apk_ostream_to_file("var/lib/apk/installed.new", 0644); os = apk_ostream_to_file("var/lib/apk/installed.new", 0644);
......
...@@ -149,6 +149,29 @@ int apk_deps_format(char *buf, int size, ...@@ -149,6 +149,29 @@ int apk_deps_format(char *buf, int size,
return n; return n;
} }
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os)
{
int i, len, n = 0;
if (deps == NULL)
return 0;
for (i = 0; i < deps->num; i++) {
if (i) {
if (os->write(os, " ", 1) != 1)
return -1;
n += 1;
}
len = strlen(deps->item[i].name->name);
if (os->write(os, deps->item[i].name->name, len) != len)
return -1;
n += len;
}
return n;
}
static const char *script_types[] = { static const char *script_types[] = {
[APK_SCRIPT_PRE_INSTALL] = "pre-install", [APK_SCRIPT_PRE_INSTALL] = "pre-install",
[APK_SCRIPT_POST_INSTALL] = "post-install", [APK_SCRIPT_POST_INSTALL] = "post-install",
......
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