fix DistributionUpdate incompatability

Since DistributionUpdate builds an Annex object, the new relative paths
code caused it to make a git object with paths like ../lib/downloads.
However, it actually runs the system's installed git-annex, and that old
version did not like being run in this situation. Probably it was buggy.

Fixed by chdir to the downloads repo before doing anything else.
This commit is contained in:
Joey Hess 2015-01-13 12:43:22 -04:00
parent 211e2bc78f
commit 596b8e1e04

View file

@ -22,6 +22,7 @@ import Git.Command
import Data.Default import Data.Default
import Data.Time.Clock import Data.Time.Clock
import Data.Char import Data.Char
import System.Posix.Directory
-- git-annex distribution signing key (for Joey Hess) -- git-annex distribution signing key (for Joey Hess)
signingKey :: String signingKey :: String
@ -49,10 +50,12 @@ autobuilds =
main :: IO () main :: IO ()
main = do main = do
version <- liftIO getChangelogVersion
repodir <- getRepoDir repodir <- getRepoDir
changeWorkingDirectory repodir
updated <- catMaybes <$> mapM (getbuild repodir) autobuilds updated <- catMaybes <$> mapM (getbuild repodir) autobuilds
state <- Annex.new =<< Git.Construct.fromPath repodir state <- Annex.new =<< Git.Construct.fromPath "."
Annex.eval state (makeinfos updated) Annex.eval state (makeinfos updated version)
-- Download a build from the autobuilder, and return its version. -- Download a build from the autobuilder, and return its version.
-- It's very important that the version matches the build, otherwise -- It's very important that the version matches the build, otherwise
@ -91,26 +94,24 @@ getbuild repodir (url, f) = do
return $ if null bv || any (not . versionchar) bv then Nothing else Just bv return $ if null bv || any (not . versionchar) bv then Nothing else Just bv
versionchar c = isAlphaNum c || c == '.' || c == '-' versionchar c = isAlphaNum c || c == '.' || c == '-'
makeinfos :: [(FilePath, Version)] -> Annex () makeinfos :: [(FilePath, Version)] -> Version -> Annex ()
makeinfos updated = do makeinfos updated version = do
mapM_ (\f -> inRepo $ runBool [Param "annex", Param "add", File f]) (map fst updated) mapM_ (\f -> inRepo $ runBool [Param "annex", Param "add", File f]) (map fst updated)
version <- liftIO getChangelogVersion
void $ inRepo $ runBool void $ inRepo $ runBool
[ Param "commit" [ Param "commit"
, Param "-a" , Param "-a"
, Param "-m" , Param "-m"
, Param $ "publishing git-annex " ++ version , Param $ "publishing git-annex " ++ version
] ]
basedir <- liftIO getRepoDir
now <- liftIO getCurrentTime now <- liftIO getCurrentTime
liftIO $ putStrLn $ "building info files in " ++ basedir liftIO $ putStrLn $ "building info files"
forM_ updated $ \(f, bv) -> do forM_ updated $ \(f, bv) -> do
v <- lookupFile (basedir </> f) v <- lookupFile f
case v of case v of
Nothing -> noop Nothing -> noop
Just k -> whenM (inAnnex k) $ do Just k -> whenM (inAnnex k) $ do
liftIO $ putStrLn f liftIO $ putStrLn f
let infofile = basedir </> f ++ ".info" let infofile = f ++ ".info"
liftIO $ writeFile infofile $ show $ GitAnnexDistribution liftIO $ writeFile infofile $ show $ GitAnnexDistribution
{ distributionUrl = mkUrl f { distributionUrl = mkUrl f
, distributionKey = k , distributionKey = k
@ -120,7 +121,7 @@ makeinfos updated = do
} }
void $ inRepo $ runBool [Param "add", File infofile] void $ inRepo $ runBool [Param "add", File infofile]
signFile infofile signFile infofile
signFile (basedir </> f) signFile f
void $ inRepo $ runBool void $ inRepo $ runBool
[ Param "commit" [ Param "commit"
, Param "-m" , Param "-m"
@ -137,14 +138,14 @@ makeinfos updated = do
-- Check for out of date info files. -- Check for out of date info files.
infos <- liftIO $ filter (".info" `isSuffixOf`) infos <- liftIO $ filter (".info" `isSuffixOf`)
<$> dirContentsRecursive (basedir </> "git-annex") <$> dirContentsRecursive "git-annex"
ds <- liftIO $ forM infos (readish <$$> readFile) ds <- liftIO $ forM infos (readish <$$> readFile)
let dis = zip infos ds let dis = zip infos ds
let ood = filter (outofdate version) dis let ood = filter outofdate dis
unless (null ood) $ unless (null ood) $
error $ "Some info files are out of date: " ++ show (map fst ood) error $ "Some info files are out of date: " ++ show (map fst ood)
where where
outofdate version (_, md) = case md of outofdate (_, md) = case md of
Nothing -> True Nothing -> True
Just d -> distributionVersion d /= version Just d -> distributionVersion d /= version