Move some utility functions to fedup.util

listdir, mkdir_p, rm_f, and rm_rf are useful little utility functions
that we might want to use elsewhere in fedup; put them in their own
module.
add missing imports to fedup.media

Heh. --iso wasn't finished when this code was released. I had intended
to stub out the --iso code until I had time to finish/test it, but.. too
late now!
If os.link fails, try to copy instead (#883107)

It's possible that someone would set up their system with their cachedir
(usually /var/cache) and persistent temporary dir (usually /var/tmp) on
different filesystems.

If that happens, we can't hardlink the files into packagedir - so copy
them instead.
Disable SELinux during upgrade if disabled on host (#882549)

Since the config in upgrade.img says to enable SELinux (and it's got
policy to load), it loads policy even if the target system has SELinux
disabled in /etc/selinux/config.

So, if SELinux is disabled during fedup runtime, disable it for the
upgrade as well.
Add fedup.conf module, write packagedir/upgrade.conf

There might be other things we want to clean up / refer to in the
future, so it might be better if we had a structured file that contained
info about the upgrade.

Currently we write two sections, like this:

  [cleanup]
  dirs = <dirs to clean up>

  [boot]
  kernel = <path to upgrader kernel>
  initrd = <path to upgrader initrd>

This allows other tools to clean up after us or examine the state of the
upgrade or whatever.
cleanup: remove useless line

'key' gets reset without ever being used, so this line is useless.
Probably some leftover vestigial code from something else.
move rmtree import to fedup.util

This needs to be imported in fedup.util (whoops) but if we use rm_rf
instead of rmtree it's not needed in fedup.download.
add Config.get()

Like set(), this is similar to RawConfigParser but it's more forgiving
of missing sections / options and just returns None instead of raising
an exception.
add fedup.boot

It turns out there's some magic in new-kernel-pkg that grubby doesn't
have; without that stuff grubby sometimes doesn't update the right
bootloader config.

So here's a module that modifies the bootloader config using
new-kernel-pkg.
Use boot image paths that new-kernel-pkg likes

new-kernel-pkg requires that the kernel have a name of the form:

  /boot/vmlinuz-$version

where $version is basically an arbitrary string you pass in.

Therefore: download our images to paths that match that form.
better handling when instrepo is disabled

Don't print the useless "No upgrade available for instrepo" message.

Instead, either tell the user their repo was rejected (if we have
args.instrepo) or that the install repo isn't available.
add default_install_mirrorlist

This is a mirrorlist URL that Fedora Infrastructure should be setting up
so we can find install images without requiring --instrepo. Yay!
use 'cmdline-instrepo' for --instrepo repoid

Just so it's perfectly clear how the repo got set up.
remove_cache(): use contents of Config

Just to be extra-sure, try to clean up whatever is in the configfile in
addition to our hardcoded defaults.
replace fedup.grubby (#872088, #879290, #881338)

Change the stuff in fedup.download that used grubby to use
new-kernel-pkg (via fedup.boot) instead.

Note that we don't bother removing existing boot entries anymore,
because new-kernel-pkg does that by default.
drop references to bootdir

We don't use bootdir anymore. Drop it.
refactor cleanup stuff, add --resetbootloader

Split up the cleanup stuff in fedup.download a little differently so we
can have the --resetbootloader flag, which just resets the bootloader
config to its previous state.
remove boot option during upgrade (#873065)

This will remove our boot option just before we start the upgrade.

This further ensures that we'll end up back in the normal system if
something goes wrong while trying to start the upgrade.

Plus, removing it before the upgrade means there's no possibility of our
boot arguments ending up in the new system's bootloader config (that's
bug #876366).
fail quicker when instrepo isn't available

Move the (very long) package download after the kernel/initrd download
so we can fail much sooner if instrepo is unreachable.