diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-03-17 13:19:06 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-03-17 13:19:06 +0200 |
commit | 7735cc644d342e39b8b2b71da6890656d1846fab (patch) | |
tree | 8f180bd7fde819b744d98d2859f502707a97e187 | |
parent | 57391d1e4c4b8464ca14b464cc6c29987922fe88 (diff) | |
download | apk-tools-7735cc644d342e39b8b2b71da6890656d1846fab.tar.gz apk-tools-7735cc644d342e39b8b2b71da6890656d1846fab.tar.bz2 apk-tools-7735cc644d342e39b8b2b71da6890656d1846fab.tar.xz apk-tools-7735cc644d342e39b8b2b71da6890656d1846fab.zip |
pkg: write dependencies directly file instead of buffer
So we don't get artificial limits on the amount of dependencies
(fixes #8).
-rw-r--r-- | src/apk_package.h | 1 | ||||
-rw-r--r-- | src/database.c | 8 | ||||
-rw-r--r-- | src/package.c | 23 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/apk_package.h b/src/apk_package.h index c6eaa1c..bf0ae95 100644 --- a/src/apk_package.h +++ b/src/apk_package.h @@ -68,6 +68,7 @@ void apk_deps_parse(struct apk_database *db, apk_blob_t blob); int apk_deps_format(char *buf, int size, 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); struct apk_package *apk_pkg_new(void); diff --git a/src/database.c b/src/database.c index 27b49ea..976102b 100644 --- a/src/database.c +++ b/src/database.c @@ -725,8 +725,6 @@ struct write_ctx { static int apk_db_write_config(struct apk_database *db) { struct apk_ostream *os; - char buf[1024]; - int n; if (db->root == NULL) return 0; @@ -741,10 +739,8 @@ static int apk_db_write_config(struct apk_database *db) os = apk_ostream_to_file("var/lib/apk/world", 0644); if (os == NULL) return -1; - n = apk_deps_format(buf, sizeof(buf), db->world); - if (n < sizeof(buf)) - buf[n++] = '\n'; - os->write(os, buf, n); + apk_deps_write(db->world, os); + os->write(os, "\n", 1); os->close(os); os = apk_ostream_to_file("var/lib/apk/installed.new", 0644); diff --git a/src/package.c b/src/package.c index a5e988b..4d9f33d 100644 --- a/src/package.c +++ b/src/package.c @@ -149,6 +149,29 @@ int apk_deps_format(char *buf, int size, 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[] = { [APK_SCRIPT_PRE_INSTALL] = "pre-install", [APK_SCRIPT_POST_INSTALL] = "post-install", |