From 644a7722179c297289d2a1195207d52f1ffc8dff Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 09 Oct 2012 18:16:44 -0400 Subject: Rewrite src/oh-installfiles.sh. --- (limited to 'src/oh-installfiles.sh') diff --git a/src/oh-installfiles.sh b/src/oh-installfiles.sh index ad8a361..45b2e21 100644 --- a/src/oh-installfiles.sh +++ b/src/oh-installfiles.sh @@ -1,4 +1,4 @@ -#!@@SHELL@@ +#!@@SH@@ # # opkhelper # src/oh-installfiles @@ -19,51 +19,39 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -. @@LIBDIR@@/opkhelper/messages +. '@@LIBOPKBUILD_1@@/load.sm' -print_usage() -{ - printf 'Usage: %s pkgname...\n' "${1}" -} +ob_use locale +ob_use output +ob_use package -if [ ${#} -eq 0 ]; then - print_usage ${0} >&2 - exit 1 -fi - -# Set the IFS to just the linebreak character to make the 'read' utility output -# entire lines. -OLDIFS="${IFS}" -IFS=' +files_ifs=' ' -# Iterate over packages. -while [ ${#} -gt 0 ]; do - oh_info 'Installing files for package "%s"...' "${1}" +main() +{ + ob_set_text_domain 'opkhelper' - mkdir ${1}.data || exit 1 - chmod 755 ${1}.data || exit 1 + ob_init_package '..' + ob_parse_package_metadata -c '.opkbuild.cache' - # Loop over lines in the 'install' file. - while read -r pattern; do - for file in dest/${pattern}; do - # Ensure that the full directory path of the pattern exists in the - # package staging area. - dir=$(dirname ${file#dest/}) - mkdir -p ${1}.data/${dir} || exit 1 - # Move any matching files from the installation destination to the - # package staging area. - mv ${file} ${1}.data/${dir} || exit 1 - done - done < ../${1}.pkg/install - shift -done + for pkg in $(ob_get_binary_packages -a "${OPK_HOST_ARCH}"); do + [ -r "../${pkg}.pkg/files" ] || continue -# TODO: This should be part of some kind of warnings/lint framework/script and -# allow the user to drop to a debug shell before cleanup. -if [ "$(find dest -type f | wc -l)" -gt 0 ]; then - oh_warn 'Files remain in installation directory' -fi + ob_info 'installing_files' "${pkg}" + + mkdir -p "${pkg}.data" + chmod 755 "${pkg}.data" + + while IFS="${files_ifs}" read -r pattern; do + find 'dest' -path "${pattern}" | \ + while IFS="${files_ifs}" read -r file; do + file="${file#dest}" + mkdir -p "${pkg}.data/${file%/*}" + ln "${PWD}/dest/${file}" "${pkg}.data/${file}" + done + done <"../${pkg}.pkg/files" + done +} -# Reset the IFS. -IFS="${OLDIFS}" +main "${@}" -- cgit v0.9.1