summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-04-16 17:05:27 +0300
committerTimo Teras <timo.teras@iki.fi>2009-04-16 17:05:27 +0300
commitec5b63c5e4d719e07c48b0de0dc0b9f3b25d2cf8 (patch)
tree12885a6778a0a746fc0ff62b0be4b75f368cebc9 /src/database.c
parent968dfbb8b376de2dc6f2441dc3966d1416ad0046 (diff)
downloadapk-tools-ec5b63c5e4d719e07c48b0de0dc0b9f3b25d2cf8.tar.gz
apk-tools-ec5b63c5e4d719e07c48b0de0dc0b9f3b25d2cf8.tar.bz2
apk-tools-ec5b63c5e4d719e07c48b0de0dc0b9f3b25d2cf8.tar.xz
apk-tools-ec5b63c5e4d719e07c48b0de0dc0b9f3b25d2cf8.zip
pkg: clean up writing of dependencies
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/database.c b/src/database.c
index 649555a..195f653 100644
--- a/src/database.c
+++ b/src/database.c
@@ -489,13 +489,12 @@ static int apk_db_write_fdb(struct apk_database *db, struct apk_ostream *os)
struct apk_db_file *file;
struct hlist_node *c1, *c2;
char buf[1024];
- apk_blob_t blob;
- int n = 0;
+ int n = 0, r;
list_for_each_entry(pkg, &db->installed.packages, installed_pkgs_list) {
- blob = apk_pkg_format_index_entry(pkg, sizeof(buf), buf);
- if (blob.ptr)
- os->write(os, blob.ptr, blob.len - 1);
+ r = apk_pkg_write_index_entry(pkg, os);
+ if (r < 0)
+ return r;
hlist_for_each_entry(diri, c1, &pkg->owned_dirs, pkg_dirs_list) {
n += snprintf(&buf[n], sizeof(buf)-n,
@@ -872,17 +871,16 @@ static int write_index_entry(apk_hash_item item, void *ctx)
{
struct index_write_ctx *iwctx = (struct index_write_ctx *) ctx;
struct apk_package *pkg = (struct apk_package *) item;
- char buf[1024];
- apk_blob_t blob;
+ int r;
if (pkg->repos != 0)
return 0;
- blob = apk_pkg_format_index_entry(pkg, sizeof(buf), buf);
- if (APK_BLOB_IS_NULL(blob))
- return 0;
+ r = apk_pkg_write_index_entry(pkg, iwctx->os);
+ if (r < 0)
+ return r;
- if (iwctx->os->write(iwctx->os, blob.ptr, blob.len) != blob.len)
+ if (iwctx->os->write(iwctx->os, "\n", 1) != 1)
return -1;
iwctx->count++;