Проверка версий зависимостей
Добавил проверку версий установленных зависимостей паков.
This commit is contained in:
@@ -181,8 +181,9 @@ function check_dependencies(packinfo)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i,dep in ipairs(packinfo.dependencies) do
|
for i,dep in ipairs(packinfo.dependencies) do
|
||||||
local depid = dep:sub(2,-1)
|
local depid, depver = unpack(string.split(dep:sub(2,-1), "@"))
|
||||||
if dep:sub(1,1) == '!' then
|
|
||||||
|
if dep:sub(1,1) == '!' then
|
||||||
if not table.has(packs_all, depid) then
|
if not table.has(packs_all, depid) then
|
||||||
return string.format(
|
return string.format(
|
||||||
"%s (%s)", gui.str("error.dependency-not-found"), depid
|
"%s (%s)", gui.str("error.dependency-not-found"), depid
|
||||||
@@ -192,6 +193,14 @@ function check_dependencies(packinfo)
|
|||||||
table.insert(required, depid)
|
table.insert(required, depid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local dep_pack = pack.get_info(depid);
|
||||||
|
|
||||||
|
if depver ~= "*" or depver ~= dep_pack.version then
|
||||||
|
return string.format("%s (%s@%s != %s)", gui.str("error.dependency-version-not-met"), depid, dep_pack.version, depver);
|
||||||
|
end
|
||||||
|
|
||||||
|
debug.print(packinfo);
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ world.convert-block-layouts=Blocks fields have changes! Convert world files?
|
|||||||
pack.remove-confirm=Do you want to erase all pack(s) content from the world forever?
|
pack.remove-confirm=Do you want to erase all pack(s) content from the world forever?
|
||||||
error.pack-not-found=Could not to find pack
|
error.pack-not-found=Could not to find pack
|
||||||
error.dependency-not-found=Dependency pack is not found
|
error.dependency-not-found=Dependency pack is not found
|
||||||
|
error.dependency-version-not-met=Dependency pack version is not met.
|
||||||
world.delete-confirm=Do you want to delete world forever?
|
world.delete-confirm=Do you want to delete world forever?
|
||||||
world.generators.default=Default
|
world.generators.default=Default
|
||||||
world.generators.flat=Flat
|
world.generators.flat=Flat
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ devtools.output=Вывод
|
|||||||
|
|
||||||
error.pack-not-found=Не удалось найти пакет
|
error.pack-not-found=Не удалось найти пакет
|
||||||
error.dependency-not-found=Используемая зависимость не найдена
|
error.dependency-not-found=Используемая зависимость не найдена
|
||||||
|
error.dependency-version-not-met=Версия зависимости не соответствует необходимой
|
||||||
pack.remove-confirm=Удалить весь поставляемый паком/паками контент из мира (безвозвратно)?
|
pack.remove-confirm=Удалить весь поставляемый паком/паками контент из мира (безвозвратно)?
|
||||||
|
|
||||||
# Подсказки
|
# Подсказки
|
||||||
|
|||||||
@@ -132,7 +132,15 @@ ContentPack ContentPack::read(const io::path& folder) {
|
|||||||
level = DependencyLevel::weak;
|
level = DependencyLevel::weak;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pack.dependencies.push_back({level, depName});
|
|
||||||
|
std::string depVersion = "*";
|
||||||
|
size_t version_pos = depName.rfind("@");
|
||||||
|
if (version_pos != std::string::npos){
|
||||||
|
depVersion = depName.substr(version_pos + 1);
|
||||||
|
depName = depName.substr(0, version_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.dependencies.push_back({level, depName, depVersion});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ enum class DependencyLevel {
|
|||||||
struct DependencyPack {
|
struct DependencyPack {
|
||||||
DependencyLevel level;
|
DependencyLevel level;
|
||||||
std::string id;
|
std::string id;
|
||||||
|
std::string verison;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ContentPackStats {
|
struct ContentPackStats {
|
||||||
|
|||||||
@@ -105,6 +105,14 @@ static bool resolve_dependencies(
|
|||||||
// added
|
// added
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (dep.verison == "*" || dep.verison == found->second.version){
|
||||||
|
// dependency pack version mets the required one
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
throw contentpack_error(
|
||||||
|
dep.id, io::path(), "does not meet required version '" + dep.verison +"' of '" + pack->id + "'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!util::contains(allNames, dep.id) &&
|
if (!util::contains(allNames, dep.id) &&
|
||||||
dep.level != DependencyLevel::weak) {
|
dep.level != DependencyLevel::weak) {
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ static int l_pack_get_info(
|
|||||||
default:
|
default:
|
||||||
throw std::runtime_error("");
|
throw std::runtime_error("");
|
||||||
}
|
}
|
||||||
lua::pushfstring(L, "%s%s", prefix.c_str(), dpack.id.c_str());
|
|
||||||
|
lua::pushfstring(L, "%s%s@%s", prefix.c_str(), dpack.id.c_str(), dpack.verison.c_str());
|
||||||
lua::rawseti(L, i + 1);
|
lua::rawseti(L, i + 1);
|
||||||
}
|
}
|
||||||
lua::setfield(L, "dependencies");
|
lua::setfield(L, "dependencies");
|
||||||
|
|||||||
Reference in New Issue
Block a user