kiwi-el8/kiwi/system_update_task.py
Marcus Schäfer 40e6308aa9 Port application from python 2.7 to 3.4
For new applications like this kiwi version and its use cases
it is better to base it on a more recent python version
2016-02-17 22:38:38 +01:00

97 lines
2.9 KiB
Python

# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
#
# This file is part of kiwi.
#
# kiwi is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# kiwi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
"""
usage: kiwi system update -h | --help
kiwi system update --root=<directory>
[--add-package=<name>...]
[--delete-package=<name>...]
kiwi system update help
commands:
update
update root system with latest repository updates
and optionally allow to add or delete packages. the options
to add or delete packages can be used multiple times
update help
show manual page for update command
options:
--root=<directory>
the path to the new root directory of the system
--add-package=<name>
install the given package name
--delete-package=<name>
delete the given package name
"""
# project
from .cli_task import CliTask
from .privileges import Privileges
from .help import Help
from .system import System
from .logger import log
class SystemUpdateTask(CliTask):
"""
Implements update and maintenance of root systems
"""
def process(self):
self.manual = Help()
if self.__help():
return
Privileges.check_for_root_permissions()
self.load_xml_description(
self.command_args['--root']
)
package_requests = False
if self.command_args['--add-package']:
package_requests = True
if self.command_args['--delete-package']:
package_requests = True
log.info('Updating system')
self.system = System(
self.xml_state,
self.command_args['--root'],
allow_existing=True
)
manager = self.system.setup_repositories()
if not package_requests:
self.system.update_system(manager)
else:
if self.command_args['--add-package']:
self.system.install_packages(
manager, self.command_args['--add-package']
)
if self.command_args['--delete-package']:
self.system.delete_packages(
manager, self.command_args['--delete-package']
)
def __help(self):
if self.command_args['help']:
self.manual.show('kiwi::system::update')
else:
return False
return self.manual