Add a Jenkinsfile for continuous integration
This commit is contained in:
parent
42a327501e
commit
a1fe98b7a3
|
@ -0,0 +1,10 @@
|
||||||
|
pipeline {
|
||||||
|
agent {label 'msspec_agent_amd64'}
|
||||||
|
stages {
|
||||||
|
stage('Initial setup...') {
|
||||||
|
steps {
|
||||||
|
echo 'Create or update the virtual Python environment'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
280
src/install.sh
280
src/install.sh
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# vim: set ts=4 sw=4 sts noet mouse=a fdm=indent:
|
||||||
|
|
||||||
PYTHON=python3
|
PYTHON=python3
|
||||||
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
||||||
|
@ -6,7 +7,8 @@ DEFAULT_DEST="${HOME}/.local/share"
|
||||||
DEFAULT_BIN="${HOME}/.local/bin"
|
DEFAULT_BIN="${HOME}/.local/bin"
|
||||||
BYPASS="n"
|
BYPASS="n"
|
||||||
DEBUG="n"
|
DEBUG="n"
|
||||||
TIMEOUT=5
|
TIMEOUT=0
|
||||||
|
DEST_ALREADY_EXISTS="n"
|
||||||
|
|
||||||
|
|
||||||
ECHO="/bin/echo -e"
|
ECHO="/bin/echo -e"
|
||||||
|
@ -24,6 +26,20 @@ init_install () {
|
||||||
${ECHO} "Installation started on $(date)" > ${LOGFILE}
|
${ECHO} "Installation started on $(date)" > ${LOGFILE}
|
||||||
${ECHO} "0" > ${GETOUTFILE}
|
${ECHO} "0" > ${GETOUTFILE}
|
||||||
get_os
|
get_os
|
||||||
|
|
||||||
|
if [ "$BYPASS" = "n" ]; then
|
||||||
|
${ECHO} "Thanks for choosing MsSpec"
|
||||||
|
${ECHO} ""
|
||||||
|
${ECHO} "This program will install the MsSpec distribution on your computer"
|
||||||
|
${ECHO} -n "Press C^c to cancel now... "
|
||||||
|
for i in $(seq -s" " 0 $TIMEOUT); do
|
||||||
|
${ECHO} -n "\b";
|
||||||
|
${ECHO} -n $(( $TIMEOUT-i ));
|
||||||
|
sleep 1;
|
||||||
|
done
|
||||||
|
${ECHO} ""
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abort_install () {
|
abort_install () {
|
||||||
|
@ -32,7 +48,13 @@ abort_install () {
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message () {
|
log_message () {
|
||||||
${ECHO} "$1" >> ${LOGFILE}
|
printf "$1\n" >> ${LOGFILE}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message2 () {
|
||||||
|
# echo to screen and to file
|
||||||
|
printf "$1\n"
|
||||||
|
log_message "$1\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
|
@ -42,15 +64,18 @@ cleanup () {
|
||||||
|
|
||||||
error_exit () {
|
error_exit () {
|
||||||
# An error occured
|
# An error occured
|
||||||
${ECHO} ""
|
printf "\n"
|
||||||
${ECHO} " /!\ An error occured during the installation process."
|
printf " /!\ An error occured during the installation process.\n"
|
||||||
${ECHO} " Please see the $(basename ${LOGFILE}) file in your HOME folder"
|
printf " Please see the $(basename ${LOGFILE}) file in your HOME folder\n"
|
||||||
${ECHO} " for more informations. "
|
printf " for more informations.\n"
|
||||||
${ECHO} " Below is an excerpt of the last 10 lines: "
|
printf " Below is an excerpt of the last 10 lines:\n"
|
||||||
${ECHO} ""
|
printf "\n"
|
||||||
tail -v -n 10 "${LOGFILE}"
|
tail -v -n 10 "${LOGFILE}"
|
||||||
|
|
||||||
|
# if the DEST_FOLDER existed before, do NOT delete it
|
||||||
|
if [ x"$DEST_ALREADY_EXISTS" = "xn" ]; then
|
||||||
rm -rf ${DEST_FOLDER} 2>/dev/null
|
rm -rf ${DEST_FOLDER} 2>/dev/null
|
||||||
|
fi
|
||||||
cleanup && exit 1
|
cleanup && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,26 +94,48 @@ get_os () {
|
||||||
|
|
||||||
|
|
||||||
read_yes_no () {
|
read_yes_no () {
|
||||||
PROMPT="$1"
|
|
||||||
DEFAULT="$2"
|
DEFAULT="$2"
|
||||||
#BYPASS="$3"
|
PROMPT="$1 (y/n) [${DEFAULT}]? "
|
||||||
|
|
||||||
ANSWER=""
|
ANSWER=""
|
||||||
RESPONSE=""
|
RESPONSE=""
|
||||||
|
|
||||||
VALID=1
|
VALID=1
|
||||||
while test $VALID -ne 0; do
|
while test $VALID -ne 0; do
|
||||||
test "$BYPASS" = "y" || read -p "${PROMPT} (y/n) [${DEFAULT}]? " "RESPONSE"
|
printf "${PROMPT}"
|
||||||
|
if [ x"$BYPASS" = "xn" ]; then
|
||||||
|
read "RESPONSE"
|
||||||
|
else
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
ANSWER="${RESPONSE:-${DEFAULT}}"
|
ANSWER="${RESPONSE:-${DEFAULT}}"
|
||||||
case "${ANSWER}" in
|
case "${ANSWER}" in
|
||||||
y|n) VALID=0 ;;
|
y|n) VALID=0 ;;
|
||||||
*) echo "Invalid choice, please answer \"y\" or \"n\"."; VALID=1 ;;
|
*) printf "Invalid choice, please answer \"y\" or \"n\".\n"; VALID=1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
log_message "QUESTION: $PROMPT"
|
||||||
|
log_message "ANSWER : $ANSWER"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
read_folder () {
|
||||||
|
DEFAULT="$2"
|
||||||
|
PROMPT="$1 [${DEFAULT}]: "
|
||||||
|
|
||||||
|
ANSWER=""
|
||||||
|
unset FOLDER
|
||||||
|
printf "${PROMPT}"
|
||||||
|
if [ x"$BYPASS" = "xn" ]; then
|
||||||
|
read "ANSWER"
|
||||||
|
else
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
|
export FOLDER="${ANSWER:-$DEFAULT}"
|
||||||
|
log_message "QUESTION: $PROMPT"
|
||||||
|
log_message "ANSWER : $FOLDER"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
create_folder () {
|
create_folder () {
|
||||||
|
@ -103,47 +150,17 @@ create_folder () {
|
||||||
|
|
||||||
case "${ANSWER}" in
|
case "${ANSWER}" in
|
||||||
y) mkdir -p "${FOLDER}" 2>>${LOGFILE} 1>>${LOGFILE} || return $ERR_MKDIR;;
|
y) mkdir -p "${FOLDER}" 2>>${LOGFILE} 1>>${LOGFILE} || return $ERR_MKDIR;;
|
||||||
n) ${ECHO} "Installation aborted by the user" >>${LOGFILE} && return $ERR_ABORT ;;
|
n) log_message2 "Installation aborted by the user" && return $ERR_ABORT ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -w "${FOLDER}" ; then
|
if ! test -w "${FOLDER}" ; then
|
||||||
${ECHO} "You do not have permission to write into \"${FOLDER}\"." >>${LOGFILE}
|
log_message2 "You do not have permission to write into \"${FOLDER}\"."
|
||||||
return $ERR_PERMS
|
return $ERR_PERMS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
common_install () {
|
|
||||||
case $LINUX_OS in
|
|
||||||
ubuntu) # raise privileges
|
|
||||||
#sudo ${ECHO} "" || exit ;
|
|
||||||
wrap "ubuntu_prerequistes" "Installing Ubuntu specific packages" ;
|
|
||||||
;;
|
|
||||||
mageia) stty -echo; printf "Please enter root password: "; read PASSWORD; stty echo; printf "\n";
|
|
||||||
wrap "mageia_prerequistes" "Installing Mageia specific packages" ;
|
|
||||||
;;
|
|
||||||
*) # message for other linux distrib
|
|
||||||
${ECHO} "Please make sure BEFORE going on with the install program"
|
|
||||||
${ECHO} "that you do have already installed on your computer the"
|
|
||||||
${ECHO} "following list of softwares or libraries:"
|
|
||||||
${ECHO} ""
|
|
||||||
cat ./distro-requirements
|
|
||||||
${ECHO} ""
|
|
||||||
if test "$BYPASS" = "n"; then
|
|
||||||
read -p "Type y to go on, or type n to quit: " "ANSWER"
|
|
||||||
case $ANSWER in
|
|
||||||
y) ;;
|
|
||||||
*) exit 1 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wrap () {
|
wrap () {
|
||||||
log_message "================================================================================"
|
log_message "================================================================================"
|
||||||
log_message "$2"
|
log_message "$2"
|
||||||
|
@ -162,93 +179,6 @@ wrap () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
local_install () {
|
|
||||||
init_install
|
|
||||||
|
|
||||||
if [ "$BYPASS" = "n" ]; then
|
|
||||||
${ECHO} "Thanks for choosing MsSpec"
|
|
||||||
${ECHO} ""
|
|
||||||
${ECHO} "This program will install the MsSpec distribution on your computer"
|
|
||||||
${ECHO} -n "Press C^c to cancel now... "
|
|
||||||
for i in $(seq -s" " 0 $TIMEOUT); do
|
|
||||||
${ECHO} -n "\b";
|
|
||||||
${ECHO} -n $(( $TIMEOUT-i ));
|
|
||||||
sleep 1;
|
|
||||||
done
|
|
||||||
${ECHO} ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
ANSWER=""
|
|
||||||
test "$BYPASS" = "y" || read -p "Please, type in the folder where to place the binary ["${DEFAULT_BIN}"]: " "ANSWER"
|
|
||||||
BIN_FOLDER="${ANSWER:-$DEFAULT_BIN}"
|
|
||||||
create_folder "${BIN_FOLDER}" || error_exit
|
|
||||||
export BIN_FOLDER
|
|
||||||
|
|
||||||
# If in a virtualenv, ask if we should install inside
|
|
||||||
if [ x"$VIRTUAL_ENV" != x ]; then
|
|
||||||
echo "You are running a Python virtual environment"
|
|
||||||
read_yes_no "Do you wish to install msspec inside ?" "y"
|
|
||||||
case ${ANSWER} in
|
|
||||||
y) # get the python version of this venv
|
|
||||||
v=$(python -V 2>&1 | cut -d" " -f2 | cut -d. -f1)
|
|
||||||
if [ $v -lt 3 ]; then
|
|
||||||
log_message "The Python version of this venv is < 3"
|
|
||||||
error_exit
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
n) error_exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
pip_opt=""
|
|
||||||
read_yes_no "Do you wish to create a virtual environment to install MsSpec inside" "y"
|
|
||||||
case ${ANSWER} in
|
|
||||||
y) # Create the destination folder
|
|
||||||
ANSWER=""
|
|
||||||
test "$BYPASS" = "y" || \
|
|
||||||
read -p "Please, type in the base installation folder ["${DEFAULT_DEST}"]: " "ANSWER"
|
|
||||||
DEST_FOLDER="${ANSWER:-$DEFAULT_DEST}/MsSpec-${VERSION}"
|
|
||||||
test -d $DEST_FOLDER && log_message "The folder $DEST_FOLDER already exists." && exit
|
|
||||||
create_folder "${DEST_FOLDER}" || error_exit
|
|
||||||
export DEST_FOLDER
|
|
||||||
wrap "${PYTHON} -m venv --system-site-packages --prompt=\"(msspec-${VERSION}) \" ${DEST_FOLDER}/venv" \
|
|
||||||
"Create a Python virtual environment"
|
|
||||||
. ${DEST_FOLDER}/venv/bin/activate
|
|
||||||
;;
|
|
||||||
n) pip_opt="--user"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# install pymsspec
|
|
||||||
wrap "make sdist" \
|
|
||||||
"Building MsSpec python package"
|
|
||||||
|
|
||||||
wrap "pip install $pip_opt dist/msspec-*.tar.gz" \
|
|
||||||
"Installing pymsspec python package and its dependencies"
|
|
||||||
|
|
||||||
# deactivate the virtualenv
|
|
||||||
#if [ x"$pip_opt" = "x" ]; then
|
|
||||||
# deactivate
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
## move the frontend to the binary folder
|
|
||||||
##wrap "mkdir -p ${LOCALBIN} && \
|
|
||||||
## cp ./msspec ${LOCALBIN} && chmod u+x ${LOCALBIN}/msspec && \
|
|
||||||
## ${ECHO} \"msspec installed in ${LOCALBIN}\"" \
|
|
||||||
## "Installing the msspec frontend"
|
|
||||||
# "cp ./msspec ${BIN_FOLDER} && chmod ugo+rx ${BIN_FOLDER}/msspec" "Installing the msspec frontend"
|
|
||||||
#
|
|
||||||
## move the uninstal script
|
|
||||||
#wrap "cp ./uninstall.sh ${DEST}" "Moving the uninstall script"
|
|
||||||
#
|
|
||||||
# installation was a succes so move the logfile to the DEST directory
|
|
||||||
#wrap "cp ${LOGFILE} ${DEST_FOLDER}/msspec_install.log" "Moving the logfile"
|
|
||||||
|
|
||||||
# self-explanatory
|
|
||||||
success_message
|
|
||||||
}
|
|
||||||
|
|
||||||
update_path () {
|
update_path () {
|
||||||
# check if the shell path contains $BIN_FOLDER
|
# check if the shell path contains $BIN_FOLDER
|
||||||
SHELLRC="$HOME/.$(basename $SHELL)rc"
|
SHELLRC="$HOME/.$(basename $SHELL)rc"
|
||||||
|
@ -299,6 +229,91 @@ patience () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local_install () {
|
||||||
|
# Initialize the install process
|
||||||
|
init_install
|
||||||
|
|
||||||
|
# ask for a place to put the binary
|
||||||
|
read_folder "Please, type in the folder where to place the binary" "${DEFAULT_BIN}"
|
||||||
|
BIN_FOLDER=${FOLDER}
|
||||||
|
create_folder "${BIN_FOLDER}" || error_exit
|
||||||
|
export BIN_FOLDER
|
||||||
|
|
||||||
|
# If in a virtualenv, ask if we should install inside
|
||||||
|
if [ x"$VIRTUAL_ENV" != x ]; then
|
||||||
|
read_yes_no "You are running a Python virtual environment.\ Do you wish to install msspec inside ?" "y"
|
||||||
|
case ${ANSWER} in
|
||||||
|
y) # get the python version of this venv...
|
||||||
|
v=$(python -V 2>&1 | cut -d" " -f2 | cut -d. -f1)
|
||||||
|
# and stops if < 3
|
||||||
|
if [ $v -lt 3 ]; then
|
||||||
|
log_message "The Python version of this venv is < 3"
|
||||||
|
error_exit
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
n) # The user decided to stop there
|
||||||
|
log_message "Please deactivate your virtual environment and restart the setup program."
|
||||||
|
error_exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Else, we are not in a virtualenv
|
||||||
|
else
|
||||||
|
pip_opt=""
|
||||||
|
# so ask if we should create one
|
||||||
|
read_yes_no "Do you wish to create a virtual environment to install MsSpec inside" "y"
|
||||||
|
case ${ANSWER} in
|
||||||
|
y) # Create the destination folder
|
||||||
|
read_folder "Please, type in the base installation folder" "${DEFAULT_DEST}"
|
||||||
|
DEST_FOLDER=${FOLDER}/MsSpec-${VERSION}
|
||||||
|
if [ -d $DEST_FOLDER ]; then
|
||||||
|
export DEST_ALREADY_EXISTS="y" # to avoid cleaning the existing DEST_FOLDER in case of any problem
|
||||||
|
read_yes_no "The folder $DEST_FOLDER already exists. Overwrite" "y"
|
||||||
|
case ${ANSWER} in
|
||||||
|
y) # overwrite
|
||||||
|
create_folder "${DEST_FOLDER}" || error_exit
|
||||||
|
;;
|
||||||
|
n) # stop here otherwise
|
||||||
|
error_exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
export DEST_FOLDER
|
||||||
|
wrap "virtualenv -vvv --python=${PYTHON} --system-site-packages --prompt=\"(msspec-${VERSION}) \" ${DEST_FOLDER}/venv" \
|
||||||
|
"Create a Python virtual environment"
|
||||||
|
. ${DEST_FOLDER}/venv/bin/activate
|
||||||
|
;;
|
||||||
|
n) # install in the user $HOME
|
||||||
|
pip_opt="--user"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build and run setuptools to create a source distribution
|
||||||
|
wrap "make sdist" \
|
||||||
|
"Building MsSpec python package"
|
||||||
|
|
||||||
|
# install the package with pip
|
||||||
|
wrap "pip install $pip_opt dist/msspec-*.tar.gz" \
|
||||||
|
"Installing pymsspec python package and its dependencies"
|
||||||
|
|
||||||
|
#
|
||||||
|
## move the frontend to the binary folder
|
||||||
|
##wrap "mkdir -p ${LOCALBIN} && \
|
||||||
|
## cp ./msspec ${LOCALBIN} && chmod u+x ${LOCALBIN}/msspec && \
|
||||||
|
## ${ECHO} \"msspec installed in ${LOCALBIN}\"" \
|
||||||
|
## "Installing the msspec frontend"
|
||||||
|
# "cp ./msspec ${BIN_FOLDER} && chmod ugo+rx ${BIN_FOLDER}/msspec" "Installing the msspec frontend"
|
||||||
|
#
|
||||||
|
## move the uninstal script
|
||||||
|
#wrap "cp ./uninstall.sh ${DEST}" "Moving the uninstall script"
|
||||||
|
#
|
||||||
|
# installation was a succes so move the logfile to the DEST directory
|
||||||
|
#wrap "cp ${LOGFILE} ${DEST_FOLDER}/msspec_install.log" "Moving the logfile"
|
||||||
|
|
||||||
|
# self-explanatory
|
||||||
|
success_message
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while getopts "p:b:yd" option
|
while getopts "p:b:yd" option
|
||||||
|
@ -318,5 +333,4 @@ done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local_install
|
local_install
|
||||||
|
|
Loading…
Reference in New Issue