ostbuild: Clean up artifact splitting, put non-symlink .so in runtime
We were breaking nss which just installs libnss3.so as the real shared library.
This commit is contained in:
parent
e34b90453c
commit
d5def94b54
|
|
@ -30,24 +30,15 @@ from .subprocess_helpers import run_sync
|
||||||
|
|
||||||
PREFIX = '/usr'
|
PREFIX = '/usr'
|
||||||
|
|
||||||
_BLACKLIST_REGEXPS = map(re.compile,
|
_DOC_DIRS = ['usr/share/doc',
|
||||||
[r'.*\.la$',
|
'usr/share/gtk-doc',
|
||||||
])
|
'usr/share/man',
|
||||||
|
'usr/share/info']
|
||||||
|
|
||||||
_RUNTIME_DIRS = ['/etc']
|
_DEVEL_DIRS = ['usr/include',
|
||||||
|
'usr/share/aclocal',
|
||||||
_DOC_DIRS = ['/usr/share/doc',
|
'usr/share/pkgconfig',
|
||||||
'/usr/share/gtk-doc',
|
'usr/lib/pkgconfig']
|
||||||
'/usr/share/man',
|
|
||||||
'/usr/share/info']
|
|
||||||
|
|
||||||
_DEVEL_DIRS = ['/usr/include',
|
|
||||||
'/usr/share/aclocal',
|
|
||||||
'/usr/share/pkgconfig',
|
|
||||||
'/usr/lib/pkgconfig']
|
|
||||||
|
|
||||||
_DEVEL_REGEXPS = map(re.compile,
|
|
||||||
[r'/(?:usr/)lib/[^/]+\.(?:so|a)$'])
|
|
||||||
|
|
||||||
class OstbuildCompileOne(builtins.Builtin):
|
class OstbuildCompileOne(builtins.Builtin):
|
||||||
name = "compile-one"
|
name = "compile-one"
|
||||||
|
|
@ -207,66 +198,49 @@ class OstbuildCompileOne(builtins.Builtin):
|
||||||
args = ['make', 'install', 'DESTDIR=' + tempdir]
|
args = ['make', 'install', 'DESTDIR=' + tempdir]
|
||||||
run_sync(args, cwd=builddir)
|
run_sync(args, cwd=builddir)
|
||||||
|
|
||||||
devel_files = set()
|
runtime_path = os.path.join(self.ostbuild_resultdir, 'runtime')
|
||||||
doc_files = set()
|
devel_path = os.path.join(self.ostbuild_resultdir, 'devel')
|
||||||
runtime_files = set()
|
docs_path = os.path.join(self.ostbuild_resultdir, 'docs')
|
||||||
|
for artifact_type in ['runtime', 'devel', 'docs']:
|
||||||
oldpwd=os.getcwd()
|
resultdir = os.path.join(self.ostbuild_resultdir, artifact_type)
|
||||||
os.chdir(tempdir)
|
if os.path.isdir(resultdir):
|
||||||
for root, dirs, files in os.walk('.'):
|
shutil.rmtree(resultdir)
|
||||||
deleted_dirs = set()
|
os.makedirs(resultdir)
|
||||||
for dirname in dirs:
|
|
||||||
path = os.path.join(root, dirname)
|
|
||||||
subpath = path[1:]
|
|
||||||
matched = False
|
|
||||||
for runtime_name in _RUNTIME_DIRS:
|
|
||||||
if subpath.startswith(runtime_name):
|
|
||||||
runtime_files.add(path)
|
|
||||||
matched = True
|
|
||||||
break
|
|
||||||
if not matched:
|
|
||||||
for devel_name in _DEVEL_DIRS:
|
|
||||||
if subpath.startswith(devel_name):
|
|
||||||
devel_files.add(path)
|
|
||||||
matched = True
|
|
||||||
break
|
|
||||||
if not matched:
|
|
||||||
for doc_name in _DOC_DIRS:
|
|
||||||
if subpath.startswith(doc_name):
|
|
||||||
doc_files.add(path)
|
|
||||||
matched = True
|
|
||||||
break
|
|
||||||
if matched:
|
|
||||||
deleted_dirs.add(dirname)
|
|
||||||
for dirname in deleted_dirs:
|
|
||||||
dirs.remove(dirname)
|
|
||||||
|
|
||||||
for filename in files:
|
|
||||||
path = os.path.join(root, filename)
|
|
||||||
|
|
||||||
blacklisted = False
|
|
||||||
for r in _BLACKLIST_REGEXPS:
|
|
||||||
if r.match(path):
|
|
||||||
blacklisted = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if blacklisted:
|
|
||||||
continue
|
|
||||||
|
|
||||||
matched = False
|
# Move symbolic links for shared libraries as well
|
||||||
for r in _DEVEL_REGEXPS:
|
# as static libraries. And delete all .la files.
|
||||||
if not r.match(path[1:]):
|
for libdirname in ['lib', 'usr/lib']:
|
||||||
continue
|
path = os.path.join(tempdir, libdirname)
|
||||||
devel_files.add(path)
|
if not os.path.isdir(path):
|
||||||
matched = True
|
continue
|
||||||
break
|
for filename in os.listdir(path):
|
||||||
if not matched:
|
subpath = os.path.join(path, filename)
|
||||||
runtime_files.add(path)
|
if filename.endswith('.la'):
|
||||||
os.chdir(oldpwd)
|
os.unlink(subpath)
|
||||||
|
continue
|
||||||
|
if not ((filename.endswith('.so')
|
||||||
|
and os.path.islink(filename))
|
||||||
|
or filename.endswith('.a')):
|
||||||
|
continue
|
||||||
|
dest = os.path.join(devel_path, libdirname, filename)
|
||||||
|
self._install_and_unlink(subpath, dest)
|
||||||
|
|
||||||
|
for dirname in _DEVEL_DIRS:
|
||||||
|
dirpath = os.path.join(tempdir, dirname)
|
||||||
|
if os.path.isdir(dirpath):
|
||||||
|
dest = os.path.join(devel_path, dirname)
|
||||||
|
self._install_and_unlink(dirpath, dest)
|
||||||
|
|
||||||
|
for dirname in _DOC_DIRS:
|
||||||
|
dirpath = os.path.join(tempdir, dirname)
|
||||||
|
if os.path.isdir(dirpath):
|
||||||
|
dest = os.path.join(docs_path, dirname)
|
||||||
|
self._install_and_unlink(dirpath, dest)
|
||||||
|
|
||||||
self.make_artifact('devel', devel_files, tempdir=tempdir)
|
for filename in os.listdir(tempdir):
|
||||||
self.make_artifact('doc', doc_files, tempdir=tempdir)
|
src_path = os.path.join(tempdir, filename)
|
||||||
self.make_artifact('runtime', runtime_files, tempdir=tempdir)
|
dest_path = os.path.join(runtime_path, filename)
|
||||||
|
self._install_and_unlink(src_path, dest_path)
|
||||||
|
|
||||||
for tmpname in self.tempfiles:
|
for tmpname in self.tempfiles:
|
||||||
assert os.path.isabs(tmpname)
|
assert os.path.isabs(tmpname)
|
||||||
|
|
@ -278,9 +252,11 @@ class OstbuildCompileOne(builtins.Builtin):
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _rename_or_copy(self, src, dest):
|
def _install_and_unlink(self, src, dest):
|
||||||
statsrc = os.lstat(src)
|
statsrc = os.lstat(src)
|
||||||
statdest = os.lstat(os.path.dirname(dest))
|
dirname = os.path.dirname(dest)
|
||||||
|
if not os.path.isdir(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
|
|
||||||
if stat.S_ISDIR(statsrc.st_mode):
|
if stat.S_ISDIR(statsrc.st_mode):
|
||||||
if not os.path.isdir(dest):
|
if not os.path.isdir(dest):
|
||||||
|
|
@ -289,7 +265,8 @@ class OstbuildCompileOne(builtins.Builtin):
|
||||||
src_child = os.path.join(src, filename)
|
src_child = os.path.join(src, filename)
|
||||||
dest_child = os.path.join(dest, filename)
|
dest_child = os.path.join(dest, filename)
|
||||||
|
|
||||||
self._rename_or_copy(src_child, dest_child)
|
self._install_and_unlink(src_child, dest_child)
|
||||||
|
os.rmdir(src)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.rename(src, dest)
|
os.rename(src, dest)
|
||||||
|
|
@ -299,25 +276,6 @@ class OstbuildCompileOne(builtins.Builtin):
|
||||||
os.symlink(linkto, dest)
|
os.symlink(linkto, dest)
|
||||||
else:
|
else:
|
||||||
shutil.copy2(src, dest)
|
shutil.copy2(src, dest)
|
||||||
|
os.unlink(src)
|
||||||
def make_artifact(self, dirtype, from_files, tempdir):
|
|
||||||
resultdir = os.path.join(self.ostbuild_resultdir, dirtype)
|
|
||||||
if os.path.isdir(resultdir):
|
|
||||||
shutil.rmtree(resultdir)
|
|
||||||
os.makedirs(resultdir)
|
|
||||||
|
|
||||||
for filename in from_files:
|
|
||||||
if filename.startswith('./'):
|
|
||||||
filename = filename[2:]
|
|
||||||
src_path = os.path.join(tempdir, filename)
|
|
||||||
dest_path = os.path.join(resultdir, filename)
|
|
||||||
dest_dir = os.path.dirname(dest_path)
|
|
||||||
if not os.path.isdir(dest_dir):
|
|
||||||
os.makedirs(dest_dir)
|
|
||||||
try:
|
|
||||||
self._rename_or_copy(src_path, dest_path)
|
|
||||||
except OSError, e:
|
|
||||||
fatal("Failed to copy %r to %r: %d %s" % (src_path, dest_path, e.errno, e.strerror))
|
|
||||||
log("created: %s" % (os.path.abspath (resultdir), ))
|
|
||||||
|
|
||||||
builtins.register(OstbuildCompileOne)
|
builtins.register(OstbuildCompileOne)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue