X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=cppreopts%2Fcppreopts.sh;fp=cppreopts%2Fcppreopts.sh;h=87982067d1682049ac310b4aa5b000d45be35d2d;hb=757d341496d8c7e69420eb51c82be2d2bc694079;hp=4c72e94128b0eea53979850975d13bf545d1a4a7;hpb=a63cf1023bd41ed01906c8d30445bb39238937f2;p=android-x86%2Fsystem-extras.git diff --git a/cppreopts/cppreopts.sh b/cppreopts/cppreopts.sh index 4c72e941..87982067 100644 --- a/cppreopts/cppreopts.sh +++ b/cppreopts/cppreopts.sh @@ -17,31 +17,13 @@ # create files with 644 (global read) permissions. umask 022 -if [ $# -ne 1 ]; then - log -p e -t cppreopts "Usage: cppreopts " - exit 1 -fi - -# Where the system_b is mounted that contains the preopt'd files -mountpoint=$1 - -if ! test -f ${mountpoint}/system-other-odex-marker ; then - log -p i -t cppreopts "system_other partition does not appear have been built to contain preopted files." - exit 1 -fi - -log -p i -t cppreopts "cppreopts from ${mountpoint}" -# For each odex file. -find ${mountpoint} -type f -name "*.odex" | while read odex_file; do - real_odex_name=${odex_file/${mountpoint}/\/system} - dest_name=$(preopt2cachename ${real_odex_name}) +# Helper function to copy files +function do_copy() { + odex_file=$1 + dest_name=$2 # Move to a temporary file so we can do a rename and have the preopted file # appear atomically in the filesystem. temp_dest_name=${dest_name}.tmp - if ! test $? -eq 0 ; then - log -p i -t cppreopts "Unable to figure out destination for ${odex_file}" - continue - fi if ! cp ${odex_file} ${temp_dest_name} ; then log -p w -t cppreopts "Unable to copy odex file ${odex_file} to ${temp_dest_name}!" else @@ -53,6 +35,35 @@ find ${mountpoint} -type f -name "*.odex" | while read odex_file; do log -p i -t cppreopts "Renamed temporary odex file from ${temp_dest_name} to ${dest_name}" fi fi -done +} + +if [ $# -eq 1 ]; then + # Where the system_b is mounted that contains the preopt'd files + mountpoint=$1 + + if ! test -f ${mountpoint}/system-other-odex-marker ; then + log -p i -t cppreopts "system_other partition does not appear have been built to contain preopted files." + exit 1 + fi -exit 0 + log -p i -t cppreopts "cppreopts from ${mountpoint}" + # For each odex file do the copy task + # NOTE: this implementation will break in any path with spaces to favor + # background copy tasks + for odex_file in $(find ${mountpoint} -type f -name "*.odex"); do + real_odex_name=${odex_file/${mountpoint}/\/system} + dest_name=$(preopt2cachename ${real_odex_name}) + if ! test $? -eq 0 ; then + log -p i -t cppreopts "Unable to figure out destination for ${odex_file}" + continue + fi + # Copy files in background to speed things up + do_copy ${odex_file} ${dest_name} & + done + # Wait for jobs to finish + wait + exit 0 +else + log -p e -t cppreopts "Usage: cppreopts " + exit 1 +fi