summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-09 18:16:44 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-09 18:16:44 (EDT)
commit644a7722179c297289d2a1195207d52f1ffc8dff (patch)
treedfb6a5d9fa5484939d64d19e4fdf25953902fbf6
parent00b3745220a6f689c6af834020ce315b733177d5 (diff)
Rewrite src/oh-installfiles.sh.
-rw-r--r--src/oh-installfiles.sh70
1 files changed, 29 insertions, 41 deletions
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 <http://www.gnu.org/licenses/>.
-. @@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 "${@}"