]>
Commit | Line | Data |
---|---|---|
3a496cd2 | 1 | #!/bin/sh |
fb83d0cc SL |
2 | set -e |
3 | ||
a5414e56 | 4 | cd "$(readlink -f $(dirname $0))" |
01c790a7 DK |
5 | |
6 | if [ -n "${GBP_BUILD_DIR}" ]; then | |
7 | cd "$GBP_BUILD_DIR" | |
8 | fi | |
9 | ||
3a496cd2 DK |
10 | VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p') |
11 | DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p') | |
12 | ||
54298f49 | 13 | LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')" |
66eae024 | 14 | LIBAPTINSTVERSION="$(sed -nr 's/set\(MAJOR ([^)]*)\)/\1/p' apt-inst/CMakeLists.txt)" |
5ca28ebd | 15 | |
4c90bc28 DK |
16 | librarysymbolsfromfile() { |
17 | local MISSING="$(grep '^+#MISSING' "$1")" | |
ae97af1f | 18 | local SYMVER="$2" |
4c90bc28 DK |
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:' | |
382704d5 | 24 | grep '^+ ' "$1" | grep -v '^+ (c++' | cut -d' ' -f 2 | cut -d'@' -f 1 | c++filt | while read line; do |
ae97af1f | 25 | echo " (c++)\"${line}@${SYMVER}\" $VERSION" |
4c90bc28 DK |
26 | done | sort -u |
27 | } | |
28 | ||
ecb8e9d7 JAK |
29 | test_deb_control() { |
30 | echo "Package: apt-test-depends" | |
31 | echo "Version: 1.0" | |
32 | echo "Architecture: all" | |
33 | printf "Depends:" | |
34 | ( | |
35 | for i in Build-Depends Build-Depends-Indep Build-Depends-Arch; do | |
36 | grep-dctrl -ns $i -S apt ./debian/control && echo , | |
37 | done | |
38 | grep-dctrl -ns Depends -F Tests run-tests ./debian/tests/control | |
39 | ) | tr '\n' ' '\ | |
40 | | sed -r -e 's#<[^,<>()@]*>##g' \ | |
41 | -e 's#@[^,<>()@]*@##g' \ | |
42 | -e 's#dpkg-dev \([^)]*\)#dpkg-dev#g' \ | |
43 | -e 's#debhelper \([^)]*\)#debhelper#g' \ | |
44 | -e 's#@##g' \ | |
45 | -e 's#,(\s+,)+#, #g' \ | |
46 | -e 's#\s+# #g' | |
47 | } | |
48 | ||
3a496cd2 | 49 | if [ "$1" = 'pre-export' ]; then |
154fd04e | 50 | libraryversioncheck() { |
58921d7d DK |
51 | local LIBRARY="$1" |
52 | local VERSION="$2" | |
154fd04e DK |
53 | if [ ! -e "debian/${LIBRARY}${VERSION}.symbols" ]; then |
54 | echo >&2 "Library ${LIBRARY} in version ${VERSION} has no symbols file! (maybe forgot to rename?)" | |
55 | exit 1 | |
56 | fi | |
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")«)" | |
59 | exit 2 | |
60 | fi | |
61 | } | |
62 | ||
5ca28ebd DK |
63 | libraryversioncheck 'libapt-pkg' "$LIBAPTPKGVERSION" |
64 | libraryversioncheck 'libapt-inst' "$LIBAPTINSTVERSION" | |
154fd04e DK |
65 | |
66 | ||
3a496cd2 DK |
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)" | |
74 | fi | |
75 | ||
66eae024 | 76 | sed -i -e "s/^set(PACKAGE_VERSION \".*\")$/set(PACKAGE_VERSION \"${VERSION}\")/" CMakeLists.txt |
fe1f8511 DK |
77 | sed -i -e "s/^<!ENTITY apt-product-version \".*\">$/<!ENTITY apt-product-version \"${VERSION}\">/" doc/apt-verbatim.ent |
78 | ||
ab5b1d0d DK |
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 | |
82 | typo | |
a95619d0 | 83 | release |
ab5b1d0d DK |
84 | Git-Dch: Ignore' "$file")" '+%Y-%m-%dT00:00:00Z')" |
85 | sed -i -e "s#^\([ ]\+\)<date>.*</date>\$#\1<date>$LASTMOD</date>#" "$file" | |
86 | done | |
87 | ||
3a496cd2 DK |
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…' | |
66eae024 JAK |
91 | [ -e build ] || mkdir build |
92 | ( cd build && cmake .. ) | |
93 | cmake --build build --target update-po -- -j 4 | |
3a496cd2 | 94 | fi |
a95619d0 DK |
95 | elif [ "$1" = 'pre-build' ]; then |
96 | if [ "$DISTRIBUTION" = "UNRELEASED" ]; then | |
97 | echo 'BUILDING AN UNRELEASED VERSION' | |
98 | else | |
66eae024 | 99 | CONFVERSION="$(sed -ne "s/^set(PACKAGE_VERSION \"\(.*\)\")$/\1/p" CMakeLists.txt)" |
a95619d0 | 100 | if [ "$VERSION" != "$CONFVERSION" ]; then |
66eae024 | 101 | echo "changelog (${VERSION}) and CMakeLists.txt (${CONFVERSION}) talk about different versions!" |
a95619d0 DK |
102 | echo "You probably want to run »./prepare-release pre-export« to fix this." |
103 | exit 1 | |
104 | fi | |
105 | fi | |
3a496cd2 DK |
106 | elif [ "$1" = 'post-build' ]; then |
107 | if [ "$DISTRIBUTION" != "UNRELEASED" ]; then | |
ab5b1d0d | 108 | echo >&2 "REMEMBER: Tag this release with »git tag -s ${VERSION}« if you are satisfied" |
3a496cd2 DK |
109 | else |
110 | echo >&2 'REMEMBER: Change to a valid distribution before release' | |
111 | fi | |
0c268997 | 112 | |
d382a0e4 DK |
113 | dpkg-checkbuilddeps -d 'libxml2-utils' |
114 | ||
5abbf5bb DK |
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 | |
121 | fi | |
122 | done | |
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 | |
128 | fi | |
129 | done | |
130 | rm "$HEADERBLUEPRINT" | |
131 | ||
0c268997 DK |
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}!" | |
137 | fi | |
138 | done | |
01c790a7 | 139 | # lets assume we will always have a german manpage translation |
66eae024 | 140 | if [ -e */doc/de/ -o -e doc/de ]; then |
01c790a7 | 141 | # … but check the translations only with one vendor for translation-specific errors |
66eae024 JAK |
142 | if ! xmllint --path /vendor/$(./vendor/getinfo current)/ \ |
143 | --path doc/ \ | |
144 | --nonet --valid --noout $(find doc/ */doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then | |
01c790a7 DK |
145 | echo >&2 "WARNING: translated docbook manpages have errors!" |
146 | fi | |
147 | else | |
148 | echo >&2 "ERROR: translated manpages need to be build before they can be checked!" | |
372c2a2d | 149 | fi |
0c268997 DK |
150 | rm -f doc/apt-vendor.ent |
151 | ||
5ca28ebd DK |
152 | elif [ "$1" = 'library' ]; then |
153 | librarysymbols() { | |
cc1b834f | 154 | local libname=$(echo "${1}" | cut -c 4-) |
f09dfdbc | 155 | local buildlib="build/bin/${1}.so.${2}" |
cc1b834f JAK |
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}" | |
160 | fi | |
161 | done | |
f09dfdbc DK |
162 | if [ ! -r "$buildlib" ]; then |
163 | echo "ERROR: The library ${1} has to be built before symbols can be checked!" | |
164 | return | |
165 | fi | |
166 | echo "Checking $1 in version $2 build at $(stat -L -c '%y' "$buildlib")" | |
58921d7d | 167 | local tmpfile=$(mktemp) |
f09dfdbc | 168 | dpkg-gensymbols -p${1}${2} -e${buildlib} -Idebian/${1}${2}.symbols -O/dev/null 2> /dev/null > $tmpfile || true |
ae97af1f | 169 | librarysymbolsfromfile "$tmpfile" "$(echo "${1}" | cut -c 4- | tr -d '-' | tr 'a-z' 'A-Z')_${2}" |
f1d87437 | 170 | rm -f $tmpfile |
5ca28ebd DK |
171 | } |
172 | librarysymbols 'libapt-pkg' "${LIBAPTPKGVERSION}" | |
173 | echo | |
174 | librarysymbols 'libapt-inst' "${LIBAPTINSTVERSION}" | |
4c90bc28 DK |
175 | elif [ "$1" = 'buildlog' ]; then |
176 | while [ -n "$2" ]; do | |
ae97af1f | 177 | librarysymbolsfromfile "$2" 'UNKNOWN' |
4c90bc28 DK |
178 | shift |
179 | done | |
d382a0e4 | 180 | elif [ "$1" = 'travis-ci' ]; then |
ecb8e9d7 JAK |
181 | apt-get install -qy --no-install-recommends dctrl-tools equivs gdebi-core |
182 | ||
183 | test_deb_control > test-control | |
184 | equivs-build test-control | |
185 | gdebi -n apt-test-depends_1.0_all.deb | |
13fe505c DK |
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' | |
191 | mkdir "$DIR" | |
192 | lcov --no-external --directory . --capture --initial --output-file "${DIR}/apt.coverage.init" ${LCOVRC} | |
ad7e0941 DK |
193 | make test || true |
194 | ./test/integration/run-tests -q || true | |
13fe505c DK |
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" | |
198 | rewritefile() { | |
199 | file="$1" | |
200 | shift | |
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" | |
205 | break | |
206 | fi | |
207 | shift | |
208 | done | |
209 | if [ -z "$1" ]; then | |
210 | echo >&2 "Coverage data captured for unknown file $file" | |
211 | fi | |
212 | } | |
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' | |
216 | done | |
217 | genhtml --output-directory "${DIR}" "${DIR}/apt.coverage.fixed" ${LCOVRC} | |
3a496cd2 DK |
218 | else |
219 | echo >&1 "Usage:\t$0 pre-export | |
a95619d0 | 220 | \t$0 pre-build |
3a496cd2 DK |
221 | \t$0 post-build |
222 | ||
a95619d0 DK |
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. | |
5ca28ebd | 228 | |
13fe505c DK |
229 | \t$0 library |
230 | \t$0 buildlog filename… | |
231 | ||
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. | |
237 | ||
238 | \t$0 travis-ci | |
239 | \t$0 coverage [output-dir] | |
240 | ||
241 | »travis-ci« is a shortcut to install all build- as well as test-dependencies | |
242 | used by .travis.yml. | |
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. | |
245 | " | |
246 | ||
3a496cd2 | 247 | fi |