Changeset 15586 in niluje


Ignore:
Timestamp:
Dec 10, 2018, 11:58:46 PM (6 months ago)
Author:
NiLuJe
Message:

MRPI:

  • Move staging directory to a tmpfs, to speed things up
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Configs/trunk/Kindle/KUAL/MRInstaller/extensions/MRInstaller/bin/mrinstaller.sh

    r15581 r15586  
    295295}
    296296
     297# Our packages live in a specific directory
     298MRPI_PKGDIR="/mnt/us/mrpackages"
     299# We're using our own tmpfs
     300MRPI_TMPFS="/tmp/mrpi"
     301# We're working in a staging directory, in our tmpfs
     302MRPI_WORKDIR="${MRPI_TMPFS}/staging"
     303# We're making KindleTool use our own tmpfs as a temp directory
     304MRPI_TMPDIR="${MRPI_TMPFS}/tmpdir"
     305
    297306## Call kindletool with the right environment setup
    298307MRINSTALLER_BINDIR="$(dirname "$(realpath "${0}")")"
     
    338347
    339348        # Pick up our own libz build...
    340         env KT_WITH_UNKNOWN_DEVCODES="true" LD_LIBRARY_PATH="${MRINSTALLER_BASEDIR}/lib/${BINARIES_TC}" ${MRINSTALLER_BASEDIR}/bin/${BINARIES_TC}/kindletool "$@"
     349        env KT_WITH_UNKNOWN_DEVCODES="true" TMPDIR="${MRPI_TMPDIR}" LD_LIBRARY_PATH="${MRINSTALLER_BASEDIR}/lib/${BINARIES_TC}" ${MRINSTALLER_BASEDIR}/bin/${BINARIES_TC}/kindletool "$@"
    341350}
    342351
     
    351360                return 0
    352361        fi
     362}
     363
     364## To make things faster, we'll try to do as much work in RAM as possible
     365## But since none of the existing tmpfs fit our needs, we'll create our own.
     366mount_mrpi_tmpfs()
     367{
     368        logmsg "I" "mount_mrpi_tmpfs" "" "trying to create mrpi tmpfs"
     369
     370        # Namely, the default ones tend to be small. So let's say we want one that's about 62.5% of the total RAM.
     371        # That's usually close enough to the free RAM we get with the framework down, and should be more than enough ;).
     372        tmpfs_size="$(awk '/MemTotal/ {print $2 * 0.625}' /proc/meminfo)"
     373        # Just in case the apocalypse hits, and our awk shenanigans fail, make sure we have sane defaults, even for 128MB of RAM
     374        is_integer "${tmpfs_size}" || tmpfs_size="81920"
     375
     376        # Create our mountpoint
     377        mkdir -p "${MRPI_TMPFS}"
     378
     379        # And mount it :)
     380        /bin/mount -t tmpfs tmpfs "${MRPI_TMPFS}" -o defaults,size=${tmpfs_size}K,mode=1777,noatime
     381        if [ $? -ne 0 ] ; then
     382                logmsg "E" "mount_mrpi_tmpfs" "" "failed to create mrpi tmpfs!"
     383                return 1
     384        fi
     385
     386        # Success!
     387        logmsg "I" "mount_mrpi_tmpfs" "" "created ${tmpfs_size}kB mrpi tmpfs"
     388        return 0
     389}
     390
     391## And unmount it when we're done...
     392umount_mrpi_tmpfs()
     393{
     394        logmsg "I" "umount_mrpi_tmpfs" "" "trying to unmount mrpi tmpfs"
     395
     396        # Sync first...
     397        sync
     398
     399        /bin/umount "${MRPI_TMPFS}"
     400        if [ $? -ne 0 ] ; then
     401                logmsg "E" "umount_mrpi_tmpfs" "" "failed to unmount mrpi tmpfs!"
     402                return 1
     403        fi
     404
     405        # Success!
     406        logmsg "I" "umount_mrpi_tmpfs" "" "successfully unmounted mrpi tmpfs"
     407        return 0
    353408}
    354409
     
    438493}
    439494
    440 # Our packages live in a specific directory
    441 MRPI_PKGDIR="/mnt/us/mrpackages"
    442 # We're working in a staging directory
    443 MRPI_WORKDIR="${MRPI_PKGDIR}/staging"
    444495## Run a single package
    445496run_package()
     
    743794        # Construct our final package list
    744795        MR_PKGS_LIST="${MR_PKGS_HEAD_LIST} ${MR_PKGS_LIST} ${MR_PKGS_TAIL_LIST}"
     796
     797        # Try to setup our tmpfs
     798        if ! mount_mrpi_tmpfs ; then
     799                eips_print_bottom_centered "Failed to create MRPI tmpfs, waiting . . ." 1
     800                sleep 5
     801                # Try one final time...
     802                if ! mount_mrpi_tmpfs ; then
     803                        eips_print_bottom_centered "Really failed to create MRPI tmpfs, aborting." 1
     804                        sleep 5
     805                        return 1
     806                fi
     807        fi
     808        mkdir -p "${MRPI_TMPDIR}"
    745809
    746810        # Don't get killed!
     
    859923        sync
    860924
     925        # Try to unmount our tmpfs
     926        rm -rf "${MRPI_TMPDIR}"
     927        if ! umount_mrpi_tmpfs ; then
     928                eips_print_bottom_centered "Failed to unmount MRPI tmpfs, waiting . . ." 1
     929                sleep 5
     930                # Try one final time...
     931                if ! umount_mrpi_tmpfs ; then
     932                        eips_print_bottom_centered "Really failed to unmount MRPI tmpfs -_-" 1
     933                        sleep 5
     934                fi
     935        fi
     936
    861937        # We're done! Enable sleepy eips calls in order to avoid losing our last message...
    862938        EIPS_SLEEP="true"
Note: See TracChangeset for help on using the changeset viewer.