Commit 00f9f974 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-3598: updating rebuild scripts

parent 0716da95
......@@ -5,79 +5,173 @@ if (( phpversion < 70 )); then
exit 1
fi
# ISTWCMS-2841: Get the current directory that we are in.
dir=$(pwd)
for i in "$@"
do
case $i in
-h|--help)
use_help="1"
shift
;;
--build-option=*)
build_option="${i#*=}"
shift # past argument=value
;;
--build-type=*)
build_type="${i#*=}"
shift # past argument=value
;;
--base-profile-branch-tag=*)
base_profile_branch_tag="${i#*=}"
shift # past argument=value
;;
--gesso-branch-tag=*)
gesso_branch_tag="${i#*=}"
shift # past argument=value
;;
--drupal-core-path=*)
drupal_core_path="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
# ISTWCMS-2841: Split the string based on /.
dirs=(`echo $dir |sed 's/\// /g'`)
if [[ ! -z $use_help ]]; then
printf "./rebuild.sh will accept the following switches:\n"
printf "\n --build-option [#] (required)"
printf "\n 1 = rebuild profile and gesso"
printf "\n 2 = rebuild gesso only"
printf "\n"
printf "\n --base-profile-branch-tag [branch/tag] (optional)"
printf "\n Provide a Git branch or tag name for uw_base_profile."
printf "\n Defaults to 8.x-3.x branch."
printf "\n"
printf "\n --gesso-branch-tag [branch/tag] (optional)"
printf "\n Provide a Git branch or tag name for uw_wcms_gesso."
printf "\n Defaults to 8.x-3.x branch."
printf "\n"
printf "\n --drupal-core-path [path] (optional)"
printf "\n Provide a path to where drupal core is located"
printf "\n Defaults to /var/www/drupal8"
printf "\n"
printf "\n --build-type [type-of-site] (optional)"
printf "\n Provide a type of site, ex vagrant, lando, wms-server"
printf "\n Defaults to vagrant"
printf "\n"
printf "\n Example usage:"
printf "\n ./rebuild.sh --build-option=1 --base-profile-branch-tag=8.x-3.x --gesso-branch-tag=8.x-3.x --drupal-core-path=/var/www/drupal8 --build-type=vagrant"
printf "\n"
printf "\n If there are no switches used then interactivity will being asking questions to get inputs but also allowing for the defaults."
printf "\n"
exit 1
fi
# ISTWCMS-2841: The drupal directory will always be the third element.
drupal_directory=${dirs[2]}
if [[ -z $build_option ]] && [[ -z $base_profile_branch_tag ]] && [[ -z $gesso_branch_tag ]] && [[ -z $drupal_core_path ]]; then
interactivity=1
elif [ ${build_option} = null ] && [ ${base_profile_branch_tag} = null ] && [ ${gesso_branch_tag} = null ] && [ ${drupal_core_path} = null ]; then
interactivity=1
else
interactivity=0
fi
# Set variables from command line, if any.
response=${1}
if [ ${interactivity} = 1 ]; then
echo "What would you like to do?"
echo "1 = Rebuild profile and gesso."
echo "2 = Rebuild gesso only."
echo "[x] Exit and do nothing"
while ! [[ "$build_option" =~ ^(1|2|x)$ ]]
do
printf "\nBuild option [1]: "
read -r build_option
case "$response" in
-y|-n|1|2|3 )
if [[ -z $build_option ]]; then
build_option=1
fi
done
# Set the variables for drupal core and pattern lab.
# If none are supplied from the commandline, use defaults.
# When argument supplied for building, arguments 2 & 3 are used.
drupal_core_path=${2:-/var/www/drupal8}
pattern_lab_root_path=${3:-/var/www/html}
if [ ${build_option} = "x" ]; then
exit 1;
fi
if [ ${response} = "-y" ]; then
answer=1
elif [ ${response} = "-n" ]; then
answer=2
else
if [ ${response} = "1" ] || [ ${response} = "2" ] || [ ${response} = "3" ]; then
answer=${response}
if [ ${build_option} = 1 ]; then
printf "\nBase profile branch/tag: [8.x-3.x]: "
read -r base_profile_branch_tag
fi
printf "\nGesso branch/tag: [8.x-3.x]: "
read -r gesso_branch_tag
if [[ ! -z $build_type ]] && [ ${build_type} = "lando" ]; then
drupal_core_path_default="/app"
else
echo "There was an incorrect flag supplied"
fi
drupal_core_path_default="/var/www/drupal8"
fi
;;
* )
echo "Error: No BUILD specified. Usage:"
echo "rebuild.sh BUILD [DRUPAL_CORE_PATH] [PATTERN_LAB_ROOT_PATH]"
echo "BUILD must be one of:"
echo "1 = Rebuild profile and pattern-lab."
echo "2 = Rebuild profile only."
echo "3 = Rebuild pattern-lab only."
exit 1
;;
esac
case $answer in
printf "\nDrupal core path: [${drupal_core_path_default}]: "
read -r drupal_core_path
fi
if [[ -z $build_option ]]; then
printf "You must specify a build option, it is a required switch.\n"
exit 1;
fi
if [[ -z $base_profile_branch_tag ]]; then
base_profile_branch_tag=8.x-3.x
fi
printf "Using base profile branch/tag: $base_profile_branch_tag.\n"
if [[ -z $gesso_branch_tag ]]; then
gesso_branch_tag=8.x-3.x
fi
printf "Using gesso profile branch/tag: $gesso_branch_tag\n"
if [[ -z $build_type ]]; then
build_type="vagrant"
fi
printf "Using build type: $build_type\n"
if [ ${build_type} = "lando" ]; then
drupal_core_path_default="/app"
else
drupal_core_path_default="/var/www/drupal8"
fi
if [[ -z $drupal_core_path ]]; then
drupal_core_path=${drupal_core_path_default}
fi
printf "Using drupal core path: $drupal_core_path\n"
case $build_option in
1 )
echo ""
echo "You have chosen to rebuild the profile and gesso.";
echo ""
sh ./scripts/github_check.sh
if [[ $? -ne 0 ]] ; then
exit 1
else
sh ./scripts/rebuild_profile.sh $drupal_core_path $pattern_lab_root_path
sh ./scripts/rebuild_gesso.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
sh ./scripts/rebuild_profile.sh $build_option $drupal_core_path $base_profile_branch_tag $gesso_branch_tag
fi
;;
2 )
echo ""
echo "You have chosen to rebuild the profile only."
echo "You have chosen to rebuild gesso only."
echo ""
sh ./scripts/rebuild_profile.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
;;
3 )
echo ""
echo "You have chosen to rebuild pattern-lab only."
echo ""
sh ./scripts/github_check.sh
if [[ $? -ne 0 ]] ; then
exit 1
else
sh ./scripts/rebuild_gesso.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
sh ./scripts/rebuild_gesso.sh $build_option $drupal_core_path $gesso_branch_tag
fi
;;
esac
echo "Done all tasks."
# By default this script works when run inside the profile/uw_base_profile/scripts directory.
# If you are not, then you must specific the parameters.
SCRIPT=$(readlink -f $0)
BASE_PATH=$(dirname "$SCRIPT")
DRUPAL_CORE_PATH=${1:-$BASE_PATH/..}
uw_wcms_gesso_root_path=${2:-/var/www/html}
drupal_directory=${3:-drupal8}
uw_profile_name=${4:-uw_base_profile}
fdsu_theme_resp_path=${5:-$DRUPAL_CORE_PATH/profiles/$uw_profile_name/themes/uw_fdsu_theme_resp}
echo "\nPATH TO THEME: "
echo "$fdsu_theme_resp_path\n"
build_option=${1}
drupal_core_path=${2:-/var/www/drupal8}
gesso_branch_tag=${3-8.x-3.x}
uw_wcms_gesso_root_path="$drupal_core_path/profiles/uw_base_profile/themes/uw_fdsu_theme_resp"
uw_wcms_gesso_path="$uw_wcms_gesso_root_path/uw_wcms_gesso"
if [ -d "$uw_wcms_gesso_root_path/uw_wcms_gesso" ]; then
echo "Removing old pattern lab ..."
rm -rf "$uw_wcms_gesso_root_path/uw_wcms_gesso"
echo "Done removing old pattern lab."
if [ -d "$uw_wcms_gesso_path" ]; then
echo "Removing old gesso ..."
rm -rf "$uw_wcms_gesso_path"
echo "Done removing old gesso."
fi
echo "Bulding new UW gesso ..."
git clone "https://git.uwaterloo.ca/wcms/uw_wcms_gesso.git" "$uw_wcms_gesso_root_path/uw_wcms_gesso"
cd "$uw_wcms_gesso_root_path/uw_wcms_gesso"
sh ./build_gesso.sh $uw_wcms_gesso_root_path
cd "$uw_wcms_gesso_root_path"
git clone "https://git.uwaterloo.ca/wcms/uw_wcms_gesso"
cd "uw_wcms_gesso"
git checkout "$gesso_branch_tag"
sh ./build_gesso.sh $build_option
echo "Done building new UW gesso."
echo "Adding symbolic links inside theme directory ..."
if [ -d "$fdsu_theme_resp_path/source" ]; then
echo "Removing old theme symbolic link to the source directory ..."
rm -rf "$fdsu_theme_resp_path/source"
echo "Done removing old theme symbolic link to the source directory."
fi
cd "$fdsu_theme_resp_path"
echo "Creating symbolic link to source directory ..."
ln -s "$uw_wcms_gesso_root_path/uw_wcms_gesso/source" source
echo "Done Creating symbolic link to source directory."
echo "Done adding symbolic links inside theme directory."
drupal_core_path=${1:-/var/www/drupal8}
pattern_lab_root_path=${2:-/var/www/html}
build_option=${1}
drupal_core_path=${2:-/var/www/drupal8}
base_profile_branch_tag=${3-8.x-3.x}
gesso_branch_tag=${4-8.x-3.x}
echo "Starting rebuild of the profile..."
......@@ -10,14 +12,21 @@ echo "Starting rebuild of the profile..."
echo "Deleting the composer.lock file..."
rm --force composer.lock
echo "Removing the existing modules, themes, and libraries directories..."
rm -rf modules/
rm -rf themes/
rm -rf libraries/
echo "Removing the existing base profile."
cd "${drupal_core_path}/profiles"
rm -rf "uw_base_profile"
echo "Existing things deleted."
echo "Checking out uw_base_profile with branch $base_profile_branch..."
git clone "https://git.uwaterloo.ca/wcms/uw_base_profile"
cd "uw_base_profile"
git checkout "$base_profile_branch_tag"
echo "Done checking out branch of uw_base_profile."
echo "Clearing the composer cache..."
composer clear-cache
echo "Done clearing the composer cache..."
echo "Running composer install..."
composer install --no-interaction
......@@ -31,18 +40,5 @@ echo ""
echo "Done updating profile."
echo ""
echo ""
echo "Running setuptheme..."
echo ""
cd themes/uw_fdsu_theme_resp/
echo "Re-add Adding symbolic links..."
ln --force --symbolic "$pattern_lab_root_path/uw_wcms_gesso" uw_wcms_gesso
# Symbolic link need to components because the module Unified Twig Extensions
# needs to extend twig and can only read theme/*/_twig_component directories
ln --force --symbolic "$pattern_lab_root_path/uw_wcms_gesso/source" source
sh ./scripts/rebuild_gesso.sh $build_option $drupal_core_path $gesso_branch_tag
# Add symbolic link for the libraries folder so we can have it in our base profile instead
ln --no-dereference --force --symbolic profiles/uw_base_profile/libraries "$drupal_core_path/libraries"
Supports Markdown
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