Commit d034a44f authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add an argument to change installer path

parent c72d879e
......@@ -19,12 +19,14 @@ loadConfigEnvFile
function showHelpAndExit {
echo "Usage :"
echo " --package-conf-dir=<package config dir> : path of the directory containing config files"
echo " --package-gen-dir=<package generation dir> : path of the directory to generate files in (will use '<config dir>/installer' if not specified)"
exit 1
}
# get params
CONFIG_DIR=""
PACKAGE_DIR=""
HELP="false"
......@@ -34,6 +36,10 @@ case $ARG in
CONFIG_DIR="${ARG#*=}"
shift # past argument=value
;;
--package-gen-dir=*)
PACKAGE_DIR="${ARG#*=}"
shift # past argument=value
;;
--help)
HELP="true"
shift # past argument with no value
......@@ -55,22 +61,25 @@ if [[ "$CONFIG_DIR" == "" ]]; then
showHelpAndExit
fi
if [[ "$PACKAGE_DIR" == "" ]]; then
PACKAGE_DIR="$CONFIG_DIR/installer"
fi
# get config dir fullpath
echo "Scripts directory : $SCRIPT_PATH"
INSTALLER_CONF_DIR="$(toFullDirPath "$CONFIG_DIR")"
echo "Installer configuration repository : $INSTALLER_CONF_DIR"
cd $(win2unix "$CONFIG_DIR") &> /dev/null
INSTALLER_PATH=$PWD
echo "Installer configuration repository : $INSTALLER_PATH"
cd - &> /dev/null
INSTALLER_GEN_DIR="$(toFullDirPath "$PACKAGE_DIR")"
echo "Installer destination directory : $INSTALLER_CONF_DIR"
# get installer params (one per repository)
INSTALLER_NAME="setup"
INSTALLER_MODE="offline"
INSTALLER_CONF_LINUX=""
INSTALLER_CONF_WINDOWS=""
if [[ -f "$INSTALLER_PATH/base.conf" ]]; then
source "$INSTALLER_PATH/base.conf"
if [[ -f "$INSTALLER_CONF_DIR/base.conf" ]]; then
source "$INSTALLER_CONF_DIR/base.conf"
else
echo "File not found in installer repository 'base.conf' !"
exit -1
......@@ -88,25 +97,22 @@ echo "Installer config file basename : $INSTALLER_CONF"
# prepare temporary folder
INSTALLER_DIRECTORY="$INSTALLER_PATH/installer"
LOG_FILE="$INSTALLER_DIRECTORY/log.txt"
LOG_FILE="$INSTALLER_GEN_DIR/log.txt"
echo "Initializing installer directory..."
rm -rf "$INSTALLER_DIRECTORY" &> /dev/null
mkdir -p "$INSTALLER_DIRECTORY" &> /dev/null
cd $INSTALLER_DIRECTORY &> /dev/null
INSTALLER_DIRECTORY=$PWD
cd - &> /dev/null
rm -rf "$INSTALLER_GEN_DIR" &> /dev/null
mkdir -p "$INSTALLER_GEN_DIR" &> /dev/null
touch $LOG_FILE &> /dev/null
echo "Copying installer configuration..."
cp -a "$INSTALLER_PATH/installer_configuration/." "$INSTALLER_DIRECTORY/" &>> $LOG_FILE
echo "Installer directory ready in $INSTALLER_DIRECTORY"
cp -a "$INSTALLER_CONF_DIR/installer_configuration/." "$INSTALLER_GEN_DIR/" &>> $LOG_FILE
echo "Installer directory ready in $INSTALLER_GEN_DIR"
# get package config files
PACKAGE_CONFIGS="$INSTALLER_PATH/config/*.conf"
PACKAGE_CONFIGS="$INSTALLER_CONF_DIR/config/*.conf"
for SUB_CONF in $PACKAGE_CONFIGS; do
# PACKAGES PARAMS
# read project params
PROJECT_NAME=""
PACKAGE_URI=""
GIT_URL_TO_FETCH=""
......@@ -138,16 +144,17 @@ for SUB_CONF in $PACKAGE_CONFIGS; do
echo "Toolchain : $TOOLCHAIN"
echo "Qt version : $QTVERSION"
# Check tools
# check tools
checkBuildTool
checkToolchain
checkQtVersion
# PREPARE
SOURCE_PATH="$INSTALLER_DIRECTORY/src-$PROJECT_NAME"
BUILD_PATH="$INSTALLER_DIRECTORY/build-$PROJECT_NAME"
DEPLOY_PATH="$INSTALLER_DIRECTORY/packages/$PACKAGE_URI/data"
# prepare
SOURCE_PATH="$INSTALLER_GEN_DIR/src-$PROJECT_NAME"
BUILD_PATH="$INSTALLER_GEN_DIR/build-$PROJECT_NAME"
DEPLOY_PATH="$INSTALLER_GEN_DIR/packages/$PACKAGE_URI/data"
echo "Source directory : $SOURCE_PATH"
echo "Build directory : $BUILD_PATH"
echo "Deploy directory : $DEPLOY_PATH"
......@@ -182,20 +189,26 @@ done
echo "========================= PACKAGING ======================="
# PACKAGE
echo "Packaging the installer..."
CONFIG_XML="$(unix2win "$INSTALLER_GEN_DIR/config/$INSTALLER_CONF.xml")"
COMPONENTS_DIR="$(unix2win "$INSTALLER_GEN_DIR/packages")"
SETUP_EXE="$(unix2win "$INSTALLER_GEN_DIR/$INSTALLER_NAME")"
if [[ "$INSTALLER_MODE" == "online" ]]; then
"$QTIFW_PATH" -v --online-only -c $(unix2win "$INSTALLER_DIRECTORY/config/$INSTALLER_CONF.xml") -p $(unix2win "$INSTALLER_DIRECTORY/packages") $(unix2win "$INSTALLER_DIRECTORY/$INSTALLER_NAME") &>> $LOG_FILE
"$QTIFW_PATH" -v --online-only -c "$CONFIG_XML" -p "$COMPONENTS_DIR" "$SETUP_EXE" &>> $LOG_FILE
elif [[ "$INSTALLER_MODE" == "offline" ]]; then
"$QTIFW_PATH" -v --offline-only -c $(unix2win "$INSTALLER_DIRECTORY/config/$INSTALLER_CONF.xml") -p $(unix2win "$INSTALLER_DIRECTORY/packages") $(unix2win "$INSTALLER_DIRECTORY/$INSTALLER_NAME") &>> $LOG_FILE
"$QTIFW_PATH" -v --offline-only -c "$CONFIG_XML" -p "$COMPONENTS_DIR" "$SETUP_EXE" &>> $LOG_FILE
else
echo "Unknown installer mode $INSTALLER_MODE ! Either 'online' or 'offline'"
exit -1
fi
if [[ "$OSFAMILY" == "GNULINUX" ]]; then
echo "Package file generated at $INSTALLER_DIRECTORY/$INSTALLER_NAME"
echo "Package file generated at $SETUP_EXE"
else
echo "Package file generated at $INSTALLER_DIRECTORY/$INSTALLER_NAME.exe"
echo "Package file generated at $SETUP_EXE.exe"
fi
echo "Done."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment