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