Revert "Let virtualenv handle paths", and use $ENV_PATH more in hope of getting rid of bad interpreter errors.

This reverts commit b2c800cadfc2f2205273eafc1ce319050d518bf7.

Conflicts:
	test.sh

#!/bin/bash

set -x

WORKSPACE="${WORKSPACE:-$(pwd)}"
CLEAN_VIRTUALENV="${CLEAN_VIRTUALENV:-0}"
DJANGO_TAGGIT="${DJANGO_TAGGIT:-1}"
DJANGO_GENERIC_M2M="${DJANGO_GENERIC_M2M:-1}"
PYTHON_VERSION="${PYTHON_VERSION:-3.3}"
DJANGO_VERSION="${DJANGO_VERSION:-1.5}"
JOB_UNIQUE_ID="$PYTHON_VERSION-$DJANGO_VERSION-$DJANGO_TAGGIT-$DJANGO_GENERIC_M2M"
DATABASE_NAME="autocomplete_light_test_${JOB_UNIQUE_ID//[.-]}"

# Make a unique env path for this configuration
ENV_PATH="$WORKSPACE/test_env"

psql -c "drop database if exists $DATABASE_NAME;" -U postgres
psql -c "create database $DATABASE_NAME;" -U postgres

# Get real django version
[ ! -d "$HOME/django" ] && git clone http://github.com/django/django.git $HOME/.django
cd $HOME/.django
git fetch --tags
DJANGO_VERSION=$(git tag -l | grep -E "$DJANGO_VERSION(\.[0-9])?$" | tail -n1)

# Clean virtualenv if necessary
[ "$CLEAN_VIRTUALENV" = "1" ] && rm -rf $ENV_PATH

# Make virtualenv if necessary
[ ! -d "$ENV_PATH" ] && virtualenv-$PYTHON_VERSION $ENV_PATH

source $ENV_PATH/bin/activate

if [ "$DJANGO_TAGGIT" = "1" ]; then
    $ENV_PATH/bin/pip install -U django-taggit
else
    $ENV_PATH/bin/pip uninstall -y django-taggit
fi

if [ "$DJANGO_GENERIC_M2M" = "1" ]; then
    $ENV_PATH/bin/pip install -U django-generic-m2m
else
    $ENV_PATH/bin/pip uninstall -y django-generic-m2m
fi

$ENV_PATH/bin/pip install -e $WORKSPACE
$ENV_PATH/bin/pip install -Ur $WORKSPACE/test_project/requirements.txt
$ENV_PATH/bin/pip install -Ur $WORKSPACE/test_project/test_requirements.txt

# Install appropriate django version because other package upgrades like
# pip install -U django-jenkins has caused installation of the latest django
# release because it requires django>=1.4.
$ENV_PATH/bin/pip install -U django==$DJANGO_VERSION

cd $WORKSPACE
$ENV_PATH/bin/python $WORKSPACE/test_project/manage.py jenkins autocomplete_light --liveserver=9000-9200 --settings=test_project.settings_postgres

#!/bin/bash

set -x

WORKSPACE="${WORKSPACE:-$(pwd)}"
CLEAN_VIRTUALENV="${CLEAN_VIRTUALENV:-0}"
DJANGO_TAGGIT="${DJANGO_TAGGIT:-1}"
DJANGO_GENERIC_M2M="${DJANGO_GENERIC_M2M:-1}"
PYTHON_VERSION="${PYTHON_VERSION:-3.3}"
DJANGO_VERSION="${DJANGO_VERSION:-1.5}"
JOB_UNIQUE_ID="$PYTHON_VERSION-$DJANGO_VERSION-$DJANGO_TAGGIT-$DJANGO_GENERIC_M2M"
DATABASE_NAME="autocomplete_light_test_${JOB_UNIQUE_ID//[.-]}"

# Make a unique env path for this configuration
ENV_PATH="$WORKSPACE/test_env"

psql -c "drop database if exists $DATABASE_NAME;" -U postgres
psql -c "create database $DATABASE_NAME;" -U postgres

# Get real django version
[ ! -d "$HOME/django" ] && git clone http://github.com/django/django.git $HOME/.django
cd $HOME/.django
git fetch --tags
DJANGO_VERSION=$(git tag -l | grep -E "$DJANGO_VERSION(\.[0-9])?$" | tail -n1)

# Clean virtualenv if necessary
[ "$CLEAN_VIRTUALENV" = "1" ] && rm -rf $ENV_PATH

# Make virtualenv if necessary
[ ! -d "$ENV_PATH" ] && virtualenv-$PYTHON_VERSION $ENV_PATH

source $ENV_PATH/bin/activate

if [ "$DJANGO_TAGGIT" = "1" ]; then
    pip install -U django-taggit
else
    pip uninstall -y django-taggit
fi

if [ "$DJANGO_GENERIC_M2M" = "1" ]; then
    pip install -U django-generic-m2m
else
    pip uninstall -y django-generic-m2m
fi

pip install -e $WORKSPACE
pip install -Ur $WORKSPACE/test_project/requirements.txt
pip install -Ur $WORKSPACE/test_project/test_requirements.txt

# Install appropriate django version because other package upgrades like
# pip install -U django-jenkins has caused installation of the latest django
# release because it requires django>=1.4.
pip install -U django==$DJANGO_VERSION

cd $WORKSPACE
test_project/manage.py jenkins autocomplete_light --liveserver=9000-9200 --settings=test_project.settings_postgres


deploy: bump node package to v0.10.36

deploy: bump node package to v0.10.36

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/StealthMicro/Adafruit-Pi-Finder.git/'


Begun PHP test harness conversion script

#!/bin/bash
#
# This script accepts a provided PHP benchmark directory path as its sole input
# and proceeds to destructively convert its C test harness into a perl script,
# matching the rest of the ManyBugs test harnesses.
#
# Usage: ./build-test-harness.sh PHP_BENCHMARK_DIR

error: pathspec 'many-bugs/php/build-test-harness.sh' did not match any file(s) known to git


changed permission of makeall.sh to executable

Former-commit-id: cdcdd5bdb3bd386c00820418c94dbfddd58111bf

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Deutsche-Digitale-Bibliothek/ddb-backend.git/'


stupid mistake

stupid mistake

# !/bin/bash

# Set your environment how you want
WORKING_DIR="$HOME"
PROJECT_ROOT="$WORKING_DIR"
DEPOT_TOOLS="$PROJECT_ROOT/depot_tools"
WEBRTC_ROOT="$PROJECT_ROOT/webrtc"

# Utility method for creating a directory
create_directory_if_not_found() {
	# if we cannot find the directory
	if [ ! -d "$1" ];
		then
		echo "$1 directory not found, creating..."
	    mkdir -p "$1"
	    echo "directory created at $1"
	fi
}

# Installs all android related dependencies
install_dependencies() {
	WORKING_DIR=`pwd`

	sudo apt-get -y install wget git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 subversion
	sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
	REPO="$WEBRTC_ROOT/repo"
	PATH="$REPO:$PATH"
	curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > "$REPO"
	chmod a+x "$REPO"
	cd $WEBRTC_ROOT

	echo Go back to working directory
}

# Installs jdk 1.6
install_jdk1_6() {
	WORKING_DIR=`pwd`
    wget http://ghaffarian.net/downloads/Java/JDK/jdk-6u45-linux-x64.bin
    sudo mkdir /usr/lib/jvm
    cd /usr/lib/jvm && sudo /bin/sh ~/jdk-6u45-linux-x64.bin -noregister
    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 50000
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 50000
    sudo update-alternatives --config javac
    sudo update-alternatives --config java
    JAVA_HOME=`readlink -f $(which java)`
    JAVA_HOME=`echo ${JAVA_HOME%/bin/java}`
    echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc
    source ~/.bashrc
    cd $WORKING_DIR
}

# Update/Get/Ensure the Gclient Depot Tools
pull_depot_tools() {
	WORKING_DIR=`pwd`

	echo If no directory where depot tools should be...
	if [ ! -d "$DEPOT_TOOLS" ]
	then
	    echo Make directory for gclient called Depot Tools
	    mkdir -p $DEPOT_TOOLS

	    echo Pull the depo tools project from chromium source into the depot tools directory
	    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS

	else

		echo Change directory into the depot tools
		cd $DEPOT_TOOLS

		echo Pull the depot tools down to the latest
		git pull
	fi
	PATH="$PATH:$DEPOT_TOOLS"
	cd $WORKING_DIR
}

# Update/Get the webrtc code base
pull_webrtc() {
	WORKING_DIR=`pwd`

	# If no directory where webrtc root should be...
	create_directory_if_not_found $WEBRTC_ROOT

    echo Change directory to webrtc root
    cd $WEBRTC_ROOT

    # Ensure our target os is correcot building android
	gclient config http://webrtc.googlecode.com/svn/trunk
	echo "target_os = ['unix', 'android']" >> .gclient

	echo Ensure gclient is in a clean state

	echo Pull down the latest from the webrtc repo
	echo this can take a while
	if [ -z $1 ]
    then
        echo "gclient sync with newest"
        gclient sync --nohooks
    else
    	trunkA="trunk@"
        echo "gclient sync with r$1"
        gclient sync -r $trunkA$1 --nohooks
    fi

	cd $WORKING_DIR
}

# Setup our defines for the build
prepare_gyp_defines() {
    # Setup deps for android and configure environment
	$WEBRTC_ROOT/trunk/build/install-build-deps-android.sh
	source $WEBRTC_ROOT/trunk/build/android/envsetup.sh

	echo Export the base settings of GYP_DEFINES so we can define how we want to build
	export GYP_DEFINES="OS=android host_os=linux target_arch=arm libjingle_java=1 build_with_libjingle=1 build_with_chromium=0 enable_tracing=1 arm_neon=1 armv7=1 enable_android_opensl=1"
	echo "GYP_DEFINES=$GYP_DEFINES"
	export DEFINES=$GYP_DEFINES
	echo "DEFINES=$DEFINES"
}

# Clean up and generate the build scripts
prepare_build() {
	WORKING_DIR=`pwd`

    echo Change directory into webrtc trunk
    cd "$WEBRTC_ROOT/trunk"

    echo cleaning old build
    rm -rf out
    mkdir out
    mkdir out/Release
    mkdir out/Debug

    echo gclient runhooks
    gclient runhooks

    cd $WORKING_DIR
}

# Builds the apprtc demo
execute_build() {
	WORKING_DIR=`pwd`
	cd "$WEBRTC_ROOT/trunk"

	PEERCONNECTION_BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
	create_directory_if_not_found "$PEERCONNECTION_BUILD"
	DEBUG_DIR="$PEERCONNECTION_BUILD/Debug"
	create_directory_if_not_found "$DEBUG_DIR"
	ARCHITECTURE="armeabi-v7a"

	DIRECTORY="$WEBRTC_ROOT/trunk/talk/examples/android/libs/$ARCHITECTURE"

	echo Build AppRTCDemo in Release mode
	ninja -C out/Release/ AppRTCDemo

	RELEASE_DIR="$PEERCONNECTION_BUILD/Release"
	create_directory_if_not_found "$RELEASE_DIR"
	create_directory_if_not_found "$RELEASE_DIR/$ARCHITECTURE"
	echo "Copy $DIRECTORY/libjingle_peerconnection_so.so to $RELEASE_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"
	cp -p "$DIRECTORY/libjingle_peerconnection_so.so" "$RELEASE_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"

	echo "Copy $WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar to $RELEASE_DIR/libjingle_peerconnection.jar"
	cp -p "$WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar" "$RELEASE_DIR/libjingle_peerconnection.jar"

	cd $WORKING_DIR
}

# Builds the apprtc demo in debug
execute_debug_build() {
	WORKING_DIR=`pwd`

	echo Change directory into webrtc trunk
	cd "$WEBRTC_ROOT/trunk"

	echo Build AppRTCDemo in Debug mode
	ninja -C out/Debug/ AppRTCDemo

	PEERCONNECTION_BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
	create_directory_if_not_found "$PEERCONNECTION_BUILD"
	DEBUG_DIR="$PEERCONNECTION_BUILD/Debug"
	create_directory_if_not_found "$DEBUG_DIR"
	ARCHITECTURE="armeabi-v7a"

	DIRECTORY="$WEBRTC_ROOT/trunk/talk/examples/android/libs/$ARCHITECTURE"

	create_directory_if_not_found "$DEBUG_DIR/$ARCHITECTURE"
	echo "Copy $DIRECTORY/libjingle_peerconnection_so.so to $DEBUG_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"
	cp -p "$DIRECTORY/libjingle_peerconnection_so.so" "$DEBUG_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"

	echo "Copy $WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar to $DEBUG_DIR/libjingle_peerconnection.jar"
	cp -p "$WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar" "$DEBUG_DIR/libjingle_peerconnection.jar"

	cd $WORKING_DIR
}

# Gets the webrtc revision
get_webrtc_revision() {
    svn info "$WEBRTC_ROOT/trunk" | awk '{ if ($1 ~ /Revision/) { print $2 } }'
}

# Updates webrtc and builds apprtc
build_apprtc() {
    pull_depot_tools &&
    pull_webrtc &&
    prepare_gyp_defines &&
    prepare_build &&
    execute_build
}

# Updates webrtc and builds apprtc in debug
build_debug_apprtc() {
    pull_depot_tools &&
    pull_webrtc &&
    prepare_gyp_defines &&
    prepare_build &&
    execute_debug_build
}

# !/bin/bash

# Set your environment how you want
WORKING_DIR="$HOME"
PROJECT_ROOT="$WORKING_DIR"
DEPOT_TOOLS="$PROJECT_ROOT/depot_tools"
WEBRTC_ROOT="$PROJECT_ROOT/webrtc"

# Utility method for creating a directory
create_directory_if_not_found() {
	# if we cannot find the directory
	if [ ! -d "$1" ];
		then
		echo "$1 directory not found, creating..."
	    mkdir -p "$1"
	    echo "directory created at $1"
	fi
}

# Installs all android related dependencies
install_dependencies() {
	WORKING_DIR=`pwd`

	sudo apt-get -y install wget git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 subversion
	sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
	REPO="$WEBRTC_ROOT/repo"
	PATH="$REPO:$PATH"
	curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > "$REPO"
	chmod a+x "$REPO"
	cd $WEBRTC_ROOT

	echo Go back to working directory
}

# Installs jdk 1.6
install_jdk1_6() {
	WORKING_DIR=`pwd`
    wget http://ghaffarian.net/downloads/Java/JDK/jdk-6u45-linux-x64.bin
    sudo mkdir /usr/lib/jvm
    cd /usr/lib/jvm && sudo /bin/sh ~/jdk-6u45-linux-x64.bin -noregister
    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 50000
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 50000
    sudo update-alternatives --config javac
    sudo update-alternatives --config java
    JAVA_HOME=`readlink -f $(which java)`
    JAVA_HOME=`echo ${JAVA_HOME%/bin/java}`
    echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc
    source ~/.bashrc
    cd $WORKING_DIR
}

# Update/Get/Ensure the Gclient Depot Tools
pull_depot_tools() {
	WORKING_DIR=`pwd`

	echo If no directory where depot tools should be...
	if [ ! -d "$DEPOT_TOOLS" ]
	then
	    echo Make directory for gclient called Depot Tools
	    mkdir -p $DEPOT_TOOLS

	    echo Pull the depo tools project from chromium source into the depot tools directory
	    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS

	else

		echo Change directory into the depot tools
		cd $DEPOT_TOOLS

		echo Pull the depot tools down to the latest
		git pull
	fi
	PATH="$PATH:$DEPOT_TOOLS"
	cd $WORKING_DIR
}

# Update/Get the webrtc code base
pull_webrtc() {
	WORKING_DIR=`pwd`

	# If no directory where webrtc root should be...
	create_directory_if_not_found $WEBRTC_ROOT

    echo Change directory to webrtc root
    cd $WEBRTC_ROOT

    # Ensure our target os is correcot building android
	gclient config http://webrtc.googlecode.com/svn/trunk
	echo "target_os = ['unix', 'android']" >> .gclient

	echo Ensure gclient is in a clean state

	echo Pull down the latest from the webrtc repo
	echo this can take a while
	if [ -z $1 ]
    then
        echo "gclient sync with newest"
        gclient sync --nohooks
    else
    	trunkA="trunk@"
        echo "gclient sync with r$1"
        gclient sync -r $trunkA$1 --nohooks
    fi

	cd $WORKING_DIR
}

# Setup our defines for the build
prepare_gyp_defines() {
    # Setup deps for android and configure environment
	$WEBRTC_ROOT/trunk/build/install-build-deps-android.sh
	source $WEBRTC_ROOT/trunk/build/android/envsetup.sh

	echo Export the base settings of GYP_DEFINES so we can define how we want to build
	export GYP_DEFINES="OS=android host_os=linux target_arch=arm libjingle_java=1 build_with_libjingle=1 build_with_chromium=0 enable_tracing=1 arm_neon=1 armv7=1 enable_android_opensl=1"
	echo "GYP_DEFINES=$GYP_DEFINES"
	export DEFINES=$GYP_DEFINES
	echo "DEFINES=$DEFINES"
}

# Clean up and generate the build scripts
prepare_build() {
	WORKING_DIR=`pwd`

    echo Change directory into webrtc trunk
    cd "$WEBRTC_ROOT/trunk"

    echo cleaning old build
    rm -rf out
    mkdir out
    mkdir out/Release
    mkdir out/Debug

    echo gclient runhooks
    gclient runhooks

    cd $WORKING_DIR
}

# Builds the apprtc demo
execute_build() {
	WORKING_DIR=`pwd`
	cd "$WEBRTC_ROOT/trunk"

	PEERCONNECTION_BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
	create_directory_if_not_found "$PEERCONNECTION_BUILD"
	DEBUG_DIR="$PEERCONNECTION_BUILD/Debug"
	create_directory_if_not_found "$DEBUG_DIR"
	ARCHITECTURE="armeabi-v7a"

	DIRECTORY="$WEBRTC_ROOT/trunk/talk/examples/android/libs/$ARCHITECTURE"

	echo Build AppRTCDemo in Release mode
	ninja -C out/Release/ AppRTCDemo

	RELEASE_DIR="$PEERCONNECTION_BUILD/Release"
	create_directory_if_not_found "$RELEASE_DIR"
	create_directory_if_not_found "$RELEASE_DIR/$ARCHITECTURE"
	echo "Copy $DIRECTORY/libjingle_peerconnection_so.so to $RELEASE_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"
	cp -p "$DIRECTORY/libjingle_peerconnection_so.so" "$RELEASE_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"

	echo "Copy $WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar to $RELEASE_DIR/libjingle_peerconnection.jar"
	cp -p "$WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar" "$RELEASE_DIR/libjingle_peerconnection.jar"

	cd $WORKING_DIR
}

# Builds the apprtc demo in debug
execute_debug_build() {
	WORKING_DIR=`pwd`

	echo Change directory into webrtc trunk
	cd "$WEBRTC_ROOT/trunk"

	echo Build AppRTCDemo in Debug mode
	ninja -C out/Debug/ AppRTCDemo

	PEERCONNECTION_BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
	create_directory_if_not_found "$PEERCONNECTION_BUILD"
	DEBUG_DIR="$PEERCONNECTION_BUILD/Debug"
	create_directory_if_not_found "$DEBUG_DIR"
	ARCHITECTURE="armeabi-v7a"

	DIRECTORY="$WEBRTC_ROOT/trunk/talk/examples/android/libs/$ARCHITECTURE"

	create_directory_if_not_found "$DEBUG_DIR/$ARCHITECTURE"
	echo "Copy $DIRECTORY/libjingle_peerconnection_so.so to $DEBUG_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"
	cp -p "$DIRECTORY/libjingle_peerconnection_so.so" "$DEBUG_DIR/$ARCHITECTURE/libjingle_peerconnection_so.so"

	echo "Copy $WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar to $DEBUG_DIR/libjingle_peerconnection.jar"
	cp -p "$WEBRTC_ROOT/trunk/talk/examples/android/libs/libjingle_peerconnection.jar" "$DEBUG_DIR/libjingle_peerconnection.jar"

	cd $WORKING_DIR
}

# Gets the webrtc revision
get_webrtc_revision() {
    svn info "$WEBRTC_ROOT/trunk" | awk '{ if ($1 ~ /Revision/) { print $2 } }'
}

# Updates webrtc and builds apprtc
build_apprtc() {
    pull_depot_tools &&
    pull_webrtc &&
    prepare_gyp_defines &&
    prepare_build &&
    execute_build
}

# Updates webrtc and builds apprtc in debug
build_apprtc() {
    pull_depot_tools &&
    pull_webrtc &&
    prepare_gyp_defines &&
    prepare_build &&
    execute_debug_build
}


Don't fail script if folder already exists

Caused build failure when run in Jenkins:

```
+ cd /var/lib/jenkins/jobs/build-webrtc/workspace/android/webrtc/libjingle_peerconnection_builds/Debug
+ mkdir res
mkdir: cannot create directory ‘res’: File exists
Build step 'Execute shell' marked build as failure
Finished: FAILURE
```

# !/bin/bash
# Copyright Pristine Inc
# Author: Rahul Behera <rahul@pristine.io>
# Author: Aaron Alaniz <aaron@pristine.io>
# Author: Arik Yaacob   <arik@pristine.io>
#
# Builds the android peer connection library

# Set your environment how you want
if [ -n  "$VAGRANT_MACHINE" ];
    then
    PROJECT_ROOT="/vagrant"
else
    # Get location of the script itself .. thanks SO ! http://stackoverflow.com/a/246128
    SOURCE="${BASH_SOURCE[0]}"
    while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
        DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
        SOURCE="$(readlink "$SOURCE")"
        [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
    PROJECT_ROOT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
fi

DEPOT_TOOLS="$PROJECT_ROOT/depot_tools"
WEBRTC_ROOT="$PROJECT_ROOT/webrtc"
BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
WEBRTC_TARGET="AppRTCDemo"

ANDROID_TOOLCHAINS="$WEBRTC_ROOT/src/third_party/android_tools/ndk/toolchains"

# Utility method for creating a directory
create_directory_if_not_found() {
	# if we cannot find the directory
	if [ ! -d "$1" ];
		then
		echo "$1 directory not found, creating..."
	    mkdir -p "$1"
	    echo "directory created at $1"
	fi
}

exec_ninja() {
  echo "Running ninja"
  ninja -C $1 $WEBRTC_TARGET
}

# Installs the required dependencies on the machine
install_dependencies() {
    sudo apt-get -y install wget git gnupg flex bison gperf build-essential zip curl subversion pkg-config
    #Download the latest script to install the android dependencies for ubuntu
    curl -o install-build-deps-android.sh https://src.chromium.org/svn/trunk/src/build/install-build-deps-android.sh
    #use bash (not dash which is default) to run the script
    sudo /bin/bash ./install-build-deps-android.sh
    #delete the file we just downloaded... not needed anymore
    rm install-build-deps-android.sh
}

# Update/Get/Ensure the Gclient Depot Tools
# Also will add to your environment
pull_depot_tools() {
	WORKING_DIR=`pwd`

    # Either clone or get latest depot tools
	if [ ! -d "$DEPOT_TOOLS" ]
	then
	    echo Make directory for gclient called Depot Tools
	    mkdir -p $DEPOT_TOOLS

	    echo Pull the depo tools project from chromium source into the depot tools directory
	    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS

	else
		echo Change directory into the depot tools
		cd $DEPOT_TOOLS

		echo Pull the depot tools down to the latest
		git pull
	fi
	PATH="$PATH:$DEPOT_TOOLS"

    # Navigate back
	cd $WORKING_DIR
}

# Update/Get the webrtc code base
pull_webrtc() {
    WORKING_DIR=`pwd`

    # If no directory where webrtc root should be...
    create_directory_if_not_found $WEBRTC_ROOT
    cd $WEBRTC_ROOT

    # Ensure our target os is correct building android
    echo Configuring gclient for Android build
	gclient config --name=src http://webrtc.googlecode.com/svn/trunk
	echo "target_os = ['unix', 'android']" >> .gclient

    # Get latest webrtc source
	echo Pull down the latest from the webrtc repo
	echo this can take a while
	if [ -z $1 ]
    then
        echo "gclient sync with newest"
        gclient sync
    else
        echo "gclient sync with $1"
        gclient sync -r $1
    fi

    # Navigate back
	cd $WORKING_DIR
}

# Prepare our build
function wrbase() {
    export GYP_DEFINES="OS=android host_os=linux libjingle_java=1 build_with_libjingle=1 build_with_chromium=0 enable_tracing=1 enable_android_opensl=1"
    export GYP_GENERATORS="ninja"
}

# Arm V7 with Neon
function wrarmv7() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android"
    export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_android_armeabi_v7a"
    export GYP_CROSSCOMPILE=1
    echo "ARMv7 with Neon Build"
}

# Arm 64
function wrarmv8() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=arm64 target_subarch=arm64"
    export GYP_GENERATOR_FLAGS="$output_dir=out_android_arm64_v8a"
    export GYP_CROSSCOMPILE=1
    echo "ARMv8 with Neon Build"
}

# x86
function wrX86() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=ia32"
    export GYP_GENERATOR_FLAGS="output_dir=out_android_x86"
    echo "x86 Build"
}

# x86_64
function wrX86_64() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=x64"
    export GYP_GENERATOR_FLAGS="output_dir=out_android_x86_64"
    echo "x86_64 Build"
}

# Setup our defines for the build
prepare_gyp_defines() {
    # Configure environment for Android
    echo Setting up build environment for Android
    source $WEBRTC_ROOT/src/build/android/envsetup.sh

    # Check to see if the user wants to set their own gyp defines
    echo Export the base settings of GYP_DEFINES so we can define how we want to build
    if [ -n $USER_GYP_DEFINES ]
    then
        echo "User has not specified any gyp defines so we proceed with default"
        if [ "$WEBRTC_ARCH" = "x86" ] ;
        then
            wrX86
        elif [ "$WEBRTC_ARCH" = "x86_64" ] ;
        then
            wrX86_64
        elif [ "$WEBRTC_ARCH" = "armv7" ] ;
        then
            wrarmv7
        elif [ "$WEBRTC_ARCH" = "armv8" ] ;
        then
            wrarmv8
        fi
    else
        echo "User has specified their own gyp defines"
        export GYP_DEFINES="$USER_GYP_DEFINES"
    fi

    echo "GYP_DEFINES=$GYP_DEFINES"
}

# Builds the apprtc demo
execute_build() {
    WORKING_DIR=`pwd`
    cd "$WEBRTC_ROOT/src"

    echo Run gclient hooks
    gclient runhooks

    if [ "$WEBRTC_ARCH" = "x86" ] ;
    then
        ARCH="x86"
        STRIP=$ANDROID_TOOLCHAINS/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-strip
    elif [ "$WEBRTC_ARCH" = "x86_64" ] ;
    then
        ARCH="x86_64"
        STRIP=$ANDROID_TOOLCHAINS/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-strip
    elif [ "$WEBRTC_ARCH" = "armv7" ] ;
    then
        ARCH="armeabi_v7a"
        STRIP=$ANDROID_TOOLCHAINS/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip
    elif [ "$WEBRTC_ARCH" = "armv8" ] ;
    then
        ARCH="arm64_v8a"
        STRIP=$ANDROID_TOOLCHAINS/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip
    fi

    if [ "$WEBRTC_DEBUG" = "true" ] ;
    then
        BUILD_TYPE="Debug"
    else
        BUILD_TYPE="Release"
    fi

    ARCH_OUT="out_android_${ARCH}"
    echo "Build ${WEBRTC_TARGET} in $BUILD_TYPE (arch: ${WEBRTC_ARCH:-arm})"
    exec_ninja "$ARCH_OUT/$BUILD_TYPE"

    REVISION_NUM=`get_webrtc_revision`
    # Verify the build actually worked
    if [ $? -eq 0 ]; then
        SOURCE_DIR="$WEBRTC_ROOT/src/$ARCH_OUT/$BUILD_TYPE"
        TARGET_DIR="$BUILD/$BUILD_TYPE"
        create_directory_if_not_found "$TARGET_DIR"

        rm "$TARGET_DIR/$REVISION_NUM.zip" || true

        echo "Copy JAR File"
        create_directory_if_not_found "$TARGET_DIR/libs/"
        create_directory_if_not_found "$TARGET_DIR/jniLibs/"

        ARCH_JNI="$TARGET_DIR/jniLibs/${ARCH}"
        create_directory_if_not_found $ARCH_JNI

        cp -p "$SOURCE_DIR/libjingle_peerconnection.jar" "$TARGET_DIR/libs/"

        $STRIP -o $ARCH_JNI/libjingle_peerconnection_so.so $WEBRTC_ROOT/src/$ARCH_OUT/$BUILD_TYPE/lib/libjingle_peerconnection_so.so -s

        #cp -pr "$SOURCE_DIR"/* "$TARGET_DIR"
        cd $TARGET_DIR
        mkdir -p res # make resources directory

        zip -r "$TARGET_DIR/$REVISION_NUM.zip" .
        cd $WORKING_DIR

        echo "$BUILD_TYPE build for apprtc complete for revision $REVISION_NUM"
    else

        echo "$BUILD_TYPE build for apprtc failed for revision $REVISION_NUM"
    fi
}

# Gets the webrtc revision
get_webrtc_revision() {
 #   git describe --tags  | sed 's/r\([0-9]*\)-.*/\1/' #Here's a nice little git version if you are using a git source
    svn info "$WEBRTC_ROOT/src" | awk '{ if ($1 ~ /Revision/) { print $2 } }'
}

get_webrtc() {
    pull_depot_tools &&
    pull_webrtc $1
}

# Updates webrtc and builds apprtc
build_apprtc() {
    export WEBRTC_ARCH=armv7
    prepare_gyp_defines &&
    execute_build

    # Uncomment once the application can successfully build for arm64
    #export WEBRTC_ARCH=armv8
    #prepare_gyp_defines &&
    #execute_build

    export WEBRTC_ARCH=x86
    prepare_gyp_defines &&
    execute_build

    export WEBRTC_ARCH=x86_64
    prepare_gyp_defines &&
    execute_build
}

# !/bin/bash
# Copyright Pristine Inc
# Author: Rahul Behera <rahul@pristine.io>
# Author: Aaron Alaniz <aaron@pristine.io>
# Author: Arik Yaacob   <arik@pristine.io>
#
# Builds the android peer connection library

# Set your environment how you want
if [ -n  "$VAGRANT_MACHINE" ];
    then
    PROJECT_ROOT="/vagrant"
else
    # Get location of the script itself .. thanks SO ! http://stackoverflow.com/a/246128
    SOURCE="${BASH_SOURCE[0]}"
    while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
        DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
        SOURCE="$(readlink "$SOURCE")"
        [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
    PROJECT_ROOT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
fi

DEPOT_TOOLS="$PROJECT_ROOT/depot_tools"
WEBRTC_ROOT="$PROJECT_ROOT/webrtc"
BUILD="$WEBRTC_ROOT/libjingle_peerconnection_builds"
WEBRTC_TARGET="AppRTCDemo"

ANDROID_TOOLCHAINS="$WEBRTC_ROOT/src/third_party/android_tools/ndk/toolchains"

# Utility method for creating a directory
create_directory_if_not_found() {
	# if we cannot find the directory
	if [ ! -d "$1" ];
		then
		echo "$1 directory not found, creating..."
	    mkdir -p "$1"
	    echo "directory created at $1"
	fi
}

exec_ninja() {
  echo "Running ninja"
  ninja -C $1 $WEBRTC_TARGET
}

# Installs the required dependencies on the machine
install_dependencies() {
    sudo apt-get -y install wget git gnupg flex bison gperf build-essential zip curl subversion pkg-config
    #Download the latest script to install the android dependencies for ubuntu
    curl -o install-build-deps-android.sh https://src.chromium.org/svn/trunk/src/build/install-build-deps-android.sh
    #use bash (not dash which is default) to run the script
    sudo /bin/bash ./install-build-deps-android.sh
    #delete the file we just downloaded... not needed anymore
    rm install-build-deps-android.sh
}

# Update/Get/Ensure the Gclient Depot Tools
# Also will add to your environment
pull_depot_tools() {
	WORKING_DIR=`pwd`

    # Either clone or get latest depot tools
	if [ ! -d "$DEPOT_TOOLS" ]
	then
	    echo Make directory for gclient called Depot Tools
	    mkdir -p $DEPOT_TOOLS

	    echo Pull the depo tools project from chromium source into the depot tools directory
	    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS

	else
		echo Change directory into the depot tools
		cd $DEPOT_TOOLS

		echo Pull the depot tools down to the latest
		git pull
	fi
	PATH="$PATH:$DEPOT_TOOLS"

    # Navigate back
	cd $WORKING_DIR
}

# Update/Get the webrtc code base
pull_webrtc() {
    WORKING_DIR=`pwd`

    # If no directory where webrtc root should be...
    create_directory_if_not_found $WEBRTC_ROOT
    cd $WEBRTC_ROOT

    # Ensure our target os is correct building android
    echo Configuring gclient for Android build
	gclient config --name=src http://webrtc.googlecode.com/svn/trunk
	echo "target_os = ['unix', 'android']" >> .gclient

    # Get latest webrtc source
	echo Pull down the latest from the webrtc repo
	echo this can take a while
	if [ -z $1 ]
    then
        echo "gclient sync with newest"
        gclient sync
    else
        echo "gclient sync with $1"
        gclient sync -r $1
    fi

    # Navigate back
	cd $WORKING_DIR
}

# Prepare our build
function wrbase() {
    export GYP_DEFINES="OS=android host_os=linux libjingle_java=1 build_with_libjingle=1 build_with_chromium=0 enable_tracing=1 enable_android_opensl=1"
    export GYP_GENERATORS="ninja"
}

# Arm V7 with Neon
function wrarmv7() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android"
    export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_android_armeabi_v7a"
    export GYP_CROSSCOMPILE=1
    echo "ARMv7 with Neon Build"
}

# Arm 64
function wrarmv8() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=arm64 target_subarch=arm64"
    export GYP_GENERATOR_FLAGS="$output_dir=out_android_arm64_v8a"
    export GYP_CROSSCOMPILE=1
    echo "ARMv8 with Neon Build"
}

# x86
function wrX86() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=ia32"
    export GYP_GENERATOR_FLAGS="output_dir=out_android_x86"
    echo "x86 Build"
}

# x86_64
function wrX86_64() {
    wrbase
    export GYP_DEFINES="$GYP_DEFINES OS=android target_arch=x64"
    export GYP_GENERATOR_FLAGS="output_dir=out_android_x86_64"
    echo "x86_64 Build"
}

# Setup our defines for the build
prepare_gyp_defines() {
    # Configure environment for Android
    echo Setting up build environment for Android
    source $WEBRTC_ROOT/src/build/android/envsetup.sh

    # Check to see if the user wants to set their own gyp defines
    echo Export the base settings of GYP_DEFINES so we can define how we want to build
    if [ -n $USER_GYP_DEFINES ]
    then
        echo "User has not specified any gyp defines so we proceed with default"
        if [ "$WEBRTC_ARCH" = "x86" ] ;
        then
            wrX86
        elif [ "$WEBRTC_ARCH" = "x86_64" ] ;
        then
            wrX86_64
        elif [ "$WEBRTC_ARCH" = "armv7" ] ;
        then
            wrarmv7
        elif [ "$WEBRTC_ARCH" = "armv8" ] ;
        then
            wrarmv8
        fi
    else
        echo "User has specified their own gyp defines"
        export GYP_DEFINES="$USER_GYP_DEFINES"
    fi

    echo "GYP_DEFINES=$GYP_DEFINES"
}

# Builds the apprtc demo
execute_build() {
    WORKING_DIR=`pwd`
    cd "$WEBRTC_ROOT/src"

    echo Run gclient hooks
    gclient runhooks

    if [ "$WEBRTC_ARCH" = "x86" ] ;
    then
        ARCH="x86"
        STRIP=$ANDROID_TOOLCHAINS/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-strip
    elif [ "$WEBRTC_ARCH" = "x86_64" ] ;
    then
        ARCH="x86_64"
        STRIP=$ANDROID_TOOLCHAINS/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-strip
    elif [ "$WEBRTC_ARCH" = "armv7" ] ;
    then
        ARCH="armeabi_v7a"
        STRIP=$ANDROID_TOOLCHAINS/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip
    elif [ "$WEBRTC_ARCH" = "armv8" ] ;
    then
        ARCH="arm64_v8a"
        STRIP=$ANDROID_TOOLCHAINS/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip
    fi

    if [ "$WEBRTC_DEBUG" = "true" ] ;
    then
        BUILD_TYPE="Debug"
    else
        BUILD_TYPE="Release"
    fi

    ARCH_OUT="out_android_${ARCH}"
    echo "Build ${WEBRTC_TARGET} in $BUILD_TYPE (arch: ${WEBRTC_ARCH:-arm})"
    exec_ninja "$ARCH_OUT/$BUILD_TYPE"

    REVISION_NUM=`get_webrtc_revision`
    # Verify the build actually worked
    if [ $? -eq 0 ]; then
        SOURCE_DIR="$WEBRTC_ROOT/src/$ARCH_OUT/$BUILD_TYPE"
        TARGET_DIR="$BUILD/$BUILD_TYPE"
        create_directory_if_not_found "$TARGET_DIR"

        rm "$TARGET_DIR/$REVISION_NUM.zip" || true

        echo "Copy JAR File"
        create_directory_if_not_found "$TARGET_DIR/libs/"
        create_directory_if_not_found "$TARGET_DIR/jniLibs/"

        ARCH_JNI="$TARGET_DIR/jniLibs/${ARCH}"
        create_directory_if_not_found $ARCH_JNI

        cp -p "$SOURCE_DIR/libjingle_peerconnection.jar" "$TARGET_DIR/libs/"

        $STRIP -o $ARCH_JNI/libjingle_peerconnection_so.so $WEBRTC_ROOT/src/$ARCH_OUT/$BUILD_TYPE/lib/libjingle_peerconnection_so.so -s

        #cp -pr "$SOURCE_DIR"/* "$TARGET_DIR"
        cd $TARGET_DIR
        mkdir res # make resources directory

        zip -r "$TARGET_DIR/$REVISION_NUM.zip" .
        cd $WORKING_DIR

        echo "$BUILD_TYPE build for apprtc complete for revision $REVISION_NUM"
    else

        echo "$BUILD_TYPE build for apprtc failed for revision $REVISION_NUM"
    fi
}

# Gets the webrtc revision
get_webrtc_revision() {
 #   git describe --tags  | sed 's/r\([0-9]*\)-.*/\1/' #Here's a nice little git version if you are using a git source
    svn info "$WEBRTC_ROOT/src" | awk '{ if ($1 ~ /Revision/) { print $2 } }'
}

get_webrtc() {
    pull_depot_tools &&
    pull_webrtc $1
}

# Updates webrtc and builds apprtc
build_apprtc() {
    export WEBRTC_ARCH=armv7
    prepare_gyp_defines &&
    execute_build

    # Uncomment once the application can successfully build for arm64
    #export WEBRTC_ARCH=armv8
    #prepare_gyp_defines &&
    #execute_build

    export WEBRTC_ARCH=x86
    prepare_gyp_defines &&
    execute_build

    export WEBRTC_ARCH=x86_64
    prepare_gyp_defines &&
    execute_build
}


Added script to copy work books to Google Drive

#!/bin/bash

#FROM=/cygdrive/c/cygwin64/home/RKurr/BitTorrentSync/Todd/mobi/
#FROM=/cygdrive/i/BitTorrenSync/'Todd Books'/Apps/
FROM=/cygdrive/i/BitTorrenSync/
#TO=/cygdrive/e/documents/transparent-language
TO=/cygdrive/c/Users/rkurr/'Google Drive'/transparent

echo 'Copying epub books to Google Drive...'
rsync --verbose --recursive --checksum --delete --prune-empty-dirs --human-readable --progress --itemize-changes --exclude='Todd Books/Apps/.sync/' --include='*/' --include='*.epub' --exclude='*' "$FROM" "$TO"

error: pathspec 'update-work-books-to-google-drive.sh' did not match any file(s) known to git


Added prebuilt PCRE for android

Added prebuilt PCRE for android

#!/bin/bash

#
# build PCRE for android
#

# exit on error
# exit on error
set -e

ME=`basename $0`
SDK_VER="5.0"
TARGET_DEVICE="arm-linux-androideabi"
DEST_DIR="${PWD}/../../prebuilt/android/${TARGET_DEVICE}/lib"
BUILD_DIR="/tmp/build-pcre-android/"

if [ ! -f pcre_version.c ]; then
	echo
	echo "Cannot find pcre_version.c"
	echo "Run script from within pcre directory:"
	echo "pcre-8.31$ ../../${ME}"
	echo
	exit
fi
mkdir -p ${DEST_DIR} &> /dev/null

# set ANDROID_NDK to default if environment variable not set
if [ ! -f ${ANDROID_NDK_ROOT}/ndk-build ]; then
	# try some convinient default locations
	if [ -d /opt/android-ndk-r7 ]; then
		ANDROID_NDK_ROOT="/opt/android-ndk-r7"
	elif [ -d /Developer/Applications/android-ndk-r7 ]; then
		ANDROID_NDK_ROOT="/Developer/Applications/android-ndk-r7"
	elif [ -d /home/sradomski/Documents/android-dev/android-ndk-r7 ]; then
		ANDROID_NDK_ROOT="/home/sradomski/Documents/android-dev/android-ndk-r7"
	else
		echo
		echo "Cannot find android-ndk, call script as"
		echo "ANDROID_NDK_ROOT=\"/path/to/android/ndk\" ${ME}"
		echo
		exit
	fi
	export ANDROID_NDK_ROOT="${ANDROID_NDK_ROOT}"
fi

# download updated config.guess and config.sub
#cd config
#wget http://git.savannah.gnu.org/cgit/config.git/plain/config.guess -O config.guess
#wget http://git.savannah.gnu.org/cgit/config.git/plain/config.sub -O config.sub
#cd ..

if [ -f Makefile ]; then
	make clean
fi

# if [ -f ispatched ]; then
# 	rm ./ispatched
# else
# 	patch -p1 < ../zeromq-3.1.0.android.patch
# fi
# touch ispatched

# select and verify toolchain
ANDROID_SYS_ROOT="${ANDROID_NDK_ROOT}/standalone"

if [ ! -f ${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-gcc ]; then
	echo
	echo "Cannot find compiler at ${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-gcc"
	echo
	exit;
fi

if [ ! -d ${ANDROID_SYS_ROOT}/lib ]; then
	echo
	echo "Cannot find sytem libraries at ${ANDROID_SYS_ROOT}/lib"
	echo
	exit;
fi

COMMON_FLAGS=" -DANDROID -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DTARGET_OS_ANDROID -fsigned-char -mfloat-abi=softfp -mfpu=vfp -fno-exceptions -fno-rtti -mthumb -fomit-frame-pointer -fno-strict-aliasing "

./configure \
CPP="cpp" \
CXXCPP="cpp" \
CC="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-gcc" \
CXX="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-g++" \
LD="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ld" \
CXXFLAGS="-Wno-sign-compare -Os -s ${COMMON_FLAGS}" \
CFLAGS="-Wno-sign-compare -Os -s ${COMMON_FLAGS}" \
LIBZMQ_EXTRA_LDFLAGS="-llog" \
LDFLAGS="-L${ANDROID_SYS_ROOT}/lib -static -Wl,--fix-cortex-a8" \
CPPFLAGS="-I${ANDROID_SYS_ROOT}/include -static" \
AR="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ar" \
AS="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-as" \
LIBTOOL="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-libtool" \
STRIP="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-strip" \
RANLIB="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ranlib" \
--disable-dependency-tracking \
--target=arm-linux-androideabi \
--host=arm-linux-androideabi \
--enable-static \
--disable-shared \
--prefix=${BUILD_DIR}

make -j2 install

mv ${BUILD_DIR}/lib/libpcre.a ${DEST_DIR}/libpcre.a
mv ${BUILD_DIR}/lib/libpcreposix.a ${DEST_DIR}/libpcreposix.a

make clean

# build again with debugging
./configure \
CPP="cpp" \
CXXCPP="cpp" \
CC="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-gcc" \
CXX="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-g++" \
LD="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ld" \
CXXFLAGS="-Wno-sign-compare -g ${COMMON_FLAGS}" \
CFLAGS="-Wno-sign-compare -g ${COMMON_FLAGS}" \
LIBZMQ_EXTRA_LDFLAGS="-llog" \
LDFLAGS="-L${ANDROID_SYS_ROOT}/lib -static -Wl,--fix-cortex-a8" \
CPPFLAGS="-I${ANDROID_SYS_ROOT}/include -static" \
AR="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ar" \
AS="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-as" \
LIBTOOL="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-libtool" \
STRIP="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-strip" \
RANLIB="${ANDROID_SYS_ROOT}/bin/${TARGET_DEVICE}-ranlib" \
--disable-dependency-tracking \
--target=arm-linux-androideabi \
--host=arm-linux-androideabi \
--enable-static \
--disable-shared \
--prefix=${BUILD_DIR}

make -j2 install

mv ${BUILD_DIR}/lib/libpcre.a ${DEST_DIR}/libpcre_d.a
mv ${BUILD_DIR}/lib/libpcreposix.a ${DEST_DIR}/libpcreposix_d.a

echo
echo "Installed static libraries in ${DEST_DIR}"
echo

error: pathspec 'contrib/build-pcre-android.sh' did not match any file(s) known to git


Update RHEL_7_Fusion_Setup.sh

Update RHEL_7_Fusion_Setup.sh

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/LucidWorks/fusion-examples.git/'


fixing CI integration

fixing CI integration

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/starschema/virtdb-logger.git/'


create benchmark tool to measure bash commands

#!/bin/zsh
# Benchmark runner

# defaults
repeats=20

run_tests() {
    # --------------------------------------------------------------------------
    # Benchmark loop
    # --------------------------------------------------------------------------
    echo 'Benchmarking ' $command_to_run '...';
    # Indicate the command we just run in the csv file
    echo '======' $command_to_run '======' >> $output_file;

    # Run the given command [repeats] times
    for (( i = 1; i <= $repeats ; i++ ))
    do
        # percentage completion
        p=$(( $i * 100 / $repeats))
        # indicator of progress
        l=$(seq -s "+" $i | sed 's/[0-9]//g')

        gtime -f "%E,%U,%S" -o ${output_file} -a npm run test:ci

        echo -ne ${l}' ('${p}'%) \r'
    done;

    echo -ne '\n'

    # Convenience seperator for file
    echo '--------------------------' >> $output_file
}

usage() {
    echo "Usage: benchmark.sh -c 'echo 1' -o 'results.csv'"
    echo ""
    echo "Options:"
    echo "  -o=<name>:    output file name (required)"
    echo "  -c=<command>: command to run (required)"
    echo "  -n=<number>:  repeat number (default: 20)"
    exit 1
}

# Option parsing
while getopts n:c:o:h OPT
do
    case "$OPT" in
        n)
            repeats=$OPTARG
            ;;
        o)
            output_file=$OPTARG
            ;;
        c)
            command_to_run=$OPTARG
            ;;
        h)
            usage
            ;;
    esac
done

if [ -z "$output_file" ]
then
  echo "Error: missing required param [-o]"
  echo ""
  usage
  exit
fi

if [ -z "$command_to_run" ]
then
  echo "Error: missing required param [-c]"
  echo ""
  usage
  exit
fi
run_tests

shift `expr $OPTIND - 1`

error: pathspec 'bin/benchmark.sh' did not match any file(s) known to git


add param

add param

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/kirisky/ReactProjectGenerator.git/'


Add guard rails alias

Add guard rails alias

error: pathspec 'rails/aliases.zsh' did not match any file(s) known to git


Linux batch para arrancar API REST

Linux batch para arrancar API REST

#!/bin/bash
cd ..
cd deliciousFoodSpring/target
java -jar deliciousFood-0.0.1-SNAPSHOT.jar

error: pathspec 'deliciousFoodAngular/API_REST.sh' did not match any file(s) known to git


script for removing private code&data

script for removing private code&data

#!/bin/bash

git clone git@bitbucket.org:krha/cloudlet.git
rm -r ./cloudlet/src/app
rm -r ./cloudlet/src/ec2
rm -r ./cloudlet/src/ISR
rm -r ./cloudlet/src/measurement
rm -r ./cloudlet/src/nova
rm -r ./cloudlet/deploy
rm -r ./cloudlet/tmp
rm -r ./cloudlet/TODO.md
rm -r ./cloudlet/.git/
rm -r ./cloudlet/.gitignore

tar cvfz cloudlet.tar.gz cloudlet/
rm -rf ./cloudlet

error: pathspec 'deploy/deploy.sh' did not match any file(s) known to git


Added a buildbox CI script.

Added a buildbox CI script.

error: pathspec 'scripts/buildbox.sh' did not match any file(s) known to git


Example script from web

Example script from web

#!/usr/bin/env python
import socket
import subprocess
import sys
from datetime import datetime

# Clear the screen
subprocess.call('clear', shell=True)

# Ask for input
remoteServer    = raw_input("Enter a remote host to scan: ")
remoteServerIP  = socket.gethostbyname(remoteServer)

# Print a nice banner with information on which host we are about to scan
print "-" * 60
print "Please wait, scanning remote host", remoteServerIP
print "-" * 60

# Check what time the scan started
t1 = datetime.now()

# Using the range function to specify ports (here it will scans all ports between 1 and 1024)

# We also put in some error handling for catching errors

try:
    for port in range(1,1025):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex((remoteServerIP, port))
        if result == 0:
            print "Port {}: \t Open".format(port)
        sock.close()

except KeyboardInterrupt:
    print "You pressed Ctrl+C"
    sys.exit()

except socket.gaierror:
    print 'Hostname could not be resolved. Exiting'
    sys.exit()

except socket.error:
    print "Couldn't connect to server"
    sys.exit()

# Checking the time again
t2 = datetime.now()

# Calculates the difference of time, to see how long it took to run the script
total =  t2 - t1

# Printing the information to screen
print 'Scanning Completed in: ', total

error: pathspec 'scripts/portscan.sh' did not match any file(s) known to git


qa: test false

qa: test false

error: pathspec 'qa/workunits/false.sh' did not match any file(s) known to git


clear out old reject files before running tests

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/altamiracorp/honeycomb.git/'


update wallpaper

update wallpaper

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/alejandrogallo/dotfiles.git/'


Add release script.

Add release script.

#!/bin/bash

set -e

BRANCH_NAME='latest'

set +e
git branch -D ${BRANCH_NAME}
set -e

rm -rf lib
rm -rf node_modules

npm version patch
git branch ${BRANCH_NAME}
git checkout ${BRANCH_NAME}

npm install
grunt build
rm -rf node_modules
npm install --production
git add -f lib/
git add -f node_modules/
git commit -m "Update generated code and runtime dependencies."
git push --force origin ${BRANCH_NAME}

git checkout master
npm version patch
git push origin master
npm install

error: pathspec 'release-as-zip.sh' did not match any file(s) known to git


Create create_SelfService_Plug-in.sh

Create create_SelfService_Plug-in.sh

Initial creation of create_SelfService_Plug-in.sh

#!/bin/bash

##	Script:		create_SelfService_Plug-in.sh
##	Author:		Mike Morales
##	Last Change:	2015-01-11

function createPlugIn ()
{

echo "Starting Plug-in creation..."
echo "Checking for existing Plug-ins..."
sleep 0.5

if [ -d "/Library/Application Support/JAMF/" ]; then
	## Check for an existing Self Service Plug-ins directory
	if [ -d "/Library/Application Support/JAMF/Self Service/Plug-ins" ]; then
		pluginFolderExists="yes"
		destDir="/Library/Application Support/JAMF/Self Service/Plug-ins"

		## Capture a list of any installed plug-ins
		installedPlugIns=$(ls "/Library/Application Support/JAMF/Self Service/Plug-ins" | sed 's/.plist//g' | sort -g | awk '$1 > 999 {print}')

		## If any are in the 1000+ range, determine the next available ID
		if [ ! -z "$installedPlugIns" ]; then
			lastID=$(ls "/Library/Application Support/JAMF/Self Service/Plug-ins" | sed 's/.plist//g' | sort -g | awk '$1 > 999 {print}' | tail -1)

			nextID=$((lastID+1))
		else
			## If none are in the 1000+ range, set the ID to 1000
			nextID="1000"
		fi
	else
		## If there is no Plug-Ins folder, set the ID to 1000
		nextID="1000"

		echo "The Self Service Plug-ins folder doesn't exist on this Mac. Creating it now..."

		mkdir -p "/Library/Application Support/JAMF/Self Service/Plug-ins"
		chown root:admin "/Library/Application Support/JAMF/Self Service/Plug-ins"
		chmod -R 755 "/Library/Application Support/JAMF/Self Service/Plug-ins"

		pluginFolderExists="yes"
		destDir="/Library/Application Support/JAMF/Self Service/Plug-ins"

		sleep 0.5
	fi
else
	## The 'JAMF' directory does not exist on this Mac. Therefore, its an un-enrolled system
	echo -e "No '/Library/Application Support/JAMF' directory was found on this Mac.\nThe Plug-in will be saved to your Desktop."

	nextID="1000"
	destDir="/Users/$loggedInUser/Desktop"

	sleep 0.5
fi

## If an image was chosen, convert it to binary data
if [ ! -z "$ICON" ]; then
	echo "Converting image file to binary data..."
	sleep 0.5

	imageData=$(cat "$ICON" | base64)
fi

id="$nextID"
url="$URL"
title="$TITLE"
subtitle="$SUBTITLE"
priority="$PRIORITY"
openInBrowser="$OPENINBROWSER"
icon="$imageData"

echo "Creating $TITLE Plug-in..."
sleep 0.5

## Create the Plug-in plist file
echo "<?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>id</key>
    <string>$id</string>
    <key>version</key>
    <integer>1</integer>
    <key>url</key>
    <string>$url</string>
    <key>title</key>
    <string>$title</string>
    <key>priority</key>
    <string>$priority</string>
    <key>subtitle</key>
    <string>$subtitle</string>
    <key>openInBrowserAutomatically</key>
    <$openInBrowser/>
    <key>image</key>
    <data>$imageData</data>
  </dict>
</plist>" > "${destDir}/${id}.plist"

if [ "$?" == "0" ]; then
	if [ "$pluginFolderExists" == "yes" ]; then
		echo -e "The Plug-in has been saved to the location: ${destDir}/${id}.plist. Self Service should now show the Plug-in\n"
		exit 0
	else
		echo -e "The Plug-in has been saved to the location: ${destDir}/${id}.plist. If necessary, you can package this plug-in plist and deploy it to other Macs.\n"
		exit 0
	fi
else
	echo "We ran into an error while creating the Plug-in.
However, its possible the Plug-in was successfully saved. If its not showing up in Self Service,
try running this script again to create it."

	exit 1
fi
}

function finalSteps ()
{

if [ -z "$SUBTITLE" ]; then
	SUBTITLE_PRINT="* None chosen *"
else
	SUBTITLE_PRINT="$SUBTITLE"
fi

if [ -z "$ICON" ]; then
	ICON_PRINT="* None chosen *"
else
	ICON_PRINT="$ICON"
fi

finalText="Looks like we have everything we need.
Check the settings you chose below and press Enter or Return to create the Self Service URL Plug-in:

URL:			$URL
Title:			$TITLE
Description:		$SUBTITLE_PRINT
Priority:		$PRIORITY
Icon:			$ICON_PRINT
Open in browser: 	$OPENINBROWSER

If everything above looks good, press 'Enter' or 'Return' to create the Plug-in.
If you would like to start over, type in REDO and press Enter or Return"

echo "$finalText"

read PROCESS

if [ -z "$PROCESS" ]; then
	echo -e "Processing...\n"
	createPlugIn

elif [[ "$PROCESS" == "REDO" || "redo" ]]; then
	echo -e "Starting over...\n"
	sleep 0.5

	initialUsage
fi

}

function askBrowserPref ()
{

browserPrefText="Step 6: Choose if you would like the Plug-in to open in a default browser, or load into Self Service.
Type in \"yes\" for opening in an external browser, or press Enter/Return to have it open in Self Service."

echo "$browserPrefText"

read BROWSER

shopt -s nocasematch

if [[ ! -z "$BROWSER" ]] && [[ "$BROWSER" == "yes" ]]; then
	OPENINBROWSER="true"

	echo -e "Setting chosen was: \"Open in browser\" Continuing...\n"
	shopt -u nocasematch

	sleep 0.5
	finalSteps

else
	OPENINBROWSER="false"

	echo -e "Setting chosen was: \"Open in Self Service\" Continuing...\n"

	sleep 0.5
	finalSteps
fi

}

function askForIcon ()
{

if [ -z "$iconText" ]; then
	iconText="Step 5: Drag and drop an image file from the Finder to be used for the Plug-in icon (Optional but Recommended) and press Enter/Return
Preferred format is PNG at 128x128 pixels, but can also accept .GIF, .TIF or .JPG formats.
Also, square images (pixel dimensions) work best, otherwise the icon will get squished disportionately within Self Service.app."
fi

echo "$iconText"

read ICON

if [ -z "$ICON" ]; then
	echo -e "Icon selected: None. This Self Service Plug-in will be created without an icon. Continuing...\n"
	askBrowserPref
else
	## Test to make sure we see a GIF, PNG, TIF or JPEG/JPG extension
	extension="${ICON##*.}"
	ICON_NAME=$(basename $ICON)

	## Set up case insensitive matching
	shopt -s nocasematch

	case "$extension" in
	png|tif|gif|jpg|jpeg)
		echo -e "Icon selected: $ICON_NAME. Continuing...\n"

		## Disable case insensitivity
		shopt -u nocasematch
		askBrowserPref ;;
	*)
		iconText="We couldn't detect if the image ${ICON_NAME} is in one of the accepted formats. Please use only a png, gif, tif or jpeg/jpg and try again:"

		## Disable case insensitivity
		shopt -u nocasematch
		askForIcon ;;
	esac

fi

}

function askForPriority ()
{

if [ -z "$priorityText" ]; then
	priorityText="Step 4: Enter a numeric value (1-20) for the priority of the Plug-in (Optional) and press Enter or Return
Lower values mean the Plug-in will appear before others in the Self Service sidebar.
Note that you can leave a default value of 5 by pressing Enter or Return:"

fi

echo "$priorityText"

read PRIORITY

if [ -z "$PRIORITY" ]; then
	echo -e "No value assigned. Using a default of \"5\"\n"

	PRIORITY="5"

	sleep 0.5
	askForIcon

else
	## Test to make sure we received an integer value
	test=$(echo "$PRIORITY / $PRIORITY" | bc)
	if [ "$test" == "1" ]; then
		if [[ "$PRIORITY" -gt 0 ]] && [[ "$PRIORITY" -lt 21 ]]; then
			echo -e "Value entered: \"$PRIORITY\" Continuing...\n"
			sleep 0.5
			askForIcon
		else
			priorityText="Oops! We can only accept a number value between 1-20. Please try again, or press Enter or Return to use the default value:"

			askForPriority
		fi
	else
		priorityText="Oops! We can only accept a number value between 1-20. No letters or punctuation. Please try again, or press Enter or Return to use the default value:"

		askForPriority
	fi
fi

}

function askForSubtitle ()
{

subTitleText="Step 3: Enter a description for the Plug-in (Optional), then Press Enter or Return
(Note: If you don't want a description, simply press Enter or Return to continue:"

echo "$subTitleText"

read SUBTITLE

if [ -z "$SUBTITLE" ]; then
	echo -e "No description was specified. Continuing...\n"
	sleep 0.5
	askForPriority
else
	echo -e "Description entered: \"$SUBTITLE\" Continuing...\n"
	sleep 0.5
	askForPriority
fi

}
function askForTitle ()
{

if [ -z "$titleText" ]; then
	titleText="Step 2: Enter a title for the Plug-in (Required), then press Enter or Return:"
fi

echo "$titleText"

read TITLE

if [ -z "$TITLE" ]; then
	titleText="Oops! A Title is required! Enter a title for the Plug-in, then press Enter or Return:"
	askForTitle
else
	echo -e "Title entered: \"$TITLE\" Continuing...\n"
	sleep 0.5
	askForSubtitle
fi

}

function askForURL ()
{

if [ -z "$urlText" ]; then
	urlText="Step 1: Enter a URL to use for the Plug-in (Required), then press Enter or Return:"
fi

echo "$urlText"

read URL

if [ -z "$URL" ]; then
	urlText="Oops! A URL is required! Please enter a URL and press Enter or Return:"
	askForURL
else
	echo -e "URL entered was: \"$URL\" Continuing...\n"
	sleep 0.5
	askForTitle
fi

}

function initialUsage ()
{

startMessage="This script will guide you in generating a Self Service URL Plug-in.
By default, new Self Service URL plug-ins are generated with an ID in the 1000 plus range
so as to avoid any conflict with Plug-ins that may be set up on your JSS.

When ready to get started, just press 'Enter' or 'Return'. Otherwise, type 'exit' and press 'Return' to exit the script."

echo "$startMessage"

read BEGIN

if [ "$BEGIN" == "" ]; then
	echo -e "Starting...\n"
	sleep 0.5
	askForURL
elif [ "$BEGIN" == "exit" ]; then
	echo "Exiting. Good-bye!"
	exit 0
else
	initialUsage
fi

}

function checkForRoot ()
{

if [[ $EUID -ne 0 ]]; then
	echo -e "This script must be run as root. Please use 'sudo /path/to/script.sh' and try again\n"
	exit 1
else
	initialUsage
fi

}

checkForRoot

error: pathspec 'create_SelfService_Plug-in.sh' did not match any file(s) known to git


Added notes in source code explaining why 'rvm use 2.1' is in ~/.bashrc

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jhsu802701/packer-debian-jessie-old.git/'


Try to fix conflict in cabal

Try to fix conflict in cabal

#!/bin/bash

# Install the last version of pandoc on travis-CI if it is
# not already available in the cache
if [[ ! -f $HOME/.cabal/bin/pandoc ]]
then
    cabal update
    cabal install monad-control-0.3.1
    cabal install pandoc-1.15.1.1
else
    echo "Get pandoc from the cache"
fi

#!/bin/bash

# Install the last version of pandoc on travis-CI if it is
# not already available in the cache
if [[ ! -f $HOME/.cabal/bin/pandoc ]]
then
    cabal update
    cabal install pandoc-1.15.1.1
else
    echo "Get pandoc from the cache"
fi


Added git aliases

Added git aliases

alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias gp='git push origin HEAD'
alias gd='git diff'
alias gc='git commit'
alias gca='git commit -a'
alias gs='git status -sb' # upgrade your git if -sb breaks for you. it's fun.
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"

error: pathspec 'git/aliases.zsh' did not match any file(s) known to git


Fix seds treatment of tabs

Fix seds treatment of tabs

Per https://github.com/holman/dotfiles/commit/3d2a856d2475f8c7e6cff6117652f92542cb6247#commitcomment-3561553.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/fogine/dotfiles.git/'


Added a "Require all granted" to apache config

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/taeram/vagrant.git/'


Add generate script

Add generate script

rm -rf _site/
bundle exec jekyll build && rm -rf docs/
cp -r _site docs/
echo "blog.salkinium.com" > docs/CNAME

error: pathspec 'generate.sh' did not match any file(s) known to git


Pre-push ruby image for extended tests

Pre-push ruby image for extended tests

#!/bin/bash

set -o nounset
set -o pipefail

OS_ROOT=$(dirname "${BASH_SOURCE}")/..

source ${OS_ROOT}/hack/util.sh
source ${OS_ROOT}/hack/common.sh

TIME_SEC=1000
TIME_MIN=$((60 * $TIME_SEC))

# TODO: Randomize these ports
export OS_MASTER_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_ASSETS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_DNS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export ETCD_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)

DEFAULT_SERVER_IP=$(ifconfig | grep -Ev "(127.0.0.1|172.17.42.1)" | grep "inet " | head -n 1 | awk '{print $2}')

export OS_MASTER_ADDR=${DEFAULT_SERVER_IP}:${OS_MASTER_PORT}
export OS_ASSETS_ADDR=${DEFAULT_SERVER_IP}:${OS_ASSETS_PORT}
export OS_DNS_ADDR=${DEFAULT_SERVER_IP}:${OS_DNS_PORT}
export KUBERNETES_MASTER="https://${OS_MASTER_ADDR}"

export TMPDIR=${TMPDIR:-/tmp}
export BASETMPDIR="${TMPDIR}/openshift-extended-tests"

# Remove all test artifacts from the previous run
rm -rf ${BASETMPDIR} && mkdir -p ${BASETMPDIR}

# Setup directories and certificates for 'curl'
export CERT_DIR="${BASETMPDIR}/cert"
export CURL_CA_BUNDLE="${CERT_DIR}/ca/cert.crt"
export CURL_CERT="${CERT_DIR}/admin/cert.crt"
export CURL_KEY="${CERT_DIR}/admin/key.key"
export KUBECONFIG="${CERT_DIR}/admin/.kubeconfig"
export OPENSHIFT_ON_PANIC=crash

cleanup() {
    set +e
    server_pids=$(pgrep -P $(cat ${BASETMPDIR}/server.pid))
    kill $server_pids $(cat ${BASETMPDIR}/server.pid) ${ETCD_PID}
    rm -rf ${ETCD_DIR}
    echo "[INFO] Cleanup complete"
}

# TODO: There is a lot of code shared between this test launcher and e2e test
#       launcher.
start_server() {
  mkdir -p ${BASETMPDIR}/volumes
  ALL_IP_ADDRESSES=`ifconfig | grep "inet " | awk '{print $2}'`
  SERVER_HOSTNAME_LIST="${DEFAULT_SERVER_IP},localhost"
  while read -r IP_ADDRESS; do
    SERVER_HOSTNAME_LIST="${SERVER_HOSTNAME_LIST},${IP_ADDRESS}"
  done <<< "${ALL_IP_ADDRESSES}"

  echo "[INFO] Create certificates for the OpenShift server"
  sudo env "PATH=${PATH}" openshift admin create-all-certs \
  --overwrite=false \
  --cert-dir="${CERT_DIR}" \
  --hostnames="${SERVER_HOSTNAME_LIST}" \
  --nodes="127.0.0.1" \
  --master="https://${OS_MASTER_ADDR}" \
  --public-master="https://${OS_MASTER_ADDR}"

  echo "[INFO] Starting OpenShift server"
  sudo env "PATH=${PATH}" openshift start \
    --listen="https://0.0.0.0:${OS_MASTER_PORT}" \
    --public-master="https://${OS_MASTER_ADDR}" \
    --etcd="http://127.0.0.1:${ETCD_PORT}" \
    --hostname="127.0.0.1" \
    --create-certs=false \
    --cert-dir="${CERT_DIR}" \
    --volume-dir="${BASETMPDIR}/volumes" \
    --master="https://${OS_MASTER_ADDR}" \
    --latest-images \
    --loglevel=${VERBOSE:-3} &> ${BASETMPDIR}/server.log &
  echo -n $! > ${BASETMPDIR}/server.pid
}

start_docker_registry() {
  mkdir -p ${BASETMPDIR}/.registry
  echo "[INFO] Creating default Router"
  openshift ex router --create --credentials="${KUBECONFIG}" \
    --images='openshift/origin-${component}:latest' &>/dev/null

  echo "[INFO] Creating Docker Registry"
  openshift ex registry --create --credentials="${KUBECONFIG}" \
    --mount-host="${BASETMPDIR}/.registry" \
    --images='openshift/origin-${component}:latest' &>/dev/null
}

# Go to the top of the tree.
cd "${OS_ROOT}"

trap cleanup EXIT SIGINT

# Start the Etcd server
echo "[INFO] Starting etcd server (127.0.0.1:${ETCD_PORT})"
start_etcd
export ETCD_STARTED="1"

# Start OpenShift sever that will be common for all extended test cases
start_server

# Wait for the API server to come up
wait_for_url_timed "https://${OS_MASTER_ADDR}/healthz" "" 90*TIME_SEC >/dev/null
wait_for_url_timed "https://${OS_MASTER_ADDR}/osapi" "" 90*TIME_SEC >/dev/null
wait_for_url "https://${OS_MASTER_ADDR}/api/v1beta1/minions/127.0.0.1" "" 0.25 80 >/dev/null

# Start the Docker registry (172.30.17.101:5000)
start_docker_registry

wait_for_command '[[ "$(osc get endpoints docker-registry -t "{{ if .endpoints}}{{ len .endpoints }}{{ else }}0{{ end }}" 2>/dev/null || echo "0")" != "0" ]]' $((5*TIME_MIN))

REGISTRY_ADDR=$(osc get --output-version=v1beta1 --template="{{ .portalIP }}:{{.port }}" \
  service docker-registry)
echo "[INFO] Verifying the docker-registry is up at ${REGISTRY_ADDR}"
wait_for_url_timed "http://${REGISTRY_ADDR}" "" $((2*TIME_MIN))

# TODO: We need to pre-push the images that we use for builds to avoid getting
#       "409 - Image already exists" during the 'push' when the Build finishes.
#       This is because Docker Registry cannot handle parallel pushes.
#       See: https://github.com/docker/docker-registry/issues/537
echo "[INFO] Pushing openshift/ruby-20-centos7 image to ${REGISTRY_ADDR}"
docker tag openshift/ruby-20-centos7 ${REGISTRY_ADDR}/openshift/ruby-20-centos7
docker push ${REGISTRY_ADDR}/openshift/ruby-20-centos7 &>/dev/null

# Run all extended tests cases
echo "[INFO] Starting extended tests"
OS_TEST_PACKAGE="test/extended" OS_TEST_TAGS="extended" OS_TEST_NAMESPACE="extended" ${OS_ROOT}/hack/test-integration.sh $@

#!/bin/bash

set -o nounset
set -o pipefail

OS_ROOT=$(dirname "${BASH_SOURCE}")/..

source ${OS_ROOT}/hack/util.sh
source ${OS_ROOT}/hack/common.sh

TIME_SEC=1000
TIME_MIN=$((60 * $TIME_SEC))

# TODO: Randomize these ports
export OS_MASTER_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_ASSETS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_DNS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export ETCD_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)

DEFAULT_SERVER_IP=$(ifconfig | grep -Ev "(127.0.0.1|172.17.42.1)" | grep "inet " | head -n 1 | awk '{print $2}')

export OS_MASTER_ADDR=${DEFAULT_SERVER_IP}:${OS_MASTER_PORT}
export OS_ASSETS_ADDR=${DEFAULT_SERVER_IP}:${OS_ASSETS_PORT}
export OS_DNS_ADDR=${DEFAULT_SERVER_IP}:${OS_DNS_PORT}
export KUBERNETES_MASTER="https://${OS_MASTER_ADDR}"

export TMPDIR=${TMPDIR:-/tmp}
export BASETMPDIR="${TMPDIR}/openshift-extended-tests"

# Remove all test artifacts from the previous run
rm -rf ${BASETMPDIR} && mkdir -p ${BASETMPDIR}

# Setup directories and certificates for 'curl'
export CERT_DIR="${BASETMPDIR}/cert"
export CURL_CA_BUNDLE="${CERT_DIR}/ca/cert.crt"
export CURL_CERT="${CERT_DIR}/admin/cert.crt"
export CURL_KEY="${CERT_DIR}/admin/key.key"
export KUBECONFIG="${CERT_DIR}/admin/.kubeconfig"
export OPENSHIFT_ON_PANIC=crash

cleanup() {
    set +e
    server_pids=$(pgrep -P $(cat ${BASETMPDIR}/server.pid))
    kill $server_pids $(cat ${BASETMPDIR}/server.pid) ${ETCD_PID}
    rm -rf ${ETCD_DIR}
    echo "[INFO] Cleanup complete"
}

# TODO: There is a lot of code shared between this test launcher and e2e test
#       launcher.
start_server() {
  mkdir -p ${BASETMPDIR}/volumes
  ALL_IP_ADDRESSES=`ifconfig | grep "inet " | awk '{print $2}'`
  SERVER_HOSTNAME_LIST="${DEFAULT_SERVER_IP},localhost"
  while read -r IP_ADDRESS; do
    SERVER_HOSTNAME_LIST="${SERVER_HOSTNAME_LIST},${IP_ADDRESS}"
  done <<< "${ALL_IP_ADDRESSES}"

  echo "[INFO] Create certificates for the OpenShift server"
  sudo env "PATH=${PATH}" openshift admin create-all-certs \
  --overwrite=false \
  --cert-dir="${CERT_DIR}" \
  --hostnames="${SERVER_HOSTNAME_LIST}" \
  --nodes="127.0.0.1" \
  --master="https://${OS_MASTER_ADDR}" \
  --public-master="https://${OS_MASTER_ADDR}"

  echo "[INFO] Starting OpenShift server"
  sudo env "PATH=${PATH}" openshift start \
    --listen="https://0.0.0.0:${OS_MASTER_PORT}" \
    --public-master="https://${OS_MASTER_ADDR}" \
    --etcd="http://127.0.0.1:${ETCD_PORT}" \
    --hostname="127.0.0.1" \
    --create-certs=false \
    --cert-dir="${CERT_DIR}" \
    --volume-dir="${BASETMPDIR}/volumes" \
    --master="https://${OS_MASTER_ADDR}" \
    --latest-images \
    --loglevel=${VERBOSE:-3} &> ${BASETMPDIR}/server.log &
  echo -n $! > ${BASETMPDIR}/server.pid
}

start_docker_registry() {
  mkdir -p ${BASETMPDIR}/.registry
  echo "[INFO] Creating default Router"
  openshift ex router --create --credentials="${KUBECONFIG}" \
    --images='openshift/origin-${component}:latest' &>/dev/null

  echo "[INFO] Creating Docker Registry"
  openshift ex registry --create --credentials="${KUBECONFIG}" \
    --mount-host="${BASETMPDIR}/.registry" \
    --images='openshift/origin-${component}:latest' &>/dev/null
}

# Go to the top of the tree.
cd "${OS_ROOT}"

trap cleanup EXIT SIGINT

# Start the Etcd server
echo "[INFO] Starting etcd server (127.0.0.1:${ETCD_PORT})"
start_etcd
export ETCD_STARTED="1"

# Start OpenShift sever that will be common for all extended test cases
start_server

# Wait for the API server to come up
wait_for_url_timed "https://${OS_MASTER_ADDR}/healthz" "" 90*TIME_SEC >/dev/null
wait_for_url_timed "https://${OS_MASTER_ADDR}/osapi" "" 90*TIME_SEC >/dev/null
wait_for_url "https://${OS_MASTER_ADDR}/api/v1beta1/minions/127.0.0.1" "" 0.25 80 >/dev/null

# Start the Docker registry (172.30.17.101:5000)
start_docker_registry

wait_for_command '[[ "$(osc get endpoints docker-registry -t "{{ if .endpoints}}{{ len .endpoints }}{{ else }}0{{ end }}" 2>/dev/null || echo "0")" != "0" ]]' $((5*TIME_MIN))

REGISTRY_ADDR=$(osc get --output-version=v1beta1 --template="{{ .portalIP }}:{{.port }}" \
  service docker-registry)
echo "[INFO] Verifying the docker-registry is up at ${REGISTRY_ADDR}"
wait_for_url_timed "http://${REGISTRY_ADDR}" "" $((2*TIME_MIN))

# Run all extended tests cases
echo "[INFO] Starting extended tests"
OS_TEST_PACKAGE="test/extended" OS_TEST_TAGS="extended" OS_TEST_NAMESPACE="extended" ${OS_ROOT}/hack/test-integration.sh $@


CESA: add one fix

CESA: add one fix

#!/bin/sh
# CYBERWATCH SAS - 2016
#
# Security fix for CESA-2016:1086
#
# Security announcement date: 2016-05-17 22:20:14 UTC
# Script generation date:     2016-05-20 08:06:58 UTC
#
# Operating System: CentOS 7
# Architecture: x86_64
#
# Vulnerable packages fix on version:
#   - libndp.i686:1.2-6.el7_2
#   - libndp.x86_64:1.2-6.el7_2
#   - libndp-devel.i686:1.2-6.el7_2
#   - libndp-devel.x86_64:1.2-6.el7_2
#
# Last versions recommanded by security team:
#   - libndp.i686:1.2-6.el7_2
#   - libndp.x86_64:1.2-6.el7_2
#   - libndp-devel.i686:1.2-6.el7_2
#   - libndp-devel.x86_64:1.2-6.el7_2
#
# CVE List:
#   - CVE-2016-3698
#
# More details:
#   - https://www.cyberwatch.fr/vulnerabilites
#
# Licence: Released under The MIT License (MIT), See LICENSE FILE
sudo yum install libndp.i686-1.2 -y
sudo yum install libndp.x86_64-1.2 -y
sudo yum install libndp-devel.i686-1.2 -y
sudo yum install libndp-devel.x86_64-1.2 -y

error: pathspec 'CentOS_7/x86_64/2016/CESA-2016:1086.sh' did not match any file(s) known to git


A third party script supplied by dbcan to parse hmmer output

#!/usr/bin/env sh

# Yanbin Yin
# 07/21/2015
# hmmscan output parser
# Usage: sh hmmscan-parser.sh hmmscan-output-file

# 1. take hmmer3 --domtblout output and extract necessary columns
# 2. sort on the protein position columns
# 3. remove overlapped/redundant hmm matches and keep the one with the lower e-values
# 4. calculate the covered fraction of hmm &
#    apply the E-value cutoff and the covered faction cutoff

cat $1 | grep -v '^#' | awk '{print $1,$3,$4,$6,$13,$16,$17,$18,$19}' | sed 's/ /\t/g' | \
	sort -k 3,3 -k 8n -k 9n | \
	perl -e 'while(<>){chomp;@a=split;next if $a[-1]==$a[-2];push(@{$b{$a[2]}},$_);}foreach(sort keys %b){@a=@{$b{$_}};for($i=0;$i<$#a;$i++){@b=split(/\t/,$a[$i]);@c=split(/\t/,$a[$i+1]);$len1=$b[-1]-$b[-2];$len2=$c[-1]-$c[-2];$len3=$b[-1]-$c[-2];if($len3>0 and ($len3/$len1>0.5 or $len3/$len2>0.5)){if($b[4]<$c[4]){splice(@a,$i+1,1);}else{splice(@a,$i,1);}$i=$i-1;}}foreach(@a){print $_."\n";}}' | \
	perl -e 'while(<>){chomp;@a=split(/\t/,$_);if(($a[-1]-$a[-2])>80){print $_,"\t",($a[-3]-$a[-4])/$a[1],"\n" if $a[4]<1e-5;}else{print $_,"\t",($a[-3]-$a[-4])/$a[1],"\n" if $a[4]<1e-3;}}' | awk '$NF>0.3' | sort -k 3 -k 8,9g

error: pathspec 'third_party_scripts/dbcan/hmmscan-parser.sh' did not match any file(s) known to git


feat: update deploy script

feat: update deploy script

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ahonn/ahonn.github.io.git/'


fix the line of doctrine proxies generation in deploy.sh

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/lpirola/mapasculturais.git/'


add install keyword

add install keyword

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Mausy5043/raspboot.git/'


Remove mamp completions

Remove mamp completions

#!/usr/bin/env bash
# completions.sh
# Caleb Evans

# Retrieve list of brew taps added on this system (much faster than `brew tap`)
__get_brew_taps() {
	for parent_dir in "$BREW_TAPS_DIR"/*; do
		local parent_dir_name="$(basename "$parent_dir")"
		for child_dir in "$parent_dir"/*; do
			local child_dir_name="$(basename "$child_dir")"
			echo "$parent_dir_name"/"${child_dir_name/#homebrew-/}"
		done
	done
}

# The pattern used for matching Homebrew package/cask names
BREW_NAME_PATT='[a-z0-9\-]+(?=\.rb)'
# The directory containing all Homebrew taps
BREW_TAPS_DIR=/usr/local/Homebrew/Library/Taps

# Retrieve list of installed Homebrew packages
__get_installed_brew_packages() {
	ls -1 /usr/local/Cellar
}

# Retrieve list of versions for the given package
__get_brew_package_versions() {
	if [ -d /usr/local/Cellar/"$1" ]; then
		ls -1 /usr/local/Cellar/"$1"
	fi
}

# Retrieve list of installed Homebrew casks
__get_installed_brew_casks() {
	ls -1 /usr/local/Caskroom
}

# Retrieve list of all available Homebrew packages
__get_all_brew_packages() {
	ls "$BREW_TAPS_DIR"/homebrew/*/Formula | grep -oP "$BREW_NAME_PATT"
}

# Retrieve list of all available Homebrew casks
__get_all_brew_casks() {
	ls "$BREW_TAPS_DIR"/homebrew/*/Casks | grep -oP "$BREW_NAME_PATT"
}

# Completion function for brew, the macOS package manager
_brew() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}
	third=${COMP_WORDS[2]}

	if [ "$prev" == 'brew' -o "$prev" == 'help' ]; then
		# Complete common brew commands for `brew`
		COMPREPLY=( $(compgen -W 'cask cleanup deps doctor help info install leaves link linkapps outdated pin prune reinstall remove rmtree search switch tap uninstall unlink unlinkapps unpin untap update upgrade uses' -- $cur) )
	elif [ "$first" == 'brew' -a "$prev" == 'cask' ]; then
		# Complete common cask commands for `brew cask`
		COMPREPLY=( $(compgen -W 'cleanup doctor help info install list reinstall search uninstall upgrade' -- $cur) )
	elif [ "$second" == 'list' -o "$second" == 'ls' ]; then
		# Complete list options for `brew list` and `brew ls`
		COMPREPLY=( $(compgen -W "--full-name --pinned --multiple --versions $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'reinstall' -o "$second" == 'remove' -o "$second" == 'rm' -o "$second" == 'rmtree' -o "$second" == 'uninstall' ]; then
		# Complete installed packages for brew package removal commands
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'cleanup' ]; then
		# Complete options and installed packages for `brew cleanup`
		COMPREPLY=( $(compgen -W "--dry-run $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'pin' -o "$second" == 'unpin' ]; then
		# Complete installed packages for brew pin commands
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'untap' ]; then
		# Complete all installed taps for `brew tap`
		COMPREPLY=( $(compgen -W "$(__get_brew_taps)" -- $cur) )
	elif [ "$second" == 'upgrade' ]; then
		# Complete options and installed packages for `brew upgrade`
		COMPREPLY=( $(compgen -W "--all --cleanup $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'install' -o "$second" == 'info' ]; then
		# Complete all available packages for `brew install`
		COMPREPLY=( $(compgen -W "$(__get_all_brew_packages)" -- $cur) )
	elif [ "$second" == 'deps' -o "$second" == 'uses' ]; then
		# Complete options and all available packages for `brew deps` and `brew uses`
		COMPREPLY=( $(compgen -W "--installed $(__get_all_brew_packages)" -- $cur) )
	elif [ "$prev" == 'switch' ]; then
		# Complete installed package names for first argument of `brew switch`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'switch' ]; then
		# Complete package versions for second argument of `brew switch`
		COMPREPLY=( $(compgen -W "$(__get_brew_package_versions "$prev")" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'info' ]; then
		# Complete all available casks for `brew cask info`
		COMPREPLY=( $(compgen -W "$(__get_all_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'install' ]; then
		# Complete options and all casks for `brew cask install`
		COMPREPLY=( $(compgen -W "--force $(__get_all_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'reinstall' ]; then
		# Complete installed casks for `brew cask reinstall`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'upgrade' ]; then
		# Complete installed casks for `brew cask upgrade`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'uninstall' ]; then
		# Complete installed casks for `brew cask uninstall`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	fi

}
complete -o default -F _brew brew

# Completion function for npm and bower, the Node-based package managers
_npm() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'npm' -o "$prev" == 'bower' -o "$prev" == 'help' ]; then
		# Complete common npm commands for `npm`
		COMPREPLY=( $(compgen -W 'cache help info init install link list outdated prune publish search show start stop test uninstall unlink unpublish update upgrade' -- $cur) )
	elif [ "$prev" == 'install' -o "$prev" == 'uninstall' ]; then
		# Complete common options for `npm install` and `npm uninstall`
		COMPREPLY=( $(compgen -W '--global --save --save-dev' -- $cur) )
	elif [ "$prev" == 'cache' ]; then
		# Complete subcommands for `npm cache`
		COMPREPLY=( $(compgen -W 'clean' -- $cur) )
	fi

}
complete -o default -F _npm npm bower

# Completion function for Grunt, the JavaScript task runner
_grunt() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'grunt' ]; then
		# Complete Grunt tasks standard to all of my Grunt-based projects
		COMPREPLY=( $(compgen -W 'build serve watch --help' -- $cur) )
	fi

}
complete -o default -F _grunt grunt

# Completion function for pip, Python's package manager
_pip() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}
	third=${COMP_WORDS[2]}

	if [ "$prev" == 'pip' -o "$prev" == 'pip2' -o "$prev" == 'pip3' -o "$prev" == 'help' ]; then
		# Complete common pip commands for `pip`
		COMPREPLY=( $(compgen -W 'freeze help install list search show uninstall' -- $cur) )
	elif [ "$prev" == '>' -o "$prev" == '-r' ]; then
		# Complete filenames when output is being redirected or for `pip install -r`
		COMPREPLY=()
	elif [ "$prev" == 'list'  ]; then
		# Complete options for `pip list`
		COMPREPLY=( $(compgen -W '--editable --local --outdated --uptodate' -- $cur) )
	elif [ "$prev" == 'show' -o "$second" == 'uninstall' -o "$third" == '-U' ]; then
		# Complete installed packages for `pip show` and `pip uninstall`
		if [ -z "$PIP_PKG_LIST" -o "$PWD" != "$PIP_PKG_PWD" ]; then
			# Cache package list for the current PWD
			PIP_PKG_LIST="$($first list '[a-z0-9\-]+(?= )' 2> /dev/null)"
			PIP_PKG_PWD="$PWD"
		fi
		COMPREPLY=( $(compgen -W "$PIP_PKG_LIST" -- $cur) )
	fi

}
complete -o default -F _pip pip pip2 pip3

# Completion function for apm, Atom's package manager
_apm() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'apm' -o "$prev" == 'help' ]; then
		# Complete common apm commands for `apm`
		COMPREPLY=( $(compgen -W 'clean develop help install list link login publish pull push search show star stars uninstall unstar update upgrade' -- $cur) )
	elif [ "$prev" == 'update' -o "$prev" == 'upgrade' ]; then
		# Complete options for `apm update` and `apm upgrade`
		COMPREPLY=( $(compgen -W '--list --no-confirm' -- $cur) )
	elif [ "$prev" == 'show' -o "$prev" == 'uninstall' ]; then
		# Complete installed packages for `apm show` and `apm uninstall`
		local pkg_list="$(ls ~/.atom/packages 2> /dev/null)"
		COMPREPLY=( $(compgen -W "$pkg_list" -- $cur) )
	fi

}
complete -o default -F _apm apm

# Completion function for Bundler, the Ruby package manager
_bundle() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	if [ "$prev" == 'bundle' -o "$prev" == 'help' ]; then
		# Complete common bundle commands for `bundle`
		COMPREPLY=( $(compgen -W 'check clean exec help init install list lock outdated package show update' -- $cur) )
	elif [ "$second" == 'exec' ]; then
		# Complete any shell command for `bundle exec`
		# This makes `bundle exec` behave like `command` and `exec` completion
		_command
	fi

}
complete -o default -F _bundle bundle bundler

# Completion function for jekyll, the static site generator
_jekyll() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	if [ "$prev" == 'jekyll' -o "$prev" == 'help' ]; then
		# Complete common jekyll commands for `jekyll`
		COMPREPLY=( $(compgen -W 'build clean doctor help new serve' -- $cur) )
	elif [ "$second" == 'build' ]; then
		# Complete options for `jekyll build`
		COMPREPLY=( $(compgen -W '--destination --source --trace --watch' -- $cur) )
	elif [ "$prev" == '--source' -o "$prev" == '--destination' ]; then
		# Complete filenames for `--source` and `--destination`
		COMPREPLY=()
	fi

}
complete -o default -F _jekyll jekyll

# Completion function for python/python3 binaries
_python() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	# Complete package and module paths
	if [ "$second" == '-m' ]; then
		# Convert current query file path (with /) to module path (with .)
		local curpath="${cur//./\/}"
		# Get package names matching current query; exclude hidden directories
		local packages="$(compgen -d -- $curpath | grep -Po '([a-z_]+/)*([a-z_]+)\b')"
		# Convert Python file paths to package paths
		packages="${packages//\//.}"
		if [ -n "$packages" ]; then
			# Apepnd . to package name completions for convenience (since user
			# will type a module name next, this eliminates the need for them to
			# type a . first)
			packages="${packages// /. }."
			# Ensure that no spaces follow completed package names
			compopt -o nospace
		fi
		# Get module names matching curent query; include only .py files
		local modules="$(compgen -f -- $curpath | grep -Po '([a-z_]+/)*([a-z_]+)\.py')"
		# Convert Python file paths to module paths
		modules="${modules//\//.}"
		# Remove .py extension (all module names omit the .py extension)
		modules="${modules//.py/}"
		COMPREPLY=( $(compgen -W "$packages $modules" -- $cur) )
	fi

}
complete -o default -F _python python
complete -o default -F _python python3

# Completion function for apachectl, Apache's HTTP server utility
_apachectl() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'apachectl' -o "$prev" == 'help' ]; then
		# Complete common apachectl commands for `apachectl`
		COMPREPLY=( $(compgen -W 'configtest restart start stop' -- $cur) )
	fi

}
complete -o default -F _apachectl apachectl

# Completion function for pypi, a custom function for interacting with PyPI
_pypi() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'pypi' ]; then
		# Complete shortcuts to common pypi operations for `pypi`
		COMPREPLY=( $(compgen -W 'register test upload' -- $cur) )
	fi

}
complete -o default -F _pypi pypi

# Completion function for mkvirtualenv, a function for creating new Python
# virtualenvs
_mkvirtualenv() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'mkvirtualenv' ]; then
		# Complete shortcuts to common mkvirtualenv operations for `mkvirtualenv`
		COMPREPLY=( $(compgen -W 'python python3' -- $cur) )
	fi

}
complete -o default -F _mkvirtualenv mkvirtualenv

# Completion function for awp, my Alfred Workflow Packager utility
_awp() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}

	if [ "$first" == 'awp' ]; then
		# Complete common commands for `awp`
		COMPREPLY=( $(compgen -W '--export --help --validate --version' -- $cur) )
	elif [ "$prev" == '--export' ]; then
		# Complete file/directory paths whenever `--export` option is supplied
		COMPREPLY=()
	fi

}
complete -o default -F _awp awp

#!/usr/bin/env bash
# completions.sh
# Caleb Evans

# Retrieve list of brew taps added on this system (much faster than `brew tap`)
__get_brew_taps() {
	for parent_dir in "$BREW_TAPS_DIR"/*; do
		local parent_dir_name="$(basename "$parent_dir")"
		for child_dir in "$parent_dir"/*; do
			local child_dir_name="$(basename "$child_dir")"
			echo "$parent_dir_name"/"${child_dir_name/#homebrew-/}"
		done
	done
}

# The pattern used for matching Homebrew package/cask names
BREW_NAME_PATT='[a-z0-9\-]+(?=\.rb)'
# The directory containing all Homebrew taps
BREW_TAPS_DIR=/usr/local/Homebrew/Library/Taps

# Retrieve list of installed Homebrew packages
__get_installed_brew_packages() {
	ls -1 /usr/local/Cellar
}

# Retrieve list of versions for the given package
__get_brew_package_versions() {
	if [ -d /usr/local/Cellar/"$1" ]; then
		ls -1 /usr/local/Cellar/"$1"
	fi
}

# Retrieve list of installed Homebrew casks
__get_installed_brew_casks() {
	ls -1 /usr/local/Caskroom
}

# Retrieve list of all available Homebrew packages
__get_all_brew_packages() {
	ls "$BREW_TAPS_DIR"/homebrew/*/Formula | grep -oP "$BREW_NAME_PATT"
}

# Retrieve list of all available Homebrew casks
__get_all_brew_casks() {
	ls "$BREW_TAPS_DIR"/homebrew/*/Casks | grep -oP "$BREW_NAME_PATT"
}

# Completion function for brew, the macOS package manager
_brew() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}
	third=${COMP_WORDS[2]}

	if [ "$prev" == 'brew' -o "$prev" == 'help' ]; then
		# Complete common brew commands for `brew`
		COMPREPLY=( $(compgen -W 'cask cleanup deps doctor help info install leaves link linkapps outdated pin prune reinstall remove rmtree search switch tap uninstall unlink unlinkapps unpin untap update upgrade uses' -- $cur) )
	elif [ "$first" == 'brew' -a "$prev" == 'cask' ]; then
		# Complete common cask commands for `brew cask`
		COMPREPLY=( $(compgen -W 'cleanup doctor help info install list reinstall search uninstall upgrade' -- $cur) )
	elif [ "$second" == 'list' -o "$second" == 'ls' ]; then
		# Complete list options for `brew list` and `brew ls`
		COMPREPLY=( $(compgen -W "--full-name --pinned --multiple --versions $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'reinstall' -o "$second" == 'remove' -o "$second" == 'rm' -o "$second" == 'rmtree' -o "$second" == 'uninstall' ]; then
		# Complete installed packages for brew package removal commands
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'cleanup' ]; then
		# Complete options and installed packages for `brew cleanup`
		COMPREPLY=( $(compgen -W "--dry-run $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'pin' -o "$second" == 'unpin' ]; then
		# Complete installed packages for brew pin commands
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'untap' ]; then
		# Complete all installed taps for `brew tap`
		COMPREPLY=( $(compgen -W "$(__get_brew_taps)" -- $cur) )
	elif [ "$second" == 'upgrade' ]; then
		# Complete options and installed packages for `brew upgrade`
		COMPREPLY=( $(compgen -W "--all --cleanup $(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'install' -o "$second" == 'info' ]; then
		# Complete all available packages for `brew install`
		COMPREPLY=( $(compgen -W "$(__get_all_brew_packages)" -- $cur) )
	elif [ "$second" == 'deps' -o "$second" == 'uses' ]; then
		# Complete options and all available packages for `brew deps` and `brew uses`
		COMPREPLY=( $(compgen -W "--installed $(__get_all_brew_packages)" -- $cur) )
	elif [ "$prev" == 'switch' ]; then
		# Complete installed package names for first argument of `brew switch`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_packages)" -- $cur) )
	elif [ "$second" == 'switch' ]; then
		# Complete package versions for second argument of `brew switch`
		COMPREPLY=( $(compgen -W "$(__get_brew_package_versions "$prev")" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'info' ]; then
		# Complete all available casks for `brew cask info`
		COMPREPLY=( $(compgen -W "$(__get_all_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'install' ]; then
		# Complete options and all casks for `brew cask install`
		COMPREPLY=( $(compgen -W "--force $(__get_all_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'reinstall' ]; then
		# Complete installed casks for `brew cask reinstall`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'upgrade' ]; then
		# Complete installed casks for `brew cask upgrade`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	elif [ "$second" == 'cask' -a "$third" == 'uninstall' ]; then
		# Complete installed casks for `brew cask uninstall`
		COMPREPLY=( $(compgen -W "$(__get_installed_brew_casks)" -- $cur) )
	fi

}
complete -o default -F _brew brew

# Completion function for npm and bower, the Node-based package managers
_npm() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'npm' -o "$prev" == 'bower' -o "$prev" == 'help' ]; then
		# Complete common npm commands for `npm`
		COMPREPLY=( $(compgen -W 'cache help info init install link list outdated prune publish search show start stop test uninstall unlink unpublish update upgrade' -- $cur) )
	elif [ "$prev" == 'install' -o "$prev" == 'uninstall' ]; then
		# Complete common options for `npm install` and `npm uninstall`
		COMPREPLY=( $(compgen -W '--global --save --save-dev' -- $cur) )
	elif [ "$prev" == 'cache' ]; then
		# Complete subcommands for `npm cache`
		COMPREPLY=( $(compgen -W 'clean' -- $cur) )
	fi

}
complete -o default -F _npm npm bower

# Completion function for Grunt, the JavaScript task runner
_grunt() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'grunt' ]; then
		# Complete Grunt tasks standard to all of my Grunt-based projects
		COMPREPLY=( $(compgen -W 'build serve watch --help' -- $cur) )
	fi

}
complete -o default -F _grunt grunt

# Completion function for pip, Python's package manager
_pip() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}
	third=${COMP_WORDS[2]}

	if [ "$prev" == 'pip' -o "$prev" == 'pip2' -o "$prev" == 'pip3' -o "$prev" == 'help' ]; then
		# Complete common pip commands for `pip`
		COMPREPLY=( $(compgen -W 'freeze help install list search show uninstall' -- $cur) )
	elif [ "$prev" == '>' -o "$prev" == '-r' ]; then
		# Complete filenames when output is being redirected or for `pip install -r`
		COMPREPLY=()
	elif [ "$prev" == 'list'  ]; then
		# Complete options for `pip list`
		COMPREPLY=( $(compgen -W '--editable --local --outdated --uptodate' -- $cur) )
	elif [ "$prev" == 'show' -o "$second" == 'uninstall' -o "$third" == '-U' ]; then
		# Complete installed packages for `pip show` and `pip uninstall`
		if [ -z "$PIP_PKG_LIST" -o "$PWD" != "$PIP_PKG_PWD" ]; then
			# Cache package list for the current PWD
			PIP_PKG_LIST="$($first list '[a-z0-9\-]+(?= )' 2> /dev/null)"
			PIP_PKG_PWD="$PWD"
		fi
		COMPREPLY=( $(compgen -W "$PIP_PKG_LIST" -- $cur) )
	fi

}
complete -o default -F _pip pip pip2 pip3

# Completion function for apm, Atom's package manager
_apm() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'apm' -o "$prev" == 'help' ]; then
		# Complete common apm commands for `apm`
		COMPREPLY=( $(compgen -W 'clean develop help install list link login publish pull push search show star stars uninstall unstar update upgrade' -- $cur) )
	elif [ "$prev" == 'update' -o "$prev" == 'upgrade' ]; then
		# Complete options for `apm update` and `apm upgrade`
		COMPREPLY=( $(compgen -W '--list --no-confirm' -- $cur) )
	elif [ "$prev" == 'show' -o "$prev" == 'uninstall' ]; then
		# Complete installed packages for `apm show` and `apm uninstall`
		local pkg_list="$(ls ~/.atom/packages 2> /dev/null)"
		COMPREPLY=( $(compgen -W "$pkg_list" -- $cur) )
	fi

}
complete -o default -F _apm apm

# Completion function for Bundler, the Ruby package manager
_bundle() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	if [ "$prev" == 'bundle' -o "$prev" == 'help' ]; then
		# Complete common bundle commands for `bundle`
		COMPREPLY=( $(compgen -W 'check clean exec help init install list lock outdated package show update' -- $cur) )
	elif [ "$second" == 'exec' ]; then
		# Complete any shell command for `bundle exec`
		# This makes `bundle exec` behave like `command` and `exec` completion
		_command
	fi

}
complete -o default -F _bundle bundle bundler

# Completion function for jekyll, the static site generator
_jekyll() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	if [ "$prev" == 'jekyll' -o "$prev" == 'help' ]; then
		# Complete common jekyll commands for `jekyll`
		COMPREPLY=( $(compgen -W 'build clean doctor help new serve' -- $cur) )
	elif [ "$second" == 'build' ]; then
		# Complete options for `jekyll build`
		COMPREPLY=( $(compgen -W '--destination --source --trace --watch' -- $cur) )
	elif [ "$prev" == '--source' -o "$prev" == '--destination' ]; then
		# Complete filenames for `--source` and `--destination`
		COMPREPLY=()
	fi

}
complete -o default -F _jekyll jekyll

# Completion function for python/python3 binaries
_python() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}
	second=${COMP_WORDS[1]}

	# Complete package and module paths
	if [ "$second" == '-m' ]; then
		# Convert current query file path (with /) to module path (with .)
		local curpath="${cur//./\/}"
		# Get package names matching current query; exclude hidden directories
		local packages="$(compgen -d -- $curpath | grep -Po '([a-z_]+/)*([a-z_]+)\b')"
		# Convert Python file paths to package paths
		packages="${packages//\//.}"
		if [ -n "$packages" ]; then
			# Apepnd . to package name completions for convenience (since user
			# will type a module name next, this eliminates the need for them to
			# type a . first)
			packages="${packages// /. }."
			# Ensure that no spaces follow completed package names
			compopt -o nospace
		fi
		# Get module names matching curent query; include only .py files
		local modules="$(compgen -f -- $curpath | grep -Po '([a-z_]+/)*([a-z_]+)\.py')"
		# Convert Python file paths to module paths
		modules="${modules//\//.}"
		# Remove .py extension (all module names omit the .py extension)
		modules="${modules//.py/}"
		COMPREPLY=( $(compgen -W "$packages $modules" -- $cur) )
	fi

}
complete -o default -F _python python
complete -o default -F _python python3

# Completion function for MAMP, the Apache-MySQL-PHP stack app
_mamp() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'mamp' ]; then
		# Complete common MAMP commands for `mamp`
		COMPREPLY=( $(compgen -W 'restart start stop' -- $cur) )
	fi

}
complete -o default -F _mamp mamp

# Completion function for apachectl, Apache's HTTP server utility
_apachectl() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'apachectl' -o "$prev" == 'help' ]; then
		# Complete common apachectl commands for `apachectl`
		COMPREPLY=( $(compgen -W 'configtest restart start stop' -- $cur) )
	fi

}
complete -o default -F _apachectl apachectl

# Completion function for pypi, a custom function for interacting with PyPI
_pypi() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'pypi' ]; then
		# Complete shortcuts to common pypi operations for `pypi`
		COMPREPLY=( $(compgen -W 'register test upload' -- $cur) )
	fi

}
complete -o default -F _pypi pypi

# Completion function for mkvirtualenv, a function for creating new Python
# virtualenvs
_mkvirtualenv() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	if [ "$prev" == 'mkvirtualenv' ]; then
		# Complete shortcuts to common mkvirtualenv operations for `mkvirtualenv`
		COMPREPLY=( $(compgen -W 'python python3' -- $cur) )
	fi

}
complete -o default -F _mkvirtualenv mkvirtualenv

# Completion function for awp, my Alfred Workflow Packager utility
_awp() {

	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	first=${COMP_WORDS[0]}

	if [ "$first" == 'awp' ]; then
		# Complete common commands for `awp`
		COMPREPLY=( $(compgen -W '--export --help --validate --version' -- $cur) )
	elif [ "$prev" == '--export' ]; then
		# Complete file/directory paths whenever `--export` option is supplied
		COMPREPLY=()
	fi

}
complete -o default -F _awp awp


refactor(zsh/gpg): ensure GPG_TTY variable is set

# From gpg-agent(1):
#
# You should always add the following lines to your .bashrc  or  whatever
# initialization file is used for all shell invocations:
#
#   GPG_TTY=$(tty)
#   export GPG_TTY
#
# It is important that this environment variable always reflects the out‐
# put of the tty command.

export GPG_TTY=$(tty)

error: pathspec 'zsh/.config/oh-my-zsh/custom/gpg.zsh' did not match any file(s) known to git