Ensure cache dir exists

If we don't have any network repositories then we'll never create the cache
dir and instrepo downloads will fail. Ensure that it's created.
media: check for .treeinfo, not .buildstamp

.buildstamp isn't present on some modern media - use .treeinfo instead.
media: add 'mnt' property that auto-unescapes mntpoint

mntpoint will frequently be full of octal escapes, and thus not match
the actual on-disk paths. So instead we provide a 'mnt' property that
has the proper escaped name.
Add fedup.media.write_systemd_unit()

write_systemd_unit() will write a systemd .mount unit for the given
FstabEntry.

Note what while you can't directly modify a FstabEntry, you can create a
new one with modified properties like so:

  newmnt = oldmnt._replace(rawmnt=newpath)
correctly delete invalid boot images

We have our own way of checking whether the file downloaded
successfully, so don't bother with urlgrabber's "reget" junk
workaround for umount bug (#873459)

The problem with bind-mounts is that once we switch-root, they all
become *private* mounts. Why does that matter? Well, it means unmounting
/sysroot/boot doesn't actually unmount the original /boot..

..which means /boot is still mounted when we reboot. So we can lose data
in recently-written files. Like that new initramfs we just wrote at the
end of the upgrade. Which leaves our system unbootable. Daaaang. Whoops.

So here's a partial workaround: make the mounts private *before*
switch-root, and unmount the *original* copy of /boot before the switch,
so the /sysroot/boot copy is the *only* one, so when we unmount that the
kernel actually writes everything to disk. Whew.

Unfortunately, this doesn't do anything for the root device, but we can
work something out for that inside the initramfs.
rename --no-bootloader to --skipbootloader

This matches our other (undocumented) flags and simplifies prep_boot().
Allow purely offline fedup runs

If version is None, assume that means 'no network', and disable all the
existing repos.
fedup.download: lorax compatibility

lorax is building upgrade.img separately, as 'upgrade', so look for that
instead.
add fedup.download.setup_media_mount

This function takes a FstabEntry object (as returned by
fedup.media.mounts() etc.) and writes out a systemd .mount unit in the
system-upgrade.target.wants directory.

This will make the system mount the install media to $UPGRADELINK/media
before the upgrade starts, so we can install packages from it. Hooray!
add fedup.media.{umount,loopmount}

These will be useful for upgrade-from-.iso-file. Woo! Fun!
Add support from installs from media and .iso files

This adds support for the --device and --iso flags (although --iso is
currently untested, --device has been tested and works fine).

It works basically by rewriting all the paths for packages contained on
local media to 'media/%s', and then writing out a systemd unit file so
the media will be mounted at $PACKAGEDIR/media, so when the upgrader
looks for them.. there they are!

Note that if we want to support installs using *multiple* devices or
media, we'll need to be a little more discerning about which package
came from which device, and where they end up mounted. But installing
from one device plus network repos (e.g. updates) should work just fine.

This patch was originally written by Matthew Garrett <mjg@redhat.com>,
who is, seriously, a goddamned prince. He is a gentleman and a scholar.
Buy him expensive liquor.