generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
801 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Craftcraft: Verify your sources.""" | ||
|
||
from craft_parts.features import Features | ||
|
||
from . import models | ||
from .application import Craftcraft | ||
|
||
try: | ||
# This only gets created at wheel-creation time, so we're ignoring all of | ||
# it for type checking purposes. | ||
from ._version import ( # type: ignore[import] | ||
__version__, | ||
) | ||
except ImportError: # pragma: no cover | ||
from importlib.metadata import version, PackageNotFoundError | ||
|
||
try: | ||
__version__ = version("craftcraft") | ||
except PackageNotFoundError: | ||
__version__ = "dev" | ||
|
||
Features( | ||
enable_overlay=False, | ||
enable_partitions=True, | ||
) | ||
|
||
__all__ = ["__version__", "models", "Craftcraft"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This file is part of craftcraft | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Entrypoint to use if running with python -m craftcraft.""" | ||
import sys | ||
|
||
from craftcraft.cli import main | ||
|
||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Main application class for craftcraft.""" | ||
import copy | ||
from typing import Any | ||
|
||
import craft_parts | ||
from craft_application import Application, AppMetadata, util | ||
|
||
from craftcraft import models | ||
|
||
APP_METADATA = AppMetadata( | ||
name="craftcraft", | ||
summary="Craft a craft application with craft-application", | ||
ProjectClass=models.Project, | ||
) | ||
|
||
|
||
class Craftcraft(Application): | ||
"""Craftcraft application definition.""" | ||
|
||
def configure(self, global_args: dict[str, Any]) -> None: | ||
"""Configure the application using global command-line arguments.""" | ||
|
||
def _configure_services(self, platform: str | None, build_for: str | None) -> None: | ||
if build_for is None: | ||
build_for = util.get_host_architecture() | ||
|
||
self.services.set_kwargs( | ||
"package", | ||
platform=platform, | ||
build_for=build_for, | ||
) | ||
super()._configure_services(platform, build_for) | ||
|
||
def _extra_yaml_transform(self, yaml_data: dict[str, Any]) -> dict[str, Any]: | ||
"""Transform the YAML file before parsing it as a project.""" | ||
yaml_data = copy.deepcopy(yaml_data) | ||
|
||
# Put your transforms here. | ||
yaml_data.update({}) | ||
|
||
return yaml_data | ||
|
||
def _project_vars(self, yaml_data: dict[str, Any]) -> dict[str, str]: | ||
"""Populate any variables to be used in the project info.""" | ||
project_vars = super()._project_vars(yaml_data) | ||
|
||
# Update the dictionary here. | ||
project_vars.update({}) | ||
|
||
return project_vars | ||
|
||
def _set_global_environment(self, info: craft_parts.ProjectInfo) -> None: | ||
"""Populate the global environment to use when running the parts lifecycle.""" | ||
super()._set_global_environment(info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Command-line interface entrypoint.""" | ||
|
||
from craftcraft import Craftcraft, application, services | ||
|
||
|
||
def main() -> int: | ||
"""Start up and run Craftcraft.""" | ||
factory = services.ServiceFactory( | ||
app=application.APP_METADATA, | ||
LifecycleClass=services.Lifecycle, | ||
PackageClass=services.Package, | ||
) | ||
|
||
app = Craftcraft(app=application.APP_METADATA, services=factory) | ||
|
||
return app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Global constants to use in craftcraft.""" | ||
|
||
# Bases supported by this application. | ||
SUPPORTED_BASES = [ | ||
"ubuntu@22.04", | ||
] | ||
|
||
# Bases that , as well as the version in which they were deprecated. | ||
DEPRECATED_BASES: dict[str, str] = { | ||
# Map the base name to the version in which it was deprecated. | ||
"ubuntu@20.04": "0.0", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Data models for Craftcraft.""" | ||
|
||
from .metadata import Metadata | ||
from .project import Project | ||
from .util import Base | ||
|
||
__all__ = ["Metadata", "Project"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This file is part of craftcraft. | ||
# | ||
# Copyright 2024 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""metadata.yaml description for craftcraft output.""" | ||
|
||
from craft_application.models import BaseMetadata | ||
|
||
from craftcraft.models.util import Base | ||
|
||
|
||
class Metadata(BaseMetadata): | ||
"""Structure to hold output metadata.""" | ||
|
||
name: str | ||
summary: str | ||
description: str | ||
version: str | ||
license: str | ||
base: Base |
Oops, something went wrong.