Description 29/26229/1
authorHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 19 Aug 2014 11:56:39 +0000 (20:56 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 19 Aug 2014 11:56:39 +0000 (20:56 +0900)
- multiple package server sync is no good design
-- Now package server can sync only one depth

Change-Id: Ie516191b0fae1b59f85de2a474a8abfb208001ca
Signed-off-by: Hyoun Jiil <jiil.hyoun@samsung.com>
package/changelog
package/pkginfo.manifest
src/pkg_server/client.rb
src/pkg_server/packageServer.rb

index d9a7cde295b86cc797eb8ad0005995b433dc9219..42380073a3027baaec91128c9a757ef6d5517451 100644 (file)
@@ -1,3 +1,7 @@
+* 2.2.3
+- multiple package server sync is no good design
+-- Now package server can sync only one depth
+== hyoun jiil <jiil.hyoun@samsung.com> 2014-08-19
 * 2.2.2
 - Fix pkg-svr clean/remove-snapshot bug 
 --  Now changes folder snapshot log also remove
index 0366a45bd35f815898c1dd060a55463f84ba9f87..2247994eccca80b9af879d676f54679caeaa7600 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :2.2.2
+Version :2.2.3
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com, jonghwan park <jonghwan2.park@samsung.com>
 
 Package : tizen-dibs-test
index 0993b99924dbaa933ac93634872bf80340100ba3..7a61e97230dd7a5e23b2e3f6b3847e0c1d7a4ddb 100644 (file)
@@ -1612,6 +1612,37 @@ class Client
         return pkg_all_list.sort
     end
 
+    public
+    # check_syncable_server?
+    # from_server : if true, update from server
+    def check_syncable_server?()
+        ssinfo_file = "snapshot.info"
+        file_url = File.join(@server_addr, ssinfo_file)
+        if @is_server_remote then
+            if not FileDownLoader.download(file_url, @config_dist_path, @log) then
+                @log.error "Server does not have \"#{ssinfo_file}\" file."
+                return false
+            end
+        else
+            if File.exist? file_url then 
+                FileUtils.cp(file_url, @config_dist_path)
+            else 
+                @log.error "Server does not have \"#{ssinfo_file}\" file."
+                return false
+            end
+        end
+
+        file_path = File.join(@config_dist_path, ssinfo_file)
+        if not File.exist? file_path then return false end
+
+        contents = File.open(file_path, "r").read
+
+        _list = contents.split("\n\n")
+        snapshot_list = _list.map {|x| x.split("\n").first.split(":")[1].strip }
+
+        return (snapshot_list.index{|x| /sync_.*/ =~ x}.nil?)
+    end
+
     private
     def get_build_dependency_arr(pkg_name, os, n)
         pkg_hash = @pkg_hash_os[os]
index 950c938a97009124ef3833f8348c524b32d2ca70..487597ab9591e08c83af08736fbab9f6a059d4a7 100644 (file)
@@ -130,6 +130,18 @@ class PackageServer
                create_distribution_struct( dist_name, server_url )
                Utils.file_unlock(lock_file)
 
+        # remote server check
+        if (not server_url.empty?) then
+            client = Client.create(server_url.strip, "#{@location}/binary", @log);
+            if client.nil? or not client.check_syncable_server? then
+                # remove configs
+                FileUtils.rm_rf @location
+                FileUtils.rm_rf @config_dir
+                @log.error( "#{server_url} is invalid or not synchronizable package server",Log::LV_USER)
+                return nil
+            end
+        end
+
                @log.output( "package server [#{@id}] created successfully", Log::LV_USER )
                @log.output( " - server location : #{@location}", Log::LV_USER )
                @log.output( " - server configure file : #{@config_file_path}", Log::LV_USER )
@@ -314,17 +326,22 @@ class PackageServer
                        return
                end
 
-               begin
-                       update, snapshot = distribution.sync(mode, snapshot)
-                       if update then
-                               distribution.generate_snapshot("sync_#{snapshot}", "", false, distribution.last_sync_changes)
-                       end
-    
-                       @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER )
-               rescue => e
-                       @log.error( e.message, Log::LV_USER)
-               end
-       end
+        client = Client.create(distribution.server_url, "#{@location}/binary", @log);
+        if client.nil? or not client.check_syncable_server? then 
+            @log.error( "#{distribution.server_url} is invalid or not synchronizable package server", Log::LV_USER)
+        else
+            begin
+                update, snapshot = distribution.sync(mode, snapshot)
+                if update then
+                    distribution.generate_snapshot("sync_#{snapshot}", "", false, distribution.last_sync_changes)
+                end
+
+                @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER )
+            rescue => e
+                @log.error( e.message, Log::LV_USER)
+            end
+        end
+    end
 
        def add_distribution( dist_name, server_url, clone )
                lock_file = Utils.file_lock(@server_lock_file_path)