Dukales

checkout latest boost FAST

Nov 22nd, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. -- mkdir boost ; cd boost ; lua ../git-submodules-clone-HEAD.lua https://github.com/boostorg/boost.git .
  2. local module_url = arg[1] or 'https://github.com/boostorg/boost.git'
  3. local module = arg[2] or module_url:match('.+/([_%d%a]+)%.git')
  4. local branch = arg[3] or 'master'
  5. function execute(command)
  6.     print('# ' .. command)
  7.     return os.execute(command)
  8. end
  9. -- execute('rm -rf ' .. module)
  10. if not execute('git clone --single-branch --branch ' .. branch .. ' --depth=1 ' .. module_url .. ' ' .. module) then
  11.     io.stderr:write('can\'t clone repository from ' .. module_url .. ' to ' .. module .. '\n')
  12.     return 1
  13. end
  14. -- cd $module ; git submodule update --init --recursive --remote --no-fetch --depth=1
  15. execute('mkdir -p ' .. module .. '/.git/modules')
  16. assert(io.input(module .. '/.gitmodules'))
  17. local lines = {}
  18. for line in io.lines() do
  19.     table.insert(lines, line)
  20. end
  21. local submodule
  22. local path
  23. local submodule_url
  24. for _, line in ipairs(lines) do
  25.     local submodule_ = line:match('^%[submodule %"([_%d%a]-)%"%]$')
  26.     if submodule_ then
  27.         submodule = submodule_
  28.         path = nil
  29.         submodule_url = nil
  30.     else
  31.         local path_ = line:match('^%s*path = (.+)$')
  32.         if path_ then
  33.             path = path_
  34.         else
  35.             submodule_url = line:match('^%s*url = (.+)$')
  36.         end
  37.         if submodule and path and submodule_url then
  38.             -- execute('rm -rf ' .. path)
  39.             local git_dir = module .. '/.git/modules/' .. path:match('^.-/(.+)$')
  40.             -- execute('rm -rf ' .. git_dir)
  41.             execute('mkdir -p $(dirname "' .. git_dir .. '")')
  42.             if not execute('git clone --depth=1 --single-branch --branch=' .. branch .. ' --separate-git-dir ' .. git_dir .. ' ' .. module_url .. '/' .. submodule_url .. ' ' .. module .. '/' .. path) then
  43.                 io.stderr:write('can\'t clone submodule ' .. submodule .. '\n')
  44.                 return 1
  45.             end
  46.             path = nil
  47.             submodule_url = nil
  48.         end
  49.     end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment