Browse code

Merge "Fix fixup_stuff.sh package permissions fix"

Jenkins authored on 2013/10/17 06:22:13
Showing 1 changed files
... ...
@@ -35,25 +35,35 @@ FILES=$TOP_DIR/files
35 35
 # Python Packages
36 36
 # ---------------
37 37
 
38
-# Pre-install affected packages so we can fix the permissions
39
-pip_install prettytable
40
-pip_install httplib2
38
+# get_package_path python-package    # in import notation
39
+function get_package_path() {
40
+    local package=$1
41
+    echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
42
+}
41 43
 
42
-SITE_DIRS=$(python -c "import site; import os; print os.linesep.join(site.getsitepackages())")
43
-for dir in $SITE_DIRS; do
44 44
 
45
-    # Fix prettytable 0.7.2 permissions
46
-    if [[ -r $dir/prettytable.py ]]; then
47
-        sudo chmod +r $dir/prettytable-0.7.2*/*
48
-    fi
45
+# Pre-install affected packages so we can fix the permissions
46
+# These can go away once we are confident that pip 1.4.1+ is available everywhere
49 47
 
50
-    # Fix httplib2 0.8 permissions
51
-    httplib_dir=httplib2-0.8.egg-info
52
-    if [[ -d $dir/$httplib_dir ]]; then
53
-        sudo chmod +r $dir/$httplib_dir/*
54
-    fi
48
+# Fix prettytable 0.7.2 permissions
49
+# Don't specify --upgrade so we use the existing package if present
50
+pip_install prettytable
51
+PACKAGE_DIR=$(get_package_path prettytable)
52
+# Only fix version 0.7.2
53
+dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
54
+if [[ -d $dir ]]; then
55
+    sudo chmod +r $dir/*
56
+fi
55 57
 
56
-done
58
+# Fix httplib2 0.8 permissions
59
+# Don't specify --upgrade so we use the existing package if present
60
+pip_install httplib2
61
+PACKAGE_DIR=$(get_package_path httplib2)
62
+# Only fix version 0.8
63
+dir=$(echo $PACKAGE_DIR-0.8*)
64
+if [[ -d $dir ]]; then
65
+    sudo chmod +r $dir/*
66
+fi
57 67
 
58 68
 
59 69
 # RHEL6