Skip to content

Commit

Permalink
Merge pull request #4435 from easybuilders/ocaisa-patch-1
Browse files Browse the repository at this point in the history
create `lib` -> `lib64` symlink (or vice versa) *before* running `postinstallcmds`
  • Loading branch information
boegel authored Feb 8, 2024
2 parents e887991 + 92e9fe1 commit 0c0332a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
12 changes: 6 additions & 6 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3030,12 +3030,6 @@ def post_install_step(self):
- run post install commands if any were specified
"""

self.run_post_install_commands()
self.apply_post_install_patches()
self.print_post_install_messages()

self.fix_shebang()

lib_dir = os.path.join(self.installdir, 'lib')
lib64_dir = os.path.join(self.installdir, 'lib64')

Expand All @@ -3056,6 +3050,12 @@ def post_install_step(self):
# create *relative* 'lib' symlink to 'lib64';
symlink('lib64', lib_dir, use_abspath_source=False)

self.run_post_install_commands()
self.apply_post_install_patches()
self.print_post_install_messages()

self.fix_shebang()

def sanity_check_step(self, *args, **kwargs):
"""
Do a sanity check on the installation
Expand Down
42 changes: 24 additions & 18 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,14 @@ def test_sanity_check_paths_lib64(self):

# modify test easyconfig: move lib/libtoy.a to lib64/libtoy.a
ectxt = re.sub(r"\s*'files'.*", "'files': ['bin/toy', ('lib/libtoy.a', 'lib/libfoo.a')],", ectxt)
postinstallcmd = "mkdir %(installdir)s/lib64 && mv %(installdir)s/lib/libtoy.a %(installdir)s/lib64/libtoy.a"
postinstallcmd = ' && '.join([
# remove lib64 symlink (if it's there)
"rm -f %(installdir)s/lib64",
# create empty lib64 dir
"mkdir %(installdir)s/lib64",
# move libtoy.a
"mv %(installdir)s/lib/libtoy.a %(installdir)s/lib64/libtoy.a",
])
ectxt = re.sub("postinstallcmds.*", "postinstallcmds = ['%s']" % postinstallcmd, ectxt)

test_ec = os.path.join(self.test_prefix, 'toy-0.0.eb')
Expand Down Expand Up @@ -3844,7 +3851,6 @@ def test_toy_build_lib_lib64_symlink(self):
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')

test_ec_txt = read_file(toy_ec)
test_ec_txt += "\npostinstallcmds += ['mv %(installdir)s/lib %(installdir)s/lib64']"

test_ec = os.path.join(self.test_prefix, 'test.eb')
write_file(test_ec, test_ec_txt)
Expand All @@ -3857,30 +3863,30 @@ def test_toy_build_lib_lib64_symlink(self):
lib_path = os.path.join(toy_installdir, 'lib')
lib64_path = os.path.join(toy_installdir, 'lib64')

# lib64 subdir exists, is not a symlink
self.assertExists(lib64_path)
self.assertTrue(os.path.isdir(lib64_path))
self.assertFalse(os.path.islink(lib64_path))

# lib subdir is a symlink to lib64 subdir
# lib subdir exists, is not a symlink
self.assertExists(lib_path)
self.assertTrue(os.path.isdir(lib_path))
self.assertTrue(os.path.islink(lib_path))
self.assertTrue(os.path.samefile(lib_path, lib64_path))
self.assertFalse(os.path.islink(lib_path))

# lib symlink should point to a relative path
self.assertFalse(os.path.isabs(os.readlink(lib_path)))
# lib64 subdir is a symlink to lib subdir
self.assertExists(lib64_path)
self.assertTrue(os.path.isdir(lib64_path))
self.assertTrue(os.path.islink(lib64_path))
self.assertTrue(os.path.samefile(lib64_path, lib_path))

# lib64 symlink should point to a relative path
self.assertFalse(os.path.isabs(os.readlink(lib64_path)))

# cleanup and try again with --disable-lib-lib64-symlink
remove_dir(self.test_installpath)
with self.mocked_stdout_stderr():
self._test_toy_build(ec_file=test_ec, extra_args=['--disable-lib-lib64-symlink'])
self._test_toy_build(ec_file=test_ec, extra_args=['--disable-lib64-lib-symlink'])

self.assertExists(lib64_path)
self.assertNotExists(lib_path)
self.assertNotIn('lib', os.listdir(toy_installdir))
self.assertTrue(os.path.isdir(lib64_path))
self.assertFalse(os.path.islink(lib64_path))
self.assertExists(lib_path)
self.assertNotExists(lib64_path)
self.assertNotIn('lib64', os.listdir(toy_installdir))
self.assertTrue(os.path.isdir(lib_path))
self.assertFalse(os.path.islink(lib_path))

def test_toy_build_sanity_check_linked_libs(self):
"""Test sanity checks for banned/requires libraries."""
Expand Down

0 comments on commit 0c0332a

Please sign in to comment.