packages feed

dl-fedora 0.7.3 → 0.7.4

raw patch · 4 files changed

+45/−25 lines, 4 filesdep ~directorydep ~http-directory

Dependency ranges changed: directory, http-directory

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ # Changelog +## 0.7.4 (2020-03-15)+- add 'koji' release target: downloads latest branched compose from kojipkgs+ ## 0.7.3 (2020-02-11) - fix CHECKSUM512 detection (for respins) 
Main.hs view
@@ -27,7 +27,8 @@  import Paths_dl_fedora (version) -import SimpleCmd (cmd_, cmdN, error', grep_, pipe_, pipeBool, pipeFile_)+import SimpleCmd (cmd_, cmdN, error', grep_, pipe_, pipeBool, pipeFile_,+                  removePrefix) import SimpleCmdArgs  import System.Directory (createDirectory, createDirectoryIfMissing,@@ -79,15 +80,16 @@ data CheckSum = AutoCheckSum | NoCheckSum | CheckSum   deriving Eq -dlFpo, downloadFpo :: String+dlFpo, downloadFpo, kojiPkgs:: String dlFpo = "https://dl.fedoraproject.org/pub" downloadFpo = "https://download.fedoraproject.org/pub"+kojiPkgs = "https://kojipkgs.fedoraproject.org/compose"  main :: IO () 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", "or stage"]),+               P.text ("RELEASE = " <> intercalate ", " ["release number", "respin", "rawhide", "test", "stage", "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 "",                P.text "See <https://fedoraproject.org/wiki/Infrastructure/MirrorManager>",@@ -99,7 +101,7 @@     <*> checkSumOpts     <*> switchWith 'n' "dry-run" "Don't actually download anything"     <*> switchWith 'r' "run" "Boot image in Qemu"-    <*> mirrorOpt+    <*> optional mirrorOpt     <*> strOptionalWith 'a' "arch" "ARCH" "Architecture [default: x86_64]" "x86_64"     <*> optionalWith auto 'e' "edition" "EDITION" "Fedora edition [default: workstation]" Workstation     <*> strArg "RELEASE"@@ -107,20 +109,26 @@     mirrorOpt :: Parser String     mirrorOpt =       flagWith' dlFpo 'd' "dl" "Use dl.fedoraproject.org" <|>-      strOptionalWith 'm' "mirror" "HOST" "Mirror url for /pub [default https://download.fedoraproject.org/pub]" downloadFpo+      strOptionWith 'm' "mirror" "HOST" "Mirror url for /pub [default https://download.fedoraproject.org/pub]"      checkSumOpts :: Parser CheckSum     checkSumOpts =       flagWith' NoCheckSum 'C' "no-checksum" "Do not check checksum" <|>       flagWith AutoCheckSum CheckSum 'c' "checksum" "Do checksum even if already downloaded" -program :: Bool -> CheckSum -> Bool -> Bool -> String -> String -> FedoraEdition -> String -> IO ()-program gpg checksum dryrun run mirror arch edition tgtrel = do+program :: Bool -> CheckSum -> Bool -> Bool -> Maybe String -> String -> FedoraEdition -> String -> IO ()+program gpg checksum dryrun run mmirror arch edition tgtrel = do+  let mirror =+        case mmirror of+          Nothing | tgtrel == "koji" -> kojiPkgs+          Nothing -> downloadFpo+          Just _ | tgtrel == "koji" -> error' "Cannot specify mirror for koji"+          Just m -> m   home <- getHomeDirectory   dlDir <- getUserDir "DOWNLOAD"   setDownloadDir dlDir home   mgr <- httpManager-  (fileurl, filenamePrefix, (masterUrl,masterSize), mchecksum, done) <- findURL mgr+  (fileurl, filenamePrefix, (masterUrl,masterSize), mchecksum, done) <- findURL mgr mirror   downloadFile done mgr fileurl (masterUrl,masterSize) >>= fileChecksum mchecksum   unless dryrun $ do     let localfile = takeFileName fileurl@@ -142,11 +150,11 @@       when dirExists' $ setCurrentDirectory dlDir      -- urlpath, fileprefix, (master,size), checksum, downloaded-    findURL :: Manager -> IO (String, String, (String,Maybe Integer), Maybe String, Bool)-    findURL mgr = do+    findURL :: Manager -> String -> IO (String, String, (String,Maybe Integer), Maybe String, Bool)+    findURL mgr mirror = do       (path,mrelease) <- urlPathMRel mgr-      -- use http-directory trailing (0.1.6)-      let masterDir = dlFpo </> path <> "/"+      -- use http-directory trailingSlash (0.1.7)+      let masterDir = (if tgtrel == "koji" then kojiPkgs else dlFpo) </> path <> "/"       hrefs <- httpDirectory mgr masterDir       let prefixPat = makeFilePrefix mrelease           selector = if '*' `elem` prefixPat then (=~ prefixPat) else (prefixPat `isPrefixOf`)@@ -194,7 +202,7 @@            findMirror masterUrl path file = do             url <--              if mirror == dlFpo then return masterUrl+              if mirror `elem` [dlFpo,kojiPkgs] then return masterUrl                 else                 if mirror /= downloadFpo then return $ mirror </> path                 else do@@ -234,6 +242,7 @@         "rawhide" -> return ("fedora/linux/development/rawhide" </> subdir, Just "Rawhide")         "test" -> testRelease mgr subdir         "stage" -> stageRelease mgr subdir+        "koji" -> kojiCompose mgr subdir         rel | all isDigit rel -> released mgr rel subdir         _ -> error' "Unknown release" @@ -241,7 +250,7 @@     testRelease mgr subdir = do       let path = "fedora/linux" </> "releases/test"           url = dlFpo </> path-      -- use http-directory-0.1.6 removeTrailing+      -- use http-directory-0.1.7 noTrailingSlash       rels <- map (T.unpack . T.dropWhileEnd (== '/')) <$> httpDirectory mgr url       let mrel = listToMaybe rels       return (path </> fromMaybe (error' ("test release not found in " <> url)) mrel </> subdir, mrel)@@ -250,11 +259,21 @@     stageRelease mgr subdir = do       let path = "alt/stage"           url = dlFpo </> path-      -- use http-directory-0.1.6 removeTrailing+      -- use http-directory-0.1.7 noTrailingSlash       rels <- reverse . map (T.unpack . T.dropWhileEnd (== '/')) <$> httpDirectory mgr url       let mrel = listToMaybe rels       return (path </> fromMaybe (error' ("staged release not found in " <> url)) mrel </> subdir, takeWhile (/= '_') <$> mrel) +    kojiCompose :: Manager -> FilePath -> IO (FilePath, Maybe String)+    kojiCompose mgr subdir = do+      let path = "branched"+          url = kojiPkgs </> path+          prefix = "latest-Fedora-"+      latest <- filter (prefix `isPrefixOf`) . map T.unpack <$> httpDirectory mgr url+      let mlatest = listToMaybe latest+      return (path </> fromMaybe (error' ("koji branched latest dir not not found in " <> url)) mlatest </> "compose" </> subdir, removePrefix prefix <$> mlatest)++    -- use https://admin.fedoraproject.org/pkgdb/api/collections ?     released :: Manager -> FilePath -> FilePath -> IO (FilePath, Maybe String)     released mgr rel subdir = do       let dir = "fedora/linux/releases"
README.md view
@@ -1,7 +1,5 @@ # dl-fedora -Earlier called `fedora-img-dl`.- [![Hackage](https://img.shields.io/hackage/v/dl-fedora.svg)](https://hackage.haskell.org/package/dl-fedora) [![GPL-3 license](https://img.shields.io/badge/license-GPL--3-blue.svg)](LICENSE) [![Stackage Lts](http://stackage.org/package/dl-fedora/badge/lts)](http://stackage.org/lts/package/dl-fedora)@@ -14,13 +12,13 @@  `dl-fedora rawhide` : downloads the latest Fedora Rawhide Workstation Live iso -`dl-fedora -e silverblue 30` : downloads Fedora 30 Silverblue iso+`dl-fedora -e silverblue 31` : downloads Fedora 31 Silverblue iso  `dl-fedora -e kde respin` : downloads the latest KDE Live respin -`dl-fedora --edition server --arch aarch64 29` : will bring down the F29 Server iso+`dl-fedora --edition server --arch aarch64 30` : will bring down the F30 Server iso -`dl-fedora --run 31` : will download Fedora 31 Workstation and boot the Live image with qemu-kvm.+`dl-fedora --run 32` : will download Fedora 32 Workstation and boot the Live image with qemu-kvm.  A symlink to the latest iso is also created: eg for rawhide it might be `"Fedora-Workstation-Live-x86_64-Rawhide-latest.iso"`.
dl-fedora.cabal view
@@ -1,6 +1,6 @@ cabal-version:       1.18 name:                dl-fedora-version:             0.7.3+version:             0.7.4 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@@ -10,12 +10,12 @@ bug-reports:         https://github.com/juhp/dl-fedora/issues author:              Jens Petersen maintainer:          juhpetersen@gmail.com-copyright:           2019  Jens Petersen+copyright:           2019-2020  Jens Petersen category:            Utility build-type:          Simple extra-doc-files:     README.md                    , CHANGELOG.md-tested-with:         GHC == 8.8.1, GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2,+tested-with:         GHC == 8.8.3, GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2,                      GHC == 8.0.2, GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3,                      GHC == 7.4.2 @@ -29,9 +29,9 @@    build-depends:       base < 5,                        bytestring,-                       directory >= 1.2.5.0,+                       directory >= 1.2.5,                        filepath,-                       http-directory >= 0.1.5,+                       http-directory == 0.1.5 || >= 0.1.8,                        http-types,                        optparse-applicative,                        regex-posix,