diff options
author | P. J. McDermott <pjm@nac.net> | 2012-01-21 14:47:08 (EST) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-01-21 14:47:08 (EST) |
commit | 8a34d4ef11a893ee51fde2c9b2784e414e68710a (patch) | |
tree | ce2162eedc4cf8020472c9d2d8cef1943e90d831 /src | |
parent | deb2032de4e20b1119ac81681b3661528c31d47a (diff) |
Add error handling to opkbuild.
Diffstat (limited to 'src')
-rw-r--r-- | src/opkbuild | 30 |
1 files changed, 19 insertions, 11 deletions
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 |