On Friday 04, Hisham wrote:
> On Fri, Mar 4, 2011 at 3:43 AM, Robert G. Jakabosky
>
> <[email protected]> wrote:
> > When installing from a rockspec that checks out from a git repository,
> > LuaRocks removes the '.git' subfolder breaking the cloned git repository.
> > This is a problem when there are submodules in a parent git repository
> > that need to be pull into during build.
> >
> > I have a fork of the lua-http-parser [1] project that I was testing some
> > changes on when I ran into this problem. It seems that this wasn't a
> > problem with LuaRocks 2.0.4, it only started happening with 2.0.4.1.
> >
> > Why is the '.git' subfolder removed?
>
> Ouch. Because someone asked me to remove it. Sounded like a good idea,
> to avoid bloating .src.rock files. It still does, and I would hate to
> have to add a source.keep_git flag or something to the rockspec
> format, but if there's no other way to build it properly...
Ah, for .src.rock files I see why it should be removed to make a smaller file.
If there was support in the rockspec file for git submodules, then that would
remove the need of the .git folder during build.
For .src.rock file releases it would be good to package the submodules too.
> A question: does lua-http-parser only do git-pull during build when
> using scm rocks or does it do the same with release versions?
lua-http-parser tries to do the following git commands:
git submodule init
git submodule update
Which clones the submodules from .gitmodules. For lua-http-parser it clones
the http-parser repository at [1]. The 1.0 lua-http-parser release has a
workarround which instead uses "git clone" when the .git folder is missing,
but that will pull the very latest http-parser code which might have a
breaking API chanage. With the submodules the parent git repository tracks
which git sha1 version is pull.
Another option would be to have the git code in LuaRocks could also check for
the .gitmodules file and run those two git commands. See the attached patch.
> Requiring internet access during build wouldn't be what I'd call a
> good practice.
>
> In any case, to workaround the issue right now you can remove the two
> fs.delete() commands near the end of luarocks/fetch/git.lua. I'll
> think of a permanent solution.
Yes, this is what I did for the time being.
1. https://github.com/ry/http-parser
--
Robert G. Jakabosky
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua
index a3b763d..6e03a28 100644
--- a/src/luarocks/fetch/git.lua
+++ b/src/luarocks/fetch/git.lua
@@ -47,6 +47,15 @@ function get_sources(rockspec, extract, dest_dir)
return nil, "Failed checking out tag/branch from git repository."
end
end
+ -- handle git submodules
+ if fs.exists('.gitmodules') then
+ if not fs.execute("git", "submodule", "init") then
+ return nil, "Failed to initialize git submodules."
+ end
+ if not fs.execute("git", "submodule", "update") then
+ return nil, "Failed to update git submodules."
+ end
+ end
fs.delete(dir.path(store_dir, module, ".git"))
fs.delete(dir.path(store_dir, module, ".gitignore"))
fs.pop_dir()
_______________________________________________
Luarocks-developers mailing list
[email protected]
http://lists.luaforge.net/cgi-bin/mailman/listinfo/luarocks-developers