Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Get full path to workdir earlier
Browse files Browse the repository at this point in the history
This patch moves the path expansion for the workdir much earlier
in the skt run. The absolute path is now gathered during the
initial configuration checks rather than during the skt operations.

This is part of #94.

Signed-off-by: Major Hayden <[email protected]>
  • Loading branch information
major committed May 14, 2018
1 parent e7e25f5 commit 356bbdc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
11 changes: 2 additions & 9 deletions skt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import re
import shutil
import subprocess
import tempfile
import sys
import io
import time
Expand Down Expand Up @@ -106,12 +105,8 @@ def __init__(self, uri, ref=None, wdir=None, fetch_depth=None):
The amount of git history to include with the clone.
Smaller depths lead to faster repo clones.
"""
# FIXME Move expansion up the call stack, as this limits the class
# usefulness, because tilde is a valid path character.
# The git "working directory" (the "checkout")
self.wdir = (os.path.expanduser(wdir)
if wdir is not None
else tempfile.mkdtemp())
self.wdir = wdir
# The cloned git repository
self.gdir = "%s/.git" % self.wdir
# The origin remote's URL
Expand Down Expand Up @@ -437,9 +432,7 @@ def bisect_iter(self, bad):
class kbuilder(object):
def __init__(self, path, basecfg, cfgtype=None, makeopts=None,
enable_debuginfo=False):
# FIXME Move expansion up the call stack, as this limits the class
# usefulness, because tilde is a valid path character.
self.path = os.path.expanduser(path)
self.path = path
# FIXME Move expansion up the call stack, as this limits the class
# usefulness, because tilde is a valid path character.
self.basecfg = os.path.expanduser(basecfg)
Expand Down
20 changes: 16 additions & 4 deletions skt/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import shutil
import sys
import tempfile
import time
import traceback

Expand Down Expand Up @@ -371,9 +372,7 @@ def cmd_cleanup(cfg):
pass

if cfg.get('wipe') and cfg.get('workdir'):
# FIXME Move expansion up the call stack, as this limits the function
# usefulness, because tilde is a valid path character.
shutil.rmtree(os.path.expanduser(cfg.get('workdir')))
shutil.rmtree(cfg.get('workdir'))


def cmd_all(cfg):
Expand Down Expand Up @@ -487,7 +486,16 @@ def setup_parser():
"""
parser = argparse.ArgumentParser()

parser.add_argument("-d", "--workdir", type=str, help="Path to work dir")
parser.add_argument(
"-d",
"--workdir",
type=str,
default=tempfile.mkdtemp(),
help=(
"Path to work directory "
"(default: 'workdir' in current directory)"
)
)
parser.add_argument("-w", "--wipe",
help="Clean build (make mrproper before building), "
"remove workdir when finished",
Expand Down Expand Up @@ -703,6 +711,10 @@ def load_config(args):
if cfg.get("bisect"):
cfg['wait'] = True

# Get absolute paths for files and directories
if cfg.get('workdir'):
cfg['workdir'] = full_path(cfg.get('workdir'))

return cfg


Expand Down

0 comments on commit 356bbdc

Please sign in to comment.