Skip to content

Commit

Permalink
Include rpzsudo in reprounzip, don't download
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jun 18, 2021
1 parent 5e26169 commit 18cf127
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
16 changes: 9 additions & 7 deletions reprounzip-docker/reprounzip_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import re
from rpaths import Path, PosixPath
import shutil
import socket
import subprocess
import sys
Expand All @@ -27,10 +28,11 @@
from reprounzip.parameters import get_parameter
from reprounzip.unpackers.common import COMPAT_OK, COMPAT_MAYBE, \
UsageError, CantFindInstaller, composite_action, target_must_exist, \
make_unique_name, shell_escape, select_installer, busybox_url, sudo_url, \
FileUploader, FileDownloader, get_runs, add_environment_options, \
parse_environment_args, interruptible_call, metadata_read, \
metadata_write, metadata_initial_iofiles, metadata_update_run, parse_ports
make_unique_name, shell_escape, select_installer, busybox_url, \
rpzsudo_binary, FileUploader, FileDownloader, get_runs, \
add_environment_options, parse_environment_args, interruptible_call, \
metadata_read, metadata_write, metadata_initial_iofiles, \
metadata_update_run, parse_ports
from reprounzip.unpackers.common.x11 import X11Handler, LocalForwarder
from reprounzip.utils import join_root, download_file

Expand Down Expand Up @@ -173,9 +175,9 @@ def docker_setup_create(args):
fp.write('COPY busybox /busybox\n')

# Installs rpzsudo
download_file(sudo_url(arch),
target / 'rpzsudo',
'rpzsudo-%s' % arch)
with rpzsudo_binary(arch) as f_in:
with (target / 'rpzsudo').open('wb') as f_out:
shutil.copyfileobj(f_in, f_out)
fp.write('COPY rpzsudo /rpzsudo\n\n')

fp.write('COPY data.tgz /reprozip_data.tgz\n\n')
Expand Down
10 changes: 2 additions & 8 deletions reprounzip/reprounzip/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"parameter file", which is just a JSON with a bunch of parameters.
In there you will find things like the address of some binaries that are
downloaded from the web (rpzsudo and busybox), and the name of Vagrant boxes
and Docker images for various operating systems.
downloaded from the web (busybox), and the name of Vagrant boxes and Docker
images for various operating systems.
"""

from distutils.version import LooseVersion
Expand Down Expand Up @@ -93,12 +93,6 @@ def get_parameter(section):
"x86_64": "https://s3.amazonaws.com/reprozip-files/busybox-x86_64",
"i686": "https://s3.amazonaws.com/reprozip-files/busybox-i686"
},
"rpzsudo_url": {
"x86_64": "https://github.com/remram44/static-sudo/releases/download/"
"current/rpzsudo-x86_64",
"i686": "https://github.com/remram44/static-sudo/releases/download/"
"current/rpzsudo-i686"
},
"docker_images": {
"default": {
"distribution": "debian",
Expand Down
Binary file added reprounzip/reprounzip/rpzsudo-i686
Binary file not shown.
Binary file added reprounzip/reprounzip/rpzsudo-x86_64
Binary file not shown.
4 changes: 2 additions & 2 deletions reprounzip/reprounzip/unpackers/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from reprounzip.unpackers.common.misc import UsageError, \
COMPAT_OK, COMPAT_NO, COMPAT_MAYBE, \
composite_action, target_must_exist, unique_names, \
make_unique_name, shell_escape, load_config, busybox_url, sudo_url, \
make_unique_name, shell_escape, load_config, busybox_url, rpzsudo_binary, \
FileUploader, FileDownloader, get_runs, add_environment_options, \
parse_environment_args, fixup_environment, interruptible_call, \
metadata_read, metadata_write, metadata_initial_iofiles, \
Expand All @@ -26,7 +26,7 @@
'UsageError', 'CantFindInstaller',
'composite_action', 'target_must_exist', 'unique_names',
'make_unique_name', 'shell_escape', 'load_config', 'busybox_url',
'sudo_url',
'rpzsudo_binary',
'join_root', 'FileUploader', 'FileDownloader', 'get_runs',
'add_environment_options', 'parse_environment_args',
'fixup_environment', 'interruptible_call', 'metadata_read',
Expand Down
13 changes: 8 additions & 5 deletions reprounzip/reprounzip/unpackers/common/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import itertools
import os
import pickle
import pkg_resources
import random
import re
import warnings

from rpaths import PosixPath, Path
import signal
import subprocess
import sys
import tarfile
import warnings

import reprounzip.common
from reprounzip.common import RPZPack
Expand Down Expand Up @@ -126,10 +126,13 @@ def busybox_url(arch):
return get_parameter('busybox_url')[arch]


def sudo_url(arch):
"""Gets the correct URL for the rpzsudo binary given the architecture.
def rpzsudo_binary(arch):
"""Gets the rpzsudo file given the architecture.
"""
return get_parameter('rpzsudo_url')[arch]
return pkg_resources.resource_stream(
__name__.split('.', 1)[0],
'rpzsudo-%s' % arch,
)


class FileUploader(object):
Expand Down
2 changes: 1 addition & 1 deletion reprounzip/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
packages=['reprounzip', 'reprounzip.unpackers',
'reprounzip.unpackers.common', 'reprounzip.plugins'],
package_data={
'reprounzip': ['reprozip-ca.crt'],
'reprounzip': ['reprozip-ca.crt', 'rpzsudo-i686', 'rpzsudo-x86_64'],
},
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 18cf127

Please sign in to comment.