[zypp-devel] How to Use libzypp Repositories Within Installation/Upgrade

Hi, This is mostly about using current repositories during upgrade (using CD/DVD media) but also about migration of these sources. During the beta phase of 10.3 a new feature has been added: When upgrading to 10.3, a new dialog appears offering to use previously used repositories in the upgrade process. How does it work? * First, it tries to find sources in the /var/lib/zypp/db/sources/ directory. * If they are none, it tries /etc/zypp/repos.d/ * Then, if any sources are found, it offers them to be enabled during the installation. * Installation then creates either disabled or enabled sources according to the user's request and these sources are used in the upgrade process. * Later, installation stores all sources used during installation to the target disk. What's wrong? * When upgrading 10.2 to 10.3 everything is fine: - Sources are found in /var/lib/zypp/db/sources/ - They are added either enabled or disabled during upgrade - They are stored to the target to /etc/zypp/repos.d/ - libzypp works with /etc/zypp/repos.d/ correctly * When upgrading 10.3 to 11.0 a problem appears: - Sources are found in /var/lib/zypp/db/sources/ - They are added either enabled or disabled during upgrade - They are stored to the target to /etc/zypp/repos.d/ but as you expected, the old ones remain there. - In the end, there are old sources as they were before the upgrade and also the new ones as decided by user during the upgrade. Why such thing happens? Because installation proceeds in inst-sys with target mounted to /mnt. Libzypp doesn't use target's repositories (which is correct because of memory consumptions). Installation/Upgrade needs to select which sources should be used and why shouldn't (for instance old online update source). Solution? A very quick but very dirty hack would be to remove all sources from /etc/zypp/repos.d/ before storing the actual set of sources to the target. Is there any better solution? Could you, please, help me with it? See bug #326325 Thanks & Bye Lukas -- Lukas Ocilka, YaST Developer (xn--luk-gla45d) ----------------------------------------------------------------- SUSE LINUX, s. r. o., Lihovarska 1060/12, Praha 9, Czech Republic

On Wed, Sep 26, Lukas Ocilka wrote:
Solution? A very quick but very dirty hack would be to remove all sources from /etc/zypp/repos.d/ before storing the actual set of sources to the target.
AFAIK we always just disabled the sources located on the old system. Until we are able to make some intelligent guess we should leave it to the user to finaly delete them. // old system root Pathname mgrdir_r( "/mnt" ); // prefix paths with /mnt // (we should add a convenience ctor for that) RepoManagerOptions mgropt; mgropt.repoCachePath = mgrdir_r/mgropt.repoCachePath; mgropt.repoRawCachePath = mgrdir_r/mgropt.repoRawCachePath; mgropt.knownReposPath = mgrdir_r/mgropt.knownReposPath"; // load old systems repos... RepoManager oldrepoManager( mgropt ); RepoInfoList oldrepos = oldrepoManager.knownRepositories(); // ...and disable them. for_( it, oldrepos.begin(), oldrepos.end() ) { oldrepoManager.modifyRepository( it->alias(), it->setEnabled( false ) ); } -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Michael Andres wrote:
On Wed, Sep 26, Lukas Ocilka wrote:
Solution? A very quick but very dirty hack would be to remove all sources from /etc/zypp/repos.d/ before storing the actual set of sources to the target.
AFAIK we always just disabled the sources located on the old system. Until we are able to make some intelligent guess we should leave it to the user to finaly delete them.
// old system root Pathname mgrdir_r( "/mnt" );
// prefix paths with /mnt // (we should add a convenience ctor for that) RepoManagerOptions mgropt; mgropt.repoCachePath = mgrdir_r/mgropt.repoCachePath; mgropt.repoRawCachePath = mgrdir_r/mgropt.repoRawCachePath; mgropt.knownReposPath = mgrdir_r/mgropt.knownReposPath";
// load old systems repos... RepoManager oldrepoManager( mgropt ); RepoInfoList oldrepos = oldrepoManager.knownRepositories();
// ...and disable them. for_( it, oldrepos.begin(), oldrepos.end() ) { oldrepoManager.modifyRepository( it->alias(), it->setEnabled( false ) ); }
Thanks, Hmm, and are Pkg Bindings able to do that? Libzypp is already initialized in inst-sys, I'd need to reinitialize it in the /mnt chroot, disable those sources and close the /mnt again... This would be partly a solution, but it doesn't solve the whole problem. Imagine the situation: * There are old sources in /mnt -> now disabled (as MA suggests) * Newly added sources (the same as found in /mnt) will be stored after SaveAll function call (some enabled, the other disabled). This leads into having the old sources twice... L.

On Thu, Sep 27, Lukas Ocilka wrote:
Michael Andres wrote:
On Wed, Sep 26, Lukas Ocilka wrote:
Solution? A very quick but very dirty hack would be to remove all sources from /etc/zypp/repos.d/ before storing the actual set of sources to the target.
AFAIK we always just disabled the sources located on the old system. Until we are able to make some intelligent guess we should leave it to the user to finaly delete them.
// old system root Pathname mgrdir_r( "/mnt" );
// prefix paths with /mnt // (we should add a convenience ctor for that) RepoManagerOptions mgropt; mgropt.repoCachePath = mgrdir_r/mgropt.repoCachePath; mgropt.repoRawCachePath = mgrdir_r/mgropt.repoRawCachePath; mgropt.knownReposPath = mgrdir_r/mgropt.knownReposPath";
// load old systems repos... RepoManager oldrepoManager( mgropt ); RepoInfoList oldrepos = oldrepoManager.knownRepositories();
// ...and disable them. for_( it, oldrepos.begin(), oldrepos.end() ) { oldrepoManager.modifyRepository( it->alias(), it->setEnabled( false ) ); }
Thanks,
Hmm, and are Pkg Bindings able to do that?
Why not.
This would be partly a solution, but it doesn't solve the whole problem. Imagine the situation:
* There are old sources in /mnt -> now disabled (as MA suggests) * Newly added sources (the same as found in /mnt) will be stored after SaveAll function call (some enabled, the other disabled).
This leads into having the old sources twice...
..i.e. two repos with the same alias? Only if you avoid using the RepoManager interface and do it on your own. If you use a RepoManager like the above, you know about the old systems repos, you can adapt their status as needed and you can inject new repos avoiding alias clashes. (and if something is misssing or inconvenient we can improve. just ask.) -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (2)
-
Lukas Ocilka
-
Michael Andres