Skip to content

Commit

Permalink
Refactor for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
destrangis committed Feb 23, 2021
1 parent beecd5f commit 22db12b
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions archiver/mkarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,7 @@
except ImportError:
from importlib_resources import read_text

from installer import create_installer
import installer


DEFAULT_LIBTAR_A = "/usr/lib/x86_64-linux-gnu/libtar.a"
Expand Down Expand Up @@ -123,13 123,32 @@ def cleanup(*files):
os.remove(f)


def create_installer(options):
varlst = options.var or []
varmap = {}
for v in varlst:
kv = v.split("=", 1)
key = kv[0]
val = kv[1] if len(kv) > 1 else None
varmap[key] = val

installer.create_installer(options.install_spec,
'setup',
options.uname,
dialog=options.dialog_tool,
vars=varmap)

if 'setup' not in options.file:
options.file.append('setup')


def parse_cmdline(argv):
p = argparse.ArgumentParser(description=__doc__)
p.add_argument(
"--output",
"-o",
metavar="name",
default="selfextract",
default=DEFAULT_SELF_EXTRACTOR_NAME,
help="Name of the output self-extractor. Default "
f"'{DEFAULT_SELF_EXTRACTOR_NAME}'",
)
Expand Down Expand Up @@ -173,22 192,7 @@ def main(argv=None):

options = parse_cmdline(argv)
if options.install_spec:
varlst = options.var or []
varmap = {}
for v in varlst:
kv = v.split("=", 1)
key = kv[0]
val = kv[1] if len(kv) > 1 else None
varmap[key] = val

create_installer(options.install_spec,
'setup',
options.uname,
dialog=options.dialog_tool,
vars=varmap)

if 'setup' not in options.file:
options.file.append('setup')
create_installer(options)

with tempfile.TemporaryDirectory(dir=options.tmpdir) as tmpdir:
workdir = pathlib.Path(tmpdir)
Expand Down

0 comments on commit 22db12b

Please sign in to comment.