From dd45f657ae496ab84e4169f8c6c254097607d7a0 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 5 Aug 2025 15:32:25 +0200 Subject: [PATCH] Makefile added with new status and init concept --- Makefile | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ init | 12 +++++++++ pylibs | 2 +- reposinit | 28 -------------------- 4 files changed, 92 insertions(+), 29 deletions(-) create mode 100644 Makefile create mode 100755 init delete mode 100755 reposinit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a9a208a --- /dev/null +++ b/Makefile @@ -0,0 +1,79 @@ +# Version 1.1 (2025-08-05) +default: help + +.ONESHELL: +SHELL = /usr/bin/bash +.SILENT: + +GIT_FLAG = ./.git +VENV_FLAG = ./.venv_required +VENV_FOLDER = ./venv +INIT_FILE = ./init + +help: + echo "Possible options are: init, status, venv_flag, clean, cleanall" + +init: print_head + # Init git repo + if [[ -e $(GIT_FLAG) ]]; then + git submodule init + git submodule update + fi + # Create venv if needed + if [[ -e $(VENV_FLAG) ]]; then + if [[ ! -e $(VENV_FOLDER) ]]; then + mkvenv + fi + fi + if [[ -x $(INIT_FILE) ]]; then + $(INIT_FILE) + fi + +initall: + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) init + done + +status: print_head + giti + echo "Submodules:" + echo "-----------" + git submodule --quiet foreach giti + +statusall: + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) status + done + +clean: + if [[ ! -e $(VENV_FLAG) ]]; then + if [[ -d $(VENV_FOLDER) ]]; then + rm -rf $(VENV_FOLDER) + fi + fi + +cleanall: clean + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall + done + + +venv_flag: + if [[ ! -e $(VENV_FLAG) ]]; then + touch $(VENV_FLAG) + if [[ -e $(GIT_FLAG) ]]; then + git add $(VENV_FLAG) + fi + fi + +print_head: + DIRNAME=$$(basename $$(pwd)) + DIRLENGTH=$${#DIRNAME} + echo -ne "\n\n\033[1;34m╔═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╗" + echo -e "║ $$DIRNAME ║" + echo -ne "╚═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╝\033[00m" + diff --git a/init b/init new file mode 100755 index 0000000..45090da --- /dev/null +++ b/init @@ -0,0 +1,12 @@ +#!/bin/bash +# +echo "* Linking pylibs to venv" +for path in `find pylibs/ -maxdepth 1 -type d`; do + if [[ $path != "pylibs/" ]];then + lib=${path#*/} + echo Creating symbolic link for library $lib + rm -f venv/lib/python*/site-packages/$lib + ln -s ../../../../$path venv/lib/python*/site-packages/ + fi +done + diff --git a/pylibs b/pylibs index b5a1574..b38e3fd 160000 --- a/pylibs +++ b/pylibs @@ -1 +1 @@ -Subproject commit b5a1574560194abe1c7cb8fb213747461e1553c5 +Subproject commit b38e3fd01559286eb5241d952ba9035f09955957 diff --git a/reposinit b/reposinit deleted file mode 100755 index 05ff823..0000000 --- a/reposinit +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -echo "* Initialising Submodules" -git submodule init -git submodule update -pushd pylibs -git submodule init -git submodule update -popd - -echo "* Creating virtual env" -BASEPATH=`realpath $(dirname $0)` - -python3 -m venv $BASEPATH/venv -$BASEPATH/venv/bin/pip install --upgrade pip -find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r -$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U - -echo "* Linking pylibs to venv" -for path in `find pylibs/ -maxdepth 1 -type d`; do - if [[ $path != "pylibs/" ]];then - lib=${path#*/} - echo Creating symbolic link for library $lib - rm -f venv/lib/python*/site-packages/$lib - ln -s ../../../../$path venv/lib/python*/site-packages/ - fi -done -