[Title] add version checker
authorjiil.hyoun <jiil.hyoun@samsung.com>
Tue, 9 Oct 2012 07:07:24 +0000 (16:07 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Tue, 9 Oct 2012 07:07:24 +0000 (16:07 +0900)
[Type] Feature
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#] 7149
[Problem] need package version check
[Cause] some error caused
[Solution]
[TestCase]

Change-Id: I3ccaaeda506b1c1c7b7b8769683138eb1e4dd4a5

src/common/parser.rb

index 99ad13725769abc9c5e406ed54c02c5a6d4d1c0a..db85cad3598c68a85cce9416dd578d7203ef149b 100644 (file)
@@ -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