Skip to content

Commit 1bc6316

Browse files
authored
Merge pull request #4438 from Flamefire/add-update-EB-develop-script
Add script for updating local git repos with develop branch
2 parents 415cbcd + b03f26e commit 1bc6316

File tree

2 files changed

+96
-4
lines changed

2 files changed

+96
-4
lines changed

easybuild/scripts/install-EasyBuild-develop.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ print_usage()
1414
echo
1515
echo " github_username: username on GitHub for which the EasyBuild repositories should be cloned"
1616
echo
17-
echo " install_dir: directory were all the EasyBuild files will be installed"
17+
echo " install_dir: directory where all the EasyBuild files will be installed"
1818
echo
1919
}
2020

@@ -79,7 +79,7 @@ EOF
7979

8080

8181
# Check for 'help' argument
82-
if [ "$1" = "-h" -o "$1" = "--help" ] ; then
82+
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
8383
print_usage
8484
exit 0
8585
fi
@@ -116,13 +116,14 @@ github_clone_branch "easybuild" "develop"
116116
EB_DEVEL_MODULE_NAME="EasyBuild-develop"
117117
MODULES_INSTALL_DIR=${INSTALL_DIR}/modules
118118
EB_DEVEL_MODULE="${MODULES_INSTALL_DIR}/${EB_DEVEL_MODULE_NAME}"
119-
mkdir -p ${MODULES_INSTALL_DIR}
119+
mkdir -p "${MODULES_INSTALL_DIR}"
120120
print_devel_module > "${EB_DEVEL_MODULE}"
121-
echo
121+
echo
122122
echo "=== Run 'module use ${MODULES_INSTALL_DIR}' and 'module load ${EB_DEVEL_MODULE_NAME}' to use your development version of EasyBuild."
123123
echo "=== (you can append ${MODULES_INSTALL_DIR} to your MODULEPATH to make this module always available for loading)"
124124
echo
125125
echo "=== To update each repository, run 'git pull origin' in each subdirectory of ${INSTALL_DIR}"
126+
echo "=== Or run $(dirname "$0")/update-EasyBuild-develop.sh '${INSTALL_DIR}'"
126127
echo
127128

128129
exit 0
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
3+
# Stop in case of error
4+
set -e
5+
6+
# Print script help
7+
print_usage()
8+
{
9+
echo "Checkout develop branch of all EasyBuild repositories"
10+
echo "and pull changes from the remote repository."
11+
echo "To be used with the EasyBuild-develop module or a set git-working-dirs-path"
12+
echo "Usage: $0 [<git_dir>]"
13+
echo
14+
echo " git_dir: directory where all the EasyBuild repositories are installed."
15+
echo " Automatically detected if not specified."
16+
echo
17+
}
18+
19+
if [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then
20+
print_usage
21+
exit 0
22+
fi
23+
24+
if [[ $# -gt 1 ]] ; then
25+
echo "Error: invalid arguments"
26+
echo
27+
print_usage
28+
exit 1
29+
fi
30+
31+
if [[ $# -eq 1 ]]; then
32+
git_dir=$1
33+
else
34+
# Auto detect git_dir
35+
git_dir=""
36+
if ! which eb &> /dev/null; then
37+
module load EasyBuild-develop || module load EasyBuild || true
38+
if ! which eb &> /dev/null; then
39+
echo 'Found neither the `eb` command nor a working module.'
40+
echo 'Please specify the git_dir!'
41+
exit 1
42+
fi
43+
fi
44+
if out=$(eb --show-config | grep -F 'git-working-dirs-path'); then
45+
path=$(echo "$out" | awk '{print $NF}')
46+
if [[ -n "$path" ]] && [[ -d "$path" ]]; then
47+
git_dir=$path
48+
echo "Using git_dir from git-working-dirs-path: $git_dir"
49+
fi
50+
fi
51+
if [[ -z "$git_dir" ]]; then
52+
eb_dir=$(dirname "$(which eb)")
53+
if [[ "$(basename "$eb_dir")" == "easybuild-framework" ]] && [[ -d "$eb_dir/.git" ]]; then
54+
git_dir=$(dirname "$eb_dir")
55+
echo "Using git_dir from eb command: $git_dir"
56+
else
57+
echo 'Please specify the git_dir as auto-detection failed!'
58+
exit 1
59+
fi
60+
fi
61+
fi
62+
63+
cd "$git_dir"
64+
65+
for folder in easybuild easybuild-framework easybuild-easyblocks easybuild-easyconfigs; do
66+
echo # A newline
67+
if [[ -d "$folder" ]]; then
68+
echo "========= Checking ${folder} ========="
69+
else
70+
echo "========= Skipping non-existent ${folder} ========="
71+
fi
72+
cd "$folder"
73+
git checkout "develop"
74+
if git remote | grep -qF github_easybuilders; then
75+
git pull "github_easybuilders"
76+
else
77+
git pull
78+
fi
79+
cd ..
80+
done
81+
82+
index_file="$git_dir/easybuild-easyconfigs/easybuild/easyconfigs/.eb-path-index"
83+
if [[ -f "$index_file" ]]; then
84+
echo -n "Trying to remove index from ${index_file}..."
85+
if rm "$index_file"; then
86+
echo "Done!"
87+
echo "Recreate with 'eb --create-index \"$(dirname "$index_file")\"'"
88+
else
89+
echo "Failed!"
90+
fi
91+
fi

0 commit comments

Comments
 (0)