diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-12-11 08:14:55 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-12-11 08:14:55 +0100 |
| commit | 6a063b2cc450b6ac90b38bc5c9ea348430794aa7 (patch) | |
| tree | eb5ba320c173f806a8a59046aed7007aa35f81ad /lib | |
| parent | e9504fb8e56fe93e4e23c52b45a620432b11570b (diff) | |
| download | slackbuilder-6a063b2cc450b6ac90b38bc5c9ea348430794aa7.tar.gz | |
Accept up2date package parameter
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/SlackBuilder/Info.hs | 63 | ||||
| -rw-r--r-- | lib/SlackBuilder/Package.hs | 10 | ||||
| -rw-r--r-- | lib/SlackBuilder/Trans.hs | 10 |
3 files changed, 11 insertions, 72 deletions
diff --git a/lib/SlackBuilder/Info.hs b/lib/SlackBuilder/Info.hs index 3ac2e5b..861193b 100644 --- a/lib/SlackBuilder/Info.hs +++ b/lib/SlackBuilder/Info.hs @@ -2,8 +2,6 @@ module SlackBuilder.Info ( PackageInfo(..) , generate , parseInfoFile - , update - , updateDownloadVersion ) where import Control.Applicative (Alternative(..)) @@ -12,7 +10,6 @@ import qualified Data.ByteArray as ByteArray import Data.ByteString (ByteString) import qualified Data.ByteString as ByteString import qualified Data.ByteString.Char8 as Char8 -import qualified Data.List.NonEmpty as NonEmpty import Data.Maybe (mapMaybe) import Data.Text (Text) import qualified Data.Text as Text @@ -27,17 +24,15 @@ import Numeric (readHex, showHex) import Text.Megaparsec (Parsec, count, eof, takeWhile1P) import Text.Megaparsec.Byte (space, string, hexDigitChar) import Text.URI - ( Authority(..) - , URI(..) - , mkPathPiece + ( URI(..) , parserBs , render - , unRText ) import qualified Data.Word8 as Word8 type GenParser = Parsec Void ByteString +-- | Data used to generate an .info file. data PackageInfo = PackageInfo { pkgname :: String , version :: Text @@ -108,60 +103,6 @@ parseInfoFile = PackageInfo *> packageName <* "\"\n" -updateDownloadVersion :: PackageInfo -> Text -> Maybe String -> [URI] -updateDownloadVersion package toVersion gnomeVersion - = updateDownload (version package) toVersion gnomeVersion - <$> downloads package - -updateDownload :: Text -> Text -> Maybe String -> URI -> URI -updateDownload fromVersion toVersion gnomeVersion - = updateCoreVersion fromVersion toVersion gnomeVersion - . updatePackageVersion fromVersion toVersion gnomeVersion - -updatePackageVersion :: Text -> Text -> Maybe String -> URI -> URI -updatePackageVersion fromVersion toVersion _gnomeVersion download = download - { uriPath = uriPath download >>= traverse (traverse updatePathPiece) - } - where - updatePathPiece = mkPathPiece - . Text.replace fromMajor toMajor - . Text.replace fromVersion toVersion - . unRText - fromMajor = major fromVersion - toMajor = major toVersion - -major :: Text -> Text -major = Text.intercalate "." . take 2 . Text.splitOn "." - -updateCoreVersion :: Text -> Text -> Maybe String -> URI -> URI -updateCoreVersion _fromVersion _toVersion (Just gnomeVersion) download - | Just (False, pathPieces) <- uriPath download - , (beforeCore, afterCore) <- NonEmpty.break (comparePathPiece "core") pathPieces - , _ : _ : _ : sources : afterSources <- afterCore - , comparePathPiece "sources" sources && not (null afterSources) - , Right Authority{..} <- uriAuthority download - , ".gnome.org" `Text.isSuffixOf` unRText authHost - , Nothing <- authPort = - download { uriPath = buildPath beforeCore afterSources } - where - comparePathPiece this that = Just that == mkPathPiece this - buildPath beforeCore afterSources = do - core <- mkPathPiece "core" - let textGnomeVersion = Text.pack gnomeVersion - minorGnomeVersion <- mkPathPiece $ major textGnomeVersion - patchGnomeVersion <- mkPathPiece textGnomeVersion - sources <- mkPathPiece "sources" - let afterCore = core : minorGnomeVersion : patchGnomeVersion : sources : afterSources - (False,) <$> NonEmpty.nonEmpty (beforeCore ++ afterCore) -updateCoreVersion _ _ _ download = download - -update :: PackageInfo -> Text -> [URI] -> [Digest MD5] -> PackageInfo -update old toVersion downloads' checksums' = old - { version = toVersion - , downloads = downloads' - , checksums = checksums' - } - generate :: PackageInfo -> Text generate pkg = Lazy.Text.toStrict $ Text.Builder.toLazyText builder where diff --git a/lib/SlackBuilder/Package.hs b/lib/SlackBuilder/Package.hs index 48a15bf..0597819 100644 --- a/lib/SlackBuilder/Package.hs +++ b/lib/SlackBuilder/Package.hs @@ -3,7 +3,6 @@ module SlackBuilder.Package , Download(..) , DownloadTemplate(..) , Package(..) - , PackageInfo(..) , Maintainer(..) , Updater(..) , renderDownloadWithVersion @@ -34,15 +33,6 @@ data Download = Download , is64 :: Bool } deriving (Eq, Show) --- | Data used to generate an .info file. -data PackageInfo = PackageInfo - { path :: FilePath - , version :: Text - , homepage :: Text - , requires :: [Text] - , maintainer :: Maintainer - } deriving (Eq, Show) - -- | Package maintainer information. data Maintainer = Maintainer { name :: Text diff --git a/lib/SlackBuilder/Trans.hs b/lib/SlackBuilder/Trans.hs index 5147a9a..ee9b539 100644 --- a/lib/SlackBuilder/Trans.hs +++ b/lib/SlackBuilder/Trans.hs @@ -1,11 +1,19 @@ module SlackBuilder.Trans - ( SlackBuilderT(..) + ( SlackBuilderException(..) + , SlackBuilderT(..) ) where import Control.Monad.Trans.Reader (ReaderT(..)) +import Data.Text (Text) import SlackBuilder.Config import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Catch (MonadCatch(..), MonadThrow(..)) +import Control.Exception (Exception(..)) + +newtype SlackBuilderException = UpdaterNotFound Text + deriving Show + +instance Exception SlackBuilderException newtype SlackBuilderT a = SlackBuilderT { runSlackBuilderT :: ReaderT Settings IO a |
