Skip to content

Commit

Permalink
Merge branch '1.0.x' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jun 18, 2021
2 parents a040a21 + 70c11b2 commit 5e26169
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
os: [ubuntu-latest]
mode: [tests]
python:
- "3.5"
- "3.8"
include:
- os: ubuntu-18.04
- os: ubuntu-latest
mode: coverage
python: "3.9"
- os: ubuntu-18.04
- os: ubuntu-latest
mode: checks
python: "3.9"
- os: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ Bugs and feature plannings are tracked in the [GitHub issues](https://github.com

To suggest changes to this source code, feel free to raise a [GitHub pull request](https://github.com/VIDA-NYU/reprozip/pulls). Any contributions received are assumed to be covered by the [BSD 3-Clause license](LICENSE.txt). We might ask you to sign a _Contributor License Agreement_ before accepting a larger contribution.

Research notice
---------------

Please note that this repository is participating in a study into sustainability of open source projects. Data will be gathered about this repository for approximately the next 12 months, starting from June 2021.

Data collected will include number of contributors, number of PRs, time taken to close/merge these PRs, and issues closed.

For more information, please visit [the informational page](https://sustainable-open-science-and-software.github.io/) or download the [participant information sheet](https://sustainable-open-science-and-software.github.io/assets/PIS_sustainable_software.pdf).

License
-------

Expand Down
33 changes: 29 additions & 4 deletions reprounzip/reprounzip/unpackers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import argparse
import copy
from elftools.common.exceptions import ELFError
from elftools.elf.elffile import ELFFile
from elftools.elf.segments import InterpSegment
import logging
import os
import platform
Expand All @@ -42,6 +45,17 @@
logger = logging.getLogger('reprounzip')


def get_elf_interpreter(file):
try:
elf = ELFFile(file)
for segment in elf.iter_segments():
if isinstance(segment, InterpSegment):
return segment.get_interp_name()
return None
except ELFError:
return None


def installpkgs(args):
"""Installs the necessary packages on the current machine.
"""
Expand Down Expand Up @@ -216,19 +230,21 @@ def directory_run(args):
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode,
['/sbin/ldconfig', '-v', '-N'])
lib_dirs = ('export LD_LIBRARY_PATH=%s' % ':'.join(
shell_escape(str(join_root(root, d)))
for d in lib_dirs))

cmds = [lib_dirs]
cmds = []
for run_number in selected_runs:
run = runs[run_number]
cmd = 'cd %s && ' % shell_escape(
str(join_root(root, Path(run['workingdir']))))
cmd += '/usr/bin/env -i '
cmd += 'LD_LIBRARY_PATH=%s' % ':'.join(
shell_escape(str(join_root(root, d)))
for d in lib_dirs
)
environ = run['environ']
environ = fixup_environment(environ, args)
if args.x11:
environ = dict(environ)
if 'DISPLAY' in os.environ:
environ['DISPLAY'] = os.environ['DISPLAY']
if 'XAUTHORITY' in os.environ:
Expand All @@ -250,6 +266,14 @@ def directory_run(args):
path = ':'.join(str(d) for d in dir_path + path)
cmd += 'PATH=%s ' % shell_escape(path)

interpreter = get_elf_interpreter(
join_root(root, PosixPath(run['binary'])).open('rb'),
)
if interpreter is not None:
interpreter = Path(interpreter)
if interpreter.exists():
cmd += '%s ' % shell_escape(str(join_root(root, interpreter)))

# FIXME : Use exec -a or something if binary != argv[0]
if cmdline is None:
argv = run['argv']
Expand Down Expand Up @@ -579,6 +603,7 @@ def chroot_run(args):
forwarders.append(fwd)

signals.pre_run(target=target)
logger.debug("Running: %s", cmds)
retcode = interruptible_call(cmds, shell=True)
print("\n*** Command finished, status: %d\n" % retcode, file=sys.stderr)
signals.post_run(target=target, retcode=retcode)
Expand Down
3 changes: 2 additions & 1 deletion reprounzip/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
'rpaths>=0.8',
'usagestats>=0.3',
'requests',
'distro']
'distro',
'pyelftools']
setup(name='reprounzip',
version='2.0.0',
packages=['reprounzip', 'reprounzip.unpackers',
Expand Down
2 changes: 1 addition & 1 deletion reprozip/reprozip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def print_db(database):
if not argv[-1]:
argv = argv[:-1]
cmdline = ' '.join(shell_escape(a) for a in argv)
if argv[0] not in (r_name, os.path.basename(r_name)):
if argv[0] != r_name:
cmdline = "(%s) %s" % (shell_escape(r_name), cmdline)
f_cmdline = " {0: <37s} ".format(cmdline)
print('|'.join(('', f_id, f_timestamp, f_proc, f_cmdline, '')))
Expand Down
1 change: 0 additions & 1 deletion tests/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def call_output(args, stream='out'):
return retcode, b''.join(output)


@print_arg_list
def check_output(args, stream='out'):
retcode, output = call_output(args, stream)
if retcode != 0:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reprozip.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def do_test(self, insert):
try:
files, inputs, outputs = get_files(conn)
files = set(fi for fi in files
if not fi.path.path.startswith(b'/lib'))
if not fi.path.path.startswith((b'/lib', b'/usr/lib')))
return files, inputs, outputs
finally:
conn.close()
Expand Down

0 comments on commit 5e26169

Please sign in to comment.