summaryrefslogtreecommitdiffstats
path: root/Doc/tools/push-docs.sh
blob: dfccb5b7330f163f8f73a5697543954ff4cc3ffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh

#  Script to push docs from my development area to SourceForge, where the
#  update-docs.sh script unpacks them into their final destination.

TARGETHOST=www.python.org
TARGETDIR=/usr/home/fdrake/tmp

PKGTYPE="bzip"  # must be one of: bzip, tar, zip  ("tar" implies gzip)

TARGET="$TARGETHOST:$TARGETDIR"

ADDRESSES='python-dev@python.org doc-sig@python.org python-list@python.org'

TOOLDIR="`dirname $0`"
VERSION=`$TOOLDIR/getversioninfo`

# Set $EXTRA to something non-empty if this is a non-trunk version:
EXTRA=`echo "$VERSION" | sed 's/^[0-9][0-9]*\.[0-9][0-9]*//'`

if echo "$EXTRA" | grep -q '[.]' ; then
    DOCLABEL="maintenance"
    DOCTYPE="maint"
else
    DOCLABEL="development"
    DOCTYPE="devel"
fi

EXPLANATION=''
ANNOUNCE=true

getopt -T >/dev/null
if [ $? -eq 4 ] ; then
    # We have a sufficiently useful getopt(1) implementation.
    set -- `getopt -ssh m:p:qt:F: "$@"`
else
    # This version of getopt doesn't support quoting of long options
    # with spaces, so let's not rely on it at all.
    :
fi

while [ "$#" -gt 0 ] ; do
  case "$1" in
      -m)
          EXPLANATION="$2"
          shift 2
          ;;
      -p)
          PKGTYPE="$2"
          shift 1
          ;;
      -q)
          ANNOUNCE=false
          shift 1
          ;;
      -t)
          DOCTYPE="$2"
          shift 2
          ;;
      -F)
          EXPLANATION="`cat $2`"
          shift 2
          ;;
      --)
          shift 1
          break
          ;;
      -*)
          echo "Unknown option: $1" >&2
          exit 2
          ;;
      *)
          break
          ;;
  esac
done
if [ "$1" ] ; then
    if [ "$EXPLANATION" ] ; then
        echo "Explanation may only be given once!" >&2
        exit 2
    fi
    EXPLANATION="$1"
    shift
fi

START="`pwd`"
MYDIR="`dirname $0`"
cd "$MYDIR"
MYDIR="`pwd`"

if [ "$PKGTYPE" = bzip ] ; then
    PKGEXT=tar.bz2
elif [ "$PKGTYPE" = tar ] ; then
    PKGEXT=tgz
elif [ "$PKGTYPE" = zip ] ; then
    PKGEXT=zip
else
    echo 1>&2 "unsupported package type: $PKGTYPE"
    exit 2
fi

cd ..

# now in .../Doc/
make --no-print-directory ${PKGTYPE}html || exit $?
PACKAGE="html-$VERSION.$PKGEXT"
scp "$PACKAGE" tools/update-docs.sh $TARGET/ || exit $?
ssh "$TARGETHOST" tmp/update-docs.sh $DOCTYPE $PACKAGE '&&' rm tmp/update-docs.sh || exit $?

if $ANNOUNCE ; then
    sendmail $ADDRESSES <<EOF
To: $ADDRESSES
From: "Fred L. Drake" <fdrake@acm.org>
Subject: [$DOCLABEL doc updates]
X-No-Archive: yes

The $DOCLABEL version of the documentation has been updated:

    http://$TARGETHOST/dev/doc/$DOCTYPE/

$EXPLANATION

A downloadable package containing the HTML is also available:

    http://$TARGETHOST/dev/doc/python-docs-$DOCTYPE.$PKGEXT
EOF
    exit $?
fi