]> git.saurik.com Git - apt.git/blame - prepare-release
Release 1.3~rc2
[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/\.$//')"
66eae024 14LIBAPTINSTVERSION="$(sed -nr 's/set\(MAJOR ([^)]*)\)/\1/p' apt-inst/CMakeLists.txt)"
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:'
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
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
66eae024 56 sed -i -e "s/^set(PACKAGE_VERSION \".*\")$/set(PACKAGE_VERSION \"${VERSION}\")/" CMakeLists.txt
fe1f8511
DK
57 sed -i -e "s/^<!ENTITY apt-product-version \".*\">$/<!ENTITY apt-product-version \"${VERSION}\">/" doc/apt-verbatim.ent
58
ab5b1d0d
DK
59 # update the last-modification field of manpages based on git changes
60 grep --files-with-matches '<date>' doc/*.xml | while read file; do \
61 LASTMOD="$(date -d "@$(git log --format='%at' --max-count=1 --invert-grep --fixed-strings --grep 'review
62typo
a95619d0 63release
ab5b1d0d
DK
64Git-Dch: Ignore' "$file")" '+%Y-%m-%dT00:00:00Z')"
65 sed -i -e "s#^\([ ]\+\)<date>.*</date>\$#\1<date>$LASTMOD</date>#" "$file"
66 done
67
3a496cd2
DK
68 if [ "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' po/apt-all.pot | cut -d' ' -f 2)" -o \
69 "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' doc/po/apt-doc.pot | cut -d' ' -f 2)" ]; then
70 echo >&2 'POT files are not up-to-date. Execute »make update-po« for you…'
66eae024
JAK
71 [ -e build ] || mkdir build
72 ( cd build && cmake .. )
73 cmake --build build --target update-po -- -j 4
3a496cd2 74 fi
a95619d0
DK
75elif [ "$1" = 'pre-build' ]; then
76 if [ "$DISTRIBUTION" = "UNRELEASED" ]; then
77 echo 'BUILDING AN UNRELEASED VERSION'
78 else
66eae024 79 CONFVERSION="$(sed -ne "s/^set(PACKAGE_VERSION \"\(.*\)\")$/\1/p" CMakeLists.txt)"
a95619d0 80 if [ "$VERSION" != "$CONFVERSION" ]; then
66eae024 81 echo "changelog (${VERSION}) and CMakeLists.txt (${CONFVERSION}) talk about different versions!"
a95619d0
DK
82 echo "You probably want to run »./prepare-release pre-export« to fix this."
83 exit 1
84 fi
85 fi
3a496cd2
DK
86elif [ "$1" = 'post-build' ]; then
87 if [ "$DISTRIBUTION" != "UNRELEASED" ]; then
ab5b1d0d 88 echo >&2 "REMEMBER: Tag this release with »git tag -s ${VERSION}« if you are satisfied"
3a496cd2
DK
89 else
90 echo >&2 'REMEMBER: Change to a valid distribution before release'
91 fi
0c268997 92
d382a0e4
DK
93 dpkg-checkbuilddeps -d 'libxml2-utils'
94
5abbf5bb
DK
95 HEADERBLUEPRINT="$(mktemp)"
96 sed -n '1,/^$/p' doc/apt.8.xml > "$HEADERBLUEPRINT"
97 find doc -mindepth 1 -maxdepth 1 -type f -name '*.xml' | while read FILE; do
98 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
99 echo >&2 "WARNING: Manpage $FILE has not the usual header! (see diff below)"
100 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
101 fi
102 done
103 sed -n '1,/^$/p' doc/guide.dbk > "$HEADERBLUEPRINT"
104 find doc -mindepth 1 -maxdepth 1 -type f -name '*.dbk' | while read FILE; do
105 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
106 echo >&2 "WARNING: Documentation $FILE has not the usual header (see diff below)!"
107 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
108 fi
109 done
110 rm "$HEADERBLUEPRINT"
111
0c268997
DK
112 # check the manpages with each vendor for vendor-specific errors…
113 find vendor -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do
114 ln -sf ../vendor/${DISTRO}/apt-vendor.ent doc
115 if ! xmllint --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then
116 echo >&2 "WARNING: original docbook manpages have errors with vendor ${DISTRO}!"
117 fi
118 done
01c790a7 119 # lets assume we will always have a german manpage translation
66eae024 120 if [ -e */doc/de/ -o -e doc/de ]; then
01c790a7 121 # … but check the translations only with one vendor for translation-specific errors
66eae024
JAK
122 if ! xmllint --path /vendor/$(./vendor/getinfo current)/ \
123 --path doc/ \
124 --nonet --valid --noout $(find doc/ */doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then
01c790a7
DK
125 echo >&2 "WARNING: translated docbook manpages have errors!"
126 fi
127 else
128 echo >&2 "ERROR: translated manpages need to be build before they can be checked!"
372c2a2d 129 fi
0c268997
DK
130 rm -f doc/apt-vendor.ent
131
5ca28ebd
DK
132elif [ "$1" = 'library' ]; then
133 librarysymbols() {
cc1b834f 134 local libname=$(echo "${1}" | cut -c 4-)
f09dfdbc 135 local buildlib="build/bin/${1}.so.${2}"
cc1b834f
JAK
136 for dir in $libname */$libname; do
137 local new_buildlib="$dir/${1}.so.${2}"
138 if [ -r "${new_buildlib}" ] && [ ! -e "$buildlib" -o "$new_buildlib" -nt "$buildlib" ]; then
139 local buildlib="${new_buildlib}"
140 fi
141 done
f09dfdbc
DK
142 if [ ! -r "$buildlib" ]; then
143 echo "ERROR: The library ${1} has to be built before symbols can be checked!"
144 return
145 fi
146 echo "Checking $1 in version $2 build at $(stat -L -c '%y' "$buildlib")"
58921d7d 147 local tmpfile=$(mktemp)
f09dfdbc 148 dpkg-gensymbols -p${1}${2} -e${buildlib} -Idebian/${1}${2}.symbols -O/dev/null 2> /dev/null > $tmpfile || true
ae97af1f 149 librarysymbolsfromfile "$tmpfile" "$(echo "${1}" | cut -c 4- | tr -d '-' | tr 'a-z' 'A-Z')_${2}"
f1d87437 150 rm -f $tmpfile
5ca28ebd
DK
151 }
152 librarysymbols 'libapt-pkg' "${LIBAPTPKGVERSION}"
153 echo
154 librarysymbols 'libapt-inst' "${LIBAPTINSTVERSION}"
4c90bc28
DK
155elif [ "$1" = 'buildlog' ]; then
156 while [ -n "$2" ]; do
ae97af1f 157 librarysymbolsfromfile "$2" 'UNKNOWN'
4c90bc28
DK
158 shift
159 done
d382a0e4 160elif [ "$1" = 'travis-ci' ]; then
19fdf93d
DK
161 apt-get install -qy --no-install-recommends dctrl-tools
162 apt-get install -qy --no-install-recommends $(grep-dctrl -S -s Build-Depends,Build-Depends-Indep,Build-Depends-Arch apt ./debian/control | sed -e 's#([^)]*)##g' -e 's#^Build-Depends\(-Indep\|-Arch\)\?: ##' -e 's#<.*>##g' | tr -s '\n,' ' ')
163 apt-get install -qy --no-install-recommends $(grep-dctrl -F Tests -s Depends run-tests ./debian/tests/control | tr -s '\n,' ' ' | cut -d'@' -f 4- | sed -e 's#gnupg1#gnupg2#' -e 's#gpgv1#gpgv2#')
13fe505c
DK
164elif [ "$1" = 'coverage' ]; then
165 DIR="${2:-./coverage}"
166 git clean -dfX # remove ignored build artefacts for a clean start
167 make CFLAGS+='--coverage' CXXFLAGS+='--coverage'
168 LCOVRC='--rc geninfo_checksum=1 --rc lcov_branch_coverage=1'
169 mkdir "$DIR"
170 lcov --no-external --directory . --capture --initial --output-file "${DIR}/apt.coverage.init" ${LCOVRC}
ad7e0941
DK
171 make test || true
172 ./test/integration/run-tests -q || true
13fe505c
DK
173 lcov --no-external --directory . --capture --output-file "${DIR}/apt.coverage.run" ${LCOVRC}
174 lcov -a "${DIR}/apt.coverage.init" -a "${DIR}/apt.coverage.run" -o "${DIR}/apt.coverage.total" ${LCOVRC}
175 cp "${DIR}/apt.coverage.total" "${DIR}/apt.coverage.fixed"
176 rewritefile() {
177 file="$1"
178 shift
179 name="$(basename "$file")"
180 while [ -n "$1" ]; do
181 if [ -r "$1/$name" ]; then
182 sed -i "s#$file#$1/$name#" "${DIR}/apt.coverage.fixed"
183 break
184 fi
185 shift
186 done
187 if [ -z "$1" ]; then
188 echo >&2 "Coverage data captured for unknown file $file"
189 fi
190 }
191 grep 'build/include/' "${DIR}/apt.coverage.fixed" | sed "s#^SF:$(pwd)/##" | while read file; do
192 rewritefile "$file" 'apt-pkg' 'apt-pkg/deb' 'apt-pkg/edsp' 'apt-pkg/contrib' \
193 'apt-inst' 'apt-inst/deb' 'apt-inst/contrib' 'apt-private'
194 done
195 genhtml --output-directory "${DIR}" "${DIR}/apt.coverage.fixed" ${LCOVRC}
3a496cd2
DK
196else
197 echo >&1 "Usage:\t$0 pre-export
a95619d0 198\t$0 pre-build
3a496cd2
DK
199\t$0 post-build
200
a95619d0
DK
201Updating po-files and versions as well as some basic checks are done
202by »pre-export« which needs to be run before package building.
203If you use »gbp buildpackage« you will be notified if you forget.
204»pre-build« and »post-build« can be used to run some more or less
205useful checks automatically run by »gbp« otherwise.
5ca28ebd 206
13fe505c
DK
207\t$0 library
208\t$0 buildlog filename…
209
210»library« and »buildlog« aren't run automatically but can be useful for
211maintaining the (more or less experimental) symbols files we provide.
212»library« displays the diff between advertised symbols and the once provided
213by the libraries, while »buildlog« extracts this diff from the buildlogs.
214Both will format the diff properly.
215
216\t$0 travis-ci
217\t$0 coverage [output-dir]
218
219»travis-ci« is a shortcut to install all build- as well as test-dependencies
220used by .travis.yml.
221»coverage« does a clean build with the right flags for coverage reporting,
222runs all tests and generates a html report in the end.
223"
224
3a496cd2 225fi