From 1b56e73c076b156497d04240b68d347b27c97c75 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Nov 2014 22:27:13 -0400 Subject: copyright update --- debian/copyright | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/copyright b/debian/copyright index 1d333cc3..d0071147 100644 --- a/debian/copyright +++ b/debian/copyright @@ -2,7 +2,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: native package Files: * -Copyright: © 2010-2014 Joey Hess +Copyright: © 2010-2014 Joey Hess and contributors License: BSD-2-clause License: BSD-2-clause -- cgit v1.3-2-g0d8e From f62d2fb18389947ce11021ba80b2aee52c6d03c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 00:22:19 -0400 Subject: propellor --spin can now deploy propellor to hosts that do not have git, ghc, or apt-get. This is accomplished by uploading a fairly portable precompiled tarball of propellor. --- debian/changelog | 8 ++++++++ src/Propellor/CmdLine.hs | 27 +++++++++++++++------------ src/Propellor/Git.hs | 2 +- src/Propellor/Protocol.hs | 2 +- src/Propellor/Server.hs | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 14 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 66e5caef..784dcdb7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +propellor (1.0.1) UNRELEASED; urgency=medium + + * propellor --spin can now deploy propellor to hosts that do not have + git, ghc, or apt-get. This is accomplished by uploading a fairly + portable precompiled tarball of propellor. + + -- Joey Hess Sat, 22 Nov 2014 00:12:35 -0400 + propellor (1.0.0) unstable; urgency=medium * propellor --spin can now be used to update remote hosts, without diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index 142efa1d..ec2ca7ed 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -114,16 +114,19 @@ unknownhost h hosts = errorMessage $ unlines ] buildFirst :: CmdLine -> IO () -> IO () -buildFirst cmdline next = do - oldtime <- getmtime - ifM (actionMessage "Propellor build" $ boolSystem "make" [Param "build"]) - ( do - newtime <- getmtime - if newtime == oldtime - then next - else void $ boolSystem "./propellor" [Param "--continue", Param (show cmdline)] - , errorMessage "Propellor build failed!" - ) +buildFirst cmdline next = ifM (doesFileExist "Makefile") + ( do + oldtime <- getmtime + ifM (actionMessage "Propellor build" $ boolSystem "make" [Param "build"]) + ( do + newtime <- getmtime + if newtime == oldtime + then next + else void $ boolSystem "./propellor" [Param "--continue", Param (show cmdline)] + , errorMessage "Propellor build failed!" + ) + , next + ) where getmtime = catchMaybeIO $ getModificationTime "propellor" @@ -172,11 +175,11 @@ spin hn hst = do updatecmd = mkcmd [ "if [ ! -d " ++ localdir ++ " ]" - , "then " ++ intercalate " && " + , "then (" ++ intercalate " && " [ "apt-get update" , "apt-get --no-install-recommends --no-upgrade -y install git make" , "echo " ++ toMarked statusMarker (show NeedGitClone) - ] + ] ++ ") || echo " ++ toMarked statusMarker (show NeedPrecompiled) , "else " ++ intercalate " && " [ "cd " ++ localdir , "if ! test -x ./propellor; then make deps build; fi" diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs index 73de1def..e5f464c0 100644 --- a/src/Propellor/Git.hs +++ b/src/Propellor/Git.hs @@ -38,7 +38,7 @@ getRepoUrl = getM get urls _ -> Nothing hasOrigin :: IO Bool -hasOrigin = do +hasOrigin = catchDefaultIO False $ do rs <- lines <$> readProcess "git" ["remote"] return $ "origin" `elem` rs diff --git a/src/Propellor/Protocol.hs b/src/Propellor/Protocol.hs index 68c2443b..95a671bc 100644 --- a/src/Propellor/Protocol.hs +++ b/src/Propellor/Protocol.hs @@ -13,7 +13,7 @@ import Data.List import Propellor -data Stage = NeedGitClone | NeedRepoUrl | NeedPrivData | NeedGitPush +data Stage = NeedGitClone | NeedRepoUrl | NeedPrivData | NeedGitPush | NeedPrecompiled deriving (Read, Show, Eq) type Marker = String diff --git a/src/Propellor/Server.hs b/src/Propellor/Server.hs index 513a81f4..786d1211 100644 --- a/src/Propellor/Server.hs +++ b/src/Propellor/Server.hs @@ -16,6 +16,7 @@ import Propellor.Protocol import Propellor.PrivData.Paths import Propellor.Git import Propellor.Ssh +import qualified Propellor.Shim as Shim import Utility.FileMode import Utility.SafeCommand @@ -69,6 +70,11 @@ updateServer hn hst connect = connect go hClose fromh sendGitClone hn updateServer hn hst connect + (Just NeedPrecompiled) -> do + hClose toh + hClose fromh + sendPrecompiled hn + updateServer hn hst connect Nothing -> return () sendRepoUrl :: Handle -> IO () @@ -113,6 +119,32 @@ sendGitClone hn = void $ actionMessage ("Clone git repository to " ++ hn) $ do , "rm -f " ++ remotebundle ] +-- Send a tarball containing the precompiled propellor, and libraries. +-- This should be reasonably portable, as long as the remote host has the +-- same architecture as the build host. +sendPrecompiled :: HostName -> IO () +sendPrecompiled hn = void $ actionMessage ("Uploading locally compiled propellor as a last resort " ++ hn) $ do + cacheparams <- sshCachingParams hn + withTmpDir "propellor" $ \tmpdir -> + bracket getWorkingDirectory changeWorkingDirectory $ \_ -> do + changeWorkingDirectory tmpdir + let shimdir = "propellor" + let me = localdir "propellor" + void $ Shim.setup me shimdir + withTmpFile "propellor.tar" $ \tarball -> allM id + [ boolSystem "strip" [File me] + , boolSystem "tar" [Param "cf", File tmp, File shimdir] + , boolSystem "scp" $ cacheparams ++ [File tarball, Param ("root@"++hn++":"++remotetarball) + , boolSystem "ssh" $ cacheparams ++ [Param ("root@"++hn), Param unpackcmd] + ] + where + remotetarball = "/usr/local/propellor.tar" + unpackcmd = shellSwap $ intercalate " && " + [ "cd " ++ takeDirectory remotetarball + , "tar xf " ++ remotetarball + , "rm -f " ++ remotetarball + ] + -- Shim for git push over the propellor ssh channel. -- Reads from stdin and sends it to hout; -- reads from hin and sends it to stdout. -- cgit v1.3-2-g0d8e From 57ec60d6f307dbf3e237b924e635b90ba889af18 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 12:09:53 -0400 Subject: mdwn man page and more complete docs --- Makefile | 7 +++++-- debian/changelog | 2 ++ doc/documentation.mdwn | 1 + doc/mdwn2man | 44 ++++++++++++++++++++++++++++++++++++++++++++ propellor.1 | 15 --------------- 5 files changed, 52 insertions(+), 17 deletions(-) create mode 100755 doc/mdwn2man delete mode 100644 propellor.1 (limited to 'debian') diff --git a/Makefile b/Makefile index 61d32424..459fae36 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ dist/setup-config: propellor.cabal @if [ "$(CABAL)" = ./Setup ]; then ghc --make Setup; fi @$(CABAL) configure -install: +install: propellor.1 install -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/src/propellor install -s dist/build/propellor/propellor $(DESTDIR)/usr/bin/propellor mkdir -p dist/gittmp @@ -34,8 +34,11 @@ install: && git show-ref master --hash > $(DESTDIR)/usr/src/propellor/head rm -rf dist/gittmp +propellor.1: doc/usage.mdwn doc/mdwn2man + doc/mdwn2man propellor 1 < doc/usage.mdwn > propellor.1 + clean: - rm -rf dist Setup tags propellor privdata/local + rm -rf dist Setup tags propellor propellor.1 privdata/local find -name \*.o -exec rm {} \; find -name \*.hi -exec rm {} \; diff --git a/debian/changelog b/debian/changelog index 784dcdb7..a44d72af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ propellor (1.0.1) UNRELEASED; urgency=medium * propellor --spin can now deploy propellor to hosts that do not have git, ghc, or apt-get. This is accomplished by uploading a fairly portable precompiled tarball of propellor. + * --spin host --via host causes propellor to bounce through an intermediate + host, which handles any necessary provisioning of the host being spun. -- Joey Hess Sat, 22 Nov 2014 00:12:35 -0400 diff --git a/doc/documentation.mdwn b/doc/documentation.mdwn index 79e242f4..9028dfaa 100644 --- a/doc/documentation.mdwn +++ b/doc/documentation.mdwn @@ -3,6 +3,7 @@ Propellor's modules is the most important docuemntation of propellor. Other documentation: +* [[man page|usage]] * [[Haskell Newbie]] * [[Centralized Git Repository]] * [[Contributing]] diff --git a/doc/mdwn2man b/doc/mdwn2man new file mode 100755 index 00000000..aadb13cd --- /dev/null +++ b/doc/mdwn2man @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +# Warning: hack + +my $prog=shift; +my $section=shift; + +print ".TH $prog $section\n"; + +while (<>) { + s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg; + s/\`([^\`]*)\`/\\fB$1\\fP/g; + s/\`//g; + s/^\s*\./\\&./g; + if (/^#\s/) { + s/^#\s/.SH /; + <>; # blank; + } + s/^[ \n]+//; + s/^\t/ /; + s/-/\\-/g; + s/^Warning:.*//g; + s/^$/.PP\n/; + s/^\*\s+(.*)/.IP "$1"/; + next if $_ eq ".PP\n" && $skippara; + if (/^.IP /) { + $inlist=1; + $spippara=0; + } + elsif (/^.SH/) { + $skippara=0; + $inlist=0; + } + elsif (/^\./) { + $skippara=1; + } + else { + $skippara=0; + } + if ($inlist && $_ eq ".PP\n") { + $_=".IP\n"; + } + + print $_; +} diff --git a/propellor.1 b/propellor.1 deleted file mode 100644 index 27547f10..00000000 --- a/propellor.1 +++ /dev/null @@ -1,15 +0,0 @@ -.\" -*- nroff -*- -.TH propellor 1 "Commands" -.SH NAME -propellor \- property-based host configuration management in haskell -.SH SYNOPSIS -.B propellor [options] host -.SH DESCRIPTION -.I propellor -is a property-based host configuration management program written -and configured in haskell. -.PP -The first time you run propellor, it will set up a ~/.propellor/ -repository. Edit ~/.propellor/config.hs to configure it. -.SH AUTHOR -Joey Hess -- cgit v1.3-2-g0d8e