Add a DiskFile class for testing partitioning code as a non-root user.

There seems to be some special treatment from parted (first free sector
is reported as 32) but the main purpose is to test partitioning code
without committing the changes to disk. It may be perfectly viable to
commit to these devices, but I haven't tried it yet. My intention is to
write unit tests for things like partition allocation -- which require
parted Device and Disk instances -- without requiring root access.

(cherry picked from commit 19a53f8bbda0c8f473b19585329ec4b68553561a)
Add a contextmanager to create and remove sparse tempfiles.

with sparsetmpfile("mytest", Size("100 MiB")) as path:
  do_stuff(fn=path)

It creates a sparse temporary file with the specified size and yields its
full path on __enter__, then unlinks the file on __exit__.

(cherry picked from commit d394eacb0472a6173fb486712caf18c80fd4c5fd)
Change signature of DiskLabel.addPartition to be more useful.

The new method accepts start sector, end sector, and partition type.

The previous method required you to pass in a parted.Partition instance.
It did not simply add that parted.Partition instance. Instead, it created
a new parted.Partition instance based on the one passed in and added that
to the parted.Disk.

(cherry picked from commit 6a9c2ed8d1c32b1062f44b6ae99fb4e08083e8b7)
Use Decimal for math in Size.convertTo. (#1120964)

Size.__div__ converts the Decimal result to a Size, which rounds its
numerical argument (byte count) down to an integer. Size.convertTo is
meant to retain precision.

(cherry picked from commit a3998ea687a96d7f6ca7a019ecae87dcc7b5d0fe)
Check new target size against min size and max size.

(cherry picked from commit e2fd4a318727b2cc92a83914749dca2f556c5bab)
Specify ntfs resize target in bytes. (#1120964)

This saves us the trouble of having to round in the correct direction.

(cherry picked from commit 8919b519e14c9df668daf7cab535a77226513dd9)
Align end sector in the appropriate direction for resize. (#1120964)

When shrinking, align the end sector up to ensure the aligned partition
is still larger than the formatting's minimum size.

When growing, align the end sector down to ensure the aligned partition
is completely within the free region (and not larger than the formatting's
maximum size).

(cherry picked from commit 652722bc1852b5185f0a48b07b301fff76c05c45)
Allow generating aligned geometry for arbitrary target size.

_computeResize still defaults to self.targetSize, but this allows us
to pass any size in and see what the aligned geometry would look like
for that target size.

(cherry picked from commit da6989606e634bb2a787af452ec251f0400bad5c)
Split out code to determine max unaligned partition size to a property.

(cherry picked from commit a9ac2316e6da993ad5c01b126833658a036627d3)
Require resize target sizes to yield aligned partitions. (#1120964)

New method StorageDevice.alignTargetSize can be used to modify target
sizes as needed to account for alignment.

Modify minSize and maxSize to return values that will yield an aligned
partition.

(cherry picked from commit b6a79c9b935191b57589fe05e18b1602fa3a2ca1)