1# -*- coding: utf-8 -*- 2 3# transaction.py 4# Managing the transaction to be passed to RPM. 5# 6# Copyright (C) 2013-2018 Red Hat, Inc. 7# 8# This copyrighted material is made available to anyone wishing to use, 9# modify, copy, or redistribute it subject to the terms and conditions of 10# the GNU General Public License v.2, or (at your option) any later version. 11# This program is distributed in the hope that it will be useful, but WITHOUT 12# ANY WARRANTY expressed or implied, including the implied warranties of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 14# Public License for more details. You should have received a copy of the 15# GNU General Public License along with this program; if not, write to the 16# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the 18# source code or documentation are not subject to the GNU General Public 19# License and may only be used or replicated with the express permission of 20# Red Hat, Inc. 21# 22 23from __future__ import absolute_import 24from __future__ import unicode_literals 25 26import libdnf.transaction 27 28from dnf.i18n import _, C_ 29 30# :api - all action constants are considered an API 31 32# per-package actions - from libdnf 33PKG_DOWNGRADE = libdnf.transaction.TransactionItemAction_DOWNGRADE 34PKG_DOWNGRADED = libdnf.transaction.TransactionItemAction_DOWNGRADED 35PKG_INSTALL = libdnf.transaction.TransactionItemAction_INSTALL 36PKG_OBSOLETE = libdnf.transaction.TransactionItemAction_OBSOLETE 37PKG_OBSOLETED = libdnf.transaction.TransactionItemAction_OBSOLETED 38PKG_REINSTALL = libdnf.transaction.TransactionItemAction_REINSTALL 39PKG_REINSTALLED = libdnf.transaction.TransactionItemAction_REINSTALLED 40PKG_REMOVE = libdnf.transaction.TransactionItemAction_REMOVE 41PKG_UPGRADE = libdnf.transaction.TransactionItemAction_UPGRADE 42PKG_UPGRADED = libdnf.transaction.TransactionItemAction_UPGRADED 43 44# compatibility 45PKG_ERASE = PKG_REMOVE 46 47# per-package actions - additional 48PKG_CLEANUP = 101 49PKG_VERIFY = 102 50PKG_SCRIPTLET = 103 51 52# transaction-wide actions 53TRANS_PREPARATION = 201 54TRANS_POST = 202 55 56 57# packages that appeared on the system 58FORWARD_ACTIONS = [ 59 libdnf.transaction.TransactionItemAction_INSTALL, 60 libdnf.transaction.TransactionItemAction_DOWNGRADE, 61 libdnf.transaction.TransactionItemAction_OBSOLETE, 62 libdnf.transaction.TransactionItemAction_UPGRADE, 63 libdnf.transaction.TransactionItemAction_REINSTALL, 64] 65 66 67# packages that got removed from the system 68BACKWARD_ACTIONS = [ 69 libdnf.transaction.TransactionItemAction_DOWNGRADED, 70 libdnf.transaction.TransactionItemAction_OBSOLETED, 71 libdnf.transaction.TransactionItemAction_UPGRADED, 72 libdnf.transaction.TransactionItemAction_REMOVE, 73# TODO: REINSTALLED may and may not belong here; the same NEVRA is in FORWARD_ACTIONS already 74# libdnf.transaction.TransactionItemAction_REINSTALLED, 75] 76 77 78ACTIONS = { 79 # TRANSLATORS: This is for a single package currently being downgraded. 80 PKG_DOWNGRADE: C_('currently', 'Downgrading'), 81 PKG_DOWNGRADED: _('Cleanup'), 82 # TRANSLATORS: This is for a single package currently being installed. 83 PKG_INSTALL: C_('currently', 'Installing'), 84 PKG_OBSOLETE: _('Obsoleting'), 85 PKG_OBSOLETED: _('Obsoleting'), 86 # TRANSLATORS: This is for a single package currently being reinstalled. 87 PKG_REINSTALL: C_('currently', 'Reinstalling'), 88 PKG_REINSTALLED: _('Cleanup'), 89 # TODO: 'Removing'? 90 PKG_REMOVE: _('Erasing'), 91 # TRANSLATORS: This is for a single package currently being upgraded. 92 PKG_UPGRADE: C_('currently', 'Upgrading'), 93 PKG_UPGRADED: _('Cleanup'), 94 95 PKG_CLEANUP: _('Cleanup'), 96 PKG_VERIFY: _('Verifying'), 97 PKG_SCRIPTLET: _('Running scriptlet'), 98 99 TRANS_PREPARATION: _('Preparing'), 100 # TODO: TRANS_POST 101} 102 103 104# untranslated strings, logging to /var/log/dnf/dnf.rpm.log 105FILE_ACTIONS = { 106 PKG_DOWNGRADE: 'Downgrade', 107 PKG_DOWNGRADED: 'Downgraded', 108 PKG_INSTALL: 'Installed', 109 PKG_OBSOLETE: 'Obsolete', 110 PKG_OBSOLETED: 'Obsoleted', 111 PKG_REINSTALL: 'Reinstall', 112 PKG_REINSTALLED: 'Reinstalled', 113 # TODO: 'Removed'? 114 PKG_REMOVE: 'Erase', 115 PKG_UPGRADE: 'Upgrade', 116 PKG_UPGRADED: 'Upgraded', 117 118 PKG_CLEANUP: 'Cleanup', 119 PKG_VERIFY: 'Verified', 120 PKG_SCRIPTLET: 'Running scriptlet', 121 122 TRANS_PREPARATION: 'Preparing', 123 # TODO: TRANS_POST 124} 125