summaryrefslogtreecommitdiff
path: root/debian/scripts/convert_source
blob: a9b18c61f70c0c7202fd512be7efeeca1a649941 (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
#!/bin/sh -ex

VERSION="$1"

if [ -z "$VERSION" ]
then
    echo "Version number not supplied" >&2
fi

# configuration

# for tarball import
#SRC="../heimdal-$VERSION.tar.gz"
#SRC_NAME="heimdal-$VERSION"
#SRC_DIR=""
# for git import
SRC=""
SRC_DIR="$PWD"
DEBIAN_DIR=""

DST="../heimdal_$VERSION.dfsg.1.orig.tar.gz"
DST_NAME="heimdal-$VERSION.dfsg.1"
DEBIAN_DIR="preserve"

# unpack directory
MYTMP=""
trap 'if [ -n "$MYTMP" ]; then rm -rf $MYTMP; fi' EXIT
MYTMP=`mktemp -td heimdal.XXXXXX` || exit 1

# Do not change below

make_dfsg_dir() {
    local DST_DIR="$1"
    local PYTHON=python

    local OPWD="$PWD"
    cd "$srcdir"
    quilt pop -a || true
    cd "$OPWD"

    #OPWD="$PWD"
    #cd "$srcdir"
    #$PYTHON "$dstdir/gen-map.py" "$dstdir/rfc3454.txt"
    #$PYTHON "$dstdir/gen-errorlist.py" "$dstdir/rfc3454.txt"
    #$PYTHON "$dstdir/gen-normalize.py" "$dstdir/UnicodeData.txt" "$srcdir/CompositionExclusions-3.2.0.txt"
    #$PYTHON "$dstdir/gen-combining.py" "$dstdir/UnicodeData.txt"
    #$PYTHON "$dstdir/gen-bidi.py" "$dstdir/rfc3454.txt"
    #$PYTHON "$dstdir/gen-punycode-examples.py" "$dstdir/rfc3492.txt"
    #cd "$OPWD"

    dstdir="$DST_DIR/lib/wind"
    python debian/scripts/rfc3454.py "$dstdir/rfc3454.txt" > "$dstdir/rfc3454.txt.tmp"
    mv "$dstdir/rfc3454.txt.tmp" "$dstdir/rfc3454.txt"

    rm -f "$dstdir/rfc3490.txt"
    rm -f "$dstdir/rfc3491.txt"
    rm -f "$dstdir/rfc4013.txt"
    rm -f "$dstdir/rfc4518.txt"

    rm -rf "$DST_DIR/doc/standardisation"
    rm -f "$DST_DIR/heimdal-1.3.99.tar.gz"
    rm -f "$DST_DIR/heimdal-1.3.99.tar.gz.cdbs-config_list"
    rm -f "$DST_DIR/appl/popper/pop3.rfc1081"
    rm -f "$DST_DIR/appl/popper/pop3e.rfc1082"
}

# GO GO GO

# Pick a good directory name that will cause tar to create tar.gz file with
# appropriate top level name
DST_DIR="$MYTMP/$DST_NAME"

# move or extract source into $DST_DIR
if [ -n "$SRC" ]
then
    tar -xzf "$SRC" -C "$MYTMP"
    SRC_DIR="$MYTMP/$SRC_NAME"
    mv "$SRC_DIR" "$DST_DIR"
else
    cp -a "$SRC_DIR" "$DST_DIR"
fi

# Do our hacking to $DST_DIR
make_dfsg_dir "$DST_DIR"

# Do we need to preseve the debian directory?
if [ "$DEBIAN_DIR" = "preserve" ]
then
    # Yes => move it out of the way
    if [ -e "$MYTMP/debian" ]
    then
        echo "Oops. Temp debian directory exists already. Not overwriting."
        exit 1
    fi
    mv "$DST_DIR/debian" "$MYTMP/debian"
else
    if [ -e "$DST_DIR/debian" ]
    then
        echo "Ooops. Debian directory exists, and we don't know what to do."
        exit 1
    fi
fi

# Create tar.gz file
tar -czf "$DST" -C "$MYTMP" "$DST_NAME"

# Do we need to restore the debian directory?
if [ "$DEBIAN_DIR" = "preserve" ]
then
    mv "$MYTMP/debian" "$DST_DIR/debian"
fi

# Move source, if required, to where it won't get deleted
if [ -e "../$DST_NAME" ]
then
    echo "Oops. Destination directory exists already. Not overwriting."
    exit 1
fi
mv "$DST_DIR" "../$DST_NAME"

exit 0