blob: c9c21aa6ebbdec9bcedfdacb234c1bce3b24e96c (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: rpm.eclass
# @MAINTAINER:
# base-system@gentoo.org
# @SUPPORTED_EAPIS: 7 8
# @BLURB: convenience class for extracting RPMs
case ${EAPI} in
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ -z ${_RPM_ECLASS} ]] ; then
_RPM_ECLASS=1
inherit estack
BDEPEND="app-arch/rpm2targz"
# @FUNCTION: rpm_unpack
# @USAGE: <rpms>
# @DESCRIPTION:
# Unpack the contents of the specified rpms like the unpack() function.
rpm_unpack() {
[[ $# -eq 0 ]] && set -- ${A}
local a
for a in "$@" ; do
echo ">>> Unpacking ${a} to ${PWD}"
if [[ ${a} == ./* ]] ; then
: # nothing to do -- path is local
elif [[ ${a} == "${DISTDIR}"/* ]] ; then
eqawarn 'do not use ${DISTDIR} with rpm_unpack -- it is added for you'
elif [[ ${a} == /* ]] ; then
eqawarn 'do not use full paths with rpm_unpack -- use ./ paths instead'
else
a="${DISTDIR}/${a}"
fi
rpm2tar -O "${a}" | tar xf -
assert "failure unpacking ${a}"
done
}
# @FUNCTION: srcrpm_unpack
# @USAGE: <rpms>
# @DESCRIPTION:
# Unpack the contents of the specified rpms like the unpack() function as well
# as any archives that it might contain. Note that the secondary archive
# unpack isn't perfect in that it simply unpacks all archives in the working
# directory (with the assumption that there weren't any to start with).
srcrpm_unpack() {
[[ $# -eq 0 ]] && set -- ${A}
rpm_unpack "$@"
# no .src.rpm files, then nothing to do
[[ "$* " != *".src.rpm " ]] && return 0
eshopts_push -s nullglob
# unpack everything
local a
for a in *.tar.{gz,bz2,xz} *.t{gz,bz2,xz} *.zip *.ZIP ; do
unpack "./${a}"
rm -f "${a}" || die
done
eshopts_pop
return 0
}
# @FUNCTION: rpm_src_unpack
# @DESCRIPTION:
# Automatically unpack all archives in ${A} including rpms. If one of the
# archives in a source rpm, then the sub archives will be unpacked as well.
rpm_src_unpack() {
local a
for a in ${A} ; do
case ${a} in
*.rpm) srcrpm_unpack "${a}" ;;
*) unpack "${a}" ;;
esac
done
}
fi
EXPORT_FUNCTIONS src_unpack
|