blob: abd140c7b843056917455410d7ac4af313029c1f [file] [log] [blame]
Patrick Williamsddad1a12017-02-23 20:36:32 -06001DESCRIPTION = "Different utilities from Android"
2SECTION = "console/utils"
Andrew Geissler9aee5002022-03-30 16:27:02 +00003LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause"
Patrick Williamsddad1a12017-02-23 20:36:32 -06004LIC_FILES_CHKSUM = " \
5 file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \
Andrew Geissler97771a32021-03-05 15:23:11 -06006 file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \
Brad Bishop0f291cc2019-09-01 15:16:57 -04007 file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \
Patrick Williamsddad1a12017-02-23 20:36:32 -06008 file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \
9"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010DEPENDS = "libbsd libpcre zlib libcap"
Patrick Williams213cb262021-08-07 19:21:33 -050011DEPENDS:append:class-target = " openssl"
Patrick Williamsddad1a12017-02-23 20:36:32 -060012
Patrick Williamsddad1a12017-02-23 20:36:32 -060013ANDROID_MIRROR = "android.googlesource.com"
Patrick Williamsddad1a12017-02-23 20:36:32 -060014
Brad Bishop316dfdd2018-06-25 12:45:53 -040015# matches with android-5.1.1_r37
16SRCREV_core = "2314b110bdebdbfd2d94c502282f9e57c849897e"
17SRCREV_extras = "3ecbe8d841df96127d7855661293e5ab6ba6c205"
18SRCREV_libhardware = "be55eb1f4d840c82ffaf7c47460df17ff5bc4d9b"
19SRCREV_libselinux = "07e9e1339ad1ba608acfba9dce2d0f474b252feb"
20SRCREV_build = "16e987def3d7d8f7d30805eb95cef69e52a87dbc"
21
William A. Kennington III49e95662021-09-15 16:19:36 -070022SRCREV_FORMAT = "core_extras_libhardware_libselinux_build"
Patrick Williamsddad1a12017-02-23 20:36:32 -060023SRC_URI = " \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 git://${ANDROID_MIRROR}/platform/system/core;name=core;protocol=https;nobranch=1;destsuffix=git/system/core \
25 git://${ANDROID_MIRROR}/platform/system/extras;name=extras;protocol=https;nobranch=1;destsuffix=git/system/extras \
26 git://${ANDROID_MIRROR}/platform/hardware/libhardware;name=libhardware;protocol=https;nobranch=1;destsuffix=git/hardware/libhardware \
27 git://${ANDROID_MIRROR}/platform/external/libselinux;name=libselinux;protocol=https;nobranch=1;destsuffix=git/external/libselinux \
28 git://${ANDROID_MIRROR}/platform/build;name=build;protocol=https;nobranch=1;destsuffix=git/build \
29 file://core/0001-adb-remove-selinux-extensions.patch;patchdir=system/core \
30 file://core/0002-adb-Use-local-sockets-where-appropriate.patch;patchdir=system/core \
31 file://core/0003-adb-define-shell-command.patch;patchdir=system/core \
32 file://core/0004-adb-Fix-build-on-big-endian-systems.patch;patchdir=system/core \
33 file://core/0005-adb-add-base64-implementation.patch;patchdir=system/core \
34 file://core/0006-adb-Musl-fixes.patch;patchdir=system/core \
35 file://core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch;patchdir=system/core \
36 file://core/0008-adb-Allow-adbd-to-be-ran-as-root.patch;patchdir=system/core \
37 file://core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch;patchdir=system/core \
38 file://core/0010-Use-linux-capability.h-on-linux-systems-too.patch;patchdir=system/core \
39 file://core/0011-Remove-bionic-specific-calls.patch;patchdir=system/core \
40 file://core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch;patchdir=system/core \
Brad Bishop19323692019-04-05 15:28:33 -040041 file://core/adb_libssl_11.diff;patchdir=system/core \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050042 file://core/b64_pton_function_decl.patch;patchdir=system/core \
Andrew Geissler82c905d2020-04-13 13:39:40 -050043 file://core/0013-adb-Support-riscv64.patch;patchdir=system/core \
Andrew Geissler9aee5002022-03-30 16:27:02 +000044 file://core/0014-add-u3-ss-descriptor-support-for-adb.patch;patchdir=system/core \
Patrick Williams92b42cb2022-09-03 06:53:57 -050045 file://core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch;patchdir=system/core \
46 file://core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch;patchdir=system/core \
47 file://core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch;patchdir=system/core \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050048 file://core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch;patchdir=system/core \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049 file://extras/0001-ext4_utils-remove-selinux-extensions.patch;patchdir=system/extras \
50 file://extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch;patchdir=system/extras \
51 file://libselinux/0001-Remove-bionic-specific-calls.patch;patchdir=external/libselinux \
Brad Bishop26bdd442019-08-16 17:08:17 -040052 file://libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch;patchdir=external/libselinux \
Patrick Williamsddad1a12017-02-23 20:36:32 -060053 file://android-tools-adbd.service \
Andrew Geissler82c905d2020-04-13 13:39:40 -050054 file://build/0001-Riscv-Add-risc-v-Android-config-header.patch;patchdir=build \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055 file://gitignore \
Patrick Williamsddad1a12017-02-23 20:36:32 -060056 file://adb.mk;subdir=${BPN} \
57 file://adbd.mk;subdir=${BPN} \
58 file://ext4_utils.mk;subdir=${BPN} \
59 file://fastboot.mk;subdir=${BPN} \
60 file://mkbootimg.mk;subdir=${BPN} \
61"
62
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080063
Patrick Williamsddad1a12017-02-23 20:36:32 -060064S = "${WORKDIR}/git"
65B = "${WORKDIR}/${BPN}"
66
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067# http://errors.yoctoproject.org/Errors/Details/133881/
Patrick Williams213cb262021-08-07 19:21:33 -050068ARM_INSTRUCTION_SET:armv4 = "arm"
69ARM_INSTRUCTION_SET:armv5 = "arm"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070
Patrick Williams213cb262021-08-07 19:21:33 -050071COMPATIBLE_HOST:powerpc = "(null)"
72COMPATIBLE_HOST:powerpc64 = "(null)"
73COMPATIBLE_HOST:powerpc64le = "(null)"
Brad Bishop19323692019-04-05 15:28:33 -040074
Patrick Williamsddad1a12017-02-23 20:36:32 -060075inherit systemd
76
Andrew Geissler72956ed2021-01-08 16:11:14 -060077SYSTEMD_PACKAGES = "${PN}-adbd"
Patrick Williams213cb262021-08-07 19:21:33 -050078SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
Patrick Williamsddad1a12017-02-23 20:36:32 -060079
Patrick Williamsddad1a12017-02-23 20:36:32 -060080# Find libbsd headers during native builds
Patrick Williams213cb262021-08-07 19:21:33 -050081CC:append:class-native = " -I${STAGING_INCDIR}"
82CC:append:class-nativesdk = " -I${STAGING_INCDIR}"
Patrick Williamsddad1a12017-02-23 20:36:32 -060083
84TOOLS = "adb fastboot ext4_utils mkbootimg adbd"
85
86# Adb needs sys/capability.h, which is not available for native*
Patrick Williams213cb262021-08-07 19:21:33 -050087TOOLS:class-native = "fastboot ext4_utils mkbootimg"
88TOOLS:class-nativesdk = "fastboot ext4_utils mkbootimg"
Patrick Williamsddad1a12017-02-23 20:36:32 -060089
90do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080091 cp ${WORKDIR}/gitignore ${S}/.gitignore
92
Patrick Williamsddad1a12017-02-23 20:36:32 -060093 # Setting both variables below causing our makefiles to not work with
94 # implicit make rules
95 unset CFLAGS
96 unset CPPFLAGS
97
98 export SRCDIR=${S}
99
100 case "${HOST_ARCH}" in
101 arm)
102 export android_arch=linux-arm
103 ;;
104 aarch64)
105 export android_arch=linux-arm64
106 ;;
Andrew Geissler82c905d2020-04-13 13:39:40 -0500107 riscv64)
108 export android_arch=linux-riscv64
109 ;;
Patrick Williamsddad1a12017-02-23 20:36:32 -0600110 mips|mipsel)
111 export android_arch=linux-mips
112 ;;
Brad Bishop19323692019-04-05 15:28:33 -0400113 mips64|mips64el)
114 export android_arch=linux-mips64
115 ;;
Patrick Williamsddad1a12017-02-23 20:36:32 -0600116 powerpc|powerpc64)
117 export android_arch=linux-ppc
118 ;;
Brad Bishopa891d152019-09-13 06:17:45 -0400119 i586|i686|x86_64)
Patrick Williamsddad1a12017-02-23 20:36:32 -0600120 export android_arch=linux-x86
121 ;;
122 esac
123
124 for tool in ${TOOLS}; do
125 mkdir -p ${B}/${tool}
126 oe_runmake -f ${B}/${tool}.mk -C ${B}/${tool}
127 done
128}
129
130do_install() {
131 if echo ${TOOLS} | grep -q "ext4_utils" ; then
132 install -D -p -m0755 ${S}/system/core/libsparse/simg_dump.py ${D}${bindir}/simg_dump
133 install -D -p -m0755 ${S}/system/extras/ext4_utils/mkuserimg.sh ${D}${bindir}/mkuserimg
134
135 install -m0755 ${B}/ext4_utils/ext2simg ${D}${bindir}
136 install -m0755 ${B}/ext4_utils/ext4fixup ${D}${bindir}
137 install -m0755 ${B}/ext4_utils/img2simg ${D}${bindir}
138 install -m0755 ${B}/ext4_utils/make_ext4fs ${D}${bindir}
139 install -m0755 ${B}/ext4_utils/simg2img ${D}${bindir}
140 install -m0755 ${B}/ext4_utils/simg2simg ${D}${bindir}
141 fi
142
Patrick Williams213cb262021-08-07 19:21:33 -0500143 if echo ${TOOLS} | grep -q "adb\>" ; then
Patrick Williamsddad1a12017-02-23 20:36:32 -0600144 install -d ${D}${bindir}
145 install -m0755 ${B}/adb/adb ${D}${bindir}
146 fi
147
148 if echo ${TOOLS} | grep -q "adbd" ; then
149 install -d ${D}${bindir}
150 install -m0755 ${B}/adbd/adbd ${D}${bindir}
151 fi
152
153 # Outside the if statement to avoid errors during do_package
154 install -D -p -m0644 ${WORKDIR}/android-tools-adbd.service \
155 ${D}${systemd_unitdir}/system/android-tools-adbd.service
156
157 if echo ${TOOLS} | grep -q "fastboot" ; then
158 install -d ${D}${bindir}
159 install -m0755 ${B}/fastboot/fastboot ${D}${bindir}
160 fi
161
162 if echo ${TOOLS} | grep -q "mkbootimg" ; then
163 install -d ${D}${bindir}
164 install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir}
165 fi
166}
167
Andrew Geissler72956ed2021-01-08 16:11:14 -0600168PACKAGES =+ "${PN}-fstools ${PN}-adbd"
Patrick Williamsddad1a12017-02-23 20:36:32 -0600169
Patrick Williams213cb262021-08-07 19:21:33 -0500170RDEPENDS:${PN}-adbd = "${PN}-conf"
171RDEPENDS:${PN}-fstools = "bash"
Andrew Geissler72956ed2021-01-08 16:11:14 -0600172
Patrick Williams213cb262021-08-07 19:21:33 -0500173FILES:${PN}-adbd = "\
Andrew Geissler72956ed2021-01-08 16:11:14 -0600174 ${bindir}/adbd \
175 ${systemd_unitdir}/system/android-tools-adbd.service \
176"
Patrick Williamsddad1a12017-02-23 20:36:32 -0600177
Patrick Williams213cb262021-08-07 19:21:33 -0500178FILES:${PN}-fstools = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -0600179 ${bindir}/ext2simg \
180 ${bindir}/ext4fixup \
181 ${bindir}/img2simg \
182 ${bindir}/make_ext4fs \
183 ${bindir}/simg2img \
184 ${bindir}/simg2simg \
185 ${bindir}/simg_dump \
186 ${bindir}/mkuserimg \
187"
188
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189BBCLASSEXTEND = "native"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500190
191android_tools_enable_devmode() {
192 touch ${IMAGE_ROOTFS}/var/usb-debugging-enabled
193}
194
195ROOTFS_POSTPROCESS_COMMAND_${PN}-adbd += "${@bb.utils.contains("USB_DEBUGGING_ENABLED", "1", "android_tools_enable_devmode;", "", d)}"