Beispiel #1
0
static inline int
install_packages(list_t *list, const char *dir, int verbose) {
  if (!list || !dir) return 0;

  list_node_t *node;
  list_iterator_t *it = list_iterator_new(list, LIST_HEAD);
  while ((node = list_iterator_next(it))) {
    clib_package_dependency_t *dep = node->val;
    char *slug = clib_package_slug(dep->author, dep->name, dep->version);
    clib_package_t *pkg = clib_package_new_from_slug(slug, verbose);

    free(slug);

    if (NULL == pkg) {
      return -1;
    }

    int rc = clib_package_install(pkg, dir, verbose);
    clib_package_free(pkg);
    if (-1 == rc) {
      list_iterator_destroy(it);
      return -1;
    }
  }

  list_iterator_destroy(it);
  return 0;
}
Beispiel #2
0
static inline int
install_packages(list_t *list, const char *dir, int verbose) {
  list_node_t *node = NULL;
  list_iterator_t *iterator = NULL;
  int rc = -1;

  if (!list || !dir) goto cleanup;

  iterator = list_iterator_new(list, LIST_HEAD);
  if (NULL == iterator) goto cleanup;

  while ((node = list_iterator_next(iterator))) {
    clib_package_dependency_t *dep = NULL;
    char *slug = NULL;
    clib_package_t *pkg = NULL;
    int error = 1;

    dep = (clib_package_dependency_t *) node->val;
    slug = clib_package_slug(dep->author, dep->name, dep->version);
    if (NULL == slug) goto loop_cleanup;

    pkg = clib_package_new_from_slug(slug, verbose);
    if (NULL == pkg) goto loop_cleanup;

    if (-1 == clib_package_install(pkg, dir, verbose)) goto loop_cleanup;

    error = 0;

  loop_cleanup:
    if (slug) free(slug);
    if (pkg) clib_package_free(pkg);
    if (error) {
      list_iterator_destroy(iterator);
      iterator = NULL;
      rc = -1;
      goto cleanup;
    }
  }

  rc = 0;

cleanup:
  if (iterator) list_iterator_destroy(iterator);
  return rc;
}