]> Git [git.vados.ru] :: Repos - Mikrotiks/Mikrotiks.git/commitdiff
commit
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Wed, 11 Mar 2026 23:35:13 +0000 (02:35 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Wed, 11 Mar 2026 23:35:13 +0000 (02:35 +0300)
.bak/Makefile [new file with mode: 0644]
.bak/tmp/Makefile [new file with mode: 0644]
.gitignore

diff --git a/.bak/Makefile b/.bak/Makefile
new file mode 100644 (file)
index 0000000..7f1bb20
--- /dev/null
@@ -0,0 +1,86 @@
+# Makefile
+
+MK_PATH:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
+WORKSPACE_LOC:=$(MK_PATH)../../
+
+WorkFiles      := checksums.json AM-GlobalFunc.rsc
+WORK_DIR       := /var/www/ros.vados.ru
+
+DATE            ?= $(shell (date '+%T %d.%m.%Y'))
+DTSTAMP         ?= $(shell (date '+%Y%d%m%H%M%S'))
+VERSION         ?= $(shell git symbolic-ref --short HEAD 2>/dev/null)/$(shell git rev-list --count HEAD 2>/dev/null)/$(shell git rev-parse --short=8 HEAD 2>/dev/null)
+OWNER           ?= $(shell whoami)
+
+#SEDCMD                ?= $(shell sed -e "/^:global CommitId/c :global CommitId \"${COMMITID:-unknown}\";")/$(shell sed )
+
+all: $(WorkFiles)
+
+.PHONY: $(WorkFiles)
+
+checksums.json : ALL_RSC := $(wildcard *.rsc */*.rsc)
+AM-GlobalFunc.rsc : COMMITID   := $(VERSION)
+AM-GlobalFunc.rsc : COMMITINFO := "$(DATE) - Commit owner: $(OWNER)"
+
+ifeq ($@,AM-GlobalFunc.rsc)
+define sed-cmd =
+       cd $(WORK_DIR) && \
+       sed \
+               -e "/^:global CommitId/c :global CommitId \"${COMMITID:-unknown}\";" \
+               -e "/^:global CommitInfo/c :global CommitInfo \"${COMMITINFO:-unknown}\";" \
+               < "./html/${1}"
+       endef
+endif
+
+ifeq ($@,checksums.json)
+       define get-sums =
+       cd $(WORK_DIR)/html && \
+       md5sum $(find -name '*.rsc' | sort) | \
+       sed -e "s| \./||" -e 's|.rsc$||' | \
+       jq --raw-input --null-input '[ inputs | split (" ") | { (.[1]): (.[0]) }] | add' > $@
+       endef
+endif
+
+$(WorkFiles):
+ifeq ($@,checksums.json)
+       $(get-sums) $(ALL_RSC); > $@
+endif
+
+checksums: checksums.json
+           cd $(WORK_DIR)/html
+
+checksums.json: $(WORK_DIR)/bin/checksums.sh $(ALL_RSC)
+       $(WORK_DIR)/bin/checksums.sh > $(WORK_DIR)/html/$@
+
+
+$(FuncFile): ./html/$@
+       $(sed-cmd) $< > $<~
+       mv $<~ $<
+
+#$(WORK_DIR)/html/AM-GlobalFunc.rsc
+#      cd $(WORK_DIR)/html && $(WORK_DIR)/bin/commitinfo.sh $< > $<~
+#      mv $<~ $<
+
+#commitinfo: push
+#      $(WORK_DIR)/bin/$@.sh
+#clean
+
+#checkout: git checkout HEAD .
+
+#push: 
+#      git $@ origin
+
+#ifeq (git,$(firstword $(MAKECMDGOALS)))
+#    # Remaining arguments form the commit string
+#    GIT_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
+#    # ...and turn them into do-nothing targets
+#    $(eval $(GIT_ARGS):;@:)
+#endif
+
+# git function to push to repo
+#git:
+#    git add . && git commit -m "$(GIT_ARGS)" && git push
+
+
+#clean:
+#      rm -f $(HTML) checksums.json
+#      make -C tmpl/ clean
diff --git a/.bak/tmp/Makefile b/.bak/tmp/Makefile
new file mode 100644 (file)
index 0000000..f9aa32a
--- /dev/null
@@ -0,0 +1,149 @@
+# Makefile
+
+BUILD_DIR       = $(shell pwd)
+
+BIN_DIR         = bin
+commitinfo.sh   := $(wildcard bin/commitinfo.sh)
+
+HTML_DIR        = html
+ALL_RSC         := $(wildcard html/*.rsc html/*/*.rsc)
+GLOB_RSC        := $(wildcard html/AM-GlobalFunc.rsc)
+
+DATE            ?= $(shell (date '+%T %d.%m.%Y'))
+DTSTAMP_FMT            ?= "+%Y%m%d%H%M"
+DTSTAMP         ?= $(shell (date $(DTSTAMP_FMT)))
+VERSION         ?= $(shell git symbolic-ref --short HEAD 2>/dev/null)/$(shell git rev-list --count HEAD 2>/dev/null)/$(shell git rev-parse --short=8 HEAD 2>/dev/null)
+RUN_OWNER       := $(shell whoami 2>/dev/null)
+COMM_REPO              := $(shell git rev-parse --show-toplevel | rev | cut -d/ -f1 | rev 2>/dev/nul)
+COMM_BRANCH            := $(shell git symbolic-ref --short HEAD 2>/dev/null)
+
+COMM_TAG := $(shell git rev-list --abbrev-commit --tags --max-count=1)
+# `2>/dev/null` suppress errors and `|| true` suppress the error codes.
+TAG := $(shell git describe --abbrev=0 --tags ${COMM_TAG} 2>/dev/null || true)
+# here we strip the version prefix
+TAG_VERS :=$(TAG:v%=%)
+# get the latest commit hash in the short form
+COMM_HASH := $(shell git rev-parse --short=8 HEAD 2>/dev/null) # Get short commit hash
+#COMMIT := $(shell git rev-parse --short HEAD)
+# get the latest commit date in the form of YYYYmmddHHMM ($(DTSTAMP_FMT))
+COMM_DATE := $(shell git log -1 --format=%cd --date=format:$(DTSTAMP_FMT))
+ifneq ($(COMM_HASH), $(COMM_TAG))
+    TAG_VERS :=$(TAG_VERS)-next-$(COMM_HASH)-$(COMM_DATE)
+endif
+ifeq ($(TAG_VERS), )
+    TAG_VERS :=$(COMM_HASH)-$(COMM_DATE)
+endif
+ifneq ($(shell git status --porcelain), )
+    TAG_VERS :=$(TAG_VERS)-dirty
+endif
+
+COMMIT_ID       := $(VERSION)
+COMM_INFO       := $(shell echo -e "Autocommit in repo: $(COMM_REPO), generated by owner: $(RUN_OWNER), in $(DATE)." 2>/dev/null)
+
+export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO
+
+SHELL := /bin/bash
+
+export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO COMM_DATE
+
+.ONESHELL:
+
+.DEFAULT_GOAL := run
+
+export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO
+
+include $(BUILD_DIR)/.config/config.mk
+
+.PHONY: run check notify checksums commitinfo test
+
+run: check
+       @echo "[run] start main flow"
+       checksums
+       commitinfo
+       @echo "[run] done"
+
+check:
+       @bash bin/check_repo.sh
+
+notify:
+       @bash bin/notify_telegram.sh "manual notify from make"
+
+checksums: checksums.json
+
+checksums.json: bin/checksums.sh $(ALL_RSC)
+       bin/checksums.sh > html/tmp/$@
+
+test:
+       @bash -n bin/check_repo.sh
+       @bash -n bin/notify_telegram.sh
+       @bash -n bin/checksums.sh
+       @bash -n bin/commitinfo.sh
+       @echo "syntax ok"
+
+
+.DEFAULT_GOAL := all
+#.PHONY: all checksums git-check commitinfo clean
+#all: checksums git-check commitinfo
+
+
+gitcheck: $(BUILD_DIR)
+       cd $ && 
+       @if git diff --quiet && git diff --cached --quiet && [ -z "$$(git ls-files --others --exclude-standard)" ]; then \
+               echo "The first checks have been passed, the repo seems to be clean... But... Still, let's check a little more!"; \
+           git add . && \
+               if [[ -n "$$(git status --porcelain)" ]]; then \
+                       echo "Uncommitted changes detected! Commit it..."; \
+#                      git commit -m "$(COMM_INFO)"; \
+#                      git push; \
+           exit 1; \
+               else \
+                       echo "repo clean"; \
+               fi \
+       else \
+               @echo "Warning: Uncommitted changes detected! Go to autocommit steps..."; \
+               git branch -v; \
+#              git commit -am "$(COMM_INFO)"; \
+#              git push; \
+       fi
+
+
+#@if [ -n "$$(git diff --quiet)" ] && [ -n "$$(git diff --cached --quiet)" ] && [ -n "$$(git ls-files --others --exclude-standard)" ]; then \
+#[ -n "$$(git status --porcelain)" ]
+
+check-uncommitted: 
+               @if [ -n "$$(git diff --quiet)" ] && [ -n "$$(git diff --cached --quiet)" ] && [ -n "$$(git ls-files --others --exclude-standard)" ]; then \
+                       echo "Warning: Uncommitted changes detected! Go to autocommit steps..."; \
+               else \
+               echo "The first checks have been passed, the repo seems to be clean... But... Still, let's check a little more!"; \
+                       if git status --porcelain; then \
+                               echo "Repository is clean (no uncommitted or untracked changes). Exit 0."; \
+                               exit 0; \
+                       else \
+                               echo "Error! Git status is not porcelain! Check it mannualy. Exit 1."; \
+                               exit 1; \
+                       fi \
+               fi
+
+
+#    if [[ -n "`$(rungit) status --porcelain`" ]];: then \
+       echo "Warning: Uncommitted changes detected! Go to autocmmit..."; \
+        git commit -m "$(COMM_INFO)"; \
+       git push origin $(COMM_BANCH); \
+    else \
+       echo "Repository is clean (no uncommitted or untracked changes). Exit 0."; \
+       exit 0; \
+    fi
+
+commitinfo: $(commitinfo.sh)
+
+.PHONY: $(commitinfo.sh)
+$(commitinfo.sh): $(GLOB_RSC)
+               $(commitinfo.sh) $< > $<~
+               mv $<~ $<
+
+
+clean:
+               git checkout HEAD -- .
+
+#      rm -f $(HTML) checksums.json
+#      make -C contrib/ clean
index c657a67feb3292d9333427398fbfd7782d0baa87..1cb6ecbc73ddec3c6012baf089a868dba52d7f6d 100644 (file)
@@ -1,6 +1,6 @@
 # folder for backups repo
 backups
-.bak
+#.bak
 # backup and temporary files
 *~
 # patches and related files