[packagekit] [PATCH 5/5] zypp: Add pattern support

Michael Andres ma at suse.de
Tue Feb 25 09:51:38 PST 2014


On Wednesday 22 January 2014 11:31:52 Thomas Perl wrote:
> Support for patterns (http://tr.opensuse.org/Patterns) by prefixing
> installation requests with "pattern:" and also listing available
> patterns as packages with "pattern:" prefix. This is similar to what
> zypper is doing, within the PackageKit framework's restriction (there
> is no package "type" for patterns, and it probably doesn't make any
> sense to have such a type for non-libzypp-based systems).
>
> Original patch by Pekka Lundstrom <pekka.lundstrom at jolla.com>
> ---
>  backends/zypp/pk-backend-zypp.cpp | 77
> ++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+),
> 10 deletions(-)
>
> diff --git a/backends/zypp/pk-backend-zypp.cpp
> b/backends/zypp/pk-backend-zypp.cpp index 7e9d8c9..f0783d9 100644
> --- a/backends/zypp/pk-backend-zypp.cpp
> +++ b/backends/zypp/pk-backend-zypp.cpp
> @@ -152,6 +152,21 @@ gchar * _repoName;
>   */
>  gboolean _updating_self = FALSE;
>
> +/*
> + * Test if this is pattern and all its dependencies are installed
> + */
> +static gboolean
> +zypp_satisfied_pattern(const sat::Solvable &solv)
> +{
> +	gboolean satisfied = FALSE;
> +
> +	if (isKind<Pattern>(solv)) {
> +		PoolItem patt = PoolItem(solv);
> +		satisfied = patt.isSatisfied();
> +	}
> +	return satisfied;
> +}
> +

Hi.

The above hunk caught my eye, because it will stop working when used with 
future openSUSE distros. Sorry for not providing a proper patch, but I'm 
(almost) on vacation.

Currently pattern are 'pseudo installed' objects. The resolver computes 
whether a patterns dependencies are currently satisfied. One may call 
this 'installed'. But a pattern will never show up in the @System repository, 
like installed packages do. This computed state is volatile. 

In openSUSE::Factory patterns become first class objects like packages. They 
will be actually installed and afterwards show up in the @System repository. 
The above function will not work for this new kind of pattern. Future distros 
will follow.


You can test whether a specific kind is 'pseudo installed' or not, so 
something like the function below could help to always compute the right case 
for 'repo = "installed";' in the hunk below.


 #include <zypp/ResTraits.h>

 inline bool isInstalledOrSatisfied( const sat::Solvable &solv )
 {
   return traits::isPseudoInstalled( solv.kind() )
          ? PoolItem(solv).isSatisfied()
          : solv.isSystem();
 }


>  /**
>   * Build a package_id from the specified resolvable.  The returned
>   * gchar * should be freed with g_free ().
> @@ -161,16 +176,22 @@ zypp_build_package_id_from_resolvable (const
> sat::Solvable &resolvable) {
>  	gchar *package_id;
>  	const char *arch;
> +	string name = resolvable.name ();
> +	string repo = resolvable.repository ().alias();

        string repo = isInstalledOrSatisfied(resolvable)
                      ? string("installed")
                      : resolvable.repository().alias();
>
> -	if (isKind<SrcPackage>(resolvable))
> +	if (isKind<Pattern>(resolvable)) {
> +		name = "pattern:" + resolvable.name ();
> +		arch = "noarch";

- > +		if (zypp_satisfied_pattern(resolvable)) 
- > +			repo = "installed";

> +	} else if (isKind<SrcPackage>(resolvable))
>  		arch = "source";
> -	else
> +	else {
>  		arch = resolvable.arch ().asString ().c_str ();
> -
> -	string repo = resolvable.repository ().alias();

- > -	if (resolvable.isSystem())
- > -		repo = "installed";

> -	package_id = pk_package_id_build (resolvable.name ().c_str (),

- > +		if (resolvable.isSystem())
- > +			repo = "installed";

> +	}
> +	package_id = pk_package_id_build (name.c_str (),
>  					  resolvable.edition ().asString ().c_str (),
>  					  arch, repo.c_str ());
>
>  		q.addAttribute( sat::SolvAttr::description );
>  		q.addAttribute( sat::SolvAttr::filelist );

-- 

cu,
    Michael Andres

+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862  27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres   SUSE LINUX Products GmbH, Development,   ma at suse.de
GF:Jeff Hawn,Jennifer Guild,Felix Imendörffer, HRB16746(AG Nürnberg) 
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+


More information about the PackageKit mailing list