3 # Script to make an offline archive for debugging with libdwfl-based tools.
5 # make-debug-archive ARCHIVE {options}
6 # make-debug-archive --kernel [--force] [RELEASE]
8 # Valid options are those listed under 'Input selection options'
9 # by running @UNSTRIP@ --help.
11 # The archive installed by --kernel be used automatically by -K.
12 # An offline archive can be used via -e in any tool that accepts those options.
15 UNSTRIP=${UNSTRIP:-@UNSTRIP@}
17 SUDO=${SUDO:-/usr/bin/sudo}
25 outdir=${TMPDIR:-/tmp}/debugar$$
29 echo "Usage: $0 ARCHIVE {options}"
30 echo " or: $0 --kernel [--sudo] [--force] [RELEASE]"
32 echo "Valid options are listed under 'Input selection options'"
33 echo "when running: $UNSTRIP --help"
35 echo "The --kernel form updates the file used by -K if the"
36 echo "kernel installation has changed, or always with --force."
37 echo "With --sudo, touches the installed file via $SUDO."
48 echo "`basename $0` (@PACKAGE_NAME@) @PACKAGE_VERSION@"
49 echo "Copyright (C) 2007 Red Hat, Inc."
50 echo "This is free software; see the source for copying conditions."
51 echo "There is NO warranty; not even for MERCHANTABILITY or"
52 echo "FITNESS FOR A PARTICULAR PURPOSE."
53 echo "Written by Roland McGrath."
59 while [ $# -gt 0 ]; do
61 x--help) usage; exit 0 ;;
62 x--version) script_version; exit 0 ;;
63 x--kernel) kernel=yes ;;
64 x--force) force_kernel=yes ;;
65 x--sudo) sudo=$SUDO ;;
71 if [ $kernel = no ] && [ $force_kernel = yes -o -n "$sudo" ]; then
75 if [ $kernel = yes ]; then
78 elif [ $# -eq 1 ]; then
84 dir=/usr/lib/debug/lib/modules/$release
86 dep=/lib/modules/$release/modules.dep
88 if [ ! -d $dir ]; then
89 echo >&2 "$0: $dir not installed"
93 # Without --force, bail if the kernel installation is not newer.
94 # This file is normally touched by installing new kernels or modules.
95 if [ $force_kernel = no -a "$archive" -nt "$dep" ]; then
99 # We have to kill the old one first, because our own -K would use it.
100 [ ! -e "$archive" ] || $sudo $RM -f "$archive" || exit
102 set "$archive" "-K$release"
105 if [ $# -lt 2 ]; then
114 *) archive="`/bin/pwd`/$archive" ;;
117 if [ -z "$sudo" ]; then
118 new_archive="$archive.new"
120 new_archive="$outdir.a"
123 $RM -f "$new_archive" || exit
125 trap '$RM -rf "$outdir" "$new_archive"' 0 1 2 15
128 $UNSTRIP -d "$outdir" -m -a -R "$@" &&
129 (cd "$outdir" && $LS | $XARGS $AR cq "$new_archive") &&
130 $sudo $MV -f "$new_archive" "$archive"