font.eclass: Add error handling where applicable
authorAndreas Sturmlechner <asturm@gentoo.org>
Mon, 7 Oct 2019 06:27:31 +0000 (08:27 +0200)
committerAndreas Sturmlechner <asturm@gentoo.org>
Wed, 16 Oct 2019 08:44:26 +0000 (10:44 +0200)
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
eclass/font.eclass

index 18dcb3f14b41c8fb4f56892cd81c2ce3c07d5643..f77f62291df825c30bacd82a6e608f9f54de7b76 100644 (file)
@@ -68,16 +68,16 @@ font_xfont_config() {
        local dir_name
        if in_iuse X && use X ; then
                dir_name="${1:-${FONT_PN}}"
-               ebegin "Creating fonts.scale & fonts.dir in ${dir_name##*/}"
-               rm -f "${ED%/}/${FONTDIR}/${1//${S}/}"/{fonts.{dir,scale},encodings.dir}
-               mkfontscale "${ED%/}/${FONTDIR}/${1//${S}/}"
+               rm -f "${ED%/}/${FONTDIR}/${1//${S}/}"/{fonts.{dir,scale},encodings.dir} \
+                       || die "failed to prepare ${FONTDIR}/${1//${S}/}"
+               einfo "Creating fonts.scale & fonts.dir in ${dir_name##*/}"
+               mkfontscale "${ED%/}/${FONTDIR}/${1//${S}/}" || eerror "failed to create fonts.scale"
                mkfontdir \
                        -e ${EPREFIX}/usr/share/fonts/encodings \
                        -e ${EPREFIX}/usr/share/fonts/encodings/large \
-                       "${ED%/}/${FONTDIR}/${1//${S}/}"
-               eend $?
-               if [[ -e fonts.alias ]] ; then
-                       doins fonts.alias
+                       "${ED%/}/${FONTDIR}/${1//${S}/}" || eerror "failed to create fonts.dir"
+               if [[ -e fonts.alias ]]; then
+                       doins fonts.alias || die "failed to install fonts.alias" # TODO old EAPI cleanup
                fi
        fi
 }
@@ -90,7 +90,9 @@ font_fontconfig() {
        if [[ -n ${FONT_CONF[@]} ]]; then
                insinto /etc/fonts/conf.avail/
                for conffile in "${FONT_CONF[@]}"; do
-                       [[ -e  ${conffile} ]] && doins ${conffile}
+                       if [[ -e  ${conffile} ]]; then
+                               doins ${conffile} || die "failed to install conf file" # TODO old EAPI cleanup
+                       fi
                done
        fi
 }
@@ -132,11 +134,12 @@ font_cleanup_dirs() {
                        # media-fonts/font-alias. any other fonts.alias files will have
                        # already been unmerged with their packages.
                        for g in ${genfiles}; do
-                               [[ ${g} != fonts.alias && ( -e ${d}/${g} || -L ${d}/${g} ) ]] \
-                                       && rm "${d}"/${g}
+                               if [[ ${g} != fonts.alias && ( -e ${d}/${g} || -L ${d}/${g} ) ]] ; then
+                                       rm "${d}"/${g} || eerror "failed to remove ${d}/${g}"
+                               fi
                        done
                        # if there's nothing left remove the directory
-                       find "${d}" -maxdepth 0 -type d -empty -exec rmdir '{}' \;
+                       find "${d}" -maxdepth 0 -type d -empty -delete || eerror "failed to purge ${d}"
                fi
        done
        eend 0
@@ -161,7 +164,9 @@ font_pkg_setup() {
 
        # make sure we get no collisions
        # setup is not the nicest place, but preinst doesn't cut it
-       [[ -e "${EROOT%/}/${FONTDIR}/fonts.cache-1" ]] && rm -f "${EROOT%/}/${FONTDIR}/fonts.cache-1"
+       if [[ -e "${EROOT%/}/${FONTDIR}/fonts.cache-1" ]] ; then
+               rm "${EROOT%/}/${FONTDIR}/fonts.cache-1" || die "failed to remove fonts.cache-1"
+       fi
 }
 
 # @FUNCTION: font_src_install
@@ -178,7 +183,7 @@ font_src_install() {
                        pushd "${dir}" > /dev/null
                        insinto "${FONTDIR}/${dir//${S}/}"
                        for suffix in ${FONT_SUFFIX}; do
-                               doins *.${suffix}
+                               doins *.${suffix} || die "font installation failed" # TODO old EAPI cleanup
                        done
                        font_xfont_config "${dir}"
                        popd > /dev/null
@@ -187,7 +192,7 @@ font_src_install() {
                pushd "${FONT_S}" > /dev/null
                insinto "${FONTDIR}"
                for suffix in ${FONT_SUFFIX}; do
-                       doins *.${suffix}
+                       doins *.${suffix} || die "font installation failed" # TODO old EAPI cleanup
                done
                font_xfont_config
                popd > /dev/null
@@ -195,7 +200,7 @@ font_src_install() {
 
        font_fontconfig
 
-       [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; }
+       [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; } # TODO old EAPI cleanup
 
        # install common docs
        for commondoc in COPYRIGHT README{,.md,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do