texlive-module.eclass: Optimize src_unpack()
authorMichał Górny <mgorny@gentoo.org>
Tue, 14 Apr 2020 13:14:42 +0000 (15:14 +0200)
committerMichał Górny <mgorny@gentoo.org>
Tue, 14 Apr 2020 13:16:52 +0000 (15:16 +0200)
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@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/texlive-module.eclass

index a415205e035fb9d33ca1ec673ee943b85516e3ff..fc83abe49c54e631aa4df6505f82f60f00493f9b 100644 (file)
@@ -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