commit:     d4450fcaad41aff9b2d5a693df80560890730dc1
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 09:36:51 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 11:58:16 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d4450fca

gen_initramfs.sh: Refactor append_libgcc_s()

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_initramfs.sh | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index c7fd1dc..8d6996e 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -613,12 +613,14 @@ append_btrfs() {
 }
 
 append_libgcc_s() {
-       if [ -d "${TEMP}/initramfs-libgcc_s-temp" ]
+       local TDIR="${TEMP}/initramfs-libgcc_s-temp"
+       if [ -d "${TDIR}" ]
        then
-               rm -r "${TEMP}/initramfs-libgcc_s-temp"
+               rm -r "${TDIR}" || gen_die "Failed to clean out existing 
'${TDIR}'!"
        fi
 
-       mkdir -p "${TEMP}/initramfs-libgcc_s-temp"
+       mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
 
        # Include libgcc_s.so.1:
        #   - workaround for zfsonlinux/zfs#4749
@@ -631,17 +633,12 @@ append_libgcc_s() {
                libgccpath="/usr/lib/gcc/*/*/libgcc_s.so.1"
        fi
 
-       # Copy binaries
-       copy_binaries "${TEMP}/initramfs-libgcc_s-temp" ${libgccpath}
-       cd "${TEMP}/initramfs-libgcc_s-temp/lib64"
-       ln -s "..${libgccpath}"
+       copy_binaries "${TDIR}" ${libgccpath}
 
-       cd "${TEMP}/initramfs-libgcc_s-temp/"
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
        log_future_cpio_content
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
-                       || gen_die "compressing libgcc_s cpio"
-       cd "${TEMP}"
-       rm -rf "${TEMP}/initramfs-libgcc_s-temp" > /dev/null
+               || gen_die "Failed to append libgcc_s to cpio!"
 }
 
 append_linker() {

Reply via email to