Topics

Best convention for FILES variable


rustyhowell@...
 

Hello,
I am relatively new to yocto, and I am working on several recipes at the moment and I'm wondering about using wildcards in my FILES_{PN} list. None of the packages have more than 5 or 6 files to package. They could easily be covered with two wildcard entries, but I wonder if there is benefit to listing each file explicitly. Thanks for the help.  Example below:
FILES_fooz = "\
*/fooz* \
*/*/fooz* \
"
vs
FILES_fooz = "\
   /lib/foozlib.so \
   /usr/lib/foozlib-2.so \
/usr/bin/fooz \
/bin/fooz \
/usr/share/fooz \
"
Thanks


Chuck Wolber
 

On Fri, Nov 20, 2020 at 6:49 PM <rustyhowell@...> wrote:
Hello,
I am relatively new to yocto, and I am working on several recipes at the moment and I'm wondering about using wildcards in my FILES_{PN} list. None of the packages have more than 5 or 6 files to package. They could easily be covered with two wildcard entries, but I wonder if there is benefit to listing each file explicitly. Thanks for the help.  Example below:
FILES_fooz = "\
*/fooz* \
*/*/fooz* \
"
vs
FILES_fooz = "\
   /lib/foozlib.so \
   /usr/lib/foozlib-2.so \
/usr/bin/fooz \
/bin/fooz \
/usr/share/fooz \
"

Both will work, although you do run the risk of accidentally globbing files that you do not mean to include, but perhaps you know your recipes well enough that that is not a factor.

Personally, I find that being explicit makes a lot more sense for a few reasons:
  • Stuff changes, and I _want_ a build error or warning to let me when it changes and someone forgot to update the recipe.
  • The grep command is your friend. If you glob, you lose a lot of fidelity there.
  • If you want to refactor a recipe into separate packages later, you probably need to do a lot of head scratching to pin down all of the files generated in the build.
And finally, I have adjusted to using the following pattern, and found that it has improved maintainability a great deal. It applies to DEPENDS and RDEPENDS as well. Yes, it is a bit tedious, but the benefits far outweigh the cost (IMHO).

FILES_fooz += " lib/foozlib.so"
FILES_fooz += " /usr/lib/foozlib-2.so"
FILES_fooz += " /usr/bin/fooz"
FILES_fooz += " /bin/fooz"
FILES_fooz += " /usr/share/fooz"

This pattern is invaluable when you start accumulating a lot of recipes. A recursive grep (grep -r) across a directory tree, will immediately tell you that (for example), /bin/fooz is file in the fooz package and it is referenced in the fooz_1.3.2.bb recipe.

..Ch:W..

--
"Perfection must be reached by degrees; she requires the slow hand of time." - Voltaire


Chuck Wolber
 



On Sat, Nov 21, 2020 at 12:21 AM Chuck Wolber <chuckwolber@...> wrote:

%< SNIP %<
 
And finally, I have adjusted to using the following pattern, and found that it has improved maintainability a great deal. It applies to DEPENDS and RDEPENDS as well. Yes, it is a bit tedious, but the benefits far outweigh the cost (IMHO).

FILES_fooz += " lib/foozlib.so"
FILES_fooz += " /usr/lib/foozlib-2.so"
FILES_fooz += " /usr/bin/fooz"
FILES_fooz += " /bin/fooz"
FILES_fooz += " /usr/share/fooz"

This pattern is invaluable when you start accumulating a lot of recipes. A recursive grep (grep -r) across a directory tree, will immediately tell you that (for example), /bin/fooz is file in the fooz package and it is referenced in the fooz_1.3.2.bb recipe.


I forgot one other benefit. When a change is made to a recipe that uses that pattern, the (Git) commit diff is a lot clearer and easier to understand.

Think of it this way... Use your pattern, but imagine there are a lot more entries in your list. A change to the middle of that list is going to result in a diff that is hard to determine if it is a FILE_fooz entry or a DEPENDS_${PN} entry. Prefixing with the directive keeps your Git history a lot clearer.
 
..Ch:W..

--
"Perfection must be reached by degrees; she requires the slow hand of time." - Voltaire


Robert P. J. Day
 

On Sat, 21 Nov 2020, Chuck Wolber wrote:



On Sat, Nov 21, 2020 at 12:21 AM Chuck Wolber <chuckwolber@gmail.com> wrote:

%< SNIP %<
 
And finally, I have adjusted to using the following pattern, and found that it
has improved maintainability a great deal. It applies to DEPENDS and RDEPENDS
as well. Yes, it is a bit tedious, but the benefits far outweigh the cost
(IMHO).

FILES_fooz += " lib/foozlib.so"
FILES_fooz += " /usr/lib/foozlib-2.so"
FILES_fooz += " /usr/bin/fooz"
FILES_fooz += " /bin/fooz"
FILES_fooz += " /usr/share/fooz"
pedantically speaking, since you're using "+=", you don't need those
leading spaces.

rday


Chuck Wolber
 

On Sat, Nov 21, 2020 at 7:48 AM Robert P. J. Day <rpjday@...> wrote:

%< SNIP %<
 
  pedantically speaking, since you're using "+=", you don't need those
leading spaces.

Indeed you are correct. I believe I mistakenly conflated that particular aspect of "_append" with "+=".

Thank you for pointing this out.

..Ch:W..

--
"Perfection must be reached by degrees; she requires the slow hand of time." - Voltaire