diff options
Diffstat (limited to 'pkg')
-rwxr-xr-x | pkg/generate_wheels.sh | 13 | ||||
-rw-r--r-- | pkg/leap_versions.txt | 4 | ||||
-rwxr-xr-x | pkg/linux/bitmask-launcher | 9 | ||||
-rw-r--r-- | pkg/linux/bitmask-root | 4 | ||||
-rw-r--r-- | pkg/linux/pyinst-notes.txt | 20 | ||||
-rw-r--r-- | pkg/osx/Info.plist | 24 | ||||
-rw-r--r-- | pkg/osx/README.rst | 27 | ||||
-rw-r--r-- | pkg/osx/bitmask.icns | bin | 47303 -> 239193 bytes | |||
-rw-r--r-- | pkg/osx/leap-client.spec | 36 | ||||
-rwxr-xr-x | pkg/pip_install_requirements.sh | 86 | ||||
-rwxr-xr-x | pkg/postmkvenv.sh | 11 | ||||
l--------- | pkg/pyinst/bitmask.py | 1 | ||||
-rw-r--r-- | pkg/pyinst/bitmask.spec | 38 | ||||
-rw-r--r-- | pkg/requirements-dev.pip | 14 | ||||
-rw-r--r-- | pkg/requirements-leap.pip | 4 | ||||
-rw-r--r-- | pkg/requirements-testing.pip | 9 | ||||
-rw-r--r-- | pkg/requirements.pip | 13 | ||||
-rwxr-xr-x | pkg/scripts/checkout_leap_versions.sh | 7 | ||||
-rwxr-xr-x | pkg/scripts/filter-bitmask-deps | 35 | ||||
-rwxr-xr-x | pkg/tools/get_authors.sh | 2 | ||||
-rw-r--r-- | pkg/tuf/apply_updates.py | 83 | ||||
-rw-r--r-- | pkg/utils.py | 18 |
22 files changed, 355 insertions, 103 deletions
diff --git a/pkg/generate_wheels.sh b/pkg/generate_wheels.sh new file mode 100755 index 00000000..a13e2c7a --- /dev/null +++ b/pkg/generate_wheels.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Generate wheels for dependencies +# Use at your own risk. + +if [ "$WHEELHOUSE" = "" ]; then + WHEELHOUSE=$HOME/wheelhouse +fi + +pip wheel --wheel-dir $WHEELHOUSE pip +pip wheel --wheel-dir $WHEELHOUSE -r pkg/requirements.pip +if [ -f pkg/requirements-testing.pip ]; then + pip wheel --wheel-dir $WHEELHOUSE -r pkg/requirements-testing.pip +fi diff --git a/pkg/leap_versions.txt b/pkg/leap_versions.txt new file mode 100644 index 00000000..0351c758 --- /dev/null +++ b/pkg/leap_versions.txt @@ -0,0 +1,4 @@ +soledad 0.7.1 +keymanager 0.4.1 +leap_common 0.4.0 +leap_mail 0.4.0rc1 diff --git a/pkg/linux/bitmask-launcher b/pkg/linux/bitmask-launcher new file mode 100755 index 00000000..550dd134 --- /dev/null +++ b/pkg/linux/bitmask-launcher @@ -0,0 +1,9 @@ +#!/bin/sh +# The Bitmask Launcher +# (c) 2015 - The LEAP Encryption Access Project + +[ -f libQtCore.so.4 ] || ln -s libQtCore.so.4.orig libQtCore.so.4 +[ -f libQtGui.so.4 ] || ln -s libQtGui.so.4.orig libQtGui.so.4 +cat /etc/os-release | grep ID | grep -i ubuntu && unlink libQtCore.so.4 && unlink libQtGui.so.4 + +./bitmask-app "$@" diff --git a/pkg/linux/bitmask-root b/pkg/linux/bitmask-root index 6fb1f0b3..80ac12e8 100644 --- a/pkg/linux/bitmask-root +++ b/pkg/linux/bitmask-root @@ -73,7 +73,7 @@ def get_no_group_name(): return None -VERSION = "5" +VERSION = "6" SCRIPT = "bitmask-root" NAMESERVER = "10.42.0.1" BITMASK_CHAIN = "bitmask" @@ -85,7 +85,7 @@ LOCAL_INTERFACE = "lo" IMAP_PORT = "1984" SMTP_PORT = "2013" -IP = "/bin/ip" +IP = "/sbin/ip" IPTABLES = "/sbin/iptables" IP6TABLES = "/sbin/ip6tables" diff --git a/pkg/linux/pyinst-notes.txt b/pkg/linux/pyinst-notes.txt new file mode 100644 index 00000000..e4310e6d --- /dev/null +++ b/pkg/linux/pyinst-notes.txt @@ -0,0 +1,20 @@ +hacks +----- +**because nobody's perfect, at least the first time** + +missing osrandom_engine header +=============================== + +1. extract osrandom_engine.* from original cryptography tarball: + +cp /src/cryptography/hazmat/bindings/openssl/src/osrandom_engine.h /tmp +cp /src/cryptography/hazmat/bindings/openssl/src/osrandom_engine.c /tmp + +cd dist/bitmask +mkdir -p cryptography/hazmat/bindings/openssl/src +cp /tmp/osrandom_engine.* cryptography/hazmat/bindings/openssl/src + +missing dbschema.sql +==================== +mkdir -p u1db/backends +cp ~VIRTUAL_ENV/lib/python2.7/site-packages/u1db/backends/dbschema.sql u1db/backends diff --git a/pkg/osx/Info.plist b/pkg/osx/Info.plist deleted file mode 100644 index dc427c4a..00000000 --- a/pkg/osx/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDisplayName</key> - <string>Bitmask</string> - <key>CFBundleExecutable</key> - <string>app</string> - <key>CFBundleIconFile</key> - <string>bitmask.icns</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>Bitmask</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleShortVersionString</key> - <string>1</string> - <key>LSBackgroundOnly</key> - <false/> - <key>CFBundleIdentifier</key> - <string>se.leap.bitmask</string> -</dict> -</plist> diff --git a/pkg/osx/README.rst b/pkg/osx/README.rst index 03aac4f2..92799ebd 100644 --- a/pkg/osx/README.rst +++ b/pkg/osx/README.rst @@ -1,31 +1,28 @@ environment setup in osx ======================== -(I rm'd my README by mistake at some point. Re-do). + +TODO:: REALLY old notes, adapting to newest flow. basically you need this to setup your environment: # check and consolidate -# install xcode and macports -# port -v selfupdate -# port install python26 -# port install python_select -# port select python python26 -# port install py26-pyqt4 -# port install py26-pip -# port install py26-virtualenv -# port install git-core -# port install platypus -# port install upx +# install xcode and homebrew + +# brew install python2.7 +# brew install python-virtualenwrapper +# brew install qt +# brew install git +# brew install platypus +# brew install upx Requirements ============ pyinstaller ----------- -Expected in ~/pyinstaller -You need the development version. -Tested with: 2.0.373 +You need the development version. do `python setup.py develop` inside your +virtualenv. platypus (tested with latest macports) diff --git a/pkg/osx/bitmask.icns b/pkg/osx/bitmask.icns Binary files differindex 7cc3e752..74fa0af6 100644 --- a/pkg/osx/bitmask.icns +++ b/pkg/osx/bitmask.icns diff --git a/pkg/osx/leap-client.spec b/pkg/osx/leap-client.spec deleted file mode 100644 index 91aa20d6..00000000 --- a/pkg/osx/leap-client.spec +++ /dev/null @@ -1,36 +0,0 @@ -# -*- mode: python -*- -a = Analysis(['../../src/leap/app.py'], - pathex=[ - '../../src/leap', - '/Users/kaliy/leap/leap_client/src/leap-client/pkg/osx'], - hiddenimports=['atexit', 'leap.common'], - hookspath=None) -pyz = PYZ(a.pure) -exe = EXE(pyz, - a.scripts, - exclude_binaries=1, - name=os.path.join('build/pyi.darwin/leap-client', 'app'), - debug=False, - strip=True, - upx=True, - console=False) -coll = COLLECT(exe, - a.binaries + - # this will easitly break if we setup the venv - # somewhere else. FIXME - [('cacert.pem', '/Users/kaliy/.Virtualenvs/leap-client/lib/python2.6/site-packages/requests-1.1.0-py2.6.egg/requests/cacert.pem', 'DATA'), - ], - a.zipfiles, - a.datas, - strip=True, - upx=True, - name=os.path.join('dist', 'app')) -app = BUNDLE(coll, - name=os.path.join('dist', 'leap-client.app')) - -import sys -if sys.platform.startswith("darwin"): - app = BUNDLE(coll, - name=os.path.join('dist', 'LEAP Client.app'), - appname='LEAP Client', - version=1) diff --git a/pkg/pip_install_requirements.sh b/pkg/pip_install_requirements.sh new file mode 100755 index 00000000..6d8ed28b --- /dev/null +++ b/pkg/pip_install_requirements.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# Update pip and install LEAP base/testing requirements. +# For convenience, $insecure_packages are allowed with insecure flags enabled. +# Use at your own risk. +# See $usage for help + +insecure_packages="dirspec" +leap_wheelhouse=https://lizard.leap.se/wheels + +show_help() { + usage="Usage: $0 [--testing] [--use-leap-wheels]\n --testing\t\tInstall dependencies from requirements-testing.pip\n +\t\t\tOtherwise, it will install requirements.pip\n +--use-leap-wheels\tUse wheels from leap.se" + echo -e $usage + + exit 1 +} + +process_arguments() { + testing=false + use_leap_wheels=false + + while [ "$#" -gt 0 ]; do + # From http://stackoverflow.com/a/31443098 + case "$1" in + --help) show_help;; + --testing) testing=true; shift 1;; + --use-leap-wheels) use_leap_wheels=true; shift 1;; + + -h) show_help;; + -*) echo "unknown option: $1" >&2; exit 1;; + esac + done +} + +return_wheelhouse() { + if $use_leap_wheels ; then + WHEELHOUSE=$leap_wheelhouse + elif [ "$WHEELHOUSE" = "" ]; then + WHEELHOUSE=$HOME/wheelhouse + fi + + # Tested with bash and zsh + if [[ $WHEELHOUSE != http* && ! -d "$WHEELHOUSE" ]]; then + mkdir $WHEELHOUSE + fi + + echo "$WHEELHOUSE" +} + +return_install_options() { + wheelhouse=`return_wheelhouse` + install_options="-U --find-links=$wheelhouse" + if $use_leap_wheels ; then + install_options="$install_options --trusted-host lizard.leap.se" + fi + + echo $install_options +} + +return_insecure_flags() { + for insecure_package in $insecure_packages; do + flags="$flags --allow-external $insecure_package --allow-unverified $insecure_package" + done + + echo $flags +} + +return_packages() { + if $testing ; then + packages="-r pkg/requirements-testing.pip" + else + packages="-r pkg/requirements.pip" + fi + + echo $packages +} + +process_arguments $@ +install_options=`return_install_options` +insecure_flags=`return_insecure_flags` +packages=`return_packages` + +pip install -U wheel +pip install $install_options pip +pip install $install_options $insecure_flags $packages diff --git a/pkg/postmkvenv.sh b/pkg/postmkvenv.sh index 7b06fa6d..2407c69b 100755 --- a/pkg/postmkvenv.sh +++ b/pkg/postmkvenv.sh @@ -21,18 +21,21 @@ LIBS=( PySide pysideuic ) PYTHON_VERSION=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))") VAR=( $(which -a $PYTHON_VERSION) ) -GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())" +# this takes care of the /usr/lib vs /usr/lib64 differences between platforms +GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib(plat_specific=True))" +GET_PYSIDE_LIB_CMD="import PySide; print '/'.join(PySide.__path__[0].split('/')[:-1])" + LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD") if [[ $platform == 'linux' ]]; then LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD") elif [[ $platform == 'darwin' ]]; then ORIGINAL_PATH=$PATH - #change first colon of path to | because path substitution is greedy + # change first colon of path to | because path substitution is greedy PATH=${PATH/:/|} - #remove everything up to | from path + # remove everything up to | from path PATH=${PATH/*|/} - LIB_SYSTEM_PATH=$(python -c "$GET_PYTHON_LIB_CMD") + LIB_SYSTEM_PATH=$(/usr/bin/python -c "$GET_PYSIDE_LIB_CMD") PATH=$ORIGINAL_PATH else echo "unsupported platform; not doing symlinks" diff --git a/pkg/pyinst/bitmask.py b/pkg/pyinst/bitmask.py new file mode 120000 index 00000000..3da791e6 --- /dev/null +++ b/pkg/pyinst/bitmask.py @@ -0,0 +1 @@ +../../src/leap/bitmask/app.py
\ No newline at end of file diff --git a/pkg/pyinst/bitmask.spec b/pkg/pyinst/bitmask.spec new file mode 100644 index 00000000..2bc2f9d2 --- /dev/null +++ b/pkg/pyinst/bitmask.spec @@ -0,0 +1,38 @@ +# -*- mode: python -*- + +block_cipher = None + + +a = Analysis([os.path.join('pkg', 'pyinst', 'bitmask.py')], + hiddenimports=[ + 'zope.interface', 'zope.proxy', + 'PySide.QtCore', 'PySide.QtGui'], + hookspath=None, + runtime_hooks=None, + excludes=None, + cipher=block_cipher) +pyz = PYZ(a.pure, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + exclude_binaries=True, + name='bitmask', + debug=False, + strip=False, + upx=True, + console=False ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + name='bitmask') +if sys.platform.startswith("darwin"): + app = BUNDLE(coll, + name=os.path.join( + 'dist', 'Bitmask.app'), + appname='Bitmask', + version='0.9.0rc2', + icon='pkg/osx/bitmask.icns', + bundle_identifier='bitmask-0.9.0rc2') diff --git a/pkg/requirements-dev.pip b/pkg/requirements-dev.pip index 799376d2..45f5fa70 100644 --- a/pkg/requirements-dev.pip +++ b/pkg/requirements-dev.pip @@ -1,3 +1,13 @@ +# ------------------------------------ +# -- useful tools that you probably -- +# -- will want during development -- +# ------------------------------------ + +wheel +sphinx +ipdb +pipdeptree + # --------------------------- # -- external requirements -- # -- during development -- @@ -11,11 +21,7 @@ # to install it. (do it after python setup.py develop and it # will only install this) # -wheel -sphinx -ipdb # in case you want to install a package from a git source, you can use this: # Useful to test pre-release branches together. #-e git+https://github.com/leapcode/leap_pycommon.git@develop#egg=leap.common -#-e git+https://github.com/leapcode/soledad.git@develop#egg=leap.soledad diff --git a/pkg/requirements-leap.pip b/pkg/requirements-leap.pip new file mode 100644 index 00000000..df2d1974 --- /dev/null +++ b/pkg/requirements-leap.pip @@ -0,0 +1,4 @@ +leap.soledad.client>=0.6.0 +leap.keymanager>=0.4.0 +leap.mail>=0.4.0rc1 +leap.common>=0.4.0 diff --git a/pkg/requirements-testing.pip b/pkg/requirements-testing.pip index e789664a..ede94516 100644 --- a/pkg/requirements-testing.pip +++ b/pkg/requirements-testing.pip @@ -7,12 +7,5 @@ mock unittest2 # TODO we should include this dep only for python2.6 coverage pep8>=1.1 +flake8 tox - -#sphinx>=1.1.2 - -# double reqs -# (the client already includes, which gives some errors) -# ----------- -#twisted -#zope.interface diff --git a/pkg/requirements.pip b/pkg/requirements.pip index 8baaecdb..85645763 100644 --- a/pkg/requirements.pip +++ b/pkg/requirements.pip @@ -9,9 +9,7 @@ argparse requests>=1.1.0 srp>=1.0.2 pyopenssl - -# This won't be needed after we refactor leap.common.events to use zmq. -python-dateutil +coloredlogs psutil @@ -24,11 +22,10 @@ zope.proxy # You will want to install this bundled if you don't have sodium in your system: # pip install pyzmq --install-option="--zmq=bundled" pyzmq - -leap.common>=0.3.7 -leap.soledad.client>=0.6.0 -leap.keymanager>=0.3.8 -leap.mail>=0.3.9 +txzmq # Remove this when u1db fixes its dependency on oauth oauth + +taskthread +logbook diff --git a/pkg/scripts/checkout_leap_versions.sh b/pkg/scripts/checkout_leap_versions.sh new file mode 100755 index 00000000..5381625b --- /dev/null +++ b/pkg/scripts/checkout_leap_versions.sh @@ -0,0 +1,7 @@ +#!/bin/sh +cat pkg/leap_versions.txt | while read line +do + package=$(echo $line | cut -f1 -d' ') + tag=$(echo $line | cut -f2 -d' ') + cd ../$package && git fetch origin && git checkout $tag +done diff --git a/pkg/scripts/filter-bitmask-deps b/pkg/scripts/filter-bitmask-deps new file mode 100755 index 00000000..9808d394 --- /dev/null +++ b/pkg/scripts/filter-bitmask-deps @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +""" +Filter bitmask dependencies. + +Usage: pipdeptree | filter-bitmask-deps +""" +import fileinput + +TARGET = "leap.bitmask" + + +def get_bitmask_deps(dep_lines): + res = [] + begin = False + for dep in dep_lines: + if dep.startswith(TARGET): + begin = True + res.append(dep) + continue + elif dep.startswith(' ') and begin: + res.append(dep) + continue + if begin: + return res + + +if __name__ == "__main__": + lines = [] + for line in fileinput.input(): + lines.append(line) + + bitmask_deps = get_bitmask_deps(lines) + for line in bitmask_deps: + print line[:-1] diff --git a/pkg/tools/get_authors.sh b/pkg/tools/get_authors.sh new file mode 100755 index 00000000..0169bb17 --- /dev/null +++ b/pkg/tools/get_authors.sh @@ -0,0 +1,2 @@ +#!/bin/sh +git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d' ' -f2- diff --git a/pkg/tuf/apply_updates.py b/pkg/tuf/apply_updates.py new file mode 100644 index 00000000..7b52ef11 --- /dev/null +++ b/pkg/tuf/apply_updates.py @@ -0,0 +1,83 @@ +#!/usr/local/bin python +# -*- coding: utf-8 -*- +# apply_updates.py +# Copyright (C) 2015 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +""" +Apply downloaded updates to the bundle +""" + +import os +import os.path +import shutil +import tuf.client.updater + + +REPO_DIR = "repo/" +UPDATES_DIR = "updates/" + + +def update_if_needed(): + if not os.path.isdir(UPDATES_DIR): + print "No updates found" + return + + print "Found updates, merging directories before doing anything..." + try: + remove_obsolete() + merge_directories(UPDATES_DIR, ".") + shutil.rmtree(UPDATES_DIR) + except Exception as e: + print "An error has ocurred while updating: " + e.message + + +def remove_obsolete(): + tuf.conf.repository_directory = REPO_DIR + updater = tuf.client.updater.Updater('leap-updater', {}) + updater.remove_obsolete_targets(".") + + +def merge_directories(src, dest): + for root, dirs, files in os.walk(src): + if not os.path.exists(root): + # It was moved as the dir din't exist in dest + continue + + destroot = os.path.join(dest, root[len(src):]) + + for f in files: + srcpath = os.path.join(root, f) + destpath = os.path.join(destroot, f) + if os.path.exists(destpath): + # FIXME: On windows we can't remove, but we can rename and + # afterwards remove. is that still true with python? + # or was just something specific of our implementation + # with C++? + os.remove(destpath) + os.rename(srcpath, destpath) + + for d in dirs: + srcpath = os.path.join(root, d) + destpath = os.path.join(destroot, d) + + if os.path.exists(destpath) and not os.path.isdir(destpath): + os.remove(destpath) + + if not os.path.exists(destpath): + os.rename(srcpath, destpath) + + +if __name__ == "__main__": + update_if_needed() diff --git a/pkg/utils.py b/pkg/utils.py index deace14b..2e316d45 100644 --- a/pkg/utils.py +++ b/pkg/utils.py @@ -14,16 +14,30 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - """ Utils to help in the setup process """ - import os import re import sys +def is_develop_mode(): + """ + Returns True if we're calling the setup script using the argument for + setuptools development mode. + + This avoids messing up with dependency pinning and order, the + responsibility of installing the leap dependencies is left to the + developer. + """ + args = sys.argv + devflags = "setup.py", "develop" + if (args[0], args[1]) == devflags: + return True + return False + + def get_reqs_from_files(reqfiles): """ Returns the contents of the top requirement file listed as a |