app-portage/eix: Major ebuild cleanup
authorMichał Górny <mgorny@gentoo.org>
Tue, 1 Nov 2016 14:48:07 +0000 (15:48 +0100)
committerMichał Górny <mgorny@gentoo.org>
Sun, 6 Nov 2016 15:34:32 +0000 (16:34 +0100)
Clean up the ebuild: wrap and sort values, shorten description,
improve readability, use bash syntax, add a lot of missing ||die,
simplify awkward logic and kill double negations.

app-portage/eix/eix-0.32.1.ebuild

index 3a9d4bf5280145f8214ac6d884889df329a54424..c6effcda1372e772fc1ffee46ca8290da165ff50 100644 (file)
@@ -7,17 +7,18 @@ EAPI=6
 PLOCALES="de ru"
 inherit bash-completion-r1 l10n systemd
 
-DESCRIPTION="Search and query ebuilds, portage incl. local settings, ext. overlays and more"
+DESCRIPTION="Search and query ebuilds"
 HOMEPAGE="https://github.com/vaeth/eix/"
 SRC_URI="https://github.com/vaeth/eix/releases/download/v${PV}/${P}.tar.xz"
 
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="debug +dep doc nls optimization +required-use security strong-optimization strong-security sqlite swap-remote tools"
+IUSE="debug +dep doc nls optimization +required-use security strong-optimization
+       strong-security sqlite swap-remote tools"
 
-BOTHDEPEND="sqlite? ( >=dev-db/sqlite-3 )
-       nls? ( virtual/libintl )"
+BOTHDEPEND="nls? ( virtual/libintl )
+       sqlite? ( >=dev-db/sqlite-3:= )"
 RDEPEND="${BOTHDEPEND}
        app-shells/push
        app-shells/quoter"
@@ -26,31 +27,39 @@ DEPEND="${BOTHDEPEND}
        nls? ( sys-devel/gettext )"
 
 pkg_setup() {
-       case " ${REPLACING_VERSIONS}" in
-       *\ 0.[0-9].*|*\ 0.1[0-9].*|*\ 0.2[0-4].*|*\ 0.25.0*)
-               local eixcache="${EROOT}/var/cache/${PN}"
-               test -f "${eixcache}" && rm -f -- "${eixcache}";;
-       esac
+       # remove stale cache file to prevent collisions
+       local old_cache=${EROOT%/}/var/cache/${PN}
+       if [[ -f ${old_cache} ]]; then
+               rm "${old_cache}" || die
+       fi
 }
 
 src_prepare() {
-       sed -i -e "s'/'${EPREFIX}/'" -- "${S}"/tmpfiles.d/eix.conf || die
-       eapply_user
+       default
+       sed -i -e "s:/:${EPREFIX}/:" tmpfiles.d/eix.conf || die
 }
 
 src_configure() {
-       econf $(use_with sqlite) $(use_with doc extra-doc) \
-               $(use_enable nls) $(use_enable tools separate-tools) \
-               $(use_enable security) $(use_enable optimization) \
-               $(use_enable strong-security) \
-               $(use_enable strong-optimization) $(use_enable debug debugging) \
-               $(use_enable swap-remote) \
-               $(use_with prefix always-accept-keywords) \
-               $(use_with dep dep-default) \
-               $(use_with required-use required-use-default) \
-               --with-zsh-completion \
-               --with-portage-rootpath="${ROOTPATH}" \
+       local myconf=(
+               $(use_enable debug debugging)
+               $(use_enable nls)
+               $(use_enable optimization)
+               $(use_enable security)
+               $(use_enable strong-optimization)
+               $(use_enable strong-security)
+               $(use_enable swap-remote)
+               $(use_enable tools separate-tools)
+               $(use_with dep dep-default)
+               $(use_with doc extra-doc)
+               $(use_with prefix always-accept-keywords)
+               $(use_with required-use required-use-default)
+               $(use_with sqlite)
+               --with-zsh-completion
+               --with-portage-rootpath="${ROOTPATH}"
                --with-eprefix-default="${EPREFIX}"
+       )
+
+       econf "${myconf[@]}"
 }
 
 src_install() {
@@ -60,14 +69,22 @@ src_install() {
 }
 
 pkg_postinst() {
-       test -d "${EROOT}var/cache/${PN}" || {
-               mkdir "${EROOT}var/cache/${PN}"
-               use prefix || chown portage:portage "${EROOT}var/cache/${PN}"
-       }
-       local obs="${EROOT}var/cache/eix.previous"
-       ! test -f "${obs}" || ewarn "Found obsolete ${obs}, please remove it"
+       local cache=${EROOT%/}/var/cache/${PN}
+       if [[ ! -d ${cache} ]]; then
+               mkdir "${cache}" || die
+               if ! use prefix; then
+                       chown portage:portage "${cache}" || die
+               fi
+       fi
+
+       local obs=${EROOT%/}/var/cache/eix.previous
+       if [[ -f ${obs} ]]; then
+               ewarn "Found obsolete ${obs}, please remove it"
+       fi
 }
 
 pkg_postrm() {
-       [ -n "${REPLACED_BY_VERSION}" ] || rm -rf -- "${EROOT}var/cache/${PN}"
+       if [[ ! -n ${REPLACED_BY_VERSION} ]]; then
+               rm -rf "${EROOT%/}/var/cache/${PN}" || die
+       fi
 }