Author: locilka Date: Thu Oct 11 11:53:35 2007 New Revision: 41360 URL: http://svn.opensuse.org/viewcvs/yast?rev=41360&view=rev Log: - New function FileUtils::MD5sum. Modified: trunk/yast2/library/modules/FileUtils.ycp trunk/yast2/package/yast2.changes trunk/yast2/yast2.spec.in Modified: trunk/yast2/library/modules/FileUtils.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/modules/FileUtils.ycp?rev=41360&r1=41359&r2=41360&view=diff ============================================================================== --- trunk/yast2/library/modules/FileUtils.ycp (original) +++ trunk/yast2/library/modules/FileUtils.ycp Thu Oct 11 11:53:35 2007 @@ -16,6 +16,7 @@ import "SCR"; import "Popup"; + import "String"; /** * Function which determines if the requested file/directory exists. @@ -335,5 +336,46 @@ } } + /** + * Function return the md5 of the file. + * + * @return integer GID, nil if doesn't exist + * @param string file name + * + * @example + * FileUtils::GetOwnerGroupID ("/etc/passwd") -> 0 + * FileUtils::GetOwnerGroupID ("/does-not-exist") -> nil + */ + global string MD5sum (string target) { + if (! Exists(target)) { + y2error ("File %1 doesn't exist", target); + return nil; + } + + if (! IsFile(target)) { + y2error ("Not a file %1", target); + return nil; + } + + string ret = ""; + + string cmd = sformat ("md5sum '%1'", String::Quote (target)); + map cmd_out = (map) SCR::Execute (.target.bash_output, cmd); + + if (cmd_out["exit"]:-1 != 0) { + y2error ("Command >%1< returned %2", cmd, cmd_out); + return nil; + } + + string filemd5 = cmd_out["stdout"]:""; + if (regexpmatch (filemd5, "[^ \t]+[ \t]+.*$")) { + // Format: '19ea7ea41de37314f71c6849ddd259d5 /the/file' + filemd5 = regexpsub (filemd5, "^([^ \t]+)[ \t]+.*$", "\\1"); + } else { + y2warning ("Strange md5out: '%1'", filemd5); + return nil; + } + } + /* EOF */ } Modified: trunk/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=41360&r1=41359&r2=41360&view=diff ============================================================================== --- trunk/yast2/package/yast2.changes (original) +++ trunk/yast2/package/yast2.changes Thu Oct 11 11:53:35 2007 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Thu Oct 11 11:52:23 CEST 2007 - locilka@suse.cz + +- New function FileUtils::MD5sum. + +------------------------------------------------------------------- Thu Oct 4 16:29:01 CEST 2007 - jsrain@suse.cz - install bigsmp kernel regardless the memory size (Fate #159006) Modified: trunk/yast2/yast2.spec.in URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/yast2.spec.in?rev=41360&r1=41359&r2=41360&view=diff ============================================================================== --- trunk/yast2/yast2.spec.in (original) +++ trunk/yast2/yast2.spec.in Thu Oct 11 11:53:35 2007 @@ -12,6 +12,7 @@ # For Cron Agent, Module Requires: perl-Config-Crontab # for ag_tty (/bin/stty) +# for /usr/bin/md5sum Requires: coreutils Requires: yast2-xml yast2-hardware-detection # for SLPAPI.pm -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org