Skip to content

Commit

Permalink
Fixes recipes so that all Darwin recipes use 'make install'. Other va…
Browse files Browse the repository at this point in the history
…rious improvements, including caching of downloads in the ~/.mussels/cache directory, and support for globbing of install files.
  • Loading branch information
val-ms committed Sep 2, 2019
1 parent 5a4b0b8 commit 9d2b6c1
Show file tree
Hide file tree
Showing 36 changed files with 513 additions and 456 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__pycache__
.mypy_cache
.pytest_cache
.vscode
out
mussels.egg-info
24 changes: 20 additions & 4 deletions mussels/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

logging.basicConfig()
module_logger = logging.getLogger("mussels")
coloredlogs.install(level="DEBUG")
coloredlogs.install(level="DEBUG", fmt="%(asctime)s %(name)s %(levelname)s %(message)s")
module_logger.setLevel(logging.DEBUG)

#
Expand Down Expand Up @@ -213,7 +213,13 @@ def recipe_show(recipe: str, version: str, verbose: bool):
is_flag=True,
help="Print out the version dependency graph without actually doing a build. [optional]",
)
def recipe_build(recipe: str, version: str, cookbook: str, dry_run: bool):
@click.option(
"--force",
"-f",
is_flag=True,
help="Re-build a recipe, even if already built. [optional]",
)
def recipe_build(recipe: str, version: str, cookbook: str, dry_run: bool, force: bool):
"""
Download, extract, build, and install a recipe.
"""
Expand All @@ -222,7 +228,9 @@ def recipe_build(recipe: str, version: str, cookbook: str, dry_run: bool):

results = []

success = my_mussels.build_recipe(recipe, version, cookbook, results, dry_run)
success = my_mussels.build_recipe(
recipe, version, cookbook, results, dry_run, force
)
if success == False:
sys.exit(1)

Expand All @@ -249,8 +257,16 @@ def recipe_build(recipe: str, version: str, cookbook: str, dry_run: bool):
is_flag=True,
help="Print out the version dependency graph without actually doing a build. [optional]",
)
@click.option(
"--force",
"-f",
is_flag=True,
help="Re-build a recipe, even if already built. [optional]",
)
@click.pass_context
def build_alias(ctx, recipe: str, version: str, cookbook: str, dry_run: bool):
def build_alias(
ctx, recipe: str, version: str, cookbook: str, dry_run: bool, force: bool
):
"""
Download, extract, build, and install a recipe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Recipe(BaseRecipe):
"""

name = "clamav_deps"
version = "0.102"
version = "0.102.0"
is_collection = True
platform = ["Darwin"]
dependencies = ["curl", "json_c", "libxml2", "openssl", "pcre2", "bzip2"]
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class Recipe(BaseRecipe):
"""

name = "clamav_deps"
version = "0.102"
version = "0.102.0"
is_collection = True
platform = ["Windows"]
dependencies = [
"curl",
"json_c",
Expand Down
25 changes: 18 additions & 7 deletions mussels/mussels.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
self,
data_dir: str = os.path.join(str(Path.home()), ".mussels"),
log_file: str = os.path.join(
str(Path.home()), ".mussels", "log", "mussels.log"
str(Path.home()), ".mussels", "logs", "mussels.log"
),
log_level: str = "DEBUG",
) -> None:
Expand Down Expand Up @@ -159,8 +159,12 @@ def _read_cookbook(self, cookbook: str, cookbook_path: str) -> bool:
sorted_tools: defaultdict = defaultdict(list)

# Load the recipes and collections
recipes = read.recipes(os.path.join(cookbook_path, "recipes", platform.system()))
recipes.update(read.recipes(os.path.join(cookbook_path, "collections", platform.system())))
recipes = read.recipes(
os.path.join(cookbook_path, "recipes", platform.system())
)
recipes.update(
read.recipes(os.path.join(cookbook_path, "collections", platform.system()))
)
sorted_recipes = sort_cookbook_by_version(recipes)

self.cookbooks[cookbook]["recipes"] = sorted_recipes
Expand Down Expand Up @@ -252,7 +256,12 @@ def _load_recipes(self) -> bool:
return True

def _build_recipe(
self, recipe: str, version: str, cookbook: str, toolchain: dict
self,
recipe: str,
version: str,
cookbook: str,
toolchain: dict,
force: bool = False,
) -> dict:
"""
Build a specific recipe.
Expand Down Expand Up @@ -318,7 +327,7 @@ def _build_recipe(
result["time elapsed"] = time.time() - start
return result

if not builder._build():
if not builder._build(force):
self.logger.error(f"FAILURE: {recipe}-{version} build failed!\n")
else:
self.logger.info(f"Success: {recipe}-{version} build succeeded. :)\n")
Expand Down Expand Up @@ -451,6 +460,7 @@ def build_recipe(
cookbook: str,
results: list,
dry_run: bool = False,
force: bool = False,
) -> bool:
"""
Execute a build of a recipe.
Expand Down Expand Up @@ -488,9 +498,9 @@ def print_results(results: list):
recipe_str = f"{recipe}=={version}"

if cookbook == "":
recipe_str = f"local:{recipe}"
recipe_str = f"local:{recipe_str}"
else:
recipe_str = f"{cookbook}:{recipe}"
recipe_str = f"{cookbook}:{recipe_str}"

batches = self._get_build_batches(recipe_str)

Expand Down Expand Up @@ -615,6 +625,7 @@ def print_results(results: list):
recipe_nvc.version,
recipe_nvc.cookbook,
toolchain,
force,
)
results.append(result)
if not result["success"]:
Expand Down
Loading

0 comments on commit 9d2b6c1

Please sign in to comment.