コード例 #1
0
ファイル: uploaderslist.c プロジェクト: KubaKaszycki/reprepro
bool uploaders_verifyatom(struct upload_conditions *conditions, atom_t atom) {
	const struct upload_condition *c = conditions->current;

	assert (c != NULL);
	assert (c->type == uc_ARCHITECTURES);

	conditions->needscandidate = false;
	switch (conditions->current->needs) {
		case needs_all:
		case needs_existsall:
			/* once one condition is false, the case is settled */

			if (conditions->matching &&
					!atomlist_in(&c->atoms, atom))
				conditions->matching = false;
			/* but while it is true, more info is needed */
			return conditions->matching;
		case needs_any:
			/* once one condition is true, the case is settled */
			if (!conditions->matching &&
					atomlist_in(&c->atoms, atom))
				conditions->matching = true;
			/* but while it is false, more info is needed */
			return !conditions->matching;
		case needs_anycandidate:
			/* we are settled, no more information needed */
			return false;
	}
	/* NOT REACHED */
	assert (conditions->current->needs != conditions->current->needs);
}
コード例 #2
0
ファイル: pull.c プロジェクト: aprillinden/reprepro
static retvalue pull_createsource(struct pull_rule *rule,
		struct target *target,
		struct pull_source ***s) {
	const struct atomlist *c;
	const struct atomlist *a_from, *a_into;
	int ai;

	assert (rule != NULL);
	assert (rule->distribution != NULL);

	if (rule->architectures_set) {
		a_from = &rule->architectures_from;
		a_into = &rule->architectures_into;
	} else {
		a_from = &rule->distribution->architectures;
		a_into = &rule->distribution->architectures;
	}
	if (target->packagetype == pt_udeb)  {
		if (rule->udebcomponents_set)
			c = &rule->udebcomponents;
		else
			c = &rule->distribution->udebcomponents;
	} else {
		if (rule->components_set)
			c = &rule->components;
		else
			c = &rule->distribution->components;
	}

	if (!atomlist_in(c, target->component))
		return RET_NOTHING;

	for (ai = 0 ; ai < a_into->count ; ai++) {
		struct pull_source *source;

		if (a_into->atoms[ai] != target->architecture)
			continue;

		source = NEW(struct pull_source);
		if (FAILEDTOALLOC(source))
			return RET_ERROR_OOM;

		source->next = NULL;
		source->rule = rule;
		source->source = distribution_getpart(rule->distribution,
				target->component,
				a_from->atoms[ai],
				target->packagetype);
		**s = source;
		*s = &source->next;
	}
	return RET_OK;
}
コード例 #3
0
ファイル: pull.c プロジェクト: aprillinden/reprepro
static void checksubset(const struct atomlist *needed, const struct atomlist *have, const char *rulename, const char *from, const char *what, const char **atoms) {
	int i, j;

	for (i = 0 ; i < needed->count ; i++) {
		atom_t value = needed->atoms[i];

		for (j = 0 ; j < i ; j++) {
			if (value == needed->atoms[j])
				break;
		}
		if (j < i)
			continue;

		if (!atomlist_in(have, value)) {
			fprintf(stderr,
"Warning: pull rule '%s' wants to get something from %s '%s',\n"
"but there is no such %s in distribution '%s'.\n"
"(This will simply be ignored and is not even checked when using --fast).\n",
					rulename, what,
					atoms[value], what, from);
		}
	}
}
コード例 #4
0
ファイル: distribution.c プロジェクト: KubaKaszycki/reprepro
/* create all contained targets... */
static retvalue createtargets(struct distribution *distribution) {
	retvalue r;
	int i, j;
	struct target *t;
	struct target *last = NULL;
	bool has_source = false;

	for (i = 0 ; i < distribution->components.count ; i++) {
		component_t c = distribution->components.atoms[i];
		for (j = 0 ; j < distribution->architectures.count ; j++) {
			architecture_t a = distribution->architectures.atoms[j];

			if (a == architecture_source) {
				has_source = true;
				continue;
			}
			if (a == architecture_all) {
				fprintf(stderr,
"Error: Distribution %s contains an architecture called 'all'.\n",
						distribution->codename);
				return RET_ERROR;
			}
			if (strcmp(atoms_architectures[a], "any") == 0) {
				fprintf(stderr,
"Error: Distribution %s contains an architecture called 'any'.\n",
						distribution->codename);
				return RET_ERROR;
			}

			r = target_initialize_binary(
					distribution,
					c, a,
					&distribution->deb,
					distribution->readonly,
					distribution->exportoptions[deo_noexport],
					distribution->fakecomponentprefix,
					&t);
			if (RET_IS_OK(r)) {
				if (last != NULL) {
					last->next = t;
				} else {
					distribution->targets = t;
				}
				last = t;
			}
			if (RET_WAS_ERROR(r))
				return r;
			if (atomlist_in(&distribution->udebcomponents, c)) {
				r = target_initialize_ubinary(
						distribution,
						c, a,
						&distribution->udeb,
						distribution->readonly,
						distribution->exportoptions
							[deo_noexport],
						distribution->fakecomponentprefix,
						&t);
				if (RET_IS_OK(r)) {
					if (last != NULL) {
						last->next = t;
					} else {
						distribution->targets = t;
					}
					last = t;
				}
				if (RET_WAS_ERROR(r))
					return r;

			}
		}
		/* check if this distribution contains source
		 * (yes, yes, source is not really an architecture, but
		 *  the .changes files started with this...) */
		if (has_source) {
			r = target_initialize_source(distribution,
					c, &distribution->dsc,
					distribution->readonly,
					distribution->exportoptions
							[deo_noexport],
					distribution->fakecomponentprefix, &t);
			if (last != NULL) {
				last->next = t;
			} else {
				distribution->targets = t;
			}
			last = t;
			if (RET_WAS_ERROR(r))
				return r;
		}
	}
	return RET_OK;
}
コード例 #5
0
ファイル: checkindeb.c プロジェクト: Noctem/reprepro
static retvalue deb_preparelocation(struct debpackage *pkg, component_t forcecomponent, const struct atomlist *forcearchitectures, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const struct overridedata **oinfo_ptr, const char *debfilename){
	const struct atomlist *components;
	const struct overridefile *binoverride;
	const struct overridedata *oinfo;
	retvalue r;

	if (packagetype == pt_udeb) {
		binoverride = distribution->overrides.udeb;
		components = &distribution->udebcomponents;
	} else {
		binoverride = distribution->overrides.deb;
		components = &distribution->components;
	}

	oinfo = override_search(binoverride, pkg->deb.name);
	*oinfo_ptr = oinfo;
	if (forcesection == NULL) {
		forcesection = override_get(oinfo, SECTION_FIELDNAME);
	}
	if (forcepriority == NULL) {
		forcepriority = override_get(oinfo, PRIORITY_FIELDNAME);
	}
	if (!atom_defined(forcecomponent)) {
		const char *fc;

		fc = override_get(oinfo, "$Component");
		if (fc != NULL) {
			forcecomponent = component_find(fc);
			if (!atom_defined(forcecomponent)) {
				fprintf(stderr,
"Unparseable component '%s' in $Component override of '%s'\n",
					fc, pkg->deb.name);
				return RET_ERROR;
			}
		}
	}

	if (forcesection != NULL) {
		free(pkg->deb.section);
		pkg->deb.section = strdup(forcesection);
		if (FAILEDTOALLOC(pkg->deb.section)) {
			return RET_ERROR_OOM;
		}
	}
	if (forcepriority != NULL) {
		free(pkg->deb.priority);
		pkg->deb.priority = strdup(forcepriority);
		if (FAILEDTOALLOC(pkg->deb.priority)) {
			return RET_ERROR_OOM;
		}
	}

	if (pkg->deb.section == NULL) {
		fprintf(stderr, "No section given for '%s', skipping.\n",
				pkg->deb.name);
		return RET_ERROR;
	}
	if (pkg->deb.priority == NULL) {
		fprintf(stderr, "No priority given for '%s', skipping.\n",
				pkg->deb.name);
		return RET_ERROR;
	}
	if (strcmp(pkg->deb.section, "unknown") == 0 && verbose >= 0) {
		fprintf(stderr, "Warning: strange section '%s'!\n",
				pkg->deb.section);
	}

	/* decide where it has to go */

	r = guess_component(distribution->codename, components,
			pkg->deb.name, pkg->deb.section,
			forcecomponent, &pkg->component);
	if (RET_WAS_ERROR(r))
		return r;
	if (verbose > 0 && !atom_defined(forcecomponent)) {
		fprintf(stderr, "%s: component guessed as '%s'\n", debfilename,
				atoms_components[pkg->component]);
	}

	/* some sanity checks: */

	if (forcearchitectures != NULL &&
			pkg->deb.architecture != architecture_all &&
			!atomlist_in(forcearchitectures,
				pkg->deb.architecture)) {
		fprintf(stderr,
"Cannot add '%s', as it is architecture '%s' and you specified to only include ",
				debfilename,
				atoms_architectures[pkg->deb.architecture]);
		atomlist_fprint(stderr, at_architecture, forcearchitectures);
		fputs(".\n", stderr);
		return RET_ERROR;
	} else if (pkg->deb.architecture != architecture_all &&
			!atomlist_in(&distribution->architectures,
				pkg->deb.architecture)) {
		(void)fprintf(stderr,
"Error looking at '%s': '%s' is not one of the valid architectures: '",
				debfilename,
				atoms_architectures[pkg->deb.architecture]);
		(void)atomlist_fprint(stderr, at_architecture,
				&distribution->architectures);
		(void)fputs("'\n", stderr);
		return RET_ERROR;
	}
	if (!atomlist_in(components, pkg->component)) {
		fprintf(stderr,
"Error looking at %s': Would be placed in unavailable component '%s'!\n",
				debfilename,
				atoms_components[pkg->component]);
		/* this cannot be ignored
		 * as there is not data structure available */
		return RET_ERROR;
	}

	r = binaries_calcfilekeys(pkg->component, &pkg->deb,
			packagetype, &pkg->filekeys);
	if (RET_WAS_ERROR(r))
		return r;
	pkg->filekey = pkg->filekeys.values[0];
	return RET_OK;
}