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