From ecec6f35a691f7fef2c2b1fd6f06cb645a33043d Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Tue, 5 Jan 2010 11:47:07 +0100 Subject: [PATCH] global interface: cleanup: The server side ./version file and the .e2/version file used to hold the global interface version, describing the way data is stored on server side. If the way data is stored is changed the version must be changed, too. That must take effect for all old versions of the project, so redundantly storing the global interface version in .e2/version must not be done. This commit cleans up the situation: remove and deprecate .e2/version introduce .e2/global_version that is created on project check-out and initialized with the value stored in ./version on the server side. Local tools check the global interface version against a list of supported versions stored in the build time configuration. That way they will, in future, be able to complain if a particular version is not supported. Global tools create projects with the newest global interface version supported. Signed-off-by: Gordon Hecker --- Changelog | 6 ++++++ Makefile | 3 +++ generic/e2lib.lua | 1 + global/e2-create-project.lua.in | 3 +-- global/e2-fetch-project.lua.in | 3 +++ global/e2-install-e2.lua.in | 2 +- local/e2tool.lua | 22 ++++++++++++++++++++++ make.vars | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index c89e6e6..dc7a12b 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,12 @@ NEXT: to this problem in the default configuration and is enabled now. * support for per-project caches (using the %l format) in e2.conf is no longer available. Cache is designed to be per user. + * the global interface version is no longer maintained in the file + .e2/version inside the project. Instead ./version on the server side + remains the only permanent copy and it is fetched to .e2/global-version + in the project environment + * the local tools check for their own support for the global interface + version in use. e2factory-2.3.3 * use sha1 module instead of calling the sha1sum tool diff --git a/Makefile b/Makefile index ac11fd6..962e6fa 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,9 @@ buildconfig.lua: Makefile make.vars @echo 'EXTRAVERSION="$(EXTRAVERSION)"' >>$@ @echo 'VERSION="$(VERSION)"' >>$@ @echo 'VERSIONSTRING="$(VERSIONSTRING)"' >>$@ + @echo 'GLOBAL_INTERFACE_VERSION={' >>$@ + @for x in $(GLOBAL_INTERFACE_VERSION) ; do echo " \"$$x\"," ; done >>$@ + @echo '}' >>$@ @echo 'SYNTAX={' >>$@ @for x in $(SYNTAX) ; do echo " \"$$x\"," ; done >>$@ @echo '}' >>$@ diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 9ceb72b..2ad01af 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -85,6 +85,7 @@ e2lib = { buildnumber_server_url = nil, template_path = string.format("%s/templates", buildconfig.SYSCONFDIR), extension_config = ".e2/extensions", + global_interface_version_file = ".e2/global-version", lock = nil, logrotate = 5, -- configurable via config.log.logrotate } diff --git a/global/e2-create-project.lua.in b/global/e2-create-project.lua.in index 52c3d55..413ca27 100755 --- a/global/e2-create-project.lua.in +++ b/global/e2-create-project.lua.in @@ -84,7 +84,7 @@ if not sl then end local p = {} -p.version = 2 -- the project version +p.version = buildconfig.GLOBAL_INTERFACE_VERSION[1] -- the project version p.e2version = string.format("%s %s", e2lib.local_e2_branch, e2lib.local_e2_tag) p.server = sl.server -- the server @@ -192,7 +192,6 @@ files = { { filename = "proj/licences", content=licences }, { filename = "proj/env", content=env }, { filename = "proj/config", content=pconfig }, - { filename = ".e2/version", content=version }, { filename = ".e2/syntax", content=syntax }, { filename = ".e2/e2version", content=e2version }, { filename = ".gitignore", content=gitignore }, diff --git a/global/e2-fetch-project.lua.in b/global/e2-fetch-project.lua.in index b70d1c1..760efda 100755 --- a/global/e2-fetch-project.lua.in +++ b/global/e2-fetch-project.lua.in @@ -174,6 +174,9 @@ if not rc then e2lib.abort(e:cat(re)) end +-- write version file +local rc, re = e2lib.write_file(e2lib.global_interface_version_file, string.format("%d\n", v)) + -- call e2-install-e2 e2_install_e2 = string.format("'%s' '%s/e2-install-e2'", buildconfig.LUA, buildconfig.TOOLDIR) diff --git a/global/e2-install-e2.lua.in b/global/e2-install-e2.lua.in index babcb24..b862740 100755 --- a/global/e2-install-e2.lua.in +++ b/global/e2-install-e2.lua.in @@ -81,7 +81,7 @@ if not rc then end -- read the version from the first line -local line, re = e2lib.read_line(".e2/version") +local line, re = e2lib.read_line(e2lib.global_interface_version_file) if not line then e2lib.abort(e:cat(re)) end diff --git a/local/e2tool.lua b/local/e2tool.lua index 4a97277..ac4d0c9 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -618,6 +618,27 @@ The newest configuration syntax supported by the tools is %s. info.project_location = l e2lib.log(4, string.format("project location is %s", info.project_location)) + -- read global interface version and check if this version of the local + -- tools supports the version used for the project + local line, re = e2lib.read_line(e2lib.global_interface_version_file) + if not line then + return false, e:cat(re) + end + info.global_interface_version = line:match("^%s*(%d+)%s*$") + local supported = false + for _,v in ipairs(buildconfig.GLOBAL_INTERFACE_VERSION) do + if v == info.global_interface_version then + supported = true + end + end + if not supported then + e:append("%s: Invalid global interface version", + e2lib.global_interface_version_file) + e:append("supported global interface versions are: %s", + table.concat(buildconfig.GLOBAL_INTERFACE_VERSION), " ") + return false, e + end + -- warn if deprecated config files still exist local deprecated_files = { "proj/servers", @@ -625,6 +646,7 @@ The newest configuration syntax supported by the tools is %s. "proj/default-results", "proj/name", "proj/release-id", + ".e2/version", } for _,f in ipairs(deprecated_files) do local path = string.format("%s/%s", info.root, f) diff --git a/make.vars b/make.vars index bc44e18..fb3d1c9 100644 --- a/make.vars +++ b/make.vars @@ -23,6 +23,14 @@ endif # list the latest one first SYNTAX = 2_3_2 +# Global interface version describes the server side data format +# It is stored in a file named `version` in the server side project location. +# This file is copied to .e2/global_version when checking out a project for +# access by the local tools. +# +# List the latest one first. It will be used when creating new projects. +GLOBAL_INTERFACE_VERSION = 2 + # when creating a project a current set of local tools is requested DEFAULT_LOCAL_BRANCH = master DEFAULT_LOCAL_TAG = $(TAG) -- 2.39.5