5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
28 # Copyright 2010, Richard Lowe
31 # Easy setup script for populating a user's ~/.hgrc
32 # This currently does the following:
33 # * Load the cadmium extension
34 # * Populate the author/email fields to be correct
35 # * Alias canonical repositories like onnv-gate
36 # * Configures mercurial to use appropriate merge tools
38 # See hgrc(5) for more information
46 "usage: $prog [-f] [-c cdm_path] [-m merge_path] [-n name] [-e email] [-p proxy] [-s style_path]
47 -f : force overwriting $HGRC
48 -c cdm_path : override Cadmium path
49 -m merge_path : override path to merge tool
50 -n name : override name (for ui.username)
51 -e email : override email (for email.from)
52 -p proxy : enable use of web proxy with specified proxy
53 -s style_path : override path to style file
55 if -n isn't provided, the entry from /etc/passwd is used
57 proxy should be in the form of hostname:port
62 while getopts c
:e
:fm
:n
:p
:s
: opt
; do
67 m
) merge_path
=$OPTARG;;
70 s
) style_path
=$OPTARG;;
75 if [ -f $HGRC -a "$force" -eq 0 ]; then
76 echo "Error: You have an existing .hgrc in $HGRC"
77 echo "Please move it aside."
81 AWK
="/usr/xpg4/bin/awk"
83 LDAPCLIENT
="/usr/bin/ldapsearch"
85 login
=$
(/usr
/bin
/id
-un)
88 # Try and determine where SUNWonbld is installed. In order of
89 # preference, look in:
91 # 1. $(whence $0), on the assumption that you want the version
92 # of SUNWonbld that best matches the hgsetup script you invoked
94 # 2. /opt/onbld, because local is generally better
96 # 3. /ws/onnv-tools/onbld, it's nfs and it might be slow, but it
97 # should resolve from most places on-SWAN
99 paths
="$(dirname $(dirname $(whence $0))) /opt/onbld /ws/onnv-tools/onbld"
100 cdmbin
="lib/python/onbld/hgext/cdm.py"
101 stylefile
="etc/hgstyle"
103 for dir
in $paths; do
104 if [[ -f "$dir/$cdmbin" && -z "$cdm_path" ]]; then
105 cdm_path
="$dir/$cdmbin"
108 if [[ -f "$dir/$stylefile" && -z "$style_path" ]]; then
109 style_path
="$dir/$stylefile"
112 if [[ -n "$cdm_path" && -n "$style_path" ]]; then
117 if [[ -n $proxy ]]; then
118 proxyConfig
="[http_proxy]
123 if [[ -z $email ]]; then
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`
128 email
="$my_id@$my_fqhn"
129 echo "No e-mail address provided, defaulting to $email"
132 if [[ -z "$name" ]]; then
133 name
=${name:=$(getent passwd $login | awk -F: '{print $5}')}
135 username="$name <$email>"
137 echo "Configured the following:"
138 if [[ -n $proxy ]]; then
139 echo " proxy: $proxy"
141 echo " email: $email"
142 echo " username: $name"
143 echo " style: $style_path"
144 echo " cadmium: $cdm_path"
146 if [[ -z "$cdm_path" ]]; then
147 echo "Warning: you will need to edit your .hgrc file\n" \
148 "to specify a path for cadmium."
151 if [[ -n $merge_path ]]; then
152 echo " merge: $merge_path"
156 $proxyConfig[extensions]
163 onnv-gate=ssh://anon@hg.opensolaris.org//hg/onnv/onnv-gate
164 illumos-gate=ssh://anonhg@hg.illumos.org/illumos-gate
168 filemerge.args=-a \$base \$local \$other \$output
170 filemerge.premerge=False
185 if [[ -n $merge_path ]]; then
186 echo "merge=$merge_path" >> $HGRC
189 echo "Please check $HGRC and verify everything looks correct"