ats-pkg 2.2.0.1 → 2.2.0.2
raw patch · 3 files changed
+27/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ats-pkg.cabal +1/−1
- man/atspkg.1 +5/−0
- src/Language/ATS/Package/Upgrade.hs +21/−3
ats-pkg.cabal view
@@ -1,5 +1,5 @@ name: ats-pkg-version: 2.2.0.1+version: 2.2.0.2 synopsis: Package manager for ATS description: A collection of scripts to make building ATS projects easy. homepage: https://github.com/vmchale/atspkg#readme
man/atspkg.1 view
@@ -53,6 +53,11 @@ Ignore cached configuration file .RS .RE+.TP+.B \f[B]\-r\f[], \f[B]\-\-rebuild\f[]+Rebuild all binary targets.+.RS+.RE .SH CONFIGURATION .PP \f[B]atspkg\f[] is configured with Dhall, in an atspkg.dhall file.
src/Language/ATS/Package/Upgrade.hs view
@@ -6,10 +6,15 @@ import qualified Data.ByteString.Lazy.Char8 as BSL import Data.Char (isDigit) import Data.List (intersperse)+import Data.Maybe (fromMaybe) import Data.Semigroup+import Development.Shake.FilePath import Network.HTTP.Client import Network.HTTP.Client.TLS (tlsManagerSettings)+import System.Directory (createDirectoryIfMissing)+import System.Environment import System.Info+import System.Posix.Files manufacturer :: String manufacturer = case os of@@ -17,16 +22,29 @@ _ -> "unknown" targetArch :: String-targetArch = mconcat . intersperse "-" $ [arch, manufacturer, os]+targetArch = g [arch, manufacturer, os]+ where g = mconcat . intersperse "-" +atspkgPath :: IO String+atspkgPath = do+ home <- fromMaybe "." <$> lookupEnv "HOME"+ pure $ home <> "/.local/bin/atspkg"+ upgradeAtsPkg :: IO () upgradeAtsPkg = do++ putStrLn "Finding latest release..." manager <- newManager tlsManagerSettings initialRequest <- parseRequest "https://github.com/vmchale/atspkg/releases/latest" response <- responseBody <$> httpLbs (initialRequest { method = "GET", redirectCount = 0 }) manager++ putStrLn "Downloading latest release..." let strVersion = BSL.takeWhile (/='"') . BSL.dropWhile (not . isDigit) . BSL.dropWhile (/='"') $ response binRequest = "https://github.com/vmchale/atspkg/releases/download/" <> BSL.unpack strVersion <> "/atspkg-" <> targetArch- putStrLn binRequest followupRequest <- parseRequest binRequest binBytes <- responseBody <$> httpLbs (followupRequest { method = "GET" }) manager- BSL.writeFile "atspkg" binBytes++ atsPath <- atspkgPath+ createDirectoryIfMissing True (takeDirectory atsPath)+ BSL.writeFile atsPath binBytes+ setFileMode atsPath ownerModes