packages feed

cabal-appimage 0.2.0 → 0.3.0.0

raw patch · 3 files changed

+59/−33 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Distribution.AppImage: [appIcon] :: AppImage -> FilePath
- Distribution.AppImage: instance GHC.Classes.Eq Distribution.AppImage.AppImage
- Distribution.AppImage: instance GHC.Show.Show Distribution.AppImage.AppImage
+ Distribution.AppImage: [appDirCustomize] :: AppImage -> Maybe AppDirCustomize
+ Distribution.AppImage: [appIcons] :: AppImage -> [FilePath]
+ Distribution.AppImage: type AppDirCustomize = FilePath " AppDir path." -> Args " Other parameters as defined in 'Distribution.Simple.postBuild'." -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
- Distribution.AppImage: AppImage :: String -> FilePath -> FilePath -> [FilePath] -> AppImage
+ Distribution.AppImage: AppImage :: String -> FilePath -> [FilePath] -> [FilePath] -> Maybe AppDirCustomize -> AppImage

Files

CHANGELOG.md view
@@ -1,8 +1,16 @@ # Revision history for cabal-appimage ++## 0.3.0.0 -- 2020-05-24++* Support for multiple icons.+* Hook to customize the generated AppDir.++ ## 0.2.0 -- 2020-05-17  * Fixes to Cabal file.+  ## 0.1.0 -- 2020-05-14 
cabal-appimage.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                cabal-appimage-version:             0.2.0+version:             0.3.0.0 synopsis:            Cabal support for creating AppImage applications description:         This package provides a build hook automating the                      creation of AppImage bundles.
src/Distribution/AppImage.hs view
@@ -2,22 +2,25 @@ Module:    Distribution.AppImage Copyright: 2020 Gabriele Sales -This module provides a custom build hook that automatically wraps executables-inside AppImage bundles.+This module provides a custom build hook for automating the creation of AppImage+bundles. -Internally, it calls the @appimagetool@ and @linuxdeploy@ utilities which must-be already installed on the system.+Internally, it calls the [appimagetool](https://github.com/AppImage/AppImageKit)+and [linuxdeploy](https://github.com/linuxdeploy/linuxdeploy) utilities which+must be already present on the system. -}  {-# LANGUAGE RecordWildCards #-}  module Distribution.AppImage   ( AppImage(..)+  , AppDirCustomize   , appImageBuildHook   ) where  import           Control.Monad+import           Data.Maybe import           Data.String import           Distribution.PackageDescription import           Distribution.Simple@@ -35,17 +38,27 @@   -- | Application name. The AppImage bundle will be produced in   -- @dist\/build\//appName/.AppImage@ and will contain the executable   -- /appName/.-  appName      :: String,+  appName         :: String,   -- | Path to desktop file.-  appDesktop   :: FilePath,-  -- | Path to icon file.-  appIcon      :: FilePath,-  -- | Other files to include in the application bundle. Will be copied in-  -- the @\/usr\/share\//appName/@ directory inside the image.-  appResources :: [FilePath]-  } deriving (Eq, Show)+  appDesktop      :: FilePath,+  -- | Application icons.+  appIcons        :: [FilePath],+  -- | Other resources to bundle. Stored in the @\usr\/share\//appName/@+  -- directory inside the image.+  appResources    :: [FilePath],+  -- | Hook to customize the generated @AppDir@ before final packaging.+  appDirCustomize :: Maybe AppDirCustomize+  } +type AppDirCustomize+  = FilePath   -- ^ AppDir path.+ -> Args       -- ^ Other parameters as defined in 'Distribution.Simple.postBuild'.+ -> BuildFlags+ -> PackageDescription+ -> LocalBuildInfo+ -> IO () + -- | Hook for building AppImage bundles. Does nothing if the OS is not Linux. -- -- Use this function as a @postBuild@ hook.@@ -56,49 +69,54 @@   -> PackageDescription   -> LocalBuildInfo   -> IO ()-appImageBuildHook apps _ flags pkg buildInfo =+appImageBuildHook apps args flags pkg buildInfo =   when (buildOS == Linux) $-    let bdir = buildDir buildInfo-        verb = fromFlagOrDefault normal (buildVerbosity flags)-    in forM_ apps (makeBundle pkg bdir verb)+    mapM_ (makeBundle args flags pkg buildInfo) apps -makeBundle :: PackageDescription -> FilePath -> Verbosity -> AppImage -> IO ()-makeBundle pkg bdir verb app@AppImage{..} = do+makeBundle :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> AppImage -> IO ()+makeBundle args flags pkg buildInfo app@AppImage{..} = do+  let bdir = buildDir buildInfo+      verb = fromFlagOrDefault normal (buildVerbosity flags)   unless (hasExecutable pkg appName) $     die' verb ("No executable defined for the AppImage bundle: " ++ appName)+  when (null appIcons) $+    die' verb ("No icon defined for the AppImage bundle: " ++ appName)   withTempDirectory verb bdir "appimage." $ \appDir -> do-    let exe   = bdir </> appName </> appName-        share = appDir </> "usr" </> "share" </> appName-    createDirectoryIfMissingVerbose verb True share-    deployExe app appDir exe verb-    copyResources appResources share verb+    deployExe (bdir </> appName </> appName) app appDir verb+    bundleFiles appResources (appDir </> "usr" </> "share" </> appName) verb+    fromMaybe noCustomization appDirCustomize appDir args flags pkg buildInfo     bundleApp appDir verb  hasExecutable :: PackageDescription -> String -> Bool hasExecutable pkg name =   any (\e -> exeName e == fromString name) (executables pkg) -deployExe :: AppImage -> FilePath -> FilePath -> Verbosity -> IO ()-deployExe AppImage{..} appDir exe verb = do+deployExe :: FilePath -> AppImage -> FilePath -> Verbosity -> IO ()+deployExe exe AppImage{..} appDir verb = do   prog <- findProg "linuxdeploy" verb-  runProgram verb prog+  runProgram verb prog $     [ "--appdir=" ++ appDir     , "--executable=" ++ exe-    , "--desktop-file=" ++ appDesktop-    , "--icon-file=" ++ appIcon-    ]+    , "--desktop-file=" ++ appDesktop ] +++    map ("--icon-file=" ++) appIcons -copyResources :: [FilePath] -> FilePath -> Verbosity -> IO ()-copyResources resources dest verb = mapM_ copy resources+bundleFiles :: [FilePath] -> FilePath -> Verbosity -> IO ()+bundleFiles files dest verb = prepare >> mapM_ copy files   where-    copy res = copyFileVerbose verb res (dest </> takeFileName res)+    prepare = createDirectoryIfMissingVerbose verb True dest +    copy file = copyFileVerbose verb file (dest </> takeFileName file)+ bundleApp :: FilePath -> Verbosity -> IO () bundleApp appDir verb = do   prog <- findProg "appimagetool" verb   let (wdir, name) = splitFileName appDir   runProgramInvocation verb $     (programInvocation prog [name]) { progInvokeCwd = Just wdir }++noCustomization :: AppDirCustomize+noCustomization _ _ _ _ _ = return ()+  findProg :: String -> Verbosity -> IO ConfiguredProgram findProg name verb = do