Compare commits

..

No commits in common. "a54e64242b2d24c0b0f969d85271c9ccd0f88d56" and "e90055e3bd181961a2609435e2afd044bf6172f6" have entirely different histories.

3 changed files with 18 additions and 44 deletions

View file

@ -1,4 +1,4 @@
__version__ = "0.2.5-7"
__version__ = "0.2.5-6"
__author__ = "Reid D. 'arrdem' McKenzie <me@arrdem.com>"
__copyright__ = "Copyright 2020"
__license__ = "https://anticapitalist.software/"

View file

@ -102,7 +102,7 @@ def expandvars(s: str) -> str:
return os.uname()[1]
elif var == "${home}":
return os.path.expanduser("~")
elif var == "${uname}" or var == "${sysname}":
elif var == "${uname}" | "${sysname}":
return platform.system().lower()
elif var == "${arch}":
return platform.machine()

View file

@ -19,12 +19,7 @@ def tempf(global_config, name):
root = Path(global_config["cram"]["root"])
assert root.exists() and root.is_dir()
cache_dir = (
global_config.get("cram", {})
.get("task", {})
.get("default", {})
.get("cache_dir")
)
cache_dir = global_config.get("cram", {}).get("task", {}).get("default", {}).get("cache_dir")
cache_root = cache_dir and Path(expandvars(cache_dir)) or root / ".cache"
return cache_root / name[0:2] / name
@ -43,9 +38,7 @@ class PackageV1(Package):
return self._config
def test(self):
return (self.root / self.SPECIAL_FILES[0]).exists() and self.config().get(
"cram", {}
).get("version") == 1
return (self.root / self.SPECIAL_FILES[0]).exists() and self.config().get("cram", {}).get("version") == 1
def requires(self):
"""Get the dependencies of this package."""
@ -56,15 +49,11 @@ class PackageV1(Package):
elif isinstance(it, dict):
return it["name"]
return [_name(it) for it in self.config().get("package", {}).get("require", [])]
return [
_name(it) for it in self.config().get("package", {}).get("require", [])
]
def do_sh_or_script(
self,
content: Optional[Union[List[str], str]],
fs: Vfs,
dest: Path,
cwd: Path = "/tmp",
):
def do_sh_or_script(self, content: Optional[Union[List[str], str]], fs: Vfs, dest: Path, cwd: Path = "/tmp"):
if content is None:
pass
@ -77,7 +66,7 @@ class PackageV1(Package):
content["run"],
fs,
dest,
{"cwd": self.root}.get(content.get("root"), "/tmp"),
{"cwd": self.root}.get(content.get("root"), "/tmp")
)
elif isinstance(content, str):
@ -104,24 +93,19 @@ class PackageV1(Package):
with open(installf, "r") as fp:
self.do_sh_or_script(fp.read(), fs, dest)
def do_build(self, fs: Vfs, dest: Path):
self.do_sh_or_script(self.config().get("package", {}).get("build"), fs, dest)
def pre_install(self, fs: Vfs, dest: Path):
self.do_sh_or_script(
self.config().get("package", {}).get("pre_install"), fs, dest
)
self.do_sh_or_script(self.config().get("package", {}).get("pre_install"), fs, dest)
def do_install(self, fs: Vfs, dest: Path):
if not self.do_sh_or_script(
self.config().get("package", {}).get("install"), fs, dest
):
if not self.do_sh_or_script(self.config().get("package", {}).get("install"), fs, dest):
stow(fs, self.root, dest, self.SPECIAL_FILES)
def post_install(self, fs: Vfs, dest: Path):
self.do_sh_or_script(
self.config().get("package", {}).get("post_install"), fs, dest
)
self.do_sh_or_script(self.config().get("package", {}).get("post_install"), fs, dest)
def json(self):
return self.config()
@ -140,24 +124,16 @@ class LightPackageV1(PackageV1):
return self._config
def test(self):
return (
self.root.exists()
and self.root.is_file()
and self.root.name.endswith(".toml")
return self.root.exists() \
and self.root.is_file() \
and self.root.name.endswith(".toml") \
and self.config().get("cram", {}).get("version") == 1
)
class ProfileV1(PackageV1):
"""Unline packages, profiles don't support recursive stow of contents."""
_LEGACY_SPECIAL_FILES = [
"BUILD",
"PRE_INSTALL",
"INSTALL",
"POST_INSTALL",
"REQUIRES",
]
_LEGACY_SPECIAL_FILES = ["BUILD", "PRE_INSTALL", "INSTALL", "POST_INSTALL", "REQUIRES"]
SPECIAL_FILES = []
_config = None
@ -165,9 +141,7 @@ class ProfileV1(PackageV1):
return {}
def test(self):
return self.root.is_dir() and not any(
(self.root / f).exists() for f in self._LEGACY_SPECIAL_FILES
)
return self.root.is_dir() and not any((self.root / f).exists() for f in self._LEGACY_SPECIAL_FILES)
def do_install(self, fs: Vfs, dest: Path):
return