~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to build/buildinfo.sh

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Licensed to the Apache Software Foundation (ASF) under one or more
 
4
# contributor license agreements.  See the NOTICE file distributed with
 
5
# this work for additional information regarding copyright ownership.
 
6
# The ASF licenses this file to You under the Apache License, Version 2.0
 
7
# (the "License"); you may not use this file except in compliance with
 
8
# the License.  You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# Unless required by applicable law or agreed to in writing, software
 
13
# distributed under the License is distributed on an "AS IS" BASIS,
 
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
# See the License for the specific language governing permissions and
 
16
# limitations under the License.
 
17
#
 
18
#
 
19
# buildinfo.sh -- Determine Build Information
 
20
# Initially written by Ralf S. Engelschall <rse@apache.org>
 
21
# for the Apache's Autoconf-style Interface (APACI) 
 
22
 
 
23
#
 
24
#   argument line handling
 
25
#
 
26
error=no
 
27
if [ $# -ne 1 -a $# -ne 2 ]; then
 
28
    error=yes
 
29
fi
 
30
if [ $# -eq 2 -a "x$1" != "x-n" ]; then
 
31
    error=yes
 
32
fi
 
33
if [ "x$error" = "xyes" ]; then
 
34
    echo "$0:Error: invalid argument line"
 
35
    echo "$0:Usage: $0 [-n] <format-string>"
 
36
    echo "Where <format-string> can contain:"
 
37
    echo "   %u ...... substituted by determined username    (foo)"
 
38
    echo "   %h ...... substituted by determined hostname    (bar)"
 
39
    echo "   %d ...... substituted by determined domainname  (.com)"
 
40
    echo "   %D ...... substituted by determined day         (DD)"
 
41
    echo "   %M ...... substituted by determined month       (MM)"
 
42
    echo "   %Y ...... substituted by determined year        (YYYYY)"
 
43
    echo "   %m ...... substituted by determined monthname   (Jan)"
 
44
    exit 1
 
45
fi
 
46
if [ $# -eq 2 ]; then
 
47
    newline=no
 
48
    format_string="$2"
 
49
else
 
50
    newline=yes
 
51
    format_string="$1"
 
52
fi
 
53
 
 
54
#
 
55
#   initialization
 
56
#
 
57
username=''
 
58
hostname=''
 
59
domainname=''
 
60
time_day=''
 
61
time_month=''
 
62
time_year=''
 
63
time_monthname=''
 
64
 
 
65
#
 
66
#   determine username
 
67
#
 
68
username="$LOGNAME"
 
69
if [ "x$username" = "x" ]; then
 
70
    username="$USER"
 
71
    if [ "x$username" = "x" ]; then
 
72
        username="`(whoami) 2>/dev/null |\
 
73
                   awk '{ printf("%s", $1); }'`"
 
74
        if [ "x$username" = "x" ]; then
 
75
            username="`(who am i) 2>/dev/null |\
 
76
                       awk '{ printf("%s", $1); }'`"
 
77
            if [ "x$username" = "x" ]; then
 
78
                username='unknown'
 
79
            fi
 
80
        fi
 
81
    fi
 
82
fi
 
83
 
 
84
#
 
85
#   determine hostname and domainname
 
86
#
 
87
hostname="`(uname -n) 2>/dev/null |\
 
88
           awk '{ printf("%s", $1); }'`"
 
89
if [ "x$hostname" = "x" ]; then
 
90
    hostname="`(hostname) 2>/dev/null |\
 
91
               awk '{ printf("%s", $1); }'`"
 
92
    if [ "x$hostname" = "x" ]; then
 
93
        hostname='unknown'
 
94
    fi
 
95
fi
 
96
case $hostname in
 
97
    *.* )
 
98
        domainname=".`echo $hostname | cut -d. -f2-`"
 
99
        hostname="`echo $hostname | cut -d. -f1`"
 
100
        ;;
 
101
esac
 
102
if [ "x$domainname" = "x" ]; then
 
103
    if [ -f /etc/resolv.conf ]; then
 
104
        domainname="`egrep '^[  ]*domain' /etc/resolv.conf | head -1 |\
 
105
                     sed -e 's/.*domain//' \
 
106
                         -e 's/^[       ]*//' -e 's/^ *//' -e 's/^      *//' \
 
107
                         -e 's/^\.//' -e 's/^/./' |\
 
108
                     awk '{ printf("%s", $1); }'`"
 
109
        if [ "x$domainname" = "x" ]; then
 
110
            domainname="`egrep '^[      ]*search' /etc/resolv.conf | head -1 |\
 
111
                         sed -e 's/.*search//' \
 
112
                             -e 's/^[   ]*//' -e 's/^ *//' -e 's/^      *//' \
 
113
                             -e 's/ .*//' -e 's/        .*//' \
 
114
                             -e 's/^\.//' -e 's/^/./' |\
 
115
                         awk '{ printf("%s", $1); }'`"
 
116
        fi
 
117
    fi
 
118
fi
 
119
 
 
120
#
 
121
#   determine current time
 
122
#
 
123
time_day="`date '+%d' | awk '{ printf("%s", $1); }'`"
 
124
time_month="`date '+%m' | awk '{ printf("%s", $1); }'`"
 
125
time_year="`date '+%Y' 2>/dev/null | awk '{ printf("%s", $1); }'`"
 
126
if [ "x$time_year" = "x" ]; then
 
127
    time_year="`date '+%y' | awk '{ printf("%s", $1); }'`"
 
128
    case $time_year in
 
129
        [5-9][0-9]) time_year="19$time_year" ;;
 
130
        [0-4][0-9]) time_year="20$time_year" ;;
 
131
    esac
 
132
fi
 
133
case $time_month in
 
134
    1|01) time_monthname='Jan' ;;
 
135
    2|02) time_monthname='Feb' ;;
 
136
    3|03) time_monthname='Mar' ;;
 
137
    4|04) time_monthname='Apr' ;;
 
138
    5|05) time_monthname='May' ;;
 
139
    6|06) time_monthname='Jun' ;;
 
140
    7|07) time_monthname='Jul' ;;
 
141
    8|08) time_monthname='Aug' ;;
 
142
    9|09) time_monthname='Sep' ;;
 
143
      10) time_monthname='Oct' ;;
 
144
      11) time_monthname='Nov' ;;
 
145
      12) time_monthname='Dec' ;;
 
146
esac
 
147
 
 
148
#
 
149
#   create result string
 
150
#
 
151
if [ "x$newline" = "xyes" ]; then
 
152
    echo $format_string |\
 
153
    sed -e "s;%u;$username;g" \
 
154
        -e "s;%h;$hostname;g" \
 
155
        -e "s;%d;$domainname;g" \
 
156
        -e "s;%D;$time_day;g" \
 
157
        -e "s;%M;$time_month;g" \
 
158
        -e "s;%Y;$time_year;g" \
 
159
        -e "s;%m;$time_monthname;g"
 
160
else
 
161
    echo "${format_string}&" |\
 
162
    sed -e "s;%u;$username;g" \
 
163
        -e "s;%h;$hostname;g" \
 
164
        -e "s;%d;$domainname;g" \
 
165
        -e "s;%D;$time_day;g" \
 
166
        -e "s;%M;$time_month;g" \
 
167
        -e "s;%Y;$time_year;g" \
 
168
        -e "s;%m;$time_monthname;g" |\
 
169
    awk '-F&' '{ printf("%s", $1); }'
 
170
fi
 
171