[SCM] ci-tooling packaging branch, master, updated. 5351e20cb881d848c51f47b5fe1c300a501169fc

Harald Sitter apachelogger-guest at moszumanska.debian.org
Tue Jun 30 07:14:34 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=0214a37

The following commit has been merged in the master branch:
commit 0214a375099dfee5b62449799a626fe36eae04cb
Author: Harald Sitter <sitter at kde.org>
Date:   Tue Jun 30 09:12:49 2015 +0200

    add a WIP reprepro incoming watcher class
    
    the idea is to have multiple instances per incoming one wants to watch
---
 lib/reprepro/incoming_watcher.rb | 96 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/lib/reprepro/incoming_watcher.rb b/lib/reprepro/incoming_watcher.rb
new file mode 100644
index 0000000..74015a8
--- /dev/null
+++ b/lib/reprepro/incoming_watcher.rb
@@ -0,0 +1,96 @@
+#!/usr/bin/env ruby
+
+require 'rb-inotify'
+
+module Reprepro
+  def reprepro(*args)
+    system('reprepro', *args)
+  end
+
+  class IncomingWatcher
+    def self.start(path)
+      repo = '/srv/apt'
+      notifier = INotify::Notifier.new
+      notifier.watch(path, :create) do |event|
+        next unless event.name.end_with?('.changes')
+        system('reprepro', '-V', '-b', repo, '--waitforlock', '1000', 'processincoming', 'default', event.name)
+        # S3MIRRORS.each do |mirror|
+        #   # NOTE: Make sure that when modifying this command, the target ends
+        #   # with a '/'
+        #   system("s3cmd -c #{repo}/s3cfg -v sync #{repo}/pool #{repo}/dists s3://#{mirror}/dci/#{FOLDER_NAME[repo]}/debian/")
+        # end
+      end
+      notifier.run
+    end
+  end
+end
+
+# :nocov:
+if __FILE__ == $PROGRAM_NAME
+  Reprepro::IncomingWatcher.start('/srv/apt_incoming')
+end
+# :nocov:
+
+
+  #!/usr/bin/env ruby
+  require 'rb-inotify'
+  require 'logger'
+  require 'thwait'
+
+  S3MIRRORS = ['pangea-data', 'pangea-data-lax-dci']
+  repos = []
+  threads = []
+  FOLDER_NAME = {}
+
+  logger = Logger.new(STDOUT)
+  logger.info "Starting ..."
+
+  notifier = INotify::Notifier.new
+
+  Dir['/home/publisher/repos/*'].each do |d|
+    next if d.include? 'processchanges'
+    repos << d if File.directory? d
+  end
+
+  logger.info "Will process #{repos}"
+
+  logger.info 'Initial sync ...'
+
+  # NOTE: Make sure that when modifying this command, the target ends
+  # with a '/'
+  repos.each do |repo|
+    FOLDER_NAME[repo] ||= repo.split('/')[-1]
+    S3MIRRORS.each do |mirror|
+      logger.info "Sending to #{mirror}/#{FOLDER_NAME[repo]}"
+      system("s3cmd -c #{repo}/s3cfg -v sync #{repo}/pool #{repo}/dists s3://#{mirror}/dci/#{FOLDER_NAME[repo]}/debian/")
+    end
+  end
+  logger.info 'Intial sync complete!'
+
+  repos.each do |repo|
+    threads << Thread.new do
+      logger.info "Processing #{repo}"
+      notifier.watch("#{repo}/incoming", :create) do |event|
+        if event.name.end_with? '.changes'
+          logger.info "Processing #{event.name}"
+          File.open(repo, 'r') do |f|
+            f.flock(File::LOCK_EX)
+            logger.info 'Locked reprepro dir'
+            system("reprepro -V -b #{repo} --waitforlock 1000 processincoming incoming #{event.name}")
+            logger.info 'INFO: Uploading to S3'
+            S3MIRRORS.each do |mirror|
+              logger.info "Sending to #{mirror}/#{FOLDER_NAME[repo]}"
+              # NOTE: Make sure that when modifying this command, the target ends
+              # with a '/'
+              system("s3cmd -c #{repo}/s3cfg -v sync #{repo}/pool #{repo}/dists s3://#{mirror}/dci/#{FOLDER_NAME[repo]}/debian/")
+            end
+            f.flock(File::LOCK_UN)
+          end
+        end
+      end
+      logger.info "Installed watch for #{repo}"
+    end
+  end
+
+  notifier.run
+  ThreadsWait.all_waits(threads)

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list