debian upgrade handling

The /usr/bin/propellor wrapper will warn when ~/.propellor/ is out of date
and a newer version is available from origin.
This commit is contained in:
Joey Hess 2014-08-19 15:22:42 -04:00
parent 527ae1dc20
commit 1830f501ee
4 changed files with 34 additions and 19 deletions

View File

@ -29,6 +29,7 @@ install:
git add . \
&& git commit -m "distributed version of propellor" \
&& git bundle create $(DESTDIR)/usr/src/propellor/propellor.git master HEAD
&& git show-ref HEAD --hash > $(DESTDIR)/usr/src/propellor/head
rm -rf dist/gittmp
clean:

View File

@ -11,12 +11,3 @@ Note that upgrading the propellor package will not update your
to the source, or may need to adapt your config.hs to work with the new
version of propellor. Instead, if your ~/.propellor/ is from an older
version of propellor, /usr/bin/propellor will warn that it's out of date.
You can `git pull upstream` in your repository to update to the
current upstream source, as distributed in the Debian package.
In older versions of propellor, the upstream remote was pointed at
the repository on github, so you may want to change it to point
to the repository included in the Debian package:
git config remote.upstream.url /usr/src/propellor/propellor.git

4
debian/changelog vendored
View File

@ -2,8 +2,10 @@ propellor (0.8.3) UNRELEASED; urgency=medium
* The Debian package now includes a single-revision git repository in
/usr/src/propellor/, and ~/.propellor/ is set up to use this repository as
its "upstream" remote. This avoids relying on the security of the github
its origin remote. This avoids relying on the security of the github
repository when using the Debian package.
* The /usr/bin/propellor wrapper will warn when ~/.propellor/ is out of date
and a newer version is available from origin.
* Included the config.hs symlink to config-simple.hs in the cabal and Debian
packages.

View File

@ -19,6 +19,7 @@ import Utility.Monad
import Utility.Process
import Utility.SafeCommand
import Utility.Directory
import Utility.Exception
import Control.Monad
import Control.Monad.IfElse
@ -27,9 +28,10 @@ import System.FilePath
import System.Environment (getArgs)
import System.Exit
import System.Posix.Directory
import System.IO
localrepo :: FilePath
localrepo = "/usr/src/propellor/propellor.git"
distrepo :: FilePath
distrepo = "/usr/src/propellor/propellor.git"
-- Using the github mirror of the main propellor repo because
-- it is accessible over https for better security.
@ -46,19 +48,34 @@ main = do
wrapper :: [String] -> FilePath -> FilePath -> IO ()
wrapper args propellordir propellorbin = do
unlessM (doesDirectoryExist propellordir) $
makeRepo
ifM (doesDirectoryExist propellordir)
( checkRepo
, makeRepo
)
buildruncfg
where
chain = do
(_, _, _, pid) <- createProcess (proc propellorbin args)
exitWith =<< waitForProcess pid
makeRepo = do
putStrLn $ "Setting up your propellor repo in " ++ propellordir
putStrLn ""
localexists <- doesFileExist localrepo <||> doesDirectoryExist localrepo
let repo = if localexists then localrepo else netrepo
distexists <- doesFileExist distrepo <||> doesDirectoryExist distrepo
let repo = if distexists then distrepo else netrepo
void $ boolSystem "git" [Param "clone", File repo, File propellordir]
disthead = propellordir </> "head"
checkRepo = whenM (doesFileExist disthead) $ do
head <- readFile disthead
changeWorkingDirectory propellordir
headknown <- catchMaybeIO $
withQuietOutput createProcessSuccess $
proc "git" ["log", head]
when (headknown == Nothing)
warnoutofdate
warnoutofdate = do
let n = hPutStrLn stderr
n ("** Your " ++ propellordir ++ " is out of date..")
n (" A newer upstream version is available in " ++ distrepo)
n (" To merge it, run eg: git pull origin master")
buildruncfg = do
changeWorkingDirectory propellordir
ifM (boolSystem "make" [Param "build"])
@ -68,3 +85,7 @@ wrapper args propellordir propellorbin = do
chain
, error "Propellor build failed."
)
chain = do
(_, _, _, pid) <- createProcess (proc propellorbin args)
exitWith =<< waitForProcess pid