pkg: write dependencies directly file instead of buffer
So we don't get artificial limits on the amount of dependencies (fixes #8).cute-signatures
parent
57391d1e4c
commit
7735cc644d
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue