| |
}
|
| |
pkg_adddep(pkg, key->data.scalar.value, origin, version);
|
| |
break;
|
| + |
case PKG_SCRIPTS:
|
| + |
if (strcmp(key->data.scalar.value, "pre-install") == 0) {
|
| + |
script_type = PKG_SCRIPT_PRE_INSTALL;
|
| + |
} else if (strcmp(key->data.scalar.value, "install") == 0) {
|
| + |
script_type = PKG_SCRIPT_INSTALL;
|
| + |
} else if (strcmp(key->data.scalar.value, "post-install") == 0) {
|
| + |
script_type = PKG_SCRIPT_POST_INSTALL;
|
| + |
} else if (strcmp(key->data.scalar.value, "pre-upgrade") == 0) {
|
| + |
script_type = PKG_SCRIPT_PRE_UPGRADE;
|
| + |
} else if (strcmp(key->data.scalar.value, "upgrade") == 0) {
|
| + |
script_type = PKG_SCRIPT_UPGRADE;
|
| + |
} else if (strcmp(key->data.scalar.value, "post-upgrade") == 0) {
|
| + |
script_type = PKG_SCRIPT_POST_UPGRADE;
|
| + |
} else if (strcmp(key->data.scalar.value, "pre-deinstall") == 0) {
|
| + |
script_type = PKG_SCRIPT_PRE_DEINSTALL;
|
| + |
} else if (strcmp(key->data.scalar.value, "deinstall") == 0) {
|
| + |
script_type = PKG_SCRIPT_DEINSTALL;
|
| + |
} else if (strcmp(key->data.scalar.value, "post-deinstall") == 0) {
|
| + |
script_type = PKG_SCRIPT_POST_DEINSTALL;
|
| + |
}
|
| + |
|
| + |
pkg_addscript(pkg, val->data.scalar.value, script_type);
|
| + |
break;
|
| |
default:
|
| |
type = manifest_type(key->data.scalar.value);
|
| |
if (type == -1) {
|
| |
int files = -1;
|
| |
int dirs = -1;
|
| |
int options = -1;
|
| + |
int scripts = -1;
|
| + |
const char *script_types;
|
| + |
struct sbuf *destbuf = sbuf_new_auto();
|
| |
|
| |
yaml_emitter_initialize(&emitter);
|
| - |
yaml_emitter_set_output(&emitter, yaml_write_buf, dest);
|
| + |
yaml_emitter_set_output(&emitter, yaml_write_buf, destbuf);
|
| |
|
| |
#define manifest_append_kv(map, key, val) yaml_document_append_mapping_pair(&doc, map, \
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, key), strlen(key), YAML_ANY_SCALAR_STYLE), \
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, val), strlen(val), YAML_ANY_SCALAR_STYLE));
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, key), strlen(key), YAML_PLAIN_SCALAR_STYLE), \
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, val), strlen(val), YAML_PLAIN_SCALAR_STYLE));
|
| + |
|
| + |
#define manifest_append_kv_literal(map, key, val) yaml_document_append_mapping_pair(&doc, map, \
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, key), strlen(key), YAML_PLAIN_SCALAR_STYLE), \
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, val), strlen(val), YAML_LITERAL_SCALAR_STYLE));
|
| |
|
| |
yaml_document_initialize(&doc, NULL, NULL, NULL, 1, 1);
|
| - |
mapping = yaml_document_add_mapping(&doc, NULL, YAML_ANY_MAPPING_STYLE);
|
| + |
mapping = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| |
|
| |
manifest_append_kv(mapping, "name", pkg_get(pkg, PKG_NAME));
|
| |
manifest_append_kv(mapping, "version", pkg_get(pkg, PKG_VERSION));
|
| |
manifest_append_kv(mapping, "prefix", pkg_get(pkg, PKG_PREFIX));
|
| |
snprintf(tmpbuf, BUFSIZ, "%ld", pkg_flatsize(pkg));
|
| |
manifest_append_kv(mapping, "flatsize", tmpbuf);
|
| + |
manifest_append_kv_literal(mapping, "desc", pkg_get(pkg, PKG_DESC));
|
| |
|
| |
while (pkg_deps(pkg, &dep) == EPKG_OK) {
|
| |
if (depsmap == -1) {
|
| - |
depsmap = yaml_document_add_mapping(&doc, NULL, YAML_ANY_MAPPING_STYLE);
|
| + |
depsmap = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, mapping,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "deps"), 4, YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "deps"), 4, YAML_PLAIN_SCALAR_STYLE),
|
| |
depsmap);
|
| |
}
|
| |
|
| - |
depkv = yaml_document_add_mapping(&doc, NULL, YAML_ANY_MAPPING_STYLE);
|
| + |
depkv = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, depsmap,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_dep_name(dep)), strlen(pkg_dep_name(dep)), YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_dep_name(dep)), strlen(pkg_dep_name(dep)), YAML_PLAIN_SCALAR_STYLE),
|
| |
depkv);
|
| |
|
| |
manifest_append_kv(depkv, "origin", pkg_dep_origin(dep));
|
| |
|
| |
while (pkg_conflicts(pkg, &conflict) == EPKG_OK) {
|
| |
if (conflicts == -1) {
|
| - |
conflicts = yaml_document_add_sequence(&doc, NULL, YAML_ANY_SEQUENCE_STYLE);
|
| + |
conflicts = yaml_document_add_sequence(&doc, NULL, YAML_BLOCK_SEQUENCE_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, mapping,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "conflicts"), 9, YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "conflicts"), 9, YAML_PLAIN_SCALAR_STYLE),
|
| |
conflicts);
|
| |
}
|
| |
yaml_document_append_sequence_item(&doc, conflicts,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_conflict_glob(conflict)), strlen(pkg_conflict_glob(conflict)), YAML_ANY_SCALAR_STYLE));
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_conflict_glob(conflict)), strlen(pkg_conflict_glob(conflict)), YAML_PLAIN_SCALAR_STYLE));
|
| |
}
|
| |
|
| |
while (pkg_options(pkg, &option) == EPKG_OK) {
|
| |
if (options == -1) {
|
| - |
options = yaml_document_add_mapping(&doc, NULL, YAML_ANY_MAPPING_STYLE);
|
| + |
options = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, mapping,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "options"), 7, YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "options"), 7, YAML_PLAIN_SCALAR_STYLE),
|
| |
options);
|
| |
}
|
| |
manifest_append_kv(files, pkg_option_opt(option), pkg_option_value(option));
|
| |
|
| |
while (pkg_files(pkg, &file) == EPKG_OK) {
|
| |
if (files == -1) {
|
| - |
files = yaml_document_add_mapping(&doc, NULL, YAML_ANY_MAPPING_STYLE);
|
| + |
files = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, mapping,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "files"), 5, YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "files"), 5, YAML_PLAIN_SCALAR_STYLE),
|
| |
files);
|
| |
}
|
| |
manifest_append_kv(files, pkg_file_path(file), pkg_file_sha256(file) && strlen(pkg_file_sha256(file)) > 0 ? pkg_file_sha256(file) : "-");
|
| |
|
| |
while (pkg_dirs(pkg, &dir) == EPKG_OK) {
|
| |
if (dirs == -1) {
|
| - |
dirs = yaml_document_add_sequence(&doc, NULL, YAML_ANY_SEQUENCE_STYLE);
|
| + |
dirs = yaml_document_add_sequence(&doc, NULL, YAML_BLOCK_SEQUENCE_STYLE);
|
| |
yaml_document_append_mapping_pair(&doc, mapping,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "dirs"), 4, YAML_ANY_SCALAR_STYLE),
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "dirs"), 4, YAML_PLAIN_SCALAR_STYLE),
|
| |
dirs);
|
| |
}
|
| |
yaml_document_append_sequence_item(&doc, dirs,
|
| - |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_dir_path(dir)), strlen(pkg_dir_path(dir)), YAML_ANY_SCALAR_STYLE));
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, pkg_dir_path(dir)), strlen(pkg_dir_path(dir)), YAML_PLAIN_SCALAR_STYLE));
|
| + |
}
|
| + |
|
| + |
while (pkg_scripts(pkg, &script) == EPKG_OK) {
|
| + |
if (scripts == -1) {
|
| + |
scripts = yaml_document_add_mapping(&doc, NULL, YAML_BLOCK_MAPPING_STYLE);
|
| + |
yaml_document_append_mapping_pair(&doc, mapping,
|
| + |
yaml_document_add_scalar(&doc, NULL, __DECONST(yaml_char_t*, "scripts"), 7, YAML_PLAIN_SCALAR_STYLE),
|
| + |
scripts);
|
| + |
}
|
| + |
switch (pkg_script_type(script)) {
|
| + |
case PKG_SCRIPT_PRE_INSTALL:
|
| + |
script_types = "pre-install";
|
| + |
break;
|
| + |
case PKG_SCRIPT_INSTALL:
|
| + |
script_types = "install";
|
| + |
break;
|
| + |
case PKG_SCRIPT_POST_INSTALL:
|
| + |
script_types = "post-install";
|
| + |
break;
|
| + |
case PKG_SCRIPT_PRE_UPGRADE:
|
| + |
script_types = "pre-upgrade";
|
| + |
break;
|
| + |
case PKG_SCRIPT_UPGRADE:
|
| + |
script_types = "upgrade";
|
| + |
break;
|
| + |
case PKG_SCRIPT_POST_UPGRADE:
|
| + |
script_types = "post-upgrade";
|
| + |
break;
|
| + |
case PKG_SCRIPT_PRE_DEINSTALL:
|
| + |
script_types = "pre-deinstall";
|
| + |
break;
|
| + |
case PKG_SCRIPT_DEINSTALL:
|
| + |
script_types = "deinstall";
|
| + |
break;
|
| + |
case PKG_SCRIPT_POST_DEINSTALL:
|
| + |
script_types = "post-deinstall";
|
| + |
break;
|
| + |
}
|
| + |
manifest_append_kv_literal(scripts, script_types, pkg_script_data(script));
|
| |
}
|
| |
|
| |
if (!yaml_emitter_dump(&emitter, &doc))
|
| |
rc = EPKG_FATAL;
|
| |
|
| + |
sbuf_finish(destbuf);
|
| + |
*dest = strdup(sbuf_data(destbuf));
|
| + |
sbuf_delete(destbuf);
|
| + |
|
| |
yaml_emitter_delete(&emitter);
|
| |
return (rc);
|
| |
|