Ejemplo n.º 1
0
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.")
Ejemplo n.º 2
0
Archivo: fedup.py Proyecto: kalev/fedup
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.")
Ejemplo n.º 3
0
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.")