diff options
| l--------- | config.hs | 2 | ||||
| -rw-r--r-- | debian/changelog | 20 | ||||
| -rw-r--r-- | doc/news/version_4.0.0.mdwn | 30 | ||||
| -rw-r--r-- | doc/news/version_4.0.1.mdwn | 6 | ||||
| -rw-r--r-- | doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror.mdwn | 4 | ||||
| -rw-r--r-- | doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror/comment_2_2c2c4817a4259acbc1a63bac2e3fb2e3._comment | 8 | ||||
| -rw-r--r-- | doc/todo/bug_in_diskimage_finalization.mdwn | 11 | ||||
| -rw-r--r-- | privdata/relocate | 1 | ||||
| -rw-r--r-- | src/Propellor/Property/Apt.hs | 64 | ||||
| -rw-r--r-- | src/Propellor/Property/Sbuild.hs | 12 | ||||
| -rw-r--r-- | src/Propellor/Property/Tor.hs | 1 |
11 files changed, 100 insertions, 59 deletions
@@ -1 +1 @@ -joeyconfig.hs
\ No newline at end of file +config-simple.hs
\ No newline at end of file diff --git a/debian/changelog b/debian/changelog index c466530e..9e6ffb67 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,12 +1,22 @@ -propellor (4.0.1) UNRELEASED; urgency=medium +propellor (4.0.2) UNRELEASED; urgency=medium - * Fix build with pre-AMP ghc. - * Tor.named, Tor.torPrivKey: Include the new ed25519 public/private key - pair in addition to the old secret_id_key. + * Apt.mirror can be used to set the preferred apt mirror of a host, + overriding the default CDN. This info is used by + Apt.stdSourcesList and Sbuild.builtFor. + Thanks, Sean Whitton. * Property.Partition: Update kpartx output parser, as its output format changed around version 0.6. Both output formats are supported now. - -- Joey Hess <id@joeyh.name> Sat, 18 Mar 2017 19:40:35 -0400 + -- Joey Hess <id@joeyh.name> Sun, 19 Mar 2017 16:37:27 -0400 + +propellor (4.0.1) unstable; urgency=medium + + * Fix build with pre-AMP ghc. + * Tor: Restart daemon after installing private key. + * Tor.named, Tor.torPrivKey: Include the new ed25519 public/private key + pair in addition to the old secret_id_key. + + -- Joey Hess <id@joeyh.name> Sun, 19 Mar 2017 16:18:11 -0400 propellor (4.0.0) unstable; urgency=medium diff --git a/doc/news/version_4.0.0.mdwn b/doc/news/version_4.0.0.mdwn deleted file mode 100644 index bb62b4a2..00000000 --- a/doc/news/version_4.0.0.mdwn +++ /dev/null @@ -1,30 +0,0 @@ -propellor 4.0.0 released with [[!toggle text="these changes"]] -[[!toggleable text=""" - * Added Monoid instances for Property and RevertableProperty. - * Removed applyToList. Instead, use mconcat. (API change) - If you had: applyToList accountFor [User "joey", User "root"] - use instead: mconcat (map accountFor [User "joey", User "root"]) - * Makefile: Removed "run" target which was default target. - "make" now only builds propellor, does not run it. - Note that propellor 1.0.0 and earlier relied on this target for - the Cron.runPropellor property's cronjob to work, so upgrading - directly from 1.0.0 to 4.0.0 would break that cron job. - * Remove make from propellor's dependency list; it's not used by - propellor any longer. - * Implemented hostChroot, as originally seen in my slides at - Linux.Conf.Au 2017 in January. Now that it's not vaporware, it allows - one Host to build a disk image that has all the properties of another - Host. - * DiskImage building properties used to propagate DNS info out from - the chroot used to build the disk image to the Host. That is no longer - done, since that chroot only exists as a side effect of the disk image - creation and servers will not be running in it. - * The IsInfo types class's propagateInfo function changed to use a - PropagateInfo data type. (API change) - * The action used to satisfy a property changed to Maybe (Propellor Result). - When it is Nothing, propellor knows it can skip displaying the - description of that property. This is mostly useful in the - implementation of mempty. (API change) - * The doNothing property is now simply mempty. The name was retained - because it can be clearer than mempty in some contexts. - * Added Apache.confEnabled."""]]
\ No newline at end of file diff --git a/doc/news/version_4.0.1.mdwn b/doc/news/version_4.0.1.mdwn new file mode 100644 index 00000000..e870a510 --- /dev/null +++ b/doc/news/version_4.0.1.mdwn @@ -0,0 +1,6 @@ +propellor 4.0.1 released with [[!toggle text="these changes"]] +[[!toggleable text=""" + * Fix build with pre-AMP ghc. + * Tor: Restart daemon after installing private key. + * Tor.named, Tor.torPrivKey: Include the new ed25519 public/private key + pair in addition to the old secret\_id\_key."""]]
\ No newline at end of file diff --git a/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror.mdwn b/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror.mdwn index 355d53b2..4cd76383 100644 --- a/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror.mdwn +++ b/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror.mdwn @@ -1 +1,5 @@ It would be good to have an info property, say `Apt.mirror`, which sets a host's preferred apt mirror. Then all properties in `Propellor.Property.Apt` would use this mirror when generating sources lists, falling back to the `deb.debian.org` default. The value of `Apt.mirror` could be an apt cache on the LAN, or a mirror that is known to be better than the Debian CDN from where the host is located. --[[spwhitton|user/spwhitton]] + +[[!tag user/spwhitton]] + +> [[merged|done]] thank you! --[[Joey]] diff --git a/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror/comment_2_2c2c4817a4259acbc1a63bac2e3fb2e3._comment b/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror/comment_2_2c2c4817a4259acbc1a63bac2e3fb2e3._comment new file mode 100644 index 00000000..b79ba1c1 --- /dev/null +++ b/doc/todo/Info_property_to_select_host__39__s_preferred_Apt_mirror/comment_2_2c2c4817a4259acbc1a63bac2e3fb2e3._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="spwhitton" + avatar="http://cdn.libravatar.org/avatar/9c3f08f80e67733fd506c353239569eb" + subject="merge request" + date="2017-03-19T18:42:20Z" + content=""" +Please see branch `apt-mirror` of repo `https://git.spwhitton.name/propellor` for an implementation of this. +"""]] diff --git a/doc/todo/bug_in_diskimage_finalization.mdwn b/doc/todo/bug_in_diskimage_finalization.mdwn new file mode 100644 index 00000000..288e96f2 --- /dev/null +++ b/doc/todo/bug_in_diskimage_finalization.mdwn @@ -0,0 +1,11 @@ +DiskImage.imageBuilt has broken and no longer runs the finalization +properties that get added to the chroot. This includes installing grub, and +Chroot.noServices etc. + +Seems that the `_chroot` info that gets propigated from imageBuilt is +for the chroot before those properties are added to it. Then when chaining +into the chroot, `_chroot` info is examined to find the properties to +ensure. + +I have not yet been able to determine what broke it -- I'm sure it used to +work. --[[Joey]] diff --git a/privdata/relocate b/privdata/relocate deleted file mode 100644 index 271692d8..00000000 --- a/privdata/relocate +++ /dev/null @@ -1 +0,0 @@ -.joeyconfig diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index c681eee6..686ddb6c 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -1,9 +1,11 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DeriveDataTypeable #-} module Propellor.Property.Apt where import Data.Maybe import Data.List +import Data.Typeable import System.IO import Control.Monad import Control.Applicative @@ -13,6 +15,37 @@ import Propellor.Base import qualified Propellor.Property.File as File import qualified Propellor.Property.Service as Service import Propellor.Property.File (Line) +import Propellor.Types.Info + +data HostMirror = HostMirror Url + deriving (Eq, Show, Typeable) + +-- | Indicate host's preferred apt mirror (e.g. an apt cacher on the host's LAN) +mirror :: Url -> Property (HasInfo + UnixLike) +mirror u = pureInfoProperty (u ++ " apt mirror selected") + (InfoVal (HostMirror u)) + +getMirror :: Propellor Url +getMirror = do + mirrorInfo <- getMirrorInfo + osInfo <- getOS + return $ case (osInfo, mirrorInfo) of + (_, Just (HostMirror u)) -> u + (Just (System (Debian _ _) _), _) -> + "http://deb.debian.org/debian" + (Just (System (Buntish _) _), _) -> + "mirror://mirrors.ubuntu.com/" + (Just (System dist _), _) -> + error ("no Apt mirror defined for " ++ show dist) + _ -> error "no Apt mirror defined for this host or OS" + where + getMirrorInfo :: Propellor (Maybe HostMirror) + getMirrorInfo = fromInfoVal <$> askInfo + +withMirror :: Desc -> (Url -> Property DebianLike) -> Property DebianLike +withMirror desc mkp = property' desc $ \w -> do + u <- getMirror + ensureProperty w (mkp u) sourcesList :: FilePath sourcesList = "/etc/apt/sources.list" @@ -37,8 +70,8 @@ stableUpdatesSuite (Stable s) = Just (s ++ "-updates") stableUpdatesSuite _ = Nothing debLine :: String -> Url -> [Section] -> Line -debLine suite mirror sections = unwords $ - ["deb", mirror, suite] ++ sections +debLine suite url sections = unwords $ + ["deb", url, suite] ++ sections srcLine :: Line -> Line srcLine l = case words l of @@ -61,8 +94,8 @@ binandsrc url suite = catMaybes bs <- backportSuite suite return $ debLine bs url stdSections -debCdn :: SourcesGenerator -debCdn = binandsrc "http://deb.debian.org/debian" +stdArchiveLines :: Propellor SourcesGenerator +stdArchiveLines = return . binandsrc =<< getMirror -- | Only available for Stable and Testing securityUpdates :: SourcesGenerator @@ -72,8 +105,9 @@ securityUpdates suite in [l, srcLine l] | otherwise = [] --- | Makes sources.list have a standard content using the Debian mirror CDN, --- with the Debian suite configured by the os. +-- | Makes sources.list have a standard content using the Debian mirror CDN +-- (or other host specified using the `mirror` property), with the +-- Debian suite configured by the os. stdSourcesList :: Property Debian stdSourcesList = withOS "standard sources.list" $ \w o -> case o of (Just (System (Debian _ suite) _)) -> @@ -88,11 +122,12 @@ stdSourcesListFor suite = stdSourcesList' suite [] -- Note that if a Property needs to enable an apt source, it's better -- to do so via a separate file in </etc/apt/sources.list.d/> stdSourcesList' :: DebianSuite -> [SourcesGenerator] -> Property Debian -stdSourcesList' suite more = tightenTargets $ setSourcesList - (concatMap (\gen -> gen suite) generators) - `describe` ("standard sources.list for " ++ show suite) +stdSourcesList' suite more = tightenTargets $ + withMirror desc $ \u -> setSourcesList + (concatMap (\gen -> gen suite) (generators u)) where - generators = [debCdn, securityUpdates] ++ more + generators u = [binandsrc u, securityUpdates] ++ more + desc = ("standard sources.list for " ++ show suite) type PinPriority = Int @@ -120,23 +155,24 @@ suiteAvailablePinned s pin = available <!> unavailable & File.notPresent prefFile setSourcesFile :: Property Debian - setSourcesFile = withOS (desc True) $ \w o -> case o of + setSourcesFile = tightenTargets $ withMirror (desc True) $ \u -> + withOS (desc True) $ \w o -> case o of (Just (System (Debian _ hostSuite) _)) | s /= hostSuite -> ensureProperty w $ - File.hasContent sourcesFile sources + File.hasContent sourcesFile (sources u) `onChange` update _ -> noChange -- Unless we are pinning a backports suite, filter out any backports -- sources that were added by our generators. The user probably doesn't -- want those to be pinned to the same value - sources = dropBackports $ concatMap (\gen -> gen s) generators + sources u = dropBackports $ concatMap (\gen -> gen s) (generators u) where dropBackports | "-backports" `isSuffixOf` (showSuite s) = id | otherwise = filter (not . isInfixOf "-backports") - generators = [debCdn, securityUpdates] + generators u = [binandsrc u, securityUpdates] prefFile = "/etc/apt/preferences.d/20" ++ showSuite s ++ ".pref" sourcesFile = "/etc/apt/sources.list.d/" ++ showSuite s ++ ".list" diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs index aaa83e6f..00109381 100644 --- a/src/Propellor/Property/Sbuild.hs +++ b/src/Propellor/Property/Sbuild.hs @@ -128,9 +128,9 @@ data UseCcache = UseCcache | NoCcache builtFor :: System -> UseCcache -> RevertableProperty DebianLike UnixLike builtFor sys cc = go <!> deleted where - go = property' ("sbuild schroot for " ++ show sys) $ - \w -> case (schrootFromSystem sys, stdMirror sys) of - (Just s, Just u) -> ensureProperty w $ + go = Apt.withMirror goDesc $ \u -> property' goDesc $ \w -> + case schrootFromSystem sys of + Just s -> ensureProperty w $ setupRevertableProperty $ built s u cc _ -> errorMessage ("don't know how to debootstrap " ++ show sys) @@ -139,6 +139,7 @@ builtFor sys cc = go <!> deleted Just s -> ensureProperty w $ undoRevertableProperty $ built s "dummy" cc Nothing -> noChange + goDesc = "sbuild schroot for " ++ show sys -- | Build and configure a schroot for use with sbuild built :: SbuildSchroot -> Apt.Url -> UseCcache -> RevertableProperty DebianLike UnixLike @@ -500,11 +501,6 @@ schrootFromSystem system@(System _ arch) = extractSuite system >>= \suite -> return $ SbuildSchroot suite arch -stdMirror :: System -> Maybe Apt.Url -stdMirror (System (Debian _ _) _) = Just "http://deb.debian.org/debian" -stdMirror (System (Buntish _) _) = Just "mirror://mirrors.ubuntu.com/" -stdMirror _ = Nothing - schrootRoot :: SbuildSchroot -> FilePath schrootRoot (SbuildSchroot s a) = "/srv/chroot" </> s ++ "-" ++ architectureToDebianArchString a diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs index 710007cb..8794bc7f 100644 --- a/src/Propellor/Property/Tor.hs +++ b/src/Propellor/Property/Tor.hs @@ -57,6 +57,7 @@ named n = configured [("Nickname", n')] -- and ed25519_master_id_secret_key from privdata. torPrivKey :: Context -> Property (HasInfo + DebianLike) torPrivKey context = mconcat (map go keyfiles) + `onChange` restarted `requires` torPrivKeyDirExists where keyfiles = map (torPrivKeyDir </>) |
