summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-20 00:47:41 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-20 00:47:41 -0500
commita6ce111ab2fd71e0c13f5e165addeb18a4125f1e (patch)
tree08f04ce0748d6719189fe3db40a3b9b0277f306a /src
parent63362d52d3943f40fb96898a2b4e87e17f0adcf4 (diff)
librefetch: improve error handling
Diffstat (limited to 'src')
-rwxr-xr-xsrc/librefetch/librefetch19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index c723721..87a55cd 100755
--- a/src/librefetch/librefetch
+++ b/src/librefetch/librefetch
@@ -18,12 +18,12 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. $(librelib conf.sh)
-. libremessages
+. $(librelib conf)
+. $(librelib messages)
+setup_traps
declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)"
-cleanup() { rm -rf -- "$tempdir"; }
-trap cleanup EXIT
+trap "rm -rf -- $(printf '%q' "$tempdir")" EXIT
cmd=${0##*/}
usage() {
@@ -91,10 +91,15 @@ main() {
local BUILDFILEDIR="${BUILDFILE%/*}"
if [[ -f "${BUILDFILEDIR}/SRCBUILD" ]]; then
BUILDFILE="${BUILDFILEDIR}/SRCBUILD"
- srcbuild="$(modified_srcbuild "$BUILDFILE")"
- else
- srcbuild="$(modified_pkgbuild "$BUILDFILE")"
fi
+ if [[ ! -f "$BUILDFILE" ]]; then
+ error "%s does not exist." "$BUILDFILE"
+ exit 1
+ fi
+ case "$BUILDFILE" in
+ */SRCBUILD) srcbuild="$(modified_srcbuild "$BUILDFILE")";;
+ *) srcbuild="$(modified_pkgbuild "$BUILDFILE")";;
+ esac
makepkg="$(modified_makepkg "$(which makepkg)")"
# Mode: checksums ######################################################