Checked django version considering information from
toaster-requirements.txt, e.g. if requirements file contains
Django<1.9 line toaster should be able to check that requirement
correctly.

Signed-off-by: Ed Bartosh <[email protected]>
---
 bitbake/bin/toaster              | 21 +++++++--------------
 bitbake/toaster-requirements.txt |  2 +-
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index 7645c56..aa184ba 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -156,16 +156,12 @@ notify_chldexit() {
 
 
 verify_prereq() {
-    # Verify prerequisites
-    regex="([0-9])\.([0-9])"
-    for line in `cat $BBBASEDIR/toaster-requirements.txt | grep Django` ; do
-        [[ `echo $line` =~ $regex ]]
-        required_major_version="${BASH_REMATCH[1]}"
-        required_minor_version="${BASH_REMATCH[2]}"
-    done
-
-    if ! echo "import django; print ($required_major_version,) == 
django.VERSION[0:1] and django.VERSION[1:2][0] in ($required_minor_version,)" | 
python 2>/dev/null | grep True >/dev/null; then
-        printf "This program needs Django 
$required_major_version.$required_minor_version. Please install with\n\npip 
install -r $BBBASEDIR/toaster-requirements.txt\n"
+    # Verify Django version
+    reqfile=$BBBASEDIR/toaster-requirements.txt
+    if ! sed -n 's/Django\([><=]\+\)\(.\+\)/import sys,django;sys.exit(not 
django.get_version().split(".")\1"\2".split("."))/p' \
+           $reqfile | python - ; then
+        req=`grep ^Django $reqfile`
+        printf "This program needs $req\nPlease install with pip install -r 
$BBBASEDIR/toaster-requirements.txt\n"
         return 2
     fi
 
@@ -265,10 +261,7 @@ if [ "$1" = 'restart-bitbake' ] ; then
     return $rc
 fi
 
-if ! verify_prereq; then
-    echo "Error: Could not verify that the needed dependencies are installed. 
Please use virtualenv and pip to install dependencies listed in 
toaster-requirements.txt" 1>&2
-    return 1
-fi
+verify_prereq || return 1
 
 # We make sure we're running in the current shell and in a good environment
 if [ -z "$BUILDDIR" ] ||  ! which bitbake >/dev/null 2>&1 ; then
diff --git a/bitbake/toaster-requirements.txt b/bitbake/toaster-requirements.txt
index 5d34494..96408c5 100644
--- a/bitbake/toaster-requirements.txt
+++ b/bitbake/toaster-requirements.txt
@@ -1,4 +1,4 @@
-Django==1.8.6
+Django<1.9
 argparse==1.2.1
 wsgiref==0.1.2
 beautifulsoup4>=4.4.0
-- 
2.1.4

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Reply via email to