update.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # This scripts pull the latest Azure Storage SDK and update this multiapi package accordingly.
  3. workdir=$(cd $(dirname $0); pwd)
  4. cd $workdir
  5. if [ ! -d venv ]; then
  6. python -m virtualenv venv
  7. . venv/bin/activate
  8. pip install azure-storage-blob azure-storage-file azure-storage-queue azure-storage-common
  9. fi
  10. ver=$(find venv -name '_constants.py' | grep blob | xargs grep 'X_MS_VERSION')
  11. ver=${ver#X_MS_VERSION = \'}
  12. ver=${ver%\'}
  13. ver=${ver//-/_}
  14. src_root=$(cd venv/lib/$(ls venv/lib); pwd)/site-packages/azure/storage
  15. tgt=../azure/multiapi/storage/v$ver
  16. mkdir -p $tgt
  17. for service in blob file queue common; do
  18. src=$src_root/$service
  19. cp -R $src $tgt
  20. for f in `find $tgt/$service -name '*.py'`; do
  21. echo Updating $f
  22. # remove BOM
  23. sed -i '1s/^\xEF\xBB\xBF//' $f
  24. if [ "$service" != "common" ]; then
  25. # make relative reference to azure.storage.common
  26. sed -i 's/from azure.storage.common./from ..common./g' $f
  27. else
  28. # make relative reference to azure.storage.common
  29. sed -i 's/from azure.storage.common./from ./g' $f
  30. sed -i 's/from azure.storage./from ../g' $f
  31. fi
  32. done
  33. done