doc: Before fetching, drop all old to cleanup deleted pages/images

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2020-09-14 23:28:53 -07:00 committed by James Valleroy
parent e421e0fde9
commit 514a04d643
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -60,13 +60,21 @@ install: all
# require further reviews.
fetch-main-list:=$(foreach lang,$(MANUAL_LANGUAGES),fetch-main-$(lang))
fetch-pages-list:=$(foreach lang,$(MANUAL_LANGUAGES),fetch-pages-$(lang))
fetch-cleanup-list:=$(foreach lang,$(MANUAL_LANGUAGES),fetch-cleanup-$(lang))
.PHONY: fetch $(fetch-main-list) $(fetch-pages-list)
.PHONY: fetch $(fetch-main-list) $(fetch-pages-list) $(fetch-cleanup-list)
fetch: $(fetch-main-list) $(fetch-pages-list)
# Remove raw wiki pages and images before fetching to drop items deleted
# upstream.
featch-cleanup-%: lang = $*
$(fetch-cleanup-list): fetch-cleanup-%:
rm -f manual/$(lang)/*.raw.wiki
rm -f manual/$(lang)/images/*.png manual/$(lang)/images/*.jpg
fetch-main-%: lang = $*
fetch-main-%: lang-fragment = $(subst en/,,$*/)
$(fetch-main-list): fetch-main-%:
$(fetch-main-list): fetch-main-%: fetch-cleanup-%
MANUAL_URL_RAW_LANG=$(subst {lang-fragment},$(lang-fragment),$(MANUAL_URL_RAW)) ; \
wget --quiet --user-agent=Firefox \
-O manual/$(lang)/freedombox-manual.raw.wiki $${MANUAL_URL_RAW_LANG}
@ -82,7 +90,7 @@ $(fetch-main-list): fetch-main-%:
fetch-pages-%: lang = $*
fetch-pages-%: lang-fragment = $(subst en/,,$*/)
$(fetch-pages-list): fetch-pages-%:
$(fetch-pages-list): fetch-pages-%: fetch-cleanup-%
MANUAL_URL_LANG=$(subst {lang-fragment},$(lang-fragment),$(MANUAL_URL_RAW)) ; \
PAGES=$$(wget --quiet --user-agent=Firefox -O - $${MANUAL_URL_LANG} | \
sed -n -e "s|.*<<Include(\([a-zA-Z0-9_/+-]*\),.*|\1|p" | sort -u) ; \