Add optional architecture qualifier to apt-sources
authorJoe O'Pecko <joe.opecko@sojern.com>
Wed, 29 May 2013 22:52:32 +0000 (15:52 -0700)
committerJoe O'Pecko <joe.opecko@sojern.com>
Sun, 2 Jun 2013 18:55:36 +0000 (11:55 -0700)
manifests/source.pp
spec/defines/source_spec.rb
templates/source.list.erb

index a859174a1aaef9296a74bc8ec8c6acd51d096f1a..64461ee57abb36d827bcfc770829a9d13d456cc8 100644 (file)
@@ -12,7 +12,8 @@ define apt::source(
   $key_server        = 'keyserver.ubuntu.com',
   $key_content       = false,
   $key_source        = false,
-  $pin               = false
+  $pin               = false,
+  $architecture      = undef
 ) {
 
   include apt::params
index 0f37f6367bcbd761d966fe448caf18ea9dd71163..884194e9f1e3b56119b50be8708b918af57a8f0d 100644 (file)
@@ -48,6 +48,9 @@ describe 'apt::source', :type => :define do
     },
     {
       :release            => 'custom',
+    },
+    {
+      :architecture       => 'amd64',
     }
   ].each do |param_set|
     describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
@@ -69,9 +72,13 @@ describe 'apt::source', :type => :define do
 
       let :content do
         content = "# #{title}"
-        content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+        if param_hash[:architecture]
+          arch = "[arch=#{param_hash[:architecture]}]"
+        end
+        content << "\ndeb #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+
         if param_hash[:include_src]
-          content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+          content << "deb-src #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
         end
         content
       end
index 65764b2612cac71780f8cbef50cb2b2d9faaf9d6..845b8ae161726ade3f617868362dfc9da975fec4 100644 (file)
@@ -1,5 +1,5 @@
 # <%= @name %>
-deb <%= @location %> <%= @release_real %> <%= @repos %>
+deb <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %>
 <%- if @include_src then -%>
-deb-src <%= @location %> <%= @release_real %> <%= @repos %>
+deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %>
 <%- end -%>