diff options
author | Boris Nagaev <bnagaev@gmail.com> | 2015-10-15 22:58:08 (GMT) |
---|---|---|
committer | Boris Nagaev <bnagaev@gmail.com> | 2015-10-16 00:30:31 (GMT) |
commit | 3b52cf6053216759b323e86c438c49cf85b2851d (patch) | |
tree | b89a9202dd9220bf87ded93dccc446382cd35f0b | |
parent | 37a2ce66c4e7c5bee34c2f7a0879562953ade20e (diff) | |
download | mxe-3b52cf6053216759b323e86c438c49cf85b2851d.zip mxe-3b52cf6053216759b323e86c438c49cf85b2851d.tar.gz mxe-3b52cf6053216759b323e86c438c49cf85b2851d.tar.bz2 |
build-pkg: use gmake or gnumake if available
see #901
see 4743e7939d10d9983e01f085c94b24e4c317811d
-rwxr-xr-x | tools/build-pkg.lua | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tools/build-pkg.lua b/tools/build-pkg.lua index 966a366..c76dcd2 100755 --- a/tools/build-pkg.lua +++ b/tools/build-pkg.lua @@ -153,6 +153,22 @@ local function execute(cmd) end end +-- for tar, try gtar and gnutar first +local tools = {} +local function tool(name) + if tools[name] then + return tools[name] + end + if execute(("g%s --help > /dev/null 2>&1"):format(name)) then + tools[name] = 'g' .. name + elseif execute(("gnu%s --help > /dev/null 2>&1"):format(name)) then + tools[name] = 'gnu' .. name + else + tools[name] = name + end + return tools[name] +end + local function fileExists(name) local f = io.open(name, "r") if f ~= nil then @@ -189,8 +205,8 @@ print-deps: local pkgs = {} local pkg2deps = {} local pkg2ver = {} - local cmd = 'make -f deps.mk print-deps MXE_TARGETS=%s' - cmd = cmd:format(target) + local cmd = '%s -f deps.mk print-deps MXE_TARGETS=%s' + cmd = cmd:format(tool 'make', target) local make = io.popen(cmd) for line in make:lines() do local deps = split(trim(line)) @@ -348,8 +364,8 @@ end -- builds package, returns list of new files local function buildPackage(pkg, pkg2deps, file2pkg) - local cmd = 'make %s MXE_TARGETS=%s --jobs=1' - os.execute(cmd:format(pkg, target)) + local cmd = '%s %s MXE_TARGETS=%s --jobs=1' + os.execute(cmd:format(tool 'make', pkg, target)) gitAdd() local new_files, changed_files = gitStatus() gitCommit(("Build %s for target %s"):format(pkg, target)) @@ -397,21 +413,6 @@ local function listFile(pkg) return ('%s-%s.list'):format(target, pkg) end -local tar_tool -local function tarTool() - if tar_tool then - return tar_tool - end - if execute("gtar --help > /dev/null 2>&1") then - tar_tool = 'gtar' - elseif execute("gnutar --help > /dev/null 2>&1") then - tar_tool = 'gnutar' - else - tar_tool = 'tar' - end - return tar_tool -end - local CONTROL = [[Package: %s Version: %s Section: devel @@ -435,7 +436,7 @@ local function makeDeb(pkg, list_path, deps, ver, add_common) -- make .tar.xz file local tar_name = dirname .. '.tar.xz' local cmd = '%s -T %s --owner=0 --group=0 -cJf %s' - os.execute(cmd:format(tarTool(), list_path, tar_name)) + os.execute(cmd:format(tool 'tar', list_path, tar_name)) -- unpack .tar.xz to the path for Debian local usr = dirname .. MXE_DIR os.execute(('mkdir -p %s'):format(usr)) @@ -444,7 +445,7 @@ local function makeDeb(pkg, list_path, deps, ver, add_common) if not no_debs then cmd = 'fakeroot -s deb.fakeroot ' .. cmd end - os.execute(cmd:format(tarTool(), usr, tar_name)) + os.execute(cmd:format(tool 'tar', usr, tar_name)) -- prepare dependencies local deb_deps = {'mxe-requirements'} for _, dep in ipairs(deps) do @@ -649,7 +650,7 @@ end assert(trim(shell('pwd')) == MXE_DIR, "Clone MXE to " .. MXE_DIR) -while not execute('make download -j 6 -k') do +while not execute(('%s download -j 6 -k'):format(tool 'make')) do end gitInit() local file2pkg = {} |