-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathadd-build-lock-file
executable file
·69 lines (61 loc) · 2.55 KB
/
add-build-lock-file
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
#!/bin/bash -e
# Add a lock file to the charm (assume it is a reactive charm).
# Run in the charm's root directory to obtain the charm name.
# Cleans up afterwards.
# Run AFTER switching the charm to stable libraries (flip-master-libs-to-stable)
_dir="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
charm_type="$(${_dir}/what-is .)"
function update_charmcraft {
# add in reactive-charm-build-arguments if needed
grep -q "reactive-charm-build-arguments:" charmcraft.yaml || {
change="\ reactive-charm-build-arguments:"
sed -i "/plugin: reactive/a $change" charmcraft.yaml
}
# add - --write-lock-file if it is missing
grep -q "write-lock-file" charmcraft.yaml || {
change="\ - --write-lock-file\n - --verbose\n - --verbose"
sed -i "/reactive-charm-build-arguments:/a $change" charmcraft.yaml
}
# comment out build binary wheels from source to enable the vcs versions of
# wheels to be discovered.
sed -i "s/^ - --binary-wheels-from-source/ # - --binary-wheels-from-source/g" charmcraft.yaml
}
case $charm_type in
source-zaza)
# Build the charm.
if [ ! -f src/build.lock ]; then
# save current charmcraft
if [ ! -f charmcraft.yaml-orig ]; then
echo "saving current charmcraft.yaml"
cp charmcraft.yaml charmcraft.yaml-orig
else
echo "resetting to saved charmcraft.yaml-orig"
cp charmcraft.yaml-orig charmcraft.yaml
fi
# update the charmcraft to build the lock file for a reactive charm
update_charmcraft
head -n 15 charmcraft.yaml
# build the charm
charmcraft clean
charmcraft -v pack --bases-index=0
rm ${charm}*.charm
# extract the build.lock file
echo "extracting the build.lock file"
charm=$(grep "charm_build_name" osci.yaml | awk '{print $2}')
echo $charm
$_dir/get-build-lock $charm
echo "restoring charmcraft.yaml"
cp charmcraft.yaml-orig charmcraft.yaml
rm charmcraft.yaml-orig
# temporarily workaround the stable branch detection - charm-tools Bug: #606
# sed -i "s#refs/heads/master\\\\nrefs/heads/stable/#refs/heads/stable/#g" src/build.lock
echo "clean up charmcraft"
charmcraft clean
else
echo " .. build.lock already exists"
fi
;;
*)
echo " .. Not a reactive charm."
;;
esac