summaryrefslogtreecommitdiff
path: root/mk/pkginstall/info-files
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-05-21 23:50:15 +0000
committerjlam <jlam@pkgsrc.org>2006-05-21 23:50:15 +0000
commit143b5f7d148dfa538bb18fb22a3bd3755f6f8c80 (patch)
tree0c523987180f677a1b6f7605da0f810de5df2349 /mk/pkginstall/info-files
parent7bd087ae6e04e7c2d1c5e1ee2dcfedae70f0e0a2 (diff)
downloadpkgsrc-143b5f7d148dfa538bb18fb22a3bd3755f6f8c80.tar.gz
Move mk/install to mk/pkginstall to better reflect the contents (the
pkginstall framework).
Diffstat (limited to 'mk/pkginstall/info-files')
-rw-r--r--mk/pkginstall/info-files136
1 files changed, 136 insertions, 0 deletions
diff --git a/mk/pkginstall/info-files b/mk/pkginstall/info-files
new file mode 100644
index 00000000000..ae68d087e11
--- /dev/null
+++ b/mk/pkginstall/info-files
@@ -0,0 +1,136 @@
+# $NetBSD: info-files,v 1.1 2006/05/21 23:50:15 jlam Exp $
+#
+# Generate an +INFO_FILES script that handles info file registration for
+# the package.
+#
+case "${STAGE},$1" in
+UNPACK,|UNPACK,+INFO_FILES)
+ ${CAT} > ./+INFO_FILES << 'EOF'
+#!@SH@
+#
+# +INFO_FILES - info file registration management script
+#
+# Usage: ./+INFO_FILES ADD|REMOVE [metadatadir]
+#
+# This script supports two actions, ADD and REMOVE, that will add or
+# remove entries for info files from the package associated with
+# <metadatadir> from the info index files (the "dir" file in the
+# same directory as the info files).
+#
+# Lines starting with "# INFO: " are data read by this script that
+# name the info files and directory containing the "dir" index that will
+# that will be updated. If the directory is not specified, then the
+# "dir" index is assumed to be in the same directory as the info file.
+#
+# # INFO: /usr/pkg/info/bar.info /usr/pkg/info
+# # INFO: /usr/pkg/info/baz.info /usr/pkg/info
+#
+# For each INFO entry, if the path is relative, that it is taken to be
+# relative to ${PKG_PREFIX}.
+#
+
+ECHO="@ECHO@"
+GREP="@GREP@"
+INSTALL_INFO="@INSTALL_INFO@"
+MKDIR="@MKDIR@"
+PWD_CMD="@PWD_CMD@"
+RM="@RM@"
+RMDIR="@RMDIR@"
+SED="@SED@"
+SORT="@SORT@"
+TEST="@TEST@"
+
+SELF=$0
+ACTION=$1
+
+PKG_METADATA_DIR="${2-`${PWD_CMD}`}"
+: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
+
+exitcode=0
+case $ACTION in
+ADD)
+ ${SED} -n "/^\# INFO: /{s/^\# INFO: //;p;}" ${SELF} | ${SORT} -u |
+ { while read file infodir; do
+ case $file in
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
+ esac
+
+ if ${TEST} ! -f "$file"; then
+ :
+ else
+ case "$printed_header" in
+ yes) ;;
+ *) printed_header=yes
+ ${ECHO} "==========================================================================="
+ ${ECHO} "Registering info files for ${PKGNAME}:"
+ ${ECHO} ""
+ ;;
+ esac
+
+ ${TEST} -n "$infodir" || infodir="${file%/*}"
+ infoindex="$infodir/dir"
+ nentries="`${GREP} -c '^\*' $infoindex 2>/dev/null`"
+ case "$nentries" in
+ [0-9]*) ${TEST} $nentries -gt 0 || ${RM} $infoindex ;;
+ esac
+ ${ECHO} " $file"
+ ${MKDIR} -p "$infodir"
+ ${INSTALL_INFO} --info-dir="$infodir" --delete $file >/dev/null 2>&1
+ ${INSTALL_INFO} --info-dir="$infodir" $file >/dev/null 2>&1
+ fi
+ done
+ case "$printed_header" in
+ yes) ${ECHO} ""
+ ${ECHO} "==========================================================================="
+ ;;
+ esac; }
+ ;;
+
+REMOVE)
+ ${SED} -n "/^\# INFO: /{s/^\# INFO: //;p;}" ${SELF} | ${SORT} -u |
+ { while read file infodir; do
+ case $file in
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
+ esac
+
+ if ${TEST} ! -f "$file"; then
+ :
+ else
+ case "$printed_header" in
+ yes) ;;
+ *) printed_header=yes
+ ${ECHO} "==========================================================================="
+ ${ECHO} "Unregistering info files for ${PKGNAME}:"
+ ${ECHO} ""
+ ;;
+ esac
+
+ ${TEST} -n "$infodir" || infodir="${file%/*}"
+ infoindex="$infodir/dir"
+ ${ECHO} " $file"
+ ${INSTALL_INFO} --info-dir="$infodir" --delete $file >/dev/null 2>&1
+ nentries="`${GREP} -c '^\*' $infoindex 2>/dev/null`"
+ case "$nentries" in
+ [0-9]*) ${TEST} $nentries -gt 1 || ${RM} $infoindex ;;
+ esac
+ ${RMDIR} -p "$infodir" 2>/dev/null || ${TRUE}
+ fi
+ done
+ case "$printed_header" in
+ yes) ${ECHO} ""
+ ${ECHO} "==========================================================================="
+ ;;
+ esac; }
+ ;;
+esac
+exit $exitcode
+
+EOF
+ ${SED} -n "/^\# INFO: /p" ${SELF} >> ./+INFO_FILES
+ ${CHMOD} +x ./+INFO_FILES
+ ;;
+esac
+