def transaction_test(pkgs): print _("testing upgrade transaction") pkgfiles = set(po.localPkg() for po in pkgs) fu = RPMUpgrade() probs = fu.setup_transaction(pkgfiles=pkgfiles, check_fatal=False) rv = fu.test_transaction(callback=output.TransactionCallback(numpkgs=len(pkgfiles))) return (probs, rv)
def transaction_test(pkgs): print _("testing upgrade transaction") pkgfiles = set(po.localPkg() for po in pkgs) fu = RPMUpgrade() probs = fu.setup_transaction(pkgfiles=pkgfiles, check_fatal=False) rv = fu.test_transaction(callback=output.TransactionCallback( numpkgs=len(pkgfiles))) return (probs, rv)
def download_boot_images(self, arch=None): # helper function to grab and checksum image files listed in .treeinfo def grab_and_check(imgarch, imgtype, outpath): relpath = self.treeinfo.get_image(imgarch, imgtype) log.debug("grabbing %s %s", imgarch, imgtype) log.info("downloading %s to %s", relpath, outpath) if self.treeinfo.checkfile(outpath, relpath): log.debug("file already exists and checksum OK") return outpath def checkfile(cb): log.debug("checking %s", relpath) if not self.treeinfo.checkfile(cb.filename, relpath): log.info("checksum doesn't match - retrying") raise yum.URLGrabError(-1) return self.instrepo.grab.urlgrab(relpath, outpath, checkfunc=checkfile, reget=None, copy_local=True) # download the images try: if not arch: arch = self.treeinfo.get('general', 'arch') kernel = grab_and_check(arch, 'kernel', kernelpath) # cache the initrd somewhere so we don't have to fetch it again # if it gets modified later. cacheinitrd = os.path.join(cachedir, os.path.basename(initrdpath)) initrd = grab_and_check(arch, 'upgrade', cacheinitrd) # copy the downloaded initrd to the target path copy2(initrd, initrdpath) initrd = initrdpath except TreeinfoError as e: raise YumBaseError(_("invalid data in .treeinfo: %s") % str(e)) except yum.URLGrabError as e: err = e.strerror if e.errno == 256: err += "\n" + _("Last error was: %s") % e.errors[-1][1] raise YumBaseError(_("couldn't get boot images: %s") % err) except KeyboardInterrupt: # if an IOError occurs while writing the file to disk, F17 # urlgrabber actually raises *KeyboardInterrupt* for some reason. # But urlgrabber.__version__ hasn't been changed since F12, so: if not hasattr(yum.urlgrabber.grabber, 'exception2msg'): # <=F17 raise KeyboardInterrupt(_("or possible error writing file")) else: # The exception actually was a KeyBoardInterrupt, re-raise it raise # Save kernel/initrd info so we can clean it up later mkdir_p(os.path.dirname(upgradeconf)) with Config(upgradeconf) as conf: conf.set("boot", "kernel", kernel) conf.set("boot", "initrd", initrd) return kernel, initrd
def isofile(arg): if not os.path.exists(arg): raise argparse.ArgumentTypeError(_("File not found: %s") % arg) if not os.path.isfile(arg): raise argparse.ArgumentTypeError(_("Not a regular file: %s") % arg) if not fedup.media.isiso(arg): raise argparse.ArgumentTypeError(_("Not an ISO 9660 image: %s") % arg) if any(arg.startswith(d.mnt) for d in fedup.media.removable()): raise argparse.ArgumentTypeError(_("ISO image on removable media\n" "Sorry, but this isn't supported yet.\n" "Copy the image to your hard drive or burn it to a disk.")) return arg
def download_packages(f): updates = f.build_update_transaction(callback=output.DepsolveCallback(f)) # check for empty upgrade transaction if not updates: print _('Your system is already upgraded!') print _('Finished. Nothing to do.') raise SystemExit(0) # clean out any unneeded packages from the cache f.clean_cache(keepfiles=(p.localPkg() for p in updates)) # download packages f.download_packages(updates, callback=output.DownloadCallback()) return updates
def setup_downloader(version, instrepo=None, cacheonly=False, repos=[]): log.debug("setup_downloader(version=%s, repos=%s)", version, repos) f = FedupDownloader(version=version, cacheonly=cacheonly) f.instrepoid = instrepo repo_cb = output.RepoCallback() repo_prog = output.RepoProgress(fo=sys.stderr) disabled_repos = f.setup_repos(callback=repo_cb, progressbar=repo_prog, repos=repos) disabled_repos = filter(lambda id: id != f.instrepoid, disabled_repos) if disabled_repos: print _("No upgrade available for the following repos") + ": " + \ " ".join(disabled_repos) log.info("disabled repos: " + " ".join(disabled_repos)) return f
def device_or_mnt(arg): if arg == 'auto': media = fedup.media.find() else: media = [m for m in fedup.media.find() if arg in (m.dev, m.mnt)] if len(media) == 1: return media.pop() if not media: msg = _("no install media found - please mount install media first") if arg != 'auto': msg = "%s: %s" % (arg, msg) else: devs = ", ".join(m.dev for m in media) msg = _("multiple devices found. please choose one of (%s)") % devs raise argparse.ArgumentTypeError(msg)
def download_packages(f): updates = f.build_update_transaction(callback=output.DepsolveCallback(f)) # check for empty upgrade transaction if not updates: print _('Your system is already upgraded!') print _('Finished. Nothing to do.') raise SystemExit(0) # print dependency problems before we start the upgrade transprobs = f.describe_transaction_problems() if transprobs: print "WARNING: potential problems with upgrade" for p in transprobs: print " " + p # clean out any unneeded packages from the cache f.clean_cache(keepfiles=(p.localPkg() for p in updates)) # download packages f.download_packages(updates, callback=output.DownloadCallback()) return updates
def download_boot_images(self, arch=None): # helper function to grab and checksum image files listed in .treeinfo def grab_and_check(imgarch, imgtype, outpath): relpath = self.treeinfo.get_image(imgarch, imgtype) log.debug("grabbing %s %s", imgarch, imgtype) log.info("downloading %s to %s", relpath, outpath) if self.treeinfo.checkfile(outpath, relpath): log.debug("file already exists and checksum OK") return outpath def checkfile(cb): log.debug("checking %s", relpath) if not self.treeinfo.checkfile(cb.filename, relpath): log.info("checksum doesn't match - retrying") raise yum.URLGrabError(-1) return self.instrepo.grab.urlgrab(relpath, outpath, checkfunc=checkfile, reget=None, copy_local=True) # download the images try: if not arch: arch = self.treeinfo.get('general', 'arch') kernel = grab_and_check(arch, 'kernel', kernelpath) initrd = grab_and_check(arch, 'upgrade', initrdpath) except TreeinfoError as e: raise YumBaseError(_("invalid data in .treeinfo: %s") % str(e)) except yum.URLGrabError as e: f = os.path.basename(self.failstate.lasturl) if e.errno >= 256: err = str(self.failstate.lastexc) else: err = str(e) raise YumBaseError(_("couldn't get %s:\n %s") % (f, err)) # Save kernel/initrd info so we can clean it up later mkdir_p(os.path.dirname(upgradeconf)) with Config(upgradeconf) as conf: conf.set("boot", "kernel", kernel) conf.set("boot", "initrd", initrd) return kernel, initrd
def download_packages(f): updates = f.build_update_transaction(callback=output.DepsolveCallback(f)) # check for empty upgrade transaction if not updates: print _('Your system is already upgraded!') print _('Finished. Nothing to do.') raise SystemExit(0) # print dependency problems before we start the upgrade # TODO: let users skip this with --force transprobs = f.describe_transaction_problems() if transprobs: print "WARNING: potential problems with upgrade" for p in transprobs: print " " + p # clean out any unneeded packages from the cache f.clean_cache(keepfiles=(p.localPkg() for p in updates)) # download packages f.download_packages(updates, callback=output.DownloadCallback()) return updates
def VERSION(arg): if arg.lower() == 'rawhide': return 'rawhide' distro, version, id = platform.linux_distribution() version = int(version) if int(arg) >= version: return arg else: msg = _("version must be greater than %i") % version raise argparse.ArgumentTypeError(msg)
def modify_bootloader(kernel, initrd): log.info("adding new boot entry") args = ["upgrade", "systemd.unit=system-upgrade.target"] if not is_selinux_enabled(): args.append("selinux=0") else: # BLERG. SELinux enforcing will cause problems if the new policy # disallows something that the previous system did differently. # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=896010 args.append("enforcing=0") boot.add_entry(kernel, initrd, banner=_("System Upgrade"), kargs=args)
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!') print _('Finished. Nothing to do.') raise SystemExit(0) # print dependency problems before we start the upgrade # TODO: let users skip this with --force # FIXME: print these after download finishes transprobs = f.describe_transaction_problems() if transprobs: print "WARNING: potential problems with upgrade" for p in transprobs: print " " + p # clean out any unneeded packages from the cache f.clean_cache(keepfiles=(p.localPkg() for p in updates)) # TODO: check disk space > sum(p.size for p in updates) # download packages f.download_packages(updates, callback=output.DownloadCallback()) return updates
def setup_downloader(version, instrepo=None, cacheonly=False, repos=[], enable_plugins=[], disable_plugins=[]): log.debug("setup_downloader(version=%s, repos=%s)", version, repos) f = UpgradeDownloader(version=version, cacheonly=cacheonly) f.preconf.enabled_plugins += enable_plugins f.preconf.disabled_plugins += disable_plugins f.instrepoid = instrepo repo_cb = output.RepoCallback() repo_prog = output.RepoProgress(fo=sys.stdout) multi_prog = output.RepoMultiProgress(fo=sys.stdout) disabled_repos = f.setup_repos(callback=repo_cb, progressbar=repo_prog, multi_progressbar=multi_prog, repos=repos) disabled_repos = filter(lambda id: id != f.instrepoid, disabled_repos) if disabled_repos: print _("No upgrade available for the following repos") + ": " + \ " ".join(disabled_repos) log.info("disabled repos: " + " ".join(disabled_repos)) return f
def device_setup(args): # treat --device like --repo REPO=file://$MOUNTPOINT if args.device: args.repos.append(('add', 'fedupdevice=file://%s' % args.device.mnt)) args.instrepo = 'fedupdevice' elif args.iso: try: args.device = fedup.media.loopmount(args.iso) except fedup.media.CalledProcessError as e: log.info("mount failure: %s", e.output) message('--iso: '+_('Unable to open %s') % args.iso) raise SystemExit(2) else: args.repos.append(('add', 'fedupiso=file://%s' % args.device.mnt)) args.instrepo = 'fedupiso'
def add_install(self, path, key=None, upgrade=False): log.debug('add_install(%s, %s, upgrade=%s)', path, key, upgrade) if key is None: key = path fileobj = open(path) retval, header = self.hdrFromFdno(fileobj) if retval != rpm.RPMRC_OK: raise rpm.error("error reading package header") if not self.addInstall(header, key, upgrade): raise rpm.error("adding package to transaction failed") fileobj.close() def __del__(self): self.closeDB() probtypes = { rpm.RPMPROB_NEW_FILE_CONFLICT : _('file conflicts'), rpm.RPMPROB_FILE_CONFLICT : _('file conflicts'), rpm.RPMPROB_OLDPACKAGE: _('older package(s)'), rpm.RPMPROB_DISKSPACE: _('insufficient disk space'), rpm.RPMPROB_DISKNODES: _('insufficient disk inodes'), rpm.RPMPROB_CONFLICT: _('package conflicts'), rpm.RPMPROB_PKG_INSTALLED: _('package already installed'), rpm.RPMPROB_REQUIRES: _('required package'), rpm.RPMPROB_BADARCH: _('package for incorrect arch'), rpm.RPMPROB_BADOS: _('package for incorrect os'), } # --- stuff for doing useful summaries of big sets of problems class ProblemSummary(object): def __init__(self, probtype, problems):
def format_details(self): return [_("%s needs %s more free space") % (mnt, hrsize(size)) for (mnt,size) in self.details.iteritems()]
def main(args): if args.clean: do_cleanup(args) return if args.device or args.iso: mnt = device_setup(args) if args.iso: if not mnt: message('--iso: ' + _('Unable to open %s') % args.iso) raise SystemExit(2) log.debug("iso is %s", os.path.realpath(args.iso)) def isocleanup(): log.debug("unmounting %s", args.device.mnt) media.umount(args.device.mnt) os.rmdir(args.device.mnt) atexit.register(isocleanup) # Get our packages set up where we can use 'em print _("setting up repos...") f = setup_downloader(version=args.network, cacheonly=args.cacheonly, instrepo=args.instrepo, repos=args.repos, enable_plugins=args.enable_plugins, disable_plugins=args.disable_plugins) if args.nogpgcheck: f._override_sigchecks = True if args.expire_cache: print "expiring cache files" f.cleanExpireCache() return if args.clean_metadata: print "cleaning metadata" f.cleanMetadata() return # TODO: error msg generation should be shared between CLI and GUI if args.skipkernel: message("skipping kernel/initrd download") elif f.instrepoid is None or f.instrepoid in f.disabled_repos: print _("Error: can't get boot images.") if args.instrepo: print _("The '%s' repo was rejected by yum as invalid." ) % args.instrepo if args.iso: print _("The given ISO probably isn't an install DVD image.") elif args.device: print _("The media doesn't contain a valid install DVD image.") else: print _("The installation repo isn't currently available.") print _("Try again later, or specify a repo using --instrepo.") raise SystemExit(1) else: print _("getting boot images...") kernel, initrd = f.download_boot_images() # TODO: force arch? if args.skippkgs: message("skipping package download") else: print _("setting up update...") if len(f.pkgSack) == 0: print("no updates available in configured repos!") raise SystemExit(1) pkgs = download_packages(f) # Run a test transaction probs, rv = transaction_test(pkgs) # And prepare for upgrade # TODO: use polkit to get root privs for these things print _("setting up system for upgrade") if not args.skippkgs: prep_upgrade(pkgs) if not args.skipbootloader: if args.skipkernel: print "warning: --skipkernel without --skipbootloader" print "using default paths: %s %s" % (kernelpath, initrdpath) kernel = kernelpath initrd = initrdpath prep_boot(kernel, initrd) if args.device: setup_media_mount(args.device) if args.reboot: reboot() else: print _('Finished. Reboot to start upgrade.') if args.skippkgs: return # --- Here's where we summarize potential problems. --- # list packages without updates, if any missing = sorted(f.find_packages_without_updates(), key=lambda p: p.envra) if missing: message(_('Packages without updates:')) for p in missing: message(" %s" % p) if not any(p.name in f.conf.kernelpkgnames for p in pkgs): message(_('WARNING: no new kernel will be installed during upgrade')) # warn if the "important" repos are disabled if f.disabled_repos: # NOTE: I hate having a hardcoded list of Important Repos here. # This information should be provided by the system, somehow.. important = ("fedora", "updates") if any(i in f.disabled_repos for i in important): msg = _("WARNING: Some important repos could not be contacted: %s") else: msg = _("NOTE: Some repos could not be contacted: %s") print msg % ", ".join(f.disabled_repos) print _( "If you start the upgrade now, packages from these repos will not be installed." ) # warn about broken dependencies etc. if probs: print print _("WARNING: problems were encountered during transaction test:") for s in probs.summaries: print " " + s.desc for line in s.format_details(): print " " + line print _("Continue with the upgrade at your own risk.")
if probs: print print _("WARNING: problems were encountered during transaction test:") for s in probs.summaries: print " " + s.desc for line in s.format_details(): print " " + line print _("Continue with the upgrade at your own risk.") if __name__ == '__main__': args = parse_args() # TODO: use polkit to get privs for modifying bootloader stuff instead if os.getuid() != 0: print _("you must be root to run this program.") raise SystemExit(1) # set up logging if args.debuglog: logutils.debuglog(args.debuglog) logutils.consolelog(level=args.loglevel) log.info("%s %s starting at %s", sys.argv[0], fedupversion, time.asctime()) try: exittype = "cleanly" main(args) except KeyboardInterrupt as e: print log.info("exiting on keyboard interrupt") if e.message:
def __init__(self, tty=sys.stderr): DownloadCallbackBase.__init__(self) self.bar = SimpleProgress(10, tty=tty, prefix=_("verify local files"))
def parse_args(gui=False): p = argparse.ArgumentParser( description=_('Prepare system for upgrade.'), # Translators: This is the CLI's "usage:" string usage=_('%(prog)s <SOURCE> [options]'), ) # === basic options === p.add_argument('-v', '--verbose', action='store_const', dest='loglevel', const=logging.INFO, help=_('print more info')) p.add_argument('-d', '--debug', action='store_const', dest='loglevel', const=logging.DEBUG, help=_('print lots of debugging info')) p.set_defaults(loglevel=logging.WARNING) p.add_argument('--debuglog', default='/var/log/fedup.log', help=_('write lots of debugging output to the given file')) p.add_argument('--reboot', action='store_true', default=False, help=_('automatically reboot to start the upgrade when ready')) # === hidden options. FOR DEBUGGING ONLY. === p.add_argument('--skippkgs', action='store_true', default=False, help=argparse.SUPPRESS) p.add_argument('--skipkernel', action='store_true', default=False, help=argparse.SUPPRESS) p.add_argument('--skipbootloader', action='store_true', default=False, help=argparse.SUPPRESS) p.add_argument('-C', '--cacheonly', action='store_true', default=False, help=argparse.SUPPRESS) # === yum options === yumopts = p.add_argument_group(_('yum options')) yumopts.add_argument('--enableplugin', metavar='PLUGIN', action='append', dest='enable_plugins', default=[], help=_('enable yum plugins by name')) yumopts.add_argument('--disableplugin', metavar='PLUGIN', action='append', dest='disable_plugins', default=[], help=_('disable yum plugins by name')) # === <SOURCE> options === req = p.add_argument_group(_('options for <SOURCE>'), _('Location to search for upgrade data.')) req.add_argument('--device', metavar='DEV', nargs='?', type=device_or_mnt, const='auto', help=_('device or mountpoint. default: check mounted devices')) req.add_argument('--iso', type=isofile, help=_('installation image file')) # Translators: This is for '--network [VERSION]' in --help output req.add_argument('--network', metavar=_('VERSION'), type=VERSION, help=_('online repos matching VERSION (a number or "rawhide")')) # === options for --network === net = p.add_argument_group(_('additional options for --network')) net.add_argument('--enablerepo', metavar='REPOID', action=RepoAction, dest='repos', help=_('enable one or more repos (wildcards allowed)')) net.add_argument('--disablerepo', metavar='REPOID', action=RepoAction, dest='repos', help=_('disable one or more repos (wildcards allowed)')) net.add_argument('--repourl', metavar='REPOID=URL', action=RepoAction, dest='repos', help=argparse.SUPPRESS) net.add_argument('--addrepo', metavar='REPOID=[@]URL', action=RepoAction, dest='repos', help=_('add the repo at URL (@URL for mirrorlist)')) net.add_argument('--instrepo', metavar='REPOID', type=str, help=_('get upgrader boot images from REPOID (default: auto)')) p.set_defaults(repos=[]) if not gui: clean = p.add_argument_group(_('cleanup commands')) clean.add_argument('--resetbootloader', action='store_const', dest='clean', const='bootloader', default=None, help=_('remove any modifications made to bootloader')) clean.add_argument('--clean', action='store_const', const='all', help=_('clean up everything written by fedup')) p.add_argument('--expire-cache', action='store_true', default=False, help=argparse.SUPPRESS) p.add_argument('--clean-metadata', action='store_true', default=False, help=argparse.SUPPRESS) args = p.parse_args() if not (gui or args.network or args.device or args.iso or args.clean): p.error(_('SOURCE is required (--network, --device, --iso)')) # allow --instrepo URL as shorthand for --repourl REPO=URL --instrepo REPO if args.instrepo and '://' in args.instrepo: args.repos.append(('add', 'cmdline-instrepo=%s' % args.instrepo)) args.instrepo = 'cmdline-instrepo' if not gui: if args.clean: args.resetbootloader = True return args
def transaction_test(pkgs): print _("testing upgrade transaction") pkgfiles = set(po.localPkg() for po in pkgs) fu = FedupUpgrade() fu.setup_transaction(pkgfiles=pkgfiles) fu.test_transaction(callback=output.TransactionCallback(numpkgs=len(pkgfiles)))
def main(args): if args.clean: do_cleanup(args) return if args.device or args.iso: device_setup(args) # Get our packages set up where we can use 'em print _("setting up repos...") f = setup_downloader(version=args.network, cacheonly=args.cacheonly, instrepo=args.instrepo, repos=args.repos, enable_plugins=args.enable_plugins, disable_plugins=args.disable_plugins) if args.expire_cache: print "expiring cache files" f.cleanExpireCache() return if args.clean_metadata: print "cleaning metadata" f.cleanMetadata() return if args.skipkernel: message("skipping kernel/initrd download") elif f.instrepoid is None or f.instrepoid in f.disabled_repos: print _("Error: can't get boot images.") if args.instrepo: print _("The '%s' repo was rejected by yum as invalid.") % args.instrepo if args.iso: print _("The given ISO probably isn't an install DVD image.") elif args.device: print _("The media doesn't contain a valid install DVD image.") else: print _("The installation repo isn't available.") print "You need to specify one with --instrepo." # XXX temporary raise SystemExit(1) else: print _("getting boot images...") kernel, initrd = f.download_boot_images() # TODO: force arch? if args.skippkgs: message("skipping package download") else: print _("setting up update...") if len(f.pkgSack) == 0: print("no updates available in configured repos!") raise SystemExit(1) pkgs = download_packages(f) # Run a test transaction transaction_test(pkgs) # And prepare for upgrade # TODO: use polkit to get root privs for these things print _("setting up system for upgrade") if not args.skippkgs: prep_upgrade(pkgs) if not args.skipbootloader: if args.skipkernel: print "warning: --skipkernel without --skipbootloader" print "using default paths: %s %s" % (kernelpath, initrdpath) kernel = kernelpath initrd = initrdpath prep_boot(kernel, initrd) if args.device: setup_media_mount(args.device) if args.iso: fedup.media.umount(args.device.mnt) if args.reboot: reboot() else: print _('Finished. Reboot to start upgrade.') if f.disabled_repos: # NOTE: I hate having a hardcoded list of Important Repos here. # This information should be provided by the system, somehow.. important = ("fedora", "updates") if any(i in f.disabled_repos for i in important): msg = _("WARNING: Some important repos could not be contacted: %s") else: msg = _("NOTE: Some repos could not be contacted: %s") print msg % ", ".join(f.disabled_repos) print _("If you start the upgrade now, packages from these repos will not be installed.")
# warn about broken dependencies etc. if probs: print print _("WARNING: problems were encountered during transaction test:") for s in probs.summaries: print " "+s.desc for line in s.format_details(): print " "+line print _("Continue with the upgrade at your own risk.") if __name__ == '__main__': args = parse_args() # TODO: use polkit to get privs for modifying bootloader stuff instead if os.getuid() != 0: print _("you must be root to run this program.") raise SystemExit(1) # set up logging if args.debuglog: logutils.debuglog(args.debuglog) logutils.consolelog(level=args.loglevel) log.info("%s %s starting at %s", sys.argv[0], fedupversion, time.asctime()) try: exittype = "cleanly" main(args) except KeyboardInterrupt as e: print log.info("exiting on keyboard interrupt") if e.message:
def __init__(self, yumobj=None, tty=sys.stderr): DepsolveCallbackBase.__init__(self, yumobj) self.progressbar = None if yumobj and tty: self.progressbar = SimpleProgress(self.installed_packages, tty=tty, prefix=_("finding updates"))
def main(args): if args.clean: do_cleanup(args) return if args.device or args.iso: mnt = device_setup(args) if args.iso: if not mnt: message('--iso: '+_('Unable to open %s') % args.iso) raise SystemExit(2) log.debug("iso is %s", os.path.realpath(args.iso)) def isocleanup(): log.debug("unmounting %s", args.device.mnt) media.umount(args.device.mnt) os.rmdir(args.device.mnt) atexit.register(isocleanup) # Get our packages set up where we can use 'em print _("setting up repos...") f = setup_downloader(version=args.network, cacheonly=args.cacheonly, instrepo=args.instrepo, repos=args.repos, enable_plugins=args.enable_plugins, disable_plugins=args.disable_plugins) if args.nogpgcheck: f._override_sigchecks = True if args.expire_cache: print "expiring cache files" f.cleanExpireCache() return if args.clean_metadata: print "cleaning metadata" f.cleanMetadata() return # TODO: error msg generation should be shared between CLI and GUI if args.skipkernel: message("skipping kernel/initrd download") elif f.instrepoid is None or f.instrepoid in f.disabled_repos: print _("Error: can't get boot images.") if args.instrepo: print _("The '%s' repo was rejected by yum as invalid.") % args.instrepo if args.iso: print _("The given ISO probably isn't an install DVD image.") elif args.device: print _("The media doesn't contain a valid install DVD image.") else: print _("The installation repo isn't currently available.") print _("Try again later, or specify a repo using --instrepo.") raise SystemExit(1) else: print _("getting boot images...") kernel, initrd = f.download_boot_images() # TODO: force arch? if args.skippkgs: message("skipping package download") else: print _("setting up update...") if len(f.pkgSack) == 0: print("no updates available in configured repos!") raise SystemExit(1) pkgs = download_packages(f) # Run a test transaction probs, rv = transaction_test(pkgs) # And prepare for upgrade # TODO: use polkit to get root privs for these things print _("setting up system for upgrade") if not args.skippkgs: prep_upgrade(pkgs) if not args.skipbootloader: if args.skipkernel: print "warning: --skipkernel without --skipbootloader" print "using default paths: %s %s" % (kernelpath, initrdpath) kernel = kernelpath initrd = initrdpath prep_boot(kernel, initrd) if args.device: setup_media_mount(args.device) if args.reboot: reboot() else: print _('Finished. Reboot to start upgrade.') if args.skippkgs: return # --- Here's where we summarize potential problems. --- # list packages without updates, if any missing = sorted(f.find_packages_without_updates(), key=lambda p:p.envra) if missing: message(_('Packages without updates:')) for p in missing: message(" %s" % p) if not any(p.name in f.conf.kernelpkgnames for p in pkgs): message(_('WARNING: no new kernel will be installed during upgrade')) # warn if the "important" repos are disabled if f.disabled_repos: # NOTE: I hate having a hardcoded list of Important Repos here. # This information should be provided by the system, somehow.. important = ("fedora", "updates") if any(i in f.disabled_repos for i in important): msg = _("WARNING: Some important repos could not be contacted: %s") else: msg = _("NOTE: Some repos could not be contacted: %s") print msg % ", ".join(f.disabled_repos) print _("If you start the upgrade now, packages from these repos will not be installed.") # warn about broken dependencies etc. if probs: print print _("WARNING: problems were encountered during transaction test:") for s in probs.summaries: print " "+s.desc for line in s.format_details(): print " "+line print _("Continue with the upgrade at your own risk.")
# NOTE: I hate having a hardcoded list of Important Repos here. # This information should be provided by the system, somehow.. important = ("fedora", "updates") if any(i in f.disabled_repos for i in important): msg = _("WARNING: Some important repos could not be contacted: %s") else: msg = _("NOTE: Some repos could not be contacted: %s") print msg % ", ".join(f.disabled_repos) print _("If you start the upgrade now, packages from these repos will not be installed.") if __name__ == '__main__': args = parse_args() # TODO: use polkit to get privs for modifying bootloader stuff instead if os.getuid() != 0: print _("you must be root to run this program.") raise SystemExit(1) # set up logging if args.debuglog: fedup.logutils.debuglog(args.debuglog) fedup.logutils.consolelog(level=args.loglevel) log.info("%s starting at %s", sys.argv[0], time.asctime()) try: main(args) except KeyboardInterrupt: print log.info("exiting on keyboard interrupt") raise SystemExit(1) except YumBaseError as e: