]> git.saurik.com Git - apt.git/blame_incremental - prepare-release
Check if the Apt::Sandbox::User exists in CheckDropPrivsMustBeDisabled()
[apt.git] / prepare-release
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4cd "$(readlink -f $(dirname $0))"
5
6if [ -n "${GBP_BUILD_DIR}" ]; then
7 cd "$GBP_BUILD_DIR"
8fi
9
10VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p')
11DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p')
12
13LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')"
14LIBAPTINSTVERSION="$(grep '^MAJOR=' apt-inst/makefile |cut -d '=' -f 2)"
15
16librarysymbolsfromfile() {
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" | 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
29if [ "$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
62typo
63Git-Dch: Ignore' "$file")" '+%Y-%m-%dT00:00:00Z')"
64 sed -i -e "s#^\([ ]\+\)<date>.*</date>\$#\1<date>$LASTMOD</date>#" "$file"
65 done
66
67 if [ "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' po/apt-all.pot | cut -d' ' -f 2)" -o \
68 "$(date +%Y-%m-%d)" != "$(grep --max-count=1 '^"POT-Creation-Date: .*\n"$' doc/po/apt-doc.pot | cut -d' ' -f 2)" ]; then
69 echo >&2 'POT files are not up-to-date. Execute »make update-po« for you…'
70 make update-po
71 fi
72elif [ "$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
79 dpkg-checkbuilddeps -d 'libxml2-utils'
80
81 HEADERBLUEPRINT="$(mktemp)"
82 sed -n '1,/^$/p' doc/apt.8.xml > "$HEADERBLUEPRINT"
83 find doc -mindepth 1 -maxdepth 1 -type f -name '*.xml' | while read FILE; do
84 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
85 echo >&2 "WARNING: Manpage $FILE has not the usual header! (see diff below)"
86 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
87 fi
88 done
89 sed -n '1,/^$/p' doc/guide.dbk > "$HEADERBLUEPRINT"
90 find doc -mindepth 1 -maxdepth 1 -type f -name '*.dbk' | while read FILE; do
91 if ! sed -n '1,/^$/p' "$FILE" | cmp "$HEADERBLUEPRINT" - >/dev/null 2>&1; then
92 echo >&2 "WARNING: Documentation $FILE has not the usual header (see diff below)!"
93 sed -n '1,/^$/p' "$FILE" | diff -u "$HEADERBLUEPRINT" - || true
94 fi
95 done
96 rm "$HEADERBLUEPRINT"
97
98 # check the manpages with each vendor for vendor-specific errors…
99 find vendor -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do
100 ln -sf ../vendor/${DISTRO}/apt-vendor.ent doc
101 if ! xmllint --nonet --valid --noout $(find doc/ -maxdepth 1 -name '*.xml'); then
102 echo >&2 "WARNING: original docbook manpages have errors with vendor ${DISTRO}!"
103 fi
104 done
105 # lets assume we will always have a german manpage translation
106 if [ -e 'doc/de/' ]; then
107 # … but check the translations only with one vendor for translation-specific errors
108 if ! xmllint --nonet --valid --noout $(find doc/ -mindepth 2 -maxdepth 2 -name '*.xml'); then
109 echo >&2 "WARNING: translated docbook manpages have errors!"
110 fi
111 else
112 echo >&2 "ERROR: translated manpages need to be build before they can be checked!"
113 fi
114 rm -f doc/apt-vendor.ent
115
116elif [ "$1" = 'library' ]; then
117 librarysymbols() {
118 echo "Checking $1 in version $2"
119 local tmpfile=$(mktemp)
120 dpkg-gensymbols -p${1}${2} -ebuild/bin/${1}.so.${2} -Idebian/${1}${2}.symbols -O/dev/null 2> /dev/null > $tmpfile || true
121 librarysymbolsfromfile "$tmpfile" "$(echo "${1}" | cut -c 4- | tr -d '-' | tr 'a-z' 'A-Z')_${2}"
122 rm -f $tmpfile
123 }
124 librarysymbols 'libapt-pkg' "${LIBAPTPKGVERSION}"
125 echo
126 librarysymbols 'libapt-inst' "${LIBAPTINSTVERSION}"
127elif [ "$1" = 'buildlog' ]; then
128 while [ -n "$2" ]; do
129 librarysymbolsfromfile "$2" 'UNKNOWN'
130 shift
131 done
132elif [ "$1" = 'travis-ci' ]; then
133 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 ',')
134 apt-get install -qy --no-install-recommends $(sed -n 's#^Depends: .*@, \(.*\)$#\1#p' debian/tests/control | tr -d ',')
135elif [ "$1" = 'coverage' ]; then
136 DIR="${2:-./coverage}"
137 git clean -dfX # remove ignored build artefacts for a clean start
138 make CFLAGS+='--coverage' CXXFLAGS+='--coverage'
139 LCOVRC='--rc geninfo_checksum=1 --rc lcov_branch_coverage=1'
140 mkdir "$DIR"
141 lcov --no-external --directory . --capture --initial --output-file "${DIR}/apt.coverage.init" ${LCOVRC}
142 make test || true
143 ./test/integration/run-tests -q || true
144 lcov --no-external --directory . --capture --output-file "${DIR}/apt.coverage.run" ${LCOVRC}
145 lcov -a "${DIR}/apt.coverage.init" -a "${DIR}/apt.coverage.run" -o "${DIR}/apt.coverage.total" ${LCOVRC}
146 cp "${DIR}/apt.coverage.total" "${DIR}/apt.coverage.fixed"
147 rewritefile() {
148 file="$1"
149 shift
150 name="$(basename "$file")"
151 while [ -n "$1" ]; do
152 if [ -r "$1/$name" ]; then
153 sed -i "s#$file#$1/$name#" "${DIR}/apt.coverage.fixed"
154 break
155 fi
156 shift
157 done
158 if [ -z "$1" ]; then
159 echo >&2 "Coverage data captured for unknown file $file"
160 fi
161 }
162 grep 'build/include/' "${DIR}/apt.coverage.fixed" | sed "s#^SF:$(pwd)/##" | while read file; do
163 rewritefile "$file" 'apt-pkg' 'apt-pkg/deb' 'apt-pkg/edsp' 'apt-pkg/contrib' \
164 'apt-inst' 'apt-inst/deb' 'apt-inst/contrib' 'apt-private'
165 done
166 genhtml --output-directory "${DIR}" "${DIR}/apt.coverage.fixed" ${LCOVRC}
167else
168 echo >&1 "Usage:\t$0 pre-export
169\t$0 post-build
170
171If you use »gbp buildpackage« you can leave these alone as they will
172be run at the right places auto-magically. Otherwise you should use
173»pre-export« to update po and pot files as well as version numbering.
174»post-build« can be used to run some more or less useful checks later on.
175
176\t$0 library
177\t$0 buildlog filename…
178
179»library« and »buildlog« aren't run automatically but can be useful for
180maintaining the (more or less experimental) symbols files we provide.
181»library« displays the diff between advertised symbols and the once provided
182by the libraries, while »buildlog« extracts this diff from the buildlogs.
183Both will format the diff properly.
184
185\t$0 travis-ci
186\t$0 coverage [output-dir]
187
188»travis-ci« is a shortcut to install all build- as well as test-dependencies
189used by .travis.yml.
190»coverage« does a clean build with the right flags for coverage reporting,
191runs all tests and generates a html report in the end.
192"
193
194fi