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