Ebuild development (end of mentoring) quiz Revision 1.3.1 - 03 May 2008 Answer in whatever length necessary for completeness. Review documentation. Consult your mentor if you're unable to locate answers. This quiz is based largely on ciaranm's bash quiz -- much thanks to him for the original and for extensive helpful feedback. 1. You are writing an ebuild for the foomatic package. Upstream calls the current version "1.3-7b" (but this is _not_ a beta release). How would the ebuild be named? What's wrong with the ebuild snippet below and how should this be written to aid maintainability? SRC_URI="http://foomatic.example.com/download/foomatic-1.3-7b.tar.bz2" S=${WORKDIR}/foomatic-1.3-7b 2. You have a patch for foomatic which enables SSL support. Give an example src_unpack() which will apply this patch to foomatic. Foomatic uses an autotools based build system. What other things must be added to the ebuild? 3. What's the difference between local and global scope in an ebuild? 4. Why should an external application (for example sed/grep) not be called in global scope? What alternative methods can be used? 5. What is wrong with using $(somecommand) or `somecommand` or $ARCH inside SRC_URI, DEPEND, etc? 6. Explain what's incorrect about the following code snippets and suggest an alternative. 6.a # This ebuild doesn't like the -mcpu=ultrasparc CFLAG, so drop to v9 CFLAGS=${CFLAGS/-mcpu=ultrasparc/-mcpu=v9} 6.b # Upstream don't support user-specified CFLAGS unset CFLAGS 6.c # Extra settings for when SSL is enabled if [ "`use ssl `" ] ; then # blah fi 6.d # Extra options for configure use jpeg && myconf="--enable-jpeg" \ || myconf="--disable-jpeg" use png && myconf="${myconf} --enable-png" \ || myconf="${myconf} --disable-png" use gif && myconf="${myconf} --enable-gif89a" \ || myconf="${myconf} --disable-gif89a" econf ${myconf} 6.e # Use an alternative implementation instead of the default depending # the foo use flag. DEPEND="foo? ( cat-foo/alternative ) : ( cat-foo/default )" 6.f # If we USE foo, we need to DEPEND upon libfoo. Unfortunately # foo is completely broken on some archs DEPEND="!x86? ( !amd64? ( !ppc? ( foo? ( >=dev-libs/libfoo-1.2 ) ) ) )" 6.g # If USE=fnord is enabled, make extra targets: use fnord && ( emake fnordification || die "it broke" ) 7. Explain briefly the purpose of the following tools: grep, cut, sed, cat, wc, awk 8. Why are 'head -5' and 'tail -5' bad? What should be used instead? 9. You're writing an ebuild and init script for a server application that needs networking to be available when started and can also use a system logger if one is available. How should this be written in the init script? 10. What is the 'Gentoo Way' of allowing the user to pass other options to the previously mentioned server application? 11. What is the 'Gentoo Way' of globally setting environment variables for all users? 12. What directory should be used for application-generated non-temporary data? 13. Which directory should manual (man) pages be in and how should they be installed from an ebuild? 14. On Gentoo Linux systems, what is the purpose of /usr/local/bin? 15. You are committing a new package to the tree. What will you have in the KEYWORDS variable? 16. You are bumping foomatic's ebuild from version 1.2 to version 1.3. The new release contains bugfixes and new functionality. The current KEYWORDS for 1.2 are "x86 sparc ~mips amd64" -- what will KEYWORDS be for the new 1.3 ebuild? 17. You are bumping foomatic's ebuild from version 1.3 to 1.4. The new release extends functionality and introduces a new dependency on libfnord version 1.2 or later. The KEYWORDS for foomatic-1.3 are "x86 sparc ~mips amd64" and the KEYWORDS for libfnord-1.2 are "x86 ~sparc" -- what will you do? 18. You are bumping foomatic's ebuild from version 1.4 to 1.5. This release introduces new optional support for the libgerbil library, which you are controlling via the gerbil global USE flag. Unfortunately libgerbil is full of code which doesn't work properly on big endian systems, and so has "-sparc -mips" in the KEYWORDS. How will you handle this? 19. You are bumping foomatic's ebuild from version 1.5 to version 2.0. This new version is a massive rewrite which introduces huge changes to the build system, the required libraries and how the code works. What will you do for KEYWORDS here?