[Pkg-octave-commit] [octave-pkg-dev] 01/01: octave-pkg.mk: Put long shell commands into individual scripts

Rafael Laboissière rlaboiss-guest at moszumanska.debian.org
Wed Feb 17 22:31:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

rlaboiss-guest pushed a commit to branch master
in repository octave-pkg-dev.

commit 79afdf4ec7e54e800c0ce02348ec0fa0cf754d04
Author: Rafael Laboissiere <rafael at laboissiere.net>
Date:   Wed Feb 17 20:26:20 2016 -0200

    octave-pkg.mk: Put long shell commands into individual scripts
    
    The commands for rules check-pkg, check-version, and install-pkg have
    been removed from octave-pkg.mk and put into individual scripts, which
    have, respectively, the same names as the rules.  These new scripts
    are installed into /usr/share/octave-pkg-dev/, thanks to the debhelper
    file debian/octave-pkg-dev.install.
    
    Notice that no new functionality has been introduced by these purely
    stylistic changes.
---
 check-pkg                     |  66 ++++++++++++++++++++++++
 check-version                 |  18 +++++++
 debian/octave-pkg-dev.install |   3 ++
 install-pkg                   |  20 ++++++++
 octave-pkg.mk                 | 114 +++++++-----------------------------------
 5 files changed, 125 insertions(+), 96 deletions(-)

diff --git a/check-pkg b/check-pkg
new file mode 100755
index 0000000..300cf78
--- /dev/null
+++ b/check-pkg
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+[ -e PKG_ADD ] && mv PKG_ADD PKG_ADD.bak
+
+echo Checking package...
+
+unit_test_regex='^%!\(assert\|test\|error\|fail\|xtest\|warning\)'
+
+# Extract tests from installed m files
+echo Checking m files ...
+tmp=$(tempfile)
+echo "addpath (genpath ([pwd(),'/debian']));" > $tmp
+echo "pkg load all;" >> $tmp
+for f in $(find debian/ -name \*.m $excluded_files_expr	| grep -v /private/) ; do
+    if grep -q "$unit_test_regex" $f ; then
+        stem=${f%%.m}
+        stem=${stem##*/}
+	echo "disp (\"[$stem]\")" >> $tmp
+        echo "test $stem $OCTPKG_TEST_OPT" >> $tmp
+    fi
+done
+$OCTPKG_TEST_ENV $octave $octave_options $tmp
+rm -f $tmp
+
+# Extract tests from .cc files - these are not installed, but the
+# compiled .oct files are.
+# We search for the tests in the .cc files, but invoke the .oct files;
+# this means we must add generate a loadpath starting at the current
+# directory and source PKG_ADD files (they might add autoload()
+# directives)
+
+# We deactivate the warning about relative paths used for the PKG_ADD file.
+echo Checking CC files ...
+tmp=$(tempfile)
+echo "addpath (genpath ([pwd()], '.pc'));" >> $tmp
+echo "pkg load all;" >> $tmp
+echo "warning ('off', 'Octave:autoload-relative-file-name');" >> $tmp
+if [ -f PKG_ADD ] ; then
+    echo "source('PKG_ADD');" >> $tmp
+fi
+if [ -f PKG_ADD.bak ] ; then
+    echo "source('PKG_ADD.bak');" > $tmp
+fi
+if [ -d src ] ; then
+    for f in $(find src/ -name \*.cc $excluded_files_expr) ; do
+        if grep -q "$unit_test_regex" $f ; then
+            stem=${f%%.cc}
+            stem=${stem##*/}
+            echo "disp (\"[$stem]\")" >> $tmp
+            echo "test $stem $OCTPKG_TEST_OPT" >> $tmp
+        fi
+    done
+fi
+$OCTPKG_TEST_ENV $octave $octave_options $tmp
+rm -f $tmp
+
+if [ -f debian/check.m ] ; then
+    $OCTPKG_TEST_ENV $octave $octave_options --eval	\
+        "addpath (genpath ([pwd(),'/debian']));		\
+         pkg load all;					\
+         source ('debian/check.m');"
+fi
+
+if [ -e PKG_ADD.bak ] ; then
+    mv PKG_ADD.bak PKG_ADD
+fi
diff --git a/check-version b/check-version
new file mode 100755
index 0000000..5c8d519
--- /dev/null
+++ b/check-version
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo -n "Checking the Octave version... "
+
+dep=$(grep Depends DESCRIPTION	\
+      | perl -ne 'if (/octave\s+\(>=\s*([.\d]+)\)/i) {print $1}')
+
+if [ "$dep" != "" ] ; then
+    if dpkg --compare-versions "$version" lt "$dep" ; then
+        echo ;
+        echo "Octave version mismatch: "		\
+             "Needs >= $dep, but version "		\
+             "$version is installed" 1>&2 ;
+        exit 1
+    fi
+fi
+
+echo ok
diff --git a/debian/octave-pkg-dev.install b/debian/octave-pkg-dev.install
index 1d10dd5..a11536b 100644
--- a/debian/octave-pkg-dev.install
+++ b/debian/octave-pkg-dev.install
@@ -1,3 +1,6 @@
 octave-pkg.mk                   usr/share/cdbs/1/class
 octave-pkg-helper	        usr/share/octave/debian/dh
 make-octave-forge-debpkg        usr/bin
+check-version			usr/share/octave-pkg-dev
+install-pkg			usr/share/octave-pkg-dev
+check-pkg			usr/share/octave-pkg-dev
diff --git a/install-pkg b/install-pkg
new file mode 100755
index 0000000..556ef3b
--- /dev/null
+++ b/install-pkg
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+[ -e PKG_ADD ] && mv PKG_ADD PKG_ADD.bak
+
+$octave $octave_options --eval					\
+    "pkg ('prefix', [pwd(),'/$debpkg/$mpath'],			\
+         [pwd(),'/$debpkg/$bpath']);				\
+    pkg ('local_list', [pwd(),'/$local_list']);			\
+    pkg ('global_list', [pwd(),'/$global_list']);		\
+    save_header_format_string(					\
+     '# Generated by Octave during Debian package build');	\
+    if (exist ('PKG_ADD.bak') == 2),				\
+        movefile ('PKG_ADD.bak', 'PKG_ADD');			\
+    endif;							\
+    pkg -verbose -nodeps install ."				\
+    | sed 's:/tmp/oct-[a-zA-Z0-9]\{6\}:[tmp-build-dir]:g'
+
+$shrpkg/dh/octave-pkg-helper
+
+dh_install --package=$package
diff --git a/octave-pkg.mk b/octave-pkg.mk
index f5e0dbf..48f327b 100644
--- a/octave-pkg.mk
+++ b/octave-pkg.mk
@@ -22,32 +22,33 @@
 
 include /usr/share/cdbs/1/rules/debhelper.mk
 
-package = $(shell awk '/^Package:/ {print $$2; exit 0}' debian/control)
-debpkg = debian/$(package)
-shrpkg = /usr/share/octave/debian
+export package = $(shell awk '/^Package:/ {print $$2; exit 0}' debian/control)
+export debpkg = debian/$(package)
+export shrpkg = /usr/share/octave/debian
 # The directories below are versioned.  We only support the packages for the
 # stable version of Octave
-mpath = usr/share/octave/packages
-bpath = usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/octave/packages
+export mpath = usr/share/octave/packages
+export bpath = usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/octave/packages
 hosttype = $(shell octave-config -p CANONICAL_HOST_TYPE)
-version = $(shell octave-config -p VERSION | sed 's/-rc/~rc/')
+export version = $(shell octave-config -p VERSION | sed 's/-rc/~rc/')
 apiversion = $(shell octave-config -p API_VERSION)
-octave = /usr/bin/octave-cli
-octave_options = --no-history --silent --no-init-file --no-window-system
-global_list = global-list
-local_list = local-list
+export octave = /usr/bin/octave-cli
+export octave_options = --no-history --silent --no-init-file --no-window-system
+export global_list = global-list
+export local_list = local-list
+libdir = /usr/share/octave-pkg-dev
 
 # The following variable can be overriden in debian/rules to alter the
 # behavior of the tests.  Possible values are 'quiet', 'normal', and
 # 'verbose'.  Users must set its value after inclusion of octave-pkg.mk.
-OCTPKG_TEST_OPT =
+export OCTPKG_TEST_OPT =
 
 # The following variable can be overriden in debian/rules to alter the the
 # way the tests are run.  Its is value is prepended to the octave command.
 # A sensible value for it would be 'xvfb-run', but environment variables
 # can be also set.  Users must set its value after inclusion of
 # octave-pkg.mk.
-OCTPKG_TEST_ENV =
+export OCTPKG_TEST_ENV =
 
 # The following variable can be overriden in debian/rules to prevent
 # the execution of the test blocks for certian files.  This variable
@@ -79,41 +80,16 @@ install/$(package)::	\
 
 .PHONY: check-version
 check-version:
-	@echo -n "Checking the Octave version... "
-	@dep=$$(grep Depends DESCRIPTION				\
-          | perl -ne 'if (/octave\s+\(>=\s*([.\d]+)\)/) {print $$1}') ;	\
-	if [ "$$dep" != "" ] ; then					\
-		dpkg --compare-versions $(version) ge $$dep		\
-			|| (echo ;					\
-			    echo "Octave version mismatch:"		\
-				 "Needs >= $$dep, but version"		\
-				 "$(version) is installed" 1>&2 ;	\
-			    false) ;					\
-	fi ;								\
-	echo ok
+	$(libdir)/check-version
 
 .PHONY: create-dirs
 create-dirs:
 	mkdir -p $(CURDIR)/$(debpkg)/$(mpath)	\
 		 $(CURDIR)/$(debpkg)/$(bpath)
 
-.PHONY: install-pkgs
+.PHONY: install-pkg
 install-pkg:
-	-[ -e PKG_ADD ] && mv PKG_ADD PKG_ADD.bak
-	$(octave) $(octave_options) --eval				\
-		 "pkg ('prefix', [pwd(),'/$(debpkg)/$(mpath)'],		\
-		      [pwd(),'/$(debpkg)/$(bpath)']);			\
-		 pkg ('local_list', [pwd(),'/$(local_list)']);		\
-		 pkg ('global_list', [pwd(),'/$(global_list)']);	\
-		 save_header_format_string(				\
-		  '# Generated by Octave during Debian package build');	\
-		 if (exist ('PKG_ADD.bak') == 2),			\
-		     movefile ('PKG_ADD.bak', 'PKG_ADD');		\
-		 endif;							\
-		 pkg -verbose -nodeps install ."			\
-	    | sed 's:/tmp/oct-[a-zA-Z0-9]\{6\}:[tmp-build-dir]:g'
-	$(shrpkg)/dh/octave-pkg-helper
-	dh_install --package=$(package)
+	$(libdir)/install-pkg
 
 .PHONY: clean-files
 clean-files::
@@ -128,65 +104,11 @@ install-docs:
 
 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
 # Compose the expression for exclusion of requested files from the find command
-excluded_files_expr = $(shell for i in $(OCTPKG_EXCLUDE_TEST) ; do echo " -a ! -name $$i " ; done)
+export excluded_files_expr = $(shell for i in $(OCTPKG_EXCLUDE_TEST) ; do echo " -a ! -name $$i " ; done)
 
 .PHONY: check-pkg
 check-pkg:
-	-[ -e PKG_ADD ] && mv PKG_ADD PKG_ADD.bak
-
-	@echo Checking package...
-
-# Extract tests from installed m files
-	@echo Checking m files ...
-	@tmp=$$(tempfile) ;					\
-	echo "addpath (genpath ([pwd(),'/debian']));" > $$tmp ;	\
-	echo "pkg load all;" >> $$tmp ;				\
-	find debian/ -name \*.m	$(excluded_files_expr)		\
-		| grep -v /private/				\
-		| xargs grep -l '^%!\(assert\|test\|error\|fail\|xtest\|warning\)'	\
-		| perl -pe 's:[^@]*/(.*)\.m::;			\
-		 print "disp (\"[$$1]\")\ntest $$1 $(OCTPKG_TEST_OPT)"'	\
-		>> $$tmp ;					\
-	$(OCTPKG_TEST_ENV) $(octave) $(octave_options) $$tmp ;	\
-	rm -f $$tmp
-
-# Extract tests from .cc files - these are not installed, but the
-# compiled .oct files are.
-# We search for the tests in the .cc files, but invoke the .oct files;
-# this means we must add generate a loadpath starting at the current
-# directory and source PKG_ADD files (they might add autoload()
-# directives)
-
-# We deactivate the warning about relative paths used for the PKG_ADD file.
-	@echo Checking CC files ...
-	@tmp=$$(tempfile) ;					\
-	echo "addpath (genpath ([pwd()], '.pc'));" >> $$tmp ;	\
-	echo "pkg load all;" >> $$tmp ;				\
-	echo "warning ('off', 'Octave:autoload-relative-file-name');" >> $$tmp ;	\
-	if [ -f PKG_ADD ] ; then				\
-		echo "source('PKG_ADD');" >> $$tmp ; 		\
-	fi ;							\
-	if [ -f PKG_ADD.bak ] ; then				\
-		echo "source('PKG_ADD.bak');" >> $$tmp ;	\
-	fi ;							\
-	if [ -d src ] ; then					\
-		find src/ -name \*.cc $(excluded_files_expr)	\
-			| xargs grep -l '^%!\(assert\|test\|error\|fail\|xtest\|warning\)'	\
-			| perl -pe 's:.*/(.*)\.cc::;		\
-				print "disp (\"[$$1]\")\ntest $$1 $(OCTPKG_TEST_OPT)"'	\
-			>> $$tmp ;				\
-	fi ;							\
-	$(OCTPKG_TEST_ENV) $(octave) $(octave_options) $$tmp ;	\
-	rm -f $$tmp
-
-	@if [ -f debian/check.m ] ; then				\
-		$(OCTPKG_TEST_ENV) $(octave) $(octave_options) --eval	\
-			"addpath (genpath ([pwd(),'/debian']));		\
-			 pkg load all;					\
-			 source ('debian/check.m');" ;			\
-	fi
-
-	-[ -e PKG_ADD.bak ] && mv PKG_ADD.bak PKG_ADD
+	$(libdir)/check-pkg
 else
 check-pkg:
 endif

-- 
Alioth's /home/groups/pkg-octave/bin/git-commit-notice on /srv/git.debian.org/git/pkg-octave/octave-pkg-dev.git



More information about the Pkg-octave-commit mailing list