forked from openstack-charmers/release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_ensure_master_libraries_all_charms
executable file
·87 lines (70 loc) · 2.89 KB
/
_ensure_master_libraries_all_charms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# Ensure that charm-helpers, charms.openstack, charms.ceph, zaza and
# zaza-openstack-tests are from the master branch.
charms="$(cat charms.txt)"
basedir="$(pwd)"
function ensure_line {
search="$1"
add_line="$2"
file="$3"
if grep "$search" "$file" >/dev/null; then
# line exists so replace it.
cmd="/$search/c\\$add_line"
sed -i "$cmd" $file
else
# line doesn't exist so add it
echo -e "\n$add_line" >> $file
fi
}
function ensure_line_if_exists {
search="$1"
add_line="$2"
file="$3"
if grep "$search" "$file" >/dev/null; then
# line exists so replace it.
cmd="/$search/c\\$add_line"
sed -i "$cmd" $file
fi
}
# the directory needs to be in the root for the charm repo for this function
function ensure_lines {
charm_type="$($basedir/what-is .)"
case $charm_type in
classic-zaza)
echo "$charm is a classic charm - possibly making changes."
# charm-helpers-hooks.yaml
ensure_line "charm-helpers" "repo: https://github.com/juju/charm-helpers" "charm-helpers-hooks.yaml"
# test-requirements.txt
ensure_line "zaza.git" "git+https://github.com/openstack-charmers/zaza.git#egg=zaza;python_version>='3.0'" "test-requirements.txt"
ensure_line "zaza-openstack-tests" "git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack" "test-requirements.txt"
;;
source-zaza)
echo "$charm is a source charm (reactive) - possibly making changes"
# src/wheelhouse.txt
ensure_line "charms.openstack" "git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack" "src/wheelhouse.txt"
ensure_line "charm-helpers" "git+https://github.com/juju/charm-helpers.git#egg=charmhelpers" "src/wheelhouse.txt"
ensure_line_if_exists "charms.ceph" "git+https://github.com/openstack/charms.ceph.git#egg=charms.ceph" "src/wheelhouse.txt"
# test-requirements.txt
ensure_line "charms.openstack" "git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack" "test-requirements.txt"
# src/test-requirements.txt
ensure_line "zaza.git" "git+https://github.com/openstack-charmers/zaza.git#egg=zaza" "src/test-requirements.txt"
ensure_line "zaza-openstack-tests" "git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack" "src/test-requirements.txt"
# remote the build lock if present
remove_build_lock_if_present
;;
esac
}
function remove_build_lock_if_present {
[ -e src/build.lock ] && rm src/build.lock
}
for charm in $charms; do
if [ ! -d "charms/$charm" ]; then
echo "charm dir $charm is missing. exiting"
exit 1
fi
(
cd charms/$charm
ensure_lines
)
done