From 23d9c48a8d8a400450191b2604c9d9b29016af6a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 22 Sep 2013 18:12:32 -0400 Subject: createworkdir: clean up Use set -euE and trap for simpler error handling. Use libregit to fetch abslibre --- src/abslibre-tools/createworkdir | 49 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir index 59cb0f3..c7b2564 100755 --- a/src/abslibre-tools/createworkdir +++ b/src/abslibre-tools/createworkdir @@ -1,8 +1,10 @@ #!/bin/bash +set -euE # CreateWorkDir # Creates a dir structure for working with Parabola packages # Copyright 2010 Nicolás Reynolds +# Copyright 2013 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -24,41 +26,26 @@ . libremessages . $(librelib conf.sh) load_files libretools -check_vars libretools WORKDIR REPOS ABSLIBREGIT || exit 1 +check_vars libretools WORKDIR REPOS ABSLIBREGIT -[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR +trap 'error "Aborting..."' EXIT - msg "Creating WORKDIR on %s" "${WORKDIR}" - mkdir -p ${WORKDIR} ||{ - error "Could not create %s" "${WORKDIR}"; exit 1 - } +msg "Creating WORKDIR at %s..." "$WORKDIR" +mkdir -p "$WORKDIR" -} +msg "Creating staging directory in WORKDIR..." +mkdir -p "$WORKDIR/staging" -for _repo in "${REPOS[@]}"; do # Create the staging dirs +cmd=(libregit "$ABSLIBREGIT" master "$WORKDIR/abslibre") +if ! "${cmd[@]}"; then + error "Could not clone ABSLibre" + print "Try running this command:" + echo + print '%s' "${cmd[*]}" + exit 1 +fi - [[ ! -d ${WORKDIR}/staging/${_repo} ]] && { - mkdir -p ${WORKDIR}/staging/${_repo} || { - error "Can't create %s" "${WORKDIR}/staging/${_repo}" - exit 1 - } - } - -done - -[[ ! -d ${WORKDIR}/abslibre/.git ]] && { - msg "Cloning into ABSLibre" - CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre" - ${CMD} || { - error "Could not clone ABSLibre" - plain "Try running this command:" - echo - plain "${CMD}" - exit 1 - } -} - -msg "Finished, your packaging dir tree looks like this now:" +msg "Finished, your packaging directory tree looks like this now:" ls --color=always ${WORKDIR}/*/* -exit 0 +trap -- EXIT -- cgit v1.2.2