From 8a34d4ef11a893ee51fde2c9b2784e414e68710a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 21 Jan 2012 14:47:08 -0500 Subject: Add error handling to opkbuild. --- (limited to 'src') diff --git a/src/opkbuild b/src/opkbuild index ec15c85..f180ad8 100644 --- a/src/opkbuild +++ b/src/opkbuild @@ -26,6 +26,12 @@ print_usage() printf 'Usage: %s\n' "$1" } +error() +{ + printf 'opkbuild: [%s] Error\n' "${1}" + exit 1 +} + # Sanity checks. printf 'opkbuild: Checking for sanity...\n' if [ ! -f format -o ! -f build -o ! -f control ]; then @@ -49,39 +55,41 @@ version=$(oh_get_field Version) # Build *-src package. printf 'opkbuild: Installing files for package "%s"...\n' "${srcpkg}-src" -mkdir -p ${srcpkg}-src.data/usr/src/${srcpkg}_${version} +mkdir -p ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || + error "${srcpkg}-src" for file in ../*; do case ${file} in ../tmp) ;; ../*) - cp -R ${file} ${srcpkg}-src.data/usr/src/${srcpkg}_${version} + cp -R ${file} ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || + error "${srcpkg}-src" ;; esac done -oh-gencontrol -s -oh-buildopk ${srcpkg}-src +oh-gencontrol -s || error "${srcpkg}-src" +oh-buildopk ${srcpkg}-src || error "${srcpkg}-src" rm -Rf ${srcpkg}-src.data printf 'opkbuild: Package "%s" complete!\n\n' "${srcpkg}-src" # Build other binary packages. for binpkgdir in ../*.pkg/; do + binpkg=${binpkgdir#'../'} + binpkg=${binpkg%'.pkg/'} # TODO: Check architecture. if true; then # Make installation directory. # TODO: Maybe this should be an FHS-compliant filesystem hierarchy. - mkdir dest + mkdir dest || error "${binpkg}" # Copy or extract software sources to src. if [ -d ../src ]; then - cp -Rp ../src src + cp -Rp ../src src || error "${binpkg}" elif [ -f ../${pkgname}_${pkgver}.tar.gz ]; then - tar -xzf ../${pkgname}_${pkgver}.tar.gz + tar -xzf ../${pkgname}_${pkgver}.tar.gz || error "${binpkg}" fi # TODO: Other compression formats, putting things in src/, ... - binpkg=${binpkgdir#'../'} - binpkg=${binpkg%'.pkg/'} # Build the package. - ../build ${binpkg} + ../build ${binpkg} || error "${binpkg}" printf 'opkbuild: Package "%s" complete!\n\n' "${binpkg}" # Clean up everything except the build stamps. for file in *; do @@ -89,7 +97,7 @@ for binpkgdir in ../*.pkg/; do *.buildstamp) ;; *) - rm -Rf ${file} + rm -Rf ${file} || error "${binpkg}" ;; esac done -- cgit v0.9.1