1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target: Avoid intermittent error when installing binary

Installing busybox sometimes fails with:

    cp: /data/local/tmp/bin/busybox: Text file busy

This happens when trying to modify a binary file while a process is
still running (e.g. unclean previous disconnection).

Fix that by using the -f option, which will remove the destination file
first and retry the copy in case of failure.
This commit is contained in:
Douglas Raillard 2023-08-04 11:53:50 +01:00 committed by Marc Bonnici
parent cf4d3b5f4c
commit 1730f69461

View File

@ -2134,7 +2134,7 @@ class AndroidTarget(Target):
on_device_executable = self.path.join(self.executables_directory, executable_name) on_device_executable = self.path.join(self.executables_directory, executable_name)
await self.push.asyn(filepath, on_device_file, timeout=timeout) await self.push.asyn(filepath, on_device_file, timeout=timeout)
if on_device_file != on_device_executable: if on_device_file != on_device_executable:
await self.execute.asyn('cp {} {}'.format(quote(on_device_file), quote(on_device_executable)), await self.execute.asyn('cp -f -- {} {}'.format(quote(on_device_file), quote(on_device_executable)),
as_root=self.needs_su, timeout=timeout) as_root=self.needs_su, timeout=timeout)
await self.remove.asyn(on_device_file, as_root=self.needs_su) await self.remove.asyn(on_device_file, as_root=self.needs_su)
await self.execute.asyn("chmod 0777 {}".format(quote(on_device_executable)), as_root=self.needs_su) await self.execute.asyn("chmod 0777 {}".format(quote(on_device_executable)), as_root=self.needs_su)