merged
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 15 Jan 2012 20:25:32 +0200
changeset 131 1bcce07aabf5
parent 130 7c6fc5f06884 (current diff)
parent 128 ca6ceff4941c (diff)
child 132 236e638526a5
merged
--- a/.hgignore	Sun Jan 15 20:25:15 2012 +0200
+++ b/.hgignore	Sun Jan 15 20:25:32 2012 +0200
@@ -1,6 +1,7 @@
 syntax: glob
 
 VERSION*
+STAT.rst
 *.dict
 *.dict.dz
 *.index
--- a/CHANGES.rst	Sun Jan 15 20:25:15 2012 +0200
+++ b/CHANGES.rst	Sun Jan 15 20:25:32 2012 +0200
@@ -9,6 +9,11 @@
 
 .. include:: VERSION.rst
 
+tag:t0.2, 2012-01-xx.
+=====================
+
+ * Add target for checks of release sanity.
+
 tag:t0.1, 2012-01-12.
 =====================
 
--- a/Makefile	Sun Jan 15 20:25:15 2012 +0200
+++ b/Makefile	Sun Jan 15 20:25:32 2012 +0200
@@ -54,12 +54,25 @@
 -include VERSION
 
 VERSION:
-	ver=$$(hg log -r . --template '{latesttag}'); \
-ver=$${ver#t}; \
-major=$${ver%.*}; \
-minor=$${ver#*.}; \
-printf "vmajor=%s\nvminor=%s\n" $$major $$minor >VERSION
-	# is_release=`hg log --template '{latesttagdistance}'`
+	\
+vtagdist=$$(hg log -r . --template '{latesttagdistance}'); \
+vatrelease=$$([ $$vtagdist = 0 ] && echo yes || echo no); \
+vtag=$$(hg log -r . --template '{latesttag}'); \
+vmajor=$${vtag#t}; \
+vmajor=$${vmajor%.*}; \
+vminor=$${vtag#*.}; \
+vrev=$$(hg id -i); \
+visclean=$$(case $$vrev in *+) echo no;; *) echo yes;; esac); \
+vrev=$${vrev%+}; \
+{ \
+echo "vrev=$$vrev"; \
+echo "vtag=$$vtag"; \
+echo "vtagdist=$$vtagdist"; \
+echo "visclean=$$visclean"; \
+echo "vatrelease=$$vatrelease"; \
+echo "vmajor=$$vmajor"; \
+echo "vminor=$$vminor"; \
+} >VERSION
 
 ################################################################
 # Determine platform/environment.
@@ -151,7 +164,7 @@
 
 # Will be accessed via http://$(pkgname).sourceforge.net
 .PHONY: deploy2sf-doc
-deploy2sf-doc: $(HTML_FILES)
+deploy2sf-doc: deploy-check $(HTML_FILES)
 	( echo 'cd htdocs'; \
 for f in $(HTML_FILES); do \
   echo "put $$f"; \
@@ -161,7 +174,7 @@
 ) | sftp -b - $(SF_USER),$(pkgname)@web.sourceforge.net
 
 .PHONY: deploy2sf-release
-deploy2sf-release: $(DIST_TARBALLS) $(DISTSRC_TARBALLS)
+deploy2sf-release: deploy-check $(DIST_TARBALLS) $(DISTSRC_TARBALLS)
 	( echo 'cd /home/frs/project/g/ga/gadict'; \
 echo "put CHANGES.rst"; \
 echo "chmod 644 CHANGES.rst"; \
@@ -180,6 +193,17 @@
 deploy2sf-src:
 	hg push ssh://gavenkoa@hg.code.sf.net/p/$(pkgname)/code
 
+.PHONY: deploy-check
+deploy-check:
+	case ${visclean} in \
+		no) echo "Local changes found. Build stop."; \
+			exit 1;; \
+	esac
+	case $(vatrelease) in \
+		no) echo "We are not at release. Build stop."; \
+			exit 1;; \
+	esac
+
 ################################################################
 # Dist targets.
 
@@ -256,9 +280,19 @@
 
 VERSION.rst: VERSION $(BUILD_SCRIPT)
 	{ \
-	echo 'Version: '$(vmajor).$(vminor); \
+	echo 'For ``$(pkgname)`` version: ``$(vmajor).$(vminor)``.'; \
+	echo; \
+	case ${visclean} in \
+		yes) echo 'Source files are at revision: ``$(vrev)``.';; \
+		no) echo 'Some source files was modified from revision: ``$(vrev)``.';; \
+	esac; \
 	echo; \
-	echo 'Date: '`date +%F`; \
+	case ${vatrelease} in \
+		yes) echo 'Package is at release state.';; \
+		no) echo 'Package is far from release state by $(vtagdist) changes.';; \
+	esac; \
+	echo; \
+	echo 'Build date: ``'$$(date +%F)'``.'; \
 	} >$@
 
 ################################################################
@@ -266,22 +300,48 @@
 
 .PHONY: help
 help:
-	@echo
-	@echo vmajor=$(vmajor)
-	@echo vminor=$(vminor)
-	@echo
-	@echo Supported targets:
-	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(BUILD_SCRIPT)
+	@\
+echo; \
+echo Current configuration:; \
+echo; \
+sed 's=^=  =' <VERSION
+	@if [ -f Makefile.config ]; then \
+		echo; \
+		echo User configuration:; \
+		echo; \
+		sed 's=^=  =' <Makefile.config; \
+	fi
+	@\
+echo; \
+echo Supported targets:; \
+echo; \
+sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(BUILD_SCRIPT)
 
 .PHONY: stat
-stat:
-	total=0; \
-	for dic in *.dict-c5; do \
-		cnt=`grep '^_____' $$dic | wc -l`; \
-		echo $$dic 'has  ' $$cnt words.; \
-		total=$$(($$total + $$cnt)); \
-	done; \
-	echo Total words count is $$total.
+stat: STAT.rst
+
+STAT.rst: $(C5_FILES) $(BUILD_SCRIPT)
+	{ \
+echo '============================'; \
+echo ' gadict project statistics.'; \
+echo '============================'; \
+echo '.. contents::'; \
+echo; \
+echo 'gadict article count.'; \
+echo '====================='; \
+echo; \
+echo '======================================== ====='; \
+echo '             Dictionary                  Count'; \
+echo '======================================== ====='; \
+total=0; \
+for dic in $(C5_FILES); do \
+  cnt=`grep '^_____' $$dic | wc -l`; \
+  printf '%40s %5s\n' $$dic $$cnt; \
+  total=$$(($$total + $$cnt)); \
+done; \
+printf '%40s %5s\n' '**Total**' $$total; \
+echo '======================================== ====='; \
+} >$@
 
 ################################################################
 # Clean targets.
@@ -292,7 +352,7 @@
 
 .PHONY: clean
 clean:
-	rm -f $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES)
+	rm -f $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES) STAT.rst
 	rm -rf $(DIST_DIR) $(DIST_TARBALLS)
 	rm -rf $(DISTSRC_DIR) $(DISTSRC_TARBALLS)