aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2016-02-17 23:14:38 +0100
committerFathi Boudra <fathi.boudra@linaro.org>2016-02-23 18:22:43 +0200
commitceb991b8edc75ce0b35261a80ce873e00fc42b88 (patch)
treec5ea114a845e0f3b5fa39bd74d45a60a430cf8ca
parentb92b19b6d52749b80209cb8e91b88079506409ee (diff)
hwpack-create: add option to conditionally enable -backports*
While some users might want to use the backports, it should not be the default case. Change-Id: I2f3c718e7ff86812ae0e5b9fc28d53b523662cd0 Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
-rwxr-xr-xlinaro-hwpack-create4
-rw-r--r--linaro_image_tools/hwpack/builder.py6
-rw-r--r--linaro_image_tools/hwpack/packages.py22
3 files changed, 20 insertions, 12 deletions
diff --git a/linaro-hwpack-create b/linaro-hwpack-create
index 7a64429..4c517a3 100755
--- a/linaro-hwpack-create
+++ b/linaro-hwpack-create
@@ -44,13 +44,15 @@ if __name__ == '__main__':
"version than a package that would be otherwise installed. "
"Can be used more than once."))
parser.add_argument("--debug", action="store_true")
+ parser.add_argument("--backports", action="store_true",
+ help="Level the pin priority for the backports repositories.")
args = parser.parse_args()
logger = get_logger(debug=args.debug)
try:
builder = HardwarePackBuilder(args.CONFIG_FILE,
- args.VERSION, args.local_debs)
+ args.VERSION, args.local_debs, args.backports)
except ConfigFileMissing, e:
logger.error(str(e))
sys.exit(1)
diff --git a/linaro_image_tools/hwpack/builder.py b/linaro_image_tools/hwpack/builder.py
index 9be8750..d5fd20b 100644
--- a/linaro_image_tools/hwpack/builder.py
+++ b/linaro_image_tools/hwpack/builder.py
@@ -61,7 +61,8 @@ class ConfigFileMissing(Exception):
class HardwarePackBuilder(object):
- def __init__(self, config_path, version, local_debs, out_name=None):
+ def __init__(self, config_path, version, local_debs, backports=False,
+ out_name=None):
try:
with open(config_path) as fp:
self.config = Config(fp, allow_unset_bootloader=True)
@@ -78,6 +79,7 @@ class HardwarePackBuilder(object):
self.packages = None
self.packages_added_to_hwpack = []
self.out_name = out_name
+ self.backports = backports
def find_fetched_package(self, packages, wanted_package_name):
wanted_package = None
@@ -224,7 +226,7 @@ class HardwarePackBuilder(object):
logger.info("Fetching packages")
fetcher = PackageFetcher(
sources, architecture=architecture,
- prefer_label=LOCAL_ARCHIVE_LABEL)
+ backports=self.backports, prefer_label=LOCAL_ARCHIVE_LABEL)
with fetcher:
with PackageUnpacker() as self.package_unpacker:
fetcher.ignore_packages(self.config.assume_installed)
diff --git a/linaro_image_tools/hwpack/packages.py b/linaro_image_tools/hwpack/packages.py
index 672f995..440236a 100644
--- a/linaro_image_tools/hwpack/packages.py
+++ b/linaro_image_tools/hwpack/packages.py
@@ -478,7 +478,8 @@ class IsolatedAptCache(object):
:type cache: apt.cache.Cache
"""
- def __init__(self, sources, architecture=None, prefer_label=None):
+ def __init__(self, sources, architecture=None, prefer_label=None,
+ backports=False):
"""Create an IsolatedAptCache.
:param sources: a list of sources such that they can be prefixed
@@ -491,6 +492,7 @@ class IsolatedAptCache(object):
self.architecture = architecture
self.tempdir = None
self.prefer_label = prefer_label
+ self.backports = backports
def prepare(self):
"""Prepare the IsolatedAptCache for use.
@@ -551,14 +553,14 @@ class IsolatedAptCache(object):
f.write(
'Apt {\nArchitecture "%s";\n'
'Install-Recommends "true";\n}\n' % self.architecture)
- # level the pin priority for the backports repositories, if required
apt_preferences = os.path.join(
self.tempdir, "etc", "apt", "preferences")
- with open(apt_preferences, 'w') as f:
- f.write(
- 'Package: *\n'
- 'Pin: release a=*-backports\n'
- 'Pin-Priority: 500\n\n')
+ if self.backports:
+ with open(apt_preferences, 'w') as f:
+ f.write(
+ 'Package: *\n'
+ 'Pin: release a=*-backports\n'
+ 'Pin-Priority: 500\n\n')
if self.prefer_label is not None:
with open(apt_preferences, 'a') as f:
f.write(
@@ -622,7 +624,8 @@ class DependencyNotSatisfied(Exception):
class PackageFetcher(object):
"""A class to fetch packages from a defined list of sources."""
- def __init__(self, sources, architecture=None, prefer_label=None):
+ def __init__(self, sources, architecture=None, prefer_label=None,
+ backports=False):
"""Create a PackageFetcher.
Once created a PackageFetcher should have its `prepare` method
@@ -635,7 +638,8 @@ class PackageFetcher(object):
:type architecture: str
"""
self.cache = IsolatedAptCache(
- sources, architecture=architecture, prefer_label=prefer_label)
+ sources, architecture=architecture, prefer_label=prefer_label,
+ backports=backports)
def prepare(self):
"""Prepare the PackageFetcher for use.