Author: locilka Date: Tue Apr 21 14:10:17 2009 New Revision: 56878 URL: http://svn.opensuse.org/viewcvs/yast?rev=56878&view=rev Log: - Using new function GetCachedFileFromSource from AddOnProduct to avoid from a 'jukebox' issues when more different physical media used during installation (bnc #486785). Modified: trunk/packager/package/yast2-packager.changes trunk/packager/src/modules/AddOnProduct.ycp Modified: trunk/packager/package/yast2-packager.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/package/yast2-packager.c... ============================================================================== --- trunk/packager/package/yast2-packager.changes (original) +++ trunk/packager/package/yast2-packager.changes Tue Apr 21 14:10:17 2009 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Apr 21 14:05:09 CEST 2009 - locilka@suse.cz + +- Using new function GetCachedFileFromSource from AddOnProduct + to avoid from a 'jukebox' issues when more different physical + media used during installation (bnc #486785). + +------------------------------------------------------------------- Mon Apr 20 12:19:34 CEST 2009 - locilka@suse.cz - Not checking signatures for add_on_products(.xml) file(s), the Modified: trunk/packager/src/modules/AddOnProduct.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/AddOnProduct... ============================================================================== --- trunk/packager/src/modules/AddOnProduct.ycp (original) +++ trunk/packager/src/modules/AddOnProduct.ycp Tue Apr 21 14:10:17 2009 @@ -100,6 +100,91 @@ // if true, both are skipped at once without asking global boolean skip_add_ons = false; +/** + * @struct $["src_id|media|filename" : "/path/to/the/file"] + */ +map <string, string> source_file_cache = $[]; + +string filecachedir = sformat ("%1/AddOns_CacheDir/", Directory::tmpdir); + +integer filecachecounter = -1; + +/** + * Downloads a requested file, caches it and returns path to that cached file. + * If a file is alerady cached, just returns the path to a cached file. + * Parameter 'sod' defines whether a file is 'signed' (file + file.asc) or 'digested' + * (file digest mentioned in signed content file). + * + * @param integer src_id + * @param integer media + * @param string filename + * @param string sod ("signed" or "digested") + * @param boolean optional (false if mandatory) + * @return string path to a cached file + * + * @example: + * // content file is usually signed with content.asc + * AddOnProduct::GetCachedFileFromSource (8, 1, "/content", "signed", false); + * // the other files are usually digested in content file + * AddOnProduct::GetCachedFileFromSource (8, 1, "/images/images.xml", "digested", true); + */ +global string GetCachedFileFromSource (integer src_id, integer media, string filename, string sod, boolean optional) { + // BNC #486785: Jukebox when using more physical media-based Add-Ons at once + string file_ID = sformat ("%1|%2|%3", src_id, media, filename); + + string provided_file = source_file_cache[file_ID]:""; + + if (provided_file != nil && provided_file != "") { + // Checking whether the cached file exists + if (FileUtils::Exists (provided_file)) { + y2milestone ("File %1 found in cache: %2", file_ID, provided_file); + + return provided_file; + } else { + y2warning ("Cached file %1 not accessible!", provided_file); + source_file_cache = remove (source_file_cache, file_ID); + } + } + + if (optional == nil) optional = true; + + if (sod == "signed") { + provided_file = Pkg::SourceProvideSignedFile (src_id, media, filename, optional); + } else if (sod == "digested") { + provided_file = Pkg::SourceProvideDigestedFile (src_id, media, filename, optional); + } else { + y2error ("Unknown SoD: %1. It can be only 'signed' or 'digested'", sod); + provided_file = nil; + } + + // A file has been found, caching... + if (provided_file != nil) { + filecachecounter = filecachecounter + 1; + + // Where the file is finally cached + string cached_file = sformat ("%1%2", filecachedir, filecachecounter); + + string cmd = sformat ( + "/bin/mkdir -p '%1'; /bin/cp '%2' '%3'", + String::Quote (filecachedir), String::Quote (provided_file), String::Quote (cached_file) + ); + map cmd_run = (map) SCR::Execute (.target.bash_output, cmd); + + // Unable to cache a file, the original file will be returned + if (cmd_run["exit"]:-1 != 0) { + y2warning ("Error caching file: %1: %2", cmd, cmd_run); + } else { + y2milestone ("File %1 cached as %2", file_ID, cached_file); + // Writes entry into cache database + source_file_cache[file_ID] = cached_file; + // Path to a cached file will be returned + provided_file = cached_file; + } + } + + return provided_file; +} + // Which part installation.xml will be used string _inst_mode = "installation"; @@ -420,7 +505,7 @@ } boolean IntegrateY2Update (integer src_id) { - string binaries = Pkg::SourceProvideDigestedFile (src_id, 1, "/y2update.tgz", true /* optional */); + string binaries = GetCachedFileFromSource (src_id, 1, "/y2update.tgz", "digested", true /* optional */); // File /y2update.tgz exists if (binaries != nil) { @@ -603,7 +688,7 @@ y2milestone ("Using cached contentfile %1", contentfile); } else { y2milestone ("Checking contentfile from repository"); - string sourcefile = Pkg::SourceProvideSignedFile (src_id, 1, "/content", true); + string sourcefile = GetCachedFileFromSource (src_id, 1, "/content", "signed", true); if (sourcefile == nil) { y2warning ("Cannot obtain content file!"); return nil; @@ -692,7 +777,7 @@ symbol ret = nil; - string control = Pkg::SourceProvideDigestedFile (src_id, 1, "/installation.xml", true /* optional */); + string control = GetCachedFileFromSource (src_id, 1, "/installation.xml", "digested", true /* optional */); if (control != nil) { y2milestone ("Add-On has own control file"); ret = DoInstall_WithControlFile (control); @@ -841,7 +926,7 @@ */ void HandleProductPATTERNS (integer srcid) { // FATE #302398: PATTERNS keyword in content file - string content_file = Pkg::SourceProvideSignedFile (srcid, 1, "/content", true); + string content_file = GetCachedFileFromSource (srcid, 1, "/content", "signed", true); if (content_file == nil) { y2warning ("Add-On %1 doesn't have a content file", srcid); @@ -860,7 +945,7 @@ y2milestone ("Integrating repository %1", srcid); // Updating inst-sys - string y2update = Pkg::SourceProvideDigestedFile (srcid, 1, "/y2update.tgz", true /* optional */); + string y2update = GetCachedFileFromSource (srcid, 1, "/y2update.tgz", "digested", true /* optional */); if (y2update == nil) { y2milestone ("No YaST update found on the media"); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org