blob: b31a17933b13a2722dd15045ed24531f6e52feda (
plain)
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
|
#!/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
|