Merge pull request #731 from QuLogic/obey-DESTDIR

Always obey DESTDIR even with absolute install_dir
pull/732/head
Jussi Pakkanen 8 years ago committed by GitHub
commit 8e904aaba0
  1. 30
      mesonbuild/scripts/meson_install.py
  2. 6
      test cases/common/52 custom install dirs/installed_files.txt
  3. 6
      test cases/common/52 custom install dirs/meson.build
  4. 1
      test cases/common/52 custom install dirs/subdir/datafile.dog

@ -37,6 +37,13 @@ def do_copy(from_file, to_file):
shutil.copystat(from_file, to_file) shutil.copystat(from_file, to_file)
append_to_log(to_file) append_to_log(to_file)
def get_destdir_path(d, path):
if os.path.isabs(path):
output = destdir_join(d.destdir, path)
else:
output = os.path.join(d.fullprefix, path)
return output
def do_install(datafilename): def do_install(datafilename):
ifile = open(datafilename, 'rb') ifile = open(datafilename, 'rb')
d = pickle.load(ifile) d = pickle.load(ifile)
@ -56,10 +63,7 @@ def install_subdirs(data):
src_dir = src_dir[:-1] src_dir = src_dir[:-1]
src_prefix = os.path.join(src_dir, inst_dir) src_prefix = os.path.join(src_dir, inst_dir)
print('Installing subdir %s to %s.' % (src_prefix, dst_dir)) print('Installing subdir %s to %s.' % (src_prefix, dst_dir))
if os.path.isabs(dst_dir): dst_dir = get_destdir_path(data, dst_dir)
dst_dir = destdir_join(data.destdir, dst_dir)
else:
dst_dir = data.fullprefix + dst_dir
if not os.path.exists(dst_dir): if not os.path.exists(dst_dir):
os.makedirs(dst_dir) os.makedirs(dst_dir)
for root, dirs, files in os.walk(src_prefix): for root, dirs, files in os.walk(src_prefix):
@ -92,22 +96,16 @@ def install_subdirs(data):
def install_data(d): def install_data(d):
for i in d.data: for i in d.data:
fullfilename = i[0] fullfilename = i[0]
outfilename = i[1] outfilename = get_destdir_path(d, i[1])
if os.path.isabs(outfilename): outdir = os.path.split(outfilename)[0]
outdir = destdir_join(d.destdir, os.path.split(outfilename)[0])
outfilename = destdir_join(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) os.makedirs(outdir, exist_ok=True)
print('Installing %s to %s.' % (fullfilename, outdir)) print('Installing %s to %s.' % (fullfilename, outdir))
do_copy(fullfilename, outfilename) do_copy(fullfilename, outfilename)
def install_man(d): def install_man(d):
for m in d.man: for m in d.man:
outfileroot = m[1]
outfilename = os.path.join(d.fullprefix, outfileroot)
full_source_filename = m[0] full_source_filename = m[0]
outfilename = get_destdir_path(d, m[1])
outdir = os.path.split(outfilename)[0] outdir = os.path.split(outfilename)[0]
os.makedirs(outdir, exist_ok=True) os.makedirs(outdir, exist_ok=True)
print('Installing %s to %s.' % (full_source_filename, outdir)) print('Installing %s to %s.' % (full_source_filename, outdir))
@ -121,8 +119,8 @@ def install_man(d):
def install_headers(d): def install_headers(d):
for t in d.headers: for t in d.headers:
fullfilename = t[0] fullfilename = t[0]
outdir = os.path.join(d.fullprefix, t[1])
fname = os.path.split(fullfilename)[1] fname = os.path.split(fullfilename)[1]
outdir = get_destdir_path(d, t[1])
outfilename = os.path.join(outdir, fname) outfilename = os.path.join(outdir, fname)
print('Installing %s to %s' % (fname, outdir)) print('Installing %s to %s' % (fname, outdir))
os.makedirs(outdir, exist_ok=True) os.makedirs(outdir, exist_ok=True)
@ -194,9 +192,9 @@ def check_for_stampfile(fname):
def install_targets(d): def install_targets(d):
for t in d.targets: for t in d.targets:
fname = check_for_stampfile(t[0]) fname = check_for_stampfile(t[0])
outdir = os.path.join(d.fullprefix, t[1]) outdir = get_destdir_path(d, t[1])
aliases = t[2]
outname = os.path.join(outdir, os.path.split(fname)[-1]) outname = os.path.join(outdir, os.path.split(fname)[-1])
aliases = t[2]
should_strip = t[3] should_strip = t[3]
install_rpath = t[4] install_rpath = t[4]
print('Installing %s to %s' % (fname, outname)) print('Installing %s to %s' % (fname, outname))

@ -1,4 +1,10 @@
usr/dib/dab/dub/prog?exe usr/dib/dab/dub/prog?exe
usr/dib/dab/dub2/prog2?exe
usr/some/dir/sample.h usr/some/dir/sample.h
usr/some/dir2/sample.h
usr/woman/prog.1.gz usr/woman/prog.1.gz
usr/woman2/prog.1.gz
usr/meow/datafile.cat usr/meow/datafile.cat
usr/meow2/datafile.cat
usr/woof/subdir/datafile.dog
usr/woof2/subdir/datafile.dog

@ -1,5 +1,11 @@
project('custom install dirs', 'c') project('custom install dirs', 'c')
executable('prog', 'prog.c', install : true, install_dir : 'dib/dab/dub') executable('prog', 'prog.c', install : true, install_dir : 'dib/dab/dub')
executable('prog2', 'prog.c', install : true, install_dir : get_option('prefix') + '/dib/dab/dub2')
install_headers('sample.h', install_dir : 'some/dir') install_headers('sample.h', install_dir : 'some/dir')
install_headers('sample.h', install_dir : get_option('prefix') + '/some/dir2')
install_man('prog.1', install_dir : 'woman') install_man('prog.1', install_dir : 'woman')
install_man('prog.1', install_dir : get_option('prefix') + '/woman2')
install_data('datafile.cat', install_dir : 'meow') install_data('datafile.cat', install_dir : 'meow')
install_data('datafile.cat', install_dir : get_option('prefix') + '/meow2')
install_subdir('subdir', install_dir : 'woof')
install_subdir('subdir', install_dir : get_option('prefix') + '/woof2')

Loading…
Cancel
Save