[Fai-commit] r6260 - trunk

Michael Prokop mika at alioth.debian.org
Sun Dec 26 22:18:14 UTC 2010


Author: mika
Date: 2010-12-26 22:18:13 +0000 (Sun, 26 Dec 2010)
New Revision: 6260

Modified:
   trunk/Makefile
Log:
Makefile: Add syntax checks to catch possible syntax problems (perl/bashism/bash).



Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2010-12-24 10:53:53 UTC (rev 6259)
+++ trunk/Makefile	2010-12-26 22:18:13 UTC (rev 6260)
@@ -9,12 +9,52 @@
 
 USRBIN_SCRIPTS = fai-class fai-do-scripts fai-mirror fai-debconf device2grub policy-rc.d.fai ainsl faimond-gui
 
+# for syntax checks
+BASH_SCRIPTS = lib/fai-divert lib/fai-mount-disk lib/fai-savelog lib/fai-vol_id lib/get-boot-info lib/get-config-dir lib/get-config-dir-cvs lib/get-config-dir-file lib/get-config-dir-git lib/get-config-dir-hg lib/get-config-dir-nfs lib/get-config-dir-svn lib/mkramdisk lib/mount2dir lib/prcopyleft lib/subroutines lib/task_sysinfo lib/updatebase
+SHELL_SCRIPTS = lib/check_status lib/create_resolv_conf lib/updatebase lib/fai-abort lib/fai-divert lib/load_keymap_consolechars lib/disk-info lib/list_disks utils/mkdebmirror utils/create-nfsroot-tar utils/all_hosts utils/rshall bin/fai-start-stop-daemon bin/policy-rc.d.fai bin/dhclient-fai-script
+PERL_SCRIPTS = lib/setup-storage/*.pm bin/ainsl bin/device2grub bin/dhcp-edit bin/fai-chboot bin/faimond bin/faimond-gui bin/fcopy bin/install_packages bin/setup_harddisks bin/setup-storage examples/more-tests/tests/DSK_TEST_1 examples/more-tests/tests/DSK_TEST_2 examples/more-tests/tests/DSK_TEST_3 examples/more-tests/tests/DSK_TEST_4 examples/simple/tests/FAIBASE_TEST examples/simple/tests/Faitest.pm lib/dhclient-perl lib/fai-savelog-ftp utils/prtnetgr
+
 # do not include .svn dir and setup-storage subdir
 libfiles=$(patsubst lib/setup-storage,,$(wildcard lib/[a-z]*))
 
 all:
+	$(MAKE) syntaxcheck
 	$(MAKE) -C doc all
 
+syntaxcheck: bashismcheck shellcheck perlcheck
+
+bashismcheck:
+	@if [ -x "$$(which checkbashisms 2>/dev/null)" ]; then \
+		echo -n "Checking for bashisms"; \
+		for SCRIPT in $(SHELL_SCRIPTS); do \
+			checkbashisms -f -x $${SCRIPT} || exit ; \
+			echo -n "."; \
+		done; \
+		echo " done."; \
+	else \
+		echo "W: checkbashisms - command not found"; \
+		echo "I: checkbashisms can be optained from: "; \
+		echo "I:   http://git.debian.org/?p=devscripts/devscripts.git"; \
+		echo "I: On Debian systems, checkbashisms can be installed with:"; \
+		echo "I:   apt-get install devscripts"; \
+	fi
+
+shellcheck:
+	echo -n "Checking for shell syntax errors"; \
+	for SCRIPT in $(BASH_SCRIPTS) $(SHELL_SCRIPTS); do \
+		bash -n $${SCRIPT} || exit ; \
+		echo -n "."; \
+	done; \
+	echo " done."; \
+
+perlcheck:
+	echo -n "Checking for perl syntax errors"; \
+	for SCRIPT in $(PERL_SCRIPTS); do \
+		perl -w -c $${SCRIPT} || exit ; \
+		echo -n "."; \
+	done; \
+	echo " done."; \
+
 clean:
 	find -name svn-commit\*.tmp -o -name svn-commit.tmp~ | xargs -r rm
 	$(MAKE) -C doc clean
@@ -22,7 +62,7 @@
 veryclean: clean
 	$(MAKE) -f debian/rules clean
 
-install: 
+install:
 	mkdir -p $(DESTDIR)/{sbin,man} $(DESTDIR)/etc/{modutils,apt/apt.conf.d}
 	mkdir -p $(DESTDIR)/usr/{sbin,bin} $(DESTDIR)/usr/lib/fai $(DESTDIR)/etc/fai/apt
 	mkdir -p $(DESTDIR)/etc/{init,init.d} $(DESTDIR)/usr/share/fai/{pixmaps/small,setup-storage}




More information about the Fai-commit mailing list