Makefile generation improved

This commit is contained in:
Anthony Axenov 2022-08-26 08:25:55 +08:00
parent c1150af922
commit 8ffc2dfe32
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
5 changed files with 86 additions and 42 deletions

View File

@ -1,4 +1,4 @@
# Autogenerated at 25.08.2022 22:32 using ./gen-makefile
# Autogenerated at 26.08.2022 08:21 using ./gen-makefile
.DEFAULT_GOAL := help
#===============================================
@ -159,6 +159,29 @@ zint:
zsh:
@./install/zsh
#===============================================
# Scripts listed in ./upgrade
#===============================================
# Upgrade omz
^omz:
@./upgrade/omz
#===============================================
# Scripts listed in ./uninstall
#===============================================
# Uninstall docker
/docker:
@./uninstall/docker
# Uninstall omz
/omz:
@./uninstall/omz
#===============================================
# Service goals
#===============================================
self:
@./gen-makefile
@ -166,20 +189,9 @@ self:
help: Makefile
@echo "Ubuntu software installator"
@echo
@echo "Usage:"
@echo "\tmake help\t - Show this help"
@echo "\tmake self\t - Regenerate Makefile (alias of ./gen-makefile)"
@echo "\tmake GOAL\t - Install software"
@echo "\tmake ^GOAL\t - Upgrade software"
@echo "\tmake @GOAL\t - Uninstall software"
@echo
@echo "You can combine GOALs, e.g. 'make @docker docker' will reinstall docker."
@echo
@echo "Available GOALs:"
@echo "Usage:\n make help|- show this help\n make self|- regenerate Makefile (alias of ./gen-makefile)\n make GOAL|- install software\n make ^GOAL|- upgrade software\n make /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 ':'
+%:
@$(MAKE) $*
^%:
@./upgrade/$*
@%:
@./uninstall/$*

View File

@ -43,16 +43,20 @@ wget -qO - https://git.axenov.dev/anthony/my-env/raw/branch/master/install/apt |
./install/apt
```
## How to add a new software script?
## How to add my script?
1. Create new `./install/*` script.
1. Create a new shell script in `./install`, `./upgrade` or `./uninstall` directory.
At the beggining of a file you must write these two lines:
```shell
#!/bin/bash
##makedesc: Your description for Makefile
```
2. Test your script
3. Run `./gen-makefile` to generate new `./Makefile`
2. Make this script executable, e.g.:
```shell
sudo chmod a+x ./install/myscript
```
3. Test your script
4. Run `make self` to generate new `./Makefile`
## How to create packs?

View File

@ -1,5 +1,7 @@
#!/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]}
@ -31,7 +33,40 @@ for file in ./install/*; do
echo -e "# ${desc}\n${name}:\n\t@${file}\n" >> Makefile
done;
cat << "EOF" >> Makefile
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='<no description>'
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='<no description>'
echo -e "# ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile
done;
cat << EOF >> Makefile
#===============================================
# Service goals
#===============================================
self:
@./gen-makefile
@ -39,26 +74,19 @@ self:
help: Makefile
@echo "Ubuntu software installator"
@echo
@echo "Usage:"
@echo "\tmake help\t - Show this help"
@echo "\tmake self\t - Regenerate Makefile (alias of ./gen-makefile)"
@echo "\tmake GOAL\t - Install software"
@echo "\tmake ^GOAL\t - Upgrade software"
@echo "\tmake @GOAL\t - Uninstall software"
@echo
@echo "You can combine GOALs, e.g. 'make @docker docker' will reinstall docker."
@echo
@echo "Available GOALs:"
@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 ':'
+%:
@$(MAKE) $*
^%:
@./upgrade/$*
@%:
@./uninstall/$*
EOF
echo "New ./Makefile has been generated!"
echo "Old one has been saved as ./Makefile.bak"
echo
make
echo "Now run 'make' to get help"

View File

@ -1,5 +1,5 @@
#!/bin/bash
##makedesc: Uninstalling omz
##makedesc: Uninstall omz
echo
echo "==============================================="

View File

@ -1,5 +1,5 @@
#!/bin/bash
##makedesc: Upgrading omz
##makedesc: Upgrade omz
echo
echo "==============================================="