diff --git a/Makefile.am b/Makefile.am index cae4c70..6d31126 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,14 @@ SUBDIRS = src +# =========================== +# Caminhos e artefactos +# =========================== +TOP_DIR = $(shell pwd) +DIST_DIR = $(TOP_DIR)/dist +BUILD_DIR = $(TOP_DIR)/build +GIT_VER = $(shell git describe --tags --always --dirty 2>/dev/null || echo "0.1-dev") +SRC_TAR = $(DIST_DIR)/neoricalex-$(GIT_VER)-src.tar.gz + # =========================== # Configurações de Git # =========================== @@ -9,13 +18,6 @@ GIT_REMOTE ?= "origin" GIT_BRANCH ?= "main" COMMIT_MSG ?= "Auto-commit via make git" -# =========================== -# Caminhos e artefactos -# =========================== -DIST_DIR ?= $(top_builddir)/dist -BUILD_DIR ?= $(top_builddir)/build -SRC_TAR ?= $(DIST_DIR)/neoricalex-src.tar.gz - # =========================== # Alvos principais # =========================== @@ -24,7 +26,7 @@ SRC_TAR ?= $(DIST_DIR)/neoricalex-src.tar.gz all: $(DIST_DIR) $(DIST_DIR): - mkdir -p $(DIST_DIR) + @mkdir -p $(DIST_DIR) # =========================== # Empacotamento do código-fonte @@ -32,9 +34,9 @@ $(DIST_DIR): tarball: $(SRC_TAR) $(SRC_TAR): - @echo "[TAR] Empacotando código-fonte..." - mkdir -p $(DIST_DIR) - cd $(top_srcdir) && tar \ + @echo "[TAR] Empacotando código-fonte (versão $(GIT_VER))..." + @mkdir -p "$(DIST_DIR)" "$(BUILD_DIR)" + cd "$(TOP_DIR)" && tar \ --exclude="$(notdir $(SRC_TAR))" \ --exclude="$(DIST_DIR)" \ --exclude="$(BUILD_DIR)" \ @@ -46,7 +48,7 @@ $(SRC_TAR): --exclude='*.o' \ --exclude='*.a' \ --exclude='*.so' \ - -czf $(SRC_TAR) . + -czf "$(SRC_TAR)" . @echo "[✔] Tarball gerado em $(SRC_TAR)" # =========================== @@ -58,27 +60,27 @@ git: check-remote @git config user.email $(GIT_EMAIL) @git rev-parse --abbrev-ref HEAD >/dev/null 2>&1 || true @git add -A - @git commit -m "$$(echo "$(COMMIT_MSG)")" || echo "Nenhuma modificação para commitar." + @git commit -m "$(COMMIT_MSG)" || echo "Nenhuma modificação para commitar." @git push $(GIT_REMOTE) $(GIT_BRANCH) # =========================== -# Release (Tarball) +# Release (Tarball + Tag) # =========================== release: tarball check-remote - @echo "🚀 Publicando build em dist/releases" + @echo "🚀 Publicando build em dist/releases (versão: $(GIT_VER))" @mkdir -p $(DIST_DIR)/releases - @if ls $(DIST_DIR)/neoricalex-*.tar.gz >/dev/null 2>&1; then \ - cp $(DIST_DIR)/neoricalex-*.tar.gz $(DIST_DIR)/releases/; \ - else \ - echo "⚠️ Nenhum tarball encontrado. Execute 'make tarball' primeiro."; \ - fi + @cp $(SRC_TAR) $(DIST_DIR)/releases/ 2>/dev/null || echo "⚠️ Nenhum tarball encontrado. Execute 'make tarball' primeiro." @git add $(DIST_DIR)/releases/ - @git commit -m "Build automático: release $(shell date +%F_%H-%M)" || echo "Nenhum ficheiro novo para commitar." + @git commit -m "Build automático: release $(GIT_VER)" || echo "Nenhum ficheiro novo para commitar." @git push origin main - @TAG="v$(shell date +%Y.%m.%d-%H%M)" && \ - echo "🏷 Criando tag $$TAG" && \ - git tag -a $$TAG -m "Release automática em $$TAG" && \ - git push origin $$TAG || echo "⚠️ Tag já existente ou erro ao criar." + @TAG="$(GIT_VER)"; \ + if git rev-parse "$$TAG" >/dev/null 2>&1; then \ + echo "⚠️ Tag $$TAG já existente."; \ + else \ + echo "🏷 Criando tag $$TAG"; \ + git tag -a "$$TAG" -m "Release automática $$TAG"; \ + git push origin "$$TAG"; \ + fi # =========================== # Git Remote (HTTPS → SSH Auto-Fix) @@ -106,7 +108,6 @@ check-remote: exit 1; \ fi - # =========================== # Teste # =========================== @@ -118,6 +119,6 @@ run: # =========================== clean-local: @echo "[CLEAN] Removendo diretórios temporários..." - rm -rf $(BUILD_DIR) - find $(DIST_DIR) -type f ! -path "$(DIST_DIR)/releases/*" -delete + @rm -rf $(BUILD_DIR) + @find $(DIST_DIR) -maxdepth 1 -type f ! -path "$(DIST_DIR)/releases/*" -delete 2>/dev/null || true @echo "[✔] Limpeza concluída (releases preservadas)" diff --git a/configure.ac b/configure.ac index 932266e..6edabcd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,37 @@ -AC_INIT([NEORICALEX], [0.1], [https://gitea.neoricalex.com/neo/neoricalex.git]) +AC_INIT([NEORICALEX], [NEO_VERSION], [https://gitea.neoricalex.com/neo/neoricalex.git]) + +# =========================== +# Diretórios base +# =========================== +AC_CONFIG_AUX_DIR([.]) +AC_SUBST([TOP_DIR], ['$(CURDIR)']) +AC_SUBST([BUILD_DIR], ['$(CURDIR)/build']) +AC_SUBST([DIST_DIR], ['$(CURDIR)/dist']) + +# =========================== +# Versão dinâmica (Git) +# =========================== +m4_define([NEO_VERSION], + m4_esyscmd_s([git describe --tags --always --dirty 2>/dev/null || echo "0.1-dev"])) +AC_SUBST([NEO_VERSION]) + +# Caminho do tarball dinâmico (protegido contra M4 expansion) +AC_SUBST([SRC_TAR], + ['$(CURDIR)/dist/neoricalex-@NEO_VERSION@-src.tar.gz']) + +# =========================== +# Automake + Python +# =========================== + AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) AM_PATH_PYTHON([3.0]) -# Diretórios base -AC_SUBST([BUILD_DIR], [${abs_top_builddir}/build]) -AC_SUBST([DIST_DIR], [${abs_top_builddir}/dist]) -AC_SUBST([SRC_TAR], [${abs_top_builddir}/dist/neoricalex-${PACKAGE_VERSION}-src.tar.gz]) - +# =========================== +# Arquivos Makefile +# =========================== AC_CONFIG_FILES([ Makefile src/Makefile src/manager/Makefile ]) AC_OUTPUT - diff --git a/dist/releases/neoricalex-b6961cd-dirty-src.tar.gz b/dist/releases/neoricalex-b6961cd-dirty-src.tar.gz new file mode 100644 index 0000000..5d9a53f Binary files /dev/null and b/dist/releases/neoricalex-b6961cd-dirty-src.tar.gz differ diff --git a/src/Makefile.am b/src/Makefile.am index bd5965a..018038e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,11 +4,15 @@ bin_SCRIPTS = neoricalex CLEANFILES = $(bin_SCRIPTS) EXTRA_DIST = neoricalex.in -do_substitution = sed -e 's,[@]pythondir[@],$(pythondir),g' \ - -e 's,[@]PACKAGE[@],$(PACKAGE),g' \ - -e 's,[@]VERSION[@],$(VERSION),g' - +# =========================== +# Substituição dinâmica +# =========================== neoricalex: neoricalex.in Makefile @which git >/dev/null || { echo "⚠️ Git não encontrado — instale-o manualmente."; exit 1; } - $(do_substitution) < $(srcdir)/neoricalex.in > neoricalex + sed \ + -e 's,[@]pythondir[@],$(pythondir),g' \ + -e 's,[@]PACKAGE[@],$(PACKAGE),g' \ + -e 's,[@]VERSION[@],$(VERSION),g' \ + < $(srcdir)/neoricalex.in > neoricalex chmod +x neoricalex + diff --git a/src/manager/Makefile.am b/src/manager/Makefile.am index 6b47378..c27bfc7 100644 --- a/src/manager/Makefile.am +++ b/src/manager/Makefile.am @@ -1,11 +1,19 @@ -# Python sources -neoricalex_PYTHON = \ +# =========================== +# Módulos Python do Manager +# =========================== + +# Diretório de instalação Python +neoricalexdir = $(pythondir) + +# Fontes do manager +dist_neoricalex_PYTHON = \ manager_main.py \ manifest_parser.py \ module_loader.py \ tui_manager.py \ - __init__.py \ - ../bootstrap.py + __init__.py + +# Inclui o bootstrap (nível acima) como parte deste pacote +EXTRA_DIST = ../bootstrap.py -neoricalexdir = $(pythondir) diff --git a/src/neoricalex b/src/neoricalex index 52aa91a..8aaa3a0 100755 --- a/src/neoricalex +++ b/src/neoricalex @@ -6,6 +6,6 @@ sys.path.insert(1, '/usr/local/local/lib/python3.12/dist-packages') from bootstrap import Application if __name__ == "__main__": - app = Application(package="neoricalex", version="0.1") + app = Application(package="neoricalex", version="b6961cd-dirty") app.run()