diff --git a/buildenliven.py b/buildenliven.py old mode 100644 new mode 100755 index cd7f6e8..4a299ad --- a/buildenliven.py +++ b/buildenliven.py @@ -1,44 +1,18 @@ #!/usr/bin/env python ''' This script is a remake of the ENLIVEN build script in Python using -Bucket_Game as the basis. +bucket_game as the basis. ''' from __future__ import print_function - import sys -import platform import os +import configparser -profile = None -if platform.system() == "Windows": - profile = os.environ.get('USERPROFILE') -else: - profile = os.environ.get('HOME') - -# see -def error(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) - -try: - import mtanalyze -except ModuleNotFoundError as ex: - # tryMTA = os.path.join(profile, "git", "mtanalyze") - tryMTA = os.path.abspath(os.path.join("..", "mtanalyze")) - if os.path.isdir(tryMTA): - sys.path.append(tryMTA) - import mtanalyze - else: - error("") - error("You must install mtanalyze alongside") - error("EnlivenMinetest such that ../mtanalize/mtanalize exists") - error("such as via:") - error(" git clone https://github.com/poikilos/mtanalyze {}" - "".format(tryMTA)) - error("") - # raise tryMTA - exit(1) - -# from mtanalyze import profile_path +from pyenliven import ( + error, + getSGPath, + profile, +) gamespec = {} gamespec['remove_mods'] = [ @@ -48,32 +22,25 @@ gamespec['remove_mods'] = [ "more_chests", # See https://github.com/poikilos/EnlivenMinetest/issues/446 "emeralds", # See https://github.com/poikilos/EnlivenMinetest/issues/497 "give_initial_stuff", # or make it configurable (It only uses a give_initial_stuff boolean, no configurable item list) + # TODO: more are at https://github.com/poikilos/EnlivenMinetest/issues/310 ] -myDir = os.path.dirname(os.path.abspath(__file__)) -mods_stopgap = os.path.join(myDir, "patches", "mods-stopgap") -if not os.path.isdir(mods_stopgap): - error("Error: \"{}\" is missing.".format(mods_stopgap)) - exit(1) -gamespec['local_mods_paths'] = [] -gamespec['local_mods_paths'].append(mods_stopgap) -# NOTE: get a git repo's origin via: git remote show origin -def getSGPath(stopgap_mod_name): - return os.path.join(mods_stopgap, stopgap_mod_name) +gamespec['local_mods_paths'] = [] +gamespec['local_mods_paths'].append("mods_stopgap") gamespec['add_mods'] = [ # {'repo':"https://github.com/poikilos/homedecor_ua"}, - {'src_path': getSGPath("animal_materials_legacy")}, + {'name': "animal_materials_legacy"}, {'repo':"https://github.com/minetest-mods/ccompass.git"}, {'repo':"https://github.com/octacian/chat3.git"}, {'repo':"https://github.com/poikilos/compassgps.git"}, - {'src_path': getSGPath("elk_legacy")}, + {'name': "elk_legacy"}, {'repo':"https://github.com/MinetestForFun/fishing.git"}, - {'src_path': getSGPath("glooptest_missing")}, + {'name': "glooptest_missing"}, {'repo':"https://github.com/minetest-mods/item_drop.git"}, {'repo':"https://github.com/poikilos/metatools.git"}, - {'src_path': getSGPath("nftools_legacy")}, - {'src_path': getSGPath("glooptest_missing")}, + {'name': "nftools_legacy"}, + {'name': "glooptest_missing"}, {'repo':"https://github.com/poikilos/slimenodes.git"}, {'repo':"https://github.com/BenjieFiftysix/sponge.git"}, {'repo':"https://github.com/poikilos/throwing.git"}, # Can utilize toolranks, toolranks_extras, wielded_light @@ -188,16 +155,52 @@ gamespec['disable_mobs'] = [ "old_lady", ] -warnings = ''' +""" +warning = ''' WARNINGS: (Bucket_Game 200527) - The "rope" required for making a fishing rod has no recipe! See ''' +""" +warnings = [] +valid_bases = ['Bucket_Game', "bucket_ game"] def main(): - print(warnings) + for warning in warnings: + error(warning) + tryGameDir = os.getcwd() + error('* examining "{}"'.format(tryGameDir)) + gameConfName = "game.conf" + gameConfPath = os.path.join(tryGameDir, gameConfName) + if not os.path.isfile(gameConfPath): + raise ValueError( + 'You must run this command from bucket_game, but there is' + ' no "{}" in "{}"' + ''.format(gameConfName, tryGameDir) + ) + config = configparser.ConfigParser() + with open(gameConfPath, 'r') as ins: + config.read_string('[top]\n' + ins.read()) + # ^ insert a section since ConfigParser requires sections. + gameName = config['top'].get("name") + error(' * detected {} from {}' + ''.format(gameName, gameConfName)) + if gameName not in valid_bases: + raise ValueError( + '{} does not appear to be compatible with the enliven build' + ' script. You must run this in a directory with one of the' + ' following name' + ' strings in {}: {}' + ''.format(tryGameDir, gameConfName, valid_bases) + ) + + targetMT = os.path.join(profile, "minetest") + # ^ TODO: Get this from mtanalyze? + targetGames = os.path.join(targetMT, "games") + target = os.path.join(targetGames, "ENLIVEN") + centerOfTheSunTarget = raise NotImplementedError("pyenliven build") if __name__ == "__main__": diff --git a/docker/lmk-libraries.devuan-chimera/Dockerfile b/docker/lmk-libraries.devuan-chimera/Dockerfile index 1349521..936613c 100644 --- a/docker/lmk-libraries.devuan-chimera/Dockerfile +++ b/docker/lmk-libraries.devuan-chimera/Dockerfile @@ -2,7 +2,7 @@ FROM dyne/devuan:chimaera # An absolute path for COPY doesn't work ('/' is removed from the beginning). COPY linux-minetest-kit.zip /opt COPY lmk.rc /opt -COPY build-lmk.sh /opt +# COPY build-lmk.sh /opt COPY install-minetest-build-deps.sh /opt RUN apt-get update RUN apt-get install -y unzip diff --git a/docker/lmk-libraries.devuan-chimera/build-lmk.sh b/docker/lmk-libraries.devuan-chimera/build-lmk.sh index 852ddf9..69dfe75 100755 --- a/docker/lmk-libraries.devuan-chimera/build-lmk.sh +++ b/docker/lmk-libraries.devuan-chimera/build-lmk.sh @@ -43,11 +43,11 @@ if [ $? -ne 0 ]; then exit 1; fi # $repo_build_libs_cmd # if [ $? -ne 0 ]; then exit 1; fi echo -echo "* building program using $repo_build_cmd..." -$repo_build_cmd +echo "* building program using $build_finetest_server_cmd..." +$build_finetest_server_cmd code=$? if [ $code -ne 0 ]; then - echo "$repo_build_cmd FAILED (code $code)" + echo "$build_finetest_server_cmd FAILED (code $code)" exit $code else echo "SUCCESS" diff --git a/docker/lmk-libraries.devuan-chimera/lmk.rc b/docker/lmk-libraries.devuan-chimera/lmk.rc index 1133b40..426a1ae 100644 --- a/docker/lmk-libraries.devuan-chimera/lmk.rc +++ b/docker/lmk-libraries.devuan-chimera/lmk.rc @@ -2,7 +2,7 @@ contained_repos=/opt docker_image_build_script_name="lmk.devuan-chimaera.sh" contained_arc="$contained_repos/linux-minetest-kit.zip" -# ^ This must always be in sync with "COPY linux-minetest-kit.zip /opt" in Dockerfile +# ^ This must match the name in "COPY linux-minetest-kit.zip /opt" in Dockerfile contained_repo=$contained_repos/linux-minetest-kit contained_user=minebest # ^ must match the useradd command in Dockerfile @@ -20,9 +20,10 @@ good_repo_flag_name="mtcompile-program.pl" repo_build_assumptions_cmd="/opt/install-minetest-build-deps.sh" # repo_build_libs_cmd="bash -e ./mtcompile-libraries.sh build" # ^ moved to the Dockerfile for the libraries image -# repo_build_cmd="./mtcompile-program.pl --build --classic --client" -repo_build_cmd="./mtcompile-program.pl --build --finetest --server" +# build_finetest_server_cmd="./mtcompile-program.pl --build --classic --client" +# build_finetest_server_cmd="./mtcompile-program.pl --build --finetest --server" +# ^ moved to server-finetest-devuan-chimera/Dockerfile contained_good_repo_flag_path="$contained_repo/$good_repo_flag_name" -run_all_build_commands_script=/opt/build-lmk.sh +# run_all_build_commands_script=/opt/build-lmk.sh echo "lmk.rc finished loading." diff --git a/docker/lmk.devuan-chimaera.sh b/docker/lmk.devuan-chimaera.sh index e9d311b..798bd7c 100755 --- a/docker/lmk.devuan-chimaera.sh +++ b/docker/lmk.devuan-chimaera.sh @@ -20,15 +20,16 @@ or Docker's own documentation at . END fi -container_name="lmk-devuan-chimaera" -image_name="lmk-devuan-chimaera-img" +container_name="linux-minetest-kit-build-libraries-devuan-chimaera" +image_name="linux-minetest-kit/libraries-devuan-chimaera" +# ^ This must match the one used in the "FROM" statement in server-finetest-devuan-chimera/Dockerfile # client_classic_image=linux-minetest-kit/client-classic -server_finetest_image=linux-minetest-kit/server-finetest +server_finetest_image="linux-minetest-kit/server-finetest-devuan-chimera" # client_classic_container="minetest-client-classic" server_container="minetestserver-finetest" -docker_image_dir="lmk.devuan-chimaera" +docker_image_dir="lmk-libraries.devuan-chimaera" if [ ! -d "$docker_image_dir" ]; then - echo "* $me must run from the directory containing the container image directory: $docker_image_dir" + echo "* $0 must run from the directory containing the container image directory: $docker_image_dir" exit 1 fi container_build_blob=$docker_image_dir/linux-minetest-kit.zip @@ -39,7 +40,6 @@ source $docker_image_dir/lmk.rc if [ $? -ne 0 ]; then exit 1 fi -me=lmk.devuan-chimaera.sh if [ "@$DL_SRC_PATH" = "@" ]; then # DL_SRC_PATH="$HOME/Downloads/$DL_SRC_NAME" diff --git a/docker/server-finetest-devuan-chimera/Dockerfile b/docker/server-finetest-devuan-chimera/Dockerfile new file mode 100644 index 0000000..772a9a1 --- /dev/null +++ b/docker/server-finetest-devuan-chimera/Dockerfile @@ -0,0 +1,3 @@ +FROM linux-minetest-kit/libraries-devuan-chimaera +WORKDIR /opt/linux-minetest-kit +RUN ./mtcompile-program.pl --build --finetest --server