~paelzer/curtin/bug-1574113-derived-repositories

« back to all changes in this revision

Viewing changes to curtin/util.py

  • Committer: Christian Ehrhardt
  • Date: 2016-07-13 15:33:26 UTC
  • Revision ID: christian.ehrhardt@canonical.com-20160713153326-xbonpilrj9n25hee
translate old curtin apt features to new format

This includes (re-)moving of old curtin code.
All apt related configuration is handled in apt.py now.
In a config that specified old&new content it fails with a proper error
message as they are mutually exclusive (curtin can't decide which one to keep).

Show diffs side-by-side

added added

removed removed

Lines of Context:
491
491
    return False
492
492
 
493
493
 
 
494
def get_installed_packages(target=None):
 
495
    cmd = []
 
496
    if target is not None:
 
497
        cmd = ['chroot', target]
 
498
    cmd.extend(['dpkg-query', '--list'])
 
499
 
 
500
    (out, _) = subp(cmd, capture=True)
 
501
    if isinstance(out, bytes):
 
502
        out = out.decode()
 
503
 
 
504
    pkgs_inst = set()
 
505
    for line in out.splitlines():
 
506
        try:
 
507
            (state, pkg, _) = line.split(None, 2)
 
508
        except ValueError:
 
509
            continue
 
510
        if state.startswith("hi") or state.startswith("ii"):
 
511
            pkgs_inst.add(re.sub(":.*", "", pkg))
 
512
 
 
513
    return pkgs_inst
 
514
 
 
515
 
494
516
def has_pkg_installed(pkg, target=None):
495
517
    chroot = []
496
518
    if target is not None: