Stop Yocto Build with Default downloads, sstate-cache, and tmp Directories

One thing that annoyed me for some time was starting a Yocto build and, only after a few minutes or hours, remember to fix the downloads, sstate-cache and tmp directories in build/conf/local.conf.

In general we want to share the downloads and the sstate-cache with other builds to speed things up as much as possible, especially when several people are working on the same the build machine. In that case we would just commit that configuration to the repository, so everyone uses it and forgets about it.

However we can also have the case where people build on many shared machines with different configurations as well on their local machines. Then everyone agrees to leave the default because that makes nobody happy.

In this case that configuration is never committed to the repository and is always floating around, get lost on a stash for a rebase or merge, and so on. When you less expect the build has started and the default directories are being used.

By default Yocto uses three directories inside build: downloads, sstate-cache, and tmp. I want to always use somewhere else.

So, to fail the build when I forget to change them, I simply create the three directories and make them read-only.

cd build
mkdir downloads sstate-cache tmp
chmod 555 downloads sstate-cache tmp

And, if this idea pleases everybody in the team, it is possible to create some placeholder read-only file inside each directory before making the directories read-only (with chmod 555 ...), then commit these untouchable directories to the repository.

touch downloads/ro sstate-cache/ro tmp/ro
chmod 444 downloads/ro sstate-cache/ro tmp/ro

I hope this helps and good luck!

Autor: Djones Boni

Engenheiro Eletricista.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *