Propellor now builds itself without needing the Makefile.
This commit is contained in:
parent
1a62575d3d
commit
dc03e317b4
19
Makefile
19
Makefile
|
@ -9,18 +9,10 @@ run: deps build
|
||||||
|
|
||||||
dev: build tags
|
dev: build tags
|
||||||
|
|
||||||
build: dist/setup-config
|
|
||||||
@if ! $(CABAL) build; then $(CABAL) configure; $(CABAL) build; fi
|
|
||||||
@ln -sf dist/build/propellor-config/propellor-config propellor
|
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
@if [ $$(whoami) = root ]; then apt-get --no-upgrade --no-install-recommends -y install $(DEBDEPS) || (apt-get update && apt-get --no-upgrade --no-install-recommends -y install $(DEBDEPS)); fi || true
|
@if [ $$(whoami) = root ]; then apt-get --no-upgrade --no-install-recommends -y install $(DEBDEPS) || (apt-get update && apt-get --no-upgrade --no-install-recommends -y install $(DEBDEPS)); fi || true
|
||||||
@if [ $$(whoami) = root ]; then apt-get --no-upgrade --no-install-recommends -y install libghc-async-dev || (cabal update; cabal install async); fi || true
|
@if [ $$(whoami) = root ]; then apt-get --no-upgrade --no-install-recommends -y install libghc-async-dev || (cabal update; cabal install async); fi || true
|
||||||
|
|
||||||
dist/setup-config: propellor.cabal
|
|
||||||
@if [ "$(CABAL)" = ./Setup ]; then ghc --make Setup; fi
|
|
||||||
@$(CABAL) configure
|
|
||||||
|
|
||||||
install: propellor.1
|
install: propellor.1
|
||||||
install -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/src/propellor
|
install -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/src/propellor
|
||||||
install -s dist/build/propellor/propellor $(DESTDIR)/usr/bin/propellor
|
install -s dist/build/propellor/propellor $(DESTDIR)/usr/bin/propellor
|
||||||
|
@ -56,3 +48,14 @@ hackage:
|
||||||
@cabal upload dist/*.tar.gz
|
@cabal upload dist/*.tar.gz
|
||||||
|
|
||||||
.PHONY: tags
|
.PHONY: tags
|
||||||
|
|
||||||
|
# The rules below are only used when bootstrapping new propellor
|
||||||
|
# installations; propellor contains equivilant haksell code.
|
||||||
|
|
||||||
|
build: dist/setup-config
|
||||||
|
@if ! $(CABAL) build; then $(CABAL) configure; $(CABAL) build; fi
|
||||||
|
@ln -sf dist/build/propellor-config/propellor-config propellor
|
||||||
|
|
||||||
|
dist/setup-config: propellor.cabal
|
||||||
|
@if [ "$(CABAL)" = ./Setup ]; then ghc --make Setup; fi
|
||||||
|
@$(CABAL) configure
|
||||||
|
|
|
@ -4,6 +4,7 @@ propellor (2.2.0) UNRELEASED; urgency=medium
|
||||||
improve process name visible in ps.
|
improve process name visible in ps.
|
||||||
* Add shebang to cron.daily etc files.
|
* Add shebang to cron.daily etc files.
|
||||||
* Some changes to tor configuration, minor API change.
|
* Some changes to tor configuration, minor API change.
|
||||||
|
* Propellor now builds itself without needing the Makefile.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 16 Feb 2015 19:00:48 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 16 Feb 2015 19:00:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ Library
|
||||||
Propellor.Types.Result
|
Propellor.Types.Result
|
||||||
Propellor.Types.CmdLine
|
Propellor.Types.CmdLine
|
||||||
Other-Modules:
|
Other-Modules:
|
||||||
|
Propellor.Bootstrap
|
||||||
Propellor.Git
|
Propellor.Git
|
||||||
Propellor.Gpg
|
Propellor.Gpg
|
||||||
Propellor.Spin
|
Propellor.Spin
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
module Propellor.Bootstrap (
|
||||||
|
buildPropellor
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Propellor
|
||||||
|
import Utility.SafeCommand
|
||||||
|
|
||||||
|
import System.Posix.Files
|
||||||
|
|
||||||
|
buildPropellor :: IO ()
|
||||||
|
buildPropellor = unlessM (actionMessage "Propellor build" build) $
|
||||||
|
errorMessage "Propellor build failed!"
|
||||||
|
|
||||||
|
-- Build propellor using cabal, and symlink propellor to where cabal
|
||||||
|
-- leaves the built binary.
|
||||||
|
--
|
||||||
|
-- For speed, only runs cabal configure when it's not been run before.
|
||||||
|
-- If the build fails cabal may need to have configure re-run.
|
||||||
|
build :: IO Bool
|
||||||
|
build = catchBoolIO $ do
|
||||||
|
make "dist/setup-config" ["propellor.cabal"] $
|
||||||
|
cabal ["configure"]
|
||||||
|
unlessM (cabal ["build"]) $ do
|
||||||
|
void $ cabal ["configure"]
|
||||||
|
unlessM (cabal ["build"]) $
|
||||||
|
error "cabal build failed"
|
||||||
|
nukeFile "propellor"
|
||||||
|
createSymbolicLink "dist/build/propellor-config/propellor-config" "propellor"
|
||||||
|
return True
|
||||||
|
|
||||||
|
make :: FilePath -> [FilePath] -> IO Bool -> IO ()
|
||||||
|
make dest srcs builder = do
|
||||||
|
dt <- getmtime dest
|
||||||
|
st <- mapM getmtime srcs
|
||||||
|
when (dt == Nothing || any (> dt) st) $
|
||||||
|
unlessM builder $
|
||||||
|
error $ "failed to make " ++ dest
|
||||||
|
where
|
||||||
|
getmtime = catchMaybeIO . getModificationTime
|
||||||
|
|
||||||
|
cabal :: [String] -> IO Bool
|
||||||
|
cabal = boolSystem "cabal" . map Param
|
|
@ -12,6 +12,7 @@ import qualified Network.BSD
|
||||||
import Propellor
|
import Propellor
|
||||||
import Propellor.Gpg
|
import Propellor.Gpg
|
||||||
import Propellor.Git
|
import Propellor.Git
|
||||||
|
import Propellor.Bootstrap
|
||||||
import Propellor.Spin
|
import Propellor.Spin
|
||||||
import Propellor.Types.CmdLine
|
import Propellor.Types.CmdLine
|
||||||
import qualified Propellor.Property.Docker as Docker
|
import qualified Propellor.Property.Docker as Docker
|
||||||
|
@ -31,6 +32,7 @@ usage h = hPutStrLn h $ unlines
|
||||||
, " propellor --edit field context"
|
, " propellor --edit field context"
|
||||||
, " propellor --list-fields"
|
, " propellor --list-fields"
|
||||||
, " propellor --merge"
|
, " propellor --merge"
|
||||||
|
, " propellor --build"
|
||||||
]
|
]
|
||||||
|
|
||||||
usageError :: [String] -> IO a
|
usageError :: [String] -> IO a
|
||||||
|
@ -128,19 +130,16 @@ unknownhost h hosts = errorMessage $ unlines
|
||||||
]
|
]
|
||||||
|
|
||||||
buildFirst :: CmdLine -> IO () -> IO ()
|
buildFirst :: CmdLine -> IO () -> IO ()
|
||||||
buildFirst cmdline next = ifM (doesFileExist "Makefile")
|
buildFirst cmdline next = do
|
||||||
( do
|
oldtime <- getmtime
|
||||||
oldtime <- getmtime
|
buildPropellor
|
||||||
ifM (actionMessage "Propellor build" $ boolSystem "make" [Param "build"])
|
newtime <- getmtime
|
||||||
( do
|
if newtime == oldtime
|
||||||
newtime <- getmtime
|
then next
|
||||||
if newtime == oldtime
|
else void $ boolSystem "./propellor"
|
||||||
then next
|
[ Param "--continue"
|
||||||
else void $ boolSystem "./propellor" [Param "--continue", Param (show cmdline)]
|
, Param (show cmdline)
|
||||||
, errorMessage "Propellor build failed!"
|
]
|
||||||
)
|
|
||||||
, next
|
|
||||||
)
|
|
||||||
where
|
where
|
||||||
getmtime = catchMaybeIO $ getModificationTime "propellor"
|
getmtime = catchMaybeIO $ getModificationTime "propellor"
|
||||||
|
|
||||||
|
@ -155,10 +154,12 @@ updateFirst cmdline next = ifM hasOrigin (updateFirst' cmdline next, next)
|
||||||
|
|
||||||
updateFirst' :: CmdLine -> IO () -> IO ()
|
updateFirst' :: CmdLine -> IO () -> IO ()
|
||||||
updateFirst' cmdline next = ifM fetchOrigin
|
updateFirst' cmdline next = ifM fetchOrigin
|
||||||
( ifM (actionMessage "Propellor build" $ boolSystem "make" [Param "build"])
|
( do
|
||||||
( void $ boolSystem "./propellor" [Param "--continue", Param (show cmdline)]
|
buildPropellor
|
||||||
, errorMessage "Propellor build failed!"
|
void $ boolSystem "./propellor"
|
||||||
)
|
[ Param "--continue"
|
||||||
|
, Param (show cmdline)
|
||||||
|
]
|
||||||
, next
|
, next
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Propellor.Message
|
import Propellor.Message
|
||||||
|
import Propellor.Bootstrap
|
||||||
import Utility.UserInfo
|
import Utility.UserInfo
|
||||||
import Utility.Monad
|
import Utility.Monad
|
||||||
import Utility.Process
|
import Utility.Process
|
||||||
|
@ -91,13 +92,10 @@ wrapper args propellordir propellorbin = do
|
||||||
warnoutofdate propellordir True
|
warnoutofdate propellordir True
|
||||||
buildruncfg = do
|
buildruncfg = do
|
||||||
changeWorkingDirectory propellordir
|
changeWorkingDirectory propellordir
|
||||||
ifM (boolSystem "make" [Param "build"])
|
buildPropellor
|
||||||
( do
|
putStrLn ""
|
||||||
putStrLn ""
|
putStrLn ""
|
||||||
putStrLn ""
|
chain
|
||||||
chain
|
|
||||||
, error "Propellor build failed."
|
|
||||||
)
|
|
||||||
chain = do
|
chain = do
|
||||||
(_, _, _, pid) <- createProcess (proc propellorbin args)
|
(_, _, _, pid) <- createProcess (proc propellorbin args)
|
||||||
exitWith =<< waitForProcess pid
|
exitWith =<< waitForProcess pid
|
||||||
|
|
Loading…
Reference in New Issue