parent
33bea69dff
commit
9ea96d0c1d
13 changed files with 39 additions and 34 deletions
|
@ -2,28 +2,22 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
import pickle
|
||||
from typing import List, Optional, Union
|
||||
import re
|
||||
import platform
|
||||
from pprint import pformat
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
from . import (
|
||||
__author__,
|
||||
__copyright__,
|
||||
__license__,
|
||||
__version__,
|
||||
)
|
||||
from .v0 import PackageV0, ProfileV0
|
||||
from .v1 import PackageV1, ProfileV1
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import click
|
||||
import toml
|
||||
from toposort import toposort_flatten
|
||||
from vfs import Vfs
|
||||
|
||||
from . import __author__, __copyright__, __license__, __version__
|
||||
from .v0 import PackageV0, ProfileV0
|
||||
from .v1 import LightPackageV1, PackageV1, ProfileV1
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -114,7 +108,7 @@ def load(root: Path, name: str, clss):
|
|||
|
||||
def load_package(root, name):
|
||||
log.debug(f"Attempting to load package {name} from {root}")
|
||||
return load(root, name, [PackageV1, PackageV0])
|
||||
return load(root, name, [LightPackageV1, PackageV1, PackageV0])
|
||||
|
||||
|
||||
def load_profile(root, name):
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from shlex import quote as sh_quote
|
||||
import sys
|
||||
from typing import List, Optional
|
||||
|
||||
from vfs import Vfs
|
||||
|
||||
|
||||
# FIXME: This should be a config somewhere
|
||||
SHELL = "/bin/sh"
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
An ill-considered pseudo-format.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
from .common import Package, sh, stow
|
||||
from pathlib import Path
|
||||
|
||||
from vfs import Vfs
|
||||
|
||||
from .common import Package, sh, stow
|
||||
|
||||
|
||||
class PackageV0(Package):
|
||||
"""The original package format from install.sh."""
|
||||
|
|
|
@ -9,11 +9,11 @@ from hashlib import sha256
|
|||
from pathlib import Path
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from .common import Package, sh, stow
|
||||
|
||||
import toml
|
||||
from vfs import Vfs
|
||||
|
||||
from .common import Package, sh, stow
|
||||
|
||||
|
||||
def tempf(name):
|
||||
root = Path("/tmp/stow")
|
||||
|
@ -94,11 +94,29 @@ class PackageV1(Package):
|
|||
def post_install(self, fs: Vfs, dest: Path):
|
||||
self.do_sh_or_script(self.config().get("package", {}).get("post_install"), fs, dest)
|
||||
|
||||
|
||||
def json(self):
|
||||
return self.config()
|
||||
|
||||
|
||||
class LightPackageV1(PackageV1):
|
||||
"""A package with no file content, defined in a single file."""
|
||||
|
||||
SPECIAL_FILES = []
|
||||
_config = None
|
||||
|
||||
def config(self):
|
||||
if not self._config:
|
||||
with open(self.root, "r") as fp:
|
||||
self._config = toml.load(fp)
|
||||
return self._config
|
||||
|
||||
def test(self):
|
||||
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."""
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import logging
|
|||
from shutil import rmtree
|
||||
from subprocess import run
|
||||
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
5
test/integration/packages.d/p8.toml
Normal file
5
test/integration/packages.d/p8.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[cram]
|
||||
version = 1
|
||||
|
||||
[[package.install]]
|
||||
run = "echo 'ok'"
|
|
@ -9,7 +9,6 @@ import sys
|
|||
|
||||
from autoflake import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
|
@ -5,7 +5,6 @@ import sys
|
|||
|
||||
from black import nullcontext, patched_main
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--output-file", default=None)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from flake8.main import cli
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli.main()
|
||||
|
|
|
@ -9,7 +9,6 @@ import sys
|
|||
|
||||
from isort.main import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
|
@ -4,7 +4,6 @@ import sys
|
|||
|
||||
import pytest
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cmdline = ["--ignore=external"] + sys.argv[1:]
|
||||
print(cmdline, file=sys.stderr)
|
||||
|
|
|
@ -4,12 +4,8 @@ Validate 3rdparty library licenses as approved.
|
|||
|
||||
import re
|
||||
|
||||
from pkg_resources import (
|
||||
DistInfoDistribution,
|
||||
working_set,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from pkg_resources import DistInfoDistribution, working_set
|
||||
|
||||
# Licenses approved as representing non-copyleft and not precluding commercial usage.
|
||||
# This is all easy, there's a good schema here.
|
||||
|
|
|
@ -7,6 +7,5 @@ Shim for executing isort.
|
|||
|
||||
from unify import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
|
|
Loading…
Reference in a new issue