Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into b0.8.1
Browse files Browse the repository at this point in the history
Merge fixes for installers
  • Loading branch information
banasiakadam60 committed Sep 21, 2017
2 parents ee4049f + 2a18936 commit b3f6509
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 63 deletions.
143 changes: 98 additions & 45 deletions Installer/Installer_Linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,18 @@
#title :install.sh
#description :This script will install Golem and required dependencies
#author :Golem Team
#email :contact@golemnetwork.com
#date :20170711
#version :0.3
#email :contact@golem.network
#date :20170920
#version :0.4
#usage :sh install.sh
#notes :Only for Ubuntu and Mint
#==============================================================================

function release_url()
{
json=$(wget -qO- --header='Accept: application/json' $1)
echo ${json} | python -c '\
import sys, json; \
j = json.load(sys.stdin); \
k = "browser_download_url"; \
print([asset[k] for entry in j \
if "assets" in entry \
for asset in entry["assets"] \
if asset[k].find("linux") != -1 \
][0])'
}

# CONSTANTS
declare -r HOME=$(readlink -f ~)
declare -r CONFIG="$HOME/.local/.golem_version"
declare -r golem_package=$(release_url "https://api.github.com/repos/golemfactory/golem/releases")
declare -r docker_checksum='d41d8cd98f00b204e9800998ecf8427e'
declare -r docker_script='docker_install.sh'
declare -r version_file='version'
declare -r hyperg=$(release_url "https://api.github.com/repos/mfranciszkiewicz/golem-hyperdrive/releases")
declare -r ui_package_url=$(release_url "https://api.github.com/repos/golemfactory/golem-electron/releases")
declare -r hyperg_pack=/tmp/hyperg.tar.gz
declare -r PACKAGE="golem-linux.tar.gz"
declare -r ELECTRON_PACKAGE="electron.tar.gz"
Expand All @@ -49,7 +31,8 @@ PACKAGE_VERSION="0.1.0"
# PARAMS
LOCAL_PACKAGE=""
UI_PACKAGE=""
DEPS_ONLY=0
declare -i DEPS_ONLY=0
declare -i DEVELOP=0

# @brief print error message
# @param error message
Expand Down Expand Up @@ -91,7 +74,22 @@ function ask_user()
done
}

# @brief check if dependencies (pip, Docker, and Ethereum) are installed and set proper 'global' variables
function release_url()
{
json=$(wget -qO- --header='Accept: application/json' $1)
echo ${json} | python -c '\
import sys, json; \
j = json.load(sys.stdin); \
k = "browser_download_url"; \
print([asset[k] for entry in j \
if "assets" in entry \
for asset in entry["assets"] \
if asset[k].find("linux") != -1 \
][0])'
}

# @brief check if dependencies (pip, Docker, and Ethereum)
# are installed and set proper 'global' variables
function check_dependencies()
{
# Check if docker daemon exists
Expand All @@ -107,6 +105,7 @@ function check_dependencies()
fi
}


# @brief Install/Upgrade required dependencies
function install_dependencies()
{
Expand All @@ -117,6 +116,11 @@ function install_dependencies()
exit 1
fi

declare -a packages=( openssl pkg-config libjpeg-dev libopenexr-dev \
libssl-dev autoconf libgmp-dev libtool qt5-default libffi-dev \
libgtk2.0-0 libxss1 libgconf-2-4 libnss3 libasound2 \
ethereum )

if [[ ${INSTALL_GETH} -eq 1 ]]; then
info_msg "INSTALLING GETH"
sudo apt-get install -y -q software-properties-common >/dev/null
Expand All @@ -125,23 +129,30 @@ function install_dependencies()

if [[ ${INSTALL_DOCKER} -eq 1 ]]; then
info_msg "INSTALLING DOCKER"
wget -qO- https://get.docker.com > /tmp/${docker_script}
if [[ "$( md5sum /tmp/${docker_script} | awk '{print $1}' )" == "$docker_checksum" ]]; then
bash /tmp/${docker_script} >/dev/null
if [[ $? -ne 0 ]]; then
warning_msg "Cannot install docker. Install it manually: https://docs.docker.com/engine/installation/"
sleep 5s
fi
if [[ $UID -ne 0 ]]; then
sudo usermod -aG docker ${USER}
fi
else
warning_msg "Cannot install docker. Install it manually: https://docs.docker.com/engine/installation/"
sleep 5s

# Ubuntu 14.04 needs some additional dependencies
if [[ $( lsb_release -r | awk '{print $2}' ) == '14.04' ]]; then
packages+=("linux-image-extra-$(uname -r)" linux-image-extra-virtual)
fi
rm -f /tmp/${docker_script}

packages+=( apt-transport-https \
ca-certificates \
software-properties-common)
wget -qO- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
fi

docker_version="$(apt-cache madison docker-ce 2>/dev/null | head -1 | awk '{print $3}')"
if [[ -z "${docker_version}" ]]; then
packages+=(docker-ce)
else
packages+=(docker-ce=${docker_version})
fi

declare -r hyperg=$(release_url "https://api.github.com/repos/mfranciszkiewicz/golem-hyperdrive/releases")
hyperg_release=$( echo ${hyperg} | cut -d '/' -f 8 | sed 's/v//' )
# Older version of HyperG doesn't have `--version`, so need to kill
( hyperg_version=$( hyperg --version 2>/dev/null ) ) & pid=$!
Expand All @@ -162,15 +173,25 @@ function install_dependencies()
rm -f ${hyperg_pack} &>/dev/null
fi
sudo apt-get update >/dev/null
declare -a packages=( openssl pkg-config libjpeg-dev libopenexr-dev \
libssl-dev autoconf libgmp-dev libtool qt5-default libffi-dev \
libgtk2.0-0 libxss1 libgconf-2-4 libnss3 libasound2 \
ethereum docker-engine )
echo -e "\e[91m"
for package in ${packages[*]}; do
sudo apt-get install -q -y ${package} >/dev/null
done
echo -e "\e[39m"
if [[ ${INSTALL_DOCKER} -eq 1 ]]; then
if [[ -z "${SUDO_USER}" ]]; then
sudo usermod -aG docker ${USER}
else
sudo usermod -aG docker ${SUDO_USER}
fi
sudo docker run hello-world &>/dev/null
if [[ ${?} -eq 0 ]]; then
info_msg "Docker installed successfully"
else
warning_msg "Error occurred during installation"
sleep 5s
fi
fi
info_msg "Done installing Golem dependencies"
}

Expand All @@ -182,7 +203,12 @@ function download_package() {
cp "$LOCAL_PACKAGE" "/tmp/$PACKAGE"
else
info_msg "Downloading Golem package"
wget -qO- "$golem_package" > /tmp/${PACKAGE}
if [[ ${DEVELOP} -eq 0 ]]; then
golem_url=$(release_url "https://api.github.com/repos/golemfactory/golem/releases")
else
golem_url=$(release_url "https://api.github.com/repos/golemfactory/golem-dev/releases")
fi
wget -qO- ${golem_url} > /tmp/${PACKAGE}
fi
if [[ ! -f /tmp/${PACKAGE} ]]; then
error_msg "Cannot find Golem package"
Expand All @@ -195,7 +221,12 @@ function download_package() {
cp ${UI_PACKAGE} /tmp/${ELECTRON_PACKAGE}
else
info_msg "Downloading ui package (it may take awhile)"
wget -qO- ${ui_package_url} > /tmp/${ELECTRON_PACKAGE}
if [[ ${DEVELOP} -eq 0 ]]; then
electron_url=$(release_url "https://api.github.com/repos/golemfactory/golem-electron/releases")
else
electron_url=$(release_url "https://api.github.com/repos/golemfactory/golem-electron-dev/releases")
fi
wget -qO- ${electron_url} > /tmp/${ELECTRON_PACKAGE}
fi
if [[ ! -f /tmp/${ELECTRON_PACKAGE} ]]; then
error_msg "Cannot find Electron package"
Expand All @@ -217,7 +248,12 @@ function check_symlink()
[[ ${point_to} == ${source} ]] && return 0
sudo rm -f ${destination} 2>/dev/null
sudo ln -s ${source} ${destination}
return $?
res=${?}
if [[ -n "${SUDO_USER}" ]]; then
sudo chown ${SUDO_USER}:${SUDO_USER} ${destination}
sudo -H -u ${SUDO_USER} chmod 755 ${destination}
fi
return ${res}
}

# @brief Download and install golem
Expand All @@ -232,6 +268,10 @@ function install_golem()
fi

tar -zxvf /tmp/${PACKAGE} >/dev/null
if [[ ${?} -ne 0 ]]; then
error_msg "ERROR) Cannot extract ${PACKAGE}. Exiting..."
return 1
fi
PACKAGE_DIR=$( find . -maxdepth 1 -name "golem-*" -type d -print | head -n1 )
if [[ ! -d ${PACKAGE_DIR} ]]; then
error_msg "Error extracting package"
Expand All @@ -257,6 +297,10 @@ function install_golem()
rm -rf ${PACKAGE_DIR} &>/dev/null

tar -zxvf /tmp/${ELECTRON_PACKAGE} >/dev/null
if [[ ${?} -ne 0 ]]; then
error_msg "ERROR) Cannot extract ${ELECTRON_PACKAGE}. Exiting..."
return 1
fi
ELECTRON_DIR=$(find . -maxdepth 1 -name "linux-unpacked" -type d -print | head -n1)
if [[ ! -d ${ELECTRON_DIR} ]]; then
error_msg "Error extracting package"
Expand All @@ -269,6 +313,11 @@ function install_golem()
rm -rf /tmp/${ELECTRON_PACKAGE} &>/dev/null
rm -rf ${ELECTRON_DIR} &>/dev/null

if [[ -n "${SUDO_USER}" ]]; then
sudo chown -R ${SUDO_USER}:${SUDO_USER} ${GOLEM_DIR}
sudo -H -u ${SUDO_USER} chmod -R 755 ${GOLEM_DIR}
fi

result=0
check_symlink ${GOLEM_DIR}/electron/golem /usr/local/bin/golem
result=$(( ${result} + $? ))
Expand Down Expand Up @@ -304,7 +353,8 @@ function help_message() {
echo -e "\e[4mOptions:\e[0m"
echo -e " -g, --golem package with Golem"
echo -e " -u, --ui package with UI"
echo -e " -d, --deps-only Install only dependencies without Golem"
echo -e " -d, --deps-only install only dependencies without Golem"
echo -e " -dev, --develop install develop version"
echo -e " -h, --help print this message"
echo
}
Expand All @@ -329,6 +379,9 @@ while [[ $# -ge 1 ]]; do
UI_PACKAGE="$2"
shift # past argument
;;
-dev|--develop)
DEVELOP=1
;;
-h|--help)
help_message
exit 0
Expand Down
7 changes: 4 additions & 3 deletions Installer/Installer_Win/install_script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
; https://www.microsoft.com/pl-pl/download/details.aspx?id=48145 vc_redist.x64.exe
; https://www.microsoft.com/en-us/download/details.aspx?id=44266
; https://download.docker.com/win/stable/DockerToolbox.exe
; https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.6.7-ab5646c5.exe
; https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.7.0-6c6c7b2a.exe
#define Repository "C:\golem"
#expr Exec("powershell.exe python setup.py pyinstaller", "", Repository, 1)
#expr Exec("powershell.exe python Installer\Installer_Win\version.py", "", Repository, 1)
#define MyAppVersion ReadIni(Repository+"\\.version.ini", "version", "version", "0.1.0")
#define MyAppNumber ReadIni(Repository+"\\.version.ini", "version", "number", "0.1.0")
#expr Exec("powershell.exe Remove-Item .version.ini", "", Repository, 1)
#define AppIcon "favicon.ico"
#define Geth "geth-windows-amd64-1.7.0-6c6c7b2a.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
Expand Down Expand Up @@ -67,7 +68,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
Source: "{#Repository}\dist\golem-{#MyAppNumber}\*"; DestDir: {app}; Flags: ignoreversion recursesubdirs
Source: "{#Repository}\Installer\Installer_Win\deps\win-unpacked\*"; DestDir: {app}; Flags: ignoreversion recursesubdirs
Source: "{#Repository}\Installer\Installer_Win\deps\DockerToolbox.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Source: "{#Repository}\Installer\Installer_Win\deps\geth-windows-amd64-1.6.7-ab5646c5.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Source: "{#Repository}\Installer\Installer_Win\deps\{#Geth}"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Source: "{#Repository}\Installer\Installer_Win\deps\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
; @todo temporary - until VBox 5.1.26 won't be installed by DockerToolbox
Source: "{#Repository}\Installer\Installer_Win\deps\VirtualBox-5.1.26-117224-Win.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Expand All @@ -90,7 +91,7 @@ Filename: "{tmp}\DockerToolbox.exe"; Parameters: "/VERYSILENT"; StatusMsg: "Inst
Filename: "{tmp}\VirtualBox-5.1.26-117224-Win.exe"; Parameters: "--silent"; StatusMsg: "Installing VirtualBox"; Description: "Install VirtualBox";

; Install geth
Filename: "{tmp}\geth-windows-amd64-1.6.7-ab5646c5.exe"; StatusMsg: "Installing geth"; Description: "Install geth"; Check: NeedsAddPath('Geth');
Filename: "{tmp}\{#Geth}"; StatusMsg: "Installing geth"; Description: "Install geth"; Check: NeedsAddPath('Geth');

[Code]
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
46 changes: 31 additions & 15 deletions setup_util/setup_commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ def run(self):
print("> Copying chain")
self.copy_chain(dist_dir)

if not is_windows():
print("> Compressing distribution")
tar_dir = self.move(dist_dir)
tar_file = self.compress(tar_dir, dist_dir)
print("> Archive saved: '{}'".format(tar_file))
print("> Compressing distribution")
archive_dir = self.move(dist_dir)
archive_file = self.compress(archive_dir, dist_dir)
print("> Archive saved: '{}'".format(archive_file))

def banner(self, msg):
print("\n> --------------------------------")
Expand Down Expand Up @@ -139,33 +138,50 @@ def move(self, dist_dir):
shutil.move(path.join(dist_dir, 'apps'), ver_dir)
shutil.move(path.join(dist_dir, 'examples'), ver_dir)
shutil.move(path.join(dist_dir, 'golem'), ver_dir)
shutil.move(path.join(dist_dir, 'golemapp'), ver_dir)
shutil.move(path.join(dist_dir, 'golemcli'), ver_dir)
if is_windows():
shutil.move(path.join(dist_dir, 'golemapp.exe'), ver_dir)
shutil.move(path.join(dist_dir, 'golemcli.exe'), ver_dir)
else:
shutil.move(path.join(dist_dir, 'golemapp'), ver_dir)
shutil.move(path.join(dist_dir, 'golemcli'), ver_dir)

return ver_dir

def compress(self, src_dir, dist_dir):
import tarfile

tar_file = self.get_tarball_path(dist_dir)
with tarfile.open(tar_file, "w:gz") as tar:
tar.add(src_dir, arcname=path.basename(src_dir))
return tar_file
archive_file = self.get_archive_path(dist_dir)
if not is_windows():
import tarfile

def get_tarball_path(self, dist_dir):
with tarfile.open(archive_file, "w:gz") as tar:
tar.add(src_dir, arcname=path.basename(src_dir))
else:
import zipfile
zf = zipfile.ZipFile(archive_file, "w")
for dirname, _, files in walk(src_dir):
zf.write(dirname)
for filename in files:
zf.write(path.join(dirname, filename))
zf.close()
return archive_file

def get_archive_path(self, dist_dir):
if self.package_path:
return self.package_path

extension = 'tar.gz'
if is_osx():
sys_name = 'macos'
elif is_linux():
sys_name = 'linux_x64'
elif is_windows():
sys_name = 'win32'
extension = 'zip'
else:
raise EnvironmentError("Unsupported OS: {}".format(sys.platform))

version = get_version()
return path.join(dist_dir,
'golem-{}-{}.tar.gz'.format(sys_name, version))
'golem-{}-{}.{}'.format(sys_name, version, extension))


def get_long_description(my_path):
Expand Down

0 comments on commit b3f6509

Please sign in to comment.