<commit_before>#!/bin/bash

############## Start Of Variable and Functions Declaration ###########

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR=/tmp/glbuilding.$RANDOM
BUILD_LOG=${BUILD_DIR}.log
TMP_KEYRING=${BUILD_DIR}/tmpkeyring.gpg
DISTRO='unknown'
DISTRO_VERSION='unknown'

if [ -f /etc/redhat-release ]; then
  DISTRO="fedora"
# Debian/Ubuntu
elif [ -r /lib/lsb/init-functions ]; then
  if [ "$( lsb_release -is )" == "Debian" ]; then
    DISTRO="debian"
    DISTRO_VERSION="$( lsb_release -ci )"
  else
    DISTRO="ubuntu"
    DISTRO_VERSION="$( lsb_release -ci )"
  fi
fi

echo "Performing installation on $DISTRO - $DISTRO_VERSION"

if [ $DISTRO != 'ubuntu' ]; then
  echo "!!!!!!!!!!!! WARNING !!!!!!!!!!!!"
  echo "You are attempting to install GlobaLeaks on an unsupported platform."
  echo "Do you wish to continue at your own risk [Y|N]? "
  read ans
  if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
  then
    echo "Ok, you wanted it!"
  else
    echo "Ok, no worries. Still friends, right?"
    exit
  fi
fi

usage()
{
cat << EOF
usage: ./${SCRIPTNAME} options

OPTIONS:
   -h      Show this message
   -y      To assume yes to all queries

EOF
}

ASSUME_YES=0
while getopts “hv:ny” OPTION
do
  case $OPTION in
    h)
      usage
      exit 1
      ;;
    y)
      ASSUME_YES=1
      ;;
    ?)
      usage
      exit
      ;;
    esac
done

DO () {
    if [ -z "$2" ]; then
        RET=0
    else
        RET=$2
    fi
    if [ -z "$3" ]; then
        CMD=$1
    else
        CMD=$3
    fi
    echo -n "Running: \"$CMD\"... "
    $1 &>${BUILD_LOG}
    if [ "$?" -eq "$2" ]; then
        echo "SUCCESS"
    else
        echo "FAIL"
        echo "COMBINED STDOUT/STDERR OUTPUT OF FAILED COMMAND:"
        cat ${BUILD_LOG}
        exit 1
    fi
}

add_repository () {
  # Distro independent function for adding a line to apt sources.list
  REPO="$(echo $1 | sed 's/DISTRO_VERSION/${DISTRO_VERSION}/')"
  if which add-apt-repository >/dev/null 2>&1;then
    add-apt-repository -y "$REPO"
  else
    if grep -Fxq "$REPO" /etc/apt/sources.list
    then
      echo "Repository already present. Not adding it..."
    else
      echo $REPO >> /etc/apt/sources.list
    fi
  fi
}

vercomp () {
    # Returnned values:
    #   0: version are equals
    #   1: $1 is bigger than $2
    #   2: $2 is bigger than $1
    if [[ $1 == $2 ]]
    then
        return 0
    fi
    local IFS=.
    local i ver1=($1) ver2=($2)
    # fill empty fields in ver1 with zeros
    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
    do
        ver1[i]=0
    done
    for ((i=0; i<${#ver1[@]}; i++))
    do
        if [[ -z ${ver2[i]} ]]
        then
            # fill empty fields in ver2 with zeros
            ver2[i]=0
        fi
        if ((10#${ver1[i]} > 10#${ver2[i]}))
        then
            return 1
        fi
        if ((10#${ver1[i]} < 10#${ver2[i]}))
        then
            return 2
        fi
    done
    return 0
}

GLOBALEAKS_KEY_FILE=${BUILD_DIR}/gl-pub-key.gpg
GLOBALEAKS_PUB_KEY="
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.3+
Comment: Hostname: <EMAIL>

mQINBFFtX2EBEADWMQ9CpB55LcQzg1JS2oCzOcHN3oWQwfluIJltFPzbUC8KSTJrrSKghSIz
gA9C5ltoFgqwhZCiwQX0sFHLHw0+WQLXDqyRcJWCmL1GVIvAN1xW5aPAjvZ14TJJiajYF+q0
v2Lm8JCtD4hk1QcpJE+IOiSMMDqu9nM9ic8+xJZKYYhlCUWvAWKTORhRhYhImJkV5P6soozv
/rHizXnQW4rzsTPSlMh8cptVx4PL9ShIrmNC9oyIdBFLGskOk9IxE6vW16YocQgwkFkT4KGI
hvq3fUyJSj+AmoxmThvY+9Y5eN8FQdFh/hH/ndU8+I9U/tDKFdII+A6tl0sbrnFKw0AG++dZ
7ZMeRFKFi76xyGAS1Juqbgatc35U3V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Os9Hy
w+h9qMDRWa2i+z4droSr3aMsygU6LXDOIzdx8xP4XZiicxjerM9WCg6wI2uP6ctb02NREdeY
YLVNCFNht1+sWENybv7jTjcclbugBa7Uh/Kx9uOl3LD7umtXetz/Cgz/NoXvH/5x9kGg9coc
sy6yk7X2958hjzcuF0gRrvXDGydPHXHZX0EqU1GxXttAlwKv0M2GmOMP6R3qZ7zbRJgjqASn
zqVf1q8vkVMT7BlPxa8tfLxKb6/DAHIYiMh4f6dmYtoPI52adMCeeGTtxidSCao6Nhs9Ur3Z
bvvP2iSrPnzrzYmA5v81ncnvNsC0vABZsVqs3k6zQnuc3jq/AP2vFkmcDfq9D2WpQ6jR8znn
5sXraODYkc8q+Kp/6M8AMrsnrl4XgdHwm60TID1TmkL/x0Qe5AmVHLnX4Bv4MZwqGVeWUmKT
P/C52ALX08WJ34OtmJMZ1SihV+3+EWhA+tU=
=x4Mn<commit_msg>updated PGP key with renewed one<commit_after>#!/bin/bash

############## Start Of Variable and Functions Declaration ###########

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR=/tmp/glbuilding.$RANDOM
BUILD_LOG=${BUILD_DIR}.log
TMP_KEYRING=${BUILD_DIR}/tmpkeyring.gpg
DISTRO='unknown'
DISTRO_VERSION='unknown'

if [ -f /etc/redhat-release ]; then
  DISTRO="fedora"
# Debian/Ubuntu
elif [ -r /lib/lsb/init-functions ]; then
  if [ "$( lsb_release -is )" == "Debian" ]; then
    DISTRO="debian"
    DISTRO_VERSION="$( lsb_release -ci )"
  else
    DISTRO="ubuntu"
    DISTRO_VERSION="$( lsb_release -ci )"
  fi
fi

echo "Performing installation on $DISTRO - $DISTRO_VERSION"

if [ $DISTRO != 'ubuntu' ]; then
  echo "!!!!!!!!!!!! WARNING !!!!!!!!!!!!"
  echo "You are attempting to install GlobaLeaks on an unsupported platform."
  echo "Do you wish to continue at your own risk [Y|N]? "
  read ans
  if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
  then
    echo "Ok, you wanted it!"
  else
    echo "Ok, no worries. Still friends, right?"
    exit
  fi
fi

usage()
{
cat << EOF
usage: ./${SCRIPTNAME} options

OPTIONS:
   -h      Show this message
   -y      To assume yes to all queries

EOF
}

ASSUME_YES=0
while getopts “hv:ny” OPTION
do
  case $OPTION in
    h)
      usage
      exit 1
      ;;
    y)
      ASSUME_YES=1
      ;;
    ?)
      usage
      exit
      ;;
    esac
done

DO () {
    if [ -z "$2" ]; then
        RET=0
    else
        RET=$2
    fi
    if [ -z "$3" ]; then
        CMD=$1
    else
        CMD=$3
    fi
    echo -n "Running: \"$CMD\"... "
    $1 &>${BUILD_LOG}
    if [ "$?" -eq "$2" ]; then
        echo "SUCCESS"
    else
        echo "FAIL"
        echo "COMBINED STDOUT/STDERR OUTPUT OF FAILED COMMAND:"
        cat ${BUILD_LOG}
        exit 1
    fi
}

add_repository () {
  # Distro independent function for adding a line to apt sources.list
  REPO="$(echo $1 | sed 's/DISTRO_VERSION/${DISTRO_VERSION}/')"
  if which add-apt-repository >/dev/null 2>&1;then
    add-apt-repository -y "$REPO"
  else
    if grep -Fxq "$REPO" /etc/apt/sources.list
    then
      echo "Repository already present. Not adding it..."
    else
      echo $REPO >> /etc/apt/sources.list
    fi
  fi
}

vercomp () {
    # Returnned values:
    #   0: version are equals
    #   1: $1 is bigger than $2
    #   2: $2 is bigger than $1
    if [[ $1 == $2 ]]
    then
        return 0
    fi
    local IFS=.
    local i ver1=($1) ver2=($2)
    # fill empty fields in ver1 with zeros
    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
    do
        ver1[i]=0
    done
    for ((i=0; i<${#ver1[@]}; i++))
    do
        if [[ -z ${ver2[i]} ]]
        then
            # fill empty fields in ver2 with zeros
            ver2[i]=0
        fi
        if ((10#${ver1[i]} > 10#${ver2[i]}))
        then
            return 1
        fi
        if ((10#${ver1[i]} < 10#${ver2[i]}))
        then
            return 2
        fi
    done
    return 0
}

GLOBALEAKS_KEY_FILE=${BUILD_DIR}/gl-pub-key.gpg
GLOBALEAKS_PUB_KEY="
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (GNU/Linux)

<KEY>
{'fraction_non_alphanumeric': 0.1192650693026754, 'fraction_numerical': 0.05845062855914903, 'mean_word_length': 3.445081184336199, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494544', 'n_tokens_mistral': 4891, 'n_tokens_neox': 4531, 'n_words': 706}