Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH v2 3/5] vcs-snapshot.eclass: Add verbose einfo for unpacking
Date: Thu, 25 Jul 2019 07:38:12
Message-Id: 20190725073722.14482-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH v2 1/5] vcs-snapshot.eclass: Allow EAPI 7 by "Michał Górny"
1 Add an einfo call to make explicit notice of each archive being
2 unpacked.
3
4 Signed-off-by: Michał Górny <mgorny@g.o>
5 ---
6 eclass/vcs-snapshot.eclass | 1 +
7 1 file changed, 1 insertion(+)
8
9 diff --git a/eclass/vcs-snapshot.eclass b/eclass/vcs-snapshot.eclass
10 index 2e734c509d1a..312e9a4611e1 100644
11 --- a/eclass/vcs-snapshot.eclass
12 +++ b/eclass/vcs-snapshot.eclass
13 @@ -1,86 +1,87 @@
14 # Copyright 1999-2019 Gentoo Authors
15 # Distributed under the terms of the GNU General Public License v2
16
17 # @ECLASS: vcs-snapshot.eclass
18 # @MAINTAINER:
19 # mgorny@g.o
20 # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
21 # @BLURB: support eclass for unpacking VCS snapshot tarballs
22 # @DESCRIPTION:
23 # THIS ECLASS IS NOT NECESSARY FOR MODERN GITHUB AND GITLAB SNAPSHOTS.
24 # THEIR DIRECTORY STRUCTURE IS ENTIRELY PREDICTABLE, SO UPDATE YOUR
25 # EBUILD TO USE /ARCHIVE/ URI AND SET S IF NECESSARY.
26 #
27 # This eclass provides a convenience src_unpack() which does unpack all
28 # the tarballs in SRC_URI to locations matching their (local) names,
29 # discarding the original parent directory.
30 #
31 # The typical use case are VCS tag snapshots coming from BitBucket
32 # (but not GitHub or GitLab). They have hash appended to the directory
33 # name which makes extracting them a painful experience. But if you are
34 # using a SRC_URI arrow to rename them (which quite likely you have to
35 # do anyway), vcs-snapshot will just extract them into matching
36 # directories.
37 #
38 # Please note that this eclass handles only tarballs (.tar, .tar.gz,
39 # .tar.bz2 & .tar.xz). For any other file format (or suffix) it will
40 # fall back to regular unpack. Support for additional formats may be
41 # added in the future if necessary.
42 #
43 # @EXAMPLE:
44 #
45 # @CODE
46 # EAPI=7
47 # inherit vcs-snapshot
48 #
49 # SRC_URI="
50 # https://bitbucket.org/foo/bar/get/${PV}.tar.bz2 -> ${P}.tar.bz2
51 # https://bitbucket.org/foo/bar-otherstuff/get/${PV}.tar.bz2
52 # -> ${P}-otherstuff.tar.bz2"
53 # @CODE
54 #
55 # and however the tarballs were originally packed, all files will appear
56 # in ${WORKDIR}/${P} and ${WORKDIR}/${P}-otherstuff respectively.
57
58 case ${EAPI:-0} in
59 0|1|2|3|4|5|6|7) ;;
60 *) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established."
61 esac
62
63 EXPORT_FUNCTIONS src_unpack
64
65 # @FUNCTION: vcs-snapshot_src_unpack
66 # @DESCRIPTION:
67 # Extract all the archives from ${A}. The .tar, .tar.gz, .tar.bz2
68 # and .tar.xz archives will be unpacked to directories matching their
69 # local names. Other archive types will be passed down to regular
70 # unpack.
71 vcs-snapshot_src_unpack() {
72 debug-print-function ${FUNCNAME} "${@}"
73
74 local f
75
76 for f in ${A}
77 do
78 case "${f}" in
79 *.tar|*.tar.gz|*.tar.bz2|*.tar.xz)
80 local destdir=${WORKDIR}/${f%.tar*}
81
82 debug-print "${FUNCNAME}: unpacking ${f} to ${destdir}"
83
84 # XXX: check whether the directory structure inside is
85 # fine? i.e. if the tarball has actually a parent dir.
86 mkdir "${destdir}" || die
87 # -o (--no-same-owner) to avoid restoring original owner
88 + einfo "Unpacking ${f}"
89 tar -C "${destdir}" -x -o --strip-components 1 \
90 -f "${DISTDIR}/${f}" || die
91 ;;
92 *)
93 debug-print "${FUNCNAME}: falling back to unpack for ${f}"
94
95 # fall back to the default method
96 unpack "${f}"
97 ;;
98 esac
99 done
100 }
101 --
102 2.22.0