-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto download images by base board, make python code a python package #…
- Loading branch information
Showing
19 changed files
with
300 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[tool.poetry] | ||
name = "custompios" | ||
version = "2.0.0" | ||
description = "A Raspberry Pi and other ARM devices distribution builder. CustomPiOS opens an already existing image, modifies it and repackages the image ready to ship." | ||
authors = ["Guy Sheffer <guysoft@gmail.com>"] | ||
license = "GPLv3" | ||
readme = "README.rst" | ||
packages = [ | ||
# { include = "src/*" }, | ||
{ include = "custompios_core", from = "src" } | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
GitPython = "^3.1.41" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
types-PyYAML = "^6.0.12.12" | ||
|
||
[tool.poetry.scripts] | ||
custompios_build = 'custompios_core.multi_build:main' | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
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
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
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
Empty file.
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,32 @@ | ||
""" Common functions between CustomPiOS python scripts""" | ||
from typing import Dict, Any, Optional, cast | ||
import yaml | ||
import os | ||
from pathlib import Path | ||
|
||
def get_custompios_folder(): | ||
custompios_path = os.environ.get("CUSTOM_PI_OS_PATH", None) | ||
if custompios_path is not None: | ||
return Path(custompios_path) | ||
return Path(__file__).parent.parent | ||
|
||
|
||
IMAGES_CONFIG = os.path.join(get_custompios_folder(), "images.yml") | ||
|
||
|
||
def read_images() -> Dict[str, Dict[str,str]]: | ||
if not os.path.isfile(IMAGES_CONFIG): | ||
raise Exception(f"Error: Remotes config file not found: {IMAGES_CONFIG}") | ||
with open(IMAGES_CONFIG,'r') as f: | ||
output = yaml.safe_load(f) | ||
return output | ||
|
||
def get_image_config() -> Optional[Dict["str", Any]]: | ||
images = read_images() | ||
|
||
base_board = os.environ.get("BASE_BOARD", None) | ||
base_image_path = os.environ.get("BASE_IMAGE_PATH", None) | ||
|
||
if base_board is not None and base_board in images["images"]: | ||
return images["images"][base_board] | ||
return None |
File renamed without changes.
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,28 @@ | ||
#!/usr/bin/python3 | ||
import os | ||
import yaml | ||
from pathlib import Path | ||
from typing import Tuple, Optional, Dict, Any, cast | ||
import git | ||
from git import RemoteProgress | ||
from common import get_image_config | ||
import argparse | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(add_help=True, description='Create an export shell script to use the yaml-configured variables') | ||
parser.add_argument('output_script', type=str, help='path to output the chroot script master') | ||
args = parser.parse_args() | ||
image_config = get_image_config() | ||
if image_config is None: | ||
print("Error: Could not get image config") | ||
sys.exit(1) | ||
cast(Dict[str,Any], image_config) | ||
if not "env" in image_config.keys(): | ||
print("Warning: no env in image config") | ||
exit() | ||
env = image_config["env"] | ||
with open(args.output_script, "w+") as w: | ||
for key in env.keys(): | ||
w.write(f'export {key}="{env[key]}"\n') | ||
|
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,11 @@ | ||
#!/usr/bin/python3 | ||
from common import read_images | ||
|
||
if __name__ == "__main__": | ||
images = read_images()["images"] | ||
print("Available board targest for --board are:") | ||
for key in sorted(images): | ||
if "description" in images[key].keys(): | ||
print(f'{key} - {images[key]["description"]}') | ||
else: | ||
print(key) |
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
import argparse | ||
|
||
def get_choices(): | ||
return ['rock', 'paper', 'scissors'] | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(add_help=True, description='Build mulitple images for multiple devices') | ||
parser.add_argument('--list', "-l", choices=get_choices(), type=str, nargs='+') | ||
args = parser.parse_args() | ||
print(args.list) | ||
print("Done") | ||
return | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.