Commit Graph

1 Commits

Author SHA1 Message Date
Martin Weinelt
06d92ba195
esphome: fix permissions on src file before modifying them
We store esphome in the nix store, which results in its file permissions
being 0444. Esphome, when compiling a firmware image, will copy these
files from the nix store to a working directory. When updating between
versions it will notice these files changed and try to copy the new
version over, which would break, because the user had no write
permissions on the files.

❯ esphome compile 01e4ac.yml
INFO Reading configuration 01e4ac.yml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight saving time from 27 March 02:00:00 to 30 October 03:00:00
INFO Generating C++ source...
ERROR Error copying file /nix/store/lmzrgl1arqfd98jcss4rsmmy6dbffddn-esphome-1.19.2/lib/python3.8/site-packages/esphome/components/api/api_connection.cpp to 01e4ac/src/esphome/components/api/api_connection.cpp: [Errno 13] Permission denied: '01e4ac/src/esphome/components/api/api_connection.cpp'

To fix this we modify chmod to 0644 just before esphome tries a copy
operation, which will fix permissions on existing working directories
just in time.
2021-06-23 05:07:11 +02:00