示例#1
0
static void
test_data_init (TestData *td)
{
  GError *local_error = NULL;
  GError **error = &local_error;
  g_autofree char *http_address = NULL;
  g_autofree char *repo_url = NULL;

  td->repo = ot_test_setup_repo (NULL, error);
  if (!td->repo)
    goto out;

  if (!ot_test_run_libtest ("setup_fake_remote_repo1 archive-z2", error))
    goto out;

  if (!g_file_get_contents ("httpd-address", &http_address, NULL, error))
    goto out;

  repo_url = g_strconcat (http_address, "/ostree/gnomerepo", NULL);

  { g_autoptr(GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
    g_autoptr(GVariant) opts = NULL;

    g_variant_builder_add (builder, "{s@v}", "gpg-verify", g_variant_new_variant (g_variant_new_boolean (FALSE)));
    opts = g_variant_ref_sink (g_variant_builder_end (builder));

    if (!ostree_repo_remote_change (td->repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD,
                                    "origin", repo_url, opts, NULL, error))
      goto out;
  }

 out:
  g_assert_no_error (local_error);
}
示例#2
0
OstreeRepo *
ot_test_setup_repo (GCancellable *cancellable,
                    GError **error)
{
  gboolean ret = FALSE;
  g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
  glnx_unref_object OstreeRepo* ret_repo = NULL;

  if (!ot_test_run_libtest ("setup_test_repository archive-z2", error))
    goto out;

  ret_repo = ostree_repo_new (repo_path);

  if (!ostree_repo_open (ret_repo, cancellable, error))
    goto out;

  ret = TRUE;
 out:
  if (ret)
    return g_steal_pointer (&ret_repo);
  return NULL;
}
示例#3
0
OstreeSysroot *
ot_test_setup_sysroot (GCancellable *cancellable,
                       GError **error)
{
  gboolean ret = FALSE;
  g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
  glnx_unref_object OstreeSysroot *ret_sysroot = NULL;

  if (!ot_test_run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
    goto out;

  /* Make sure deployments are mutable */
  g_setenv ("OSTREE_SYSROOT_DEBUG", "mutable-deployments", TRUE);

  ret_sysroot = ostree_sysroot_new (sysroot_path);

  ret = TRUE;
 out:
  if (ret)
    return g_steal_pointer (&ret_sysroot);
  return NULL;
}
示例#4
0
OstreeSysroot *
ot_test_setup_sysroot (GCancellable *cancellable,
                       GError **error)
{
  gboolean ret = FALSE;
  g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
  glnx_unref_object OstreeSysroot *ret_sysroot = NULL;
  struct statfs stbuf;

  if (!ot_test_run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
    goto out;

  { g_autoptr(GString) buf = g_string_new ("mutable-deployments");
    if (statfs ("/", &stbuf) < 0)
      return glnx_null_throw_errno (error);
    /* Keep this in sync with the overlayfs bits in libtest.sh */
#ifndef OVERLAYFS_SUPER_MAGIC
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
#endif
    if (stbuf.f_type == OVERLAYFS_SUPER_MAGIC)
      {
        g_print ("libostreetest: detected overlayfs\n");
        g_string_append (buf, ",no-xattrs");
      }
    /* Make sure deployments are mutable */
    g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);
  }

  ret_sysroot = ostree_sysroot_new (sysroot_path);

  ret = TRUE;
 out:
  if (ret)
    return g_steal_pointer (&ret_sysroot);
  return NULL;
}