diff --git a/README.rst b/README.rst index 45d63ed..8e87e40 100644 --- a/README.rst +++ b/README.rst @@ -96,24 +96,26 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the ``build_docker`` pipeline instead. -Optional tools (``--build-env-args``) -===================================== +Optional build steps (``--build-env-args``) +=========================================== -Some development tools are **not** installed by default. They are enabled with -a flag passed as a build environment variable using ``--build-env-args``, which -generates an ``ENV =TRUE`` line in the Dockerfile. If the flag is not -defined, the installation step is skipped. +Some development tools and build steps are **not** enabled by default. They are +enabled with a flag passed as a build environment variable using +``--build-env-args``, which generates an ``ENV =TRUE`` line in the +Dockerfile. If the flag is not defined, the step is skipped. .. list-table:: :widths: 30 70 :header-rows: 1 * - Flag - - Installs + - Enables * - ``VIM_INSTALL`` - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration * - ``ZSH_INSTALL`` - zsh + oh-my-zsh with the ``odoo-shippable`` theme + * - ``CHOWN_UID_GID`` + - Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem Example enabling more than one:: diff --git a/src/travis2docker/templates/build.sh b/src/travis2docker/templates/build.sh index 9f59b3a..a52596d 100644 --- a/src/travis2docker/templates/build.sh +++ b/src/travis2docker/templates/build.sh @@ -220,21 +220,35 @@ set_odoo_ids(){ # OrchestSH images (ORCHESTSH=True) use UID/GID 5410 for the odoo user; # older images use 1000/1001. A mismatch causes permission issues when # sharing files across containers, so align both to 5410 when they differ. + if [ -z ${CHOWN_UID_GID+x} ]; + then + echo "CHOWN_UID_GID was not defined. Skipping odoo UID/GID alignment. Use t2d parameter --build-env-args=CHOWN_UID_GID to be autoconfigured." + return 0; + fi CURRENT_UID=$(id -u odoo) CURRENT_GID=$(id -g odoo) NEW_ID=5410 + if [ "${CURRENT_UID}" = "${NEW_ID}" ] && [ "${CURRENT_GID}" = "${NEW_ID}" ]; then + echo "odoo UID/GID already set to ${NEW_ID}. Nothing to do." + return 0; + fi if [ "${CURRENT_GID}" != "${NEW_ID}" ]; then echo "Changing odoo GID from ${CURRENT_GID} to ${NEW_ID}" groupmod -g "${NEW_ID}" odoo - # groupmod does not re-chown any file - find / -xdev -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + 2>/dev/null || true fi if [ "${CURRENT_UID}" != "${NEW_ID}" ]; then echo "Changing odoo UID from ${CURRENT_UID} to ${NEW_ID}" usermod -u "${NEW_ID}" odoo - # usermod only re-chowns files inside the home directory - find / -xdev -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + 2>/dev/null || true fi + # groupmod does not re-chown any file and usermod only re-chowns files inside + # the home directory, so the leftovers are re-chowned here. Both predicates are + # evaluated in a single filesystem traversal using the "," operator: walking the + # whole filesystem twice is what makes this step slow. The branch whose ID did + # not change simply re-applies the very same ID, so it is a no-op. + find / -xdev \ + \( -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + \) , \ + \( -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + \) \ + 2>/dev/null || true } configure_vim(){ diff --git a/src/travis2docker/travis2docker.py b/src/travis2docker/travis2docker.py index f42102b..e2a4781 100644 --- a/src/travis2docker/travis2docker.py +++ b/src/travis2docker/travis2docker.py @@ -135,7 +135,7 @@ def copy_path(self, path): if src.is_dir(): try: shutil.copytree(src, dest_path) - except shutil.Error: # pylint: disable=except-pass + except shutil.Error: # ruff: ignore[except-pass] pass # There are permissions errors to copy elif src.is_file(): shutil.copy(src, dest_path)