Rework installation logic so we can go outside the install prefix.

pull/34/head
Jussi Pakkanen 10 years ago
parent 1eaf6673b7
commit 73b8ff5341
  1. 29
      meson_install.py
  2. 7
      ninjabackend.py
  3. 6
      run_tests.py
  4. 6
      test cases/common/10 man install/installed_files.txt
  5. 1
      test cases/common/12 data/etcfile.dat
  6. 5
      test cases/common/12 data/installed_files.txt
  7. 1
      test cases/common/12 data/meson.build
  8. 6
      test cases/common/27 library versions/installed_files.txt
  9. 8
      test cases/common/46 library chain/installed_files.txt
  10. 4
      test cases/common/49 subproject/installed_files.txt
  11. 6
      test cases/common/51 pkgconfig-gen/installed_files.txt
  12. 8
      test cases/common/52 custom install dirs/installed_files.txt
  13. 2
      test cases/common/56 custom target/installed_files.txt
  14. 2
      test cases/common/57 custom target chain/installed_files.txt
  15. 4
      test cases/common/6 linkshared/installed_files.txt
  16. 4
      test cases/common/60 install script/installed_files.txt
  17. 5
      test cases/common/60 install script/myinstall.sh
  18. 4
      test cases/common/66 install subdir/installed_files.txt
  19. 6
      test cases/common/67 foreach/installed_files.txt
  20. 6
      test cases/common/8 install/installed_files.txt
  21. 6
      test cases/common/9 header install/installed_files.txt
  22. 2
      test cases/csharp/1 basic/installed_files.txt
  23. 4
      test cases/csharp/2 library/installed_files.txt
  24. 6
      test cases/frameworks/6 gettext/installed_files.txt
  25. 2
      test cases/frameworks/7 gir/installed_files.txt

@ -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]

@ -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):

@ -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')

@ -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

@ -0,0 +1 @@
This goes into /etc/etcfile.dat

@ -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

@ -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')

@ -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

@ -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

@ -1,2 +1,2 @@
bin/user
lib/libsublib.so
usr/bin/user
usr/lib/libsublib.so

@ -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

@ -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

@ -1 +1 @@
subdir/data.dat
usr/subdir/data.dat

@ -1,2 +1,2 @@
bin/prog
lib/libmylib.so
usr/bin/prog
usr/lib/libmylib.so

@ -1,2 +1,2 @@
bin/prog
diiba/daaba/file.dat
usr/bin/prog
usr/diiba/daaba/file.dat

@ -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

@ -1,2 +1,2 @@
share/sub1/data1.dat
share/sub1/sub2/data2.dat
usr/share/sub1/data1.dat
usr/share/sub1/sub2/data2.dat

@ -1,3 +1,3 @@
bin/prog1
bin/prog2
bin/prog3
usr/bin/prog1
usr/bin/prog2
usr/bin/prog3

@ -1,3 +1,3 @@
bin/prog
lib/libshar.so
lib/libstat.a
usr/bin/prog
usr/lib/libshar.so
usr/lib/libstat.a

@ -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

@ -1 +1 @@
bin/prog.exe
usr/bin/prog.exe

@ -1,2 +1,2 @@
bin/prog.exe
lib/libhelper.dll
usr/bin/prog.exe
usr/lib/libhelper.dll

@ -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

@ -1 +1 @@
typelibdir/Meson-1.0.typelib
usr/typelibdir/Meson-1.0.typelib
Loading…
Cancel
Save