-
Notifications
You must be signed in to change notification settings - Fork 15
/
update-package.sh
executable file
·109 lines (91 loc) · 2.62 KB
/
update-package.sh
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
OLDROOT="`pwd`"
[ -z "$1" ] || VARIANT="$1"
[ "$REPOROOT" ] || REPOROOT="`dirname "$0"`"
[ "$VARIANT" ] || VARIANT="`basename "$OLDROOT"`"
if [[ ! -d "$REPOROOT"/"$VARIANT" ]]; then
echo "No configuration for this variant found!"
exit 1
fi
if [[ -z "`which mustache`" ]]; then
echo "'mustache' not found!"
echo
echo "Mustache is templating software that is needed to create .spec file"
exit 2
fi
rm -f *.diff
echo "Copying common files..."
if ! cp -Lv "$REPOROOT"/common/* . | sed -e 's/^/ /'; then
echo "Unable to copy files!"
exit 3
fi
echo
echo "Copying $VARIANT files..."
if ! cp -Lv "$REPOROOT"/"$VARIANT"/* . | sed -e 's/^/ /'; then
echo "Unable to copy files!"
exit 4
fi
echo
echo "Checking for additional patches to the project..."
for diff in [0-9]_*.diff [0-9][0-9]_*.diff; do
if [ -f "$diff" ]; then
echo " using $diff..."
if patch < "$diff" | sed -e 's/^/ /'; then
rm "$diff"
else
exit 5
fi
fi
done
rm *.orig &> /dev/null
echo " Additional patching done."
if [[ -f to_delete ]]; then
cat to_delete | while read f; do
echo " Deleting $f..."
rm -f "$f"
done
fi
rm -f to_delete
echo
echo "Creating files from templates..."
if [ "`head -n 1 config.yaml | sed -n 's|---|yes|p'`" ]; then
echo -e '1d\nwq\n' | ed config.yaml > /dev/null 2> /dev/null
fi
if [ "`tail -n 1 default.yaml | sed -n 's|---|yes|p'`" ]; then
echo -e '$d\nwq\n' | ed default.yaml > /dev/null 2> /dev/null
fi
cat ./default.yaml ./config.yaml > ./whole-config.yaml
sync
# If it is preferred variant set correct library name
[ "`echo '0{{preferred}}' | mustache ./whole-config.yaml -`" -le 0 ] || sed -i 's|^lib-name:.*|lib-name:\ mysqlclient|' ./whole-config.yaml
SPEC="`ls -1 *.spec | head -n1`"
PKGNAME="`echo '{{pkg-name}}' | mustache ./whole-config.yaml -`"
for i in ./*.in; do
REALNAME="`echo "$i" | sed -e 's|\.in$||'`"
echo " Creating \"$REALNAME\"..."
if ! mustache ./whole-config.yaml "$i" > "$REALNAME"; then
echo "Creating \"$REALNAME\" failed!"
exit 6
fi
done
sync
sleep 1
[ "$SPEC" = "mysql.spec" ] || mv "mysql.spec" "$SPEC"
echo
echo "Packing configuration..."
if ! tar -caf configuration-tweaks.tar.xz *.cnf; then
echo "Unable to create configuration tarball!"
exit 4
fi
echo
echo "Adding patches..."
if ! "$REPOROOT"/patches/tools/gettar.sh; then
echo "Getting patches failed!"
exit 4
fi
echo "Cleaning up..."
echo
rm -f ./*.in ./default.yaml ./config.yaml ./whole-config.yaml ./*.cnf
if [[ -x ./last_run.sh ]]; then
./last_run.sh && rm ./last_run.sh
fi