From fa8794a5bf41b1a3ca3f7ed838226fd3e32ba503 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 30 Jan 2012 16:04:30 -0500 Subject: Extract compressed source archives. --- (limited to 'src') diff --git a/src/opkbuild b/src/opkbuild index 6cae035..d920da9 100644 --- a/src/opkbuild +++ b/src/opkbuild @@ -21,6 +21,7 @@ . @@LIBDIR@@/opkhelper/controlfields . @@LIBDIR@@/opkhelper/architecture +. @@LIBDIR@@/opkhelper/archive print_usage() { @@ -171,16 +172,53 @@ for binpkgdir in ../*.pkg/; do oh_is_buildable "${binpkg}" if [ ${?} -eq 0 ]; then printf 'opkbuild: Attempting to build package "%s"...\n' "${binpkg}" - # Make installation directory. - # TODO: Maybe this should be an FHS-compliant filesystem hierarchy. - mkdir dest || error "${binpkg}" # Copy or extract software sources to src. if [ -d ../src ]; then + printf 'opkbuild: Copying sources into work area...\n' cp -Rp ../src src || error "${binpkg}" - elif [ -f ../${pkgname}_${pkgver}.tar.gz ]; then - tar -xzf ../${pkgname}_${pkgver}.tar.gz || error "${binpkg}" + else + printf 'opkbuild: Extracting sources into work area...\n' + oh_archive_extract_source + case ${?} in + 1) + printf 'opkbuild: Error: No source archive found\n' >&2 + exit 1 + ;; + 2) + printf 'opkbuild: Error: Multiple source archives found\n' \ + >&2 + exit 1 + ;; + 3) + printf 'opkbuild: Error: %s\n' \ + 'Unsupported archive compression format detected' >&2 + exit 1 + ;; + 4) + printf 'opkbuild: Error: %s\n' \ + 'No directories found in source archive' >&2 + exit 1 + ;; + 5) + printf 'opkbuild: Error: %s\n' \ + 'Multiple top-level directories found in source archive' >&2 + exit 1 + ;; + 6) + printf 'opkbuild: Error: %s\n' \ + 'Failed to extract source archive' >&2 + exit 1 + ;; + 7) + printf 'opkbuild: Error: %s\n' \ + 'Failed to move extracted sources' >&2 + exit 1 + ;; + esac fi - # TODO: Other compression formats, putting things in src/, ... + # Make installation directory. + # TODO: Maybe this should be an FHS-compliant filesystem hierarchy. + mkdir dest || error "${binpkg}" # Apply patches. oh-applypatches # Copy platform config files. -- cgit v0.9.1