diff --git a/docs/development/setup-advanced.md b/docs/development/setup-advanced.md index 6fdda879bf..afa0332a1d 100644 --- a/docs/development/setup-advanced.md +++ b/docs/development/setup-advanced.md @@ -224,8 +224,6 @@ Now run these commands: ``` sudo ./scripts/lib/install-node yarn install -sudo mkdir /srv/zulip-emoji-cache -sudo chown -R `whoami`: /srv/zulip-emoji-cache ./tools/setup/emoji/build_emoji ./scripts/setup/inline_email_css.py ./tools/setup/build_pygments_data diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.py index 936c093589..2543898086 100755 --- a/tools/lib/provision_inner.py +++ b/tools/lib/provision_inner.py @@ -8,7 +8,7 @@ import shutil ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(ZULIP_PATH) -from scripts.lib.zulip_tools import run, run_as_root, OKBLUE, ENDC, \ +from scripts.lib.zulip_tools import run, OKBLUE, ENDC, \ get_dev_uuid_var_path, file_or_package_hash_updated from version import PROVISION_VERSION @@ -16,15 +16,6 @@ from version import PROVISION_VERSION from tools.setup.generate_zulip_bots_static_files import generate_zulip_bots_static_files VENV_PATH = "/srv/zulip-py3-venv" - -is_travis = 'TRAVIS' in os.environ - -# TODO: De-duplicate this with emoji_dump.py -EMOJI_CACHE_PATH = "/srv/zulip-emoji-cache" -if is_travis: - # In Travis CI, we don't have root access - EMOJI_CACHE_PATH = "/home/travis/zulip-emoji-cache" - UUID_VAR_PATH = get_dev_uuid_var_path() def create_var_directories() -> None: @@ -156,9 +147,6 @@ def main(options: argparse.Namespace) -> int: # The `build_emoji` script requires `emoji-datasource` package # which we install via npm; thus this step is after installing npm # packages. - if not os.access(EMOJI_CACHE_PATH, os.W_OK): - run_as_root(["mkdir", "-p", EMOJI_CACHE_PATH]) - run_as_root(["chown", "%s:%s" % (os.getuid(), os.getgid()), EMOJI_CACHE_PATH]) run(["tools/setup/emoji/build_emoji"]) # copy over static files from the zulip_bots package diff --git a/tools/setup/emoji/build_emoji b/tools/setup/emoji/build_emoji index 9b736a41ab..a70e9d16d3 100755 --- a/tools/setup/emoji/build_emoji +++ b/tools/setup/emoji/build_emoji @@ -17,7 +17,7 @@ from emoji_names import EMOJI_NAME_MAPS ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../') sys.path.append(ZULIP_PATH) -from scripts.lib.zulip_tools import generate_sha1sum_emoji +from scripts.lib.zulip_tools import generate_sha1sum_emoji, run_as_root TARGET_EMOJI_DUMP = os.path.join(ZULIP_PATH, 'static', 'generated', 'emoji') TARGET_EMOJI_STYLES = os.path.join(ZULIP_PATH, 'static', 'generated', 'emoji-styles') @@ -77,6 +77,14 @@ if 'TRAVIS' in os.environ: EMOJI_CACHE_PATH = "/home/travis/zulip-emoji-cache" def main() -> None: + if not os.access(EMOJI_CACHE_PATH, os.W_OK): + # Note: In production, this block will fail, since we don't + # assume sudo access; but it should never run in production + # anyway, because EMOJI_CACHE_PATH is created by puppet before + # build_emoji would be run. + run_as_root(["mkdir", "-p", EMOJI_CACHE_PATH]) + run_as_root(["chown", "%s:%s" % (os.getuid(), os.getgid()), EMOJI_CACHE_PATH]) + sha1_hexdigest = generate_sha1sum_emoji(ZULIP_PATH) source_emoji_dump = os.path.join(EMOJI_CACHE_PATH, sha1_hexdigest, 'emoji') success_stamp = os.path.join(source_emoji_dump, '.success-stamp')