Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for -force-components flag #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ The following parameters are available in the `aptly::mirror` defined type:
* [`filter_with_deps`](#-aptly--mirror--filter_with_deps)
* [`environment`](#-aptly--mirror--environment)
* [`keyring`](#-aptly--mirror--keyring)
* [`force_components`](#-aptly--mirror--force_components)

##### <a name="-aptly--mirror--location"></a>`location`

Expand Down Expand Up @@ -298,6 +299,14 @@ path to the keyring used by aptly

Default value: `'/etc/apt/trusted.gpg'`

##### <a name="-aptly--mirror--force_components"></a>`force_components`

Data type: `Boolean`

Boolean to control whether Aptly should force download of components.

Default value: `false`

### <a name="aptly--repo"></a>`aptly::repo`

aptly::repo
Expand Down
10 changes: 9 additions & 1 deletion manifests/mirror.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# @param filter_with_deps Boolean to control whether when filtering to include dependencies of matching packages as well
# @param environment Optional environment variables to pass to the exec. Example: ['http_proxy=http://127.0.0.2:3128']
# @param keyring path to the keyring used by aptly
# @param force_components Boolean to control whether Aptly should force download of components.
#
define aptly::mirror (
String $location,
Expand All @@ -33,6 +34,7 @@
Boolean $with_udebs = false,
Boolean $filter_with_deps = false,
Array $environment = [],
Boolean $force_components = false,
) {
include aptly

Expand Down Expand Up @@ -106,8 +108,14 @@
]
}

if $force_components {
$force_components_arg = ' -force-components'
} else {
$force_components_arg = ''
}

exec { "aptly_mirror_create-${title}":
command => "${aptly_cmd} create ${architectures_arg} -with-sources=${with_sources} -with-udebs=${with_udebs}${filter_arg}${filter_with_deps_arg} ${title} ${location} ${release}${components_arg}",
command => "${aptly_cmd} create ${architectures_arg} -with-sources=${with_sources} -with-udebs=${with_udebs}${filter_arg}${filter_with_deps_arg}${force_components_arg} ${title} ${location} ${release}${components_arg}",
unless => "${aptly_cmd} show ${title} >/dev/null",
user => $aptly::user,
require => $exec_aptly_mirror_create_require,
Expand Down
22 changes: 22 additions & 0 deletions spec/defines/mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,27 @@ class { 'aptly':
}
end
end

describe '#force_components' do
context 'with boolean true' do
let(:params) do
{
location: 'http://repo.example.com',
key: {
id: 'ABC123',
server: 'keyserver.ubuntu.com'
},
force_components: true,
release: 'precise'
}
end

it {
is_expected.to contain_exec('aptly_mirror_create-example').with_command(
%r{/usr/bin/aptly -config /etc/aptly.conf mirror create -with-sources=false -with-udebs=false -force-components example http://repo.example.com precise}
)
}
end
end
end
end