aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-09-10 13:57:20 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-09-10 12:38:05 +0000
commit9fb839687b70443757c3e77b4a1c5857d553bdc2 (patch)
treeddeeb363aad3ec6132fc8b3a20463dc7eeb9c35e /mesonbuild/minstall.py
parent8bb3f16f090d93687190cfd424e0414704361daf (diff)
downloadmeson-9fb839687b70443757c3e77b4a1c5857d553bdc2.zip
meson-9fb839687b70443757c3e77b4a1c5857d553bdc2.tar.gz
meson-9fb839687b70443757c3e77b4a1c5857d553bdc2.tar.bz2
minstall: Add version field to install data
And check the install data in the same way that mtest checks serialisation data. Fixes https://github.com/mesonbuild/meson/issues/2354
Diffstat (limited to 'mesonbuild/minstall.py')
-rw-r--r--mesonbuild/minstall.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index d477718..7a56275 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -20,6 +20,9 @@ from .scripts import depfixer
from .scripts import destdir_join
from .mesonlib import is_windows, Popen_safe
from .mtest import rebuild_all
+from .backend.backends import InstallData
+from .coredata import major_versions_differ, MesonVersionMismatchException
+from .coredata import version as coredata_version
try:
from __main__ import __file__ as main_file
except ImportError:
@@ -343,9 +346,18 @@ class Installer:
self.do_copyfile(abs_src, abs_dst)
set_mode(abs_dst, install_mode, data.install_umask)
+ @staticmethod
+ def check_installdata(obj: InstallData) -> InstallData:
+ if not isinstance(obj, InstallData) or not hasattr(obj, 'version'):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ if major_versions_differ(obj.version, coredata_version):
+ raise MesonVersionMismatchException(obj.version, coredata_version)
+ return obj
+
def do_install(self, datafilename):
with open(datafilename, 'rb') as ifile:
- d = pickle.load(ifile)
+ d = self.check_installdata(pickle.load(ifile))
+
d.destdir = os.environ.get('DESTDIR', '')
d.fullprefix = destdir_join(d.destdir, d.prefix)