From e5539fc65872aa98d510a03d1e20c207ca6ed058 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 21 Nov 2010 10:07:59 +0100 Subject: sourceballs: fix error handling --- misc-scripts/make-sourceball | 29 ++++++++++++++++++++++++----- misc-scripts/sourceballs-cleanup | 12 ++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index da51c93..bdf5f59 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -25,8 +25,20 @@ create_srcpackage() { if [ -d "$1" ]; then pushd "$1" >/dev/null pkgver=$(. PKGBUILD; echo ${pkgver}) + if [ $? -ne 0 ]; then + error "Failed to read pkgver from $1" + return 1 + fi pkgrel=$(. PKGBUILD; echo ${pkgrel}) + if [ $? -ne 0 ]; then + error "Failed to read pkgrel from $1" + return 1 + fi license=($(. PKGBUILD; echo ${license[@]})) + if [ $? -ne 0 ]; then + error "Failed to read license from $1" + return 1 + fi if ! [ $FORCE == 1 ] && ! chk_license ${license[@]} ; then # Removed so as not to clutter failed.txt #warning "$packagename license (${license[@]}) does not require source tarballs" @@ -35,9 +47,11 @@ create_srcpackage() { msg "Creating source tarball for $packagename-$pkgver-$pkgrel" fi - local logfile="${LOGDIR}/sourceballs/$packagename.gz" - if ! /usr/bin/makepkg --allsource --ignorearch 2>&1 | gzip >"$logfile"; then - die "Failed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" + local logfile="${LOGDIR}/sourceballs/$packagename" + if ! /usr/bin/makepkg --allsource --ignorearch >"$logfile" 2>&1; then + error "Failed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" + popd >/dev/null + return 1 fi /bin/rm -f "$logfile" @@ -55,10 +69,15 @@ set_umask [ ! -d "${LOGDIR}/sourceballs" ] && mkdir -p "${LOGDIR}/sourceballs" cd "$WORKDIR" +failed=0 + if /usr/bin/svn export -q "$SVNREPO/$packagename" $packagename; then - create_srcpackage "$packagename/repos/$reponame-$arch" + create_srcpackage "$packagename/repos/$reponame-$arch" || failed=1 else - die "Package '$packagename' does not exist in repo '$reponame-$arch'" + error "Package '$packagename' does not exist in repo '$reponame-$arch'" + failed=1 fi script_unlock + +exit $failed \ No newline at end of file diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index 788cc98..fc5f649 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -52,13 +52,17 @@ cd "$WORKDIR" echo "Orphaned sourceballs:" > "$logfile" for sourceball in "${FTP_BASE}/${SRCPOOL}"/*$SRCEXT; do + [ -f "$sourceball" ] || continue packagename=$(basename $sourceball) packagename=${packagename%-*-*$SRCEXT} - if ! /usr/bin/svn export -q --force "$SVNREPO/$packagename" "$packagename" >/dev/null 2>&1 \ - && ! /usr/bin/svn export -q --force "$SVNREPOCOMMUNITY/$packagename" "$packagename" >/dev/null 2>&1 ; then - echo "$packagename : no longer in svn. Removing sourceball." >> "$logfile" - mv $sourceball $SOURCE_CLEANUP_DESTDIR + if ! /usr/bin/svn export -q --force "$SVNREPO/$packagename" "$packagename" >/dev/null 2>&1; then + if [ $? -ne 1 ]; then + echo "$packagename : svn died during export. Skipping sourceball." >> "$logfile" + else + echo "$packagename : no longer in svn. Removing sourceball." >> "$logfile" + mv $sourceball $SOURCE_CLEANUP_DESTDIR + fi elif [ -z "$(ls -A "$packagename/repos")" ]; then echo "$packagename : no longer in repos but trunk is still in svn. Removing sourceball." >> "$logfile" mv $sourceball $SOURCE_CLEANUP_DESTDIR -- cgit v1.2.3-24-g4f1b