1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#!/bin/bash
# This script assumes that it will be called like:
#
# SCRIPT --upstream-version VERSION
#
# It also assumes that it will be invoked from inside the source tree.
#
# It works with uscan v4.
set -ex
set -o pipefail
die()
{
printf "E: %s\n" "$*"
exit 1
}
UPSTREAM_VERSION="${2}"
TARBALL=$(realpath -e "../gdb_${UPSTREAM_VERSION}.orig.tar.xz")
TARDIR=$(dirname "${TARBALL}")
DFSG_TAR="${TARDIR}/gdb_${UPSTREAM_VERSION}.orig.tar.xz"
DOC_TAR="${TARDIR}/gdb-doc_${UPSTREAM_VERSION}.orig.tar.xz"
tmpdir=$(mktemp -d)
trap 'rm -rf "${tmpdir}"' EXIT ERR INT
cd "${tmpdir}"
mkdir src
cd src
tar xf "${TARBALL}"
cd ..
src=$(readlink -f "src/gdb-${UPSTREAM_VERSION}")
dest=$(readlink -f "gdb-${UPSTREAM_VERSION}")
destdoc=$(readlink -f "gdb-doc-${UPSTREAM_VERSION}")
[ ! -d "${src}" ] && die "Could not find source directory ${src}"
if [ -z "${dest}" ] || [ -e "${dest}" ]; then
die "Could not create dest directory ${dest}"
fi
cp -a "${src}" "${dest}"
cp -a "${src}" "${destdoc}"
pushd "${dest}" > /dev/null
# All of the gdb manpages are GFDL'd now
find gdb -type f -name '*.[1-9]' -delete
# Almost all of the texinfo documentation is GFDL. PSIM's is not, but
# we don't need that manual especially anyway. Special care must be taken
# with observer.texi, which is necessary for the build process. Remove
# all pregenerated info files, then replace all texinfo files with dummy
# versions.
find . -type f \( -name '*.info' -o -name '*.info-*' \) -delete
find . -type f -name '*.chm' -delete
find . -type f \( -name '*.texinfo' -o -name '*.texi' \) | \
while read -r file; do
if [ "$(basename "${file}")" = "observer.texi" ]; then
sed -ne '/@c This/,/@c any later/p; /@deftype/p' "${src}/${file}" > "${file}"
continue
fi
echo > "${file}"
done
popd > /dev/null
tar --auto-compress -cf "${DFSG_TAR}" "gdb-${UPSTREAM_VERSION}"
pushd "${destdoc}" > /dev/null
find . -type f -name '*.chm' -delete
popd > /dev/null
tar --auto-compress -cf "${DOC_TAR}" "gdb-doc-${UPSTREAM_VERSION}"
|