diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/build-pkg.lua | 642 | ||||
-rwxr-xr-x | tools/make-shared-from-static | 3 | ||||
-rw-r--r-- | tools/nonetwork.c | 36 |
3 files changed, 398 insertions, 283 deletions
diff --git a/tools/build-pkg.lua b/tools/build-pkg.lua index 7a5df56..eaacb93 100755 --- a/tools/build-pkg.lua +++ b/tools/build-pkg.lua @@ -22,7 +22,7 @@ set environment variable MXE_NO_DEBS to 1 In this case fakeroot and dpkg-deb are not needed. To limit number of packages being built to x, -set environment variable MXE_MAX_PACKAGES to x, +set environment variable MXE_MAX_ITEMS to x, The following error: > fakeroot, while creating message channels: Invalid argument @@ -32,10 +32,10 @@ can be caused by leaked ipc resources originating in fakeroot. How to remove them: http://stackoverflow.com/a/4262545 ]] -local max_packages = tonumber(os.getenv('MXE_MAX_PACKAGES')) +local max_items = tonumber(os.getenv('MXE_MAX_ITEMS')) local no_debs = os.getenv('MXE_NO_DEBS') -local ARCH = 'amd64' +local TODAY = os.date("%Y%m%d") local MXE_DIR = os.getenv('MXE_DIR') or '/usr/lib/mxe' @@ -43,47 +43,16 @@ local GIT = 'git --work-tree=./usr/ --git-dir=./usr/.git ' local BLACKLIST = { '^usr/installed/check%-requirements$', - '^usr/share/', + -- usr/share/cmake is useful + '^usr/share/doc/', + '^usr/share/info/', + '^usr/share/man/', + '^usr/share/gcc', + '^usr/lib/nonetwork.so', '^usr/[^/]+/share/doc/', '^usr/[^/]+/share/info/', } -local COMMON_FILES = { - ['gcc-isl'] = { - '^usr/include/isl/', - '^usr/lib/libisl%.', - '^usr/lib/pkgconfig/isl.pc$', - }, - ['gcc-mpc'] = { - '^usr/include/mpc.h$', - '^usr/lib/libmpc%.', - }, - ['gcc-gmp'] = { - '^usr/include/gmp.h$', - '^usr/lib/libgmp%.', - }, - ['gcc-mpfr'] = { - '^usr/include/mpf2mpfr.h$', - '^usr/include/mpfr.h$', - '^usr/lib/libmpfr%.', - }, - ['gcc'] = { - '^usr/lib/libcc1%.', - }, - ['yasm'] = { - '^usr/include/libyasm', - '^usr/lib/libyasm.a$', - }, - ['ncurses'] = { - '^usr/lib/pkgconfig/', - }, - ['pkgconf'] = { - '^usr/bin/config.guess$', - }, -} - -local ARCH_FOR_COMMON = 'i686-w64-mingw32.static' - local TARGETS = { 'i686-w64-mingw32.static', 'x86_64-w64-mingw32.static', @@ -91,10 +60,12 @@ local TARGETS = { 'x86_64-w64-mingw32.shared', } -local target -- used by many functions +local function echo(fmt, ...) + print(fmt:format(...)) +end local function log(fmt, ...) - print('[build-pkg]', target, fmt:format(...)) + echo('[build-pkg]\t' .. fmt, ...) end -- based on http://lua-users.org/wiki/SplitJoin @@ -129,14 +100,37 @@ local function trim(str) end local function isInArray(element, array) - for _, item in ipairs(array) do - if item == element then + for _, member in ipairs(array) do + if member == element then return true end end return false end +local function sliceArray(list, nelements) + nelements = nelements or #list + local new_list = {} + for i = 1, nelements do + new_list[i] = list[i] + end + return new_list +end + +local function concatArrays(...) + local result = {} + for _, array in ipairs({...}) do + for _, elem in ipairs(array) do + table.insert(result, elem) + end + end + return result +end + +local function isInString(substring, string) + return string:find(substring, 1, true) +end + local function shell(cmd) local f = io.popen(cmd, 'r') local text = f:read('*all') @@ -153,6 +147,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 @@ -163,34 +173,36 @@ local function fileExists(name) end end --- return several tables describing packages --- * list of packages --- * map from package to list of deps --- * map from package to version of package -local function getPkgs() - -- create file deps.mk showing deps - -- (make show-upstream-deps-% does not present in - -- stable MXE) - local deps_mk_content = [[ -include Makefile -NOTHING:= -SPACE:=$(NOTHING) $(NOTHING) -NAME_WITH_UNDERSCORES:=$(subst $(SPACE),_,$(NAME)) -print-deps: - @$(foreach pkg,$(PKGS),echo \ - for-build-pkg $(pkg) \ - $(subst $(SPACE),-,$($(pkg)_VERSION)) \ - $($(pkg)_DEPS) \ - $(if $(call set_is_not_member,$(pkg),$(MXE_CONF_PKGS)), \ - $(MXE_CONF_PKGS));)]] - local deps_mk_file = io.open('deps.mk', 'w') - deps_mk_file:write(deps_mk_content) - deps_mk_file:close() - local pkgs = {} - local pkg2deps = {} - local pkg2ver = {} - local cmd = 'make -f deps.mk print-deps MXE_TARGETS=%s' - cmd = cmd:format(target) +local function writeFile(filename, data) + local file = io.open(filename, 'w') + file:write(data) + file:close() +end + +local NATIVE_TARGET = trim(shell("ext/config.guess")) +local function isCross(target) + return target ~= NATIVE_TARGET +end + +local cmd = "dpkg-architecture -qDEB_BUILD_ARCH 2> /dev/null" +local ARCH = trim(shell(cmd)) + +-- return target and package from item name +local function parseItem(item) + return item:match("([^~]+)~([^~]+)") +end + +-- return several tables describing packages for all targets +-- * list of items +-- * map from item to list of deps (which are also items) +-- * map from item to version +-- Item is a string like "target~pkg" +local function getItems() + local items = {} + local item2deps = {} + local item2ver = {} + local cmd = '%s print-deps-for-build-pkg MXE_TARGETS=%q' + cmd = cmd:format(tool 'make', table.concat(TARGETS, ' ')) local make = io.popen(cmd) for line in make:lines() do local deps = split(trim(line)) @@ -198,29 +210,36 @@ print-deps: -- first value is marker 'for-build-pkg' table.remove(deps, 1) -- first value is name of package which depends on - local pkg = table.remove(deps, 1) + local item = table.remove(deps, 1) -- second value is version of package local ver = table.remove(deps, 1) - table.insert(pkgs, pkg) - pkg2deps[pkg] = deps - pkg2ver[pkg] = ver + table.insert(items, item) + item2deps[item] = deps + item2ver[item] = ver + local target, _ = parseItem(item) + for _, dep_item in ipairs(deps) do + local target2, _ = parseItem(dep_item) + if isCross(target2) and target2 ~= target then + log("Cross-target dependency %s -> %s", + target2, target) + end + end end end make:close() - os.remove('deps.mk') - return pkgs, pkg2deps, pkg2ver + return items, item2deps, item2ver end --- return packages ordered in build order --- this means, if pkg1 depends on pkg2, then --- pkg2 preceeds pkg1 in the list -local function sortForBuild(pkgs, pkg2deps) +-- return items ordered in build order +-- this means, if item depends on item2, then +-- item2 preceeds item1 in the list +local function sortForBuild(items, item2deps) -- use sommand tsort local tsort_input_fname = os.tmpname() local tsort_input = io.open(tsort_input_fname, 'w') - for _, pkg1 in ipairs(pkgs) do - for _, pkg2 in ipairs(pkg2deps[pkg1]) do - tsort_input:write(pkg2 .. ' ' .. pkg1 .. '\n') + for _, item1 in ipairs(items) do + for _, item2 in ipairs(item2deps[item1]) do + tsort_input:write(item2 .. ' ' .. item1 .. '\n') end end tsort_input:close() @@ -228,8 +247,8 @@ local function sortForBuild(pkgs, pkg2deps) local build_list = {} local tsort = io.popen('tsort ' .. tsort_input_fname, 'r') for line in tsort:lines() do - local pkg = trim(line) - table.insert(build_list, pkg) + local item = trim(line) + table.insert(build_list, item) end tsort:close() os.remove(tsort_input_fname) @@ -299,12 +318,13 @@ local function gitCommit(message) os.execute(cmd:format(message)) end -local function isValidBinary(file) +local function isValidBinary(target, file) local cmd = './usr/bin/%s-objdump -t %s > /dev/null 2>&1' return execute(cmd:format(target, file)) end -local function checkFile(file, pkg) +local function checkFile(file, item) + local target, _ = parseItem(item) -- if it is PE32 file, it must have '.exe' in name local ext = file:sub(-4):lower() local cmd = 'file --dereference --brief %q' @@ -314,77 +334,93 @@ local function checkFile(file, pkg) elseif ext == '.exe' then if not file_type:match('PE32') then log('File %s (%s) is %q. Remove .exe', - file, pkg, file_type) + file, item, file_type) end elseif ext == '.dll' then if not file_type:match('PE32.*DLL') then log('File %s (%s) is %q. Remove .dll', - file, pkg, file_type) + file, item, file_type) end else if file_type:match('PE32') then log('File %s (%s) is %q. Add exe or dll', - file, pkg, file_type) + file, item, file_type) end end for _, t in ipairs(TARGETS) do - if t ~= target and file:match(t) then + if t ~= target and isInString(t, file) then log('File %s (%s): other target %s in name', - file, pkg, t) + file, item, t) end end if file:match('/lib/.*%.dll$') then - log('File %s (%s): DLL in /lib/', file, pkg) + log('File %s (%s): DLL in /lib/', file, item) end if file:match('%.dll$') or file:match('%.a$') then - if file:find(target, 1, true) then -- not common - if not isValidBinary(file) then + if isInString(target, file) and isCross(target) then + -- cross-compiled + if not isValidBinary(target, file) then log('File %s (%s): not recognized library', - file, pkg) + file, item) end end end end +local function checkFileList(files, item) + local target, _ = parseItem(item) + if target:match('shared') then + local has_a, has_dll + for _, file in ipairs(files) do + file = file:lower() + if file:match('%.a') then + has_a = true + end + if file:match('%.dll') then + has_dll = true + end + end + if has_a and not has_dll then + log('Shared item %s installs .a file ' .. + 'but no .dll', item) + end + end +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 function buildItem(item, item2deps, file2item) + local target, pkg = parseItem(item) + 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)) + gitCommit(("Build %s"):format(item)) for _, file in ipairs(new_files) do - checkFile(file, pkg) - file2pkg[file] = {pkg=pkg, target=target} + checkFile(file, item) + file2item[file] = item end for _, file in ipairs(changed_files) do - checkFile(file, pkg) + checkFile(file, item) -- add a dependency on a package created this file - local creator_pkg = assert(file2pkg[file]).pkg - local creator_target = assert(file2pkg[file]).target - local level = '' - if target == creator_target then - if not isInArray(creator_pkg, pkg2deps[pkg]) then - table.insert(pkg2deps[pkg], creator_pkg) - end - else - level = 'error' + local creator_item = assert(file2item[file]) + if not isInArray(creator_item, item2deps[item]) then + table.insert(item2deps[item], creator_item) end - log('Package %s changes %s, created by %s (%s) %s', - pkg, file, creator_pkg, creator_target, level) + log('Item %s changes %s, created by %s', + item, file, creator_item) end + checkFileList(concatArrays(new_files, changed_files), item) return new_files end -local function nameToDebian(pkg, t) - local name = 'mxe-%s-%s' - name = name:format(t or target, pkg) - name = name:gsub('_', '-') - return name +local function nameToDebian(item) + item = item:gsub('[~_]', '-') + local name = 'mxe-%s' + return name:format(item) end local function protectVersion(ver) - ver = ver:gsub('_', '-') + ver = ver:gsub('_', '.') if ver:sub(1, 1):match('%d') then return ver else @@ -393,10 +429,6 @@ local function protectVersion(ver) end end -local function listFile(pkg) - return ('%s-%s.list'):format(target, pkg) -end - local CONTROL = [[Package: %s Version: %s Section: devel @@ -405,73 +437,85 @@ Architecture: %s Depends: %s Maintainer: Boris Nagaev <bnagaev@gmail.com> Homepage: http://mxe.cc -Description: MXE package %s for %s +Description: %s MXE (M cross environment) is a Makefile that compiles a cross compiler and cross compiles many free libraries such as SDL and Qt for various target platforms (MinGW). . - This package contains the files for MXE package %s. + %s ]] -local function makeDeb(pkg, list_path, deps, ver, add_common) - local deb_pkg = nameToDebian(pkg) - local dirname = ('%s_%s'):format(deb_pkg, +local function debianControl(options) + local deb_deps_str = table.concat(options.deps, ', ') + local version = options.version .. '-' .. TODAY + return CONTROL:format( + options.package, + version, + options.arch, + deb_deps_str, + options.description1, + options.description2 + ) +end + +local function makePackage(name, files, deps, ver, d1, d2, dst) + local dst = dst or '.' + local dirname = ('%s/%s_%s'):format(dst, name, protectVersion(ver)) + -- make .list file + local list_path = ('%s/%s.list'):format(dst, name) + writeFile(list_path, table.concat(files, "\n") .. "\n") -- make .tar.xz file local tar_name = dirname .. '.tar.xz' - local cmd = 'tar -T %s --owner=0 --group=0 -cJf %s' - os.execute(cmd:format(list_path, tar_name)) - -- unpack .tar.xz to the path for Debian - local usr = dirname .. MXE_DIR - os.execute(('mkdir -p %s'):format(usr)) - -- use tar to copy files with paths - local cmd = 'tar -C %s -xf %s' - if not no_debs then - cmd = 'fakeroot -s deb.fakeroot ' .. cmd - end - os.execute(cmd:format(usr, tar_name)) - -- prepare dependencies - local deb_deps = {'mxe-requirements'} - for _, dep in ipairs(deps) do - table.insert(deb_deps, nameToDebian(dep)) - end - if add_common then - table.insert(deb_deps, nameToDebian(pkg, 'common')) - end - local deb_deps_str = table.concat(deb_deps, ', ') + local cmd = '%s -T %s --owner=root --group=root -cJf %s' + os.execute(cmd:format(tool 'tar', list_path, tar_name)) -- make DEBIAN/control file - os.execute(('mkdir -p %s/DEBIAN'):format(dirname)) - local control_fname = dirname .. '/DEBIAN/control' - local control = io.open(control_fname, 'w') - control:write(CONTROL:format(deb_pkg, protectVersion(ver), - ARCH, deb_deps_str, pkg, target, pkg)) - control:close() + local control_text = debianControl { + package = name, + version = protectVersion(ver), + arch = ARCH, + deps = deps, + description1 = d1, + description2 = d2, + } + writeFile(dirname .. ".deb-control", control_text) if not no_debs then + -- unpack .tar.xz to the path for Debian + local usr = dirname .. MXE_DIR + os.execute(('mkdir -p %s'):format(usr)) + os.execute(('mkdir -p %s/DEBIAN'):format(dirname)) + -- use tar to copy files with paths + local cmd = '%s -C %s -xf %s' + cmd = 'fakeroot -s deb.fakeroot ' .. cmd + os.execute(cmd:format(tool 'tar', usr, tar_name)) + -- make DEBIAN/control file + local control_fname = dirname .. '/DEBIAN/control' + writeFile(control_fname, control_text) -- make .deb file local cmd = 'fakeroot -i deb.fakeroot dpkg-deb -b %s' os.execute(cmd:format(dirname)) + -- cleanup + os.execute(('rm -fr %s deb.fakeroot'):format(dirname)) end - -- cleanup - os.execute(('rm -fr %s deb.fakeroot'):format(dirname)) end -local function readFileList(list_file) - local list = {} - for installed_file in io.lines(list_file) do - table.insert(list, installed_file) - end - return list -end +local D1 = "MXE package %s for %s" +local D2 = "This package contains the files for MXE package %s" -local function saveFileList(list_file, list) - local file = io.open(list_file, 'w') - for _, installed_file in ipairs(list) do - file:write(installed_file .. '\n') +local function makeDeb(item, files, deps, ver) + local target, pkg = parseItem(item) + local deb_pkg = nameToDebian(item) + local d1 = D1:format(pkg, target) + local d2 = D2:format(pkg) + local deb_deps = {'mxe-requirements', 'mxe-source'} + for _, dep in ipairs(deps) do + table.insert(deb_deps, nameToDebian(dep)) end - file:close() + makePackage(deb_pkg, files, deb_deps, ver, d1, d2) end -local function isBuilt(pkg, files) +local function isBuilt(item, files) + local target, pkg = parseItem(item) local INSTALLED = 'usr/%s/installed/%s' local installed = INSTALLED:format(target, pkg) for _, file in ipairs(files) do @@ -482,94 +526,117 @@ local function isBuilt(pkg, files) return false end --- build all packages, save filelist to file #pkg.list -local function buildPackages(pkgs, pkg2deps, file2pkg) +-- script building HUGE_TIMES from MXE main log +-- https://gist.github.com/starius/3ea9d953b0c30df88aa7 +local HUGE_TIMES = { + [7] = {"ocaml-native", "ffmpeg", "boost"}, + [9] = {"openssl", "qtdeclarative", "ossim", "wxwidgets"}, + [12] = {"ocaml-core", "itk", "wt"}, + [19] = {"gcc", "qtbase", "llvm"}, + [24] = {"vtk", "vtk6", "openscenegraph"}, + [36] = {"openblas", "pcl", "oce"}, + [51] = {"qt"}, +} + +local PROGRESS = "[%3d/%d] " .. + "The build is expected to complete in %0.1f hours, " .. + "on %s" + +local function progressPrinter(items) + local pkg2time = {} + for time, pkgs in pairs(HUGE_TIMES) do + for _, pkg in ipairs(pkgs) do + pkg2time[pkg] = time + end + end + -- + local started_at = os.time() + local sums = {} + for i, item in ipairs(items) do + local target, pkg = parseItem(item) + local expected_time = pkg2time[pkg] or 1 + sums[i] = (sums[i - 1] or 0) + expected_time + end + local total_time = sums[#sums] + local time_done = 0 + local pkgs_done = 0 + local printer = {} + -- + function printer:advance(i) + pkgs_done = i + time_done = sums[i] + end + function printer:status() + local now = os.time() + local spent = now - started_at + local predicted_duration = spent * total_time / time_done + local predicted_end = started_at + predicted_duration + local predicted_end_str = os.date("%c", math.floor(predicted_end + 0.5)) + local predicted_wait = predicted_end - now + local predicted_wait_hours = predicted_wait / 3600.0 + return PROGRESS:format(pkgs_done, #items, + predicted_wait_hours, predicted_end_str) + end + return printer +end + +local function isEmpty(item, files) + return #files == 1 +end + +-- build all packages, save filelist to list file +local function buildPackages(items, item2deps) local broken = {} local unbroken = {} - local function brokenDep(pkg) - for _, dep in ipairs(pkg2deps[pkg]) do + local file2item = {} + local item2files = {} + local function brokenDep(item) + for _, dep in ipairs(item2deps[item]) do if broken[dep] then return dep end end return false end - for _, pkg in ipairs(pkgs) do - if not brokenDep(pkg) then - local files = buildPackage(pkg, pkg2deps, file2pkg) - if isBuilt(pkg, files) then - saveFileList(listFile(pkg), files) - table.insert(unbroken, pkg) + local progress_printer = progressPrinter(items) + for i, item in ipairs(items) do + if not brokenDep(item) then + local files = buildItem(item, item2deps, file2item) + if isBuilt(item, files) then + item2files[item] = files + table.insert(unbroken, item) else -- broken package - broken[pkg] = true - log('The package is broken: %s', pkg) + broken[item] = true + log('Item is broken: %s', item) end else - broken[pkg] = true - log('Package %s depends on broken %s', - pkg, brokenDep(pkg)) - end - end - return unbroken -end - -local function filterFiles(pkg, filter_common) - local list = readFileList(listFile(pkg)) - local list2 = {} - local common_list = COMMON_FILES[pkg] - for _, installed_file in ipairs(list) do - local listed = isListed(installed_file, common_list) - if listed == filter_common then - table.insert(list2, installed_file) + broken[item] = true + log('Item %s depends on broken item %s', + item, brokenDep(item)) end + progress_printer:advance(i) + echo(progress_printer:status()) end - return list2 -end - -local function excludeCommon(pkg) - local noncommon_files = filterFiles(pkg, false) - saveFileList(listFile(pkg), noncommon_files) -end - -local function makeCommonDeb(pkg, ver) - local common_files = filterFiles(pkg, true) - local list_path = ('common-%s.list'):format(pkg) - saveFileList(list_path, common_files) - local orig_target = target - target = 'common' - makeDeb(pkg, list_path, {}, ver) - target = orig_target -end - -local function makeDebs(pkgs, pkg2deps, pkg2ver) - for _, pkg in ipairs(pkgs) do - local deps = assert(pkg2deps[pkg], pkg) - local ver = assert(pkg2ver[pkg], pkg) - local list_path = listFile(pkg) - local add_common = false - if COMMON_FILES[pkg] then - if target == ARCH_FOR_COMMON then - makeCommonDeb(pkg, ver) + return unbroken, item2files +end + +local function makeDebs(items, item2deps, item2ver, item2files) + for _, item in ipairs(items) do + local deps = assert(item2deps[item], item) + local ver = assert(item2ver[item], item) + local files = assert(item2files[item], item) + if not isEmpty(item, files) then + for _, dep in ipairs(deps) do + local dep_files = assert(item2files[dep], dep) + if isEmpty(dep, dep_files) then + log('Non-empty item %s depends on ' .. + 'empty item %s', item, dep) + end end - add_common = true - excludeCommon(pkg) - end - makeDeb(pkg, list_path, deps, ver, add_common) - end -end - -local function buildForTarget(mxe_target, file2pkg) - target = mxe_target - local pkgs, pkg2deps, pkg2ver = getPkgs() - local build_list = sortForBuild(pkgs, pkg2deps) - if max_packages then - while #build_list > max_packages do - table.remove(build_list) + makeDeb(item, files, deps, ver) end end - local unbroken = buildPackages(build_list, pkg2deps, file2pkg) - makeDebs(unbroken, pkg2deps, pkg2ver) end local function getMxeVersion() @@ -579,24 +646,12 @@ local function getMxeVersion() return text:match('Release ([^<]+)') end -local MXE_REQUIREMENTS_CONTROL = [[Package: %s -Version: %s -Section: devel -Priority: optional -Architecture: %s -Depends: %s -Maintainer: Boris Nagaev <bnagaev@gmail.com> -Homepage: http://mxe.cc -Description: MXE requirements package - MXE (M cross environment) is a Makefile that compiles - a cross compiler and cross compiles many free libraries - such as SDL and Qt for various target platforms (MinGW). - . - This package depends on all Debian dependencies of MXE. - Other MXE packages depend on this package. -]] +local MXE_REQUIREMENTS_DESCRIPTION2 = +[[This package depends on all Debian dependencies of MXE. + Other MXE packages depend on this package.]] -local function makeMxeRequirementsDeb(release) +local function makeMxeRequirementsPackage(release) + os.execute(('mkdir -p %s'):format(release)) local name = 'mxe-requirements' local ver = getMxeVersion() .. release -- dependencies @@ -614,34 +669,55 @@ local function makeMxeRequirementsDeb(release) -- Jessie+ table.insert(deps, 'libtool-bin') end - local deps_str = table.concat(deps, ', ') - -- directory - local DIRNAME = '%s/%s_%s_%s' - local dirname = DIRNAME:format(release, name, ver, ARCH) - -- make DEBIAN/control file - os.execute(('mkdir -p %s/DEBIAN'):format(dirname)) - local control_fname = dirname .. '/DEBIAN/control' - local control = io.open(control_fname, 'w') - control:write(MXE_REQUIREMENTS_CONTROL:format(name, - ver, ARCH, deps_str)) - control:close() - -- make .deb file - local cmd = 'dpkg-deb -b %s' - os.execute(cmd:format(dirname)) - -- cleanup - os.execute(('rm -fr %s'):format(dirname)) + local files = {} + local d1 = "MXE requirements package" + local d2 = MXE_REQUIREMENTS_DESCRIPTION2 + local dst = release + makePackage(name, files, deps, ver, d1, d2, dst) +end + +local MXE_SOURCE_DESCRIPTION2 = +[[This package contains MXE source files. + Other MXE packages depend on this package.]] + +local function makeMxeSourcePackage() + local name = 'mxe-source' + local ver = getMxeVersion() + -- dependencies + local deps = {} + local files = { + 'CNAME', + 'LICENSE.md', + 'Makefile', + 'README.md', + 'assets', + 'doc', + 'ext', + 'index.html', + 'src', + 'tools', + 'versions.json', + } + local d1 = "MXE source" + local d2 = MXE_SOURCE_DESCRIPTION2 + makePackage(name, files, deps, ver, d1, d2) end assert(trim(shell('pwd')) == MXE_DIR, "Clone MXE to " .. MXE_DIR) -while not execute('make download -j 6 -k') do +assert(execute(("%s check-requirements"):format(tool 'make'))) +if not max_items then + local cmd = ('%s download -j 6 -k'):format(tool 'make') + while not execute(cmd) do end end gitInit() -local file2pkg = {} -for _, t in ipairs(TARGETS) do - buildForTarget(t, file2pkg) -end +local items, item2deps, item2ver = getItems() +local build_list = sortForBuild(items, item2deps) +build_list = sliceArray(build_list, max_items) +local unbroken, item2files = buildPackages(build_list, item2deps) +makeDebs(unbroken, item2deps, item2ver, item2files) if not no_debs then - makeMxeRequirementsDeb('wheezy') - makeMxeRequirementsDeb('jessie') + makeMxeRequirementsPackage('wheezy') + makeMxeRequirementsPackage('jessie') end +makeMxeSourcePackage() diff --git a/tools/make-shared-from-static b/tools/make-shared-from-static index 6b4100c..df18ead 100755 --- a/tools/make-shared-from-static +++ b/tools/make-shared-from-static @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Taken from: +# http://hg.octave.org/mxe-octave/file/tip/tools/make-shared-from-static + set -e . tools/compat-init.sh diff --git a/tools/nonetwork.c b/tools/nonetwork.c new file mode 100644 index 0000000..d203fb2 --- /dev/null +++ b/tools/nonetwork.c @@ -0,0 +1,36 @@ +// nonetwork, break standard network functions using LD_PRELOAD +// Source: https://github.com/starius/nonetwork +// Copyright (C) 2015 Boris Nagaev +// License: MIT + +#include <errno.h> + +int connect(int sock, const void *addr, unsigned int len) { + errno = 13; // EACCES, Permission denied + return -1; +} + +void *gethostbyname(const char *name) { + return 0; +} + +int getaddrinfo(const char *node, const char *service, + const void *hints, + void **res) { + return -4; // EAI_FAIL +} + +void freeaddrinfo(void *res) { +} + +int getnameinfo(const void * sa, + unsigned int salen, char * host, + unsigned int hostlen, char * serv, + unsigned int servlen, int flags) { + return -4; // EAI_FAIL +} + +struct hostent *gethostbyaddr(const void *addr, unsigned int len, + int type) { + return 0; +} |