~smoser/curtin/trunk.use-smtar

« back to all changes in this revision

Viewing changes to curtin/commands/curthooks.py

  • Committer: Scott Moser
  • Date: 2015-10-02 19:59:11 UTC
  • mfrom: (269.1.11 trunk.dist-upgrade)
  • Revision ID: smoser@ubuntu.com-20151002195911-om9vrzt0uqcnak4b
add 'system-upgrade' command

The intent of this is to be runnable easily as 'curtin system-upgrade'
We can expose this from a config option and run it in curthooks also.

One such reason for this is shown in bug 1481992.
upgrading a system is often times unfortunately more complex than
'apt-get dist-upgrade'.

And the goal would be to make this run the appropriate system upgrade
command for the os in target (yum update for example).

Also enabled here is running system-upgrade in the target via
config.  Example:

  system_upgrade:
     enabled: True

Show diffs side-by-side

added added

removed removed

Lines of Context:
610
610
        util.install_packages(needed_packages, target=target)
611
611
 
612
612
 
 
613
def system_upgrade(cfg, target):
 
614
    """run system-upgrade (apt-get dist-upgrade) or other in target.
 
615
 
 
616
    config:
 
617
      system_upgrade:
 
618
        enabled: False
 
619
 
 
620
    """
 
621
    mycfg = {'system_upgrade': {'enabled': False}}
 
622
    config.merge_config(mycfg, cfg)
 
623
    mycfg = mycfg.get('system_upgrade')
 
624
    if not isinstance(mycfg, dict):
 
625
        LOG.debug("system_upgrade disabled by config. entry not a dict.")
 
626
        return
 
627
 
 
628
    if not config.value_as_boolean(mycfg.get('enabled', True)):
 
629
        LOG.debug("system_upgrade disabled by config.")
 
630
        return
 
631
 
 
632
    util.system_upgrade(target=target)
 
633
 
 
634
 
613
635
def curthooks(args):
614
636
    state = util.load_command_environment()
615
637
 
647
669
 
648
670
    install_missing_packages(cfg, target)
649
671
 
 
672
    system_upgrade(cfg, target)
 
673
 
650
674
    # If a crypttab file was created by block_meta than it needs to be copied
651
675
    # onto the target system, and update_initramfs() needs to be run, so that
652
676
    # the cryptsetup hooks are properly configured on the installed system and