Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit 1e49c14

Browse files
committed
pridanie navratovych hodnot
1 parent 0256345 commit 1e49c14

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

dist/init.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function install(package_names, deploy_dir, variables)
7373

7474
-- get manifest
7575
local manifest, err = mf.get_manifest()
76-
if not manifest then return nil, "Error getting manifest: " .. err end
76+
if not manifest then return nil, "Error getting manifest: " .. err, 101 end
7777

7878
-- get dependency manifest
7979
-- TODO: Is it good that dep_manifest is deploy_dir-specific?
@@ -89,7 +89,7 @@ function install(package_names, deploy_dir, variables)
8989

9090
-- resolve dependencies
9191
local dependencies, dep_manifest_or_err = depends.get_depends(package_names, installed, manifest, dep_manifest, deploy_dir, false, false)
92-
if not dependencies then return nil, dep_manifest_or_err end
92+
if not dependencies then return nil, dep_manifest_or_err, 102 end
9393
if #dependencies == 0 then return nil, "No packages to install." end
9494

9595
-- save updated dependency manifest
@@ -102,14 +102,14 @@ function install(package_names, deploy_dir, variables)
102102
local fetched_pkgs = {}
103103
for _, pkg in pairs(dependencies) do
104104
local fetched_pkg, err = package.fetch_pkg(pkg, sys.make_path(deploy_dir, cfg.temp_dir))
105-
if not fetched_pkg then return nil, err end
105+
if not fetched_pkg then return nil, err, 103 end
106106
table.insert(fetched_pkgs, fetched_pkg)
107107
end
108108

109109
-- install fetched packages
110110
for _, pkg in pairs(fetched_pkgs) do
111-
local ok, err = package.install_pkg(pkg.download_dir, deploy_dir, variables, pkg.preserve_pkg_dir)
112-
if not ok then return nil, err end
111+
local ok, err, status = package.install_pkg(pkg.download_dir, deploy_dir, variables, pkg.preserve_pkg_dir)
112+
if not ok then return nil, err, status end
113113
end
114114

115115
return true

dist/package.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ function install_pkg(pkg_dir, deploy_dir, variables, preserve_pkg_dir)
107107

108108
-- check for dist.info
109109
local info, err = mf.load_distinfo(sys.make_path(pkg_dir, "dist.info"))
110-
if not info then return nil, "Error installing: the directory '" .. pkg_dir .. "' doesn't exist or doesn't contain valid 'dist.info' file." end
110+
if not info then return nil, "Error installing: the directory '" .. pkg_dir .. "' doesn't exist or doesn't contain valid 'dist.info' file.", 501 end
111111

112112
-- check if the package is source
113113
if is_source_type(pkg_dir) then info = ensure_source_arch_and_type(info) end
114114

115115
-- check package's architecture
116116
if not (info.arch == "Universal" or info.arch == cfg.arch) then
117-
return nil, "Error installing '" .. info.name .. "-" .. info.version .. "': architecture '" .. info.arch .. "' is not suitable for this machine."
117+
return nil, "Error installing '" .. info.name .. "-" .. info.version .. "': architecture '" .. info.arch .. "' is not suitable for this machine.", 502
118118
end
119119

120120
-- check package's type
121121
if not (info.type == "all" or info.type == "source" or info.type == cfg.type) then
122-
return nil, "Error installing '" .. info.name .. "-" .. info.version .. "': architecture type '" .. info.type .. "' is not suitable for this machine."
122+
return nil, "Error installing '" .. info.name .. "-" .. info.version .. "': architecture type '" .. info.type .. "' is not suitable for this machine.", 502
123123
end
124124

125125
local ok, err
@@ -133,7 +133,7 @@ function install_pkg(pkg_dir, deploy_dir, variables, preserve_pkg_dir)
133133

134134
-- check if we have cmake
135135
ok = utils.system_dependency_available("cmake", "cmake --version")
136-
if not ok then return nil, "Error when installing: Command 'cmake' not available on the system." end
136+
if not ok then return nil, "Error when installing: Command 'cmake' not available on the system.", 503 end
137137

138138
-- set cmake variables
139139
local cmake_variables = {}
@@ -153,15 +153,15 @@ function install_pkg(pkg_dir, deploy_dir, variables, preserve_pkg_dir)
153153
cmake_variables.CMAKE_PROGRAM_PATH = table.concat({cmake_variables.CMAKE_PROGRAM_PATH or "", sys.make_path(deploy_dir, "bin")}, ";")
154154

155155
-- build the package and deploy it
156-
ok, err = build_pkg(pkg_dir, deploy_dir, cmake_variables)
157-
if not ok then return nil, err end
156+
ok, err,status = build_pkg(pkg_dir, deploy_dir, cmake_variables)
157+
if not ok then return nil, err, status end
158158

159159
end
160160

161161
-- delete directory of fetched package
162162
if not (cfg.debug or preserve_pkg_dir) then sys.delete(pkg_dir) end
163163

164-
return ok, err
164+
return ok, err, status
165165
end
166166

167167
-- Build and deploy package from 'src_dir' to 'deploy_dir' using 'variables'.
@@ -180,7 +180,7 @@ function build_pkg(src_dir, deploy_dir, variables)
180180

181181
-- check for dist.info
182182
local info, err = mf.load_distinfo(sys.make_path(src_dir, "dist.info"))
183-
if not info then return nil, "Error building package from '" .. src_dir .. "': it doesn't contain valid 'dist.info' file." end
183+
if not info then return nil, "Error building package from '" .. src_dir .. "': it doesn't contain valid 'dist.info' file.", 501 end
184184
local pkg_name = info.name .. "-" .. info.version
185185

186186
-- set machine information
@@ -194,7 +194,7 @@ function build_pkg(src_dir, deploy_dir, variables)
194194
-- create cmake cache
195195
variables["CMAKE_INSTALL_PREFIX"] = deploy_dir
196196
local cache_file = io.open(sys.make_path(cmake_build_dir, "cache.cmake"), "w")
197-
if not cache_file then return nil, "Error creating CMake cache file in '" .. cmake_build_dir .. "'" end
197+
if not cache_file then return nil, "Error creating CMake cache file in '" .. cmake_build_dir .. "'", 401 end
198198

199199
-- Fill in cache variables
200200
for k,v in pairs(variables) do
@@ -224,11 +224,11 @@ function build_pkg(src_dir, deploy_dir, variables)
224224

225225
-- set the cmake cache
226226
local ok = sys.exec("cd " .. sys.quote(cmake_build_dir) .. " && " .. cache_command .. " " .. sys.quote(src_dir))
227-
if not ok then return nil, "Error preloading the CMake cache script '" .. sys.make_path(cmake_build_dir, "cmake.cache") .. "'" end
227+
if not ok then return nil, "Error preloading the CMake cache script '" .. sys.make_path(cmake_build_dir, "cmake.cache") .. "'", 402 end
228228

229229
-- build with cmake
230230
ok = sys.exec("cd " .. sys.quote(cmake_build_dir) .. " && " .. build_command)
231-
if not ok then return nil, "Error building with CMake in directory '" .. cmake_build_dir .. "'" end
231+
if not ok then return nil, "Error building with CMake in directory '" .. cmake_build_dir .. "'",403 end
232232

233233
-- if this is only simulation, exit sucessfully, skipping the next actions
234234
if cfg.simulate then
@@ -245,7 +245,7 @@ function build_pkg(src_dir, deploy_dir, variables)
245245

246246
local ok = sys.exec("cd " .. sys.quote(cmake_build_dir) .. " && " .. cfg.cmake .. " " .. strip_option .. " " ..cfg.install_component_command:gsub("#COMPONENT#", component))
247247

248-
if not ok then return nil, "Error when installing the component '" .. component .. "' with CMake in directory '" .. cmake_build_dir .. "'" end
248+
if not ok then return nil, "Error when installing the component '" .. component .. "' with CMake in directory '" .. cmake_build_dir .. "'", 301 end
249249

250250
local install_mf = sys.make_path(cmake_build_dir, "install_manifest_" .. component .. ".txt")
251251
local mf, err
@@ -254,7 +254,7 @@ function build_pkg(src_dir, deploy_dir, variables)
254254
-- collect files installed in this component
255255
if sys.exists(install_mf) then
256256
mf, err = io.open(install_mf, "r")
257-
if not mf then return nil, "Error when opening the CMake installation manifest '" .. install_mf .. "': " .. err end
257+
if not mf then return nil, "Error when opening the CMake installation manifest '" .. install_mf .. "': " .. err, 302 end
258258
for line in mf:lines() do
259259
line = sys.check_separators(line)
260260
local file = line:gsub(utils.escape_magic(deploy_dir .. sys.path_separator()), "")
@@ -272,7 +272,7 @@ function build_pkg(src_dir, deploy_dir, variables)
272272
if cfg.test then
273273
print("Testing " .. sys.extract_name(src_dir) .. " ...")
274274
ok = sys.exec("cd " .. sys.quote(deploy_dir) .. " && " .. cfg.test_command)
275-
if not ok then return nil, "Error when testing the module '" .. pkg_name .. "' with CTest." end
275+
if not ok then return nil, "Error when testing the module '" .. pkg_name .. "' with CTest.", 201 end
276276
end
277277

278278
-- Rewrite dependencies for binary package

0 commit comments

Comments
 (0)