Changed the logic which decides where to place the dynamic loader. Other minor script improvements.

This commit is contained in:
Ivan Davidov 2016-05-04 19:30:03 +03:00
parent e11ed73329
commit 25568226f8
2 changed files with 31 additions and 26 deletions

View File

@ -1,18 +1,23 @@
#!/bin/sh #!/bin/sh
# Remember the prepared glibc folder. SRC_ROOT=$(pwd)
# Remember the glibc prepared folder.
GLIBC_PREPARED=$(pwd)/work/glibc/glibc_prepared GLIBC_PREPARED=$(pwd)/work/glibc/glibc_prepared
# Remember the BysyBox install folder.
BUSYBOX_INSTALLED=$(pwd)/work/busybox/busybox_installed
cd work cd work
echo "Preparing initramfs work area..." echo "Preparing initramfs work area..."
rm -rf rootfs rm -rf rootfs
# Copy all BusyBox generated stuff to the location of our 'initramfs' folder. # 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. # 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 cd rootfs
@ -20,43 +25,43 @@ cd rootfs
rm -f linuxrc rm -f linuxrc
# Read the 'COPY_SOURCE_ROOTFS' property from '.config' # 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 if [ "$COPY_SOURCE_ROOTFS" = "true" ] ; then
# Copy all prepared source files and folders to '/src'. Note that the scripts # Copy all prepared source files and folders to '/src'. Note that the scripts
# will not work there because you also need proper toolchain. # will not work there because you also need proper toolchain.
cp -r ../src src cp -r ../src src
echo "Original source files and folders have been copied." echo "Source files and folders have been copied to '/src'."
else 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 fi
# Copy all necessary 'glibc' libraries to '/lib' BEGIN. # 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. # BusyBox has direct dependencies on these libraries.
cp $GLIBC_PREPARED/lib/libm.so.6 ./lib cp $GLIBC_PREPARED/lib/libm.so.6 lib
cp $GLIBC_PREPARED/lib/libc.so.6 ./lib cp $GLIBC_PREPARED/lib/libc.so.6 lib
# These libraries are necessary for the DNS resolving. # These libraries are necessary for the DNS resolving.
cp $GLIBC_PREPARED/lib/libresolv.so.2 ./lib cp $GLIBC_PREPARED/lib/libresolv.so.2 lib
cp $GLIBC_PREPARED/lib/libnss_dns.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
# Copy all necessary 'glibc' libraries to '/lib' END. # Copy all necessary 'glibc' libraries to '/lib' END.
echo "The initramfs area has been generated." echo "The initramfs area has been generated."
cd ../.. cd $SRC_ROOT

View File

@ -44,9 +44,9 @@ if [ "$COPY_SOURCE_ISO" = "true" ] ; then
# Copy all prepared source files and folders to '/src'. Note that the scripts # Copy all prepared source files and folders to '/src'. Note that the scripts
# will not work there because you also need proper toolchain. # will not work there because you also need proper toolchain.
cp -r ../src src cp -r ../src src
echo "Original source files and folders have been copied." echo "Source files and folders have been copied to '/src'."
else else
echo "Original source files and folders have been skipped." echo "Source files and folders have been skipped."
fi fi
# Read the 'OVERLAY_TYPE' property from '.config' # Read the 'OVERLAY_TYPE' property from '.config'