android_system_core/fs_mgr/libsnapshot/Android.bp

511 lines
11 KiB
Plaintext
Raw Normal View History

//
// Copyright (C) 2018 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.
//
[LSC] Add LOCAL_LICENSE_KINDS to system/core Added SPDX-license-identifier-Apache-2.0 to: bootstat/Android.bp cli-test/Android.bp code_coverage/Android.bp cpio/Android.bp debuggerd/crasher/Android.bp debuggerd/proto/Android.bp diagnose_usb/Android.bp fs_mgr/libdm/Android.bp fs_mgr/libfiemap/Android.bp fs_mgr/liblp/Android.bp fs_mgr/libsnapshot/Android.bp fs_mgr/libstorage_literals/Android.bp fs_mgr/libvbmeta/Android.bp fs_mgr/tests/Android.bp fs_mgr/tools/Android.bp gatekeeperd/Android.bp healthd/Android.bp healthd/testdata/Android.bp init/Android.bp init/Android.mk init/sysprop/Android.bp init/test_kill_services/Android.bp init/test_service/Android.bp libappfuse/Android.bp libasyncio/Android.bp libbinderwrapper/Android.bp libcrypto_utils/Android.bp libcrypto_utils/tests/Android.bp libdiskconfig/Android.bp libgrallocusage/Android.bp libkeyutils/mini_keyctl/Android.bp libmodprobe/Android.bp libnetutils/Android.bp libpackagelistparser/Android.bp libprocessgroup/Android.bp libprocessgroup/cgrouprc/Android.bp libprocessgroup/cgrouprc_format/Android.bp libprocessgroup/profiles/Android.bp libprocessgroup/setup/Android.bp libqtaguid/Android.bp libsparse/Android.bp libstats/push_compat/Android.bp libsuspend/Android.bp libsync/Android.bp libsystem/Android.bp libsysutils/Android.bp libusbhost/Android.bp libutils/Android.bp libvndksupport/Android.bp libvndksupport/tests/Android.bp llkd/Android.bp llkd/tests/Android.bp property_service/libpropertyinfoparser/Android.bp property_service/libpropertyinfoserializer/Android.bp property_service/property_info_checker/Android.bp qemu_pipe/Android.bp reboot/Android.bp rootdir/Android.bp rootdir/Android.mk rootdir/avb/Android.bp rootdir/avb/Android.mk run-as/Android.bp sdcard/Android.bp set-verity-state/Android.bp shell_and_utilities/Android.bp storaged/Android.bp toolbox/Android.bp trusty/apploader/Android.bp trusty/confirmationui/Android.bp trusty/confirmationui/fuzz/Android.bp trusty/coverage/Android.bp trusty/fuzz/Android.bp trusty/fuzz/test/Android.bp trusty/gatekeeper/Android.bp trusty/gatekeeper/fuzz/Android.bp trusty/keymaster/Android.bp trusty/keymaster/fuzz/Android.bp trusty/libtrusty/Android.bp trusty/libtrusty/tipc-test/Android.bp trusty/secure_dpu/Android.bp trusty/storage/interface/Android.bp trusty/storage/lib/Android.bp trusty/storage/proxy/Android.bp trusty/storage/tests/Android.bp trusty/utils/spiproxyd/Android.bp trusty/utils/trusty-ut-ctrl/Android.bp usbd/Android.bp watchdogd/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to: debuggerd/Android.bp fastboot/Android.bp libkeyutils/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-MIT to: libcutils/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT to: fs_mgr/Android.bp fs_mgr/libfs_avb/Android.bp trusty/Android.bp trusty/utils/rpmb_dev/Android.bp Added SPDX-license-identifier-BSD to: fastboot/fuzzy_fastboot/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-17 03:02:14 +00:00
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_defaults {
name: "libsnapshot_defaults",
defaults: ["fs_mgr_defaults"],
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
shared_libs: [
"libbase",
"libchrome",
"libcutils",
"liblog",
],
static_libs: [
"libbrotli",
"libdm",
"libfstab",
"update_metadata-protos",
],
whole_static_libs: [
libsnapshot: Add support for first-to-second-stage transitions of snapuserd. This patch introduces the fundamentals needed to support booting off dm-user. First, a method has been added to start snapuserd in first-stage init. It simply forks and execs, creates a specially named first-stage socket, then waits for requests. Next, a new method has been added to SnapshotManager to perform a second-stage handoff. This works by first launching a second copy of snapuserd using init's normal service management functionality. The new snapuserd runs alongside the original, but has correct privileges and a correct selinux context. Next, we inspect each COW device, and if its table uses dm-user, we replace the table with a renamed control device. The new control device is bound to the new snapuserd. device-mapper guarantees that such a table swap is safe. It flushes I/O to the old table and then replaces it with the new table. Once the new table is in place, the old dm-user control devices are automatically destroyed. Thus, once all dm-user devices has been transitioned, the first-stage daemon is idle and can gracefully exit. This patch does not modify init. A few changes will be needed on top of this patch: (1) CreateLogicalAndSnapshotPartitions will need further changes to start the first-stage daemon and track its pid. Additionally, it will need to ensure the named socket file is deleted, so there is no further IPC allowed after partitions are completed. (2) init will need to propagate the pid to second-stage init so the process can be killed (or signalled). (3) first-stage snapuserd will need to gracefully exit once it has no active handler threads. (4) second-stage init will need to invoke the transition helper on SnapshotMaanager, ideally as soon as feasible. Bug: 168259959 Test: manual test Change-Id: I54dec2edf85ed95f11ab4518eb3d7dbaf0bdcbfd
2020-10-29 00:02:25 +00:00
"libbrotli",
"libcutils",
"libext2_uuid",
"libext4_utils",
"libfstab",
"libsnapshot_snapuserd",
libsnapshot: Add support for first-to-second-stage transitions of snapuserd. This patch introduces the fundamentals needed to support booting off dm-user. First, a method has been added to start snapuserd in first-stage init. It simply forks and execs, creates a specially named first-stage socket, then waits for requests. Next, a new method has been added to SnapshotManager to perform a second-stage handoff. This works by first launching a second copy of snapuserd using init's normal service management functionality. The new snapuserd runs alongside the original, but has correct privileges and a correct selinux context. Next, we inspect each COW device, and if its table uses dm-user, we replace the table with a renamed control device. The new control device is bound to the new snapuserd. device-mapper guarantees that such a table swap is safe. It flushes I/O to the old table and then replaces it with the new table. Once the new table is in place, the old dm-user control devices are automatically destroyed. Thus, once all dm-user devices has been transitioned, the first-stage daemon is idle and can gracefully exit. This patch does not modify init. A few changes will be needed on top of this patch: (1) CreateLogicalAndSnapshotPartitions will need further changes to start the first-stage daemon and track its pid. Additionally, it will need to ensure the named socket file is deleted, so there is no further IPC allowed after partitions are completed. (2) init will need to propagate the pid to second-stage init so the process can be killed (or signalled). (3) first-stage snapuserd will need to gracefully exit once it has no active handler threads. (4) second-stage init will need to invoke the transition helper on SnapshotMaanager, ideally as soon as feasible. Bug: 168259959 Test: manual test Change-Id: I54dec2edf85ed95f11ab4518eb3d7dbaf0bdcbfd
2020-10-29 00:02:25 +00:00
"libz",
],
header_libs: [
"libfiemap_headers",
"libstorage_literals_headers",
"libupdate_engine_headers",
],
export_static_lib_headers: [
"update_metadata-protos",
],
export_header_lib_headers: [
"libfiemap_headers",
],
export_include_dirs: ["include"],
proto: {
type: "lite",
export_proto_headers: true,
canonical_path_from_root: false,
},
}
cc_defaults {
name: "libsnapshot_hal_deps",
cflags: [
"-DLIBSNAPSHOT_USE_HAL",
],
shared_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
"android.hardware.boot-V1-ndk",
"libboot_control_client",
],
}
filegroup {
name: "libsnapshot_sources",
srcs: [
"android/snapshot/snapshot.proto",
"device_info.cpp",
"snapshot.cpp",
"snapshot_reader.cpp",
"snapshot_stats.cpp",
"snapshot_stub.cpp",
"snapshot_metadata_updater.cpp",
"snapshot_writer.cpp",
"partition_cow_creator.cpp",
"return.cpp",
"utility.cpp",
],
}
cc_library_headers {
name: "libsnapshot_headers",
recovery_available: true,
defaults: ["libsnapshot_defaults"],
}
cc_library_static {
name: "libsnapshot",
defaults: [
"libsnapshot_defaults",
"libsnapshot_hal_deps",
],
srcs: [":libsnapshot_sources"],
static_libs: [
"libfs_mgr_binder"
],
}
cc_library_static {
name: "libsnapshot_init",
native_coverage : true,
defaults: ["libsnapshot_defaults"],
srcs: [":libsnapshot_sources"],
ramdisk_available: true,
recovery_available: true,
cflags: [
"-DLIBSNAPSHOT_NO_COW_WRITE",
],
static_libs: [
"libfs_mgr",
],
}
cc_library_static {
name: "libsnapshot_nobinder",
defaults: [
"libsnapshot_defaults",
"libsnapshot_hal_deps",
],
srcs: [":libsnapshot_sources"],
recovery_available: true,
cflags: [
"-DLIBSNAPSHOT_NO_COW_WRITE",
],
static_libs: [
"libfs_mgr",
],
}
cc_defaults {
name: "libsnapshot_cow_defaults",
defaults: [
"fs_mgr_defaults",
],
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
shared_libs: [
"libbase",
"liblog",
],
static_libs: [
"libbrotli",
"libz",
"liblz4",
],
export_include_dirs: ["include"],
}
cc_library_static {
name: "libsnapshot_cow",
defaults: [
"libsnapshot_cow_defaults",
],
srcs: [
"libsnapshot_cow/cow_decompress.cpp",
"libsnapshot_cow/cow_reader.cpp",
"libsnapshot_cow/cow_writer.cpp",
"libsnapshot_cow/cow_format.cpp",
"libsnapshot_cow/cow_compress.cpp",
],
host_supported: true,
recovery_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
}
cc_library_static {
name: "libsnapshot_test_helpers",
defaults: ["libsnapshot_defaults"],
export_include_dirs: [
"include_test",
],
srcs: [
"android/snapshot/snapshot.proto",
"test_helpers.cpp",
],
shared_libs: [
"android.hardware.boot@1.1",
"libcrypto",
],
export_shared_lib_headers: [
"android.hardware.boot@1.1",
],
header_libs: [
"libstorage_literals_headers",
],
export_header_lib_headers: [
"libstorage_literals_headers",
],
static_libs: [
"libfs_mgr",
"libgmock",
"libgtest",
],
}
cc_defaults {
name: "libsnapshot_test_defaults",
defaults: ["libsnapshot_defaults", "libsnapshot_cow_defaults"],
srcs: [
"partition_cow_creator_test.cpp",
"snapshot_metadata_updater_test.cpp",
"snapshot_reader_test.cpp",
"snapshot_test.cpp",
"snapshot_writer_test.cpp",
],
shared_libs: [
"libbinder",
"libcrypto",
"libhidlbase",
"libprotobuf-cpp-lite",
"libutils",
"libz",
],
static_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
"android.hardware.boot-V1-ndk",
"libbrotli",
"libc++fs",
"libfs_mgr_binder",
"libgflags",
"libgsi",
"libgmock",
"liblp",
"libsnapshot",
"libsnapshot_cow",
"libsnapshot_test_helpers",
"libsparse",
],
header_libs: [
"libstorage_literals_headers",
],
test_suites: [
"vts",
"device-tests"
],
test_options: {
min_shipping_api_level: 29,
},
auto_gen_config: true,
require_root: true,
compile_multilib: "first",
}
cc_test {
name: "vts_libsnapshot_test",
defaults: ["libsnapshot_test_defaults", "libsnapshot_hal_deps"],
}
cc_test {
name: "vab_legacy_tests",
defaults: ["libsnapshot_test_defaults", "libsnapshot_hal_deps"],
cppflags: [
"-DLIBSNAPSHOT_TEST_VAB_LEGACY",
],
}
cc_test {
name: "vabc_legacy_tests",
defaults: ["libsnapshot_test_defaults", "libsnapshot_hal_deps"],
cppflags: [
"-DLIBSNAPSHOT_TEST_VABC_LEGACY",
],
}
cc_test {
name: "vts_ota_config_test",
srcs: [
"vts_ota_config_test.cpp",
],
shared_libs: [
"libbase",
],
test_suites: [
"vts",
],
test_options: {
min_shipping_api_level: 33,
},
auto_gen_config: true,
require_root: true,
}
cc_binary {
name: "snapshotctl",
defaults: ["libsnapshot_cow_defaults", "libsnapshot_hal_deps"],
srcs: [
"snapshotctl.cpp",
],
static_libs: [
"libbrotli",
"libc++fs",
"libfstab",
"libsnapshot",
"libsnapshot_cow",
"libz",
"update_metadata-protos",
],
shared_libs: [
"libbase",
"libext2_uuid",
"libext4_utils",
"libfs_mgr_binder",
"libhidlbase",
"liblog",
"liblp",
"libprotobuf-cpp-lite",
"libstatslog",
"libutils",
],
header_libs: [
"libstorage_literals_headers",
],
product_variables: {
debuggable: {
cppflags: [
"-DSNAPSHOTCTL_USERDEBUG_OR_ENG",
],
shared_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
"android.hardware.boot-V1-ndk",
"libboot_control_client",
],
},
},
}
cc_test {
name: "snapshot_power_test",
srcs: [
"power_test.cpp",
],
static_libs: [
"libc++fs",
"libsnapshot",
"update_metadata-protos",
],
shared_libs: [
"libbase",
"libfs_mgr_binder",
"liblog",
],
gtest: false,
}
cc_test {
name: "cow_api_test",
defaults: [
"fs_mgr_defaults",
"libsnapshot_cow_defaults",
],
srcs: [
"libsnapshot_cow/cow_api_test.cpp",
],
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
shared_libs: [
"libbase",
"libcrypto",
"liblog",
"libz",
],
static_libs: [
"libbrotli",
"libgtest",
"libsnapshot_cow",
],
test_suites: [
"device-tests"
],
test_options: {
min_shipping_api_level: 30,
},
auto_gen_config: true,
require_root: false,
host_supported: true,
}
cc_binary {
name: "make_cow_from_ab_ota",
host_supported: true,
device_supported: false,
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
static_libs: [
"libbase",
"libbspatch",
"libbrotli",
"libbz",
"libchrome",
"libcrypto",
"libgflags",
"liblog",
"libprotobuf-cpp-lite",
"libpuffpatch",
"libsnapshot_cow",
"libsparse",
"libxz",
"libz",
"liblz4",
"libziparchive",
"update_metadata-protos",
],
srcs: [
"make_cow_from_ab_ota.cpp",
],
target: {
darwin: {
enabled: false,
},
},
}
cc_binary {
name: "estimate_cow_from_nonab_ota",
defaults: [
"libsnapshot_cow_defaults",
],
host_supported: true,
device_supported: false,
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
static_libs: [
"libbase",
"libbrotli",
"libbz",
"libcrypto",
"libgflags",
"liblog",
"libsnapshot_cow",
"libsparse",
"libz",
"libziparchive",
],
srcs: [
"estimate_cow_from_nonab_ota.cpp",
],
target: {
darwin: {
enabled: false,
},
},
}
cc_binary {
name: "inspect_cow",
host_supported: true,
device_supported: true,
defaults: ["libsnapshot_cow_defaults"],
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-Wall",
"-Werror",
],
static_libs: [
"libbase",
"libbrotli",
"libcrypto_static",
"liblog",
"libsnapshot_cow",
"libz",
],
shared_libs: [
],
srcs: [
"libsnapshot_cow/inspect_cow.cpp",
],
}
python_library_host {
name: "snapshot_proto_python",
srcs: [
"android/snapshot/snapshot.proto",
],
proto: {
canonical_path_from_root: false,
},
}