author | Norm Jacobs <Norm.Jacobs@Oracle.COM> |
Mon, 09 May 2011 18:25:46 -0700 | |
changeset 221 | a82f927119a1 |
child 536 | cc30c1136ebb |
permissions | -rw-r--r-- |
221
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
1 |
#!/bin/bash |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
2 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
4 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
8 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
13 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
19 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
21 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
22 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
23 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
24 |
# Copyright (c) 2011, Oracle and/or it's affiliates. All rights reserved. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
25 |
# |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
26 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
27 |
. /lib/svc/share/smf_include.sh |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
28 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
29 |
TEXINFO_DATA_DIR="/var/info" |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
30 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
31 |
function populate_texinfo_directory() { |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
32 |
directory=$(dirname $1) |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
33 |
dir_file=$(readlink -f $1) |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
34 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
35 |
[[ ${dir_file} -ot ${directory} ]] || return |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
36 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
37 |
case "${dir_file}" in |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
38 |
/var/info/*) # Only process if the link resolves inside /var/info. |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
39 |
echo "populating ${dir_file} from ${directory}" |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
40 |
/bin/rm -f ${dir_file}.new |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
41 |
for info_file in $(find ${directory} -type f | \ |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
42 |
egrep -v -e '-[0-9]+$') ; do |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
43 |
/usr/bin/install-info --dir-file=${dir_file}.new \ |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
44 |
--info-file=${info_file} |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
45 |
done |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
46 |
/bin/mv -f ${dir_file}.new ${dir_file} |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
47 |
/bin/ln -s ${1} ${dir_file}.backlink 2>/dev/null |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
48 |
;; |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
49 |
esac |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
50 |
} |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
51 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
52 |
### Begin Here ### |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
53 |
|
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
54 |
case "$1" in |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
55 |
'start'|'refresh') |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
56 |
# refresh texinfo directories |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
57 |
for dir_link in $(pkg search -H -l -o path ':link:path:*/info/dir' | \ |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
58 |
sort -u) ; do |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
59 |
populate_texinfo_directory /${dir_link} |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
60 |
done |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
61 |
# remove any unreferenced directories |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
62 |
for link in $(find ${TEXINFO_DATA_DIR} -type l -name '*.backlink') ; do |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
63 |
path=$(readlink ${link}) |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
64 |
if [[ ! -L ${path} ]] ; then |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
65 |
file=$(expr "${link}" : "\(.*\)\.backlink") |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
66 |
echo -n "removing unreferenced texinfo directory: " |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
67 |
echo "${file} ${link}" |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
68 |
/bin/rm -f ${file} ${link} |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
69 |
fi |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
70 |
done |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
71 |
;; |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
72 |
*) |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
73 |
echo "Usage: $0 (start|refresh)" |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
74 |
exit 1 |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
75 |
;; |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
76 |
esac |
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
77 |
exit $SMF_EXIT_OK |