From d04895e00befc10fb3cf6ff6cf3ca0e411623e00 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 12:44:11 +0200 Subject: [PATCH 1/6] grammar --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f10ddc..7d1129b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ttrpg-fortunes -A collection of fortunes regarding tabletop rpgs and adjacent topics -This is supposed to be a collection of adages, jokes, stories, DM Aid, and observations regarding tabletop roleplaying games. +A collection of fortunes regarding tabletop rpgs and adjacent topics. +This is supposed to be a collection of adages, jokes, stories, DM aids, and observations regarding tabletop roleplaying games. It likely should be split into multiple sections when it gets large enough. -Collection of quotes happens on the wiki: https://campaignwiki.org/wiki/TTRPGFortuneFile/HomePage \ No newline at end of file +Collection of quotes happens on the wiki: https://campaignwiki.org/wiki/TTRPGFortuneFile/HomePage From cfbae34f3b65be6bd828f7a1bf9bab9ebebc413e Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 13:43:55 +0200 Subject: [PATCH 2/6] makin' make-files! --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4ac7db2 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +fortune_directory = /usr/share/fortune + +dat_files = $(wildcard *.dat) + +fortune_files = $(patsubst %.dat, %, $(dat_files)) +fortune_files += $(dat_files) + +targets = $(patsubst %, $(fortune_directory)/%, $(fortune_files)) + +$(targets): $(fortune_directory)/%: % + install -pm644 $< $@ + +.PHONY: install +install: $(targets) + +clean: + $(RM) $(wildcard $(targets)) From 25cc3dd7285e767b32eb105591e2f2e0d75f3ce6 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 13:44:30 +0200 Subject: [PATCH 3/6] make comments --- Makefile | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4ac7db2..a351e93 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,38 @@ +########## Variables ########## + fortune_directory = /usr/share/fortune +# This just equals 'ttrpg.dat', but if someone wants to split it into separate +# files, e.g. 'D20.dat' and 'WW.dat', the they would be included. + dat_files = $(wildcard *.dat) +# Each .dat file has a corresponding fortune file to be included. This +# apparently convoluted mess is just here to select fortune files, and not the +# Makefile and README. fortune_files = $(patsubst %.dat, %, $(dat_files)) fortune_files += $(dat_files) +# `patsubst` = 'path substitution', so +# 'ttrpg' --> /usr/share/fortune/ttrpg +# Now `make` knows (at long last) what you want installed. targets = $(patsubst %, $(fortune_directory)/%, $(fortune_files)) -$(targets): $(fortune_directory)/%: % - install -pm644 $< $@ +########## Rules ########## .PHONY: install install: $(targets) +# Ignore the `$(targets): ` section; the rule is about how to make +# /usr/share/fortune/[that] from [this]. +# The next linen says you just install this (`$<`) from that (`$@`). +# We use `install` rather than the more familiar `cp`, because cause back in the +# days of Unix-yore, Xenox had a patent on the concept of a copy and +# Mathematicians had to do their own legal work as international law hadn't been +# established. Now I'd like to digress from my prepared remarks to discuss how +# I invented the terlet... +$(targets): $(fortune_directory)/%: % + install -pm644 $< $@ + clean: $(RM) $(wildcard $(targets)) From 980063f8032966ac705f39c6b3d8a6659d8e1a5b Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 13:48:35 +0200 Subject: [PATCH 4/6] rename clean uninstall --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a351e93..dcda37c 100644 --- a/Makefile +++ b/Makefile @@ -34,5 +34,5 @@ install: $(targets) $(targets): $(fortune_directory)/%: % install -pm644 $< $@ -clean: +uninstall: $(RM) $(wildcard $(targets)) From b0aea6b533e909bdf6cdeb2ce648de70104f4e34 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 13:58:21 +0200 Subject: [PATCH 5/6] use local fortunes directory This stops interference with package managers, who never respond kindly to outside interference. --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index dcda37c..7fab25f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ########## Variables ########## -fortune_directory = /usr/share/fortune +fortune_directory = /usr/local/share/fortune # This just equals 'ttrpg.dat', but if someone wants to split it into separate # files, e.g. 'D20.dat' and 'WW.dat', the they would be included. @@ -31,8 +31,12 @@ install: $(targets) # Mathematicians had to do their own legal work as international law hadn't been # established. Now I'd like to digress from my prepared remarks to discuss how # I invented the terlet... -$(targets): $(fortune_directory)/%: % +$(targets): $(fortune_directory)/%: % | $(fortune_directory) install -pm644 $< $@ +$(fortune_directory): + mkdir $@ + uninstall: - $(RM) $(wildcard $(targets)) + $(RM) $(targets) + ! test -d $(fortune_directory) || rmdir --ignore-fail-on-non-empty $(fortune_directory) From 4e2849377a22b325190c9febf87ec64919dbd41d Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 14 Apr 2025 14:55:11 +0200 Subject: [PATCH 6/6] refactor for automatic .dat files Now `make` makes .dat files on the fly, so they're never out of sync with the base-file. Also, /usr/local has been abandoned as it does not work with fortune. --- Makefile | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 7fab25f..99b6f68 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,24 @@ ########## Variables ########## -fortune_directory = /usr/local/share/fortune +fortune_directory = /usr/share/fortune -# This just equals 'ttrpg.dat', but if someone wants to split it into separate -# files, e.g. 'D20.dat' and 'WW.dat', the they would be included. +cookies = $(wildcard ttrpg*) -dat_files = $(wildcard *.dat) +target_cookies = $(patsubst %, $(fortune_directory)/%, $(cookies)) +target_dats = $(patsubst %, $(fortune_directory)/%.dat, $(cookies)) -# Each .dat file has a corresponding fortune file to be included. This -# apparently convoluted mess is just here to select fortune files, and not the -# Makefile and README. -fortune_files = $(patsubst %.dat, %, $(dat_files)) -fortune_files += $(dat_files) - -# `patsubst` = 'path substitution', so -# 'ttrpg' --> /usr/share/fortune/ttrpg -# Now `make` knows (at long last) what you want installed. -targets = $(patsubst %, $(fortune_directory)/%, $(fortune_files)) +targets = $(target_cookies) $(target_dats) ########## Rules ########## .PHONY: install install: $(targets) -# Ignore the `$(targets): ` section; the rule is about how to make -# /usr/share/fortune/[that] from [this]. -# The next linen says you just install this (`$<`) from that (`$@`). -# We use `install` rather than the more familiar `cp`, because cause back in the -# days of Unix-yore, Xenox had a patent on the concept of a copy and -# Mathematicians had to do their own legal work as international law hadn't been -# established. Now I'd like to digress from my prepared remarks to discuss how -# I invented the terlet... -$(targets): $(fortune_directory)/%: % | $(fortune_directory) +$(target_cookies): $(fortune_directory)/%: % install -pm644 $< $@ -$(fortune_directory): - mkdir $@ +$(target_dats): $(fortune_directory)/%.dat: % + strfile $< $@ uninstall: - $(RM) $(targets) - ! test -d $(fortune_directory) || rmdir --ignore-fail-on-non-empty $(fortune_directory) + $(RM) $(wildcard $(targets))