3 # Copyright (C) 2016 The Android Open Source Project
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # create files with 644 (global read) permissions.
21 log -p e -t cppreopts "Usage: cppreopts <preopts-mount-point>"
25 # Where the system_b is mounted that contains the preopt'd files
28 if ! test -f ${mountpoint}/system-other-odex-marker ; then
29 log -p i -t cppreopts "system_other partition does not appear have been built to contain preopted files."
33 log -p i -t cppreopts "cppreopts from ${mountpoint}"
35 find ${mountpoint} -type f -name "*.odex" | while read odex_file; do
36 real_odex_name=${odex_file/${mountpoint}/\/system}
37 dest_name=$(preopt2cachename ${real_odex_name})
38 # Move to a temporary file so we can do a rename and have the preopted file
39 # appear atomically in the filesystem.
40 temp_dest_name=${dest_name}.tmp
41 if ! test $? -eq 0 ; then
42 log -p i -t cppreopts "Unable to figure out destination for ${odex_file}"
45 if ! cp ${odex_file} ${temp_dest_name} ; then
46 log -p w -t cppreopts "Unable to copy odex file ${odex_file} to ${temp_dest_name}!"
48 log -p i -t cppreopts "Copied odex file from ${odex_file} to ${temp_dest_name}"
50 if ! mv ${temp_dest_name} ${dest_name} ; then
51 log -p w -t cppreopts "Unable to rename temporary odex file from ${temp_dest_name} to ${dest_name}"
53 log -p i -t cppreopts "Renamed temporary odex file from ${temp_dest_name} to ${dest_name}"