#!/usr/bin/make -f # Usage: first run # # umask 002 && # ./update-website.mk WWW_WC="" svn-checkout # # to create an initial repository on WWW_WC, if it does not exist yet. To # update the website manually (usually this will be done by a post-commit hook # script) run # # cd "" && # umask 002 && # ./scripts/update-website.mk svn-update update-website # SVN = svn://svn.linuxfromscratch.org REV = HEAD # Website working copy location # Note: the working copy below should not be manipulated directly! # Assuming we are already on WWW_WC WWW_WC = $(PWD) # Website location (defined on the Subversion hook script) #TARGETDIR = /home/httpd/test.linuxfromscratch.org SCRIPTS = $(WWW_WC)/scripts # "LC_ALL=C" garantees a sane localization setting MANAGE_NEWS = LC_ALL=C $(SCRIPTS)/manage_news.pl SVN2HTML = $(SCRIPTS)/svn2html.pl SVN2HTML2 = $(SCRIPTS)/svn2html2.pl SVNLOG = svn log --verbose --xml TEMPLATES = templates # TODO This can be automated # Projects which have news to be archived PROJECTS = . lfs alfs blfs hints hlfs # Years corresponding to the news-YYYY.txt files YEARS = 2003 2004 2005 # Current year YEAR = $(shell date +%Y) update-website: update-alfs update-blfs update-hints update-hlfs \ update-lfs update-patches update-www news-archive: $(foreach y, $(YEARS), \ $(foreach i, $(PROJECTS), $(if $(wildcard $(i)/news-$(y).txt), news/$(i)/$(y)))) news-html: alfs/news.html blfs/news.html hints/news.html hlfs/news.html \ lfs/news.html patches/news.html news-rss: alfs/feed.rss blfs/feed.rss hlfs/feed.rss lfs/feed.rss backup: tar -cPf /var/tmp/website-backup.tar $(WWW_WC) # Useful for the initial repository setup svn-checkout: # The setgid bit on dirs forces all files under it to have the same group of # WWW_WC install -g lfswww -m 2775 -d $(WWW_WC) svn -q checkout $(SVN)/www/html/trunk $(WWW_WC) mkdir -p $(WWW_WC)/patches/downloads svn -q checkout $(SVN)/patches/trunk $(WWW_WC)/patches/downloads mkdir -p $(WWW_WC)/hints/downloads/files svn -q checkout $(SVN)/hints/trunk $(WWW_WC)/hints/downloads/files ln -s files/ATTACHMENTS $(WWW_WC)/hints/downloads/attachments # Add some compatibility symlinks ln -s lfs/view $(WWW_WC) ln -s images/favicon.ico $(WWW_WC) ln -s 2columns.css $(WWW_WC)/style/screen.css svn-update: svn -q update $(WWW_WC) -r $(REV) # Generate news archives define gen_news_targets news/$(1)/$(2): $(1)/news-$(2).txt $(TEMPLATES)/$(1)/archive-*.html rm -rf $$@ $(MANAGE_NEWS) -a news/ -i $(1)/news-$(2).txt \ -t $(TEMPLATES)/$(1)/archive-top.html -b $(TEMPLATES)/$(1)/archive-bottom.html endef $(foreach y,$(YEARS),$(foreach i,$(PROJECTS),$(eval $(call gen_news_targets,$(i),$(y))))) svnlog-%: mkdir -p logs $(SVNLOG) $(SVN)/$* 2>/dev/null | $(SVN2HTML) --with-branchname > logs/$*.html.tmp cmp -s logs/$*.html.tmp logs/$*.html || cp logs/$*.html.tmp logs/$*.html rm logs/$*.html.tmp svnlog2-%: mkdir -p logs $(SVN2HTML2) --project $* --with-branchname > logs/$*.html.tmp cmp -s logs/$*.html.tmp logs/$*.html || cp logs/$*.html.tmp logs/$*.html rm logs/$*.html.tmp logs/%.html: touch $@ alfs/news.html: $(TEMPLATES)/alfs/news-*.html news-$(YEAR).txt alfs/news-$(YEAR).txt logs/ALFS.html cat $(TEMPLATES)/alfs/news-top.html > alfs/news.html $(MANAGE_NEWS) -i alfs/news-$(YEAR).txt >> alfs/news.html $(MANAGE_NEWS) -i news-$(YEAR).txt >> alfs/news.html cat logs/ALFS.html \ $(TEMPLATES)/alfs/news-bottom.html >> alfs/news.html blfs/news.html: $(TEMPLATES)/blfs/news-*.html news-$(YEAR).txt blfs/news-$(YEAR).txt logs/BLFS.html cat $(TEMPLATES)/blfs/news-top.html > blfs/news.html $(MANAGE_NEWS) -i blfs/news-$(YEAR).txt >> blfs/news.html $(MANAGE_NEWS) -i news-$(YEAR).txt >> blfs/news.html cat logs/BLFS.html \ $(TEMPLATES)/blfs/news-bottom.html >> blfs/news.html hints/news.html: $(TEMPLATES)/hints/news-*.html logs/hints.html cat $(TEMPLATES)/hints/news-top.html \ logs/hints.html \ $(TEMPLATES)/hints/news-bottom.html > hints/news.html hlfs/news.html: $(TEMPLATES)/hlfs/news-*.html news-$(YEAR).txt hlfs/news-$(YEAR).txt logs/HLFS.html cat $(TEMPLATES)/hlfs/news-top.html > hlfs/news.html $(MANAGE_NEWS) -i hlfs/news-$(YEAR).txt >> hlfs/news.html $(MANAGE_NEWS) -i news-$(YEAR).txt >> hlfs/news.html cat logs/HLFS.html \ $(TEMPLATES)/hlfs/news-bottom.html >> hlfs/news.html lfs/news.html: $(TEMPLATES)/lfs/news-*.html news-$(YEAR).txt lfs/news-$(YEAR).txt logs/LFS.html cat $(TEMPLATES)/lfs/news-top.html > lfs/news.html $(MANAGE_NEWS) -i lfs/news-$(YEAR).txt >> lfs/news.html $(MANAGE_NEWS) -i news-$(YEAR).txt >> lfs/news.html cat logs/LFS.html \ $(TEMPLATES)/lfs/news-bottom.html >> lfs/news.html patches/news.html: $(TEMPLATES)/patches/news-*.html logs/patches.html cat $(TEMPLATES)/patches/news-top.html \ logs/patches.html \ $(TEMPLATES)/patches/news-bottom.html > patches/news.html website.html: $(TEMPLATES)/website-*.html logs/www.html cat $(TEMPLATES)/website-top.html \ logs/www.html \ $(TEMPLATES)/website-bottom.html > website.html # Generate RSS feeds %/feed.rss: %/news.html $(SCRIPTS)/lfs2rss.pl -n $< -r $@ # Create mirrors list for each section PROJS = alfs hlfs blfs hints lfs patches INDEXES = $(foreach i,$(PROJS),$(i)/index.html) mirrors-list: index.html $(INDEXES) index.html: mirrorlist.html $(TEMPLATES)/index-*.html cat $(TEMPLATES)/index-top.html \ mirrorlist.html \ $(TEMPLATES)/index-bottom.html > index.html $(INDEXES): mirrorlist.html $(foreach i,$(PROJS),$(TEMPLATES)/$(i)/index-*.html) for i in $(PROJS); do \ cat $(TEMPLATES)/$$i/index-top.html > $$i/index.html; \ sed "s@/lfs/news.html@/$$i/news.html@g" mirrorlist.html >> $$i/index.html; \ cat $(TEMPLATES)/$$i/index-bottom.html >> $$i/index.html; done ########################################### # Update project-specific website sections # # TODO: These rules should be run by each project's post-commit script or by # cron jobs update-alfs: svnlog2-ALFS alfs/news.html update-blfs: svnlog-BLFS blfs/news.html update-hints: svnlog-hints hints/news.html fetch-hints hints-tarball \ hints-symlinks hints-list update-hlfs: svnlog-HLFS hlfs/news.html update-lfs: svnlog-LFS lfs/news.html update-patches: svnlog-patches patches/news.html svn -q update patches/downloads update-www: svnlog-www website.html news-archive news-html news-rss \ mirrors-list error-pages # Add the timestamp for mirrors update-timestamp: mkdir -p timestamp date +%s > timestamp/timestamp fetch-hints: find hints/downloads -type l -exec rm '{}' \; svn -q update hints/downloads/files hints-tarball: ln -s files hints/downloads/hints cd hints/downloads && tar --exclude=.svn -chjf hints.tar.bz2 hints/ rm hints/downloads/hints hints-symlinks: cd hints/downloads/files && \ if [ -d HOLD ]; then for i in $$(ls HOLD/*.txt); do ln -s $$i; done; fi cd hints/downloads/files && \ for i in $$(ls PREVIOUS_FORMAT/*.txt); do ln -s $$i; done hints-list: cd hints && $(SCRIPTS)/genlist.sh # Validate XHTML files # FIXME: better on a pre-commit script? validate: test -n "$(TARGETDIR)" cd $(TARGETDIR) && \ find -name \*.html -maxdepth 3 | while read file; do \ xmllint --valid --noout $$file || exit 1; done # Copy these to the httpd error dirs error-pages: 403.html 404.html cp 40{3,4}.html /home/httpd/error # Copy website content to its final location run-rsync: test -n "$(TARGETDIR)" @echo @echo "*** The following rsync command may fail to setup permissions if the" @echo "*** caller is not owner of the file(s). This error can be ignored." @echo rsync -av --delete --exclude-from=scripts/rsync-ignore . $(TARGETDIR)/ || true