diff options
author | Modestas Vainius <modestas@vainius.eu> | 2010-03-16 00:32:16 +0200 |
---|---|---|
committer | Modestas Vainius <modestas@vainius.eu> | 2010-03-16 00:32:16 +0200 |
commit | edd5387961a5b01efba9b63ec3d9187462c246ef (patch) | |
tree | b3437ec2c7fe2ef3c7a0198fffd3bb2fca66973b /pkgkde-debs2symbols | |
parent | d750b7bdd629cbec8560d8fbb0d133e5982c7e79 (diff) | |
download | pkg-kde-tools-edd5387961a5b01efba9b63ec3d9187462c246ef.tar.gz |
Reorganize source package directory structure.
- get rid of symbolshelper, debhelper, vcs subdirectires. Move perl modules
to perllib subdirectory and the rest to the top of the source tree;
- unify how datalibdir is found and exported in the Debian::PkgKde module
({find,setup}_datalibdir()). Make pkgkde-gensymbols and
pkgkde-symbolshelper use these new subroutines;
- change datalib path in pkgkde-deb2symbols;
- rewrite Makefile for reorganized source tree.
Diffstat (limited to 'pkgkde-debs2symbols')
-rwxr-xr-x | pkgkde-debs2symbols | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/pkgkde-debs2symbols b/pkgkde-debs2symbols new file mode 100755 index 0000000..37150c3 --- /dev/null +++ b/pkgkde-debs2symbols @@ -0,0 +1,142 @@ +#!/bin/sh + +set -e + +include_common() { + local _dirname + _dirname="`dirname "$0"`" + if [ -n "$_dirname" ] && [ -f "$_dirname/datalib/shell_common" ]; then + . "$_dirname/datalib/shell_common" + else + . /usr/share/pkg-kde-tools/lib/shell_common + fi +} + +usage() { + echo "$PROGNAME: usage:" "$0" "[ -i symbol_file ]" "[ -d debdir ]" "[ -s symboldir ]" package version "[ download_url ]" >&2 +} + + +download() { + local debdir + debdir="$1" + # Download debs + info "Downloading packages from $URL ..." + wget -e robots=off --timestamping --no-directories --directory-prefix="$debdir" \ + --recursive --level=1 --no-parent --accept "$DEB_WILDCARD" "$URL" +} + +extract_deb() { + local deb tmpdir outdir + local arch package version outfile + + deb="$1" + tmpdir="$2" + outdir="$3" + + info2 "Extracting `basename $deb` ..." + dpkg-deb -e "$deb" "$tmpdir/DEBIAN" + dpkg-deb -x "$deb" "$tmpdir" +} + +dump_symbols() { + local tmpdir outdir reffile + local arch package version outfile outpatch + + tmpdir="$1" + outdir="$2" + reffile="$3" + + # Collection information about package + package=$(sed -n '/^Package:/ {s/[^:]\+:[[:space:]]*\(.\+\)/\1/; p; q}' "$tmpdir/DEBIAN/control") + version=$(sed -n '/^Version:/ {s/[^:]\+:[[:space:]]*\(.\+\)/\1/; p; q}' "$tmpdir/DEBIAN/control") + arch=$(sed -n '/^Architecture:/ {s/[^:]\+:[[:space:]]*\(.\+\)/\1/; p; q}' "$tmpdir/DEBIAN/control") + + if [ "$arch" = "all" ]; then + error "it does not make sense to process arch:all package ($deb)" + fi + + if [ -n "$reffile" ]; then + outfile="${package}_${arch}" + patchfile="$outdir/$outfile.patch" + info2 "[$arch] Dumping patch & symbol file as $outfile/$outfile.{patch,symbols} ..." + pkgkde-gensymbols "-p$package" "-P$tmpdir" "-v$version" "-a$arch" \ + -c1 "-I$reffile" -O"$outdir/$outfile.symbols" > "$patchfile" || true + test -s "$patchfile" || rm -f "$patchfile" + else + outfile="${package}_${arch}" + info2 "[$arch] Dumping symbol file as $outfile ..." + pkgkde-gensymbols "-p$package" "-P$tmpdir" "-v$version" "-a$arch" \ + -c0 -q -I/dev/null "-O$outdir/$outfile" + fi +} + +include_common + +# Process options +REFFILE="" +DEBDIR="" +SYMBOLDIR="" +while getopts "i:d:s:" name; do + case "$name" in + i) REFFILE="$OPTARG" ;; + d) DEBDIR="$OPTARG" ;; + s) SYMBOLDIR="$OPTARG" ;; + \?) usage; exit 2 ;; + esac +done + +shift `expr $OPTIND - 1` + +PACKAGE="$1" +VERSION="$2" +URL="$3" + +DEB_WILDCARD="${PACKAGE}_${VERSION}_*.deb" + +if [ -z "$PACKAGE" ] || [ -z "$VERSION" ]; then + usage + exit 2 +fi + +# Create directories to store downloaded debs and symbol files +debdir="${DEBDIR:-${PACKAGE}_${VERSION}_debs}" +symboldir="${SYMBOLDIR:-${PACKAGE}_${VERSION}_symbols}" + +info "Selected directory for packages (*.deb):" "$debdir/" +if [ -n "$URL" ]; then + if [ "${URL#http://}" != "$URL" ] || [ "${URL#ftp://}" != "$URL" ]; then + if [ ! -d "$debdir" ]; then + mkdir "$debdir" + fi + download "$debdir" + else + error "only http:// and ftp:// download URLs are supported" + fi +fi + +# Extract and process debs +c=0 +if [ -d "$debdir" ]; then + tmpdir=`mktemp -d --tmpdir=. tmpdeb.XXXXXX` + rmdir "$tmpdir" + if [ ! -d "$symboldir" ]; then + mkdir "$symboldir" + fi + + info "Selected temporary directory:" "$tmpdir/" + info "Selected directory for symbol files:" "$symboldir/" + for deb in `ls -1 "$debdir"/$DEB_WILDCARD 2>/dev/null | sort`; do + mkdir "$tmpdir" + extract_deb "$deb" "$tmpdir" "$symboldir" + dump_symbols "$tmpdir" "$symboldir" "$REFFILE" + rm -rf "$tmpdir" + c=$(($c+1)) + done +fi + +if [ $c -eq 0 ]; then + error "no '$DEB_WILDCARD' binary packages found in $debdir/" +fi + +info "$c arch specific symbol files dumped successfully to $symboldir/" |