commit:     97812dcc9ddb1e043d8a67216692b214d62099a7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 14 13:14:42 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Apr 14 13:16:52 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=97812dcc

texlive-module.eclass: Optimize src_unpack()

This goes a bit further than slyfox's work.  On my machine, it reduces
the post-unpack time from ~44m to ~13m.

Bug: https://bugs.gentoo.org/688922
Acked-by: Mikle Kolyada <zlogene <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/texlive-module.eclass | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index a415205e035..fc83abe49c5 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -140,16 +140,14 @@ RELOC_TARGET=texmf-dist
 texlive-module_src_unpack() {
        unpack ${A}
 
-       grep RELOC tlpkg/tlpobj/* | awk '{print $2}' | sed 's#^RELOC/##' > 
"${T}/reloclist" || die
-       { for i in $(<"${T}/reloclist"); do  dirname ${i}; done; } | uniq > 
"${T}/dirlist"
-       for i in $(<"${T}/dirlist"); do
-               if [[ ! -d ${RELOC_TARGET}/${i} ]]; then
-                       mkdir -p "${RELOC_TARGET}/${i}" || die
-               fi
-       done
-       for i in $(<"${T}/reloclist"); do
-               mv "${i}" "${RELOC_TARGET}"/$(dirname "${i}") || die "failed to 
relocate ${i} to ${RELOC_TARGET}/$(dirname ${i})"
-       done
+       sed -n -e 's:\s*RELOC/::p' tlpkg/tlpobj/* > "${T}/reloclist" || die
+       sed -e 's/\/[^/]*$//' -e "s:^:${RELOC_TARGET}/:" "${T}/reloclist" |
+               sort -u |
+               xargs mkdir -p || die
+       local i
+       while read i; do
+               mv "${i}" "${RELOC_TARGET}/${i%/*}" || die
+       done < "${T}/reloclist"
 }
 
 # @FUNCTION: texlive-module_add_format

Reply via email to