Hi all,

Here are a few build-system simplifications.  With the addition of one
file + franchise (see darcs get http://darcs.net/repos/franchise),
this allows me to cross-compile windows binaries using wine, by
eliminating the dependency on the presence of sh, gnu make or perl.
The franchise build isn't yet close to on par with the autoconf/make
build, since I haven't finished teaching it to build the docs, the
ChangeLog, the AUTHORS file, to run any of the test suite, use
libcurl, etc.  But the testing functionality is there, it uses libwww
if it's present, uses HTTP if it's present, checks for native libz or
haskell zlib package, etc.  So the functionality is there to finish
this up.

This particular set of patches just cleans up the build to be less
reliant on autoconf.  It also probably breaks the ghc 6.4 build, so
it's probably better for a post-2.0.3 kind of change (so I'm not
pushing this just yet).

David

Thu Sep 18 11:01:44 EDT 2008  David Roundy <[EMAIL PROTECTED]>
  * eliminate autogeneration of Workaround.hs

Thu Sep 18 14:20:15 EDT 2008  David Roundy <[EMAIL PROTECTED]>
  * make various autoconf simplifications.

New patches:

[eliminate autogeneration of Workaround.hs
David Roundy <[EMAIL PROTECTED]>**20080918150144
 Ignore-this: edf61a7f140ff8bfaad1e734fd16536c
] hunk ./GNUmakefile 45
 MODULES_AUTOCONF :=\
 	Autoconf.lhs \
 	Context.hs \
-        Workaround.hs \
 
 MODULES_GENERAL :=\
 	ThisVersion.lhs \
hunk ./GNUmakefile 56
 	Printer.lhs	\
 	RegChars.lhs \
 	SHA1.lhs Ssh.hs UTF8.lhs	\
+	Workaround.hs \
 
 MODULES_CRYPT := SHA256.hs
 
hunk ./GNUmakefile 505
 
 distclean:	clean
 	rm -rf config.status config.log autoconf.mk config.cache autom4te.cache
-	rm -f doc/manual/darcs.ps doc/manual/darcs.pdf doc/manual/patch-theory.pdf src/Autoconf.lhs Workaround.hs darcs.idv
+	rm -f doc/manual/darcs.ps doc/manual/darcs.pdf doc/manual/patch-theory.pdf src/Autoconf.lhs darcs.idv
 	rm -f src/ThisVersion.lhs tools/cgi/README tools/cgi/darcs.cgi tools/cgi/cgi.conf
 	rm -f config.command
 
hunk ./aclocal.m4 103
   ])
 ])
 
-# INIT_WORKAROUND
-# ---------------
-# Initialize src/Workaround.hs module.
-AC_DEFUN([INIT_WORKAROUND],[
-rm -f src/Workaround.hs.beginning src/Workaround.hs.ending
-touch src/Workaround.hs.ending
-cat << \EOF > src/Workaround.hs.prefix
-{-# OPTIONS -w #-}
-{- Workaround.hs
-
-This file was created automatically by configure.  We disable warnings to
-avoid issues with duplicate imports.
-
--}
-
-module Workaround(
-EOF
-cat << \EOF > src/Workaround.hs.beginning
- ) where
-
-EOF
-])
-
-# OUTPUT_WORKAROUND
-# -----------------
-# Create the src/Workaround.hs module.
-AC_DEFUN([OUTPUT_WORKAROUND],[
-cat src/Workaround.hs.prefix src/Workaround.hs.beginning src/Workaround.hs.ending > src/Workaround.hs
-rm -f src/Workaround.hs.beginning src/Workaround.hs.ending src/Workaround.hs.prefix
-])
-
-# IMPORT_WORKAROUND(CODE)
-# -----------------------
-# Import a module into src/Workaround.hs
-AC_DEFUN([IMPORT_WORKAROUND],[
-cat << \EOF >> src/Workaround.hs.beginning
-$1
-EOF
-])
-
-# EXPORT_WORKAROUND(CODE)
-# -----------------------
-# Export from src/Workaround.hs
-AC_DEFUN([EXPORT_WORKAROUND],[
-cat << \EOF >> src/Workaround.hs.prefix
-$1
-EOF
-])
-
-# CODE_WORKAROUND(CODE)
-# ---------------------
-# Import a module into src/Workaround.hs
-AC_DEFUN([CODE_WORKAROUND],[
-cat << \EOF >> src/Workaround.hs.ending
-$1
-EOF
-])
-
-# WORKAROUND_POSIXSIGNALS(IMPORTS)
-# -----------------------
-# Work around missing POSIX signals code.
-AC_DEFUN([WORKAROUND_POSIXSIGNALS],[
-  EXPORT_WORKAROUND([$1])
-  GHC_CHECK_MODULE(System.Posix.Signals($1), unix, undefined,
-    [IMPORT_WORKAROUND([import System.Posix.Signals($1)])],
-    GHC_CHECK_MODULE(Posix($1), util, undefined,
-      [IMPORT_WORKAROUND([import Posix($1)])],
-      [CODE_WORKAROUND([[
-
--- Dummy implementation of POSIX signals
-
-data Handler = Default | Ignore | Catch (IO ())
-type Signal = Int
-
-installHandler :: Signal -> Handler -> Maybe () -> IO ()
-installHandler _ _ _ = return ()
-
-raiseSignal :: Signal -> IO ()
-raiseSignal _ = return ()
-
-sigINT, {- sigKILL, -} sigHUP, {- sigQUIT, -} sigABRT, sigALRM, sigTERM, sigPIPE :: Signal
-sigINT = 0
--- not used: sigKILL = 0
-sigHUP = 0
--- not used: sigQUIT = 0
-sigABRT = 0
-sigTERM = 0
-sigPIPE = 0
-sigALRM = 0
-
--- not used: raiseSignal :: Signal -> IO ()
--- not used: raiseSignal _ = return ()
-
-]])]
-    )
-  )
-])
-
-# WORKAROUND_bracketOnError
-# -----------------------
-# Work around missing bracketOnError
-AC_DEFUN([WORKAROUND_bracketOnError],[
-  EXPORT_WORKAROUND([           bracketOnError, ])
-  GHC_CHECK_MODULE(Control.Exception( bracketOnError ), base ,
-    bracketOnError (return ()) (const $ return ()) (const $ return ()),
-    [IMPORT_WORKAROUND([import Control.Exception( bracketOnError )])],
-    [IMPORT_WORKAROUND([import qualified Control.Exception( catch, throw, block, unblock )])
-     CODE_WORKAROUND([[
-
--- | Like bracket, but only performs the final action if there was an
--- exception raised by the in-between computation.
--- From GHC 6.6 (with twiddling for qualified block, catch, etc)
-bracketOnError
-	:: IO a		-- ^ computation to run first (\"acquire resource\")
-	-> (a -> IO b)  -- ^ computation to run last (\"release resource\")
-	-> (a -> IO c)	-- ^ computation to run in-between
-	-> IO c		-- returns the value from the in-between computation
-bracketOnError before after thing =
-  Control.Exception.block (do
-    a <- before
-    Control.Exception.catch
-	(Control.Exception.unblock (thing a))
-	(\e -> do { after a; Control.Exception.throw e })
-  )
-]])
-])
-])
-
-# WORKAROUND_createLink
-# -----------------------
-# Work around missing POSIX createLink code.
-AC_DEFUN([WORKAROUND_createLink],[
-  EXPORT_WORKAROUND([           createLink, ])
-  GHC_CHECK_MODULE(System.Posix.Files( createLink ), unix, createLink "a" "b",
-    [IMPORT_WORKAROUND([import System.Posix.Files( createLink )])],
-    GHC_CHECK_MODULE(Posix( createLink ), util, createLink "a" "b",
-      [IMPORT_WORKAROUND([import Posix( createLink )])],
-      [CODE_WORKAROUND([[
-
--- Dummy implementation of createLink.
-
-createLink :: FilePath -> FilePath -> IO ()
-createLink _ _ = fail "Dummy create link error should be caught."
-]])]
-    )
-  )
-])
-
-# WORKAROUND_createDirectoryIfMissing
-# ------------------------------
-# Work around missing createDirectoryIfMissing.
-AC_DEFUN([WORKAROUND_createDirectoryIfMissing],[
-  EXPORT_WORKAROUND([           createDirectoryIfMissing, ])
-  AC_MSG_CHECKING([createDirectoryIfMissing])
-  TRY_COMPILE_GHC([
-import System.Directory(createDirectoryIfMissing)
-main = createDirectoryIfMissing True ""
-    ],
-    [AC_MSG_RESULT([has createDirectoryIfMissing])
-     IMPORT_WORKAROUND([import System.Directory(createDirectoryIfMissing)])],
-    [AC_MSG_RESULT([doesn't have createDirectoryIfMissing])
-      IMPORT_WORKAROUND([import System.Directory ( doesDirectoryExist, createDirectory )])
-      CODE_WORKAROUND([[
-createDirectoryIfMissing
-  :: Bool     -- ^ Create its parents too?
-  -> FilePath -- ^ The path to the directory you want to make
-  -> IO ()
-createDirectoryIfMissing parents file = do
-  b <- doesDirectoryExist file
-  case (b,parents, file) of
-    (_,     _, "") -> return ()
-    (True,  _,  _) -> return ()
-    (_,  True,  _) -> mapM_ (createDirectoryIfMissing False) (tail (pathParents file))
-    (_, False,  _) -> createDirectory file
- where    pathParents :: FilePath -> [FilePath]
-          pathParents p =
-              root'' : map ((++) root') (dropEmptyPath $ inits path')
-              where
-#ifdef WIN32
-                 (root,path) = case break (== ':') p of
-                    (rel,    "") -> ("",rel)
-                    (drv,_:rel) -> (drv++":",rel)
-#else
-                 (root,path) = ("",p)
-#endif
-                 (root',root'',path') = case path of
-                   (c:path'') | isPathSeparator c -> (root++[pathSeparator],root++[pathSeparator],path'')
-                   _                              -> (root                 ,root++"."            ,path)
-          
-                 dropEmptyPath ("":paths) = paths
-                 dropEmptyPath paths      = paths
-          
-                 inits :: String -> [String]
-                 inits [] =  [""]
-                 inits cs =
-                   case pre of
-                     "."  -> inits suf
-                     ".." -> map (joinFileName pre) (dropEmptyPath $ inits suf)
-                     _    -> "" : map (joinFileName pre) (inits suf)
-                   where
-                     (pre,suf) = case break isPathSeparator cs of
-                        (pre',"")     -> (pre', "")
-                        (pre',_:suf') -> (pre',suf')
-                 isPathSeparator :: Char -> Bool
-                 isPathSeparator ch = ch == pathSeparator || ch == '/'
-                 pathSeparator :: Char
-#ifdef WIN32
-                 pathSeparator = '\\'
-#else
-                 pathSeparator = '/'
-#endif
-                 joinFileName :: String -> String -> FilePath
-                 joinFileName ""  fname = fname
-                 joinFileName "." fname = fname
-                 joinFileName dir ""    = dir
-                 joinFileName dir fname
-                   | isPathSeparator (last dir) = dir++fname
-                   | otherwise                  = dir++pathSeparator:fname
-      ]])
-    ]
-  )
-])
-
-# WORKAROUND_getCurrentDirectory
-# ------------------------------
-# Work around getCurrentDirectory that uses '\\' rather than '/'.
-AC_DEFUN([WORKAROUND_getCurrentDirectory],[
-  EXPORT_WORKAROUND([           getCurrentDirectory, ])
-  AC_MSG_CHECKING([getCurrentDirectory])
-  TRY_RUN_GHC([
-import System.Directory(getCurrentDirectory, setCurrentDirectory)
-main = do setCurrentDirectory "src"
-          d <- getCurrentDirectory
-          case reverse $ take 4 $ reverse d of
-              "/src" -> return ()
-    ],
-    [AC_MSG_RESULT([uses /])
-     IMPORT_WORKAROUND([import System.Directory(getCurrentDirectory)])]
-     GHC_SEPARATOR='/',
-    [AC_MSG_RESULT([uses \\])
-      IMPORT_WORKAROUND([import qualified System.Directory(getCurrentDirectory)])
-      GHC_SEPARATOR='\\'
-      CODE_WORKAROUND([[
-{-
-System.Directory.getCurrentDirectory returns a path with backslashes in it
-under windows, and some of the code gets confused by that, so we override
-getCurrentDirectory and translates '\\' to '/'
--}
-
-getCurrentDirectory :: IO FilePath
-getCurrentDirectory = do d <- System.Directory.getCurrentDirectory
-                         return $ map rb d
-    where rb '\\' = '/'
-          rb c = c
-      ]])
-    ]
-  )
-])
-
-# WORKAROUND_renameFile
-# -----------------------
-# Work around buggy renameFile.
-AC_DEFUN([WORKAROUND_renameFile],[
-  EXPORT_WORKAROUND([           renameFile, ])
-  AC_MSG_CHECKING([renameFile])
-  TRY_RUN_GHC([
-import System.Directory ( renameFile )
-
-main = do writeFile "conftest.data" "orig_data"
-          writeFile "conftest.newdata" "new_data"
-          renameFile "conftest.newdata" "conftest.data"
-    ],
-    [AC_MSG_RESULT([okay])
-     IMPORT_WORKAROUND([import System.Directory ( renameFile )])],
-    AC_MSG_RESULT([buggy!])
-    IMPORT_WORKAROUND([import qualified System.Directory( renameFile, removeFile )])
-    IMPORT_WORKAROUND([import qualified System.IO.Error])
-    IMPORT_WORKAROUND([import qualified Control.Exception ( block )])
-    CODE_WORKAROUND([
-{-
-System.Directory.renameFile incorrectly fails when the new file already
-exists.  This code works around that bug at the cost of losing atomic
-writes.
--}
-
-renameFile :: FilePath -> FilePath -> IO ()
-renameFile old new = Control.Exception.block $
-   do System.Directory.removeFile new
-        `System.IO.Error.catch`
-         (\e -> if System.IO.Error.isDoesNotExistError e
-                   then return ()
-                   else System.IO.Error.ioError e)
-      System.Directory.renameFile old new
-     ])
-  )
-])
-
-# WORKAROUND_fileModes
-# --------------------
-# Figure out how to set unix permissions on a file (or creates a dummy
-# function for this).
-
-AC_DEFUN([WORKAROUND_fileModes],[
-  EXPORT_WORKAROUND([           fileMode, getFileStatus, setFileMode, ])
-  GHC_CHECK_MODULE(System.Posix.Files( fileMode, getFileStatus, setFileMode ), unix, getFileStatus "",
-    IMPORT_WORKAROUND([import System.Posix.Files(fileMode,getFileStatus,setFileMode)]),
-    CODE_WORKAROUND([
-fileMode :: () -> ()
-fileMode _ = ()
-getFileStatus :: FilePath -> IO ()
-getFileStatus _ = return ()
-setFileMode :: FilePath -> () -> IO ()
-setFileMode _ _ = return ()
-])
-  )
-])
-
-# WORKAROUND_executable
-# --------------------
-# Figure out how to make a file executable (or test if it is).
-
-AC_DEFUN([WORKAROUND_executable],[
-  EXPORT_WORKAROUND([           setExecutable, ])
-  GHC_CHECK_MODULE(System.Posix.Files( fileMode, getFileStatus, setFileMode, setFileCreationMask ),
-                   unix, getFileStatus "",
-    IMPORT_WORKAROUND([
-import System.Posix.Files (fileMode,getFileStatus, setFileMode, nullFileMode,
-                           setFileCreationMask,
-                           ownerReadMode, ownerWriteMode, ownerExecuteMode,
-                           groupReadMode, groupWriteMode, groupExecuteMode,
-                           otherReadMode, otherWriteMode, otherExecuteMode)
-import Data.Bits ( (.&.), (.|.), complement )
-
-setExecutable :: FilePath -> Bool -> IO ()
-setExecutable f ex =
-  do st <- getFileStatus f
-     umask <- setFileCreationMask 0
-     setFileCreationMask umask
-     let rw = fileMode st .&.
-              (ownerReadMode .|. ownerWriteMode .|.
-               groupReadMode .|. groupWriteMode .|.
-               otherReadMode .|. otherWriteMode)
-         total = if ex then rw .|.
-                           ((ownerExecuteMode .|. groupExecuteMode .|. otherExecuteMode)
-                            .&. complement umask)
-                       else rw
-     setFileMode f total
-]),
-    CODE_WORKAROUND([
-setExecutable :: FilePath -> Bool -> IO ()
-setExecutable _ _ = return ()
-])
-  )
-])
-
-# WORKAROUND_openFd
-# -----------------------
-# Work around changing openFd function
-AC_DEFUN([WORKAROUND_openFd],[
-  EXPORT_WORKAROUND([           openFd, ])
-  AC_MSG_CHECKING([GHC.Handle.openFd])
-  TRY_RUN_GHC([
-import GHC.Handle ( openFd )
-import IO ( IOMode(..))
-
-main = openFd 1 Nothing "stdout" WriteMode True False
-    ],
-     AC_MSG_RESULT([okay])
-     IMPORT_WORKAROUND([import GHC.Handle( openFd )]),
-     AC_MSG_RESULT([NOT old API])
-     AC_MSG_CHECKING([GHC.Handle.openFd new API])
-     TRY_RUN_GHC([
-import GHC.Handle ( openFd )
-import IO ( IOMode(..))
-
-main = openFd 1 Nothing False "stdout" WriteMode True
-      ],
-      AC_MSG_RESULT([okay])
-      IMPORT_WORKAROUND([import qualified GHC.Handle ( openFd )
-import System.IO ( Handle, IOMode )
-import System.Posix.Internals ( FDType )
-])
-      CODE_WORKAROUND([[
-{-
-Work around change in the GHC.Handle.openFd API.
--}
-openFd :: Int -> Maybe FDType -> FilePath -> IOMode -> Bool -> Bool -> IO Handle
-openFd fd x y z a b = GHC.Handle.openFd fd x b y z a
-        ]]),
-       AC_MSG_RESULT([NOT 'new' API])
-       AC_MSG_CHECKING([GHC.Handle.fdToHandle' API])
-       TRY_RUN_GHC([
-import GHC.Handle ( fdToHandle' )
-import IO ( IOMode(..) )
-
-main = fdToHandle' 1 Nothing False "stdout" WriteMode True
-       ],
-       AC_MSG_RESULT([okay])
-       IMPORT_WORKAROUND([import qualified GHC.Handle ( fdToHandle' )
-import System.IO ( Handle, IOMode )
-import System.Posix.Internals ( FDType )
-])
-       CODE_WORKAROUND([[
-{-
-Work around renaming of GHC.Handle.openFd and change in its API.
--}
-openFd :: Int -> Maybe FDType -> FilePath -> IOMode -> Bool -> Bool -> IO Handle
-openFd fd x y z a b = GHC.Handle.fdToHandle' (fromIntegral fd) x b y z a
-        ]]),
-       AC_MSG_RESULT([failed])
-       AC_MSG_ERROR([Couldnt figure out how to call GHC.Handle.openFd!])
-    )
-  )
-)])
-
-
-
hunk ./configure.ac 124
                  AC_MSG_WARN([Unable to compile with threaded runtime!])
                  GHCFLAGS=$MYOLDGHCFLAGS])])
 
-INIT_WORKAROUND
-
-dnl Figure out how to convert a file descriptor to a Handle
-
-WORKAROUND_openFd
-
-dnl Handle posix signals nicely:
-
-WORKAROUND_POSIXSIGNALS([installHandler, raiseSignal, Handler(..), Signal,
-                         sigINT, sigHUP, sigABRT, sigALRM, sigTERM, sigPIPE,])
-
 AC_CHECK_HEADERS([siginfo.h])
 
 dnl Look for Text.Regex
hunk ./configure.ac 232
 if test "$SYS" = "windows"; then
   GHC_CHECK_MODULE(System.Random( randomIO ), random, randomIO :: IO Int,,
                    AC_MSG_ERROR(Cannot find System.Random; try installing the Haskell package random?))
+else
+  dnl if we're not in windows, we need System.Posix.Files
+  GHC_CHECK_MODULE(System.Posix.Files, unix, undefined,,
+                   AC_MSG_ERROR(Cannot find System.Posix.Files; try installing the Haskell package unix?))
 fi
 
hunk ./configure.ac 238
-dnl Deal with systems on which getCurrentDirectory uses '\\' rather than '/':
-
-WORKAROUND_getCurrentDirectory
-AC_SUBST(GHC_SEPARATOR)
-
-dnl Deal with systems without createLink
-
-WORKAROUND_createLink
-
-dnl Deal with GHCs without createDirectoryIfMissing
-
-WORKAROUND_createDirectoryIfMissing
-
-dnl Handle systems with a buggy renameFile
-
-WORKAROUND_renameFile
-
-dnl Deal with systems without bracketWithError
-
-WORKAROUND_bracketOnError
-
-dnl Handle systems that don't do POSIX file modes
-
-WORKAROUND_fileModes
-
-WORKAROUND_executable
-
 dnl Make default to have optimizations on...
 
 AC_MSG_CHECKING([whether to optimize])
hunk ./configure.ac 629
 fi
 
 AC_DEFUN([AC_DATAROOTDIR_CHECKED])
-OUTPUT_WORKAROUND
+
 AC_CONFIG_FILES([autoconf.mk src/Autoconf.lhs
            tools/cgi/darcs.cgi tools/cgi/README tools/cgi/cgi.conf
 	   release/darcs.spec])
hunk ./src/Autoconf.lhs.in 74
 
 {-# INLINE path_separator #-}
 path_separator :: Char
-path_separator = '@GHC_SEPARATOR@'
+#ifdef WIN32
+path_separator = '\\'
+#else
+path_separator = '/'
+#endif
 
 {-# INLINE big_endian #-}
 big_endian :: Bool
hunk ./src/Darcs/Commands/Repair.lhs 21
 \subsection{darcs repair}
 \begin{code}
 module Darcs.Commands.Repair ( repair ) where
-import Workaround ( getCurrentDirectory, createDirectoryIfMissing )
+import Workaround ( getCurrentDirectory )
+import System.Directory ( createDirectoryIfMissing )
 import System.IO
 import System.Exit ( exitWith, ExitCode(..) )
 import Control.Monad ( when, unless )
hunk ./src/Darcs/External.hs 47
 import Foreign.Marshal.Alloc (allocaBytes)
 import Autoconf ( use_color )
 #endif
-import Workaround ( createLink, createDirectoryIfMissing )
+import System.Posix.Files ( createLink )
+import System.Directory ( createDirectoryIfMissing )
 
 import Darcs.Flags ( DarcsFlag( SignAs, Sign, SignSSL, NoLinks,
                                 Verify, VerifySSL ) )
hunk ./src/Darcs/Lock.lhs 53
 import Workaround ( renameFile )
 import Darcs.Utils ( withCurrentDirectory, maybeGetEnv, firstJustIO )
 import Control.Monad ( when )
-import Workaround ( fileMode, getFileStatus, setFileMode )
 
 import Darcs.URL ( is_relative )
 import Darcs.Utils ( catchall, add_to_error_loc )
hunk ./src/Darcs/Lock.lhs 67
 import Darcs.Global ( atexit, darcsdir )
 import Darcs.Compat ( mk_stdout_temp, canonFilename, maybeRelink,
                 atomic_create, sloppy_atomic_create )
-import System.Posix.Files ( getSymbolicLinkStatus, isDirectory )
+import System.Posix.Files ( getSymbolicLinkStatus, isDirectory,
+                            fileMode, getFileStatus, setFileMode )
 import System.Posix ( sleep )
 #include "impossible.h"
 
hunk ./src/Darcs/Repository/Cache.lhs 27
 import FastPackedString ( PackedString, unpackPS, gzWriteFilePS, lengthPS,
                           linesPS, dropPS )
 import SHA1 ( sha1PS )
-import Workaround ( createLink, createDirectoryIfMissing )
+import System.Posix.Files ( createLink )
+import System.Directory ( createDirectoryIfMissing )
 
 import Darcs.External ( gzFetchFilePS, fetchFilePS, speculateFileOrUrl, copyFileOrUrl,
                         Cachable( Cachable ) )
hunk ./src/Darcs/Repository/Checkpoint.lhs 1
+
 %  Copyright (C) 2002-2005 David Roundy
 %
 %  This program is free software; you can redistribute it and/or modify
hunk ./src/Darcs/Repository/Checkpoint.lhs 33
                                      write_checkpoint_patch,
                                    ) where
 
-import System.Directory ( setCurrentDirectory )
-import Workaround ( getCurrentDirectory, createDirectoryIfMissing )
+import System.Directory ( setCurrentDirectory, createDirectoryIfMissing )
+import Workaround ( getCurrentDirectory )
 import System.IO.Unsafe ( unsafeInterleaveIO )
 import Data.Maybe ( listToMaybe, catMaybes )
 import Darcs.Hopefully ( PatchInfoAnd, hopefully, info )
hunk ./src/Darcs/Repository/DarcsRepo.lhs 60
                                     copy_patches
                                   ) where
 
-import System.Directory ( doesDirectoryExist )
-import Workaround ( renameFile, createDirectoryIfMissing )
+import System.Directory ( doesDirectoryExist, createDirectoryIfMissing )
+import Workaround ( renameFile )
 import Darcs.Utils ( clarify_errors )
 import Darcs.Progress ( debugMessage, beginTedious, endTedious, finishedOneIO )
 import Darcs.FilePathUtils ( absolute_dir )
hunk ./src/Darcs/Repository/HashedIO.lhs 27
 
 import Darcs.Global ( darcsdir )
 import Data.List ( (\\) )
-import System.Directory ( getDirectoryContents )
+import System.Directory ( getDirectoryContents, createDirectoryIfMissing )
 import System.Posix.Types ( EpochTime )
 import Control.Monad.State ( StateT, runStateT, modify, get, put, gets, lift )
 import Control.Monad ( when )
hunk ./src/Darcs/Repository/HashedIO.lhs 34
 import Data.Maybe ( isJust )
 import System.IO.Unsafe ( unsafeInterleaveIO )
 
-import Workaround ( createDirectoryIfMissing )
 import Darcs.SlurpDirectory ( Slurpy(..), withSlurpy, undefined_time, undefined_size )
 import Darcs.Repository.Cache ( Cache, fetchFileUsingCache, writeFileUsingCache,
                                 peekInCache, speculateFileUsingCache,
hunk ./src/Darcs/Repository/HashedRepo.lhs 37
                                      readHashedPristineRoot
                                    ) where
 
-import System.Directory ( doesFileExist )
+import System.Directory ( doesFileExist, createDirectoryIfMissing )
 import System.IO.Unsafe ( unsafeInterleaveIO )
 import System.IO ( stderr, hPutStrLn )
 import Data.List ( delete )
hunk ./src/Darcs/Repository/HashedRepo.lhs 43
 import Control.Monad ( unless )
 
-import Workaround ( renameFile, createDirectoryIfMissing )
+import Workaround ( renameFile )
 import Darcs.Flags ( DarcsFlag, Compression )
 import Darcs.Patch.Set ( PatchSet, SealedPatchSet )
 import Darcs.FilePathUtils ( absolute_dir )
hunk ./src/Darcs/Repository/Internal.lhs 70
 import Darcs.Repository.Format ( RepoFormat, RepoProperty( Darcs2, HashedInventory ),
                                  identifyRepoFormat, format_has,
                                  write_problem, read_problem, readfrom_and_writeto_problem )
-import System.Directory ( doesDirectoryExist, setCurrentDirectory, removeFile )
+import System.Directory ( doesDirectoryExist, setCurrentDirectory, removeFile,
+                          createDirectoryIfMissing )
 import Control.Monad ( liftM, when, unless )
hunk ./src/Darcs/Repository/Internal.lhs 73
-import Workaround ( createDirectoryIfMissing, getCurrentDirectory, renameFile, setExecutable )
+import Workaround ( getCurrentDirectory, renameFile, setExecutable )
 import FastPackedString ( PackedString, readFilePS, gzReadFilePS, nilPS, packString, takePS )
 import Darcs.Patch ( Patch, RealPatch, Effect, is_hunk, is_binary, description,
hunk ./src/Darcs/Repository/Internal.lhs 76
+
                      try_to_shrink, commuteFL, commute )
 import Darcs.Patch.Prim ( try_shrinking_inverse, Conflict )
 import Darcs.Patch.Bundle ( scan_bundle, make_bundle )
hunk ./src/Exec.lhs 46
 import System.Process
 import GHC.Handle	( hDuplicate )
         -- urgh.  hDuplicate isn't available from a standard place.
-import Workaround       ( bracketOnError )
+import Control.Exception ( bracketOnError )
 
 import Darcs.Global ( whenDebugMode )
 
hunk ./src/Ssh.hs 18
 #endif
 import System.IO ( Handle, hPutStr, hPutStrLn, hGetLine, hGetContents, hClose, hFlush )
 import System.IO.Unsafe ( unsafePerformIO )
-import System.Directory ( doesFileExist )
+import System.Directory ( doesFileExist, createDirectoryIfMissing )
 import Control.Monad ( when )
 import System.Process ( runInteractiveProcess )
 
hunk ./src/Ssh.hs 26
 import Data.IORef ( IORef, newIORef, readIORef, modifyIORef )
 
 import Darcs.SignalHandler ( catchNonSignal )
-import Workaround ( createDirectoryIfMissing )
 import Darcs.Utils ( withCurrentDirectory, breakCommand, prettyException, catchall )
 import Darcs.Global ( atexit, sshControlMasterDisabled, darcsdir, withDebugMode )
 import Darcs.Lock ( withTemp, withOpenTemp, tempdir_loc, removeFileMayNotExist )
addfile ./src/Workaround.hs
hunk ./src/Workaround.hs 1
+{-# OPTIONS_GHC -cpp #-}
+
+module Workaround ( renameFile, setExecutable, getCurrentDirectory,
+                    installHandler, raiseSignal, Handler(..), Signal,
+                    sigINT, sigHUP, sigABRT, sigALRM, sigTERM, sigPIPE ) where
+
+#ifdef HAVE_SIGNALS
+import System.Posix.Signals(installHandler, raiseSignal, Handler(..), Signal,
+                         sigINT, sigHUP, sigABRT, sigALRM, sigTERM, sigPIPE,)
+#endif
+
+#ifdef WIN32
+import qualified System.Directory ( renameFile, getCurrentDirectory, removeFile )
+import qualified Control.Exception ( block )
+import qualified System.IO.Error ( isDoesNotExistError, ioError, catch )
+#else
+import System.Directory ( renameFile, getCurrentDirectory )
+import System.Posix.Files (fileMode,getFileStatus, setFileMode,
+                           setFileCreationMask,
+                           ownerReadMode, ownerWriteMode, ownerExecuteMode,
+                           groupReadMode, groupWriteMode, groupExecuteMode,
+                           otherReadMode, otherWriteMode, otherExecuteMode)
+import Data.Bits ( (.&.), (.|.), complement )
+#endif
+
+#ifndef HAVE_SIGNALS
+-- Dummy implementation of POSIX signals
+data Handler = Default | Ignore | Catch (IO ())
+type Signal = Int
+
+installHandler :: Signal -> Handler -> Maybe () -> IO ()
+installHandler _ _ _ = return ()
+
+raiseSignal :: Signal -> IO ()
+raiseSignal _ = return ()
+
+sigINT, {- sigKILL, -} sigHUP, {- sigQUIT, -} sigABRT, sigALRM, sigTERM, sigPIPE :: Signal
+sigINT = 0
+-- not used: sigKILL = 0
+sigHUP = 0
+-- not used: sigQUIT = 0
+sigABRT = 0
+sigTERM = 0
+sigPIPE = 0
+sigALRM = 0
+#endif
+
+#ifdef WIN32
+{-
+System.Directory.renameFile incorrectly fails when the new file already
+exists.  This code works around that bug at the cost of losing atomic
+writes.
+-}
+
+renameFile :: FilePath -> FilePath -> IO ()
+renameFile old new = Control.Exception.block $
+   do System.Directory.removeFile new
+        `System.IO.Error.catch`
+         (\e -> if System.IO.Error.isDoesNotExistError e
+                   then return ()
+                   else System.IO.Error.ioError e)
+      System.Directory.renameFile old new
+
+setExecutable :: FilePath -> Bool -> IO ()
+setExecutable _ _ = return ()
+
+{-
+System.Directory.getCurrentDirectory returns a path with backslashes in it
+under windows, and some of the code gets confused by that, so we override
+getCurrentDirectory and translates '\\' to '/'
+-}
+
+getCurrentDirectory :: IO FilePath
+getCurrentDirectory = do d <- System.Directory.getCurrentDirectory
+                         return $ map rb d
+    where rb '\\' = '/'
+          rb c = c
+
+#else
+
+setExecutable :: FilePath -> Bool -> IO ()
+setExecutable f ex =
+  do st <- getFileStatus f
+     umask <- setFileCreationMask 0
+     setFileCreationMask umask
+     let rw = fileMode st .&.
+              (ownerReadMode .|. ownerWriteMode .|.
+               groupReadMode .|. groupWriteMode .|.
+               otherReadMode .|. otherWriteMode)
+         total = if ex then rw .|.
+                           ((ownerExecuteMode .|. groupExecuteMode .|. otherExecuteMode)
+                            .&. complement umask)
+                       else rw
+     setFileMode f total
+
+#endif
hunk ./src/win32/System/Posix/Files.hsc 72
 fileSize :: FileStatus -> FileOffset
 fileSize = fst_size
 
+fileMode :: () -> ()
+fileMode _ = ()
+
+getFileStatus :: FilePath -> IO ()
+getFileStatus _ = return ()
+
+setFileMode :: FilePath -> () -> IO ()
+setFileMode _ _ = return ()
+
 #include <sys/stat.h>
 stdFileMode :: FileMode
 stdFileMode = (#const S_IRUSR) .|. (#const S_IWUSR)
hunk ./src/win32/System/Posix/Files.hsc 91
 getSymbolicLinkStatus fp = 
   do_stat (\p -> (fp `withCString` (`lstat` p)))
 
+-- Dummy implementation of createLink.
+createLink :: FilePath -> FilePath -> IO ()
+createLink _ _ = fail "Dummy create link error should be caught."
[make various autoconf simplifications.
David Roundy <[EMAIL PROTECTED]>**20080918182015
 Ignore-this: 5f7a595598d2f8872c2377bb638e6b19
] hunk ./configure.ac 588
 fi
 AC_SUBST(HAVE_CURSES)
 
-dnl Look for a suitable diff command
-
-AC_CHECK_PROGS(DIFF, [gdiff gnudiff diff])
-
 dnl Look for NullSoft Installer System
 
 AC_PATH_PROGS(MAKENSIS, [makensis.exe])
hunk ./src/Autoconf.lhs.in 8
 %
 \begin{code}
 {-# OPTIONS -cpp #-}
-module Autoconf ( darcsconfdir, datadir, libexecdir, have_libcurl, have_libwww, have_HTTP,
+module Autoconf ( have_libcurl, have_libwww, have_HTTP,
                   use_color, use_mmap, darcs_version, sendmail_path, have_sendmail,
hunk ./src/Autoconf.lhs.in 10
-                  have_mapi, diff_program,
+                  have_mapi,
                   path_separator, big_endian,
                 ) where
 
hunk ./src/Autoconf.lhs.in 16
 import ThisVersion ( darcs_version )
 
-{-# INLINE darcsconfdir #-}
-darcsconfdir :: String
-darcsconfdir = "@sysconfdir@/darcs"
-
-{-# INLINE datadir #-}
-datadir :: String
-datadir = "@datadir@"
-
-{-# INLINE libexecdir #-}
-libexecdir :: String
-libexecdir = "@libexecdir@"
-
 {-# INLINE have_libcurl #-}
 have_libcurl :: Bool
 #ifdef HAVE_CURL
hunk ./src/Autoconf.lhs.in 56
 have_mapi :: Bool
 have_mapi = @HAVE_MAPI@
 
-{-# INLINE diff_program #-}
-diff_program :: String
-diff_program = "@DIFF@"
-
 {-# INLINE path_separator #-}
 path_separator :: Char
 #ifdef WIN32
hunk ./src/Darcs/Commands/Diff.lhs 29
 import Control.Monad ( liftM, when )
 import Data.List ( (\\) )
 
-import Autoconf ( diff_program )
 import CommandLine ( parseCmd )
 import Darcs.Commands ( DarcsCommand(..), nodefaults )
 import Darcs.Arguments ( DarcsFlag(DiffFlags, Unified, DiffCmd, StoreInMemory,
hunk ./src/Darcs/Commands/Diff.lhs 139
     Right ([],_)    -> bug $ "parseCmd should never return empty list"
     Right ((h:t),_) -> Right (h,t)
   helper [] = -- if no command specified, use 'diff'
-    Right (diff_program, ("-rN":get_diff_opts opts++[f1,f2]))
+    Right ("diff", ("-rN":get_diff_opts opts++[f1,f2]))
   helper (_:t) = helper t
 \end{code}
 
hunk ./src/darcsman.hs 19
 
 module Main (main) where
 
-import Autoconf ( datadir )
 import Darcs.Commands
 import Darcs.TheCommands
 import Time
hunk ./src/darcsman.hs 93
    "\n"++
    "darcs is a nifty revision control tool.  For more a detailed description,\n"++
    "see the html documentation, which should be available at\n"++
-   datadir++"/doc/darcs/manual/index.html.  To easily get more specific help\n"++
+   "/usr/share/doc/darcs/manual/index.html.  To easily get more specific help\n"++
    "on each command, you can call `darcs COMMAND --help'.\n"++
    "\n"
 

Context:

[fix changes.pl test (translating to bash)
David Roundy <[EMAIL PROTECTED]>**20080917182432
 Ignore-this: 5f8bc7e1f9eadc073402a935142281c4
 This test made assumptions such as that darcs wouldn't ever add a long
 comment to its internal representation of changes, which are now
 broken.
] 
[hokey fix to allow unit tests to generate random input.
David Roundy <[EMAIL PROTECTED]>**20080917170913
 Ignore-this: 31e847e82eef741f4c6cc857fd79a245
 A nicer fix would be to move namepatch and patchinfo into some sort of
 random-number monad rather than leaving them in IO and using
 unsafePerformIO in the example-generation scripts.
] 
[resolve issue27: add junk to patch identifiers.
David Roundy <[EMAIL PROTECTED]>**20080917154657
 Ignore-this: b91ab6f6e05e0fda25488fa51653b741
] 
[TAG 2.0.3pre1
Eric Kow <[EMAIL PROTECTED]>**20080918023645] 
[Bump version number to 2.0.3pre1.
Eric Kow <[EMAIL PROTECTED]>**20080918023634] 
[Canonize Florent Becker, Matthias Killian, Trent Buck, Thorkil Naur
Eric Kow <[EMAIL PROTECTED]>**20080918020453] 
[ChangeLog entries for darcs 2.0.3pre1 again.
Eric Kow <[EMAIL PROTECTED]>**20080918020442] 
[Re-enable haskeline by default.  Require haskeline>=0.3.1 which fixes issue1050.
Judah Jacobson <[EMAIL PROTECTED]>**20080917194007] 
[Throw an error when haskeline returns an EOF/EOT.
Judah Jacobson <[EMAIL PROTECTED]>**20080917180124] 
[Disable more record_editor tests under Windows.
Eric Kow <[EMAIL PROTECTED]>**20080917192602
 It still appears to be failing under Cygwin.
] 
[add a couple of tests of unrecord.
David Roundy <[EMAIL PROTECTED]>**20080917133738] 
[add a few (passing) tests of pending handling in obliterate and unrecord.
David Roundy <[EMAIL PROTECTED]>**20080917130423] 
[Use putStrLn for "Cancelled." message.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080916205014] 
[remove now-unused is_addrmfile and is_addrmdir.
David Roundy <[EMAIL PROTECTED]>**20080916173136] 
[resolve issue1012: it seems to be fixed by the fix for issue709.
David Roundy <[EMAIL PROTECTED]>**20080916173116] 
[resolve issue885: fix patchSetToRepository to work with hashed.
David Roundy <[EMAIL PROTECTED]>**20080916173030] 
[resolve issue709: avoid adding changes to pending in rmpend when possible.
David Roundy <[EMAIL PROTECTED]>**20080916173002] 
[first-stage fix for issue709.
David Roundy <[EMAIL PROTECTED]>**20080916170333
 Here I fix the bug which leads to a corrupt pending being left, with a
 rmfile change but no hunk removing the contents.  This doesn't fix
 issue709, since an incorrect pending is left, it's just no longer a
 corrupt pending (i.e. it's still got the rmfile, but if you record it
 there's no problem).
] 
[add new test that we don't do anything when repairing a clean repo.
David Roundy <[EMAIL PROTECTED]>**20080916165437] 
[whitespace change in prepend.
David Roundy <[EMAIL PROTECTED]>**20080916160425] 
[tiny refactor in Internal.lhs.
David Roundy <[EMAIL PROTECTED]>**20080916155922] 
[simplify issue965 test (which took quite a while for me to figure out).
David Roundy <[EMAIL PROTECTED]>**20080916152028] 
[make shell_harness print summary of passing tests when running bugs tests.
David Roundy <[EMAIL PROTECTED]>**20080916145820] 
[trailing whitespace cleanup in Repository.Internal.
David Roundy <[EMAIL PROTECTED]>**20080916142112] 
[Test for issue691.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080916111332] 
[Make match.pl test understand Windows dates.
Eric Kow <[EMAIL PROTECTED]>**20080916011339
 Windows does not abbreviate its timezones.
] 
[Disable some tests that don't work under Windows.
Eric Kow <[EMAIL PROTECTED]>**20080916000912] 
[Translate get.pl test into shell.
Eric Kow <[EMAIL PROTECTED]>**20080916000227
 The original get.pl uses the Perl Cwd library, which seems not
 to work for purposes of this test under MSYS.
] 
[Resolve issue691: distinguish between NoArg and ReqArg in defaults parser.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080915224046] 
[Move get_default_flag type to definition.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080915220316] 
[reverse overly-invasive haddocking.
David Roundy <[EMAIL PROTECTED]>**20080915110353] 
[In darcs send if POST fails try sendmail.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914234314] 
[Grammar in Darcs.Commands.Send.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914232923] 
[Print "Successfully sent patch bundle to" only when we really sent something.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914232905] 
[Fix overzealous escaping in haddock.
Eric Kow <[EMAIL PROTECTED]>**20080915070926] 
[Haddock documentation for English.lhs
[EMAIL PROTECTED]
 Docstrings by Eric Kow
] 
[Haddock documentation for PrintPatch
[EMAIL PROTECTED] 
[Haddock documentation for Flags
[EMAIL PROTECTED] 
[Haddock documentation for Motd
[EMAIL PROTECTED]
 docstring by Eric Kow
] 
[Haddock string for TheCommands
[EMAIL PROTECTED]
 Docstring by Eric Kow
] 
[Run testing in temp directories to avoid collosions, fail if DarcsURL header is not found.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914223930] 
[Use tempfile() UNLINK option to automatically remove temp files at exit.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914223827] 
[Coding style in upload.cgi.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914223751] 
[Stop after we found the first DarcsURL: in patch bundle.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914220421] 
[Spaces in upload.cgi.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080914220324] 
[Really allow pull.sh test to pass on Windows.
Eric Kow <[EMAIL PROTECTED]>**20080914211458
 
 It seems that these redirections cause an openBinaryFile failure under
 Windows.  I do not yet understand why using different names makes a
 difference, but it could provide an interesting clue.
] 
[rewrite upload.cgi so it won't need any customization by default.
David Roundy <[EMAIL PROTECTED]>**20080913171447
 The downside is that it has to do a darcs get --lazy in order to check if
 the patch can be applied.  If you define $target_repo, however, it doesn't
 need to do this (but then can only accept patches to a single
 locally-present repo).
] 
[when _darcs/prefs/post is present, use _darcs/prefs/post for To: header.
David Roundy <[EMAIL PROTECTED]>**20080913171025] 
[sketchy documentation of _darcs/prefs/post
David Roundy <[EMAIL PROTECTED]>**20080913115655] 
[ChangeLog entries for darcs 2.0.3pre1
Eric Kow <[EMAIL PROTECTED]>**20080914094144] 
[Disable amend-cancelling test under Cygwin.
Eric Kow <[EMAIL PROTECTED]>**20080913213039] 
[Make binary.sh test more portable (avoid copying an exe).
Eric Kow <[EMAIL PROTECTED]>**20080913212843
 Under Windows, copying the exe file will result in an .exe extension
 being appended to the filename.  This confuses the test.
] 
[set default upload.cgi to work on darcs-unstable.
David Roundy <[EMAIL PROTECTED]>**20080913112227] 
[Improve upload.cgi.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912230953
 - check if patch is valid before sending
 - use sendmail to send patches or drop to maildir
] 
[Spaces and punctuation in upload.cgi.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912230827] 
[fix problem in Darcs.URL refactor pointed out by Eric.
David Roundy <[EMAIL PROTECTED]>**20080913104327] 
[Disable a pull.sh test under Windows.
Eric Kow <[EMAIL PROTECTED]>**20080912224027
 It relies on darcs not working if we chmod u-r a file.
 This seems to have little effect in Windows.
] 
[refactor Darcs.URL to eliminate use of Regexes.
David Roundy <[EMAIL PROTECTED]>**20080912173611
 The algorithms here are not tricky, and I find this easier to read.
] 
[change is_file to return false on [EMAIL PROTECTED]:
David Roundy <[EMAIL PROTECTED]>**20080912173501] 
[clean up whitespace.
David Roundy <[EMAIL PROTECTED]>**20080912150248] 
[fix manual for optional arguments.
David Roundy <[EMAIL PROTECTED]>**20080912150231] 
[clean up whitespace.
David Roundy <[EMAIL PROTECTED]>**20080912145708] 
[add test for new --output-auto-name feature.
David Roundy <[EMAIL PROTECTED]>**20080912145648] 
[Spaces in Darcs.Commands.Send module.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912122223] 
[Make '--output-auto-name' accept optional directory argument.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912120516] 
[Add DarcsOptAbsPathOption for options with optional path argument.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912112458] 
[Refactor Darcs.Repository.Prefs.getCaches.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912055204] 
[Print warning when '--http-pipelining' option is used, but darcs is compiled without HTTP pipelining support.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912054253] 
[Do not download URL we have speculated before.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912053236] 
[Spaces and parentheses in URL module.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080912053000] 
[Coding style in Darcs.Arguments.network_options.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080911140710] 
[Resolve issue1054: --no-cache option to ignore patch caches.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080911140233] 
[Remove unused variable from configure.ac.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080911132107] 
[Comment in configure.ac.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080911115840] 
[Indentation fixes in configure.ac.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080911115117] 
[Formating and minor refactoring in URL.urlThread.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080910061227] 
[insecure printfs - fix the two that I can currently hit
Steve Cotton <[EMAIL PROTECTED]>**20080910230659] 
[TAG this version works.
David Roundy <[EMAIL PROTECTED]>**20080910212908] 
Patch bundle hash:
b2c420ad1d46d19c2a2f2371ecf5435b91d85e44
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to