Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Path concat in embedded lua script

28 views
Skip to first unread message

Oleksandr Andrushchenko

unread,
Dec 17, 2024, 3:35:21 PM12/17/24
to swupdate
Hello!

I am using an embedded LUA script which has the following line in it:

'if (cmdexec("rm -rf " .. tmpdir .. "/{*,.*}") == false) then'

which results in the following log when I run swupdate:

swupdate.sh[781]: rm: cannot remove '/tmp/tmp.ZV3iZzT4Gg': Device or resource busy
swupdate.sh[781]: sh: line 2: /bin: Is a directory
swupdate.sh[781]: [ERROR] : SWUPDATE failed [0] ERROR lua_interface.c : notify_helper : 725 : rm -rf /tmp/tmp.ZV3iZzT4Gg
swupdate.sh[781]: /{*,.*} returns with error

I also tried to just print it with

'swupdate.info("rm -rf " .. tmpdir .. "/{*,.*}")'

which produces

swupdate.sh[1591]: [INFO ] : SWUPDATE running :  [notify_helper] : rm -rf /tmp/tmp.AtbJHFG5DZ
swupdate.sh[1591]: /{*,.*}


So, this is actually not about how the SWUpdate process executes the command, but about
the string to be executed is not concatenated right, e.g. SWUpdate has it as
two lines instead of a single one:
instead of "rf /tmp/tmp.AtbJHFG5DZ/{*,.*}" it produces
"rf /tmp/tmp.AtbJHFG5DZ" (then new line I guess) and then "/{*,.*}"

Could you please help me understand what is wrong with this?
The same code I run on a host PC executes without an issue,
but refuses to run with swupdate...

cmdexec if from [1]

Thank you in advance,
Oleksandr

[1] https://github.com/sbabic/meta-swupdate-boards/blob/master/recipes-extended/images/update-image/beaglebone-yocto/emmcsetup.lua#L13

Oleksandr Andrushchenko

unread,
Dec 17, 2024, 3:35:21 PM12/17/24
to swupdate

Oleksandr Andrushchenko

unread,
Dec 18, 2024, 3:23:36 AM12/18/24
to swupdate
sorry for the noise: it was that I used os.capture form [1] which obviously returns "\n" at the end,
so it should be "os.capture('mktemp -d'):gsub('\\n', '')" in my case

вівторок, 17 грудня 2024 р. о 22:35:21 UTC+2 Oleksandr Andrushchenko пише:
Reply all
Reply to author
Forward
0 new messages