-
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
244 additions
and
28 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() |
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,60 @@ | ||
images: | ||
raspberrypiarmhf: | ||
description: "Official raspberrypi lite 32bit image" | ||
# url: "https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.torrent" | ||
# checksum: "https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.sha256" | ||
# type: torrent | ||
url: "https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz" | ||
checksum: "https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz.sha256" | ||
type: http | ||
env: | ||
BASE_ARCH: armhf | ||
raspberrypiarm64: | ||
description: "Official raspberrypi lite 64bit image" | ||
url: "https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.torrent" | ||
checksum: "https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.sha256" | ||
type: torrent | ||
env: | ||
BASE_ARCH: arm64 | ||
orangepi_orangepi_zero2: | ||
description: "Orange Pi Zero2" | ||
url: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/orangepi-orangepi_zero2_bullseye.img.xz" | ||
checksum: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/orangepi-orangepi_zero2_bullseye.img.xz.sha256" | ||
type: http | ||
env: | ||
BASE_ARCH: arm64 | ||
armbian_bananapim2zero: | ||
description: "Banana Pi BPI-M2 ZERO" | ||
url: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-bananapi_m2_zero_bullseye.img.xz" | ||
checksum: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-bananapi_m2_zero_bullseye.img.xz.sha256" | ||
type: http | ||
env: | ||
BASE_ARCH: arm64 | ||
armbian_orangepi3lts: | ||
description: "Orange Pi 3 LTS" | ||
url: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-orangepi3_lts_bullseye.img.xz" | ||
checksum: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-orangepi3_lts_bullseye.img.xz.sha256" | ||
type: http | ||
env: | ||
BASE_ARCH: arm64 | ||
armbian_orangepi4lts: | ||
description: "Orange Pi 4 LTS" | ||
url: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-orangepi4_lts_bullseye.img.xz" | ||
checksum: "https://github.com/mainsail-crew/armbian-builds/releases/latest/download/armbian-orangepi4_lts_bullseye.img.xz.sha256" | ||
type: http | ||
env: | ||
BASE_ARCH: arm64 | ||
BASE_DISTRO: armbian | ||
BASE_IMAGE_RASPBIAN: "no" | ||
raspbian_lepotato: | ||
description: "Le Potato AML-S905X-CC Raspbian image" | ||
url: "https://distro.libre.computer/ci/raspbian/11/2023-05-03-raspbian-bullseye-arm64-lite%2Baml-s905x-cc.img.xz" | ||
checksum: "https://distro.libre.computer/ci/raspbian/11/SHA256SUMS" | ||
type: http | ||
env: | ||
BASE_ARCH: arm64 | ||
BASE_DISTRO: raspbian | ||
BASE_IMAGE_RASPBIAN: "yes" | ||
BASE_ADD_USER: "yes" | ||
BASE_USER: "pi" | ||
BASE_USER_PASSWORD: "lepotato" |
Oops, something went wrong.