bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

git submodule update --init happens too early #144

Closed phyber closed 8 years ago

phyber commented 8 years ago

Hi,

I'm attempting to use a git repo as the source of a recipe. I'm using a specific :tag from this repo and there are submodules to be had. It seems easy enough to enable this using :submodule => true, yay!

However, fpm-cookery is attempting to initialize and update the submodules too early, while the git repository is still on the master branch.

ie. It does this

    git clone https://some.where/repo.git
    cd repo
    git submodule update --init
    git checkout -f the_tag

The submodules step happens too early, and may not exist in the master branch, etc. I believe it should do this:

    git clone https://some.where/repo.git
    cd repo
    git checkout -f the_tag
    git submodule update --init

Now you should have the correct submodules for the tag that was checked out.

Currently, this can be worked around using an after_source_download hook with content along the lines of:

    Dir.chdir cachedir/name do
        sh "git checkout #{name}-#{version}" # Or whatever your tag is
        sh "git submodule update --init"
    end

It must be done at this stage since after this the source is "extracted" (copied) over to the builddir without the .git repo.

Cheers,

bernd commented 8 years ago

Thank you for the report and the detailed information. This has been fixed and will be in the next version. (0.32.0 or 0.31.1)