Beispiel #1
0
static bool
diversion_is_shared(struct pkgset *set, struct fsys_namenode *namenode)
{
	const char *archname;
	struct pkginfo *pkg;
	struct dpkg_arch *arch;
	struct fsys_node_pkgs_iter *iter;
	bool shared = false;

	if (set == NULL)
		return false;

	archname = getenv("DPKG_MAINTSCRIPT_ARCH");
	arch = dpkg_arch_find(archname);
	if (arch->type == DPKG_ARCH_NONE || arch->type == DPKG_ARCH_EMPTY)
		return false;

	for (pkg = &set->pkg; pkg; pkg = pkg->arch_next)
		ensure_packagefiles_available(pkg);

	iter = fsys_node_pkgs_iter_new(namenode);
	while ((pkg = fsys_node_pkgs_iter_next(iter))) {
		if (pkg->set == set && pkg->installed.arch != arch) {
			shared = true;
			break;
		}
	}
	fsys_node_pkgs_iter_free(iter);

	return shared;
}
Beispiel #2
0
static void
test_dpkg_arch_modify(void)
{
	struct dpkg_arch *arch;

	dpkg_arch_reset_list();

	/* Insert a new unknown arch. */
	arch = dpkg_arch_find("foo");
	test_pass(arch->type == DPKG_ARCH_UNKNOWN);
	test_str(arch->name, ==, "foo");

	/* Check that existing unknown arch gets tagged. */
	arch = dpkg_arch_add("foo");
	test_pass(arch->type == DPKG_ARCH_FOREIGN);
	test_str(arch->name, ==, "foo");

	/* Check that new unknown arch gets tagged. */
	arch = dpkg_arch_add("quux");
	test_pass(arch->type == DPKG_ARCH_FOREIGN);
	test_str(arch->name, ==, "quux");

	/* Unmark foreign architectures. */

	arch = dpkg_arch_find("foo");
	dpkg_arch_unmark(arch);
	test_pass(arch->type == DPKG_ARCH_UNKNOWN);

	arch = dpkg_arch_find("bar");
	dpkg_arch_unmark(arch);
	test_pass(arch->type == DPKG_ARCH_UNKNOWN);

	arch = dpkg_arch_find("quux");
	dpkg_arch_unmark(arch);
	test_pass(arch->type == DPKG_ARCH_UNKNOWN);
}
Beispiel #3
0
static const char *
pkg_spec_prep(struct pkg_spec *ps, char *pkgname, const char *archname)
{
	ps->name = pkgname;
	ps->arch = dpkg_arch_find(archname);

	ps->name_is_pattern = false;
	ps->arch_is_pattern = false;

	/* Detect if we have patterns and/or illegal names. */
	if ((ps->flags & PKG_SPEC_PATTERNS) && strpbrk(ps->name, "*[?\\"))
		ps->name_is_pattern = true;

	if ((ps->flags & PKG_SPEC_PATTERNS) && strpbrk(ps->arch->name, "*[?\\"))
		ps->arch_is_pattern = true;

	return pkg_spec_is_illegal(ps);
}
Beispiel #4
0
static int
arch_remove(const char *const *argv)
{
  const char *archname = *argv++;
  struct dpkg_arch *arch;
  struct pkgiterator *iter;
  struct pkginfo *pkg;

  if (archname == NULL || *argv)
    badusage(_("--%s takes exactly one argument"), cipaction->olong);

  modstatdb_open(msdbrw_readonly);

  arch = dpkg_arch_find(archname);
  if (arch->type != DPKG_ARCH_FOREIGN) {
    warning(_("cannot remove non-foreign architecture '%s'"), arch->name);
    return 0;
  }

  /* Check if it's safe to remove the architecture from the db. */
  iter = pkg_db_iter_new();
  while ((pkg = pkg_db_iter_next_pkg(iter))) {
    if (pkg->status < PKG_STAT_HALFINSTALLED)
      continue;
    if (pkg->installed.arch == arch) {
      if (fc_architecture)
        warning(_("removing architecture '%s' currently in use by database"),
                arch->name);
      else
        ohshit(_("cannot remove architecture '%s' currently in use by the database"),
               arch->name);
      break;
    }
  }
  pkg_db_iter_free(iter);

  dpkg_arch_unmark(arch);
  dpkg_arch_save_list();

  modstatdb_shutdown();

  return 0;
}
Beispiel #5
0
static void
test_dpkg_arch_find(void)
{
	struct dpkg_arch *arch;

	/* Test existence and initial values of default architectures. */
	arch = dpkg_arch_find("all");
	test_pass(arch->type == DPKG_ARCH_ALL);
	test_pass(dpkg_arch_get(DPKG_ARCH_ALL) == arch);
	arch = dpkg_arch_find(ARCHITECTURE);
	test_pass(arch->type == DPKG_ARCH_NATIVE);
	test_pass(dpkg_arch_get(DPKG_ARCH_NATIVE) == arch);
	arch = dpkg_arch_find("any");
	test_pass(arch->type == DPKG_ARCH_WILDCARD);
	test_pass(dpkg_arch_get(DPKG_ARCH_WILDCARD) == arch);

	/* Test missing architecture. */
	arch = dpkg_arch_find(NULL);
	test_pass(arch->type == DPKG_ARCH_NONE);
	test_pass(dpkg_arch_get(DPKG_ARCH_NONE) == arch);
	test_str(arch->name, ==, "");

	/* Test empty architectures. */
	arch = dpkg_arch_find("");
	test_pass(arch->type == DPKG_ARCH_EMPTY);
	test_pass(dpkg_arch_get(DPKG_ARCH_EMPTY) == arch);
	test_str(arch->name, ==, "");

	/* Test for an unknown type. */
	test_pass(dpkg_arch_get(1000) == NULL);

	/* New valid architectures are marked unknown. */
	arch = dpkg_arch_find("foobar");
	test_pass(arch->type == DPKG_ARCH_UNKNOWN);
	test_str(arch->name, ==, "foobar");

	/* New illegal architectures are marked illegal. */
	arch = dpkg_arch_find("a:b");
	test_pass(arch->type == DPKG_ARCH_ILLEGAL);
	test_str(arch->name, ==, "a:b");
}