4 cd "$(readlink -f $(dirname $0))"
6 if [ -n "${GBP_BUILD_DIR}" ]; then
10 VERSION
=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p')
11 DISTRIBUTION
=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p')
13 LIBAPTPKGVERSION
="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')"
14 LIBAPTINSTVERSION
="$(sed -nr 's/set\(MAJOR ([^)]*)\)/\1/p' apt-inst/CMakeLists.txt)"
16 librarysymbolsfromfile
() {
17 local MISSING
="$(grep '^+#MISSING' "$1")"
19 echo '=== Missing optional symbols:'
20 echo -n "$MISSING" | grep '|optional=' || true
21 echo '=== Missing required symbols:'
22 echo -n "$MISSING" | grep -v '|optional=' || true
23 echo '=== New symbols:'
24 grep '^+ ' "$1" | grep -v '^+ (c++' | cut
-d' ' -f 2 | cut
-d'@' -f 1 | c
++filt
| while read line
; do
25 echo " (c++)\"${line}@${SYMVER}\" $VERSION"
30 echo "Package: apt-test-depends"
32 echo "Architecture: all"
35 for i
in Build
-Depends Build
-Depends-Indep Build
-Depends-Arch; do
36 grep-dctrl -ns $i -S apt .
/debian
/control
&& echo ,
38 grep-dctrl -ns Depends
-F Tests run
-tests .
/debian
/tests
/control
40 | sed -r -e 's#<[^,<>()@]*>##g' \
41 -e 's#@[^,<>()@]*@##g' \
42 -e 's#dpkg-dev \([^)]*\)#dpkg-dev#g' \
43 -e 's#debhelper \([^)]*\)#debhelper#g' \
45 -e 's#,(\s+,)+#, #g' \
49 if [ "$1" = 'pre-export' ]; then
50 libraryversioncheck
() {
53 if [ ! -e "debian/${LIBRARY}${VERSION}.symbols" ]; then
54 echo >&2 "Library ${LIBRARY} in version ${VERSION} has no symbols file! (maybe forgot to rename?)"
57 if [ "$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")" != "${LIBRARY}.so.${VERSION} ${LIBRARY}${VERSION} #MINVER#" ]; then
58 echo >&2 "Library ${LIBRARY}${VERSION} has incorrect version in symbol header! (»$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")«)"
63 libraryversioncheck
'libapt-pkg' "$LIBAPTPKGVERSION"
64 libraryversioncheck
'libapt-inst' "$LIBAPTINSTVERSION"
67 if [ "$DISTRIBUTION" = 'sid' ]; then
68 echo >&2 '»sid« is not a valid distribution. Replace it with »unstable« for you'
69 sed -i -e 's/) sid; urgency=/) unstable; urgency=/' debian
/changelog
70 DISTRIBUTION
='unstable'
71 elif [ "$DISTRIBUTION" = 'UNRELEASED' ]; then
72 echo >&2 'WARNING: Remember to change to a valid distribution for release'
73 VERSION
="$VERSION~$(date +%Y%m%d)"
76 sed -i -e "s/^set(PACKAGE_VERSION \".*\")$/set(PACKAGE_VERSION \"${VERSION}\")/" CMakeLists.txt
77 sed -i -e "s/^<!ENTITY apt-product-version \".*\">$/<!ENTITY apt-product-version \"${VERSION}\">/" doc
/apt
-verbatim.ent
79 # update the last-modification field of manpages based on git changes
80 grep --files-with-matches '<date>' doc
/*.xml
| while read file; do \
81 LASTMOD
="$(date -d "@$
(git log
--format='%at' --max-count=1 --invert-grep --fixed-strings --grep 'review
84 Git-Dch: Ignore' "$file")" '+%Y-%m-%dT00:00:00Z')"
85 sed -i -e "s#^\([ ]\+\)<date>.*</date>\$#\1<date>$LASTMOD</date>#" "$file"
88 if [ "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' po/apt-all.pot | cut -d' ' -f 2)" -o \
89 "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' doc/po/apt-doc.pot | cut -d' ' -f 2)" ]; then
90 echo >&2 'POT files are not up-to-date. Execute »make update-po« for you…'
91 [ -e build
] || mkdir build
92 ( cd build
&& cmake ..
)
93 cmake
--build build
--target update
-po -- -j 4
95 elif [ "$1" = 'pre-build' ]; then
96 if [ "$DISTRIBUTION" = "UNRELEASED" ]; then
97 echo 'BUILDING AN UNRELEASED VERSION'
99 CONFVERSION
="$(sed -ne "s/^set(PACKAGE_VERSION \"\(.*\)\")$/\1/p" CMakeLists.txt
)"
100 if [ "$VERSION" != "$CONFVERSION" ]; then
101 echo "changelog
(${VERSION}) and CMakeLists.txt
(${CONFVERSION}) talk about different versions
!"
102 echo "You probably want to run ».
/prepare
-release pre
-export« to fix this.
"
106 elif [ "$1" = 'post-build' ]; then
107 if [ "$DISTRIBUTION" != "UNRELEASED
" ]; then
108 echo >&2 "REMEMBER
: Tag this release with »git tag
-s ${VERSION}«
if you are satisfied
"
110 echo >&2 'REMEMBER: Change to a valid distribution before release'
113 dpkg-checkbuilddeps -d 'libxml2-utils'
115 HEADERBLUEPRINT="$(mktemp)"
116 sed -n '1,/^$/p' doc/apt.8.xml > "$HEADERBLUEPRINT"
117 find doc -mindepth 1 -maxdepth 1 -type f -name '*.xml' | while read FILE; do
118 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
119 echo >&2 "WARNING
: Manpage
$FILE has not the usual header
! (see
diff below
)"
120 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
123 sed -n '1,/^$/p' doc/guide.dbk > "$HEADERBLUEPRINT"
124 find doc -mindepth 1 -maxdepth 1 -type f -name '*.dbk' | while read FILE; do
125 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
126 echo >&2 "WARNING
: Documentation
$FILE has not the usual header
(see
diff below
)!"
127 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
130 rm "$HEADERBLUEPRINT"
132 # check the manpages with each vendor for vendor-specific errors…
133 find vendor -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do
134 ln -sf ../vendor/${DISTRO}/apt-vendor.ent doc
135 if ! xmllint --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then
136 echo >&2 "WARNING
: original docbook manpages have errors with vendor
${DISTRO}!"
139 # lets assume we will always have a german manpage translation
140 if [ -e */doc/de/ -o -e doc/de ]; then
141 # … but check the translations only with one vendor for translation-specific errors
142 if ! xmllint --path /vendor/$(./vendor/getinfo current)/ \
144 --nonet --valid --noout $(find doc/ */doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then
145 echo >&2 "WARNING
: translated docbook manpages have errors
!"
148 echo >&2 "ERROR
: translated manpages need to be build before they can be checked
!"
150 rm -f doc/apt-vendor.ent
152 elif [ "$1" = 'library' ]; then
154 local libname=$(echo "${1}" | cut -c 4-)
155 local buildlib="build
/bin
/${1}.so.
${2}"
156 for dir in $libname */$libname; do
157 local new_buildlib="$dir/${1}.so.
${2}"
158 if [ -r "${new_buildlib}" ] && [ ! -e "$buildlib" -o "$new_buildlib" -nt "$buildlib" ]; then
159 local buildlib="${new_buildlib}"
162 if [ ! -r "$buildlib" ]; then
163 echo "ERROR
: The library
${1} has to be built before symbols can be checked
!"
166 echo "Checking
$1 in version
$2 build
at $(stat -L -c '%y' "$buildlib")"
167 local tmpfile=$(mktemp)
168 dpkg-gensymbols -p${1}${2} -e${buildlib} -Idebian/${1}${2}.symbols -O/dev/null 2> /dev/null > $tmpfile || true
169 librarysymbolsfromfile "$tmpfile" "$(echo "${1}" | cut -c 4- | tr -d '-' | tr 'a-z' 'A-Z')_
${2}"
172 librarysymbols 'libapt-pkg' "${LIBAPTPKGVERSION}"
174 librarysymbols 'libapt-inst' "${LIBAPTINSTVERSION}"
175 elif [ "$1" = 'buildlog' ]; then
176 while [ -n "$2" ]; do
177 librarysymbolsfromfile "$2" 'UNKNOWN'
180 elif [ "$1" = 'travis-ci' ]; then
181 apt-get install -qy --no-install-recommends dctrl-tools equivs gdebi-core
183 test_deb_control > test-control
184 equivs-build test-control
185 gdebi -n apt-test-depends_1.0_all.deb
186 elif [ "$1" = 'coverage' ]; then
187 DIR="${2:-./coverage}"
188 git clean -dfX # remove ignored build artefacts for a clean start
189 make CFLAGS+='--coverage' CXXFLAGS+='--coverage'
190 LCOVRC='--rc geninfo_checksum=1 --rc lcov_branch_coverage=1'
192 lcov --no-external --directory . --capture --initial --output-file "${DIR}/apt.coverage.init
" ${LCOVRC}
194 ./test/integration/run-tests -q || true
195 lcov --no-external --directory . --capture --output-file "${DIR}/apt.coverage.run
" ${LCOVRC}
196 lcov -a "${DIR}/apt.coverage.init
" -a "${DIR}/apt.coverage.run
" -o "${DIR}/apt.coverage.total
" ${LCOVRC}
197 cp "${DIR}/apt.coverage.total
" "${DIR}/apt.coverage.fixed
"
201 name="$(basename "$file")"
202 while [ -n "$1" ]; do
203 if [ -r "$1/$name" ]; then
204 sed -i "s
#$file#$1/$name#" "${DIR}/apt.coverage.fixed"
210 echo >&2 "Coverage data captured for unknown file $file"
213 grep 'build/include/' "${DIR}/apt.coverage.fixed" | sed "s#^SF:$(pwd)/##" | while read file; do
214 rewritefile
"$file" 'apt-pkg' 'apt-pkg/deb' 'apt-pkg/edsp' 'apt-pkg/contrib' \
215 'apt-inst' 'apt-inst/deb' 'apt-inst/contrib' 'apt-private'
217 genhtml
--output-directory "${DIR}" "${DIR}/apt.coverage.fixed" ${LCOVRC}
219 echo >&1 "Usage:\t$0 pre-export
223 Updating po-files and versions as well as some basic checks are done
224 by »pre-export« which needs to be run before package building.
225 If you use »gbp buildpackage« you will be notified if you forget.
226 »pre-build« and »post-build« can be used to run some more or less
227 useful checks automatically run by »gbp« otherwise.
230 \t$0 buildlog filename…
232 »library« and »buildlog« aren't run automatically but can be useful for
233 maintaining the (more or less experimental) symbols files we provide.
234 »library« displays the diff between advertised symbols and the once provided
235 by the libraries, while »buildlog« extracts this diff from the buildlogs.
236 Both will format the diff properly.
239 \t$0 coverage [output-dir]
241 »travis-ci« is a shortcut to install all build- as well as test-dependencies
243 »coverage« does a clean build with the right flags for coverage reporting,
244 runs all tests and generates a html report in the end.