vcs-snapshot.eclass: Detect unnecessary usage and complain
authorMichał Górny <mgorny@gentoo.org>
Thu, 25 Jul 2019 06:24:07 +0000 (08:24 +0200)
committerMichał Górny <mgorny@gentoo.org>
Sat, 27 Jul 2019 09:49:51 +0000 (11:49 +0200)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/vcs-snapshot.eclass

index d3f7025fbb35bd7b478f1b759cb145d3fe31c8a4..05d963917e258d2b58d35b1059e6d647efc0776d 100644 (file)
@@ -58,6 +58,7 @@ EXPORT_FUNCTIONS src_unpack
 vcs-snapshot_src_unpack() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       local renamed_any=
        local f
 
        for f in ${A}
@@ -82,6 +83,7 @@ vcs-snapshot_src_unpack() {
                                        done
                                        die "${FUNCNAME}: Invalid directory structure in archive ${f}"
                                fi
+                               [[ ${topdirs[0]} != ${f%.tar*} ]] && renamed_any=1
 
                                mkdir "${destdir}" || die
                                # -o (--no-same-owner) to avoid restoring original owner
@@ -97,4 +99,14 @@ vcs-snapshot_src_unpack() {
                                ;;
                esac
        done
+
+       if [[ ! ${renamed_any} ]]; then
+               local w=eerror
+               [[ ${EAPI} == [0123456] ]] && w=eqawarn
+               "${w}" "${FUNCNAME} did not find any archives that needed renaming."
+               "${w}" "Please verify that its usage is really necessary, and remove"
+               "${w}" "the inherit if it is not."
+
+               [[ ${w} == eerror ]] && die "${FUNCNAME}: Unnecessary usage detected"
+       fi
 }