From 6abfbcfcfb75f827600c29a1d7f0ec4b3adf5e96 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Dec 2017 18:27:52 -0400 Subject: setting up joeyconfig after merge --- config.hs | 2 +- privdata/relocate | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 privdata/relocate diff --git a/config.hs b/config.hs index ec313725..97d90636 120000 --- a/config.hs +++ b/config.hs @@ -1 +1 @@ -config-simple.hs \ No newline at end of file +joeyconfig.hs \ No newline at end of file diff --git a/privdata/relocate b/privdata/relocate new file mode 100644 index 00000000..271692d8 --- /dev/null +++ b/privdata/relocate @@ -0,0 +1 @@ +.joeyconfig -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 9beb0011f00b591757db34873e1b8fc353ff7e75 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Dec 2017 19:01:42 -0400 Subject: say when resizing/creating disk image file That can take quite a while, so let the user know why propellor has stalled. --- src/Propellor/Property/DiskImage.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index c9998d3c..1f4f8118 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -41,6 +41,7 @@ import Propellor.Types.Bootloader import Propellor.Container import Utility.Path import Utility.FileMode +import Utility.DataUnits import Data.List (isPrefixOf, isInfixOf, sortBy, unzip4) import Data.Function (on) @@ -344,17 +345,24 @@ getMountSz szm l (Just mntpt) = imageExists :: RawDiskImage -> ByteSize -> Property Linux imageExists (RawDiskImage img) isz = property ("disk image exists" ++ img) $ liftIO $ do ms <- catchMaybeIO $ getFileStatus img - case ms of + case fmap (toInteger . fileSize) ms of Just s - | toInteger (fileSize s) == toInteger sz -> return NoChange - | toInteger (fileSize s) > toInteger sz -> do + | s == toInteger sz -> return NoChange + | s > toInteger sz -> do + infoMessage ["truncating " ++ img ++ " to " ++ humansz] setFileSize img (fromInteger sz) return MadeChange - _ -> do + | otherwise -> do + infoMessage ["expanding " ++ img ++ " from " ++ roughSize storageUnits False s ++ " to " ++ humansz] + L.writeFile img (L.replicate (fromIntegral sz) 0) + return MadeChange + Nothing -> do + infoMessage ["creating " ++ img ++ " of size " ++ humansz] L.writeFile img (L.replicate (fromIntegral sz) 0) return MadeChange where sz = ceiling (fromInteger isz / sectorsize) * ceiling sectorsize + humansz = roughSize storageUnits False (toInteger sz) -- Disks have a sector size, and making a disk image not -- aligned to a sector size will confuse some programs. -- Common sector sizes are 512 and 4096; use 4096 as it's larger. -- cgit v1.2.3 -- cgit v1.2.3