diff --git a/.UPGRADE_INSTRUCTIONS b/.UPGRADE_INSTRUCTIONS new file mode 100644 index 000000000..f1def3218 --- /dev/null +++ b/.UPGRADE_INSTRUCTIONS @@ -0,0 +1,6 @@ +Manually apply the ngeo application changes as shown in the `ngeo.diff` file. +You should apply the changes shown in the diff file on `CONST_create_template/` on your project's ``. +Some advice to be more efficient: if the changes on a file concern a file that you never customize, you can simply copy the new file from `CONST_create_template` (`cp CONST_create_template/ `).You can furthermore add this file to the `unmanaged_files` section of the `project.yaml` file, to avoid its contents appearing in the diff file for the next upgrade. +Note that you can also apply them using: git apply --3way ngeo.diff +To continue, type: +./upgrade 2.7.1.2 10 diff --git a/.upgrade.yaml b/.upgrade.yaml new file mode 100644 index 000000000..528b26324 --- /dev/null +++ b/.upgrade.yaml @@ -0,0 +1,191 @@ +--- +# The list (by include, exclude) of default files that will not be overwritten by the upgrade. +# That that can be extended with managed_files or reduced with unmanaged_files from the +# project.yaml file in the project root directory. +default_project_file: + include: + - geoportal/setup\.py + - geoportal/vars\.yaml + - geoportal/Makefile + - geoportal/geomapfish_geoportal/__init__\.py + - geoportal/geomapfish_geoportal/templates/.* + - geoportal/geomapfish_geoportal/locale/.* + - geoportal/geomapfish_geoportal/static/.* + - geoportal/geomapfish_geoportal/static-ngeo/.* + - print/print-apps/.* + - mapserver/.* + - tilegeneration/config\.yaml\.tmpl + - project\.yaml + - docker-compose\.yaml + - env\.project + - README\.rst + - \.github/workflows/main\.yaml + - \.github/workflows/rebuild\.yaml + exclude: + - mapserver/demo\.map\.tmpl + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/image/favicon\.ico + +# Files ignored when creating the diff files => will just be left untouched. +no_diff: + - .*\.po + - CONST_.+ + - .*/CONST_.+ + +# Files that will be present in the CONST_create_template but will not be considered in the upgrade. +# Used to provide the alt applications => does not disturb the user during upgrade. +extra: + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/mobile_alt\.html\.ejs + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/oeedit\.html\.ejs + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/Controllermobile_alt\.js + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/Controlleroeedit\.js + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/sass/mobile_alt\.scss + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/sass/vars_mobile_alt\.scss + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/sass/oeedit\.scss + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/sass/vars_oeedit\.scss + - geoportal/interfaces/desktop_alt\.html\.mako + - geoportal/geomapfish_geoportal/static/images/background-layer-button\.png + +# Automated file system operations: +# Remove some files or directories: +# - action: remove +# paths: +# - +# Move a file: +# - action: move +# from: +# to: +upgrade_files: + - action: remove + paths: + - docker-run + - .config + - docker-compose-run + - docker-compose-build.yaml + - geoportal/jsbuild/ + - geoportal/{package}_geoportal/templates/api/ + - geoportal/{package}_geoportal/static/lib/.gitignore + - testdb/ + - vars_convert2tmpl.yaml + - CONST_convert2tmpl.mk + - CONST_config-schema.yaml + - CONST_Makefile + - CONST_vars.yaml + - project.yaml.mako + - geoportal/geomapfish_geoportal/static/apihelp/images + - action: move + from: .eslintrc + to: geoportal/.eslintrc + - action: move + from: language_mapping + to: geoportal/language_mapping + - action: move + from: lingua-client.cfg + to: geoportal/lingua-client.cfg + - action: move + from: lingua-server.cfg + to: geoportal/lingua-server.cfg + - action: move + from: vars.yaml + to: geoportal/vars.yaml + - action: move + from: geoportal/webpack.apps.js.mako + to: geoportal/webpack.apps.js + - action: move + from: geoportal/Dockerfile.mako + to: geoportal/Dockerfile + - action: move + from: geoportal/development.ini.mako + to: geoportal/development.ini + - action: move + from: geoportal/production.ini.mako + to: geoportal/production.ini + - action: move + from: .env.mako + to: .env.sample + - action: move + from: Dockerfile.mako + to: Dockerfile + - action: move + from: tools/extract-messages.js + to: geoportal/tools/extract-messages.js + - action: move + from: scripts/deploy-docker + to: scripts/publish-docker + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/index.html + to: geoportal/geomapfish_geoportal/static/apihelp/index.html + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/rainbow-custom.min.js + to: geoportal/geomapfish_geoportal/static/apihelp/rainbow-custom.min.js + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/github.css + to: geoportal/geomapfish_geoportal/static/apihelp/github.css + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/data.txt + to: geoportal/geomapfish_geoportal/static/apihelp/data.txt + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/img + to: geoportal/geomapfish_geoportal/static/apihelp/img + - action: remove + paths: + - geoportal/geomapfish_geoportal/static/apihelp/track0.gpx + - geoportal/geomapfish_geoportal/static-ngeo/api/apihelp/ + - action: remove + paths: + - geoportal/geomapfish_geoportal/static/css/proj.css + - geoportal/geomapfish_geoportal/static/css/proj-map.css + - geoportal/geomapfish_geoportal/static/css/proj-widgets.css + - geoportal/geomapfish_geoportal/static/js/ + - action: remove + paths: + - scripts/CONST_clone_schema.sql + - action: remove + paths: + - front + - front_dev + - bin/entrypoint + - bin/eval-templates + - action: move + from: .env.sample + to: env.sample + - action: remove + paths: + - cgxp_revision + - action: remove + paths: + - .circleci/config.yml + - .travis.yml + - action: move + from: env.sample + to: env.default + - action: remove + paths: + - mapserver/CONST_example_map + - action: remove + paths: + - geoportal/geomapfish_geoportal/static-ngeo/js/apps/image/crosshair.svg + - action: move + from: geoportal/geomapfish_geoportal/static-ngeo/js/apps/image/favicon.ico + to: geoportal/geomapfish_geoportal/static/images/favicon.ico + override: True + - action: move + from: .github/workflows/ci.yaml + to: .github/workflows/main.yaml + - action: remove + paths: + - scripts/publish-docker + - action: remove + paths: + - geoportal/geomapfish_geoportal/locale/.emptyfolder + - action: move + from: geoportal/.eslintrc + to: geoportal/.eslintrc.yaml + - action: remove + paths: + - qgisserver/geomapfish.yaml.tmpl + - action: remove + paths: + - ci/trigger + - action: remove + paths: + - yamllint.yaml diff --git a/CONST_create_template/env.default b/CONST_create_template/env.default index 918b25925..d0fa0b514 100644 --- a/CONST_create_template/env.default +++ b/CONST_create_template/env.default @@ -1,5 +1,5 @@ # Default values for c2cgeoportal -GEOMAPFISH_VERSION=2.7.1.1 +GEOMAPFISH_VERSION=2.7.1.2 GEOMAPFISH_MAIN_VERSION=2.7 GEOMAPFISH_MAIN_MINOR_VERSION=2.7.1 COMPOSE_PROJECT_NAME=geomapfish diff --git a/CONST_create_template/geoportal/vars.yaml b/CONST_create_template/geoportal/vars.yaml index 89625dde4..dfade1f1d 100644 --- a/CONST_create_template/geoportal/vars.yaml +++ b/CONST_create_template/geoportal/vars.yaml @@ -295,6 +295,11 @@ vars: # connection_kwargs: # db: '{REDIS_DB}' + # This parameter set the list of hosts allowed to use the iframe api. + # 'self' will block all external usage, you must add additional hosts separated by space. + # see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors + content_security_policy_iframe_api_frame_ancestors: "'self'" + # Control the HTTP headers headers: dynamic: &header {} diff --git a/CONST_create_template/geoportal/webpack.apps.js b/CONST_create_template/geoportal/webpack.apps.js index 4a6b3bf22..aebbc7cf3 100644 --- a/CONST_create_template/geoportal/webpack.apps.js +++ b/CONST_create_template/geoportal/webpack.apps.js @@ -21,7 +21,7 @@ for (const filename of ls(path.resolve(__dirname, 'geomapfish_geoportal/static-n chunks: [name], vars: { entry_point: '${VISIBLE_ENTRY_POINT}', - version: '2.7.1.1', + version: '2.7.1.2', cache_version: '${CACHE_VERSION}', }, }) diff --git a/env.default b/env.default index 918b25925..d0fa0b514 100644 --- a/env.default +++ b/env.default @@ -1,5 +1,5 @@ # Default values for c2cgeoportal -GEOMAPFISH_VERSION=2.7.1.1 +GEOMAPFISH_VERSION=2.7.1.2 GEOMAPFISH_MAIN_VERSION=2.7 GEOMAPFISH_MAIN_MINOR_VERSION=2.7.1 COMPOSE_PROJECT_NAME=geomapfish diff --git a/geoportal/vars.yaml b/geoportal/vars.yaml index 4372061de..ea302009e 100644 --- a/geoportal/vars.yaml +++ b/geoportal/vars.yaml @@ -710,6 +710,32 @@ vars: # https://www.google-analytics.com/ # https://localhost:3001" +<<<<<<< ours +======= + # The dogpile.cache configuration. + cache: + std: + # Standalone version + backend: c2cgeoportal.hybrid + arguments: + host: '{REDIS_HOST}' + port: '{REDIS_PORT}' + db: '{REDIS_DB}' + # Kubernetes version + # arguments: + # sentinels: + # - - '{REDIS_HOST}' + # - '{REDIS_PORT}' + # connection_kwargs: + # db: '{REDIS_DB}' + + # This parameter set the list of hosts allowed to use the iframe api. + # 'self' will block all external usage, you must add additional hosts separated by space. + # see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors + content_security_policy_iframe_api_frame_ancestors: "'self'" + + # Control the HTTP headers +>>>>>>> theirs headers: dynamic: &header {} index: *header diff --git a/geoportal/webpack.apps.js b/geoportal/webpack.apps.js index 4a6b3bf22..aebbc7cf3 100644 --- a/geoportal/webpack.apps.js +++ b/geoportal/webpack.apps.js @@ -21,7 +21,7 @@ for (const filename of ls(path.resolve(__dirname, 'geomapfish_geoportal/static-n chunks: [name], vars: { entry_point: '${VISIBLE_ENTRY_POINT}', - version: '2.7.1.1', + version: '2.7.1.2', cache_version: '${CACHE_VERSION}', }, }) diff --git a/ngeo.diff b/ngeo.diff new file mode 100644 index 000000000..399078b91 --- /dev/null +++ b/ngeo.diff @@ -0,0 +1,16 @@ +diff --git a/geoportal/vars.yaml b/geoportal/vars.yaml +index 89625dd..dfade1f 100644 +--- a/geoportal/vars.yaml ++++ b/geoportal/vars.yaml +@@ -295,6 +295,11 @@ vars: + # connection_kwargs: + # db: '{REDIS_DB}' + ++ # This parameter set the list of hosts allowed to use the iframe api. ++ # 'self' will block all external usage, you must add additional hosts separated by space. ++ # see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors ++ content_security_policy_iframe_api_frame_ancestors: "'self'" ++ + # Control the HTTP headers + headers: + dynamic: &header {} diff --git a/upgrade b/upgrade new file mode 100755 index 000000000..d2d8fb027 --- /dev/null +++ b/upgrade @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2019-2020, Camptocamp SA +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# The views and conclusions contained in the software and documentation are those +# of the authors and should not be interpreted as representing official policies, +# either expressed or implied, of the FreeBSD Project. + + +import argparse +import os +import platform +import re +import subprocess +import sys + +parser = argparse.ArgumentParser(description="Upgrade the project") +parser.add_argument( + "--debug", help="Path to c2cgeoportal source folder to be able to debug the upgrade procedure" +) +parser.add_argument("version", help="the version to upgrade to (master or x.y.z)") +parser.add_argument("step", nargs="?", help="the step to run") +parser_finalize = argparse.ArgumentParser(description="Upgrade the project", add_help=False) +parser_finalize.add_argument("--finalize", action="store_true", help="finalize the upgrade") +parser_finalize.add_argument("--help", action="help", help="show this help message and exit") +parser_finalize.add_argument("build_arg", nargs="*", help="build arguments") + +if len(sys.argv) >= 2 and sys.argv[1] == "--finalize": + args = parser_finalize.parse_args() + + if platform.system() == "Windows": + code = subprocess.call(["python", "build"] + args.build_arg) + else: + code = subprocess.call(["./build"] + args.build_arg) + if code != 0: + sys.exit(code) + + subprocess.call(["docker-compose", "down", "--remove-orphans"]) + subprocess.call( + ["docker-compose", "pull", "--ignore-pull-failures"], env={**os.environ, "DOCKER_TAG": "unexisting"} + ) + subprocess.check_call(["docker-compose", "up", "-d"]) + subprocess.check_call( + [ + "docker-compose", + "exec", + "geoportal", + "alembic", + "--name=main", + "--config=alembic.ini", + "upgrade", + "head", + ] + ) + +else: + args = parser.parse_args() + + c2cupgrade_args = ["--step", args.step] if args.step is not None else [] + + if os.environ.get("CI") != "true" and args.step is None: + major_version = args.version + match = re.match(r"^([0-9]+\.[0-9]+)\.[0-9]+$", args.version) + if match is not None: + major_version = match.group(1) + match = re.match(r"^([0-9]+\.[0-9]+)\.[0-9a-z]+\.[0-9]+$", args.version) + if match is not None: + major_version = match.group(1) + if not args.debug: + subprocess.check_call( + [ + "docker", + "pull", + "camptocamp/geomapfish:{major_version}".format(major_version=major_version), + ] + ) + subprocess.check_call( + ["docker", "pull", "camptocamp/geomapfish-tools:{version}".format(version=args.version)] + ) + subprocess.check_call( + [ + "docker", + "pull", + "camptocamp/geomapfish-config:{major_version}".format(major_version=major_version), + ] + ) + + debug_volumes = ( + [ + "--volume={debug}/geoportal/c2cgeoportal_geoportal/scripts/c2cupgrade.py:".format( + debug=args.debug + ), + "/opt/c2cgeoportal/geoportal/c2cgeoportal_geoportal/scripts/c2cupgrade.py", + ] + if args.debug + else [] + ) + + win = platform.system() == "Windows" + sys.exit( + subprocess.call( + [ + "docker", + "run", + "--rm", + "--env=CI", + "--volume={}:/src".format(os.getcwd()), + ] + + debug_volumes + + [ + "camptocamp/geomapfish-tools:{version}".format(version=args.version), + "run-git", + subprocess.check_output(["git", "config", "--get", "user.name"]).decode().strip(), + subprocess.check_output(["git", "config", "--get", "user.email"]).decode().strip(), + "" if win else subprocess.check_output(["id", "-u"]).decode().strip(), + "" if win else subprocess.check_output(["id", "-g"]).decode().strip(), + "/src", + "c2cupgrade", + ] + + c2cupgrade_args + ) + )