From 14362f616538e11e2928ecfe68d325e5a939b8fc Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Fri, 30 Sep 2022 15:48:27 +0800 Subject: [PATCH] gen-makefile is back --- gen-makefile | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 gen-makefile diff --git a/gen-makefile b/gen-makefile new file mode 100755 index 0000000..163f333 --- /dev/null +++ b/gen-makefile @@ -0,0 +1,92 @@ +#!/bin/bash +mv Makefile Makefile.bak +CHR_UPGRADE='^' +CHR_UNINSTALL='/' + +cat << EOF >> Makefile +# Autogenerated at $(date +'%d.%m.%Y %H:%M') using ${BASH_SOURCE[0]} +.DEFAULT_GOAL := help + +#=============================================== +# Scripts listed in ./packs +#=============================================== + +EOF + +for file in ./packs/*; do + cat "$file" >> Makefile + echo >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Scripts listed in ./install +#=============================================== + +EOF + +for file in ./install/*; do + name=${file##*/} + name=${name%.sh} + desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file}) + [ -z "$desc" ] && desc='' + echo -e "# ${desc}\n${name}:\n\t@${file}\n" >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Scripts listed in ./upgrade +#=============================================== + +EOF + +for file in ./upgrade/*; do + name=${file##*/} + name=${name%.sh} + desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file}) + [ -z "$desc" ] && desc='' + echo -e "# ${desc}\n${CHR_UPGRADE}${name}:\n\t@${file}\n" >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Scripts listed in ./uninstall +#=============================================== + +EOF + +for file in ./uninstall/*; do + name=${file##*/} + name=${name%.sh} + desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file}) + [ -z "$desc" ] && desc='' + echo -e "# ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Service goals +#=============================================== + +self: + @./gen-makefile + +help: Makefile + @echo "Ubuntu software installator" + @echo + @echo "Usage:\n \ + make help|- show this help\n \ + make self|- regenerate Makefile (alias of ./gen-makefile)\n \ + make GOAL|- install software\n \ + make ${CHR_UPGRADE}GOAL|- upgrade software\n \ + make ${CHR_UNINSTALL}GOAL|- uninstall software" | column -ts '|' + @echo "\nYou can combine GOALs, here are some examples:" + @echo "\tmake @docker docker" + @echo "\tmake php @docker ^omz" + @echo "\nAvailable GOALs:" + @sed -n '/^#/{N;s/# *\(.*\)\n\([^# .].*:\)/\t\2\1/p}' $< | column -ts ':' +EOF + +echo "New ./Makefile has been generated!" +echo "Old one has been saved as ./Makefile.bak" +echo "Now run 'make' to get help"