Пример #1
0
string convertWildcardedExpressionToFse(const string& expression)
{
	auto getPackageNameFse = [](const string& packageNameExpression)
	{
		return format2("package:name(%s)", globToRegexString(packageNameExpression));
	};

	auto delimiterPosition = expression.find_first_of("/=");
	if (delimiterPosition != string::npos)
	{
		string additionalFseRule;

		string packageGlobExpression = expression.substr(0, delimiterPosition);
		string remainder = expression.substr(delimiterPosition+1);
		if (expression[delimiterPosition] == '/') // distribution
		{
			static const sregex distributionExpressionRegex = sregex::compile("[a-z-]+");
			static smatch m;
			if (!regex_match(remainder, m, distributionExpressionRegex))
			{
				fatal2(__("bad distribution '%s' requested, use archive or codename"), remainder);
			}

			additionalFseRule = format2("or(release:archive(%s), release:codename(%s))", remainder, remainder);
		}
		else // exact version string
		{
			checkVersionString(remainder);
			additionalFseRule = format2("version(%s)", globToRegexString(remainder));
		}

		return format2("%s & %s", getPackageNameFse(packageGlobExpression), additionalFseRule);
	}
	else
	{
		return getPackageNameFse(expression);
	}
}
Пример #2
0
sregex globToRegex(const string& glob)
{
	return stringToRegex<sregex>(globToRegexString(glob));
}