Bug 368104

Summary: target product not read
Product: [openSUSE] openSUSE 11.0 Reporter: Jiří Suchomel <jsuchome>
Component: libzyppAssignee: Ladislav Slezák <lslezak>
Status: RESOLVED FIXED QA Contact: Duncan Mac-Vicar <dmacvicar>
Severity: Normal    
Priority: P2 - High CC: benji, bugz57, francis, lslezak, ma, martin.schlander
Version: Alpha 2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: y2log

Description Jiří Suchomel 2008-03-07 09:22:39 UTC
Created attachment 199391 [details]
y2log

When yast2-repair is called from installation media, it does some checks to compare source product (on the media) with installed target product (selected by user for repairing).

In YaST, I'm calling
Pkg::TargetInit ("/mnt", false)
(which doesn't produce any error message)

and later Pkg::TargetProducts (), which should return the list of target products, but returns nothing.


The real target product mounted under /mnt is actually also openSUSE11.0Alpha2+
Comment 1 Ladislav Slezák 2008-03-07 09:49:27 UTC
A short summary of what pkg-bindings do:

Pkg::TargetInit():

- zypp_ptr()->initializeTarget(r) // r = "/mnt" in this case,
  // "false" is an unused historical parameter
- zypp_ptr()->target()->load()
- remember the root, every zypp::RepoManager object which is later created uses this root path

Pkg::TargetProducts():

- iterates over the pool and searches for installed Product resolvable
(uh, that could be improved by using byIdent iterators instead of iterating over the whole pool, but this is irrelevant here...)
Comment 2 Ladislav Slezák 2008-03-07 09:51:26 UTC
(oh, I meant byKind iterator of course...)
Comment 3 Michael Andres 2008-03-07 17:16:42 UTC
Yes. As you may know the Product/Patch/Pattern is going to be changed. Currently these items are neither installed in the system nor available as installed items in the pool. 

It might be that 'being installed' becomes a property that applies to packages only, and for Product/Patch/Pattern we compute whether they are satisfied or broken.


I'll provide an interface in the pool that lets you access the installed-satisfies-however-computed products for this target.

Comment 4 Michael Andres 2008-03-07 17:45:09 UTC
*** Bug 367809 has been marked as a duplicate of this bug. ***
Comment 5 Benjamin Weber 2008-04-06 16:13:58 UTC
*** Bug 373367 has been marked as a duplicate of this bug. ***
Comment 6 Volker Kuhlmann 2008-04-10 21:17:37 UTC
*** Bug 375134 has been marked as a duplicate of this bug. ***
Comment 7 Michael Andres 2008-04-11 12:51:09 UTC
  ResPool pool( ResPool::instance() );
  for_( it, pool.satisfiedProductsBegin(), pool.satisfiedProductsEnd() )
  {
    Product_constPtr p( asKind<Product>(*it) );
    ...
  }

The above loop iterates over all satisfied products. Is satisfied status is computed and updated on each solver run. So it does not reflect any changes made since the last solver run.

Comment 8 Michael Andres 2008-04-11 13:27:53 UTC
I also adapted the loop in TargetProducts to iterate over satisfied products
(in SVN trunk).

Now someone has to take care that at the time TargetProducts is called, both - target and repositories - are loaded, and the solver was called.

Ladislav? Or is this to be done in YCP? If so, please reassign.
Comment 9 Ladislav Slezák 2008-04-14 10:58:41 UTC
I think it should be rather fiex in the YCP level.
Comment 10 Ladislav Slezák 2008-04-14 11:33:02 UTC
Pkg::TargetProducts() is used at two places in yast:

- in Products.ycp - that's a trivial fix to initial the target and the sources and run the solver (I'll fix that)

- in OSRPkg.ycp - it's tricky here because the repair module can be started from the installation media, I'm not sure whether the installation source is already registered when the module is started. Jiri?
Comment 11 Jiří Suchomel 2008-04-14 12:19:06 UTC
(In reply to comment #10 from Ladislav Slezak)

> - in OSRPkg.ycp - it's tricky here because the repair module can be started
> from the installation media, I'm not sure whether the installation source is
> already registered when the module is started. Jiri?

I added the solver run, let's see if it works in beta1. 

Comment 12 Ladislav Slezák 2008-04-14 15:54:52 UTC
I have adapted Product.ycp in yast2-2.16.51, resolving as FIXED.
Comment 13 Benjamin Weber 2008-04-20 13:55:11 UTC
Problem still present in yast2-2.16.52-6 (current factory).

Testcase:

echo '{import "Product"; y2milestone("Product is `%1`",Product::name);}' > ./ProductTest.ycp && /sbin/YaST2 ./ProductTest.ycp && grep "Product is" ~/.y2log


Logs "Product is ``" expected to log the product name.

YaST log: http://bw.uwcs.co.uk/ProductTest.log

Also, it now shows the distracting full screen package manager progress just for reading the product name, even without importing package callbacks, I expect that's another issue though.
Comment 14 Ladislav Slezák 2008-04-21 13:02:15 UTC
I'll change the Product module to read /etc/SuSE-release file instead of using the package manager...
Comment 15 Michael Andres 2008-04-21 13:42:58 UTC
Call Target::release() for this:

      getZYpp()->initializeTarget( sysRoot );
      std::string release = getZYpp()->target()->release();
Comment 16 Ladislav Slezák 2008-04-23 13:57:25 UTC
I fixed Product.ycp to read /etc/SuSE-release file directly because the module is imported in many yast modules which do not use package manager at all.

This will avoid initializing libzypp library just for reading a single file (when Martin's dlopen patch for is ready).

Fixed in yast2-2.16.55.
Comment 17 Benjamin Weber 2008-04-29 20:48:32 UTC
In current factory Product::name is reporting just "openSUSE". It should return "openSUSE 11.0" or "openSUSE Factory", including the version. Product::short_name should be the one with just the name.

    /**
     * General product name and version
     */
    global string name		= "";			// "SuSE Linux 8.1"
    global string short_name	= "";			// "SuSE Linux"
    global string version	= "";			// "8.1"
    global string vendor	= "";			// "SuSE Linux AG"

The method of identifying the product and version is really not something to break backwards compatibility on. 



Comment 18 Ladislav Slezák 2008-04-30 10:04:39 UTC
Fixed in SVN.

Benji, thanks for looking at it.
Comment 19 Ladislav Slezák 2008-04-30 12:36:13 UTC
*** Bug 381660 has been marked as a duplicate of this bug. ***
Comment 20 Ladislav Slezák 2008-05-02 13:02:34 UTC
Submitted in yast2-2.16.61