1
by Christopher Lee
Initial commit (with some fleshed out scripts) |
1 |
#!/bin/sh
|
2 |
||
3 |
version_major=0 |
|
4 |
version_minor=0 |
|
5 |
version_patch=2 |
|
6 |
||
7 |
echo "BuilderScript Ver. $version_major.$version_minor.$version_patch" |
|
8 |
||
9 |
main_branch= |
|
10 |
packaging_branch= |
|
11 |
work_dir= |
|
12 |
config_file= |
|
13 |
result_dir= |
|
14 |
hook_dir= |
|
15 |
chrooted="" |
|
16 |
target_branch= |
|
17 |
||
18 |
while getopts "m:p:h:w:r:ct:" opt; do |
|
19 |
case $opt in |
|
20 |
m)
|
|
21 |
echo "(m)ain branch: $OPTARG" >&2 |
|
22 |
main_branch=$OPTARG |
|
23 |
;;
|
|
24 |
p)
|
|
25 |
echo "(p)ackaging branch: $OPTARG" >&2 |
|
26 |
packaging_branch=$OPTARG |
|
27 |
;;
|
|
28 |
w)
|
|
29 |
echo "(w)orking dir: $OPTARG" >&2 |
|
30 |
work_dir=$OPTARG |
|
31 |
;;
|
|
32 |
h)
|
|
33 |
echo "(h)ook dir: $OPTARG" >&2 |
|
34 |
hook_dir=$OPTARG |
|
35 |
;;
|
|
36 |
r)
|
|
37 |
echo "(r)esult dir: $OPTARG" >&2 |
|
38 |
result_dir=$OPTARG |
|
39 |
;;
|
|
40 |
c)
|
|
41 |
echo "Considering (c)hrooted build" >&2 |
|
42 |
chrooted="" |
|
43 |
;;
|
|
44 |
t)
|
|
45 |
echo "(t)arget branch: $OPTARG" >&2 |
|
46 |
target_branch="$OPTARG" |
|
47 |
;;
|
|
48 |
\p) |
|
49 |
echo "Invalid option: -$OPTARG" >&2 |
|
50 |
exit 1 |
|
51 |
;;
|
|
52 |
:)
|
|
53 |
echo "Option -$OPTARG requires an argument." >&2 |
|
54 |
exit 1 |
|
55 |
;;
|
|
56 |
esac
|
|
57 |
done
|
|
58 |
||
59 |
# convert to absolute path
|
|
60 |
result_dir=$(readlink -f "$result_dir") |
|
61 |
hook_dir=$(readlink -f "$hook_dir") |
|
62 |
||
63 |
# do not continue if any command fails
|
|
64 |
set -ex
|
|
65 |
||
66 |
# clean up
|
|
67 |
rm -rf "$work_dir" |
|
68 |
mkdir "$work_dir" |
|
69 |
||
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
70 |
if [ -z "$target_branch" ]; then |
71 |
# pull main branch and merge in packaging branch
|
|
72 |
bzr branch $main_branch "$work_dir/trunk" |
|
4
by Christopher Lee
Oops, got the paths wrong |
73 |
cd "$work_dir/trunk" |
74 |
# cd "$work_dir"
|
|
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
75 |
else
|
76 |
bzr branch "$target_branch" "$work_dir/trunk" |
|
77 |
cd "$work_dir/trunk" |
|
78 |
bzr merge "$main_branch" |
|
4
by Christopher Lee
Oops, got the paths wrong |
79 |
# cd "$work_dir"
|
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
80 |
fi
|
81 |
||
82 |
bzr checkout "$packaging_branch" packaging |
|
83 |
if [ -d 'packaging/debian' ]; then |
|
4
by Christopher Lee
Oops, got the paths wrong |
84 |
mv packaging/debian . |
85 |
# mv packaging/debian "$work_dir/trunk/debian"
|
|
86 |
# cd "$work_dir/trunk"
|
|
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
87 |
else
|
88 |
echo "Packaging branch doesn't include packaging information. Aborting" |
|
89 |
exit 1 |
|
90 |
fi
|
|
91 |
||
92 |
# deal with autogen
|
|
93 |
||
94 |
# This is potentially dangerous
|
|
95 |
# but we force a native source format
|
|
96 |
# to prevent from dpkg-buildpackage bailing out
|
|
97 |
if [ -f "debian/source/format" ]; then |
|
4
by Christopher Lee
Oops, got the paths wrong |
98 |
sed -i 's/quilt/native/g' debian/source/format
|
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
99 |
else
|
4
by Christopher Lee
Oops, got the paths wrong |
100 |
mkdir -p debian/source |
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
101 |
echo '3.0 (native)' > debian/source/format |
4
by Christopher Lee
Oops, got the paths wrong |
102 |
fi
|
3
by Christopher Lee
Further additions (stolen, err, taken from mmrazik) |
103 |
|
104 |
# Extract some packaging information
|
|
105 |
version=`dpkg-parsechangelog | awk '/^Version/ {print $2}' | sed -e "s/\(.*\)-[0-9]ubuntu.*/\1/"`+bzr${trunkrev} |
|
106 |
version=${version}ubuntu0+${packaging_rev} |
|
107 |
sourcename=`dpkg-parsechangelog | awk '/^Source/ {print $2}'` |
|
108 |
# Generate the actual source package
|
|
109 |
cd ..
|
|
110 |
tar -czf ${sourcename}_${version}.orig.tar.gz trunk |
|
111 |
||
112 |
cd trunk
|
|
113 |
||
114 |
||
115 |
if [ -z "$chrooted" ]; then |
|
116 |
trunk_dir=$(readlink -f ".") |
|
117 |
||
118 |
export BUILD_DIR=$(readlink -f ".") |
|
119 |
export RESULT_DIR=$result_dir |
|
120 |
||
121 |
cd "$hook_dir" |
|
122 |
"./D00dependency_hooks"
|
|
123 |
||
124 |
cd "$trunk_dir" |
|
125 |
||
126 |
#sed -i 's/\({GTEST_TEST_COMMAND[_a-zA-Z]*}\)/\1 --gtest_output=xml:.\//' tests/CMakeLists.txt
|
|
127 |
||
128 |
#head -n19 CMakeLists.txt > a.txt
|
|
129 |
#cat >> a.txt <<EOF
|
|
130 |
#option (USE_GCOV "Use coverage profiling for this build" ON)
|
|
131 |
#if (USE_GCOV)
|
|
132 |
# set (CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -O0 --coverage ")
|
|
133 |
#endif (USE_GCOV)
|
|
134 |
#EOF
|
|
135 |
#tail -n+20 CMakeLists.txt >> a.txt
|
|
136 |
#mv a.txt CMakeLists.txt
|
|
137 |
||
138 |
mk-build-deps --install --tool 'apt-get -y --force-yes' --build-dep debian/control
|
|
139 |
export DEB_CXXFLAGS_STRIP="-O2" |
|
140 |
export DEB_CPPFLAGS_STRIP="-O2" |
|
141 |
export DEB_CFLAGS_STRIP="-O2" |
|
142 |
export DEB_FFLAGS_STRIP="-O2" |
|
143 |
yes | debuild -uc -us -d
|
|
144 |
||
145 |
cd "$hook_dir" |
|
146 |
"./B00build_hooks"
|
|
147 |
else
|
|
148 |
echo "Would use pdbuilder" |
|
149 |
fi
|
|
150 |
||
151 |
rm -f -- "ReportDir"
|
|
1
by Christopher Lee
Initial commit (with some fleshed out scripts) |
152 |