diff --git a/.gitignore b/.gitignore index 65bba00..9e55ce3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ __pycache__/ packages/ pkgbuilds/ +output/ run.sh diff --git a/Dockerfile b/Dockerfile index 3b5876f..cfc045b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,14 @@ ADD scripts/run.sh /tmp RUN chmod +x /tmp/build.sh && \ chmod +x /tmp/run.sh && \ chmod -R 777 /tmp/pkgbuilds && \ - chmod 777 /tmp/packages -RUN /tmp/run.sh + /tmp/run.sh && \ + echo "Build completed!" + WORKDIR /tmp/gintctl ENTRYPOINT git clone https://gitea.planet-casio.com/Lephenixnoir/gintctl.git . && \ fxsdk build-cg && \ - fxsdk build-fx + fxsdk build-fx && \ + cp /tmp/pkgbuilds/**/*.pkg.* /mnt/output/ && \ + cp /tmp/packages/* /mnt/output/ && \ + echo "Build completed!" diff --git a/main.py b/main.py index 140b89b..c1c7390 100755 --- a/main.py +++ b/main.py @@ -45,17 +45,16 @@ def main(): with open("scripts/run.sh", "w") as file: file.write("#!/usr/bin/env bash\n") file.write("useradd user\n") - file.write("echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers)\n") + file.write("echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers\n") file.write(" && \\\n".join(commands)) if diffs == 0: logging.info("no updates planned") sys.exit(0) + docker_build() + # TODO: - # - build the container with a tag - # - run it - # - retreive built packages if everthing is fine # - push them to the repository # - create a systemd timer to run this script # - setup a web server to publish logs in case of failure diff --git a/scripts/build.sh b/scripts/build.sh index cf1b971..4ec6053 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash cd $1 -makepkg -si --noconfirm && cp *.pkg.tar.zst /tmp/packages/ +makepkg -si --noconfirm diff --git a/utils/__init__.py b/utils/__init__.py index b7b878b..49861bb 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,4 +1,5 @@ -from .middlearch import get_package_version, get_package_tarball from .config import load_config, clean_directories +from .docker import docker_build from .git import get_tags_from_git +from .middlearch import get_package_version, get_package_tarball from .pkgbuild import render_pkgbuild diff --git a/utils/config.py b/utils/config.py index c55c2dc..afd59b8 100644 --- a/utils/config.py +++ b/utils/config.py @@ -13,7 +13,7 @@ def load_config(path="packages.yaml"): return packages def clean_directories(): - for i in ["pkgbuilds", "packages"]: + for i in ["pkgbuilds", "packages", "output"]: try: shutil.rmtree(i) except FileNotFoundError: diff --git a/utils/docker.py b/utils/docker.py new file mode 100644 index 0000000..dc4eb6d --- /dev/null +++ b/utils/docker.py @@ -0,0 +1,15 @@ +import logging +import os + +def docker_build(): + def run(cmd, quiet=True): + r = os.popen(cmd).read() + if not "Build completed!" in r: + logging.error(r) + logging.error("toolchain build failed") + exit(1) + if not quiet: + logging.info(r) + + run(f"docker build . -t middlearch/ci") + run(f"docker run -i --mount type=bind,src=/home/eldeberen/Programmation/Casio/MiddleArch/output,dst=/mnt/output middlearch/ci", quiet=False)