Hello community,
here is the log from the commit of package webyast-software-ws for
openSUSE:Factory
checked in at Wed May 4 10:49:27 CEST 2011.
--------
--- webyast-software-ws/webyast-software-ws.changes 2011-02-09
10:19:23.000000000 +0100
+++
/mounts/work_src_done/STABLE/webyast-software-ws/webyast-software-ws.changes
2011-05-03 11:01:41.000000000 +0200
@@ -1,0 +2,24 @@
+Tue May 3 09:01:34 UTC 2011 - [email protected]
+
+- adapted deleting cache key
+- 0.3.5
+
+-------------------------------------------------------------------
+Mon May 2 12:43:38 UTC 2011 - [email protected]
+
+- adapt caching to the new job handling
+- 0.3.4
+
+-------------------------------------------------------------------
+Tue Apr 12 13:29:12 UTC 2011 - [email protected]
+
+- new caching
+- 0.3.3
+
+-------------------------------------------------------------------
+Fri Feb 11 09:42:29 UTC 2011 - [email protected]
+
+- fix installing patches which require EULA confirmation
+ (bnc#669470)
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ webyast-software-ws.spec ++++++
--- /var/tmp/diff_new_pack.1Mx9xm/_old 2011-05-04 10:46:53.000000000 +0200
+++ /var/tmp/diff_new_pack.1Mx9xm/_new 2011-05-04 10:46:53.000000000 +0200
@@ -48,7 +48,7 @@
Group: Productivity/Networking/Web/Utilities
Url: http://en.opensuse.org/Portal:WebYaST
AutoReqProv: on
-Version: 0.3.2
+Version: 0.3.5
Release: 1
Summary: WebYaST - software management service
Source: www.tar.bz2
@@ -128,7 +128,7 @@
%endif
%endif
-mkdir -p $RPM_BUILD_ROOT/var/lib/yastws/software
+mkdir -p $RPM_BUILD_ROOT/var/lib/yastws/software/licenses/accepted
%clean
rm -rf $RPM_BUILD_ROOT
@@ -143,6 +143,7 @@
# grant the permission for the webservice user
polkit-auth --user %{webyast_ws_user} --grant
org.freedesktop.packagekit.system-sources-configure >& /dev/null || true
polkit-auth --user %{webyast_ws_user} --grant
org.freedesktop.packagekit.system-update >& /dev/null || true
+polkit-auth --user %{webyast_ws_user} --grant
org.freedesktop.packagekit.package-eula-accept >& /dev/null || true
%files
%defattr(-,root,root)
@@ -159,7 +160,6 @@
%{plugin_dir}/uninstall.rb
%{plugin_dir}/app
%{plugin_dir}/lib
-%{plugin_dir}/scripts
%{plugin_dir}/config
%attr(644,root,root) %config
/usr/share/PolicyKit/policy/org.opensuse.yast.system.patches.policy
%attr(644,root,root) %config
/usr/share/PolicyKit/policy/org.opensuse.yast.system.packages.policy
++++++ www.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/controllers/packages_controller.rb
new/www/app/controllers/packages_controller.rb
--- old/www/app/controllers/packages_controller.rb 2010-08-27
14:58:55.000000000 +0200
+++ new/www/app/controllers/packages_controller.rb 2011-04-11
12:49:05.000000000 +0200
@@ -25,13 +25,8 @@
before_filter :login_required
- # always check permissions and cache expiration
- # even if the result is already created and cached
+ # always check permissions
before_filter :check_read_permissions, :only => {:index, :show}
- before_filter :check_cache_status, :only => :index
-
- # cache 'index' method result
- caches_action :index
private
@@ -39,24 +34,6 @@
permission_check "org.opensuse.yast.system.patches.read"
end
- # check whether the cached result is still valid
- def check_cache_status
- cache_timestamp = Rails.cache.read('patches:timestamp')
-
- if cache_timestamp.nil?
- # this is the first run, the cache is not initialized yet, just return
- Rails.cache.write('patches:timestamp', Time.now)
- return
- # the cache expires after 5 minutes, repository metadata
- # or RPM database update invalidates the cache immeditely
- # (new patches might be applicable)
- elsif cache_timestamp < 5.minutes.ago || cache_timestamp < Patch.mtime
- logger.debug "#### Patch cache expired"
- expire_action :action => :index, :format => params["format"]
- Rails.cache.write('patches:timestamp', Time.now)
- end
- end
-
def compare_lists(packages)
vendor_packages = Array.new
#TODO: replace by real yml file
@@ -73,8 +50,8 @@
public
- # GET /patch_updates
- # GET /patch_updates.xml
+ # GET /packages
+ # GET /packages.xml
def index
# note: permission check was performed in :before_filter
@packages = Package.find(:installed)
@@ -87,13 +64,13 @@
end
end
- # GET /patch_updates/1
- # GET /patch_updates/1.xml
+ # GET /packages/1
+ # GET /packages/1.xml
def show
end
- # PUT /patch_updates/1
- # PUT /patch_updates/1.xml
+ # PUT /packages/1
+ # PUT /packages/1.xml
def update
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/controllers/patch_update/state_controller.rb
new/www/app/controllers/patch_update/state_controller.rb
--- old/www/app/controllers/patch_update/state_controller.rb 2010-09-17
16:25:41.000000000 +0200
+++ new/www/app/controllers/patch_update/state_controller.rb 2011-05-02
16:34:56.000000000 +0200
@@ -33,7 +33,7 @@
logger.warn "Confirmation of reading patch messages"
File.delete Patch::MESSAGES_FILE
-
+ YastCache.delete(Plugin.new(),"patch")
respond_to do |format|
format.xml { head :ok }
format.json { head :ok }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/controllers/patches_controller.rb
new/www/app/controllers/patches_controller.rb
--- old/www/app/controllers/patches_controller.rb 2011-02-01
10:49:25.000000000 +0100
+++ new/www/app/controllers/patches_controller.rb 2011-04-20
12:44:33.000000000 +0200
@@ -25,15 +25,8 @@
before_filter :login_required
- # always check permissions and cache expiration
- # even if the result is already created and cached
+ # always check permissions
before_filter :check_read_permissions, :only => [:index, :show]
- before_filter :check_cache_status, :only => :index
-
- # cache 'index' method result, but don't cache message requests
- # (caching messages would complicate the cache invalidation code
- # and it's fast anyway so it is actually not important)
- caches_action :index, :unless => Proc.new { |ctrl| ctrl.params['messages'] }
private
@@ -41,72 +34,38 @@
permission_check "org.opensuse.yast.system.patches.read" # RORSCAN_ITL
end
- # check whether the cached result is still valid
- def check_cache_status
- #cache contain string as it is only object supported by all caching backends
- cache_timestamp = Rails.cache.read('patches:timestamp').to_i
-
- if cache_timestamp.nil?
- # this is the first run, the cache is not initialized yet, just return
- Rails.cache.write('patches:timestamp', Time.now.to_i.to_s)
- # the cache expires after 5 minutes, repository metadata
- # or RPM database update invalidates the cache immediately
- # (new patches might be applicable)
- elsif cache_timestamp < 15.minutes.ago.to_i || cache_timestamp <
Patch.mtime.to_i
- logger.debug "#### Patch cache expired"
- expire_action :action => :index, :format => params["format"]
- Rails.cache.write('patches:timestamp', Time.now.to_i.to_s)
- end
- end
-
def collect_done_patches
done = []
+ installed = Rails.cache.fetch("patch:installed") || []
+ installed.each { |patch_id|
+ # e.g.: 'suse-build-key;1.0-907.30;noarch;@System'
+ attrs = patch_id.split(';')
+ done << Patch.new(:resolvable_id => attrs[1],
+ :name => attrs[0],
+ :arch => attrs[2],
+ :repo => attrs[3],
+ :installed => true)
+ }
+ return done
+ end
- BackgroundManager.instance.done.each do |k,v|
- if k.match(/^packagekit_install_(.*)/)
- patch_id = $1
- if BackgroundManager.instance.process_finished? k
- Rails.logger.debug "Patch installation request #{patch_id} is done"
- ret = BackgroundManager.instance.get_value k
-
- # check for exception
- if ret.is_a? StandardError
- raise ret
- end
-
- # e.g.: 'suse-build-key;1.0-907.30;noarch;@System'
- attrs = patch_id.split(';')
-
- done << Patch.new(:resolvable_id => attrs[1],
- :name => attrs[0],
- :arch => attrs[2],
- :repo => attrs[3],
- :installed => true)
- end
- end
+ def check_license_required
+ if PatchesState.read[:message_id] == "PATCH_EULA"
+ raise LicenseRequiredException.new
end
-
- return done
end
- def check_running_install
+ def check_running_install
running = 0
- max_progress = nil
- status = nil
- BackgroundManager.instance.running.each do |k,v|
- if k.match(/^packagekit_install_(.*)/)
- patch_id = $1
- tmp = BackgroundManager.instance.get_progress k
- if max_progress.nil? || tmp.progress > max_progress
- max_progress = tmp.progress
- status = tmp
- end
- logger.info "installation in progress. Patch #{k}"
- running += 1
- end
- end
- raise InstallInProgressException.new running,status if running > 0 #there
is process which runs installation
- end
+ jobs = Delayed::Job.find(:all)
+ jobs.each { |job|
+ running += 1 if
job.handler.split("\n")[1].split[1].include?("patch:install:")
+ } unless jobs.blank?
+ Rails.logger.info("#{running} installation jobs in the queue")
+ Rails.cache.delete("patch:installed") if running == 0 #remove installed
patches from cache if the installation
+ #has been finished
+ raise InstallInProgressException.new running if running > 0 #there is
process which runs installation
+ end
def read_messages
if File.exists?(Patch::MESSAGES_FILE)
@@ -132,23 +91,22 @@
end
return
end
- check_running_install
+ if params[:license].present?
+ respond_to do |format|
+ format.xml { render :xml => Patch.license.to_xml( :root =>
"licenses", :dasherize => false ) }
+ format.json { render :json => Patch.license.to_json( :root =>
"licenses", :dasherize => false ) }
+ end
+ return
+ end
+ check_license_required
+ check_running_install
# note: permission check was performed in :before_filter
- bgr = params['background']
- Rails.logger.info "Reading patches in background" if bgr
-
- @patches = Patch.find(:available, {:background => bgr})
+ @patches = Patch.find(:all)
@patches = @patches + collect_done_patches #report also which patches is
installed
respond_to do |format|
format.xml { render :xml => @patches.to_xml( :root => "patches",
:dasherize => false ) }
format.json { render :json => @patches.to_json( :root => "patches",
:dasherize => false ) }
end
-
- # do not cache the background progress status
- # (expire the cache in the next request)
- if bgr && @patches.first.class == BackgroundStatus
- Rails.cache.write('patches:timestamp', Time.at(0))
- end
end
# GET /patch_updates/1
@@ -179,8 +137,13 @@
# POST /patch_updates/
def create
permission_check "org.opensuse.yast.system.patches.install" # RORSCAN_ITL
- @patch_update = Patch.find(params[:patches][:resolvable_id].to_s)
+ if params[:patches][:accept_license].present? ||
params[:patches][:reject_license].present?
+ params[:patches][:accept_license].present? ? Patch.accept_license :
Patch.reject_license
+ index
+ return
+ end
+ @patch_update = Patch.find(params[:patches][:resolvable_id].to_s)
#Patch for Bug 560701 - [build 24.1] webYaST appears to crash after
installing webclient patch
#Packagekit returns empty string if the patch is allready installed.
if @patch_update.is_a?(Array) && @patch_update.empty?
@@ -194,8 +157,7 @@
end
res = @patch_update.install(true) #always install in backend otherwise
there is problem with long running updates
- Rails.cache.write('patches:timestamp', Time.at(0)) #invalidate cache
- index
+ render :show
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/controllers/repositories_controller.rb
new/www/app/controllers/repositories_controller.rb
--- old/www/app/controllers/repositories_controller.rb 2011-02-01
10:49:25.000000000 +0100
+++ new/www/app/controllers/repositories_controller.rb 2011-04-27
15:12:09.000000000 +0200
@@ -22,31 +22,10 @@
class RepositoriesController < ApplicationController
before_filter :login_required
-
- # cache index and show action
- before_filter :check_cache_status, :only => [:index]
before_filter :check_read_permissions, :only => [:index]
- caches_action :index
-
- CACHE_ID = 'repositories:timestamp'
private
- # check whether the cached result is still valid
- def check_cache_status
- cache_timestamp = Rails.cache.read(CACHE_ID)
-
- if cache_timestamp.nil?
- # this is the first run, the cache is not initialized yet, just return
- Rails.cache.write(CACHE_ID, Time.now)
- # the cache expires when /etc/zypp/repos.d is modified
- elsif cache_timestamp < Repository.mtime
- Rails.logger.debug "#### Repositories cache expired"
- expire_action :action => :index, :format => params["format"]
- Rails.cache.write(CACHE_ID, Time.now)
- end
- end
-
def check_read_permissions
permission_check "org.opensuse.yast.system.repositories.read" # RORSCAN_ITL
end
@@ -154,4 +133,4 @@
render :show
end
-end
\ No newline at end of file
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/models/package.rb
new/www/app/models/package.rb
--- old/www/app/models/package.rb 2011-02-01 10:49:25.000000000 +0100
+++ new/www/app/models/package.rb 2011-05-02 09:49:37.000000000 +0200
@@ -28,20 +28,23 @@
end
def self.find(what)
+ what = :installed if what == :all #default search for cache
if what == :installed
- package_list = Array.new
- self.execute("GetPackages", what.to_s, "Package") { |line1,line2,line3|
# RORSCAN_ITL
- columns = line2.split ";"
- package = Package.new(:resolvable_id => line2,
- :name => columns[0],
- :version => columns[1]
- )
- # :arch => columns[2],
- # :repo => columns[3],
- # :summary => line3 )
- package_list << package
- }
- package_list
+ YastCache.fetch(self,what) {
+ package_list = Array.new
+ PackageKit.transact("GetPackages", what.to_s, "Package") {
|line1,line2,line3| # RORSCAN_ITL
+ columns = line2.split ";"
+ package = Package.new(:resolvable_id => line2,
+ :name => columns[0],
+ :version => columns[1]
+ )
+ # :arch => columns[2],
+ # :repo => columns[3],
+ # :summary => line3 )
+ package_list << package
+ }
+ package_list
+ }
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/models/patch.rb new/www/app/models/patch.rb
--- old/www/app/models/patch.rb 2011-02-01 10:49:25.000000000 +0100
+++ new/www/app/models/patch.rb 2011-04-29 18:23:25.000000000 +0200
@@ -27,370 +27,227 @@
attr_accessor :messages
MESSAGES_FILE = File.join(Paths::VAR,"software","patch_installion_messages")
+ LICENSES_DIR = File.join(Paths::VAR,"software","licenses")
+ ACCEPTED_LICENSES_DIR =
File.join(Paths::VAR,"software","licenses","accepted")
+ JOB_PRIO = -30
private
- # just a short cut for accessing the singleton object
- def self.bm
- BackgroundManager.instance
+ def self.decide_license(accept)
+ #we don't know eula id, but as it block package kit, then there is only
one license file to decide
+ if accept
+ `find #{LICENSES_DIR} -type f -exec mv {} #{ACCEPTED_LICENSES_DIR} \\;`
+ else
+ `find #{LICENSES_DIR} -type f -delete`
+ end
end
- # create unique id for the background manager
- def self.id(what)
- "patches_#{what}"
+ public
+
+ def self.accept_license
+ decide_license true
end
- public
+ def self.reject_license
+ decide_license false
+ end
def to_xml( options = {} )
super :patch_update, options, @messages
end
# install
- def install(background=false)
- @messages=[]
+ def install(background = false)
+ # background process doesn't work correctly if class reloading is active
+ # (static class members are lost between requests)
+ # So the job queue is also not active
+ if background && !YastCache.job_queue_enabled?
+ Rails.logger.info "Job queue is not active. Disable background mode"
+ background = false
+ end
update_id = "#{self.name};#{self.resolvable_id};#{self.arch};#{self.repo}"
Rails.logger.error "Install Update: #{update_id}"
- Patch.install(update_id, background, ['RequireRestart','Message']) {
|type, details|
- Rails.logger.info "Message signal received: #{type}, #{details}"
- @messages << {:kind => type, :details => details}
- begin
- dirname = File.dirname(MESSAGES_FILE)
- FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
- f = File.new(MESSAGES_FILE, 'a+')
- f.puts '<br/>' unless File.size(MESSAGES_FILE).zero?
- # TODO: make the message traslatable
- f.puts "#{details}"
- rescue Exception => e
- Rails.logger.error "writing #{MESSAGES_FILE} file failed:
#{e.try(:message)}"
- ensure
- f.try(:close)
- end
- }
+ unless background
+ Patch.install(update_id) #install at once
+ else
+ #inserting job in background
+ Rails.logger.info("Inserting job #{key}")
+ PluginJob.run_async(JOB_PRIO, :Patch, :install, update_id )
+ Delayed::Job.enqueue(PluginJob.new(key),JOB_PRIO)
+ end
end
# find patches using PackageKit
- def self.do_find(what, bg_status = nil)
+ def self.do_find(what)
+ bg_status = nil #not needed due caching
patch_updates = Array.new
- PackageKit.transact("GetUpdates", "none", "Package", bg_status) {
|line1,line2,line3|
- columns = line2.split ";"
- if what == :available || columns[1] == what
- update = Patch.new(:resolvable_id => columns[1],
- :kind => line1,
- :name => columns[0],
- :arch => columns[2],
- :repo => columns[3],
- :summary => line3 )
-
- if what == :available
- # add the update to the list
- patch_updates << update
- else
- # just return this single update
- patch_updates = update
- end
- end
- }
- return patch_updates
- end
-
- def self.subprocess_find(what)
- # open subprocess
- subproc = open_subprocess :find, what
-
- result = nil
-
- while !eof_subprocess?(subproc) do
- begin
- line = read_subprocess subproc
-
- unless line.blank?
- received = Hash.from_xml(line)
-
- # is it a progress or the final list?
- if received.has_key? 'patches'
- Rails.logger.debug "Found #{received['patches'].size} patches"
- # create Patch objects
- result = received['patches'].map{|patch|
Patch.new(patch.symbolize_keys) }
- elsif received.has_key? 'background_status'
- s = received['background_status']
-
- bm.update_progress id(what) do |bs|
- bs.status = s['status']
- bs.progress = s['progress']
- bs.subprogress = s['subprogress']
- end
- elsif received.has_key? 'error'
- return PackageKitError.new(received['error']['description'])
+ PackageKit.lock #locking
+ begin
+ PackageKit.transact("GetUpdates", "none", "Package", bg_status) {
|line1,line2,line3|
+ columns = line2.split ";"
+ if what == :available || columns[1] == what
+ update = Patch.new(:resolvable_id => columns[1],
+ :kind => line1,
+ :name => columns[0],
+ :arch => columns[2],
+ :repo => columns[3],
+ :summary => line3 )
+
+ if what == :available
+ # add the update to the list
+ patch_updates << update
else
- Rails.logger.warn "*** Patch thread: Received unknown input:
#{line}"
+ # just return this single update
+ patch_updates = update
end
end
- rescue Exception => e
- Rails.logger.error "Background thread: Could not evaluate output:
#{line.chomp}, exception: #{e}" # RORSCAN_ITL
- Rails.logger.error "Background thread: Backtrace:
#{e.backtrace.join("\n")}"
-
- # rethrow the exception
- raise e
- end
+ }
+ ensure
+ #unlocking PackageKit
+ PackageKit.unlock
end
-
- result
+ return patch_updates
end
# find patches
# Patch.find(:available)
- # Patch.find(:available, :background => true) - read patches in background
- # the result may the current state (progress) or the actual patch list
- # call this function in a loop until a patch list (or an error) is received
# Patch.find(212)
def self.find(what, opts = {})
- background = opts[:background]
-
- # background reading doesn't work correctly if class reloading is active
- # (static class members are lost between requests)
- if background && !bm.background_enabled?
- Rails.logger.info "Class reloading is active, cannot use background
thread (set config.cache_classes = true)"
- background = false
- end
-
- if background
- proc_id = id(what)
- if bm.process_finished? proc_id
- Rails.logger.debug "Request #{proc_id} is done"
- ret = bm.get_value proc_id
-
- # check for exception
- if ret.is_a? StandardError
- raise ret
- end
-
- return ret
- end
-
- running = bm.get_progress proc_id
- if running
- Rails.logger.debug "Request #{proc_id} is already running:
#{running.inspect}"
- return [running]
- end
-
-
- bm.add_process proc_id
-
- Rails.logger.info "Starting background thread for reading patches..."
- # run the patch query in a separate thread
- Thread.new do
- res = subprocess_find what
-
- # check for exception
- unless res.is_a? StandardError
- Rails.logger.info "*** Patches thread: Found #{res.size} applicable
patches"
- else
- Rails.logger.debug "*** Exception raised: #{res.inspect}"
- end
- bm.finish_process(proc_id, res)
- end
-
- return [ bm.get_progress(proc_id) ]
- else
- return do_find(what)
- end
+ search_id = what == :all ? :available : what
+ YastCache.fetch(self, what) {
+ do_find(search_id)
+ }
end
# install an update, based on the PackageKit
# id ("<name>;<id>;<arch>;<repo>")
- # signal: signal to intercept (usually "Package") (optional)
- # block: block to run on signal (optional)
#
- def self.install(pk_id, background = false, signal_list = nil, &block)
- Rails.logger.debug "Installing #{pk_id}, background:
#{background.inspect}"
-
- # background process doesn't work correctly if class reloading is active
- # (static class members are lost between requests)
- bm = BackgroundManager.instance
- if background && !bm.background_enabled?
- Rails.logger.info "Class reloading is active, cannot use background
thread (set config.cache_classes = true)"
- background = false
- end
- Rails.logger.debug "Background: #{background.inspect}"
-
- if background
- proc_id = bgid(pk_id)
-
- running = bm.get_progress proc_id
- if running
- Rails.logger.debug "Request #{proc_id} is already running:
#{running.inspect}"
- return running
+ def self.install(pk_id)
+ Rails.logger.debug "Installing #{pk_id}"
+ @messages=[]
+ ret = do_install(pk_id,['RequireRestart','Message']) { |type, details|
+ Rails.logger.info "Message signal received: #{type}, #{details}"
+ @messages << {:kind => type, :details => details}
+ begin
+ dirname = File.dirname(MESSAGES_FILE)
+ FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
+ f = File.new(MESSAGES_FILE, 'a+')
+ f.puts '<br/>' unless File.size(MESSAGES_FILE).zero?
+ # TODO: make the message traslatable
+ f.puts "#{details}"
+ rescue Exception => e
+ Rails.logger.error "writing #{MESSAGES_FILE} file failed:
#{e.try(:message)}"
+ ensure
+ f.try(:close)
end
+ }
+ #save installed patches in cache
+ i = Rails.cache.fetch("patch:installed") || []
+ installed = i.dup #cache is frozen
+ installed << pk_id
+ Rails.cache.write("patch:installed", installed)
+
+ YastCache.delete(self,pk_id.split(';')[1])
+ return ret
+ end
- bm.add_process proc_id
-
- Rails.logger.info "Starting background thread for installing patches..."
- # run the patch query in a separate thread
- Thread.new do
- @@package_kit_mutex ||= Mutex.new #TODO move to
packagekit lib
- @@package_kit_mutex.synchronize do
- res = subprocess_install pk_id
-
- # check for exception
- unless res.is_a? StandardError
- Rails.logger.info "*** Patch install thread: Result:
#{res.inspect}"
- else
- Rails.logger.debug "*** Patch install thread: Exception raised:
#{res.inspect}"
- end
- bm.finish_process(proc_id, res)
- end
+ def self.license
+ Dir.glob(File.join(LICENSES_DIR,"*")).reduce([]) do |res,f|
+ if File.file? f
+ res << ({
+ :name => File.basename(f),
+ :text => File.read(f)
+ })
end
-
- return bm.get_progress(proc_id)
- else
- return do_install(pk_id,signal_list,&block)
+ res
end
end
+
def self.do_install(pk_id, signal_list = [], &block)
+ #locking PackageKit for single use
+ PackageKit.lock
+
ok = true
- transaction_iface, packagekit_iface = PackageKit.connect
+ begin
+ transaction_iface, packagekit_iface = PackageKit.connect
- proxy = transaction_iface.object
+ proxy = transaction_iface.object
- if block_given?
- signal_list.each { |signal|
- # set the custom signal handle
- proxy.on_signal(signal.to_s, &block)
- }
- end
-
- proxy.on_signal("Package") do |line1,line2,line3|
- Rails.logger.debug " update package: #{line2}"
- end
-
- error = ''
- dbusloop = PackageKit.dbusloop proxy, error
- dbusloop << proxy.bus
-
- proxy.on_signal("Error") do |u1,u2|
- ok = false
- dbusloop.quit
- end
- if transaction_iface.methods["UpdatePackages"] && # catch mocking
- transaction_iface.methods["UpdatePackages"].params.size == 2 &&
- transaction_iface.methods["UpdatePackages"].params[0][0] ==
"only_trusted"
- #PackageKit of 11.2
- transaction_iface.UpdatePackages(true, #only_trusted
- [pk_id])
- else
- #PackageKit older versions like SLES11
- transaction_iface.UpdatePackages([pk_id])
- end
-
- dbusloop.run
- packagekit_iface.SuggestDaemonQuit
-
- ok &= error.blank?
-
- # bnc#617350, remove signals
- proxy.on_signal "Error"
- proxy.on_signal "Package"
- if block_given?
- signal_list.each { |signal|
- proxy.on_signal signal.to_s
- }
- end
-
- return ok
- end
-
-private
-
- def self.bgid(what)
- "packagekit_install_#{what}"
- end
-
- def self.subprocess_script(type)
- file = case type
- when :find then "list_patches.rb"
- when :install then "install_patches.rb"
- else raise "unsupported type"
- end
- # find the helper script
- script = File.join(RAILS_ROOT, 'vendor/plugins/software/scripts',file) #
RORSCAN_ITL
-
- unless File.exists? script # RORSCAN_ITL
- script = File.join(RAILS_ROOT, '../plugins/software/scripts',file) #
RORSCAN_ITL
-
- unless File.exists? script # RORSCAN_ITL
- raise "File software/scripts/#{file} was not found!" # RORSCAN_ITL
+ if block_given?
+ signal_list.each { |signal|
+ # set the custom signal handle
+ proxy.on_signal(signal.to_s, &block)
+ }
+ end
+
+ proxy.on_signal("Package") do |line1,line2,line3|
+ Rails.logger.debug " update package: #{line2}"
+ end
+
+ error = ''
+ dbusloop = PackageKit.dbusloop proxy, error
+ dbusloop << proxy.bus
+
+ proxy.on_signal("Error") do |u1,u2|
+ ok = false
+ dbusloop.quit
+ end
+ proxy.on_signal("EulaRequired") do
|eula_id,package_id,vendor_name,license_text|
+ #FIXME check if user already agree with license
+ if handle_eula(eula_id,license_text)
+ PackageKit.transact :AcceptEula, [eula_id],nil,nil
+ PackageKit.transact :UpdatePackages, [[pk_id]], nil, nil
+ dbusloop.quit
+ else
+ ok = false
+ dbusloop.quit
+ end
end
+ if transaction_iface.methods["UpdatePackages"] && # catch mocking
+ transaction_iface.methods["UpdatePackages"].params.size == 2 &&
+ transaction_iface.methods["UpdatePackages"].params[0][0] ==
"only_trusted"
+ #PackageKit of 11.2
+ transaction_iface.UpdatePackages(true, #only_trusted
+ [pk_id])
+ else
+ #PackageKit older versions like SLES11
+ transaction_iface.UpdatePackages([pk_id])
+ end
+
+ dbusloop.run
+
+ ok &= error.blank?
+
+ # bnc#617350, remove signals
+ proxy.on_signal "Error"
+ proxy.on_signal "Package"
+ proxy.on_signal "EulaRequired"
+ if block_given?
+ signal_list.each { |signal|
+ proxy.on_signal signal.to_s
+ }
+ end
+ ensure
+ #unlocking PackageKit
+ PackageKit.unlock
end
- Rails.logger.debug "Using #{script} script file" # RORSCAN_ITL
- script
- end
-
- def self.subprocess_command(type,what)
- raise "Invalid parameter" if what.to_s.include?("'") or
what.to_s.include?('\\')
- ret = "cd #{RAILS_ROOT} && RAILS_ENV=#{ENV['RAILS_ENV'] || 'development'}
#{File.join(RAILS_ROOT, 'script/runner')} #{subprocess_script type} "
- ret = ret + "'#{what}'" if type == :install #only install use specified
patches
- return ret
- end
-
- # IO functions moved to separate methods for easy mocking/testing
-
- def self.open_subprocess(type,what)
- IO.popen subprocess_command(type,what)
- end
-
- def self.read_subprocess(subproc)
- subproc.readline
+ return ok
end
- def self.eof_subprocess?(subproc)
- subproc.eof?
+ def self.handle_eula(eula_id,license_text)
+ #TODO check if user already accept exactly same license
+ license_file = File.join(LICENSES_DIR,eula_id)
+ File.open(license_file,"w") { |f| f.write license_text }
+ while File.exists?(license_file)
+ sleep 1 #prevent turning server into radiator
+ end
+ accepted_path = File.join(ACCEPTED_LICENSES_DIR,eula_id)
+ ret = File.exists?(accepted_path) #eula is in accepted dir
+ File.delete accepted_path if ret #require new confirmation every patch
same as zypper
+ ret
end
- def self.subprocess_install(what)
- # open subprocess
- subproc = open_subprocess :install, what
-
- result = nil
-
- while !eof_subprocess?(subproc) do
- begin
- line = read_subprocess subproc
-
- unless line.blank?
- received = Hash.from_xml(line)
-
- # is it a progress or the final list?
- if received.has_key? 'patch_installation'
- Rails.logger.debug "Received background patch installation result:
#{received['patch_installation'].inspect}"
- # create Patch objects
- result = received['patch_installation']['result']
- elsif received.has_key? 'background_status'
- s = received['background_status']
-
- bm.update_progress bgid(what) do |bs|
- bs.status = s['status']
- bs.progress = s['progress']
- bs.subprogress = s['subprogress']
- end
- elsif received.has_key? 'error'
- return PackageKitError.new(received['error']['description'])
- else
- Rails.logger.warn "*** Patch installtion thread: Received unknown
input: #{line}"
- end
- end
- rescue Exception => e
- Rails.logger.error "Background thread: Could not evaluate output:
#{line.chomp}, exception: #{e}" # RORSCAN_ITL
- Rails.logger.error "Background thread: Backtrace:
#{e.backtrace.join("\n")}"
-
- # rethrow the exception
- raise e
- end
- end
-
- result
- end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/models/patches_state.rb
new/www/app/models/patches_state.rb
--- old/www/app/models/patches_state.rb 2010-09-17 16:23:35.000000000 +0200
+++ new/www/app/models/patches_state.rb 2011-04-20 11:40:23.000000000 +0200
@@ -24,7 +24,21 @@
class PatchesState
include GetText
def self.read()
- if File.exist? Patch::MESSAGES_FILE
+ licenses_to_confirm = Dir.glob(File.join(Patch::LICENSES_DIR,"*")).select
{|f| File.file? f}
+ if !licenses_to_confirm.empty?
+ file = licenses_to_confirm[0] #take first one
+ text = File.read file
+ return { :level => "warning",
+ :message_id => "PATCH_EULA",
+ :short_description => _("EULA accept required"),
+ :long_description => _("Package require accept specific EULA
before its installation. Please follow bellowed link."),
+ :details => "",
+ :confirmation_host => "client",
+ :confirmation_link => "/patch_updates/license",
+ :confirmation_label => _("decide"),
+ :confirmation_kind => "link" }
+
+ elsif File.exist? Patch::MESSAGES_FILE
f = File.new(Patch::MESSAGES_FILE, 'r')
messages = f.gets(nil) || ""
@@ -32,13 +46,14 @@
:message_id => "PATCH_MESSAGES",
:short_description => _("Patch installation messages not
confirmed"),
:long_description => messages,
- :details => "",
+ :details => "",
:confirmation_host => "service",
:confirmation_link => "/patch_update/state",
:confirmation_label => _("OK"),
- :confirmation_kind => "button" }
+ :confirmation_kind => "button" }
else
return {}
- end
+ end
end
+
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/app/models/repository.rb
new/www/app/models/repository.rb
--- old/www/app/models/repository.rb 2010-12-13 11:21:27.000000000 +0100
+++ new/www/app/models/repository.rb 2011-04-29 18:23:25.000000000 +0200
@@ -63,22 +63,28 @@
end
def self.find(what)
- repositories = Array.new
-
- PackageKit.transact('GetRepoList', 'none', 'RepoDetail') { |id, name,
enabled|
- Rails.logger.debug "RepoDetail signal received: #{id}, #{name},
#{enabled}"
-
- if what == :all || id == what
- repo = Repository.new(id, name, enabled)
- # read other attributes directly from *.repo file,
- # because PackageKit doesn't have API for that
- repo.read_file
-
- repositories << repo
+ YastCache.fetch(self,what) {
+ PackageKit.lock #locking
+ begin
+ repositories = Array.new
+
+ PackageKit.transact('GetRepoList', 'none', 'RepoDetail') { |id, name,
enabled|
+ Rails.logger.debug "RepoDetail signal received: #{id}, #{name},
#{enabled}"
+
+ if what == :all || id == what
+ repo = Repository.new(id, name, enabled)
+ # read other attributes directly from *.repo file,
+ # because PackageKit doesn't have API for that
+ repo.read_file
+
+ repositories << repo
+ end
+ }
+ ensure
+ PackageKit.unlock #locking
end
+ repositories
}
-
- repositories
end
def self.mtime
@@ -152,29 +158,36 @@
#
def update
# create a new repository if it does not exist yet
- if !Repository.exists?(@id)
- Rails.logger.info "Adding a new repository '#{@id}': #{self.inspect}"
- PackageKit.transact('RepoSetData', [@id, 'add', @url])
- else
- Rails.logger.info "Modifying repository '#{@id}': #{self.inspect}"
- # set url
- PackageKit.transact('RepoSetData', [@id, 'url', @url])
- end
-
- # set enabled flag
- PackageKit.transact('RepoEnable', [@id, @enabled])
+ repo_exist = Repository.exists?(@id)
+ PackageKit.lock #locking
+ begin
+ unless repo_exist
+ Rails.logger.info "Adding a new repository '#{@id}': #{self.inspect}"
+ PackageKit.transact('RepoSetData', [@id, 'add', @url])
+ else
+ Rails.logger.info "Modifying repository '#{@id}': #{self.inspect}"
+ # set url
+ PackageKit.transact('RepoSetData', [@id, 'url', @url])
+ end
- # set priority
- PackageKit.transact('RepoSetData', [@id, 'prio', @priority.to_s])
+ # set enabled flag
+ PackageKit.transact('RepoEnable', [@id, @enabled])
- # set autorefresh
- PackageKit.transact('RepoSetData', [@id, 'refresh', @autorefresh.to_s])
+ # set priority
+ PackageKit.transact('RepoSetData', [@id, 'prio', @priority.to_s])
- # set name
- PackageKit.transact('RepoSetData', [@id, 'name', @name.to_s])
+ # set autorefresh
+ PackageKit.transact('RepoSetData', [@id, 'refresh', @autorefresh.to_s])
- # set keep_package
- PackageKit.transact('RepoSetData', [@id, 'keep', @keep_packages.to_s])
+ # set name
+ PackageKit.transact('RepoSetData', [@id, 'name', @name.to_s])
+
+ # set keep_package
+ PackageKit.transact('RepoSetData', [@id, 'keep', @keep_packages.to_s])
+ ensure
+ PackageKit.unlock #locking
+ end
+ YastCache.reset(self,@id)
end
#
@@ -182,8 +195,16 @@
#
def destroy
return false if @id.blank?
-
- PackageKit.transact('RepoSetData', [@id, 'remove', 'NONE'])
+ ret = false
+ PackageKit.lock #locking
+ begin
+ ret = PackageKit.transact('RepoSetData', [@id, 'remove', 'NONE'])
+ ensure
+ PackageKit.unlock #locking
+ return ret
+ end
+ YastCache.delete(self,@id)
+ return ret
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/config/resources/packages.yml
new/www/config/resources/packages.yml
--- old/www/config/resources/packages.yml 2010-08-27 14:58:55.000000000
+0200
+++ new/www/config/resources/packages.yml 2011-04-11 12:49:05.000000000
+0200
@@ -1,2 +1,9 @@
interface: org.opensuse.yast.system.packages
controller: packages
+
+#cache:
+# enabled: true/false
+# priority: -100..100
+# reload_after: seconds (0 == do not reload)
+cache:
+ enabled: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/config/resources/patches.yml
new/www/config/resources/patches.yml
--- old/www/config/resources/patches.yml 2010-08-27 14:58:55.000000000
+0200
+++ new/www/config/resources/patches.yml 2011-04-19 11:37:20.000000000
+0200
@@ -1,2 +1,11 @@
interface: org.opensuse.yast.system.patches
controller: patches
+
+#cache:
+# enabled: true/false
+# priority: -100..100
+# reload_after: seconds (0 == do not reload)
+cache:
+ enabled: true
+ priority: 20
+ reload_after: 360
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/lib/install_in_progress_exception.rb
new/www/lib/install_in_progress_exception.rb
--- old/www/lib/install_in_progress_exception.rb 2010-08-27
14:58:55.000000000 +0200
+++ new/www/lib/install_in_progress_exception.rb 2011-04-11
12:49:05.000000000 +0200
@@ -20,21 +20,19 @@
#++
class InstallInProgressException < BackendException
- def initialize(count,progress)
- @progress = progress
+ def initialize(count)
@count = count
- end
+ end
- def to_xml
+ def to_xml
xml = Builder::XmlMarkup.new({})
xml.instruct!
xml.error do
xml.type "PACKAGEKIT_INSTALL"
- xml.description "Cannot obtain patches, installation in progress. Remain
#{@count} packages. Status of currently installed package #{@progress.progress}"
- xml.progress @progress
+ xml.description "Cannot obtain patches, installation in progress. Remain
#{@count} packages."
xml.count @count, :type => "integer"
xml.bug false, :type => "boolean"
end
- end
+ end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/lib/license_required_exception.rb
new/www/lib/license_required_exception.rb
--- old/www/lib/license_required_exception.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/www/lib/license_required_exception.rb 2011-04-20 12:45:00.000000000
+0200
@@ -0,0 +1,37 @@
+#--
+# Copyright (c) 2009-2011 Novell, Inc.
+#
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, contact Novell, Inc.
+#
+# To contact Novell about this file by physical or electronic mail,
+# you may find current contact information at www.novell.com
+#++
+
+class LicenseRequiredException < BackendException
+ def initialize
+ super "License confirm required to continue with installation. Please go
to patch module, where you can decide about license confirmation."
+ end
+
+ def to_xml
+ xml = Builder::XmlMarkup.new({})
+ xml.instruct!
+
+ xml.error do
+ xml.type "PACKAGEKIT_LICENSE"
+ xml.description message
+ xml.bug false, :type => "boolean"
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/lib/packagekit.rb new/www/lib/packagekit.rb
--- old/www/lib/packagekit.rb 2011-02-01 10:49:25.000000000 +0100
+++ new/www/lib/packagekit.rb 2011-04-20 12:42:18.000000000 +0200
@@ -51,7 +51,7 @@
private
def self.improve_error(dbus_error)
# check if it is a known error
- if dbus_error.message =~ /org.freedesktop.DBus.Error.([A-Za-z.]*)/
+ if dbus_error.name =~ /org.freedesktop.DBus.Error.([A-Za-z.]*)/
case $1
when "ServiceUnknown"
return ServiceNotAvailable.new('PackageKit')
@@ -99,6 +99,30 @@
end
public
+
+ #
+ # PackageKit.lock
+ #
+ # Lock PackagKit for single use
+ #
+ def self.lock
+ Rails.logger.info "PackageKit locking via DBUS lock"
+ YastService.lock # Only one thread have access to DBUS.
+ # So we have to synchronize with YastService calls
+ # Otherwise DBUS hangs
+ Rails.logger.info "PackageKit locked"
+ end
+
+ #
+ # PackageKit.unlock
+ #
+ # Unlock PackagKit
+ #
+ def self.unlock
+ YastService.unlock
+ Rails.logger.info "PackageKit unlocked via DBUS unlock"
+ end
+
#
# PackageKit.connect
#
@@ -160,15 +184,15 @@
#
def self.transact(method, args, signal = nil, bg_stat = nil, &block)
begin
+ error = ''
+ result = nil
transaction_iface, packagekit_iface = self.connect
proxy = transaction_iface.object
- error = ''
-
# set the custom signal handler if set
proxy.on_signal(signal.to_s, &block) if !signal.blank? && block_given?
-
+ proxy.on_signal("Error") { dbusloop.quit }
if bg_stat
proxy.on_signal("StatusChanged") do |s|
Rails.logger.debug "PackageKit progress: StatusChanged: #{s}"
@@ -182,17 +206,13 @@
bg_stat.subprogress = p2 < 101 ? p2 : -1
end
end
-
dbusloop = self.dbusloop proxy, error
-
dbusloop << proxy.bus
-
# Do the call only when all signal handlers are in place,
# otherwise Finished can arrive early and dbusloop will never
# quit, bnc#561578
# call it after creating the DBus loop (bnc#579001)
result = transaction_iface.send(method.to_sym, *args)
-
# run the main loop, process the incoming signals
dbusloop.run
@@ -203,8 +223,7 @@
proxy.on_signal("StatusChanged")
end
proxy.on_signal(signal.to_s) if !signal.blank? && block_given?
-
- packagekit_iface.SuggestDaemonQuit
+ proxy.on_signal("Error")
raise PackageKitError.new(error) unless error.blank?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/scripts/install_patches.rb
new/www/scripts/install_patches.rb
--- old/www/scripts/install_patches.rb 2010-12-13 11:21:27.000000000 +0100
+++ new/www/scripts/install_patches.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,77 +0,0 @@
-#--
-# Copyright (c) 2009-2010 Novell, Inc.
-#
-# All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, contact Novell, Inc.
-#
-# To contact Novell about this file by physical or electronic mail,
-# you may find current contact information at www.novell.com
-#++
-
-
-# this is a helper script
-#
-# ruby-dbus is NOT thread safe and therefore patches cannot be safely read
-# in a separate thread, workaround is to use a separate process (this script)
-
-# this is an observer class which prints changes in the progress
-# in XML format on stdout
-class ProgressPrinter
- def initialize(prog)
- # watch changes in a progress status object
- prog.add_observer(self)
- end
-
- # this is the callback method
- def update(progress)
- # print the progress in XML format on single line
- puts progress.to_xml.gsub("\n", '')
-
- # print it immediately, flush the output buffer
- $stdout.flush
- end
-end
-
-bs = BackgroundStatus.new
-
-# register a progress printer for the progress object
-ProgressPrinter.new(bs)
-
-pk_id = ARGV[0]
-
-begin
- result = Patch.do_install(pk_id, ['RequireRestart','Message']) { |type,
details|
- Rails.logger.info "** Background process: Message signal received:
#{type}, #{details}"
- begin
- dirname = File.dirname(Patch::MESSAGES_FILE)
- FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
- f = File.new(Patch::MESSAGES_FILE, 'a+')
- f.puts '<br/>' unless File.size(Patch::MESSAGES_FILE).zero?
- # TODO: make the message traslatable
- f.puts "#{details}"
- rescue Exception => e
- Rails.logger.error "writing #{Patch::MESSAGES_FILE} file failed:
#{e.try(:message)}"
- ensure
- f.try(:close)
- end
- }
-
- puts ({'result' => result}).to_xml(:root => "patch_installation", :dasherize
=> false).gsub("\n", '')
-rescue Exception => e
- if e.respond_to? :to_xml
- puts e.to_xml.gsub("\n", '')
- else
- puts PackageKitError.new(e.message).to_xml.gsub("\n", '')
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/scripts/list_patches.rb
new/www/scripts/list_patches.rb
--- old/www/scripts/list_patches.rb 2010-08-27 14:58:55.000000000 +0200
+++ new/www/scripts/list_patches.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,62 +0,0 @@
-#--
-# Copyright (c) 2009-2010 Novell, Inc.
-#
-# All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, contact Novell, Inc.
-#
-# To contact Novell about this file by physical or electronic mail,
-# you may find current contact information at www.novell.com
-#++
-
-
-# this is a helper script
-#
-# ruby-dbus is NOT thread safe and therefore patches cannot be safely read
-# in a separate thread, workaround is to use a separate process (this script)
-
-# this an observer class which prints changes in the progress
-# in XML format on stdout
-class ProgressPrinter
- def initialize(prog)
- # watch changes in a progress status object
- prog.add_observer(self)
- end
-
- # this is the callback method
- def update(progress)
- # print the progress in XML format on single line
- puts progress.to_xml.gsub("\n", '')
-
- # print it immediately, flush the output buffer
- $stdout.flush
- end
-end
-
-bs = BackgroundStatus.new
-
-# register a progress printer for the progress object
-ProgressPrinter.new(bs)
-
-what = :available
-
-begin
- patches = Patch.do_find(what, bs)
- puts patches.to_xml(:root => "patches", :dasherize => false).gsub("\n", '')
-rescue Exception => e
- if e.respond_to? :to_xml
- puts e.to_xml.gsub("\n", '')
- else
- puts PackageKitError.new(e.message).to_xml.gsub("\n", '')
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/test/functional/patches_controller_test.rb
new/www/test/functional/patches_controller_test.rb
--- old/www/test/functional/patches_controller_test.rb 2010-12-13
11:21:27.000000000 +0100
+++ new/www/test/functional/patches_controller_test.rb 2011-04-20
13:07:36.000000000 +0200
@@ -51,7 +51,7 @@
:repo => "openSUSE-11.1-Updates")
Patch.stubs(:mtime).returns(Time.now)
- Patch.stubs(:find).with(:available, {:background => nil}).returns([@p1,
@p2])
+ Patch.stubs(:find).with(:all).returns([@p1, @p2])
Patch.stubs(:find).with('462').returns(@p1)
Patch.stubs(:find).with('wrong_id').returns(nil)
Patch.stubs(:find).with('not_found').returns(nil)
@@ -137,4 +137,12 @@
assert Hash.from_xml(@response.body)["messages"].empty?
end
+ test "license required" do
+ PatchesState.stubs(:read).returns(:message_id => "PATCH_EULA").once
+
+ get :index
+ assert_response 503
+ assert_equal "PACKAGEKIT_LICENSE",
Hash.from_xml(@response.body)["error"]["type"]
+ end
+
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/test/functional/repositories_controller_test.rb
new/www/test/functional/repositories_controller_test.rb
--- old/www/test/functional/repositories_controller_test.rb 2010-08-27
14:58:55.000000000 +0200
+++ new/www/test/functional/repositories_controller_test.rb 2011-04-11
12:49:05.000000000 +0200
@@ -219,58 +219,6 @@
assert_response :missing
end
- # Test cache expiration
- test "cache expired" do
- cached = Time.utc(2010,"jan",1,20,0,0) #=> Fri Jan 01 20:00:00 UTC 2010
- modified = cached + 60 # modified 1 minute after caching
- current_time = modified + 60 # now it's 1 minute after the
modification
- Time.stubs(:now).returns(current_time)
-
-
Rails.cache.expects(:read).with(RepositoriesController::CACHE_ID).returns(cached)
- Repository.expects(:mtime).returns(modified)
-
- # check that the actions are expired
- @controller.expects(:expire_action).with(:action => :index, :format => nil)
-
- Rails.cache.expects(:write).with(RepositoriesController::CACHE_ID,
current_time)
-
- get :index
- end
-
- test "cache still valid" do
- cached = Time.utc(2010,"jan",1,20,0,0) #=> Fri Jan 01 20:00:00 UTC 2010
- modified = cached - 60 # modified 1 minute before caching
- current_time = cached + 60 # now it's 1 minute after caching
the first call
- Time.stubs(:now).returns(current_time)
-
-
Rails.cache.expects(:read).with(RepositoriesController::CACHE_ID).returns(cached)
- Repository.expects(:mtime).returns(modified)
-
- # check that the actions are not expired
- @controller.expects(:expire_action).never
- # do not update the cache time stamp
- Rails.cache.expects(:write).never
-
- get :index
- end
-
- test "not cached yet" do
- cached = nil # not cached yet
- modified = Time.utc(2010,"jan",1,20,0,0) #=> Fri Jan 01 20:00:00 UTC 2010
- current_time = modified + 60 # now it's 1 minute after the
modification
- Time.stubs(:now).returns(current_time)
-
-
Rails.cache.expects(:read).with(RepositoriesController::CACHE_ID).returns(cached)
-
- # check that the actions are not expired
- @controller.expects(:expire_action).never
-
- # just update the cache time stamp
- Rails.cache.expects(:write).with(RepositoriesController::CACHE_ID,
current_time)
-
- get :index
- end
-
# Test validations
test "create with invalid priority" do
Repository.any_instance.expects(:update).never
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/test/unit/packagekit_test.rb
new/www/test/unit/packagekit_test.rb
--- old/www/test/unit/packagekit_test.rb 2010-08-27 14:58:55.000000000
+0200
+++ new/www/test/unit/packagekit_test.rb 2011-04-11 12:49:05.000000000
+0200
@@ -59,7 +59,7 @@
def test_install
@transaction.stubs(:UpdatePackages).returns(true)
- result = Patch.install :id1
+ result = Patch.install "id1"
assert result
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/www/test/unit/patch_test.rb
new/www/test/unit/patch_test.rb
--- old/www/test/unit/patch_test.rb 2010-08-27 14:58:55.000000000 +0200
+++ new/www/test/unit/patch_test.rb 2011-04-11 12:49:05.000000000 +0200
@@ -93,39 +93,6 @@
assert_equal [], patch
end
- SCRIPT_OUTPUT_ERROR = read_test_data('patch_test-script_error.out')
-
- def test_available_patches_background_mode_error
-
- Patch.stubs(:read_subprocess).returns(*SCRIPT_OUTPUT_ERROR)
- # return EOF when all lines are read
-
Patch.stubs(:eof_subprocess?).returns(*(Array.new(SCRIPT_OUTPUT_ERROR.size,
false) << true))
-
- # note: Patch.find(:available, {:background => true})
- # cannot be used here, Threading support in test mode doesn't work :-(
- patches = Patch.subprocess_find(:available)
-
- assert_equal PackageKitError, patches.class
- end
-
- SCRIPT_OUTPUT_OK = read_test_data('patch_test-script_ok.out')
-
- def test_available_patches_background_mode_ok
- Patch.stubs(:read_subprocess).returns(*SCRIPT_OUTPUT_OK)
-
- # return EOF when all lines are read
- Patch.stubs(:eof_subprocess?).returns(*(Array.new(SCRIPT_OUTPUT_OK.size,
false) << true))
-
- # note: Patch.find(:available, {:background => true})
- # cannot be used here, Threading support in test mode doesn't work :-(
- patches = Patch.subprocess_find(:available)
-
- assert_equal 4, patches.size
- assert_equal 1579, patches.first.resolvable_id
- assert_equal 'slessp0-openslp', patches.first.name
- end
-
-
def test_patch_install
rset = PackageKitResultSet.new "Package", :info => :s, :id => :s, :summary
=> :s
rset << [ 'important',
'update-test-affects-package-manager;847;noarch;updates-test', 'update-test:
Test updates for 11.2' ]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]