aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-02-04 22:00:06 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-02-04 22:00:06 +0200
commit73b8ff534115074125568b33ed2c67065c5e91b5 (patch)
treed5a2c024adbebbbe4028be8bc16c571498308d8d
parent1eaf6673b73be1393de61f0367d1fd352872b5cc (diff)
downloadmeson-73b8ff534115074125568b33ed2c67065c5e91b5.zip
meson-73b8ff534115074125568b33ed2c67065c5e91b5.tar.gz
meson-73b8ff534115074125568b33ed2c67065c5e91b5.tar.bz2
Rework installation logic so we can go outside the install prefix.
-rwxr-xr-xmeson_install.py29
-rw-r--r--ninjabackend.py7
-rwxr-xr-xrun_tests.py6
-rw-r--r--test cases/common/10 man install/installed_files.txt6
-rw-r--r--test cases/common/12 data/etcfile.dat1
-rw-r--r--test cases/common/12 data/installed_files.txt5
-rw-r--r--test cases/common/12 data/meson.build1
-rw-r--r--test cases/common/27 library versions/installed_files.txt6
-rw-r--r--test cases/common/46 library chain/installed_files.txt8
-rw-r--r--test cases/common/49 subproject/installed_files.txt4
-rw-r--r--test cases/common/51 pkgconfig-gen/installed_files.txt6
-rw-r--r--test cases/common/52 custom install dirs/installed_files.txt8
-rw-r--r--test cases/common/56 custom target/installed_files.txt2
-rw-r--r--test cases/common/57 custom target chain/installed_files.txt2
-rw-r--r--test cases/common/6 linkshared/installed_files.txt4
-rw-r--r--test cases/common/60 install script/installed_files.txt4
-rwxr-xr-xtest cases/common/60 install script/myinstall.sh5
-rw-r--r--test cases/common/66 install subdir/installed_files.txt4
-rw-r--r--test cases/common/67 foreach/installed_files.txt6
-rw-r--r--test cases/common/8 install/installed_files.txt6
-rw-r--r--test cases/common/9 header install/installed_files.txt6
-rw-r--r--test cases/csharp/1 basic/installed_files.txt2
-rw-r--r--test cases/csharp/2 library/installed_files.txt4
-rw-r--r--test cases/frameworks/6 gettext/installed_files.txt6
-rw-r--r--test cases/frameworks/7 gir/installed_files.txt2
25 files changed, 74 insertions, 66 deletions
diff --git a/meson_install.py b/meson_install.py
index dd88496..d54cbbc 100755
--- a/meson_install.py
+++ b/meson_install.py
@@ -37,11 +37,11 @@ def do_install(datafilename):
d = pickle.load(ifile)
destdir_var = 'DESTDIR'
if destdir_var in os.environ:
- if d.prefix[0] == '/':
- subdir = d.prefix[1:]
- else:
- subdir = d.prefix
- d.prefix = os.path.join(os.environ[destdir_var], subdir)
+ d.destdir = os.environ[destdir_var]
+ else:
+ d.destdir = ''
+ d.fullprefix = d.destdir + d.prefix
+
install_subdirs(d) # Must be first, because it needs to delete the old subtree.
install_targets(d)
install_headers(d)
@@ -52,6 +52,7 @@ def do_install(datafilename):
def install_subdirs(d):
for (src_dir, dst_dir) in d.install_subdirs:
+ dst_dir = d.destdir + dst_dir
# Python's copytree works in strange ways.
last_level = os.path.split(src_dir)[-1]
final_dst = os.path.join(dst_dir, last_level)
@@ -65,7 +66,7 @@ def install_po(d):
srcfile = f[0]
localedir = f[1]
languagename = f[2]
- outfile = os.path.join(d.prefix, localedir, languagename, 'LC_MESSAGES',
+ outfile = os.path.join(d.fullprefix, localedir, languagename, 'LC_MESSAGES',
packagename + '.mo')
os.makedirs(os.path.split(outfile)[0], exist_ok=True)
shutil.copyfile(srcfile, outfile)
@@ -75,9 +76,13 @@ def install_po(d):
def install_data(d):
for i in d.data:
fullfilename = i[0]
- outfilerel = i[1]
- outdir = os.path.join(d.prefix, os.path.split(outfilerel)[0])
- outfilename = os.path.join(outdir, os.path.split(outfilerel)[1])
+ outfilename = i[1]
+ if os.path.isabs(outfilename):
+ outdir = d.destdir + os.path.split(outfilename)[0]
+ outfilename = d.destdir + outfilename
+ else:
+ outdir = os.path.join(d.fullprefix, os.path.split(outfilename)[0])
+ outfilename = os.path.join(outdir, os.path.split(outfilename)[1])
os.makedirs(outdir, exist_ok=True)
print('Installing %s to %s.' % (fullfilename, outdir))
shutil.copyfile(fullfilename, outfilename)
@@ -86,7 +91,7 @@ def install_data(d):
def install_man(d):
for m in d.man:
outfileroot = m[1]
- outfilename = os.path.join(d.prefix, outfileroot)
+ outfilename = os.path.join(d.fullprefix, outfileroot)
full_source_filename = m[0]
outdir = os.path.split(outfilename)[0]
os.makedirs(outdir, exist_ok=True)
@@ -100,7 +105,7 @@ def install_man(d):
def install_headers(d):
for t in d.headers:
fullfilename = t[0]
- outdir = os.path.join(d.prefix, t[1])
+ outdir = os.path.join(d.fullprefix, t[1])
fname = os.path.split(fullfilename)[1]
outfilename = os.path.join(outdir, fname)
print('Installing %s to %s' % (fname, outdir))
@@ -164,7 +169,7 @@ def check_for_stampfile(fname):
def install_targets(d):
for t in d.targets:
fname = check_for_stampfile(t[0])
- outdir = os.path.join(d.prefix, t[1])
+ outdir = os.path.join(d.fullprefix, t[1])
aliases = t[2]
outname = os.path.join(outdir, os.path.split(fname)[-1])
should_strip = t[3]
diff --git a/ninjabackend.py b/ninjabackend.py
index ad43217..abb2760 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -415,15 +415,14 @@ class NinjaBackend(backends.Backend):
d.targets.append(i)
def generate_pkgconfig_install(self, d):
- pkgroot = os.path.join(self.environment.coredata.prefix,
- self.environment.coredata.libdir, 'pkgconfig')
+ pkgroot = os.path.join(self.environment.coredata.libdir, 'pkgconfig')
for p in self.build.pkgconfig_gens:
pcfile = p.filebase + '.pc'
srcabs = os.path.join(self.environment.get_scratch_dir(),
pcfile)
- dstabs = os.path.join(pkgroot, pcfile)
- i = [srcabs, dstabs]
+ dstrel = os.path.join(pkgroot, pcfile)
+ i = [srcabs, dstrel]
d.man.append(i)
def generate_custom_install_script(self, d):
diff --git a/run_tests.py b/run_tests.py
index c572257..eb4b3fa 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -130,7 +130,7 @@ def run_test(testdir, should_succeed):
os.mkdir(test_build_dir)
os.mkdir(install_dir)
print('Running test: ' + testdir)
- gen_command = [sys.executable, meson_command, '--prefix', install_dir, testdir, test_build_dir]\
+ gen_command = [sys.executable, meson_command, '--prefix', '/usr', testdir, test_build_dir]\
+ unity_flags + backend_flags
p = subprocess.Popen(gen_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdo, stde) = p.communicate()
@@ -165,7 +165,9 @@ def run_test(testdir, should_succeed):
print("Skipping install test")
return ('', '', '')
else:
- pi = subprocess.Popen(install_commands, cwd=test_build_dir,
+ env = os.environ.copy()
+ env['DESTDIR'] = install_dir
+ pi = subprocess.Popen(install_commands, cwd=test_build_dir, env=env,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(o, e) = pi.communicate()
stdo += o.decode('utf-8')
diff --git a/test cases/common/10 man install/installed_files.txt b/test cases/common/10 man install/installed_files.txt
index 6a86b92..29331e4 100644
--- a/test cases/common/10 man install/installed_files.txt
+++ b/test cases/common/10 man install/installed_files.txt
@@ -1,3 +1,3 @@
-share/man/man1/foo.1.gz
-share/man/man2/bar.2.gz
-share/man/man1/vanishing.1.gz
+usr/share/man/man1/foo.1.gz
+usr/share/man/man2/bar.2.gz
+usr/share/man/man1/vanishing.1.gz
diff --git a/test cases/common/12 data/etcfile.dat b/test cases/common/12 data/etcfile.dat
new file mode 100644
index 0000000..93db8cb
--- /dev/null
+++ b/test cases/common/12 data/etcfile.dat
@@ -0,0 +1 @@
+This goes into /etc/etcfile.dat
diff --git a/test cases/common/12 data/installed_files.txt b/test cases/common/12 data/installed_files.txt
index 8d7ff70..1c58623 100644
--- a/test cases/common/12 data/installed_files.txt
+++ b/test cases/common/12 data/installed_files.txt
@@ -1,2 +1,3 @@
-share/progname/datafile.dat
-share/progname/vanishing.dat
+usr/share/progname/datafile.dat
+usr/share/progname/vanishing.dat
+etc/etcfile.dat
diff --git a/test cases/common/12 data/meson.build b/test cases/common/12 data/meson.build
index 8507046..5a04d6c 100644
--- a/test cases/common/12 data/meson.build
+++ b/test cases/common/12 data/meson.build
@@ -1,3 +1,4 @@
project('data install test', 'c')
install_data('progname', sources : 'datafile.dat')
+install_data('dummy', sources : 'etcfile.dat', install_dir : '/etc')
subdir('vanishing')
diff --git a/test cases/common/27 library versions/installed_files.txt b/test cases/common/27 library versions/installed_files.txt
index 9c9e1e0..a218d29 100644
--- a/test cases/common/27 library versions/installed_files.txt
+++ b/test cases/common/27 library versions/installed_files.txt
@@ -1,3 +1,3 @@
-lib/libsomelib.so
-lib/libsomelib.so.0
-lib/libsomelib.so.1.2.3
+usr/lib/libsomelib.so
+usr/lib/libsomelib.so.0
+usr/lib/libsomelib.so.1.2.3
diff --git a/test cases/common/46 library chain/installed_files.txt b/test cases/common/46 library chain/installed_files.txt
index cee40b7..8d38fd9 100644
--- a/test cases/common/46 library chain/installed_files.txt
+++ b/test cases/common/46 library chain/installed_files.txt
@@ -1,4 +1,4 @@
-bin/prog
-lib/liblib1.so
-lib/liblib2.so
-lib/liblib3.so
+usr/bin/prog
+usr/lib/liblib1.so
+usr/lib/liblib2.so
+usr/lib/liblib3.so
diff --git a/test cases/common/49 subproject/installed_files.txt b/test cases/common/49 subproject/installed_files.txt
index e4b1e3f..55a8595 100644
--- a/test cases/common/49 subproject/installed_files.txt
+++ b/test cases/common/49 subproject/installed_files.txt
@@ -1,2 +1,2 @@
-bin/user
-lib/libsublib.so
+usr/bin/user
+usr/lib/libsublib.so
diff --git a/test cases/common/51 pkgconfig-gen/installed_files.txt b/test cases/common/51 pkgconfig-gen/installed_files.txt
index 547e530..cc5d34b 100644
--- a/test cases/common/51 pkgconfig-gen/installed_files.txt
+++ b/test cases/common/51 pkgconfig-gen/installed_files.txt
@@ -1,3 +1,3 @@
-include/simple.h
-lib/libsimple.so
-lib/pkgconfig/simple.pc
+usr/include/simple.h
+usr/lib/libsimple.so
+usr/lib/pkgconfig/simple.pc
diff --git a/test cases/common/52 custom install dirs/installed_files.txt b/test cases/common/52 custom install dirs/installed_files.txt
index ad6ce3b..dc495e2 100644
--- a/test cases/common/52 custom install dirs/installed_files.txt
+++ b/test cases/common/52 custom install dirs/installed_files.txt
@@ -1,4 +1,4 @@
-dib/dab/dub/prog
-some/dir/sample.h
-woman/prog.1.gz
-meow/datafile.cat
+usr/dib/dab/dub/prog
+usr/some/dir/sample.h
+usr/woman/prog.1.gz
+usr/meow/datafile.cat
diff --git a/test cases/common/56 custom target/installed_files.txt b/test cases/common/56 custom target/installed_files.txt
index 6baed14..d90a6b0 100644
--- a/test cases/common/56 custom target/installed_files.txt
+++ b/test cases/common/56 custom target/installed_files.txt
@@ -1 +1 @@
-subdir/data.dat
+usr/subdir/data.dat
diff --git a/test cases/common/57 custom target chain/installed_files.txt b/test cases/common/57 custom target chain/installed_files.txt
index c5f8bd7..4e326a2 100644
--- a/test cases/common/57 custom target chain/installed_files.txt
+++ b/test cases/common/57 custom target chain/installed_files.txt
@@ -1 +1 @@
-subdir/data2.dat
+usr/subdir/data2.dat
diff --git a/test cases/common/6 linkshared/installed_files.txt b/test cases/common/6 linkshared/installed_files.txt
index cabfd81..2a4c330 100644
--- a/test cases/common/6 linkshared/installed_files.txt
+++ b/test cases/common/6 linkshared/installed_files.txt
@@ -1,2 +1,2 @@
-bin/prog
-lib/libmylib.so
+usr/bin/prog
+usr/lib/libmylib.so
diff --git a/test cases/common/60 install script/installed_files.txt b/test cases/common/60 install script/installed_files.txt
index 13150a2..58315f9 100644
--- a/test cases/common/60 install script/installed_files.txt
+++ b/test cases/common/60 install script/installed_files.txt
@@ -1,2 +1,2 @@
-bin/prog
-diiba/daaba/file.dat
+usr/bin/prog
+usr/diiba/daaba/file.dat
diff --git a/test cases/common/60 install script/myinstall.sh b/test cases/common/60 install script/myinstall.sh
index 725f639..4739dee 100755
--- a/test cases/common/60 install script/myinstall.sh
+++ b/test cases/common/60 install script/myinstall.sh
@@ -4,8 +4,7 @@ echo Starting custom installation step
# These commands fail on Windows, but we don't really care.
-mkdir "${DESTDIR}/${MESON_INSTALL_PREFIX}/diiba"
-mkdir "${DESTDIR}/${MESON_INSTALL_PREFIX}/diiba/daaba"
-touch "${DESTDIR}/${MESON_INSTALL_PREFIX}/diiba/daaba/file.dat"
+mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba"
+touch "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba/file.dat"
echo Finishing custom install step
diff --git a/test cases/common/66 install subdir/installed_files.txt b/test cases/common/66 install subdir/installed_files.txt
index 4f5bacf..93ee283 100644
--- a/test cases/common/66 install subdir/installed_files.txt
+++ b/test cases/common/66 install subdir/installed_files.txt
@@ -1,2 +1,2 @@
-share/sub1/data1.dat
-share/sub1/sub2/data2.dat
+usr/share/sub1/data1.dat
+usr/share/sub1/sub2/data2.dat
diff --git a/test cases/common/67 foreach/installed_files.txt b/test cases/common/67 foreach/installed_files.txt
index 8056948..36c6386 100644
--- a/test cases/common/67 foreach/installed_files.txt
+++ b/test cases/common/67 foreach/installed_files.txt
@@ -1,3 +1,3 @@
-bin/prog1
-bin/prog2
-bin/prog3
+usr/bin/prog1
+usr/bin/prog2
+usr/bin/prog3
diff --git a/test cases/common/8 install/installed_files.txt b/test cases/common/8 install/installed_files.txt
index fa8530b..1e9166b 100644
--- a/test cases/common/8 install/installed_files.txt
+++ b/test cases/common/8 install/installed_files.txt
@@ -1,3 +1,3 @@
-bin/prog
-lib/libshar.so
-lib/libstat.a
+usr/bin/prog
+usr/lib/libshar.so
+usr/lib/libstat.a
diff --git a/test cases/common/9 header install/installed_files.txt b/test cases/common/9 header install/installed_files.txt
index 508aa32..b9e91a2 100644
--- a/test cases/common/9 header install/installed_files.txt
+++ b/test cases/common/9 header install/installed_files.txt
@@ -1,3 +1,3 @@
-include/rootdir.h
-include/subdir/subdir.h
-include/vanished.h
+usr/include/rootdir.h
+usr/include/subdir/subdir.h
+usr/include/vanished.h
diff --git a/test cases/csharp/1 basic/installed_files.txt b/test cases/csharp/1 basic/installed_files.txt
index 3e93017..f64c68c 100644
--- a/test cases/csharp/1 basic/installed_files.txt
+++ b/test cases/csharp/1 basic/installed_files.txt
@@ -1 +1 @@
-bin/prog.exe
+usr/bin/prog.exe
diff --git a/test cases/csharp/2 library/installed_files.txt b/test cases/csharp/2 library/installed_files.txt
index 48d5277..b830634 100644
--- a/test cases/csharp/2 library/installed_files.txt
+++ b/test cases/csharp/2 library/installed_files.txt
@@ -1,2 +1,2 @@
-bin/prog.exe
-lib/libhelper.dll
+usr/bin/prog.exe
+usr/lib/libhelper.dll
diff --git a/test cases/frameworks/6 gettext/installed_files.txt b/test cases/frameworks/6 gettext/installed_files.txt
index 60a2b78..c95b9fd 100644
--- a/test cases/frameworks/6 gettext/installed_files.txt
+++ b/test cases/frameworks/6 gettext/installed_files.txt
@@ -1,3 +1,3 @@
-bin/intlprog
-share/locale/de/LC_MESSAGES/intltest.mo
-share/locale/fi/LC_MESSAGES/intltest.mo
+usr/bin/intlprog
+usr/share/locale/de/LC_MESSAGES/intltest.mo
+usr/share/locale/fi/LC_MESSAGES/intltest.mo
diff --git a/test cases/frameworks/7 gir/installed_files.txt b/test cases/frameworks/7 gir/installed_files.txt
index 568324a..beb8cba 100644
--- a/test cases/frameworks/7 gir/installed_files.txt
+++ b/test cases/frameworks/7 gir/installed_files.txt
@@ -1 +1 @@
-typelibdir/Meson-1.0.typelib \ No newline at end of file
+usr/typelibdir/Meson-1.0.typelib \ No newline at end of file