[mousetrap/gnome3-wip: 31/240] Fix breakage from last commit.



commit 7a8a67187866a2f40eb8793bd4d635f0a25c2b9e
Author: Stoney Jackson <dr stoney gmail com>
Date:   Fri May 9 16:53:59 2014 -0400

    Fix breakage from last commit.

 .gitignore                     |    3 ++-
 README                         |    4 ++--
 bin/install.sh                 |    8 +++-----
 bin/lib/environment_up.sh      |    3 +++
 bin/lib/test_environment_up.sh |   15 +++++++--------
 bin/mousetrap.py               |   37 -------------------------------------
 bin/mousetrap.sh               |    5 +++++
 bin/test.py                    |    6 ++----
 configure.ac                   |    4 ++--
 9 files changed, 26 insertions(+), 59 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b195bd8..49517bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,7 +56,7 @@ mousetrap.desktop
 omf.make
 po/*.gmo
 py-compile
-run_pylint.sh
+bin/pylint.sh
 stamp-h1
 xmldocs.make
 docs/doxygen/Doxyfile
@@ -69,4 +69,5 @@ aclocal.m4
 po/POTFILES
 
 /INSTALL
+/.last_install
 /.last_built
diff --git a/README b/README
index 05908c7..c1e537e 100644
--- a/README
+++ b/README
@@ -13,7 +13,7 @@ From the mousetrap project directory:
 
 ## Other commands (primarily for developers)
 
-* bin/build.sh   # builds (no install)
+* bin/build.sh
 * bin/pylint.sh
 * bin/test.py
-* bin/mousetrap.py   # runs mousetrap from project directory (i.e., no build or install)
+* bin/mousetrap.sh
diff --git a/bin/install.sh b/bin/install.sh
index f27af2e..168f49a 100755
--- a/bin/install.sh
+++ b/bin/install.sh
@@ -2,11 +2,9 @@
 test -z "$PROJECT_DIRECTORY" && . "$(dirname "$0")"/lib/environment_up.sh
 cd "$PROJECT_DIRECTORY"
 
-last_mod="$(find . \( -path './.git/*' -o -name "*.swp" -prune \) -o -type f -exec stat -f '%m %N' {} \; | 
sort -n | tail -1)"
-read -ra ADDR <<< "$last_mod"
-last_mod_file="${ADDR[1]}"
-
-if [ "$last_mod_file" -nt .last_built ] ; then
+if [ ! -f "$PROJECT_DIRECTORY/.last_built" -o \
+     "$(last_modified_file)" -nt "$PROJECT_DIRECTORY/.last_built" ]
+then
     "$PROJECT_DIRECTORY/bin/build.sh"
 fi
 
diff --git a/bin/lib/environment_up.sh b/bin/lib/environment_up.sh
index 69079cd..4b21b1c 100644
--- a/bin/lib/environment_up.sh
+++ b/bin/lib/environment_up.sh
@@ -13,5 +13,8 @@ project_directory(){
     echo "$PWD"
     cd "$original_directory" >& /dev/null
 }
+last_modified_file() {
+       find "$1" \( -name "*.swp" -o -path "*.git/*" \) -prune -o -type f -exec stat --format '%Y :%y %n' {} 
\; | sort -nr | cut -d' ' -f5- | head -1
+}
 SCRIPT_DIRECTORY="$(absolute_directory "$(dirname "$0")")"
 PROJECT_DIRECTORY="$(project_directory)"
diff --git a/bin/lib/test_environment_up.sh b/bin/lib/test_environment_up.sh
index e95729b..8b97a71 100755
--- a/bin/lib/test_environment_up.sh
+++ b/bin/lib/test_environment_up.sh
@@ -14,24 +14,23 @@ test_project_directory() {
         "$(project_directory)"
 }
 
-test_SCRIPT_DIRECTORY_defined() {
-    assertNotNull "$SCRIPT_DIRECTORY"
-}
-
 test_SCRIPT_DIRECTORY_correct() {
     assertEquals \
         "$(absolute_directory "$(dirname "$0")")" \
         "$SCRIPT_DIRECTORY"
 }
 
-test_PROJECT_DIRECTORY_defined() {
-    assertNotNull "$PROJECT_DIRECTORY"
-}
-
 test_PROJECT_DIRECTORY_correct() {
     assertEquals \
         "$(absolute_directory "$(dirname "$0")/../..")" \
         "$PROJECT_DIRECTORY"
 }
 
+test_last_modified_file() {
+       file="test_last_modified_file.tmp"
+       touch "$file"
+       assertEquals "./$file" "$(last_modified_file .)"
+       rm "$file"
+}
+
 . shunit2
diff --git a/bin/mousetrap.sh b/bin/mousetrap.sh
new file mode 100755
index 0000000..81310a5
--- /dev/null
+++ b/bin/mousetrap.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+test -z "$PROJECT_DIRECTORY" && . "$(dirname "$0")"/lib/environment_up.sh
+cd "$PROJECT_DIRECTORY"
+
+"$PROJECT_DIRECTORY/src/mousetrap/mousetrap"
diff --git a/bin/test.py b/bin/test.py
index 9f485e3..8950848 100755
--- a/bin/test.py
+++ b/bin/test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 from unittest import TestLoader
 from unittest.runner import TextTestRunner
-from pathlib import Path
+import os.path
 
 
 def main():
@@ -16,9 +16,7 @@ def load_tests():
 
 
 def get_package_root_directory():
-    this_file = Path(__file__).absolute()
-    package_root = this_file.parent.parent/'src/mousetrap'
-    return str(package_root)
+    return os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/src/mousetrap'
 
 
 def run_tests(tests):
diff --git a/configure.ac b/configure.ac
index 08f2bb2..be15795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,7 @@ DOCBOOK_CHECK()
 #mousetrap.spec
 
 AC_OUTPUT([
-run_pylint.sh
+bin/pylint.sh
 Makefile
 mousetrap.desktop
 po/Makefile.in
@@ -97,7 +97,7 @@ src/mousetrap/ocvfw/dev/Makefile
 src/mousetrap/ocvfw/idm/Makefile
 src/mousetrap/ocvfw/haars/Makefile
 src/mousetrap/ui/Makefile
-],[chmod +x run_pylint.sh])
+],[chmod +x bin/pylint.sh])
 
 ###############################################################################
 # Don't include src/mousetrap/app/mousetrap.in in AC_OUTPUT.  It will be


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]