Remove deprecated ART apex hooks.
Rationale: these hooks were meant for on-device compilation of boot
image combined with fs-verity to protect compilation artifacts. This
approach is now abandoned in favour of on-host compilation of boot
image and packaging it in the apex (to be implemented in a follow-up
patch set).
Bug: b/143761527
Bug: b/125474642
Test: m com.android.art
Test: art/build/apex/runtests.sh: All ART APEX tests passed
Test: Experimental installation of ART apex on device:
- increase the "version" field in build/apex/manifest-art.json (say,
to version 5)
- rebuild ART apex: `m com.android.art`
- install apex on device:
`adb install --wait out/target/product/$PRODUCT/system/apex/com.android.art.debug.apex`
observe the following output in the of the shell command:
```
Performing Streamed Install
Success
```
- run `adb logcat | grep apexd` in the shell and see that the
session is staged successfully:
```
[...] apexd : markStagedSessionReady() received by ApexService, session id <...>
```
- reboot the device with `adb reboot`
- run `adb logcat | grep apexd` in the shell and see that the
installation session is completed successfully:
```
apexd : Successfully activated /data/apex/active/com.android.art@5.apex package_name: com.android.art version: 5
```
Change-Id: I39de908ebe52f06f19781dc024ede619802a3196
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index ceb3093..fc9e148 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -228,13 +228,6 @@
art_tools_device_only_binaries,
},
},
- binaries: [
- "art_postinstall_hook",
- "art_preinstall_hook",
- "art_preinstall_hook_boot",
- "art_preinstall_hook_system_server",
- "art_prepostinstall_utils",
- ],
prebuilts: ["com.android.art.ld.config.txt"],
key: "com.android.art.key",
required: [
@@ -462,36 +455,3 @@
defaults: ["art-check-apex-gen-fakebin-defaults"],
srcs: [":art-check-testing-apex-gen"],
}
-
-// Pre-install scripts.
-
-sh_binary {
- name: "art_preinstall_hook",
- src: "art_preinstall_hook.sh",
-}
-
-sh_binary {
- name: "art_preinstall_hook_boot",
- src: "art_preinstall_hook_boot.sh",
-}
-
-sh_binary {
- name: "art_preinstall_hook_system_server",
- src: "art_preinstall_hook_system_server.sh",
-}
-
-sh_binary {
- name: "art_prepostinstall_utils",
- src: "art_prepostinstall_utils.sh",
-}
-
-sh_binary {
- name: "art_postinstall_hook",
- src: "art_postinstall_hook.sh",
-}
-
-sh_binary {
- name: "art_apex_boot_integrity",
- src: "art_apex_boot_integrity.sh",
- init_rc: ["art_apex_boot_integrity.rc"],
-}
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index d9e5c08..3d8c5e3 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -531,13 +531,6 @@
return 'Release (Target) Checker'
def run(self):
- # Check the APEX package scripts.
- self._checker.check_executable('art_postinstall_hook')
- self._checker.check_executable('art_preinstall_hook')
- self._checker.check_executable('art_preinstall_hook_boot')
- self._checker.check_executable('art_preinstall_hook_system_server')
- self._checker.check_executable('art_prepostinstall_utils')
-
# Check binaries for ART.
self._checker.check_executable('oatdump')
diff --git a/build/apex/art_postinstall_hook.sh b/build/apex/art_postinstall_hook.sh
deleted file mode 100644
index cb3b887..0000000
--- a/build/apex/art_postinstall_hook.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/system/bin/sh
-
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-. `dirname $0`/art_prepostinstall_utils || exit 100
-
-log_info "=== ART runtime post-install ==="
-
-# Check for OTA base folder.
-if [ ! -d /data/ota/dalvik-cache ] ; then
- log_error "Postinstall dalvik-cache does not exist or is not a directory"
- exit 101
-fi
-
-log_info "Checking fsverity"
-
-# Measure (and enable) fsverity to see if things are installed. Enable is not
-# idempotent, and we'd need to parse the error string to see whether it says
-# data was installed. Rather do a two-step.
-FILES=`find /data/ota/dalvik-cache -type f`
-for FILE in $FILES ; do
- fsverity measure $FILE && continue
- ENABLE_MSG=`fsverity enable $FILE 2>&1` && continue
-
- # No installed data, can't enable. Clean up and fail.
- log_error "Enable failed: $ENABLE_MSG"
- rm -rf /data/ota/dalvik-cache
- exit 200
-done
-
-log_info "Moving dalvik-cache"
-
-rm -rf /data/dalvik-cache/* || exit 102
-mv /data/ota/dalvik-cache/* /data/dalvik-cache/ || exit 103
-restorecon -R -F /data/dalvik-cache/* || exit 104
diff --git a/build/apex/art_preinstall_hook.sh b/build/apex/art_preinstall_hook.sh
deleted file mode 100644
index 94a1b21..0000000
--- a/build/apex/art_preinstall_hook.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/system/bin/sh
-
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-. `dirname $0`/art_prepostinstall_utils || exit 100
-
-log_info "=== ART runtime pre-install ==="
-
-set_arches || exit 101
-log_info "Arches = `echo $ARCHES`"
-
-# The runtime update uses /data/ota as a staging directory, similar to
-# A/B OTA. (There is no overlap, as A/B uses slot prefixes.)
-
-# Create OTA base folder.
-mkdir -p /data/ota/dalvik-cache || exit 102
-# Bind-mount to perceive as normal structure.
-mount -o bind /data/ota/dalvik-cache /data/dalvik-cache || exit 103
-
-for ARCH in $ARCHES ; do
- log_info "Preparing compilation output directories for $ARCH"
-
- # Create OTA folders.
- mkdir -p /data/ota/dalvik-cache/$ARCH || exit 104
- rm -rf /data/ota/dalvik-cache/$ARCH/* || exit 105
-
- `dirname $0`/art_preinstall_hook_boot $ARCH || exit 200
-done
-
-PRIMARY_ARCH=`echo $ARCHES | sed -e 's/ .*//'`
-`dirname $0`/art_preinstall_hook_system_server $PRIMARY_ARCH || exit 300
-
-FILES=`find /data/dalvik-cache -type f`
-for FILE in $FILES ; do
- setup_fsverity $FILE || exit 400
-done
diff --git a/build/apex/art_preinstall_hook_boot.sh b/build/apex/art_preinstall_hook_boot.sh
deleted file mode 100644
index 0985bef..0000000
--- a/build/apex/art_preinstall_hook_boot.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/system/bin/sh
-
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-. `dirname $0`/art_prepostinstall_utils || exit 100
-
-log_info "Preparing boot image compilation parameters"
-
-# Prefer DEX2OATBOOTCLASSPATH, then BOOTCLASSPATH.
-USED_CLASSPATH=$DEX2OATBOOTCLASSPATH
-if [ -z "$USED_CLASSPATH" ] ; then
- USED_CLASSPATH=$BOOTCLASSPATH
- if [ -z "$USED_CLASSPATH" ] ; then
- log_error "Could not find boot class-path to compile"
- exit 101
- fi
-fi
-BOOTCP=`echo $USED_CLASSPATH | tr ":" "\n"`
-
-DEX_FILES=
-DEX_LOCATIONS=
-for component in $BOOTCP ; do
- DEX_FILES="$DEX_FILES --dex-file=$component"
- DEX_LOCATIONS="$DEX_LOCATIONS --dex-location=$component"
-done
-
-PROFILING=
-if [ -f "/system/etc/boot-image.prof" ] ; then
- PROFILING="--compiler-filter=speed-profile --profile-file=/system/etc/boot-image.prof"
-fi
-if [ -f "/system/etc/dirty-image-objects" ] ; then
- PROFILING="$PROFILING --dirty-image-objects=/system/etc/dirty-image-objects"
-fi
-
-DEX2OAT_IMAGE_XMX=`getprop dalvik.vm.image-dex2oat-Xmx`
-
-DEX2OAT_TARGET_ARCH=$1
-DEX2OAT_TARGET_CPU_VARIANT=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.variant`
-DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.features`
-
-log_info "Compiling boot image for $DEX2OAT_TARGET_ARCH"
-
-dex2oat \
- --avoid-storing-invocation \
- --runtime-arg -Xmx$DEX2OAT_IMAGE_XMX \
- $PROFILING \
- $DEX_FILES \
- $DEX_LOCATIONS \
- --generate-mini-debug-info \
- --strip \
- --oat-file=/data/dalvik-cache/$DEX2OAT_TARGET_ARCH/system@framework@boot.oat \
- --oat-location=/data/dalvik-cache/$DEX2OAT_TARGET_ARCH/system@framework@boot.oat \
- --image=/data/dalvik-cache/$DEX2OAT_TARGET_ARCH/system@framework@boot.art --base=0x70000000 \
- --instruction-set=$DEX2OAT_TARGET_ARCH \
- --instruction-set-variant=$DEX2OAT_TARGET_CPU_VARIANT \
- --instruction-set-features=$DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES \
- --android-root=/system \
- --no-inline-from=core-oj.jar \
- --abort-on-hard-verifier-error \
- --force-determinism || { log_error "Dex2oat failed" ; exit 102 ; }
diff --git a/build/apex/art_preinstall_hook_system_server.sh b/build/apex/art_preinstall_hook_system_server.sh
deleted file mode 100644
index 9462c3b..0000000
--- a/build/apex/art_preinstall_hook_system_server.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/system/bin/sh
-
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-. `dirname $0`/art_prepostinstall_utils || exit 100
-
-function dalvik_cache_name {
- local input=$1
- # Strip first /, replace rest with @.
- DALVIK_CACHE_NAME=`echo $input | sed -e 's,^/,,' -e 's,/,@,g'`
- # Append @classes.dex.
- DALVIK_CACHE_NAME="${DALVIK_CACHE_NAME}@classes.dex"
-}
-
-log_info "Preparing system server compilation parameters"
-
-if [ "x$SYSTEMSERVERCLASSPATH" = "x" ] ; then
- log_info "SYSTEMSERVERCLASSPATH is not set! Trying to retrieve from init.environ.rc."
- SYSTEMSERVERCLASSPATH=`grep "export SYSTEMSERVERCLASSPATH" init.environ.rc | sed -e "s/.* //"`
- if [ "x$SYSTEMSERVERCLASSPATH" = "x" ] ; then
- log_error "Could not find SYSTEMSERVERCLASSPATH"
- exit 101
- fi
-fi
-SYSCP=`echo $SYSTEMSERVERCLASSPATH | tr ":" "\n"`
-
-BOOTCPPARAM=
-if [ ! -z "$DEX2OATBOOTCLASSPATH" ] ; then
- BOOTCPPARAM="--runtime-arg -Xbootclasspath:$DEX2OATBOOTCLASSPATH"
-fi
-
-DEX2OAT_IMAGE_XMX=`getprop dalvik.vm.dex2oat-Xmx`
-
-DEX2OAT_TARGET_ARCH=$1
-DEX2OAT_TARGET_CPU_VARIANT=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.variant`
-DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES=`getprop dalvik.vm.isa.${DEX2OAT_TARGET_ARCH}.features`
-
-# Do this like preopt: speed compile, no classpath, possibly pick up profiles.
-
-# TODO: App image? Would have to scan /system for an existing image.
-
-for COMPONENT in $SYSCP ; do
- log_info "Compiling $COMPONENT"
- dalvik_cache_name $COMPONENT
- PROFILING=
- if [ -f "${COMPONENT}.prof" ] ; then
- PROFILING="--profile-file=${COMPONENT}.prof"
- fi
- dex2oat \
- --avoid-storing-invocation \
- --runtime-arg -Xmx$DEX2OAT_IMAGE_XMX \
- $BOOTCPPARAM \
- --class-loader-context=\& \
- --boot-image=/data/dalvik-cache/system@framework@boot.art \
- --dex-file=$COMPONENT \
- --dex-location=$COMPONENT \
- --oat-file=/data/dalvik-cache/$DEX2OAT_TARGET_ARCH/$DALVIK_CACHE_NAME \
- --android-root=/system \
- --instruction-set=$DEX2OAT_TARGET_ARCH \
- --instruction-set-variant=$DEX2OAT_TARGET_CPU_VARIANT \
- --instruction-set-features=$DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES \
- --no-generate-debug-info \
- --abort-on-hard-verifier-error \
- --force-determinism \
- --no-inline-from=core-oj.jar \
- --copy-dex-files=false \
- --compiler-filter=speed \
- --generate-mini-debug-info \
- $PROFILING \
- || { log_error "Dex2oat failed" ; exit 102 ; }
-done
diff --git a/build/apex/art_prepostinstall_utils.sh b/build/apex/art_prepostinstall_utils.sh
deleted file mode 100644
index f5a94d1..0000000
--- a/build/apex/art_prepostinstall_utils.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/system/bin/sh
-
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-alias log_info="log -t art_apex -p i"
-alias log_error="log -t art_apex -p f"
-
-# Set |ARCHES| to a string containing the architectures of the device.
-function set_arches {
- # Derive architectures. For now, stop at two.
- local abilist_prop=`getprop ro.product.cpu.abilist`
- local abilist=`echo $abilist_prop | tr "," "\n"`
- ARCHES=""
- for abi in $abilist ; do
- case "$abi" in
- arm64-v8a)
- ARCHES="$ARCHES\narm64"
- ;;
- armeabi-v7a|armeabi)
- ARCHES="$ARCHES\narm"
- ;;
- x86)
- ARCHES="$ARCHES\nx86"
- ;;
- x86_64)
- ARCHES="$ARCHES\nx86_64"
- ;;
- *)
- log_error "Unsupported ABI $abi"
- return 1
- ;;
- esac
- done
- ARCHES=`echo $ARCHES | uniq`
- return 0
-}
-
-function setup_fsverity {
- local full_shell_path=`readlink -f $0`
- local bin_dir=`dirname $full_shell_path`
- local apex_dir=`dirname $bin_dir`
- local sig_dir="${apex_dir}.signatures"
- local file=$1
- local signature_file="$sig_dir/$file.sig"
- # Setup.
- log_info "fsverity setup for $file"
- SETUP_MSG=`fsverity setup $file --signature=$signature_file --hash=sha256 2>&1` || \
- { log_error "Setup failed: $SETUP_MSG" ; return 300 ; }
- # Enable.
- log_info "fsverity enable for $file"
- ENABLE_MSG=`fsverity enable $file 2>&1` || \
- { log_error "Enable failed: $ENABLE_MSG" ; return 301 ; }
- # Test integrity.
- INTEGRITY_MSG=`dd if=$file of=/dev/null bs=4k 2>&1` || \
- { log_error "Integrity failed: $INTEGRITY_MSG" ; return 302 ; }
- return 0
-}
diff --git a/build/apex/manifest-art.json b/build/apex/manifest-art.json
index ebba1b2..59cbfac 100644
--- a/build/apex/manifest-art.json
+++ b/build/apex/manifest-art.json
@@ -1,6 +1,4 @@
{
"name": "com.android.art",
- "version": 1,
- "preInstallHook": "bin/art_preinstall_hook",
- "postInstallHook": "bin/art_postinstall_hook"
+ "version": 1
}