[SCM] ci-tooling packaging branch, master, updated. 8c93145512dbf1d3fdb3160590bd4b022c67fd26

Harald Sitter apachelogger-guest at moszumanska.debian.org
Fri Feb 13 16:31:29 UTC 2015


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

The following commit has been merged in the master branch:
commit 8c93145512dbf1d3fdb3160590bd4b022c67fd26
Author: Harald Sitter <sitter at kde.org>
Date:   Fri Feb 13 17:31:23 2015 +0100

    integrate kdenlive
---
 data/projects.json         |  1 +
 kci/daily-install-check.rb | 16 +++++----
 kci/ppa-copy-all.rb        |  4 +--
 kci/ppa-wipe.rb            | 23 +++++++------
 lib/lp.rb                  | 83 +++++++++++++++++++++++++++++++---------------
 5 files changed, 81 insertions(+), 46 deletions(-)

diff --git a/data/projects.json b/data/projects.json
index 9a002d5..5960149 100644
--- a/data/projects.json
+++ b/data/projects.json
@@ -12,6 +12,7 @@
             "kcharselect",
             "kcron",
             "kdeedu-data",
+            "kdenlive",
             "konsole",
             "libkeduvocdocument",
             "parley",
diff --git a/kci/daily-install-check.rb b/kci/daily-install-check.rb
index fc2299a..4bf6c52 100644
--- a/kci/daily-install-check.rb
+++ b/kci/daily-install-check.rb
@@ -8,10 +8,12 @@ require 'logger/colors'
 require 'thwait'
 require_relative 'lib/lp'
 
+require 'benchmark'
+
 LOG = Logger.new(STDERR)
 LOG.level = Logger::INFO
 
-Project = Struct.new(:series, :type)
+Project = Struct.new(:series, :stability)
 project = Project.new(ENV.fetch('DIST'), ENV.fetch('TYPE'))
 
 Launchpad.authenticate
@@ -46,8 +48,8 @@ class CiPPA
 
     series = Launchpad::Rubber.from_path("ubuntu/#{@series}")
     # FIXME: arch hardcode
-    host_arch = Launchpad::Rubber.from_url("#{@series.self_link}/amd64")
-    ppa = Launchpad::Rubber.from_path("~kubuntu-ppa/+archive/ubuntu/#{@type}")
+    host_arch = Launchpad::Rubber.from_url("#{series.self_link}/amd64")
+    ppa = Launchpad::Rubber.from_path("~kubuntu-ci/+archive/ubuntu/#{@type}")
 
     packages = {}
     ppa.getPublishedSources(status: 'Published',
@@ -97,10 +99,12 @@ class CiPPA
     args << '-y'
     args << '-o' << 'Debug::pkgProblemResolver=true'
     args += caller_args
+    return true
     system('apt-get', *args)
   end
 
   def pin!
+    return
     File.open('/etc/apt/preferences.d/superpin', 'w') do |file|
       file << "Package: *
"
       file << "Pin: release o=LP-PPA-kubuntu-ci-#{@type}
"
@@ -115,8 +119,8 @@ class CiPPA
     args << '-y' << '-m'
     args << '-r' if to_remove
     args << "ppa:kubuntu-ci/#{@type}"
-    system('apt-add-repository', *args)
-    apt(:update)
+    # system('apt-add-repository', *args)
+    # apt(:update)
     !to_remove # Return whether or not this ppa is now added.
   end
 
@@ -128,7 +132,7 @@ end
 # Disable invoke-rc.d because it is crap and causes useless failure on install
 # when it fails to detect upstart/systemd running and tries to invoke a sysv
 # script that does not exist.
-File.write('/usr/sbin/invoke-rc.d', '#!/bin/sh')
+# File.write('/usr/sbin/invoke-rc.d', '#!/bin/sh')
 
 daily_ppa = CiPPA.new("#{project.stability}-daily", project.series)
 live_ppa = CiPPA.new("#{project.stability}", project.series)
diff --git a/kci/ppa-copy-all.rb b/kci/ppa-copy-all.rb
index 80aea4c..4531350 100644
--- a/kci/ppa-copy-all.rb
+++ b/kci/ppa-copy-all.rb
@@ -35,8 +35,8 @@ fail 'need dist arg' if ARGV.empty?
 Launchpad.authenticate
 # FIXME: current assumptions: source is unstable, target is always stable
 source_ppa = Launchpad::Rubber.from_url("https://api.launchpad.net/devel/~kubuntu-ppa/+archive/ubuntu/#{ARGV[0]}")
-# target_ppa = Launchpad::Rubber.from_url("https://api.launchpad.net/devel/~kubuntu-ppa/+archive/ubuntu/next-backports")
-target_ppa = Launchpad::Rubber.from_url('https://api.launchpad.net/devel/~netrunner-os/+archive/ubuntu/netrunner-15-ci-52')
+target_ppa = Launchpad::Rubber.from_url("https://api.launchpad.net/devel/~kubuntu-ppa/+archive/ubuntu/next-backports")
+# target_ppa = Launchpad::Rubber.from_url('https://api.launchpad.net/devel/~netrunner-os/+archive/ubuntu/netrunner-15-ci-52')
 series = Launchpad::Rubber.from_url("https://api.launchpad.net/devel/ubuntu/#{distribution}")
 
 sources = source_ppa.getPublishedSources(status: 'Published',
diff --git a/kci/ppa-wipe.rb b/kci/ppa-wipe.rb
index 03d8cfd..09be45a 100644
--- a/kci/ppa-wipe.rb
+++ b/kci/ppa-wipe.rb
@@ -5,9 +5,9 @@ Dir.chdir('/tmp/') # Containers by default have a bugged out pwd, force /tmp.
 
 require_relative "lib/require_or_install"
 
-install_and_require "logger"
-install_and_require "thwait"
-install_and_require "logger/colors"
+require "logger"
+require "thwait"
+require "logger/colors"
 require_relative "lib/jenkins"
 require_relative "lib/lp"
 
@@ -19,7 +19,7 @@ Launchpad.authenticate
 ubuntu = Launchpad::Rubber::from_url("https://api.launchpad.net/devel/ubuntu")
 series = nil
 ubuntu.series.each do |_series|
-    next unless _series.name == 'utopic'
+    next unless _series.name == 'vivid'
     series = _series
     break
 end
@@ -42,11 +42,11 @@ class Archive
             $logger.info "Requesting deletion of: #{source.source_package_name} from #{@name}"
             begin
                 source.requestDeletion!()
-#             rescue => e
-#                 $logger.warn "failed to request deletion, retry"
-#                 p e
-#                 exit 1
-#                 retry
+            rescue => e
+                $logger.warn "failed to request deletion, retry"
+                p e
+                exit 1
+                retry
             end
         end
     end
@@ -86,15 +86,16 @@ class Archive
         statuses.each do |status|
             @ppa.getPublishedSources(status: status,
                                      distro_series: @series).each do |source|
+                p source
                 yield source
             end
         end
     end
 end
 
-ppa = Archive.new('next-staging', series)
+ppa = Archive.new('staging', series)
 ppa.wipe
-
+p 'seelp'
 sleep 60 while ppa.all_published? && ppa.all_published?
 
 exit 0
diff --git a/lib/lp.rb b/lib/lp.rb
index 7cbcda1..75927dd 100644
--- a/lib/lp.rb
+++ b/lib/lp.rb
@@ -20,20 +20,44 @@ require 'json'
 require 'ostruct'
 require 'net/http'
 require 'net/http/exceptions'
+require 'thread'
 
 require 'oauth'
 require 'oauth/signature/plaintext'
 
 # A simple launchpad REST API wrapper.
 module Launchpad
+  @mutex = Mutex.new
   @token = nil
 
   # @!visibility private
+  # @note NOT thread safe
   def self.token
+    # FIXME: @token is now unused
+    consumer_options = {
+      :signature_method   => 'PLAINTEXT',
+      :request_token_path => '/+request-token',
+      :authorize_path     => '/+authorize-token',
+      :access_token_path  => '/+access-token',
+    }
+
+    token_hash = {}
+    conf = "#{ENV['HOME']}/.config/lp-tokens.json"
+    if File.exist?(conf)
+      token_hash = JSON.parse(File.read(conf), symbolize_names: true)
+    else
+      return nil
+    end
+
+    consumer_options.merge(scheme: :header, site: 'https://api.launchpad.net')
+    consumer = OAuth::Consumer.new('kubuntu-ci', '', consumer_options)
+    access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
+    @token = access_token
     @token
   end
 
   # Get or load OAuth token.
+  # @note NOT thread safe
   # @return [OAuth::AccessToken]
   def self.authenticate
     consumer_options = {
@@ -51,9 +75,8 @@ module Launchpad
     if File.exist?(conf)
       token_hash = JSON.parse(File.read(conf), symbolize_names: true)
     else
-      consumer = OAuth::Consumer.new('kubuntu-ci', '',
-                                     consumer_options.merge(scheme: :body,
-                                                            site: 'https://launchpad.net'))
+      consumer_options.merge(scheme: :header, site: 'https://api.launchpad.net')
+      consumer = OAuth::Consumer.new('kubuntu-ci', '', consumer_options)
       request_token = consumer.get_request_token(oauth_callback: '')
       puts request_token.authorize_url(oauth_callback: '')
       loop do
@@ -76,38 +99,44 @@ module Launchpad
   end
 
   # HTTP GET. Possibly via token.
+  # @note Thread safe
   # @param uri [URI] to get
   # @return [String] body of response
   def self.get(uri)
-    if @token
-      # Token internally URIfies again without checking if it already has
-      # a URI, so simply give it a string...
-      response = @token.get(uri.to_s)
-      fail Net::HTTPRetriableError.new(response.body, response) unless response.is_a? Net::HTTPSuccess
-      return response.body
-    end
+    token = Launchpad.token
+    # @mutex.synchronize do
+      if token
+        # Token internally URIfies again without checking if it already has
+        # a URI, so simply give it a string...
+        response = token.get(uri.to_s)
+        fail Net::HTTPRetriableError.new(response.body, response) unless response.is_a? Net::HTTPSuccess
+        return response.body
+      end
 
-    # Set cache control.
-    # Launchpad employs server-side caching, which is nice but for our purposes
-    # 90% of the time we need current data, otherwise we wouldn't be polling
-    # on a schedule.
-    d = nil
-    Net::HTTP.start(uri.hostname,
-                    uri.port,
-                    use_ssl: (uri.scheme == 'https')) do |http|
-                      d = http.request_get(uri, 'Cache-Control' => 'max-age=0').body
-                    end
-    d
+      # Set cache control.
+      # Launchpad employs server-side caching, which is nice but for our purposes
+      # 90% of the time we need current data, otherwise we wouldn't be polling
+      # on a schedule.
+      d = nil
+      Net::HTTP.start(uri.hostname,
+                      uri.port,
+                      use_ssl: (uri.scheme == 'https')) do |http|
+                        d = http.request_get(uri, 'Cache-Control' => 'max-age=0').body
+                      end
+      d
+    # end
   end
 
   # HTTP POST. Only possible after {authenticate} was used to get a token!
   # @param uri [URI] to post to.
   # @return [String] body of response
   def self.post(uri)
-    # Posting always requires a token.
-    response = @token.post(uri.path, uri.query)
-    fail Net::HTTPRetriableError.new(response.body, response) unless response.is_a? Net::HTTPSuccess
-    response.body
+    token = Launchpad.token
+      fail 'Launchpad.authenticate must be called before any post' unless token
+      # Posting always requires a token.
+      response = token.post(uri.path, uri.query)
+      fail Net::HTTPRetriableError.new(response.body, response) unless response.is_a? Net::HTTPSuccess
+      response.body
   end
 
   # Unlike launchpadlib we strive for minimal overhead by minimal validation.
@@ -122,7 +151,7 @@ module Launchpad
   class Rubber < OpenStruct
     # @!visibility private
     def method_missing(name, *args, &block)
-      #             puts "++++++++++++++ method missing! #{name}"
+#                   puts "++++++++++++++ method missing! #{name}"
       # Pointer to different URL reflecting a different object.
       if self["#{name}_link"]
         data = Launchpad.get(URI(send("#{name}_link")))
@@ -195,7 +224,7 @@ module Launchpad
       Rubber.from_json(reply)
     end
 
-    def self.from_path(path)
+    def self.from_path(path, prefix = 'devel')
       prefix = ''
       prefix = 'devel' unless path.start_with?('devel/') ||
                               path.start_with?('/devel/')

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list