Coder Social home page Coder Social logo

Comments (11)

michaelpj avatar michaelpj commented on June 15, 2024

Can you elaborate on your use case? It works fine for Cabal.

from cardano-haskell-packages.

arrowd avatar arrowd commented on June 15, 2024

Many downstream packagers (including FreeBSD) are prefetching all required sources before the build to allow caching and to be able to disable network access during build. I implemented all the necessary machinery for multi-repository Cabal projects, but it turned out that URL patterns are different. I just wanted to make it easy for me, if it is cheap to implement on your side.

from cardano-haskell-packages.

michaelpj avatar michaelpj commented on June 15, 2024

The only robust way to do that is to get cabal to do it for you, I think. I don't think we want to promise that we will always match the layout of Hackage if that's not a requirement on Cabal package repositories.

from cardano-haskell-packages.

michaelpj avatar michaelpj commented on June 15, 2024

@andreabedini

from cardano-haskell-packages.

arrowd avatar arrowd commented on June 15, 2024

Interestingly, Stackage URLs also do not have that extra /foo-1.2.3/ part. I wonder if it is because both CHaP and Stackage do not support package revisions, only Hackage does. In this case, I think, nothing should be done on the CHaP side.

from cardano-haskell-packages.

andreabedini avatar andreabedini commented on June 15, 2024

Interesting, thanks for bringing this up @arrowd. I originally based my code on what hackage-repo-tool does and never really dug into the details once I saw the code working. Looking at the code It turns out both schemes are kind of correct: the long one is a legacy one, the short one is the new. I don't know if there's a fallback between the two.

-- | Generate the URI of the tarball for a given package.
--
packageURI :: RemoteRepo -> PackageId -> URI
packageURI repo pkgid | isOldHackageURI (remoteRepoURI repo) =
  (remoteRepoURI repo) {
    uriPath = FilePath.Posix.joinPath
      [uriPath (remoteRepoURI repo)
      ,prettyShow (packageName    pkgid)
      ,prettyShow (packageVersion pkgid)
      ,prettyShow pkgid <.> "tar.gz"]
  }
packageURI repo pkgid =
  (remoteRepoURI repo) {
    uriPath = FilePath.Posix.joinPath
      [uriPath (remoteRepoURI repo)
      ,"package"
      ,prettyShow pkgid <.> "tar.gz"]
  }

from cardano-haskell-packages.

arrowd avatar arrowd commented on June 15, 2024

I wonder how revision URLs look like in the new scheme.

from cardano-haskell-packages.

andreabedini avatar andreabedini commented on June 15, 2024

My understanding is that revisions are not fetched by url but are read off the index file (which contains all the cabal files of all the packages).

from cardano-haskell-packages.

arrowd avatar arrowd commented on June 15, 2024

Fetching by URL works for Hackage. I suppose the index file contains only the last revision?

from cardano-haskell-packages.

andreabedini avatar andreabedini commented on June 15, 2024

I think I didn't explain myself well.

Hackage exposes a large api hackage.haskell.org/api but to build a project cabal only uses two bits:

  1. the index file https://hackage.haskell.org/01-index.tar.gz
  2. the package tarballs https://hackage.haskell.org/package/package-id.tar.gz (as above)

The index file is append-only and contains all the cabal files of all packages and their revisions (plus some other metadata like preferred versions and the hashes of the package tarballs).

The index file alone is enough for cabal to orchestrate a build, but it needs to download the package tarball to actually execute them. In particular cabal never downloads the revisions from the url since they are all already included in the index file (even older revisions).

from cardano-haskell-packages.

michaelpj avatar michaelpj commented on June 15, 2024

I'm closing this with "working as reasonably intended".

from cardano-haskell-packages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.