prepare-release 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #!/bin/sh
  2. set -e
  3. cd "$(readlink -f $(dirname $0))"
  4. if [ -n "${GBP_BUILD_DIR}" ]; then
  5. cd "$GBP_BUILD_DIR"
  6. fi
  7. VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p')
  8. DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p')
  9. LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')"
  10. LIBAPTINSTVERSION="$(grep '^MAJOR=' apt-inst/makefile |cut -d '=' -f 2)"
  11. librarysymbolsfromfile() {
  12. local MISSING="$(grep '^+#MISSING' "$1")"
  13. local SYMVER="$2"
  14. echo '=== Missing optional symbols:'
  15. echo -n "$MISSING" | grep '|optional=' || true
  16. echo '=== Missing required symbols:'
  17. echo -n "$MISSING" | grep -v '|optional=' || true
  18. echo '=== New symbols:'
  19. grep '^+ ' "$1" | cut -d' ' -f 2 | cut -d'@' -f 1 | c++filt | while read line; do
  20. echo " (c++)\"${line}@${SYMVER}\" $VERSION"
  21. done | sort -u
  22. }
  23. if [ "$1" = 'pre-export' ]; then
  24. libraryversioncheck() {
  25. local LIBRARY="$1"
  26. local VERSION="$2"
  27. if [ ! -e "debian/${LIBRARY}${VERSION}.symbols" ]; then
  28. echo >&2 "Library ${LIBRARY} in version ${VERSION} has no symbols file! (maybe forgot to rename?)"
  29. exit 1
  30. fi
  31. if [ "$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")" != "${LIBRARY}.so.${VERSION} ${LIBRARY}${VERSION} #MINVER#" ]; then
  32. echo >&2 "Library ${LIBRARY}${VERSION} has incorrect version in symbol header! (»$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")«)"
  33. exit 2
  34. fi
  35. }
  36. libraryversioncheck 'libapt-pkg' "$LIBAPTPKGVERSION"
  37. libraryversioncheck 'libapt-inst' "$LIBAPTINSTVERSION"
  38. if [ "$DISTRIBUTION" = 'sid' ]; then
  39. echo >&2 '»sid« is not a valid distribution. Replace it with »unstable« for you'
  40. sed -i -e 's/) sid; urgency=/) unstable; urgency=/' debian/changelog
  41. DISTRIBUTION='unstable'
  42. elif [ "$DISTRIBUTION" = 'UNRELEASED' ]; then
  43. echo >&2 'WARNING: Remember to change to a valid distribution for release'
  44. VERSION="$VERSION~$(date +%Y%m%d)"
  45. fi
  46. sed -i -e "s/^PACKAGE_VERSION=\".*\"$/PACKAGE_VERSION=\"${VERSION}\"/" configure.ac
  47. sed -i -e "s/^<!ENTITY apt-product-version \".*\">$/<!ENTITY apt-product-version \"${VERSION}\">/" doc/apt-verbatim.ent
  48. # update the last-modification field of manpages based on git changes
  49. grep --files-with-matches '<date>' doc/*.xml | while read file; do \
  50. LASTMOD="$(date -d "@$(git log --format='%at' --max-count=1 --invert-grep --fixed-strings --grep 'review
  51. typo
  52. release
  53. Git-Dch: Ignore' "$file")" '+%Y-%m-%dT00:00:00Z')"
  54. sed -i -e "s#^\([ ]\+\)<date>.*</date>\$#\1<date>$LASTMOD</date>#" "$file"
  55. done
  56. if [ "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' po/apt-all.pot | cut -d' ' -f 2)" -o \
  57. "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' doc/po/apt-doc.pot | cut -d' ' -f 2)" ]; then
  58. echo >&2 'POT files are not up-to-date. Execute »make update-po« for you…'
  59. make update-po
  60. fi
  61. elif [ "$1" = 'pre-build' ]; then
  62. if [ "$DISTRIBUTION" = "UNRELEASED" ]; then
  63. echo 'BUILDING AN UNRELEASED VERSION'
  64. else
  65. CONFVERSION="$(sed -ne "s/^PACKAGE_VERSION=\"\(.*\)\"$/\1/p" configure.ac)"
  66. if [ "$VERSION" != "$CONFVERSION" ]; then
  67. echo "changelog (${VERSION}) and configure (${CONFVERSION}) talk about different versions!"
  68. echo "You probably want to run »./prepare-release pre-export« to fix this."
  69. exit 1
  70. fi
  71. fi
  72. elif [ "$1" = 'post-build' ]; then
  73. if [ "$DISTRIBUTION" != "UNRELEASED" ]; then
  74. echo >&2 "REMEMBER: Tag this release with »git tag -s ${VERSION}« if you are satisfied"
  75. else
  76. echo >&2 'REMEMBER: Change to a valid distribution before release'
  77. fi
  78. dpkg-checkbuilddeps -d 'libxml2-utils'
  79. HEADERBLUEPRINT="$(mktemp)"
  80. sed -n '1,/^$/p' doc/apt.8.xml > "$HEADERBLUEPRINT"
  81. find doc -mindepth 1 -maxdepth 1 -type f -name '*.xml' | while read FILE; do
  82. if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
  83. echo >&2 "WARNING: Manpage $FILE has not the usual header! (see diff below)"
  84. sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
  85. fi
  86. done
  87. sed -n '1,/^$/p' doc/guide.dbk > "$HEADERBLUEPRINT"
  88. find doc -mindepth 1 -maxdepth 1 -type f -name '*.dbk' | while read FILE; do
  89. if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
  90. echo >&2 "WARNING: Documentation $FILE has not the usual header (see diff below)!"
  91. sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
  92. fi
  93. done
  94. rm "$HEADERBLUEPRINT"
  95. # check the manpages with each vendor for vendor-specific errors…
  96. find vendor -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do
  97. ln -sf ../vendor/${DISTRO}/apt-vendor.ent doc
  98. if ! xmllint --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then
  99. echo >&2 "WARNING: original docbook manpages have errors with vendor ${DISTRO}!"
  100. fi
  101. done
  102. # lets assume we will always have a german manpage translation
  103. if [ -e 'doc/de/' ]; then
  104. # … but check the translations only with one vendor for translation-specific errors
  105. if ! xmllint --nonet --valid --noout $(find doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then
  106. echo >&2 "WARNING: translated docbook manpages have errors!"
  107. fi
  108. else
  109. echo >&2 "ERROR: translated manpages need to be build before they can be checked!"
  110. fi
  111. rm -f doc/apt-vendor.ent
  112. elif [ "$1" = 'library' ]; then
  113. librarysymbols() {
  114. local buildlib="build/bin/${1}.so.${2}"
  115. if [ ! -r "$buildlib" ]; then
  116. echo "ERROR: The library ${1} has to be built before symbols can be checked!"
  117. return
  118. fi
  119. echo "Checking $1 in version $2 build at $(stat -L -c '%y' "$buildlib")"
  120. local tmpfile=$(mktemp)
  121. dpkg-gensymbols -p${1}${2} -e${buildlib} -Idebian/${1}${2}.symbols -O/dev/null 2> /dev/null > $tmpfile || true
  122. librarysymbolsfromfile "$tmpfile" "$(echo "${1}" | cut -c 4- | tr -d '-' | tr 'a-z' 'A-Z')_${2}"
  123. rm -f $tmpfile
  124. }
  125. librarysymbols 'libapt-pkg' "${LIBAPTPKGVERSION}"
  126. echo
  127. librarysymbols 'libapt-inst' "${LIBAPTINSTVERSION}"
  128. elif [ "$1" = 'buildlog' ]; then
  129. while [ -n "$2" ]; do
  130. librarysymbolsfromfile "$2" 'UNKNOWN'
  131. shift
  132. done
  133. elif [ "$1" = 'travis-ci' ]; then
  134. apt-get install -qy --no-install-recommends $(sed -n -e '/^Build-Depends: /,/^Build-Depends-Indep: / {p}' debian/control | sed -e 's#([^)]*)##g' -e 's#^Build-Depends\(-Indep\)\?: ##' -e 's#<.*>##g' | tr -d ',')
  135. apt-get install -qy --no-install-recommends $(sed -n 's#^Depends: .*@, \(.*\)$#\1#p' debian/tests/control | tr -d ',')
  136. elif [ "$1" = 'coverage' ]; then
  137. DIR="${2:-./coverage}"
  138. git clean -dfX # remove ignored build artefacts for a clean start
  139. make CFLAGS+='--coverage' CXXFLAGS+='--coverage'
  140. LCOVRC='--rc geninfo_checksum=1 --rc lcov_branch_coverage=1'
  141. mkdir "$DIR"
  142. lcov --no-external --directory . --capture --initial --output-file "${DIR}/apt.coverage.init" ${LCOVRC}
  143. make test || true
  144. ./test/integration/run-tests -q || true
  145. lcov --no-external --directory . --capture --output-file "${DIR}/apt.coverage.run" ${LCOVRC}
  146. lcov -a "${DIR}/apt.coverage.init" -a "${DIR}/apt.coverage.run" -o "${DIR}/apt.coverage.total" ${LCOVRC}
  147. cp "${DIR}/apt.coverage.total" "${DIR}/apt.coverage.fixed"
  148. rewritefile() {
  149. file="$1"
  150. shift
  151. name="$(basename "$file")"
  152. while [ -n "$1" ]; do
  153. if [ -r "$1/$name" ]; then
  154. sed -i "s#$file#$1/$name#" "${DIR}/apt.coverage.fixed"
  155. break
  156. fi
  157. shift
  158. done
  159. if [ -z "$1" ]; then
  160. echo >&2 "Coverage data captured for unknown file $file"
  161. fi
  162. }
  163. grep 'build/include/' "${DIR}/apt.coverage.fixed" | sed "s#^SF:$(pwd)/##" | while read file; do
  164. rewritefile "$file" 'apt-pkg' 'apt-pkg/deb' 'apt-pkg/edsp' 'apt-pkg/contrib' \
  165. 'apt-inst' 'apt-inst/deb' 'apt-inst/contrib' 'apt-private'
  166. done
  167. genhtml --output-directory "${DIR}" "${DIR}/apt.coverage.fixed" ${LCOVRC}
  168. else
  169. echo >&1 "Usage:\t$0 pre-export
  170. \t$0 pre-build
  171. \t$0 post-build
  172. Updating po-files and versions as well as some basic checks are done
  173. by »pre-export« which needs to be run before package building.
  174. If you use »gbp buildpackage« you will be notified if you forget.
  175. »pre-build« and »post-build« can be used to run some more or less
  176. useful checks automatically run by »gbp« otherwise.
  177. \t$0 library
  178. \t$0 buildlog filename…
  179. »library« and »buildlog« aren't run automatically but can be useful for
  180. maintaining the (more or less experimental) symbols files we provide.
  181. »library« displays the diff between advertised symbols and the once provided
  182. by the libraries, while »buildlog« extracts this diff from the buildlogs.
  183. Both will format the diff properly.
  184. \t$0 travis-ci
  185. \t$0 coverage [output-dir]
  186. »travis-ci« is a shortcut to install all build- as well as test-dependencies
  187. used by .travis.yml.
  188. »coverage« does a clean build with the right flags for coverage reporting,
  189. runs all tests and generates a html report in the end.
  190. "
  191. fi