Print this page
5166 sendmail package should be replaceable
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/hgsetup.sh
+++ new/usr/src/tools/scripts/hgsetup.sh
1 1 #! /usr/bin/ksh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 # Copyright 2010, Richard Lowe
29 29
30 30 #
31 31 # Easy setup script for populating a user's ~/.hgrc
32 32 # This currently does the following:
33 33 # * Load the cadmium extension
34 34 # * Populate the author/email fields to be correct
35 35 # * Alias canonical repositories like onnv-gate
36 36 # * Configures mercurial to use appropriate merge tools
37 37 #
38 38 # See hgrc(5) for more information
39 39 #
40 40
41 41 HGRC=$HOME/.hgrc
42 42
43 43 usage() {
44 44 prog=$(basename "$0")
45 45 echo \
46 46 "usage: $prog [-f] [-c cdm_path] [-m merge_path] [-n name] [-e email] [-p proxy] [-s style_path]
47 47 -f : force overwriting $HGRC
48 48 -c cdm_path : override Cadmium path
49 49 -m merge_path : override path to merge tool
50 50 -n name : override name (for ui.username)
51 51 -e email : override email (for email.from)
52 52 -p proxy : enable use of web proxy with specified proxy
53 53 -s style_path : override path to style file
54 54
55 55 if -n isn't provided, the entry from /etc/passwd is used
56 56
57 57 proxy should be in the form of hostname:port
58 58 "
59 59 exit 1
60 60 }
61 61
62 62 while getopts c:e:fm:n:p:s: opt; do
63 63 case "$opt" in
64 64 c) cdm_path=$OPTARG;;
65 65 e) email=$OPTARG;;
66 66 f) force=1;;
67 67 m) merge_path=$OPTARG;;
68 68 n) name=$OPTARG;;
69 69 p) proxy=$OPTARG;;
70 70 s) style_path=$OPTARG;;
71 71 *) usage;;
72 72 esac
73 73 done
74 74
75 75 if [ -f $HGRC -a "$force" -eq 0 ]; then
76 76 echo "Error: You have an existing .hgrc in $HGRC"
77 77 echo "Please move it aside."
78 78 exit 1
79 79 fi
80 80
81 81 AWK="/usr/xpg4/bin/awk"
82 82 SED="/usr/bin/sed"
83 83 LDAPCLIENT="/usr/bin/ldapsearch"
84 84
85 85 login=$(/usr/bin/id -un)
86 86
87 87 #
88 88 # Try and determine where SUNWonbld is installed. In order of
89 89 # preference, look in:
90 90 #
91 91 # 1. $(whence $0), on the assumption that you want the version
92 92 # of SUNWonbld that best matches the hgsetup script you invoked
93 93 #
94 94 # 2. /opt/onbld, because local is generally better
95 95 #
96 96 # 3. /ws/onnv-tools/onbld, it's nfs and it might be slow, but it
97 97 # should resolve from most places on-SWAN
98 98 #
99 99 paths="$(dirname $(dirname $(whence $0))) /opt/onbld /ws/onnv-tools/onbld"
100 100 cdmbin="lib/python/onbld/hgext/cdm.py"
101 101 stylefile="etc/hgstyle"
102 102
103 103 for dir in $paths; do
104 104 if [[ -f "$dir/$cdmbin" && -z "$cdm_path" ]]; then
105 105 cdm_path="$dir/$cdmbin"
106 106 fi
107 107
108 108 if [[ -f "$dir/$stylefile" && -z "$style_path" ]]; then
109 109 style_path="$dir/$stylefile"
110 110 fi
111 111
112 112 if [[ -n "$cdm_path" && -n "$style_path" ]]; then
113 113 break
114 114 fi
↓ open down ↓ |
114 lines elided |
↑ open up ↑ |
115 115 done
116 116
117 117 if [[ -n $proxy ]]; then
118 118 proxyConfig="[http_proxy]
119 119 host=$proxy
120 120 "
121 121 fi
122 122
123 123 if [[ -z $email ]]; then
124 124 my_id=$(id -un)
125 - my_checkhostname=$(check-hostname)
126 - my_fqhn=${my_checkhostname##* }
125 + my_hostname=$(hostname)
126 + possible_fqhns=$(getent hosts $my_hostname | cut -f 2-)
127 + my_fqhn=`for i in $possible_fqhns; do case $i in *.*) echo $i; break;; esac; done`
127 128 email="$my_id@$my_fqhn"
128 129 echo "No e-mail address provided, defaulting to $email"
129 130 fi
130 131
131 132 if [[ -z "$name" ]]; then
132 133 name=${name:=$(getent passwd $login | awk -F: '{print $5}')}
133 134 fi
134 135 username="$name <$email>"
135 136
136 137 echo "Configured the following:"
137 138 if [[ -n $proxy ]]; then
138 139 echo " proxy: $proxy"
139 140 fi
140 141 echo " email: $email"
141 142 echo " username: $name"
142 143 echo " style: $style_path"
143 144 echo " cadmium: $cdm_path"
144 145
145 146 if [[ -z "$cdm_path" ]]; then
146 147 echo "Warning: you will need to edit your .hgrc file\n" \
147 148 "to specify a path for cadmium."
148 149 fi
149 150
150 151 if [[ -n $merge_path ]]; then
151 152 echo " merge: $merge_path"
152 153 fi
153 154
154 155 cat <<EOF >$HGRC
155 156 $proxyConfig[extensions]
156 157 hgext.cdm=$cdm_path
157 158
158 159 [email]
159 160 from=$email
160 161
161 162 [paths]
162 163 onnv-gate=ssh://anon@hg.opensolaris.org//hg/onnv/onnv-gate
163 164 illumos-gate=ssh://anonhg@hg.illumos.org/illumos-gate
164 165
165 166 [merge-tools]
166 167 filemerge.gui=True
167 168 filemerge.args=-a \$base \$local \$other \$output
168 169 filemerge.priority=1
169 170 filemerge.premerge=False
170 171
171 172 meld.gui=True
172 173 meld.priority=0
173 174 meld.premerge=False
174 175
175 176 gpyfm.gui=True
176 177 gpyfm.priority=0
177 178 gpyfm.premerge=False
178 179
179 180 [ui]
180 181 username=$username
181 182 style=$style_path
182 183 EOF
183 184
184 185 if [[ -n $merge_path ]]; then
185 186 echo "merge=$merge_path" >> $HGRC
186 187 fi
187 188
188 189 echo "Please check $HGRC and verify everything looks correct"
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX