From fb4ea3fb1dfe5f90a35936cb132135f9835ab37d Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Sat, 9 Sep 2023 08:20:48 +0200 Subject: [PATCH] Reorder features based on Makefile --- Makefile | 60 ++++++++++++++++++++++++++++++++++++++++++ build/genFeatures.sh | 8 +++--- build/updateCVElist.pl | 4 +-- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..365da2b --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +VERSION=$(shell grep '\- Version ' mysqltuner.pl | awk '{ print $$NF}') +UPDATE_SUB_VERSION=$(shell echo $(VERSION) | awk -F. '{ print $$1"."$$2"."$$3+1 }') +UPDATE_MINOR_VERSION=$(shell echo $(VERSION) | awk -F. '{ print $$1"."$$2+1".0" }') +UPDATE_MAJOR_VERSION=$(shell echo $(VERSION) | awk -F. '{ print $$1+1".0.0" }') + +all: generate_cve generate_features generate_usage tidy increment_sub_version + +help: + @echo "Usage: make " + @echo " help: Show this help" + @echo " generate_usage: Generate USAGE.md" + @echo " generate_cve: Generate vulnerabilities.csv" + @echo " generate_features: Generate FEATURES.md" + @echo " tidy: Tidy mysqltuner.pl" + @echo " installdep_debian: Install dependencies on Debian" + @echo " increment_sub_version: Increment sub version" + @echo " increment_minor_version: Increment minor version" + @echo " increment_major_version: Increment major version" + @echo " push: Push to GitHub" + + +installdep_debian: + apt install -y cpanminus libpod-markdown-perl libwww-mechanize-gzip-perl perltidy dos2unix + cpanm File::Util + +tidy: + dos2unix ./mysqltuner.pl + perltidy -b ./mysqltuner.pl +# git add ./mysqltuner.pl +# git commit -m "Indenting mysqltuner at $(shell date --iso=seconds)" + +generate_usage: + pod2markdown mysqltuner.pl >USAGE.md +# git add ./USAGE.md +# git commit -m "Generate USAGE.md at $(shell date --iso=seconds)" + +generate_cve: + perl ./build/updateCVElist.pl +# git add ./vulnerabilities.csv +# git commit -m "Generate CVE list at $(shell date --iso=seconds)" + +generate_features: + perl ./build/genFeatures.sh +# git add ./FEATURES.md +# git commit -m "Generate FEATURES.md at $(shell date --iso=seconds)" + +increment_sub_version: + @echo "Incrementing sub version from $(VERSION) to $(UPDATE_SUB_VERSION)" + sed -i "s/$(VERSION)/$(UPDATE_SUB_VERSION)/" mysqltuner.pl *.md + +increment_minor_version: + @echo "Incrementing minor version from $(VERSION) to $(UPDATE_MINOR_VERSION)" + sed -i "s/$(VERSION)/$(UPDATE_MINOR_VERSION)/" mysqltuner.pl *.md + +increment_major_version: + @echo "Incrementing major version from $(VERSION) to $(UPDATE_MAJOR_VERSION)" + sed -i "s/$(VERSION)/$(UPDATE_MAJOR_VERSION)/" mysqltuner.pl *.md + +push: + git push \ No newline at end of file diff --git a/build/genFeatures.sh b/build/genFeatures.sh index 3736fcf..17fdeca 100644 --- a/build/genFeatures.sh +++ b/build/genFeatures.sh @@ -4,10 +4,10 @@ ( export LANG=C echo -e "Features list for option: --feature (dev only)\n---\n\n" - grep -E '^sub ' ../mysqltuner.pl | \ + grep -E '^sub ' ./mysqltuner.pl | \ perl -pe 's/sub //;s/\s*\{//g' | \ sort -n | \ perl -pe 's/^/* /g' | \ - grep -vE '(get_|close_|check_|memerror|human_size|string2file|file2|arr2|dump|which|percentage|trim|is_|hr_|info|print|select|wrap|remove_)' -) > ../FEATURES.md -cat ../FEATURES.md + grep -vE '(get_|close_|check_|memerror|cpu_cores|compare_tuner_version|grep_file_contents|update_tuner_version|mysql_version_|calculations|merge_hash|os_setup|pretty_uptime|update_tuner_version|human_size|string2file|file2|arr2|dump|which|percentage|trim|is_|hr_|info|print|select|wrap|remove_)' +) > ./FEATURES.md +cat ./FEATURES.md diff --git a/build/updateCVElist.pl b/build/updateCVElist.pl index 5369e45..7c8203d 100644 --- a/build/updateCVElist.pl +++ b/build/updateCVElist.pl @@ -49,7 +49,7 @@ File::Util->flock_rules( qw/ IGNORE/ ); my @versions; my $temp; -unlink '../vulnerabilities.csv' if -f '../vulnerabilities.csv'; +unlink './vulnerabilities.csv' if -f './vulnerabilities.csv'; open(CVE, 'cve.csv') or die("Could not open file."); foreach my $line () { if ($line =~ /(mysql|mariadb|percona)/i @@ -69,7 +69,7 @@ foreach my $line () { #print $vers."\n".Dumper @nb; #print "$line"; #exit 0 if ($line =~/before/i) ; - $f->write_file('file' => '../vulnerabilities.csv', 'content' => "$nb[0].$nb[1].$nb[2];$nb[0];$nb[1];$nb[2];$line", 'mode' => 'append'); + $f->write_file('file' => './vulnerabilities.csv', 'content' => "$nb[0].$nb[1].$nb[2];$nb[0];$nb[1];$nb[2];$line", 'mode' => 'append'); } } }