Browse Source

Make version optional. Fix dirname of classic. Return all errors from install_minetest.

master
poikilos 1 year ago
parent
commit
878aa1a349
  1. 83
      utilities/install-minetest-kit

83
utilities/install-minetest-kit

@ -4,7 +4,7 @@ Usage:
deploy-minetest-kit <project name> [--from <built dir>] [options] deploy-minetest-kit <project name> [--from <built dir>] [options]
The available project names are: The available project names are:
classic (or final) to install ~/minetest-rsync, classic (or final or minetest) to install ~/minetest-rsync,
finetest (or fine) to install ~/finetest-rsync finetest (or fine) to install ~/finetest-rsync
(for the game that ripped off Multicraft.org's name), or (for the game that ripped off Multicraft.org's name), or
trolltest (or troll) to install ~/trolltest-rsync (based on MT5). trolltest (or troll) to install ~/trolltest-rsync (based on MT5).
@ -62,8 +62,10 @@ KEYWORDS = ("sandbox;world;mining;crafting;blocks;nodes;multiplayer;"
"roleplaying;minetest;") "roleplaying;minetest;")
project_metas = { project_metas = {
'classic': { 'minetest': { # minetest is the project name (in mtsrc/newline dir)
'name_fmt': "Final Minetest ({})", 'dirname': "minetest",
'name_and_version_fmt': "Final Minetest ({})",
'name': "Final Minetest",
'GenericName': "Final Minetest", 'GenericName': "Final Minetest",
'exe_relpath': os.path.join("bin", "minetest"), 'exe_relpath': os.path.join("bin", "minetest"),
'platform_icon_relpath': { 'platform_icon_relpath': {
@ -75,7 +77,9 @@ project_metas = {
'shortcut_name_noext': "org.minetest.minetest", 'shortcut_name_noext': "org.minetest.minetest",
}, },
'finetest': { 'finetest': {
'name_fmt': "Finetest ({})", 'dirname': "finetest",
'name_and_version_fmt': "Finetest ({})",
'name': "Finetest",
'GenericName': "Finetest", 'GenericName': "Finetest",
'exe_relpath': os.path.join("bin", "finetest"), 'exe_relpath': os.path.join("bin", "finetest"),
'platform_icon_relpath': { 'platform_icon_relpath': {
@ -87,7 +91,9 @@ project_metas = {
'shortcut_name_noext': "org.minetest.finetest", 'shortcut_name_noext': "org.minetest.finetest",
}, },
'trolltest': { 'trolltest': {
'name_fmt': "Trolltest (minetest.org {})", 'dirname': "trolltest",
'name_and_version_fmt': "Trolltest ({}) (minetest.org)",
'name': "Trolltest (minetest.org)",
'GenericName': "Trolltest", 'GenericName': "Trolltest",
'platform_icon_relpath': { 'platform_icon_relpath': {
'Linux': os.path.join("misc", "minetest.svg"), 'Linux': os.path.join("misc", "minetest.svg"),
@ -173,11 +179,14 @@ def main():
install_from, install_from,
appenders=appenders, appenders=appenders,
) )
error = results.get('error')
if error is not None:
echo0("Error: %s" % error)
return 0 return 0
def install_minetest(project_name, src, dst=None, versioned_dirname=None, def install_minetest(project_name, src, dst=None, versioned_dirname=None,
appenders=[""]): appenders=[""], version=VERSION):
"""Install Minetest & generate a shortcut based on the destination. """Install Minetest & generate a shortcut based on the destination.
The metadata written to shortcut must be the installed metadata! The metadata written to shortcut must be the installed metadata!
@ -186,7 +195,7 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
- shortcut_dst generated based on OS and shortcut_name_noext - shortcut_dst generated based on OS and shortcut_name_noext
Args: Args:
project_name (string): Must be classic, finetest, or trolltest. project_name (string): Must be minetest, finetest, or trolltest.
src (string): The location of the minetest install source to src (string): The location of the minetest install source to
copy. copy.
dst (Optional[string]): Install here. If None, it will become dst (Optional[string]): Install here. If None, it will become
@ -195,9 +204,12 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
versioned_dirname (Optional[string]): Set the install directory versioned_dirname (Optional[string]): Set the install directory
name (ignored if dst is set). If None, it will become the name (ignored if dst is set). If None, it will become the
default. Defaults to project_name + "-" + VERSION (such as default. Defaults to project_name + "-" + VERSION (such as
minetest-rsync). minetest-rsync). If VERSION is blank or None, the
versioned_dirname will become the same as the dirname
(such as minetest).
appenders (list): Install client if [""], or server if appenders (list): Install client if [""], or server if
["server"]. Include both to require that both were built. ["server"]. Include both to require that both were built.
version (string): Version to append to the dirname.
Returns: Returns:
dict: "destination" is where it was installed if at all. See dict: "destination" is where it was installed if at all. See
@ -205,19 +217,17 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
install. install.
""" """
arg = project_name arg = project_name
project_name = arg_to_mode(arg) project_name = arg_to_project_name(arg)
if project_name is None: if project_name is None:
usage() usage()
echo0("{} is not a valid project name.".format(arg)) return {
return 1 'error': "{} is not a valid project name.".format(arg),
}
src_files = expected_src_files(src, project_name, appenders) src_files = expected_src_files(src, project_name, appenders)
if src_files is None: if src_files is None:
usage() usage()
raise NotImplementedError( error = "There are no source files for {}".format(project_name)
"There are no source files for {}" raise NotImplementedError(error)
"".format(project_name)
)
return 1
missing_files = [] missing_files = []
for src_file in src_files: for src_file in src_files:
@ -225,12 +235,22 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
missing_files.append(src_file) missing_files.append(src_file)
if len(missing_files) > 0: if len(missing_files) > 0:
echo0("Error: The following files are required to be compiled" error = ("Error: The following files are required to be compiled"
" {} before install but are not present: {}" " {} before install but are not present: {}"
"".format(project_name, missing_files)) "".format(project_name, missing_files))
return 1 return {
'error': error,
}
project_meta = project_metas[project_name]
dirname = project_meta['dirname']
versioned_dirname = dirname
append_version = False
if (version is not None) and (len(version.strip()) > 0):
versioned_dirname += "-" + version
append_version = True
versioned_dirname = project_name + "-" + VERSION
if dst is None: if dst is None:
if platform.system() == "Windows": if platform.system() == "Windows":
GAMES = "C:\\games" GAMES = "C:\\games"
@ -240,6 +260,8 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
else: else:
dst = os.path.join(HOME, versioned_dirname) dst = os.path.join(HOME, versioned_dirname)
warning = None warning = None
if not os.path.isdir(dst): if not os.path.isdir(dst):
write0('Installing {} to "{}"...'.format(project_name, dst)) write0('Installing {} to "{}"...'.format(project_name, dst))
shutil.copytree(src, dst) shutil.copytree(src, dst)
@ -251,9 +273,10 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
echo0('WARNING: {}'.format(warning)) echo0('WARNING: {}'.format(warning))
project_meta = project_metas[project_name]
Name = project_meta['name_fmt'].format(VERSION) Name = project_meta['name']
if append_version:
Name = project_meta['name_and_version_fmt'].format(version)
GenericName = project_meta['GenericName'] GenericName = project_meta['GenericName']
Exec = os.path.join(dst, project_meta['exe_relpath']) Exec = os.path.join(dst, project_meta['exe_relpath'])
icon_relpath = project_meta['platform_icon_relpath'].get(platform.system()) icon_relpath = project_meta['platform_icon_relpath'].get(platform.system())
@ -302,8 +325,8 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
# ^ Run the game & close Command Prompt immediately. # ^ Run the game & close Command Prompt immediately.
# ^ First arg is Command Prompt title, so leave it blank. # ^ First arg is Command Prompt title, so leave it blank.
else: else:
echo0("Icon install isn't implemented for {}." warning = ("Icon install isn't implemented for {}."
"".format(platform.system())) "".format(platform.system()))
return { return {
"warning": warning, # may be None "warning": warning, # may be None
"destination": dst, "destination": dst,
@ -315,11 +338,13 @@ def install_minetest(project_name, src, dst=None, versioned_dirname=None,
# """ # """
def arg_to_mode(arg): def arg_to_project_name(arg):
if arg == "final": if arg == "final":
return "classic" return "minetest"
elif arg == "classic": elif arg == "classic":
return "classic" return "minetest"
elif arg == "minetest":
return "minetest"
elif arg == "trolltest": elif arg == "trolltest":
return "trolltest" return "trolltest"
elif arg == "troll": elif arg == "troll":
@ -361,7 +386,7 @@ def expected_src_files(src, project_name, appenders=[""]):
for appender in appenders: for appender in appenders:
src_file = None src_file = None
if project_name == "classic": if project_name == "minetest":
src_file = os.path.join(src, "bin", "minetest"+appender) src_file = os.path.join(src, "bin", "minetest"+appender)
elif project_name == "trolltest": elif project_name == "trolltest":
src_file = os.path.join(src, "bin", "minetest"+appender) src_file = os.path.join(src, "bin", "minetest"+appender)

Loading…
Cancel
Save