Implement pinning options for extra repo as map object for Docker tests
Change-Id: I8a8ff7f6b8201b5b8e5c5580d52c653e7bada9c6
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 18838b1..1f96449 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -924,15 +924,18 @@
configYaml = '''
---
aprConfD: |-
- APT::Get::AllowUnauthenticated 'true';
+ APT::Get::AllowUnauthenticated 'true';
repo:
- mcp_saltstack:
- source: "deb [arch=amd64] http://mirror.mirantis.com/nightly/saltstack-2017.7/xenial xenial main"
- pinning: |-
- Package: libsodium18
- Pin: release o=SaltStack
- Pin-Priority: 50
- repo_key: "http://mirror.mirantis.com/public.gpg"
+ mcp_saltstack:
+ source: "deb [arch=amd64] http://mirror.mirantis.com/nightly/saltstack-2017.7/xenial xenial main"
+ pin:
+ - package: "libsodium18"
+ pin: "release o=SaltStack"
+ priority: 50
+ - package: "*"
+ pin: "release o=SaltStack"
+ priority: "1100"
+ repo_key: "http://mirror.mirantis.com/public.gpg"
'''
*
*/
@@ -948,7 +951,21 @@
key = config['repo'][repo]['repo_key']
sh("wget -O - '${key}' | apt-key add -")
}
- // TODO implement pining
+ if (config['repo'][repo]['pin']) {
+ def repoPins = []
+ for (Map pin in config['repo'][repo]['pin']) {
+ repoPins.add("Package: ${pin['package']}")
+ repoPins.add("Pin: ${pin['pin']}")
+ repoPins.add("Pin-Priority: ${pin['priority']}")
+ }
+ if (repoPins) {
+ repoPins.add(0, "### Extra ${repo} repo pin start ###")
+ repoPins.add("### Extra ${repo} repo pin end ###")
+ repoPinning = repoPins.join('\n')
+ warningMsg("Adding pinning \n${repoPinning}\n => /etc/apt/preferences.d/${repo}")
+ sh("echo '${repoPinning}' > /etc/apt/preferences.d/${repo}")
+ }
+ }
}
}
if (config.get('aprConfD', false)) {
diff --git a/src/com/mirantis/mk/SaltModelTesting.groovy b/src/com/mirantis/mk/SaltModelTesting.groovy
index 7f298f2..3e40b0f 100644
--- a/src/com/mirantis/mk/SaltModelTesting.groovy
+++ b/src/com/mirantis/mk/SaltModelTesting.groovy
@@ -70,14 +70,13 @@
repo:
mcp_saltstack:
source: "deb [arch=amd64] http://mirror.mirantis.com/${distribRevision}/saltstack-2017.7/xenial xenial main"
- pinning: |-
- Package: libsodium18
- Pin: release o=SaltStack
- Pin-Priority: 50
-
- Package: *
- Pin: release o=SaltStack
- Pin-Priority: 1100
+ pin:
+ - package: "libsodium18"
+ pin: "release o=SaltStack"
+ priority: 50
+ - package: "*"
+ pin: "release o=SaltStack"
+ priority: "1100"
mcp_extra:
source: "${extraRepoSource}"
mcp_saltformulas:
@@ -109,6 +108,7 @@
echo "Installing extra-deb dependencies inside docker:"
echo > /etc/apt/sources.list
rm -vf /etc/apt/sources.list.d/* || true
+ rm -vf /etc/apt/preferences.d/* || true
""")
common.debianExtraRepos(extraReposYaml)
sh('''#!/bin/bash -xe