Author: lslezak Date: Tue Jun 29 15:43:44 2010 New Revision: 62172 URL: http://svn.opensuse.org/viewcvs/yast?rev=62172&view=rev Log: - fixed creating SLP reg. files: fixed reading supported architectures from content file (bnc#608834), fixed also for SLES10 repositories (bnc#616307) - fixed reescaping already escaped values - 2.19.0 Modified: trunk/instserver/VERSION trunk/instserver/package/yast2-instserver.changes trunk/instserver/src/Instserver.ycp Modified: trunk/instserver/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/instserver/VERSION?rev=62172&r1=62171&r2=62172&view=diff ============================================================================== --- trunk/instserver/VERSION (original) +++ trunk/instserver/VERSION Tue Jun 29 15:43:44 2010 @@ -1 +1 @@ -2.18.3 +2.19.0 Modified: trunk/instserver/package/yast2-instserver.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/instserver/package/yast2-instserver.changes?rev=62172&r1=62171&r2=62172&view=diff ============================================================================== --- trunk/instserver/package/yast2-instserver.changes (original) +++ trunk/instserver/package/yast2-instserver.changes Tue Jun 29 15:43:44 2010 @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Jun 29 10:14:47 UTC 2010 - lslezak@suse.cz + +- fixed creating SLP reg. files: fixed reading supported + architectures from content file (bnc#608834), fixed also for + SLES10 repositories (bnc#616307) +- fixed reescaping already escaped values +- 2.19.0 + ------------------------------------------------------------------ Wed Jan 13 18:56:03 CET 2010 - kmachalkova@suse.cz Modified: trunk/instserver/src/Instserver.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/instserver/src/Instserver.ycp?rev=62172&r1=62171&r2=62172&view=diff ============================================================================== --- trunk/instserver/src/Instserver.ycp (original) +++ trunk/instserver/src/Instserver.ycp Tue Jun 29 15:43:44 2010 @@ -573,6 +573,76 @@ return ret; } +string subreplace(string text, string in, string out) +{ + list<string> parts = splitstring(text, "\\"); + + // don't modify the first item, it's the non-matched prefix + boolean first = true; + list<string> new_parts = maplist(string p, parts, + { + if (first) + { + first = false; + return p; + } + + string new_part = p; + + if (in == substring(p, 0, 2)) + { + new_part = out + substring(p, 2); + } + else + { + // put the backslash back if the remaining part doesn't match + new_part = "\\" + p; + } + + return new_part; + } + ); + + string ret = mergestring(new_parts, ""); + y2debug("unescaped str: text: %1, in: %2, out: %3 => %4", text, in, out, ret); + + return ret; +} + +// this is an oppsite function to EscapeSLPData() +// it takes SLP input and unescpaes the backslash sequences +map<string, string> UnEscapeSLPData(map<string, string> a) +{ + map<string, string> ret = $[]; + + foreach(string key, string value, a, + { + // String::Replace() enters endless loop in '\' -> '\5c' conversion + // use splitstring() and mergestring() builtins instead + string new_key = key; + new_key = subreplace(new_key, "2e", "."); + new_key = subreplace(new_key, "3d", "="); + new_key = subreplace(new_key, "23", "#"); + new_key = subreplace(new_key, "3b", ";"); + new_key = subreplace(new_key, "5c", "\\"); + + string new_value = value; + new_value = subreplace(new_value, "28", "("); + new_value = subreplace(new_value, "29", ")"); + new_value = subreplace(new_value, "2c", ","); + new_value = subreplace(new_value, "23", "#"); + new_value = subreplace(new_value, "3b", ";"); + new_value = subreplace(new_value, "5c", "\\"); + + ret[new_key] = new_value; + } + ); + + y2milestone("Unescaped SLP attributes: %1 -> %2", a, ret); + + return ret; +} + /* * Return the IP address of the local machine * @return string IP Address @@ -605,6 +675,48 @@ return hostname; } +list<string> basearch_mapping(string basearch) +{ + map<string,list<string> > mapping = $[ + "i586" : [ "i586", "i686" ], + "mips" : [ "mips", "mips64" ], + "ppc" : [ "ppc", "ppc64" ], + "sparc" : [ "sparc", "sparc64"], + "x86_64" : [ "x86_64"] + ]; + + if (!haskey(mapping, basearch)) + { + y2warning("Unknown BASEARCH: %1", basearch); + } + + // return the original basearch if mapping is unknown + list<string> ret = mapping[basearch]:[basearch]; + + y2milestone("Using BASEARCH mapping: %1 -> %2", basearch, ret); + + return ret; +} + +list<string> get_machines(string basearch_value) +{ + list<string> archs = splitstring(basearch_value, " "); + archs = filter(string a, archs, {return a != nil && a != "";}); + + list<string> ret = []; + + foreach(string a, archs, + { + ret = (list<string>)merge(ret, basearch_mapping(a)); + } + ); + + y2milestone("Final BASEARCH mapping: %1", ret); + + return ret; +} + + /** * Write SLP configuration */ @@ -680,21 +792,38 @@ string machine = ""; list<string> machines = []; foreach(string k, any v, cm, ``{ - if (issubstring(k, "ARCH")) + y2debug("Read Key: '%1'", k); + + if (k == "BASEARCHS") + { + // machine mapping + machines = get_machines((string)v); + } + else if (issubstring(k, "ARCH")) { - machines = (list<string>)union (machines, splitstring((string)v, " ") ); + string a = regexpsub(k, "ARCH\\.(.*)", "\\1"); + + if (a != nil) + { + y2milestone("Found %1 key, adding arch %2 to the list", k, a); + machines = add(machines, a); + } } }); machines = filter(string m , machines, ``(m!="" && m!="noarch")); machines = toset(machines); + + // sort the list so it looks better + machines = sort(machines); + string machines_string = mergestring(machines, ","); + y2debug("machines: %1", machines); - attr["machine"] = mergestring(machines, ","); - y2debug("machine: %1", machine); // preserve the old configuration if (SCR::Read(.target.size, read_file) >= 0) { y2milestone("Existing reg.d file found: %1", read_file); + map<string, string> old_attr = $[]; string reg_cont = (string)SCR::Read(.target.string, read_file); list<string> lines = splitstring(reg_cont, "\n"); @@ -706,11 +835,24 @@ if (parsed_name != nil) { y2milestone("Reusing attribute: %1=%2", parsed_name, parsed_value); - attr[parsed_name] = parsed_value; + old_attr[parsed_name] = parsed_value; } } ); + // unescape the read value + old_attr = UnEscapeSLPData(old_attr); + + if (haskey(old_attr, "machine")) + { + // backup the "machine" value + machines_string = old_attr["machine"]:""; + } + + // merge them with read values, + // keep the original setting if a value was already set + attr = (map<string, string>)union(attr, old_attr); + /* TODO: checking? // don't check the overwritten config file @@ -728,6 +870,11 @@ // escape invalid characters attr = EscapeSLPData(attr); + // replace the machine option after escaping, + // it actually _is_ a list so "," is valid here + attr["machine"] = machines_string; + y2milestone("machine: %1", attr["machine"]:""); + y2milestone("registering SLP service: serv: %1, attr: %2, regfile: %3", serv, attr, regfile); boolean ret = SLP::RegFile(serv, attr, regfile ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org