Re: [gentoo-dev] [PATCH 4/5] vcs-snapshot.eclass: Detect and report invalid directory structure

2019-07-25 Thread Michał Górny
On Thu, 2019-07-25 at 09:15 +0200, Ulrich Mueller wrote:
> > > > > > On Thu, 25 Jul 2019, Michał Górny wrote:
> > +   readarray -t topdirs \
> 
> Not legal in EAPIs 0 to 5 which use bash-3.2.
> 

I knew there was a reason I was doing it manually in all these eclasses!

-- 
Best regards,
Michał Górny



signature.asc
Description: This is a digitally signed message part


Re: [gentoo-dev] [PATCH 4/5] vcs-snapshot.eclass: Detect and report invalid directory structure

2019-07-25 Thread Ulrich Mueller
> On Thu, 25 Jul 2019, Ulrich Mueller wrote:

>> +readarray -t topdirs \

> Not legal in EAPIs 0 to 5 which use bash-3.2.

In fact, not legal in EAPIs 6 and 7 either, because the -t option
doesn't exist in bash-4.2.


signature.asc
Description: PGP signature


Re: [gentoo-dev] [PATCH 4/5] vcs-snapshot.eclass: Detect and report invalid directory structure

2019-07-25 Thread Ulrich Mueller
> On Thu, 25 Jul 2019, Michał Górny wrote:

> + readarray -t topdirs \

Not legal in EAPIs 0 to 5 which use bash-3.2.

Ulrich


signature.asc
Description: PGP signature


[gentoo-dev] [PATCH 4/5] vcs-snapshot.eclass: Detect and report invalid directory structure

2019-07-24 Thread Michał Górny
Detect when the archive does not contain a single top-level directory,
and abort in that case.  Otherwise, --strip-components would result
in unpredictable mess.

Signed-off-by: Michał Górny 
---
 eclass/vcs-snapshot.eclass | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/eclass/vcs-snapshot.eclass b/eclass/vcs-snapshot.eclass
index 312e9a4611e1..dbca6fd586d2 100644
--- a/eclass/vcs-snapshot.eclass
+++ b/eclass/vcs-snapshot.eclass
@@ -68,8 +68,20 @@ vcs-snapshot_src_unpack() {
 
debug-print "${FUNCNAME}: unpacking ${f} to 
${destdir}"
 
-   # XXX: check whether the directory structure 
inside is
-   # fine? i.e. if the tarball has actually a 
parent dir.
+   local topdirs=()
+   readarray -t topdirs \
+   < <(tar -t -f "${DISTDIR}/${f}" | cut 
-d/ -f1 | sort -u)
+   if [[ ${#topdirs[@]} -gt 1 ]]; then
+   eerror "The archive ${f} contains 
multiple or no top directory."
+   eerror "It is impossible for 
vcs-snapshot to unpack this correctly."
+   eerror "Top directories found:"
+   local d
+   for d in "${topdirs[@]}"; do
+   eerror "${d}"
+   done
+   die "${FUNCNAME}: Invalid directory 
structure in archive ${f}"
+   fi
+
mkdir "${destdir}" || die
# -o (--no-same-owner) to avoid restoring 
original owner
einfo "Unpacking ${f}"
-- 
2.22.0