User:Sam/ebuild wrapper

From Gentoo Wiki
Jump to:navigation Jump to:search

I use a small wrapper for ebuild(1) inspired by slyfox's e. It also makes use of gitify in /etc/portage/bashrc.

I create the following files and add ~/bin to PATH. I also have ~/bin/ebuild as a symlink to ~/bin/e.

FILE ~/bin/ebuild
#!/usr/bin/env bash
# Originally based on https://github.com/trofi/home/blob/ff297b2b6fe51fd0ab226f92c19b5717598b568d/bin%2Fe
# Note that this is used with https://github.com/gentoo-haskell/gentoo-haskell/blob/master/projects/doc/hacking-tips.rst#gitify-your-ebuilds-in-prepare-phase
if [[ $0 != *@(e|/home/sam/bin/e) ]] ; then
        # Only gitify ${WORKDIR} if invoked as 'e', not 'ebuild'
        export GITIFY=no
fi

PORTAGE_NICENESS=0 \
PORTAGE_IONICE_COMMAND="true" \
CCACHE_DIR="/var/cache/ccache" \
FEATURES="ccache -test-fail-continue splitdebug compressdebug installsources -nostrip ${FEATURES}" \
CFLAGS="$(portageq envvar CFLAGS)     ${E_DFLAGS--ggdb3}" \
CXXFLAGS="$(portageq envvar CXXFLAGS) ${E_DFLAGS--ggdb3}" \
FFLAGS="$(portageq envvar FFLAGS)     ${E_DFLAGS--ggdb3}" \
FCFLAGS="$(portageq envvar FCFLAGS)   ${E_DFLAGS--ggdb3}" \
GITIFY=${GITIFY-yes} \
PORTAGE_TMPDIR=${PORTAGE_TMPDIR:-/var/tmp} \
exec sudo --preserve-env ebuild "$@"
FILE /etc/portage/bashrc
# From iwdevtools
source /usr/share/iwdevtools/bashrc

# gitify
# https://github.com/gentoo-haskell/gentoo-haskell/blob/master/projects/doc/hacking-tips.rst#gitify-your-ebuilds-in-prepare-phase
git_commit_current_state() {
        [[ -z ${GITIFY} || ${GITIFY} == "no" ]] && return

        pushd "${S}" &> /dev/null

        rm -f .gitignore &> /dev/null
        git init -q . &> /dev/null
        git config --add safe.directory ${PWD} &> /dev/null
        git config user.name "Sam James" &> /dev/null
        git config user.email "sam@gentoo.org" &> /dev/null
        git add . &> /dev/null
        git commit -q -a -s -m "$@" &> /dev/null

        popd &> /dev/null
}

post_src_unpack() {
        git_commit_current_state "state after src_unpack()"
}

post_src_prepare() {
        git_commit_current_state "state after src_prepare()"
}