[SCM] vim-addon-manager packaging branch, master, updated. f871ef948f8fea13e4945343561007711353f3f1

James Vega jamessan at debian.org
Sun Aug 2 21:26:30 UTC 2009


The following commit has been merged in the master branch:
commit f871ef948f8fea13e4945343561007711353f3f1
Author: James Vega <jamessan at debian.org>
Date:   Fri Jul 31 18:47:14 2009 -0400

    Add :unavailable state
    
    When performing an action on an addon, ensure that all of its source
    files exist first.  This prevents us from telling a user we've installed
    an addon when not all of its files were actually available.
    
    Signed-off-by: James Vega <jamessan at debian.org>

diff --git a/src/vim-addons b/src/vim-addons
index c8c3f8d..ca18f31 100755
--- a/src/vim-addons
+++ b/src/vim-addons
@@ -51,6 +51,10 @@ with respect to a user Vim configuration, in one of the following states:
   only some of the files composing the addon are installed under ~/.vim. The
   addon is probably not working for the current user
 
+:unavailable
+  some (or all) of the files composing the addon are missing from the source
+  directory
+
 === COMMANDS
 
 A number of commands can be given to vim-addons to inspect or alter the status
diff --git a/src/vim/addon-manager.rb b/src/vim/addon-manager.rb
index 1ce18e3..86e812f 100644
--- a/src/vim/addon-manager.rb
+++ b/src/vim/addon-manager.rb
@@ -33,7 +33,7 @@ module Vim
 	symlink = lambda do |file|
 	  dest = File.join(@target_dir, file)
 	  dest_dir = File.dirname dest
-	  FileUtils.mkdir_p dest_dir unless File.directory? dest_dir
+	  FileUtils.mkdir_p dest_dir
 	  FileUtils.ln_sf(File.join(base_dir, file), dest)
 	end
 	status = addon.status(@target_dir)
@@ -41,13 +41,17 @@ module Vim
 	when :broken
 	  Vim.info "installing broken addon '#{addon}'"
 	  status.missing_files.each(&symlink)
-          installed_files.concat(status.missing_files.to_a)
+	  installed_files.concat(status.missing_files.to_a)
 	when :not_installed
 	  Vim.info "installing removed addon '#{addon}'"
 	  addon.files.each(&symlink)
-          installed_files.concat(addon.files.to_a)
-        else
-          Vim.info "ignoring '#{addon}' which is neither removed nor broken"
+	  installed_files.concat(addon.files.to_a)
+	when :unavailable
+	  s = "ignoring '#{addon}' which is missing source files"
+	  s << "\n- #{status.missing_files.join "\n- "}" if Vim.verbose?
+	  Vim.warn s
+	else
+	  Vim.info "ignoring '#{addon}' which is neither removed nor broken"
 	end
       end
       rebuild_tags(installed_files)
diff --git a/src/vim/registry.rb b/src/vim/registry.rb
index 663e91c..1fb49bc 100644
--- a/src/vim/registry.rb
+++ b/src/vim/registry.rb
@@ -22,6 +22,8 @@ module Vim
   # - :installed
   # - :broken (missing_files attribute is then used to list not installed
   # files)
+  # - :unavailable (missing_files attribute is then used to list source files
+  # that weren't found)
   #
   AddonStatusStruct = Struct.new(:status, :missing_files)
 
@@ -36,18 +38,26 @@ module Vim
 
     def to_s
       if @disabled
-        'disabled'
+	'disabled'
       else
-        case status
-        when :installed
-            'installed'
-        when :not_installed
-            'removed'
-        when :broken
-            s = 'broken'
-            s << " (missing: #{missing_files.join ', '})" if Vim.verbose?
-            s
-        end
+	case status
+	when :installed
+	  'installed'
+	when :not_installed
+	  'removed'
+	when :broken
+	  s = 'broken'
+	  if Vim.verbose?
+	    s << " (missing: #{missing_files.join ', '})"
+	  end
+	  s
+	when :unavailable
+	  s = 'unavailable'
+	  if Vim.verbose?
+	    s << " (missing source files: #{missing_files.join ', '})"
+	  end
+	  s
+	end
       end
     end
 
@@ -77,35 +87,33 @@ module Vim
     # directory, and the system wide installation directory.
     # A status is a ternary value: :not_installed (the addon is not installed
     # at all), :installed (the addon is completely installed), :broken (the
-    # addon is only partially installed)
+    # addon is only partially installed), :unavailable (source files are
+    # missing)
     #
     def status(target_dir)
-      expected = @files.collect {|f| File.join(target_dir, f)}
-      installed = expected.select do |f|
-        case
-        when (File.exist? f)
-          true
-        #when (File.symlink? f)
-          #(File.readlink f) ==
-          #(File.join @basedir, f.gsub(/^#{Regexp.escape target_dir}\/*/, ''))
-        #when (File.file? f)
-          #true
-        else
-          false
-        end
+      expected_dest = @files.collect {|f| File.join(target_dir, f)}
+      installed = expected_dest.select do |f|
+	File.exist? f
+      end
+      expected_src = @files.collect {|f| File.join(@basedir, f)}
+      available = expected_src.select do |f|
+	File.exist? f
       end
 
       status =
-        if installed.size == expected.size
-          AddonStatus.new :installed
-        elsif installed.size == 0
-          AddonStatus.new :not_installed
-        else
-          missing = expected - installed
-          prefix = /^#{Regexp.escape target_dir}\/+/o
-          missing.collect! {|f| f.gsub(prefix, '')}
-          AddonStatus.new(:broken, missing)
-        end
+	if available.size != expected_src.size
+	  missing = expected_src - available
+	  AddonStatus.new(:unavailable, missing)
+	elsif installed.size == expected_dest.size
+	  AddonStatus.new :installed
+	elsif installed.size == 0
+	  AddonStatus.new :not_installed
+	else
+	  missing = expected - installed
+	  prefix = /^#{Regexp.escape target_dir}\/+/o
+	  missing.collect! {|f| f.gsub(prefix, '')}
+	  AddonStatus.new(:broken, missing)
+	end
 
       status.disabled = is_disabled_in? target_dir
       status

-- 
vim-addon-manager packaging



More information about the pkg-vim-maintainers mailing list