summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2009-01-26 18:10:49 -0500
committerWill Woods <wwoods@redhat.com>2009-01-26 18:10:49 -0500
commit06b40afc07f6d99c0f1dbc9a99ef00be7f4d76ef (patch)
tree04faee9151a228de36af90862ce4352c21087ef2
downloaddebuginfofs-06b40afc07f6d99c0f1dbc9a99ef00be7f4d76ef.tar.gz
debuginfofs-06b40afc07f6d99c0f1dbc9a99ef00be7f4d76ef.tar.xz
debuginfofs-06b40afc07f6d99c0f1dbc9a99ef00be7f4d76ef.zip
Initial commit
-rw-r--r--TODO6
-rw-r--r--config.sh13
-rw-r--r--dav-debuginfo.conf17
-rwxr-xr-xdebuginfofs.init98
-rw-r--r--debuginfofs.sysconfig3
-rwxr-xr-xmake-links.sh39
-rwxr-xr-xrsync-debuginfo.sh35
-rwxr-xr-xunpack-debuginfo.sh68
8 files changed, 279 insertions, 0 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..1058fa1
--- /dev/null
+++ b/TODO
@@ -0,0 +1,6 @@
+- write script to fetch all (debuginfo) packages for distro/arch
+ - use yum repo config files
+- use unpack-debuginfo.sh to do a Proof-of-Concept demo on F10
+- rewrite unpack-debuginfo.sh in Python (for importing elsewhere)
+- NEED SOURCE FILES.
+ - auto-generate per-session mounts, or make the filenames unique somehow?
diff --git a/config.sh b/config.sh
new file mode 100644
index 0000000..c608e80
--- /dev/null
+++ b/config.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# config.sh - set some config data for debuginfofs scripts
+#
+# GPLv2+. BOILERPLATE SHOULD GO HERE.
+#
+# Copyright 2009 Red Hat, Inc.
+# Author: Will Woods <wwoods@redhat.com>
+
+debug="yes"
+verbose="yes"
+libdir="/var/lib/debuginfofs"
+cachedir="/var/cache/debuginfofs"
+exportdir="/var/www/debuginfofs"
diff --git a/dav-debuginfo.conf b/dav-debuginfo.conf
new file mode 100644
index 0000000..f1c9160
--- /dev/null
+++ b/dav-debuginfo.conf
@@ -0,0 +1,17 @@
+# Export debuginfo as a readonly DAV share
+# See also: /usr/share/gnome-user-share/dav_user.conf
+
+#Alias /debuginfofs/src /var/www/debuginfofs/src
+#Alias /debuginfofs/lib /var/www/debuginfofs/lib
+#<LocationMatch "/debuginfofs/(src|lib)">
+
+Alias /debuginfofs /var/www/debuginfofs
+<Location "/debuginfofs">
+ AllowOverride None
+ DAV On
+ <LimitExcept GET HEAD OPTIONS PROPFIND>
+ Order allow,deny
+ Deny from all
+ </LimitExcept>
+</Location>
+#</LocationMatch>
diff --git a/debuginfofs.init b/debuginfofs.init
new file mode 100755
index 0000000..09e93e8
--- /dev/null
+++ b/debuginfofs.init
@@ -0,0 +1,98 @@
+#!/bin/bash
+#
+### BEGIN INIT INFO
+# Provides: debuginfofs
+# Required-Start: $local_fs $network $named $remote_fs $syslog
+# Required-Stop: $local_fs $network $named $remote_fs $syslog
+# Short-Description: Remote debuginfo filesystem
+# Description: Mount a remote debuginfo filesystem for use with debugging tools
+#
+### END INIT INFO
+
+# debuginfofs This shell script takes care of mounting and unmounting the
+# debuginfo filesystem.
+#
+# chkconfig: - 60 50
+# description: debuginfofs mounts a WebDAV share of debuginfo files at the \
+# appropriate place(s) in the filesystem for use by gdb and other \
+# debugging tools.
+# config: /etc/sysconfig/debuginfofs
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Source our configuration
+. /etc/sysconfig/debuginfofs
+
+RETVAL=0
+prog="debuginfofs"
+
+start() {
+ # Mount filesystems.
+
+ # Check that networking is up.
+ [ ${NETWORKING} = "no" ] && exit 1
+
+ # Sanity check binary and configuration
+ [ -x /usr/bin/wdfs ] || exit 1
+ [ -n "$BUILDID_URL" ] || exit 1
+ [ -n "$BUILDID_MOUNTPOINT" ] || exit 1
+ [ -d "$BUILDID_MOUNTPOINT" ] || mkdir -p "$BUILDID_MOUNTPOINT"
+
+ echo -n $"Starting debuginfofs: "
+ # TODO: consider -o kernel_cache
+ # TODO: consider -o entry_timeout=60 -o attr_timeout=60
+ # TODO: consider -o intr
+ wdfs "$BUILDID_URL" "$BUILDID_MOUNTPOINT" -o allow_other -o nonempty \
+ $BUILDID_ARGS
+ RETVAL=$?
+
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
+ [ $RETVAL -eq 0 ] && success $"$prog startup" || failure $"$prog startup"
+ echo
+ return $RETVAL
+}
+
+stop() {
+ echo -n $"Stopping debuginfofs: "
+ fusermount -u "$BUILDID_MOUNTPOINT"
+ RETVAL=$?
+ rm -f /var/lock/subsys/$prog
+ [ $RETVAL -eq 0 ] && success $"$prog shutdown" || failure $"$prog shutdown"
+ echo
+ return $RETVAL
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload)
+ stop
+ start
+ RETVAL=$?
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/$prog ]; then
+ stop
+ start
+ RETVAL=$?
+ fi
+ ;;
+ status)
+ status $prog
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/debuginfofs.sysconfig b/debuginfofs.sysconfig
new file mode 100644
index 0000000..a8985d3
--- /dev/null
+++ b/debuginfofs.sysconfig
@@ -0,0 +1,3 @@
+BUILDID_URL="http://test1079.test.redhat.com/debuginfofs/.build-id/"
+BUILDID_MOUNTPOINT="/usr/lib/debug/.build-id"
+BUILDID_ARGS="-o umask=022"
diff --git a/make-links.sh b/make-links.sh
new file mode 100755
index 0000000..af15f30
--- /dev/null
+++ b/make-links.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# make-links.sh - script to populate the global .build-id dir with hardlinks.
+#
+# GPLv2+. BOILERPLATE SHOULD GO HERE.
+#
+# Copyright 2009 Red Hat, Inc.
+# Author: Will Woods <wwoods@redhat.com>
+
+source config.sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 reponame [reponame...]"
+ echo "populates $exportdir/.build-id with hardlinks to .debug files."
+ exit 1
+fi
+
+if [ -z "$libdir" ]; then
+ echo "Couldn't find config.sh - exiting."
+ exit 1
+fi
+
+while [ $# -gt 0 ]; do
+ reponame="$1"
+ shift
+
+ if [ ! -d "$libdir/$reponame" ]; then
+ echo "$libdir/$reponame does not exist - please unpack debuginfo first"
+ continue
+ fi
+
+ find $libdir/$reponame -regex '.*/usr/lib/debug/\.build-id/.*\.debug' | \
+ while read u; do
+ target=$(readlink --canonicalize $u)
+ linkname=${u#*/usr/lib/debug/}
+ newlink="$exportdir/$linkname"
+ mkdir -p $(dirname $newlink)
+ ln -f $target $newlink
+ done
+done
diff --git a/rsync-debuginfo.sh b/rsync-debuginfo.sh
new file mode 100755
index 0000000..f6d6aa3
--- /dev/null
+++ b/rsync-debuginfo.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Given arch and version, fetch all debuginfo packages
+
+source config.sh
+
+if [ -z "$cachedir" ]; then
+ echo "Couldn't find config.sh - exiting."
+ exit 1
+fi
+
+# FIXME get these from commandline
+ver="10"
+arch="i386"
+
+rpmdir="$cachedir/debuginfo-$ver-$arch"
+
+# FIXME use mirrormanager / yum repo files / something
+server="rsync://wallace.redhat.com/fedora-enchilada/linux"
+
+# This is dumb. Use a dict or something.
+testing=$server/updates/testing/$ver/$arch/debug
+updates=$server/updates/$ver/$arch/debug
+fedora=$server/releases/$ver/Everything/$arch/debug
+
+mkdir -p $rpmdir
+rsync -avz $@ --progress $testing $rpmdir/testing
+rsync -avz $@ --progress $updates $rpmdir/updates
+rsync -avz $@ --progress $fedora $rpmdir/fedora
+find $rpmdir/testing -name "*.rpm" \
+ -exec ./unpack-debuginfo.sh testing-$ver-$arch {} +
+find $rpmdir/updates -name "*.rpm" \
+ -exec ./unpack-debuginfo.sh updates-$ver-$arch {} +
+find $rpmdir/fedora -name "*.rpm" \
+ -exec ./unpack-debuginfo.sh fedora-$ver-$arch {} +
+./make-links.sh testing-$ver-$arch updates-$ver-$arch fedora-$ver-$arch
diff --git a/unpack-debuginfo.sh b/unpack-debuginfo.sh
new file mode 100755
index 0000000..b31a179
--- /dev/null
+++ b/unpack-debuginfo.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# unpack-debuginfo.sh - a simple script to unpack an RPM in a manner
+# usable by debuginfofs.
+#
+# GPLv2+. BOILERPLATE SHOULD GO HERE.
+#
+# Copyright 2009 Red Hat, Inc.
+# Author: Will Woods <wwoods@redhat.com>
+
+source config.sh
+
+if [ -z "$libdir" ]; then
+ echo "Couldn't find config.sh - exiting."
+ exit 1
+fi
+
+if [ $# -lt 2 ]; then
+ echo "Usage: $0 reponame rpmfile [rpmfile...]"
+ echo "unpacks the given rpmfiles under $libdir/reponame"
+ exit 1
+fi
+
+function rpm_envra {
+ if [ -z "$1" ]; then return; fi
+ envra="$(rpm -qp $1 --qf '%{E}:%{N}-%{V}-%{R}.%{ARCH}' 2>/dev/null)"
+ if [ "${envra:0:1}" == ":" ]; then
+ envra="0$envra"
+ elif [ "${envra:0:6}" == "(none)" ]; then
+ envra="0${envra:6}"
+ fi
+ echo $envra
+}
+
+function unpack_rpm {
+ [ "$debug" ] && echo "unpack_rpm($1 $2)" >&2
+ rpmfile="$1"
+ targetdir="$2"
+ rpm2cpio $1 | ( cd $targetdir; cpio --quiet -iumd )
+ # Fix dir perms so that anyone can read the data
+ find $targetdir -type d -exec chmod a+rx {} +
+}
+
+reponame="$1"
+shift
+
+# TODO perm check
+
+# FIXME only do this if we're sure that reponame is OK?
+mkdir -p "$libdir/$reponame"
+
+if [ ! -d "$libdir/$reponame" ]; then
+ echo "$libdir/$reponame does not exist - please create it first."
+ exit 1
+fi
+
+while [ $# -gt 0 ]; do
+ envra="$(rpm_envra $1)"
+ nvra="${envra#*:}"
+ first_letter="${nvra:0:1}"
+ targetdir="$libdir/$reponame/$first_letter/$envra"
+ if [ -d $targetdir ]; then
+ [ "$verbose" ] && echo "$envra already unpacked; skipping..."
+ else
+ mkdir -p $targetdir
+ unpack_rpm $1 $targetdir
+ fi
+ shift
+done