[Groonga-commit] groonga/chef-cookbooks at 908a0a6 [master] Use apt-line to guess code name when lsb-release isn't installed

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 24 16:58:54 JST 2014


Kouhei Sutou	2014-01-24 16:58:54 +0900 (Fri, 24 Jan 2014)

  New Revision: 908a0a629a4578bd713ddcdf2ce39a27a224406a
  https://github.com/groonga/chef-cookbooks/commit/908a0a629a4578bd713ddcdf2ce39a27a224406a

  Message:
    Use apt-line to guess code name when lsb-release isn't installed
    
    lsb-release may not be installed in the first chef run.

  Modified files:
    groonga/recipes/repository.rb

  Modified: groonga/recipes/repository.rb (+15 -1)
===================================================================
--- groonga/recipes/repository.rb    2014-01-24 12:30:04 +0900 (f370c89)
+++ groonga/recipes/repository.rb    2014-01-24 16:58:54 +0900 (e3301f9)
@@ -24,12 +24,26 @@ if platform_family?("debian")
   apt_repository "groonga" do
     extend Chef::Mixin::ShellOut
 
+    guess_code_name = lambda do
+      ::File.open("/etc/apt/sources.list") do |file|
+        file.each_line do |line|
+          case line
+          when /\Adeb http/
+            deb, url, code_name, *comopnents = line.split
+            code_name == "unstable" if code_name == "sid"
+            return code_name
+          end
+        end
+      end
+      nil
+    end
+
     platform = node.platform
     apt_policy = shell_out!("apt-cache", "policy").stdout
     if /(?:[an]=)(?:unstable|sid),/ =~ apt_policy
       code_name = "unstable"
     else
-      code_name = shell_out!("lsb_release", "--short", "--codename").stdout.strip
+      code_name = node.lsb["codename"] || guess_code_name.call
     end
 
     case platform
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index