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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#!/bin/sh
version_major=0
version_minor=0
version_patch=2
echo "BuilderScript Ver. $version_major.$version_minor.$version_patch"
main_branch=
packaging_branch=
work_dir=
config_file=
result_dir=
hook_dir=
chrooted=""
target_branch=
while getopts "m:p:h:w:r:ct:" opt; do
case $opt in
m)
echo "(m)ain branch: $OPTARG" >&2
main_branch=$OPTARG
;;
p)
echo "(p)ackaging branch: $OPTARG" >&2
packaging_branch=$OPTARG
;;
w)
echo "(w)orking dir: $OPTARG" >&2
work_dir=$OPTARG
;;
h)
echo "(h)ook dir: $OPTARG" >&2
hook_dir=$OPTARG
;;
r)
echo "(r)esult dir: $OPTARG" >&2
result_dir=$OPTARG
;;
c)
echo "Considering (c)hrooted build" >&2
chrooted=""
;;
t)
echo "(t)arget branch: $OPTARG" >&2
target_branch="$OPTARG"
;;
\p)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# convert to absolute path
result_dir=$(readlink -f "$result_dir")
hook_dir=$(readlink -f "$hook_dir")
# do not continue if any command fails
set -ex
# clean up
rm -rf "$work_dir"
mkdir "$work_dir"
if [ -z "$target_branch" ]; then
# pull main branch and merge in packaging branch
bzr branch $main_branch "$work_dir/trunk"
cd "$work_dir/trunk"
# cd "$work_dir"
else
bzr branch "$target_branch" "$work_dir/trunk"
cd "$work_dir/trunk"
bzr merge "$main_branch"
# cd "$work_dir"
fi
bzr checkout "$packaging_branch" packaging
if [ -d 'packaging/debian' ]; then
mv packaging/debian .
# mv packaging/debian "$work_dir/trunk/debian"
# cd "$work_dir/trunk"
else
echo "Packaging branch doesn't include packaging information. Aborting"
exit 1
fi
# deal with autogen
# This is potentially dangerous
# but we force a native source format
# to prevent from dpkg-buildpackage bailing out
if [ -f "debian/source/format" ]; then
sed -i 's/quilt/native/g' debian/source/format
else
mkdir -p debian/source
echo '3.0 (native)' > debian/source/format
fi
# Extract some packaging information
version=`dpkg-parsechangelog | awk '/^Version/ {print $2}' | sed -e "s/\(.*\)-[0-9]ubuntu.*/\1/"`+bzr${trunkrev}
version=${version}ubuntu0+${packaging_rev}
sourcename=`dpkg-parsechangelog | awk '/^Source/ {print $2}'`
# Generate the actual source package
cd ..
tar -czf ${sourcename}_${version}.orig.tar.gz trunk
cd trunk
if [ -z "$chrooted" ]; then
trunk_dir=$(readlink -f ".")
export BUILD_DIR=$(readlink -f ".")
export RESULT_DIR=$result_dir
cd "$hook_dir"
"./D00dependency_hooks"
cd "$trunk_dir"
#sed -i 's/\({GTEST_TEST_COMMAND[_a-zA-Z]*}\)/\1 --gtest_output=xml:.\//' tests/CMakeLists.txt
#head -n19 CMakeLists.txt > a.txt
#cat >> a.txt <<EOF
#option (USE_GCOV "Use coverage profiling for this build" ON)
#if (USE_GCOV)
# set (CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -O0 --coverage ")
#endif (USE_GCOV)
#EOF
#tail -n+20 CMakeLists.txt >> a.txt
#mv a.txt CMakeLists.txt
mk-build-deps --install --tool 'apt-get -y --force-yes' --build-dep debian/control
export DEB_CXXFLAGS_STRIP="-O2"
export DEB_CPPFLAGS_STRIP="-O2"
export DEB_CFLAGS_STRIP="-O2"
export DEB_FFLAGS_STRIP="-O2"
yes | debuild -uc -us -d
cd "$hook_dir"
"./B00build_hooks"
else
echo "Would use pdbuilder"
fi
rm -f -- "ReportDir"
|