Author: lslezak Date: Wed Jun 6 15:59:58 2007 New Revision: 38317 URL: http://svn.opensuse.org/viewcvs/yast?rev=38317&view=rev Log: - check existence of the files (#256442) Modified: trunk/sound/sound/src/ (props changed) trunk/sound/sound/src/read_routines.ycp trunk/sound/sound/src/volume_routines.ycp trunk/sound/sound/src/write_routines.ycp Modified: trunk/sound/sound/src/read_routines.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/read_routines.ycp?rev=38317&r1=38316&r2=38317&view=diff ============================================================================== --- trunk/sound/sound/src/read_routines.ycp (original) +++ trunk/sound/sound/src/read_routines.ycp Wed Jun 6 15:59:58 2007 @@ -214,18 +214,33 @@ * @return list */ define list<map> read_save_info () ``{ + list<map> saved = []; // First, read from /etc/modprobe.d/sound - list<map> saved = read_modprobe (.modprobe_sound); - if (saved == []) + if (SCR::Read(.target.size, "/etc/modprobe.d/sound") >= 0) { - // Nothing was there. So, try /etc/modprobe.conf... - saved = read_modprobe (.modules); - if (saved != []) + saved = read_modprobe (.modprobe_sound); + } + else + { + y2milestone("/etc/modprobe.d/sound doesn't exist"); + + // try /etc/modprobe.conf... + if (SCR::Read(.target.size, "/etc/modprobe.conf") >= 0) { - Sound::used_modprobe_conf = true; + saved = read_modprobe (.modules); + + if (saved != []) + { + Sound::used_modprobe_conf = true; + } + } + else + { + y2milestone("/etc/modprobe.conf doesn't exist"); } } + return saved; } Modified: trunk/sound/sound/src/volume_routines.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/volume_routines.ycp?rev=38317&r1=38316&r2=38317&view=diff ============================================================================== --- trunk/sound/sound/src/volume_routines.ycp (original) +++ trunk/sound/sound/src/volume_routines.ycp Wed Jun 6 15:59:58 2007 @@ -235,6 +235,14 @@ } } + boolean GlobExists(string glob) + { + map out = (map)SCR::Execute(.target.bash_output, sformat("echo -n %1", glob)); + y2debug("output: %1", out); + + return out["stdout"]:"" != glob; + } + /** * stops all programs using sound devices * @return boolean true if nothing's using sound, false otherwise @@ -244,7 +252,23 @@ { return true; } - integer fuser = (integer) SCR::Execute (.target.bash, "/bin/fuser /dev/dsp* /dev/audio* /dev/mixer* /dev/midi* /dev/mixer*", $[]); + + // list of files to check, * must be present! + list<string> audio_files = ["/dev/dsp*", "/dev/audio*", "/dev/mixer*", "/dev/midi*", "/dev/mixer*"]; + + audio_files = filter(string file, audio_files, {return GlobExists(file);}); + y2milestone("Checking audio files: %1", audio_files); + + if (size(audio_files) == 0) + { + y2milestone("No audio device file found, skipping fuser call"); + return true; + } + + string fuser_options = mergestring(audio_files, " "); + y2milestone("fuser options: %1", fuser_options); + + integer fuser = (integer) SCR::Execute (.target.bash, "/bin/fuser " + fuser_options, $[]); if (fuser == 0) { @@ -252,7 +276,7 @@ boolean terminate = Sound::use_ui ? Popup::YesNo (msg) : true; if (terminate) { - SCR::Execute (.target.bash, "/bin/fuser -k /dev/dsp* /dev/audio* /dev/mixer* /dev/midi* /dev/mixer*", $[]); + SCR::Execute (.target.bash, "/bin/fuser -k " + fuser_options, $[]); } else { Modified: trunk/sound/sound/src/write_routines.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/write_routines.ycp?rev=38317&r1=38316&r2=38317&view=diff ============================================================================== --- trunk/sound/sound/src/write_routines.ycp (original) +++ trunk/sound/sound/src/write_routines.ycp Wed Jun 6 15:59:58 2007 @@ -211,7 +211,17 @@ ``(card["module"]:"off"))); // remove the options for unused modules - list<string> configured_options = SCR::Dir(.modprobe_sound.options); + list<string> configured_options = []; + + if (SCR::Read(.target.size, "/etc/modprobe.d/sound") >=0 ) + { + configured_options = SCR::Dir(.modprobe_sound.options); + } + else + { + // the file doesn't exist, create an empty file + SCR::Execute(.target.bash, "/usr/bin/touch /etc/modprobe.d/sound"); + } foreach(string op, configured_options, { @@ -234,14 +244,17 @@ * @param als list with old aliases */ define void removeOldEntries(list als) ``{ - maplist(string e, (list<string>) als, ``{ - if (is_snd_alias(e) || - issubstring(e, "sound-service-") || - issubstring(e, "sound-slot-")) - { - SCR::Write( add (.modprobe_sound.alias, e), nil); - } - }); + if (SCR::Read(.target.size, "/etc/modprobe.d/sound") >=0 ) + { + maplist(string e, (list<string>) als, ``{ + if (is_snd_alias(e) || + issubstring(e, "sound-service-") || + issubstring(e, "sound-slot-")) + { + SCR::Write( add (.modprobe_sound.alias, e), nil); + } + }); + } } /** @@ -321,7 +334,7 @@ list als=[]; string err_msg = ""; - if (contains(SCR::Dir(mod), "alias")) + if (SCR::Read(.target.size, "/etc/modprobe.d/sound") >=0 && contains(SCR::Dir(mod), "alias")) { als = (list)SCR::Read(mod_alias); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org