packages feed

nsis 0.1 → 0.1.1

raw patch · 3 files changed

+102/−21 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Development.NSIS: findOnce :: Exp FilePath -> Exp String

Files

Development/NSIS.hs view
@@ -6,9 +6,29 @@ --   of the hard work in developing an install script. Simple NSIS installers should look mostly the same, complex ones should --   be significantly more maintainable. -----   For examples, see the Examples source directory.+--   As a simple example of using this library: -----   Much of the documentation from the Installer section is taken straight from the NSIS documentation.+-- @+--import "Development.NSIS"+--+--main = writeFile \"example1.nsi\" $ 'nsis' $ do+--     'name' \"Example1\"                  -- The name of the installer+--     'outFile' \"example1.exe\"           -- Where to produce the installer+--     'installDir' \"$DESKTOP/Example1\"   -- The default installation directory+--     'requestExecutionLevel' 'User'       -- Request application privileges for Windows Vista+--     -- Pages to display+--     'page' 'Directory'                   -- Pick where to install+--     'page' 'InstFiles'                   -- Give a progress bar while installing+--     -- Groups fo files to install+--     'section' \"\" [] $ do+--         'setOutPath' \"$INSTDIR\"        -- Where to install files in this section+--         'file' [] \"Example1.hs\"        -- File to put into this section+-- @+--+--   The file @example1.nsi@ can now be processed with @makensis@ to produce the installer @example1.exe@.+--   For more examples, see the @Examples@ source directory.+--+--   Much of the documentation from the Installer section is taken from the NSIS documentation. module Development.NSIS     (     -- * Core types@@ -30,7 +50,7 @@     -- ** File system manipulation     FileHandle, fileOpen, fileWrite, fileClose, withFile', writeFile', writeFileLines,     rmdir, delete, -    getFileTime, fileExists, findEach, findOnce,+    getFileTime, fileExists, findEach,     createDirectory, createShortcut,     -- ** Registry manipulation     readRegStr, deleteRegKey, writeRegStr, writeRegDWORD,
Development/NSIS/Sugar.hs view
@@ -108,6 +108,7 @@     "TEMPLATES VIDEOS WINDIR"  +-- | Set all 'file' actions to automatically take 'NonFatal'. alwaysNonFatal :: Action () -> Action () alwaysNonFatal act = do     (xs, _) <- capture act@@ -435,6 +436,8 @@ strDrop :: Exp Int -> Exp String -> Exp String strDrop n x = do Value n <- n; Value x <- x; v <- var; emit $ StrCpy v x (lit "") n; return $ Value $ val v +-- | Gets the last write time of the file, you should only use the result to compare for equality+--   with other results from 'getFileTime'. On failure the error flag is set. getFileTime :: Exp FilePath -> Exp String getFileTime x = do Value x <- x; v1 <- var; v2 <- var; emit $ GetFileTime x v1 v2; strConcat [return $ Value $ val v1, "#", return $ Value $ val v2] @@ -577,6 +580,11 @@     label end  +-- | Checks for existence of file(s) (which can be a wildcard, or a directory).+--   If you want to check to see if a file is a directory, use @fileExists "DIRECTORY/*.*"@.+--+-- > iff_ (fileExists "$WINDIR/notepad.exe") $+-- >     messageBox [MB_OK] "notepad is installed" fileExists :: Exp FilePath -> Exp Bool fileExists x = do     v <- mutable_ false@@ -590,7 +598,13 @@     v  --- If you jump from inside the loop to outside then you may leak a find handle+-- | Performs a search for filespec, running the action with each file found.+--   If no files are found the error flag is set. Note that the filename output is without path.+--+-- > findEach "$INSTDIR/*.txt" $ \x ->+-- >     detailPrint x+--+--   If you jump from inside the loop to after the loop then you may leak a search handle. findEach :: Exp FilePath -> (Exp FilePath -> Action ()) -> Action () findEach spec act = do     Value spec <- spec@@ -603,18 +617,6 @@     emit $ FindClose $ val hdl  --- return either "" for no patterns matched, or the first file-findOnce :: Exp FilePath -> Exp String-findOnce spec = do-    -- can't use findEach + jump since then we leak a find handle-    Value spec <- spec-    hdl <- var-    v <- var-    emit $ FindFirst hdl v spec-    emit $ FindClose $ val hdl-    return $ Value $ val v-- infixr 5 &  -- | Concatenate two strings, for example @\"$FOO\" & \"$BAR\"@ is equivalent@@ -623,7 +625,7 @@ (&) a b = strConcat [a,b]  ---  |Convert an 'Int' to a 'String'.+-- | Convert an 'Int' to a 'String' by showing it. strShow :: Exp Int -> Exp String strShow = fmap (Value . fromValue) @@ -633,6 +635,7 @@ strRead = fmap (Value . fromValue)  +-- | Show an alert, equivalent to @messageBox [MB_ICONEXCLAMATION]@. alert :: Exp String -> Action () alert x = do     _ <- messageBox [MB_ICONEXCLAMATION] x@@ -684,7 +687,7 @@  -- | Set the icon used for the installer\/uninstaller. ----- > installIcon "NSISDIR/Contrib/Graphics/Icons/modern-install.ico"+-- > installIcon "$NSISDIR/Contrib/Graphics/Icons/modern-install.ico" installIcon, uninstallIcon :: Exp FilePath -> Action () installIcon = emit1 InstallIcon uninstallIcon = emit1 UninstallIcon@@ -762,6 +765,8 @@ writeRegDWORD :: HKEY -> Exp String -> Exp String -> Exp Int -> Action () writeRegDWORD k = emit3 $ WriteRegDWORD k +-- | While the action is executing, do not update the progress bar.+--   Useful for functions which do a large amount of computation, or have loops. hideProgress :: Action a -> Action a hideProgress act = do     fun <- fmap Fun unique@@ -857,6 +862,12 @@ uninstall :: Action () -> Action () uninstall = section "Uninstall" [] +-- | Delete file (which can be a file or wildcard, but should be specified with a full path) from the target system.+--   If 'RebootOK' is specified and the file cannot be deleted then the file is deleted when the system reboots --+--   if the file will be deleted on a reboot, the reboot flag will be set. The error flag is set if files are found+--   and cannot be deleted. The error flag is not set from trying to delete a file that does not exist.+--+-- > delete [] "$INSTDIR/somefile.dat" delete :: [Attrib] -> Exp FilePath -> Action () delete as x = do     Value x <- x@@ -865,6 +876,36 @@         f c RebootOK = c{delRebootOK=True}         f c x = error $ "Invalid attribute to delete: " ++ show x +-- | Remove the specified directory (fully qualified path with no wildcards). Without 'Recursive',+--   the directory will only be removed if it is completely empty. If 'Recursive' is specified, the+--   directory will be removed recursively, so all directories and files in the specified directory+--   will be removed. If 'RebootOK' is specified, any file or directory which could not have been+--   removed during the process will be removed on reboot -- if any file or directory will be+--   removed on a reboot, the reboot flag will be set.+--   The error flag is set if any file or directory cannot be removed.+--+-- > rmdir [] "$INSTDIR"+-- > rmdir [] "$INSTDIR/data"+-- > rmdir [Recursive, RebootOK] "$INSTDIR"+-- > rmdir [RebootOK] "$INSTDIR/DLLs"+--+--   Note that the current working directory can not be deleted. The current working directory is+--   set by 'setOutPath'. For example, the following example will not delete the directory.+--+-- > setOutPath "$TEMP/dir"+-- > rmdir [] "$TEMP/dir"+--+--   The next example will succeed in deleting the directory.+--+-- > setOutPath "$TEMP/dir"+-- > setOutPath "$TEMP"+-- > rmdir [] "$TEMP/dir"+--+--   Warning: using @rmdir [Recursive] "$INSTDIR"@ in 'uninstall' is not safe. Though it is unlikely,+--   the user might select to install to the Program Files folder and so this command will wipe out+--   the entire Program Files folder, including other programs that has nothing to do with the uninstaller.+--   The user can also put other files but the program's files and would expect them to get deleted with+--   the program. Solutions are available for easily uninstalling only files which were installed by the installer. rmdir :: [Attrib] -> Exp FilePath -> Action () rmdir as x = do     Value x <- x@@ -874,6 +915,22 @@         f c Recursive = c{rmRecursive=True}         f c x = error $ "Invalid attribute to rmdir: " ++ show x +-- | Creates a shortcut file that links to a 'Traget' file, with optional 'Parameters'. The icon used for the shortcut+--   is 'IconFile','IconIndex'. 'StartOptions' should be one of: SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED.+--   'KeyboardShortcut' should be in the form of 'flag|c' where flag can be a combination (using |) of: ALT, CONTROL, EXT, or SHIFT.+--   c is the character to use (a-z, A-Z, 0-9, F1-F24, etc). Note that no spaces are allowed in this string. A good example is+--   \"ALT|CONTROL|F8\". @$OUTDIR@ is used for the working directory. You can change it by using 'setOutPath' before creating+--   the Shortcut. 'Description' should be the description of the shortcut, or comment as it is called under XP.+--   The error flag is set if the shortcut cannot be created (i.e. either of the paths (link or target) does not exist, or some other error).+--+-- > createDirectory "$SMPROGRAMS/My Company"+-- > createShortcut "$SMPROGRAMS/My Company/My Program.lnk"+-- >    [Target "$INSTDIR/My Program.exe"+-- >    ,Parameter "some command line parameters"+-- >    ,IconFile "$INSTDIR/My Program.exe", IconIndex 2+-- >    ,StartOptions "SW_SHOWNORMAL"+-- >    ,KeyboardShortcut "ALT|CONTROL|SHIFT|F5"+-- >    ,Description "a description"] createShortcut :: Exp FilePath -> [Attrib] -> Action () createShortcut name as = do Value name <- name; x <- foldM f def{scFile=name} as; emit $ CreateShortcut x     where
nsis.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.6 build-type:         Simple name:               nsis-version:            0.1+version:            0.1.1 -- license is GPL v2 only license:            GPL license-file:       LICENSE@@ -9,9 +9,13 @@ author:             Neil Mitchell <ndmitchell@gmail.com> maintainer:         Neil Mitchell <ndmitchell@gmail.com> copyright:          Neil Mitchell 2012-synopsis:           Build NSIS Installers+synopsis:           DSL for producing Windows Installer using NSIS. description:-    Helps writing NSIS Installers, see <http://nsis.sourceforge.net/>.+    NSIS (Nullsoft Scriptable Install System, <http://nsis.sourceforge.net/>) is a tool that allows programmers+    to create installers for Windows.+    This library provides an alternative syntax for NSIS scripts, as an embedded Haskell language, removing much+    of the hard work in developing an install script. Simple NSIS installers should look mostly the same, complex ones should+    be significantly more maintainable. homepage:           http://community.haskell.org/~ndm/nsis/ stability:          Beta