summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJensPetersen <>2021-04-06 17:14:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2021-04-06 17:14:00 (GMT)
commit6493289148b7d8bb0846808b7e0d95abfa3ad38c (patch)
treee6a4d0d3ba4d1d64bd6004649d7321fd9714d8d1
parent1462a5f3fa3be848bb4b918860f0fb41bd1690d5 (diff)
version 0.7.70.7.7
-rw-r--r--CHANGELOG.md5
-rw-r--r--README.md13
-rw-r--r--dl-fedora.cabal16
-rw-r--r--src/Main.hs (renamed from Main.hs)27
-rw-r--r--test/tests.hs22
5 files changed, 67 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc42eb2..ca99c47 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 0.7.7 (2021-04-06)
+- add the new F34 i3 spin
+- shorten mate_compiz to mate
+- convert tests to Haskell
+
## 0.7.6 (2021-01-21)
- improve help text for releases related for Beta and RCs (#1)
- if ~/Downloads/iso/ exists then download to it otherwise ~/Downloads/
diff --git a/README.md b/README.md
index 97d04ac..6cbd009 100644
--- a/README.md
+++ b/README.md
@@ -13,17 +13,20 @@ Usage examples:
`dl-fedora rawhide` : downloads the latest Fedora Rawhide Workstation Live iso
-`dl-fedora -e silverblue 33` : downloads the Fedora Silverblue iso
+`dl-fedora -e silverblue 34` : downloads the Fedora Silverblue iso
`dl-fedora -e kde respin` : downloads the latest KDE Live respin
-`dl-fedora --edition server --arch aarch64 32` : will bring down the F32 Server iso
+`dl-fedora --edition server --arch aarch64 33` : will bring down the F33 Server iso for armv8
-`dl-fedora --run 33` : will download Fedora 33 Workstation and boot the Live image with qemu-kvm.
+`dl-fedora --run 34` : will download Fedora 34 Workstation and boot the Live image with qemu-kvm.
-If the image is already in the Downloads/ directory
+By default dl-fedora downloads to `~/Downloads/`, but if you create
+`~/Downloads/iso/` it will use that directory instead.
+
+If the image is already found to be downloaded
it will not be downloaded again of course.
-Curl is used to do the downloading.
+Curl is used to do the downloading: partial downloads will continue.
A symlink to the latest iso is also created:
eg for rawhide it might be `"Fedora-Workstation-Live-x86_64-Rawhide-latest.iso"`.
diff --git a/dl-fedora.cabal b/dl-fedora.cabal
index 5a0ea52..201e1a6 100644
--- a/dl-fedora.cabal
+++ b/dl-fedora.cabal
@@ -1,6 +1,6 @@
cabal-version: 1.18
name: dl-fedora
-version: 0.7.6
+version: 0.7.7
synopsis: Fedora image download tool
description: Tool to download Fedora iso and image files
-- can change to GPL-3.0-or-later with Cabal-2.2
@@ -25,7 +25,7 @@ source-repository head
location: https://github.com/juhp/dl-fedora.git
executable dl-fedora
- main-is: Main.hs
+ main-is: src/Main.hs
other-modules: Paths_dl_fedora
build-depends: base < 5,
@@ -50,3 +50,15 @@ executable dl-fedora
-Wall
default-language: Haskell2010
+
+test-suite test
+ main-is: tests.hs
+ type: exitcode-stdio-1.0
+ hs-source-dirs: test
+
+ default-language: Haskell2010
+
+ ghc-options: -Wall
+ build-depends: base >= 4 && < 5
+ , simple-cmd
+ build-tools: dl-fedora
diff --git a/Main.hs b/src/Main.hs
index f85614b..449ecd8 100644
--- a/Main.hs
+++ b/src/Main.hs
@@ -12,8 +12,8 @@ import Data.Semigroup ((<>))
import Control.Monad.Extra
import qualified Data.ByteString.Char8 as B
-import Data.Char (isDigit, toLower, toUpper)
-import Data.List
+import Data.Char (isDigit)
+import Data.List.Extra
import Data.Maybe
import qualified Data.Text as T
import Data.Time.LocalTime (utcToLocalZonedTime)
@@ -56,17 +56,26 @@ data FedoraEdition = Cloud
| KDE
| LXDE
| LXQt
- | MATE_Compiz
+ | MATE
| Soas
| Xfce
+ | I3
deriving (Show, Enum, Bounded, Eq)
+showEdition :: FedoraEdition -> String
+showEdition MATE = "MATE_Compiz"
+showEdition I3 = "i3"
+showEdition e = show e
+
+lowerEdition :: FedoraEdition -> String
+lowerEdition = lower . show
+
instance Read FedoraEdition where
readPrec = do
s <- look
- let e = map toLower s
+ let e = lower s
editionMap =
- map (\ ed -> (map toLower (show ed), ed)) [minBound..maxBound]
+ map (\ ed -> (lowerEdition ed, ed)) [minBound..maxBound]
res = lookup e editionMap
case res of
Nothing -> error' "unknown edition" >> RP.pfail
@@ -91,7 +100,7 @@ main = do
let pdoc = Just $ P.vcat
[ P.text "Tool for downloading Fedora iso file images.",
P.text ("RELEASE = " <> intercalate ", " ["release number", "respin", "rawhide", "test (Beta)", "stage (RC)", "eln", "or koji"]),
- P.text "EDITION = " <> P.lbrace <> P.align (P.fillCat (P.punctuate P.comma (map (P.text . map toLower . show) [(minBound :: FedoraEdition)..maxBound])) <> P.rbrace),
+ P.text "EDITION = " <> P.lbrace <> P.align (P.fillCat (P.punctuate P.comma (map (P.text . lowerEdition) [(minBound :: FedoraEdition)..maxBound])) <> P.rbrace),
P.text "",
P.text "See <https://fedoraproject.org/wiki/Infrastructure/MirrorManager>",
P.text "and also <https://fedoramagazine.org/verify-fedora-iso-file>."
@@ -242,7 +251,7 @@ program gpg checksum dryrun run removeold mmirror arch edition tgtrel = do
let subdir =
if edition `elem` fedoraSpins
then joinPath ["Spins", arch, "iso"]
- else joinPath [show edition, arch, editionMedia edition]
+ else joinPath [showEdition edition, arch, editionMedia edition]
case tgtrel of
"respin" -> return ("alt/live-respins", Nothing)
"rawhide" -> return ("fedora/linux/development/rawhide" </> subdir, Just "Rawhide")
@@ -307,7 +316,7 @@ program gpg checksum dryrun run removeold mmirror arch edition tgtrel = do
then rel ++ [".*" <> arch]
else arch : rel
in
- intercalate "-" (["Fedora", show edition, editionType edition] ++ middle)
+ intercalate "-" (["Fedora", showEdition edition, editionType edition] ++ middle)
downloadFile :: Bool -> Manager -> URL -> (URL, Maybe Integer) -> IO Bool
downloadFile done mgr url (masterUrl,masterSize) =
@@ -417,7 +426,7 @@ editionMedia Container = "images"
editionMedia _ = "iso"
liveRespin :: FedoraEdition -> String
-liveRespin = take 4 . map toUpper . show
+liveRespin = take 4 . upper . showEdition
infixr 5 </>
(</>) :: String -> String -> String
diff --git a/test/tests.hs b/test/tests.hs
new file mode 100644
index 0000000..fb7b6ad
--- /dev/null
+++ b/test/tests.hs
@@ -0,0 +1,22 @@
+import SimpleCmd
+
+dlFedora :: [String] -> IO ()
+dlFedora args =
+ putStrLn "" >> cmdLog "dl-fedora" args
+
+tests :: [[String]]
+tests =
+ [["-n", "33", "-c"]
+ ,["-n", "rawhide", "-e", "silverblue"]
+ ,["-n", "34", "-e", "silverblue"]
+ ,["respin"]
+ ,["-n", "32", "-e", "kde"]
+ ,["-n", "33", "-e", "everything"]
+ ,["-n", "33", "-e", "server", "--arch", "aarch64"]
+ ,["-n", "34"]
+ ]
+
+main :: IO ()
+main = do
+ mapM_ dlFedora tests
+ putStrLn $ show (length tests) ++ " tests run"