packages feed

hsinstall 2.1 → 2.2

raw patch · 7 files changed

+79/−27 lines, 7 filesdep +safe-exceptionsPVP ok

version bump matches the API change (PVP)

Dependencies added: safe-exceptions

API changes (from Hackage documentation)

Files

README.md view
@@ -11,8 +11,9 @@ ### OVERVIEW  hsinstall is a tool for deploying software projects into directory structures-suitable for installation on a system. It builds upon the `stack install`-command and adds more features. Those are:+suitable for installation on a system. At this time this means Haskell software+but possible future expansion could support other types of projects. It builds+upon the `stack install` command and adds more features. Those are:  - Copying the `LICENSE` file into the deployment directory - Copying the `resources` directory into the deployment directory so these@@ -39,8 +40,9 @@ change the PREFIX to `AppDir_EXECUTABLE/usr`. And only that single executable will be copied to the `AppDir_EXECUTABLE/usr/bin` directory. -The directory layout will be a standard [FHS](http://www.pathname.com/fhs/)-shape, common in UNIX-like operating systems. Like this:+Regardless of which mode is being used, the directory layout will be a standard+[FHS](http://www.pathname.com/fhs/) shape, common in UNIX-like operating+systems. Like this:      <PREFIX>/       bin/...@@ -74,9 +76,9 @@  If present, hsinstall will deploy a `resources` directory to `<PREFIX>/share/PROJECT-VERSION/resources`. In order to locate these files at-runtime, the hsinstall project includes a library to build filesystem-portable-relative paths. See this source code for help on integrating this into your-app:+runtime, the hsinstall project includes a library to construct paths relative+to the executable. See this source code for help with integrating this into+your app: https://github.com/dino-/hsinstall/blob/master/src/lib/HSInstall/Resources.hs  
changelog.md view
@@ -1,3 +1,9 @@+2.2 (2018-11-07)++  * Added actual exception handling+  * Reworded usage and README text++ 2.1 (2018-10-22)    * Switched to a a lighter-weight here-document library@@ -48,12 +54,12 @@   * Added a tested-with line to the cabal file  -1.1 (2016-10-07)+1.1 (2016-10-03)    * Updated to stackage lts-7.2  -1.0 (2016-10-02)+1.0 (2016-10-03)    * Cleaned up cabal file   * Wrote API docs
hsinstall.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a681e9c6bebfdb69f5381c614da7b4914226a5b02e54964d30b3bd8ed648caa7+-- hash: 35c4f282c3fea06102620b49eaf6f60604590bc715e824129b7d631d3abcce75  name:           hsinstall-version:        2.1+version:        2.2 synopsis:       Install Haskell software description:    This is a tool for deploying software projects into directory structures suitable for installation on a system. It builds upon the `stack install` command and adds more features. It's also a tool for easier AppImage creation. category:       Utility@@ -50,6 +50,7 @@ executable hsinstall   main-is: hsinstall.hs   other-modules:+      HSInstall.Except       HSInstall.Opts       Paths_hsinstall   hs-source-dirs:@@ -63,4 +64,5 @@     , heredoc     , hsinstall     , process+    , safe-exceptions   default-language: Haskell2010
package.yaml view
@@ -1,5 +1,5 @@ name: hsinstall-version: '2.1'+version: '2.2' synopsis: Install Haskell software description: This is a tool for deploying software projects into directory structures suitable for installation on a system. It builds upon the `stack install` command and adds more features. It's also a tool for easier AppImage creation. license: ISC@@ -48,3 +48,4 @@     - heredoc     - hsinstall     - process+    - safe-exceptions
+ src/app/HSInstall/Except.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE ScopedTypeVariables #-}++module HSInstall.Except+  ( HSInstallException (..)+  , withExceptionHandling++  -- Re-exported+  , throwM+  )+  where++import Control.Exception.Safe+  ( Exception, Handler (..), Typeable, catches, throwM )+import GHC.IO.Exception ( IOException (ioe_filename, ioe_type) )+import System.Exit ( die )+import Text.Printf ( printf )+++data HSInstallException+  = NoCabalFiles+  | OneExePerAppImage+  deriving Typeable++instance Show HSInstallException where+  show NoCabalFiles = "no cabal files were found in ."+  show OneExePerAppImage = "one executable must be specified to build an AppImage"++instance Exception HSInstallException+++withExceptionHandling :: IO a -> IO a+withExceptionHandling = flip catches exceptionHandlers+++exceptionHandlers :: [Handler IO a]+exceptionHandlers =+  [ Handler (\(err :: IOException) -> explainError $+    printf "%s%s" (show . ioe_type $ err) (maybe "" (": " ++) . ioe_filename $ err))+  , Handler (\(err :: HSInstallException) -> explainError $ show err)+  ]+++explainError :: String -> IO a+explainError = die . printf "Could not continue because: %s"
src/app/HSInstall/Opts.hs view
@@ -96,7 +96,7 @@       ]     body = [here|OVERVIEW -hsinstall is a tool for deploying software projects into directory structures suitable for installation on a system. It builds upon the `stack install` command and adds more features. Those are:+hsinstall is a tool for deploying software projects into directory structures suitable for installation on a system. At this time this means Haskell software but possible future expansion could support other types of projects. It builds upon the `stack install` command and adds more features. Those are:  - Copying the `LICENSE` file into the deployment directory - Copying the `resources` directory into the deployment directory so these files can be located using relative paths at runtime (more on this later in RESOURCES)@@ -115,7 +115,7 @@  The second mode is intended to set up for AppImage creation and is triggered by specifying exactly one EXECUTABLE from the project in the arguments. This will change the PREFIX to `AppDir_EXECUTABLE/usr`. And only that single executable will be copied to the `AppDir_EXECUTABLE/usr/bin` directory. -The directory layout will be a standard FHS shape, common in UNIX-like operating systems. Like this:+Regardless of which mode is being used, the directory layout will be a standard FHS shape, common in UNIX-like operating systems. Like this:      <PREFIX>/       bin/...@@ -138,7 +138,7 @@  RESOURCES -If present, hsinstall will deploy a `resources` directory to `<PREFIX>/share/PROJECT-VERSION/resources`. In order to locate these files at runtime, the hsinstall project includes a library to build filesystem-portable relative paths. See this source code for help on integrating this into your app: https://github.com/dino-/hsinstall/blob/master/src/lib/HSInstall/Resources.hs+If present, hsinstall will deploy a `resources` directory to `<PREFIX>/share/PROJECT-VERSION/resources`. In order to locate these files at runtime, the hsinstall project includes a library to construct paths relative to the executable. See this source code for help with integrating this into your app: https://github.com/dino-/hsinstall/blob/master/src/lib/HSInstall/Resources.hs   Version %s  Dino Morelli <dino@ui3.info>|]
src/app/hsinstall.hs view
@@ -15,23 +15,27 @@ import Distribution.Simple.Utils ( copyDirectoryRecursive ) import Distribution.Types.PackageName ( unPackageName ) import Distribution.Verbosity ( normal )+import HSInstall.Resources ( getRsrcDir ) import qualified System.Directory as Dir import System.Environment ( getArgs )-import System.Exit ( die, exitSuccess )+import System.Exit ( exitSuccess ) import System.FilePath ( (</>), (<.>), takeDirectory ) import System.Process ( callProcess ) import Text.Printf ( printf ) +import HSInstall.Except+  ( HSInstallException (NoCabalFiles, OneExePerAppImage)+  , withExceptionHandling, throwM+  ) import HSInstall.Opts   ( AppImageExe (getExe), Options (..)   , formattedVersion, parseOpts, usageText   )-import HSInstall.Resources ( getRsrcDir ) import Paths_hsinstall ( getDataDir )   main :: IO ()-main = do+main = withExceptionHandling $ do   (opts, mbAppImageExe) <- getOpts    when (optDumpIcon opts) $ dumpStockIcon Nothing >> exitSuccess@@ -58,7 +62,7 @@   when (optVersion opts) $ formattedVersion >>= putStrLn >> exitSuccess    when (isNothing mbAppImageExe && optMkAppImage opts) $ do-    die "Can't continue because --mk-appimage is only possible when a single EXECUTABLE is specified"+    throwM OneExePerAppImage    return allOpts @@ -68,13 +72,7 @@   resourcesDir <- getRsrcDir getDataDir   let iconFilename = "unix-terminal" <.> "svg"   let iconSourcePath = resourcesDir </> iconFilename--  iconFileExists <- Dir.doesFileExist iconSourcePath-  unless iconFileExists $ die $ printf-    "Error: icon file at this path is not present! %s\n" iconSourcePath-   let destPath = maybe iconFilename id mbDestPath-   Dir.copyFile iconSourcePath destPath  @@ -93,8 +91,7 @@   cabalFiles <- (filter $ isSuffixOf ".cabal")     <$> Dir.getDirectoryContents "." -  when (null cabalFiles) $ do-    die "Can't continue because no cabal files were found in ."+  when (null cabalFiles) $ throwM NoCabalFiles    -- Parse the cabal file and extract things we need from it   -- then pass a pile of what we know to a function to create the