packages feed

rpm-nvr 0.1.1 → 0.1.2

raw patch · 5 files changed

+25/−10 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,8 @@ # Revision history for rpm-nvr +## 0.1.2 (2022-05-10)+- tighten NVR and NVRA string validation to prevent empty names+ ## 0.1.1 (2021-11-02) - fix a critical bug in rpmVerCompare numeric comparison - reading NVRA now removes any directory prefix
rpm-nvr.cabal view
@@ -1,5 +1,5 @@ name:                rpm-nvr-version:             0.1.1+version:             0.1.2 synopsis:            RPM package name-version-release data types description:             The library provides types related to RPM package
src/Data/RPM/NVR.hs view
@@ -33,7 +33,7 @@ eitherNVR s =   case reverse (splitOn "-" s) of     rel:ver:emaN ->-      if any null (rel:ver:emaN)+      if null rel || null ver || null emaN       then Left $ "NVR cannot start or end with '-'s: " ++ s       else Right (NVR (intercalate "-" $ reverse emaN) (VerRel ver rel))     _ ->
src/Data/RPM/NVRA.hs view
@@ -53,8 +53,8 @@   let nvra = dropSuffix ".rpm" $ takeFileName s   in     case reverse (splitOn "-" nvra) of-      ps@(relarch:ver:emaN) ->-        if any null ps+      relarch:ver:emaN ->+        if null relarch || null ver || null emaN         then Left $ "Bad NVRA string: " ++ s         else           case breakOnEnd "." relarch of
test/RPM/PackageSpec.hs view
@@ -1,37 +1,49 @@ module RPM.PackageSpec (pkgspec) where  import           Test.Hspec-import           Data.Foldable(forM_) import           Data.RPM.NV import           Data.RPM.NVR import           Data.RPM.NVRA +import Data.Maybe (isNothing) import System.FilePath (dropExtension, takeFileName)  -- FIXME add some failures too pkgspec :: Spec pkgspec = do   describe "NV" $ do-    forM_ ["my-pkg-1.0.1"] $ \nv ->+    let nv = "my-pkg-1.0.1" in       it nv $       showNV (readNV nv) `shouldBe` nv +    let v = "1.0.1" in+      it v $+      isNothing (maybeNV v) `shouldBe` True+   describe "NVR" $ do-    forM_ ["my-pkg-1.0.1-1.2"] $ \nvr ->+    let nvr = "my-pkg-1.0.1-1.2" in       it nvr $       showNVR (readNVR nvr) `shouldBe` nvr +    let nv = "name-1.0.1" in+      it nv $+      isNothing (maybeNVR nv) `shouldBe` True+   describe "NVRA" $ do-    forM_ ["my-pkg-1.0.1-1.2.x86_64"] $ \pkg ->+    let pkg = "my-pkg-1.0.1-1.2.x86_64" in       it pkg $       showNVRA (readNVRA pkg) `shouldBe` pkg +    let nv = "name-1.0.1" in+      it nv $+      isNothing (maybeNVRA nv) `shouldBe` True+   describe "NVRA.rpm" $ do-    forM_ ["my-pkg-1.0.1-1.2.x86_64.rpm"] $ \pkg ->+    let pkg = "my-pkg-1.0.1-1.2.x86_64.rpm" in       it pkg $       showNVRA (readNVRA pkg) `shouldBe` dropExtension pkg    describe "dir/NVRA.rpm" $ do-    forM_ ["dir/my-pkg-1.0.1-1.2.x86_64.rpm"] $ \pkg ->+    let pkg = "dir/my-pkg-1.0.1-1.2.x86_64.rpm" in       it pkg $       showNVRA (readNVRA pkg) `shouldBe` dropExtension (takeFileName pkg)