From 25568226f882489ac97e0d98ba66995dcf22ebdd Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Wed, 4 May 2016 19:30:03 +0300 Subject: [PATCH] Changed the logic which decides where to place the dynamic loader. Other minor script improvements. --- src/09_generate_rootfs.sh | 53 +++++++++++++++++++++------------------ src/12_generate_iso.sh | 4 +-- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/09_generate_rootfs.sh b/src/09_generate_rootfs.sh index 323489604..5f6f53341 100755 --- a/src/09_generate_rootfs.sh +++ b/src/09_generate_rootfs.sh @@ -1,18 +1,23 @@ #!/bin/sh -# Remember the prepared glibc folder. +SRC_ROOT=$(pwd) + +# Remember the glibc prepared folder. GLIBC_PREPARED=$(pwd)/work/glibc/glibc_prepared +# Remember the BysyBox install folder. +BUSYBOX_INSTALLED=$(pwd)/work/busybox/busybox_installed + cd work echo "Preparing initramfs work area..." rm -rf rootfs # Copy all BusyBox generated stuff to the location of our 'initramfs' folder. -cp -r busybox/busybox_installed rootfs +cp -r $BUSYBOX_INSTALLED rootfs # Copy all rootfs resources to the location of our 'initramfs' folder. -cp -r ../09_generate_rootfs/* rootfs +cp -r src/09_generate_rootfs/* rootfs cd rootfs @@ -20,43 +25,43 @@ cd rootfs rm -f linuxrc # Read the 'COPY_SOURCE_ROOTFS' property from '.config' -COPY_SOURCE_ROOTFS="$(grep -i COPY_SOURCE_ROOTFS ../../.config | cut -f2 -d'=')" +COPY_SOURCE_ROOTFS="$(grep -i COPY_SOURCE_ROOTFS $SRC_ROOT/.config | cut -f2 -d'=')" if [ "$COPY_SOURCE_ROOTFS" = "true" ] ; then # Copy all prepared source files and folders to '/src'. Note that the scripts # will not work there because you also need proper toolchain. cp -r ../src src - echo "Original source files and folders have been copied." + echo "Source files and folders have been copied to '/src'." else - echo "Original source files and folders have been skipped." + echo "Source files and folders have been skipped." +fi + +# This is for the dynamic loader. Note that the file name and the the location +# are both specific for 32-bit and 64-bit machines. First we check the BusyBox +# executable and then we copy the loader to its appropriate location. +BUSYBOX_ARCH=$(file bin/busybox | cut -d\ -f3) +if [ "$BUSYBOX_ARCH" = "64-bit" ] ; then + mkdir lib64 + cp $GLIBC_PREPARED/lib/ld-linux* lib64 + echo "Dynamic loader is accessed via '/lib64'." +else + cp $GLIBC_PREPARED/lib/ld-linux* lib + echo "Dynamic loader is accessed via '/lib'." fi # Copy all necessary 'glibc' libraries to '/lib' BEGIN. -# This is the dynamic loader. Note that the file name is different for 32-bit -# and 64-bit machines. -cp $GLIBC_PREPARED/lib/ld-linux* ./lib - # BusyBox has direct dependencies on these libraries. -cp $GLIBC_PREPARED/lib/libm.so.6 ./lib -cp $GLIBC_PREPARED/lib/libc.so.6 ./lib +cp $GLIBC_PREPARED/lib/libm.so.6 lib +cp $GLIBC_PREPARED/lib/libc.so.6 lib # These libraries are necessary for the DNS resolving. -cp $GLIBC_PREPARED/lib/libresolv.so.2 ./lib -cp $GLIBC_PREPARED/lib/libnss_dns.so.2 ./lib - -# Make sure the Linux loader is visible on 64-bit machines. We can't rename the -# folder to '/lib64' because the glibc root location is set to '/lib' in the -# '05_build_glibc.sh' source script and therefore all 64-bit executables will -# be looking for shared libraries directly in '/lib'. -BUSYBOX_ARCH=$(file busybox | cut -d\ -f3) -if [ "$BUSYBOX_ARCH" = "64-bit" ] ; then - ln -s lib lib64 -fi +cp $GLIBC_PREPARED/lib/libresolv.so.2 lib +cp $GLIBC_PREPARED/lib/libnss_dns.so.2 lib # Copy all necessary 'glibc' libraries to '/lib' END. echo "The initramfs area has been generated." -cd ../.. +cd $SRC_ROOT diff --git a/src/12_generate_iso.sh b/src/12_generate_iso.sh index 646dcd23c..3364d2362 100755 --- a/src/12_generate_iso.sh +++ b/src/12_generate_iso.sh @@ -44,9 +44,9 @@ if [ "$COPY_SOURCE_ISO" = "true" ] ; then # Copy all prepared source files and folders to '/src'. Note that the scripts # will not work there because you also need proper toolchain. cp -r ../src src - echo "Original source files and folders have been copied." + echo "Source files and folders have been copied to '/src'." else - echo "Original source files and folders have been skipped." + echo "Source files and folders have been skipped." fi # Read the 'OVERLAY_TYPE' property from '.config'