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