Skip to content

Commit

Permalink
New --add-install flag for CLI
Browse files Browse the repository at this point in the history
This flag lets you add arbitrary things to the upgrade transaction.

The string that you pass just gets handed to yum, as if you were doing
'yum install PATTERN'. So you can use globs, groups, or whatever other
crazy junk you like.

If the requested item doesn't exist, a warning will be printed, but
these warnings are not considered fatal.
  • Loading branch information
wgwoods committed Oct 13, 2014
1 parent 652aee6 commit 6341783
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions fedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def setup_downloader(version, instrepo=None, cacheonly=False, repos=[],
log.info("disabled repos: " + " ".join(disabled_repos))
return f

def download_packages(f):
updates = f.build_update_transaction(callback=output.DepsolveCallback(f))
def download_packages(f, add_install=[]):
updates = f.build_update_transaction(callback=output.DepsolveCallback(f),
add_install=add_install)
# check for empty upgrade transaction
if not updates:
print _('Your system is already upgraded!')
Expand Down Expand Up @@ -160,7 +161,7 @@ def isocleanup():
if len(f.pkgSack) == 0:
print("no updates available in configured repos!")
raise SystemExit(1)
pkgs = download_packages(f)
pkgs = download_packages(f, add_install=args.add_install)
# Run a test transaction
probs, rv = transaction_test(pkgs)

Expand Down
3 changes: 3 additions & 0 deletions fedup/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def parse_args(gui=False):
help=_('disable yum plugins by name'))
yumopts.add_argument('--nogpgcheck', action='store_true', default=False,
help=_('disable GPG signature checking'))
yumopts.add_argument('--add-install', metavar='PKG-OR-GROUP',
action='append', dest='add_install', default=[],
help=_('add extra item to be installed during upgrade'))


# === <SOURCE> options ===
Expand Down
19 changes: 17 additions & 2 deletions fedup/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .callback import BaseTsCallback
from .treeinfo import Treeinfo, TreeinfoError
from .conf import Config
from yum.Errors import YumBaseError
from yum.Errors import YumBaseError, InstallError
from yum.parser import varReplace
from yum.constants import TS_REMOVE_STATES, TS_TRUEINSTALL
from yum.misc import gpgme
Expand Down Expand Up @@ -250,10 +250,24 @@ def save_repo_configs():
log.warn("couldn't write repofile for %s: %s", repo.id, str(e))

# NOTE: could raise RepoError if metadata is missing/busted
def build_update_transaction(self, callback=None):
def build_update_transaction(self, callback=None, add_install=[]):
log.info("looking for updates")
self.dsCallback = callback
# get updates for everything on the system
self.update()
# add some extra things to the upgrade transaction
for pat in add_install:
log.info("adding '%s' to upgrade", pat)
try:
tx = self.install(pattern=pat)
except InstallError as e:
log.warn("couldn't add '%s': %s", pat, e)
if len(tx) > 1:
log.info("added %i items for %s: %s", len(tx), pat,
' '.join(t.po.name for t in tx))
elif not tx:
log.warn("nothing added for %s", pat)
# build the actual transaction
(rv, msgs) = self.buildTransaction(unfinished_transactions_check=False)
# NOTE: self.po_with_problems is now a list of (po1, po2, errmsg) tuples
log.info("buildTransaction returned %i", rv)
Expand Down Expand Up @@ -494,6 +508,7 @@ def _GPGKeyCheck(self, info, callback=None):
return True
else:
log.info("no automatic trust for key %s", keyfile)
# XXX TODO: fall back to parent's GPG import callback
return False

def check_keyfile(self, keyfile):
Expand Down

0 comments on commit 6341783

Please sign in to comment.