From: jiil.hyoun Date: Tue, 9 Oct 2012 07:07:24 +0000 (+0900) Subject: [Title] add version checker X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8961bfb41da6d0903b2e07c305436da1a7e6856;p=sdk%2Ftools%2Fsdk-build.git [Title] add version checker [Type] Feature [Module] Toolchain / [Priority] Minor [Jira#] [Redmine#] 7149 [Problem] need package version check [Cause] some error caused [Solution] [TestCase] Change-Id: I3ccaaeda506b1c1c7b7b8769683138eb1e4dd4a5 --- diff --git a/src/common/parser.rb b/src/common/parser.rb index 99ad137..db85cad 100644 --- a/src/common/parser.rb +++ b/src/common/parser.rb @@ -64,7 +64,7 @@ class Parser end when /^Version$/i then state = "COMMON" - if common_version.empty? then common_version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip + if common_version.empty? then common_version = check_version l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field" end when /^Maintainer$/i then @@ -112,7 +112,7 @@ class Parser end when /^Version$/i then state = "COMMON" - if common_version.empty? then common_version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip + if common_version.empty? then common_version = check_version l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field" end when /^Maintainer$/i then @@ -138,7 +138,7 @@ class Parser end multi_line = nil when /^Version$/i then - if common_version.empty? and package.version.empty? then package.version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip + if common_version.empty? and package.version.empty? then package.version = check_version l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field" end multi_line = nil @@ -244,6 +244,14 @@ class Parser return pkglist end + def Parser.check_version(version) + if not version =~ /^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*$/ then + raise RuntimeError, "Version format not matched \"#{version}\"\nVersion format must be \"{digit}.{digit}.{digit}\"" + end + puts version + return version + end + def Parser.read_changelog(file) return read_multy_pkginfo_from(file,true)[3] end