Author: jsuchome Date: Tue Oct 18 11:09:06 2011 New Revision: 66472 URL: http://svn.opensuse.org/viewcvs/yast?rev=66472&view=rev Log: - call SLEPOS specific XSL transformation (bnc#723031) Modified: trunk/product-creator/package/yast2-product-creator.changes trunk/product-creator/src/Kiwi.ycp Modified: trunk/product-creator/package/yast2-product-creator.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/package/yast2-product-creator.changes?rev=66472&r1=66471&r2=66472&view=diff ============================================================================== --- trunk/product-creator/package/yast2-product-creator.changes (original) +++ trunk/product-creator/package/yast2-product-creator.changes Tue Oct 18 11:09:06 2011 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Mon Oct 17 15:28:32 CEST 2011 - jsuchome@suse.cz + +- call SLEPOS specific XSL transformation (bnc#723031) + +------------------------------------------------------------------- Tue Sep 27 15:00:13 CEST 2011 - visnov@suse.cz - set dialog title Modified: trunk/product-creator/src/Kiwi.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/Kiwi.ycp?rev=66472&r1=66471&r2=66472&view=diff ============================================================================== --- trunk/product-creator/src/Kiwi.ycp (original) +++ trunk/product-creator/src/Kiwi.ycp Tue Oct 18 11:09:06 2011 @@ -219,6 +219,32 @@ return ret; } + /** + * Transform given XML file using given XSL transformation file + * Return path to new file if transformation was done and was successful + * @param config_path path to XML file + * @param xsl_file path to XSL file + */ + string XSLTTransform (string config_path, string xsl_file) { + string ret_path = config_path; + if (Package::Installed ("libxslt") && FileUtils::Exists (xsl_file)) + { + // new path identified by xsl file: + // config-usr-share-kiwi-xsl-convertSleposSp1toSp2-xsl.xml + ret_path = sformat ("%1/config%2.xml", + Directory::tmpdir, + mergestring (splitstring (xsl_file, "/ ."), "-")); + map out = (map) SCR::Execute (.target.bash_output, sformat ( + "/usr/bin/xsltproc '%1' '%2' > %3", + String::Quote (xsl_file), String::Quote (config_path), ret_path)); + if (out["exit"]:0 != 0) + { + y2error ("xslt transformation failed: %1", out); + ret_path = config_path; + } + } + return ret_path; + } /** * import the data from given config.xml @@ -234,16 +260,24 @@ return ret; } string file_path = base_path + "/config.xml"; - if (FileUtils::Exists ("/usr/share/kiwi/xsl/master.xsl")) + + // transformation to latest kiwi version + file_path = XSLTTransform (file_path, "/usr/share/kiwi/xsl/master.xsl"); + // transformation to latest SLEPOs version (bnc#723031) + string slepos_path = XSLTTransform (file_path, "/usr/share/kiwi/xsl/convertSleposSp1toSp2.xsl"); + // make a backup when SLEPOS transformation changed anything + if (slepos_path != file_path) { - file_path = Directory::tmpdir + "/transformed-config.xml"; map out = (map) SCR::Execute (.target.bash_output, sformat ( - "xsltproc /usr/share/kiwi/xsl/master.xsl %1/config.xml > %2", - base_path, file_path)); + "diff -1 '%1' '%2'", file_path, slepos_path)); if (out["exit"]:0 != 0) { - y2error ("xslt transformation failed: %1", out); + string backup = base_path + "/config.xml.POSsave"; + y2milestone ("creating backup of config file: %1", backup); + SCR::Execute (.target.bash, sformat ("cp -- '%1' '%2'", + String::Quote (file_path), String::Quote (backup))); } + file_path = slepos_path; } // read rest of config.xml using more generic agent -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org