Add Lua 5.4.0-work{1,2} to supported releases
Refactor the way download names and urls are acquired to allow more flexibility.
This commit is contained in:
parent
68d9caef5a
commit
095dcc9b4a
73
hererocks.py
73
hererocks.py
@ -196,7 +196,6 @@ platform_to_lua_target = {
|
|||||||
def using_cl():
|
def using_cl():
|
||||||
return opts.target.startswith("vs")
|
return opts.target.startswith("vs")
|
||||||
|
|
||||||
|
|
||||||
def get_default_lua_target():
|
def get_default_lua_target():
|
||||||
for plat, lua_target in platform_to_lua_target.items():
|
for plat, lua_target in platform_to_lua_target.items():
|
||||||
if sys.platform.startswith(plat):
|
if sys.platform.startswith(plat):
|
||||||
@ -419,6 +418,10 @@ def sha256_of_file(filename):
|
|||||||
|
|
||||||
return hashlib.sha256(contents).hexdigest()
|
return hashlib.sha256(contents).hexdigest()
|
||||||
|
|
||||||
|
def strip_extensions(filename):
|
||||||
|
# Just handle .zip and .tar.gz.
|
||||||
|
return os.path.splitext(os.path.splitext(filename)[0])[0]
|
||||||
|
|
||||||
class Program(object):
|
class Program(object):
|
||||||
def __init__(self, version):
|
def __init__(self, version):
|
||||||
version = self.translations.get(version, version)
|
version = self.translations.get(version, version)
|
||||||
@ -428,7 +431,6 @@ class Program(object):
|
|||||||
self.source = "release"
|
self.source = "release"
|
||||||
self.fetched = False
|
self.fetched = False
|
||||||
self.version = version
|
self.version = version
|
||||||
self.fixed_version = version
|
|
||||||
self.version_suffix = " " + version
|
self.version_suffix = " " + version
|
||||||
elif "@" in version:
|
elif "@" in version:
|
||||||
# Version from a git repo.
|
# Version from a git repo.
|
||||||
@ -497,15 +499,6 @@ class Program(object):
|
|||||||
if need_checkout and ref != "master":
|
if need_checkout and ref != "master":
|
||||||
run("git", "checkout", ref)
|
run("git", "checkout", ref)
|
||||||
|
|
||||||
def get_download_name(self):
|
|
||||||
return self.name + "-" + self.fixed_version + ("-win32" if self.win32_zip else "")
|
|
||||||
|
|
||||||
def get_file_name(self):
|
|
||||||
return self.get_download_name() + (".zip" if self.win32_zip else ".tar.gz")
|
|
||||||
|
|
||||||
def get_download_url(self, base_url):
|
|
||||||
return base_url + "/" + self.get_file_name()
|
|
||||||
|
|
||||||
def fetch(self):
|
def fetch(self):
|
||||||
if self.fetched:
|
if self.fetched:
|
||||||
return
|
return
|
||||||
@ -518,18 +511,17 @@ class Program(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if opts.downloads is None:
|
if opts.downloads is None:
|
||||||
archive_name = os.path.join(temp_dir, self.get_file_name())
|
archive_name = os.path.join(temp_dir, self.get_download_name())
|
||||||
else:
|
else:
|
||||||
if not os.path.exists(opts.downloads):
|
if not os.path.exists(opts.downloads):
|
||||||
os.makedirs(opts.downloads)
|
os.makedirs(opts.downloads)
|
||||||
|
|
||||||
archive_name = os.path.join(opts.downloads, self.get_file_name())
|
archive_name = os.path.join(opts.downloads, self.get_download_name())
|
||||||
|
|
||||||
if opts.downloads and os.path.exists(archive_name):
|
if opts.downloads and os.path.exists(archive_name):
|
||||||
print("Fetching {}{} (cached)".format(self.title, self.version_suffix))
|
print("Fetching {}{} (cached)".format(self.title, self.version_suffix))
|
||||||
else:
|
else:
|
||||||
for base_url in self.downloads:
|
for url in self.get_download_urls():
|
||||||
url = self.get_download_url(base_url)
|
|
||||||
print("Fetching {}{} from {}".format(self.title, self.version_suffix, url))
|
print("Fetching {}{} from {}".format(self.title, self.version_suffix, url))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -542,7 +534,7 @@ class Program(object):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print("Verifying SHA256 checksum")
|
print("Verifying SHA256 checksum")
|
||||||
expected_checksum = self.checksums[self.get_file_name()]
|
expected_checksum = self.checksums[self.get_download_name()]
|
||||||
observed_checksum = sha256_of_file(archive_name)
|
observed_checksum = sha256_of_file(archive_name)
|
||||||
if expected_checksum != observed_checksum:
|
if expected_checksum != observed_checksum:
|
||||||
message = "SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format(
|
message = "SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format(
|
||||||
@ -553,14 +545,14 @@ class Program(object):
|
|||||||
else:
|
else:
|
||||||
sys.exit("Error: " + message)
|
sys.exit("Error: " + message)
|
||||||
|
|
||||||
if self.win32_zip:
|
if archive_name.endswith(".zip"):
|
||||||
archive = zipfile.ZipFile(archive_name)
|
archive = zipfile.ZipFile(archive_name)
|
||||||
else:
|
else:
|
||||||
archive = tarfile.open(archive_name, "r:gz")
|
archive = tarfile.open(archive_name, "r:gz")
|
||||||
|
|
||||||
archive.extractall(temp_dir)
|
archive.extractall(temp_dir)
|
||||||
archive.close()
|
archive.close()
|
||||||
os.chdir(os.path.join(temp_dir, self.get_download_name()))
|
os.chdir(os.path.join(temp_dir, strip_extensions(self.get_download_name())))
|
||||||
self.fetched = True
|
self.fetched = True
|
||||||
|
|
||||||
def set_identifiers(self):
|
def set_identifiers(self):
|
||||||
@ -875,13 +867,14 @@ class Patch(object):
|
|||||||
class RioLua(Lua):
|
class RioLua(Lua):
|
||||||
name = "lua"
|
name = "lua"
|
||||||
title = "Lua"
|
title = "Lua"
|
||||||
downloads = ["http://www.lua.org/ftp", "http://webserver2.tecgraf.puc-rio.br/lua/mirror/ftp"]
|
base_download_urls = ["http://www.lua.org/ftp", "http://webserver2.tecgraf.puc-rio.br/lua/mirror/ftp"]
|
||||||
win32_zip = False
|
work_base_download_url = "http://www.lua.org/work"
|
||||||
default_repo = "https://github.com/lua/lua"
|
default_repo = "https://github.com/lua/lua"
|
||||||
versions = [
|
versions = [
|
||||||
"5.1", "5.1.1", "5.1.2", "5.1.3", "5.1.4", "5.1.5",
|
"5.1", "5.1.1", "5.1.2", "5.1.3", "5.1.4", "5.1.5",
|
||||||
"5.2.0", "5.2.1", "5.2.2", "5.2.3", "5.2.4",
|
"5.2.0", "5.2.1", "5.2.2", "5.2.3", "5.2.4",
|
||||||
"5.3.0", "5.3.1", "5.3.2", "5.3.3", "5.3.4", "5.3.5"
|
"5.3.0", "5.3.1", "5.3.2", "5.3.3", "5.3.4", "5.3.5",
|
||||||
|
"5.4.0", "5.4.0-work1", "5.4.0-work2"
|
||||||
]
|
]
|
||||||
translations = {
|
translations = {
|
||||||
"5": "5.3.5",
|
"5": "5.3.5",
|
||||||
@ -889,6 +882,8 @@ class RioLua(Lua):
|
|||||||
"5.1.0": "5.1",
|
"5.1.0": "5.1",
|
||||||
"5.2": "5.2.4",
|
"5.2": "5.2.4",
|
||||||
"5.3": "5.3.5",
|
"5.3": "5.3.5",
|
||||||
|
"5.4": "5.4.0-work2",
|
||||||
|
"5.4.0": "5.4.0-work2",
|
||||||
"^": "5.3.5",
|
"^": "5.3.5",
|
||||||
"latest": "5.3.5"
|
"latest": "5.3.5"
|
||||||
}
|
}
|
||||||
@ -910,6 +905,8 @@ class RioLua(Lua):
|
|||||||
"lua-5.3.3.tar.gz" : "5113c06884f7de453ce57702abaac1d618307f33f6789fa870e87a59d772aca2",
|
"lua-5.3.3.tar.gz" : "5113c06884f7de453ce57702abaac1d618307f33f6789fa870e87a59d772aca2",
|
||||||
"lua-5.3.4.tar.gz" : "f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c",
|
"lua-5.3.4.tar.gz" : "f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c",
|
||||||
"lua-5.3.5.tar.gz" : "0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac",
|
"lua-5.3.5.tar.gz" : "0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac",
|
||||||
|
"lua-5.4.0-work1.tar.gz": "ada03980481110bfde44b3bd44bde4b03d72c84318b34d657b5b5a91ddb3912c",
|
||||||
|
"lua-5.4.0-work2.tar.gz": "68b7e8f1ff561b9a7e1c29de26ff99ac2a704773c0965a4fe1800b7657d5a057",
|
||||||
}
|
}
|
||||||
all_patches = {
|
all_patches = {
|
||||||
"When loading a file, Lua may call the reader function again after it returned end of input": """
|
"When loading a file, Lua may call the reader function again after it returned end of input": """
|
||||||
@ -1233,6 +1230,15 @@ class RioLua(Lua):
|
|||||||
else:
|
else:
|
||||||
self.dll_file = None
|
self.dll_file = None
|
||||||
|
|
||||||
|
def get_download_name(self):
|
||||||
|
return "{}-{}.tar.gz".format(self.name, self.version)
|
||||||
|
|
||||||
|
def get_download_urls(self):
|
||||||
|
if self.version.startswith("5.4.0-work"):
|
||||||
|
return ["{}/{}".format(self.work_base_download_url, self.get_download_name())]
|
||||||
|
else:
|
||||||
|
return ["{}/{}".format(base_download_url, self.get_download_name()) for base_download_url in self.base_download_urls]
|
||||||
|
|
||||||
def get_source_files_prefix(self):
|
def get_source_files_prefix(self):
|
||||||
# When installing PUC-Rio Lua from a git repo or local sources,
|
# When installing PUC-Rio Lua from a git repo or local sources,
|
||||||
# use directory structure of its GitHub mirror, where
|
# use directory structure of its GitHub mirror, where
|
||||||
@ -1478,8 +1484,7 @@ class RioLua(Lua):
|
|||||||
class LuaJIT(Lua):
|
class LuaJIT(Lua):
|
||||||
name = "LuaJIT"
|
name = "LuaJIT"
|
||||||
title = "LuaJIT"
|
title = "LuaJIT"
|
||||||
downloads = ["https://github.com/LuaJIT/LuaJIT/archive"]
|
base_download_url = "https://github.com/LuaJIT/LuaJIT/archive"
|
||||||
win32_zip = False
|
|
||||||
default_repo = "https://github.com/LuaJIT/LuaJIT"
|
default_repo = "https://github.com/LuaJIT/LuaJIT"
|
||||||
versions = [
|
versions = [
|
||||||
"2.0.0", "2.0.1", "2.0.2", "2.0.3", "2.0.4", "2.0.5",
|
"2.0.0", "2.0.1", "2.0.2", "2.0.3", "2.0.4", "2.0.5",
|
||||||
@ -1504,15 +1509,12 @@ class LuaJIT(Lua):
|
|||||||
"LuaJIT-2.1.0-beta3.tar.gz": "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8",
|
"LuaJIT-2.1.0-beta3.tar.gz": "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, version):
|
def get_download_name(self):
|
||||||
super(LuaJIT, self).__init__(version)
|
|
||||||
|
|
||||||
if self.source == "release" and self.version == "2.0.1":
|
|
||||||
# v2.0.1 tag is broken, use v2.0.1-fixed.
|
# v2.0.1 tag is broken, use v2.0.1-fixed.
|
||||||
self.fixed_version = "2.0.1-fixed"
|
return "{}-{}.tar.gz".format(self.name, "2.0.1-fixed" if self.version == "2.0.1" else self.version)
|
||||||
|
|
||||||
def get_download_url(self, base_url):
|
def get_download_urls(self):
|
||||||
return base_url + "/v" + self.fixed_version + ".tar.gz"
|
return ["{}/v{}.tar.gz".format(self.base_download_url, "2.0.1-fixed" if self.version == "2.0.1" else self.version)]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def major_version_from_version():
|
def major_version_from_version():
|
||||||
@ -1605,8 +1607,7 @@ class LuaJIT(Lua):
|
|||||||
class LuaRocks(Program):
|
class LuaRocks(Program):
|
||||||
name = "luarocks"
|
name = "luarocks"
|
||||||
title = "LuaRocks"
|
title = "LuaRocks"
|
||||||
downloads = ["http://luarocks.github.io/luarocks/releases"]
|
base_download_url = "http://luarocks.github.io/luarocks/releases"
|
||||||
win32_zip = os.name == "nt"
|
|
||||||
default_repo = "https://github.com/luarocks/luarocks"
|
default_repo = "https://github.com/luarocks/luarocks"
|
||||||
versions = [
|
versions = [
|
||||||
"2.0.8", "2.0.9", "2.0.10", "2.0.11", "2.0.12", "2.0.13",
|
"2.0.8", "2.0.9", "2.0.10", "2.0.11", "2.0.12", "2.0.13",
|
||||||
@ -1665,6 +1666,12 @@ class LuaRocks(Program):
|
|||||||
"luarocks-2.4.4-win32.zip" : "763d2fbe301b5f941dd5ea4aea485fb35e75cbbdceca8cc2f18726b75f9895c1",
|
"luarocks-2.4.4-win32.zip" : "763d2fbe301b5f941dd5ea4aea485fb35e75cbbdceca8cc2f18726b75f9895c1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_download_name(self):
|
||||||
|
return "{}-{}{}".format(self.name, self.version, "-win32.zip" if os.name == "nt" else ".tar.gz")
|
||||||
|
|
||||||
|
def get_download_urls(self):
|
||||||
|
return ["{}/{}".format(self.base_download_url, self.get_download_name())]
|
||||||
|
|
||||||
def is_luarocks_2_0(self):
|
def is_luarocks_2_0(self):
|
||||||
if self.source == "release":
|
if self.source == "release":
|
||||||
return self.versions.index(self.version) < self.versions.index("2.1.0")
|
return self.versions.index(self.version) < self.versions.index("2.1.0")
|
||||||
@ -1969,7 +1976,7 @@ def main(argv=None):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-l", "--lua", help="Version of standard PUC-Rio Lua to install. "
|
"-l", "--lua", help="Version of standard PUC-Rio Lua to install. "
|
||||||
"Version can be specified as a version number, e.g. 5.2 or 5.3.1. "
|
"Version can be specified as a version number, e.g. 5.2 or 5.3.1. "
|
||||||
"Versions 5.1.0 - 5.3.5 are supported, "
|
"Versions 5.1.0 - 5.3.5 are supported, as well as 5.4.0-work1 and 5.4.0-work2. "
|
||||||
"'^' or 'latest' can be used to install the latest stable version. "
|
"'^' or 'latest' can be used to install the latest stable version. "
|
||||||
"If the argument contains '@', sources will be downloaded "
|
"If the argument contains '@', sources will be downloaded "
|
||||||
"from a git repo using URI before '@' and using part after '@' as git reference "
|
"from a git repo using URI before '@' and using part after '@' as git reference "
|
||||||
|
|||||||
@ -146,3 +146,7 @@ class TestCLI(unittest.TestCase):
|
|||||||
"activate 2: {}{}{}".format(path2, os.pathsep, path),
|
"activate 2: {}{}{}".format(path2, os.pathsep, path),
|
||||||
"deactivate 2: {}".format(path)
|
"deactivate 2: {}".format(path)
|
||||||
], from_prefix=False)
|
], from_prefix=False)
|
||||||
|
|
||||||
|
def test_install_lua_5_4_with_luarocks_3(self):
|
||||||
|
self.assertHererocksSuccess(["--lua", "5.4", "--luarocks", "3"])
|
||||||
|
self.assertHererocksSuccess(["--lua", "5.4.0-work1", "--luarocks", "3"])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user