summaryrefslogtreecommitdiffstats
path: root/bin/docrelease
blob: d6018982f7a059c5082912870412481c0b59f0db (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
129
130
#!/bin/sh

URL=""
VERS=""
BASE=$PWD
while getopts ":u:v:h" opt; do
    case $opt in
    u)
        echo "DOCRELEASE: URL for package is $OPTARG"
        if [ -n "$OPTARG" ]; then
            URL=$OPTARG
        fi
        ;;
    v)
        echo "DOCRELEASE: Version is $OPTARG"
        if [ -n "$OPTARG" ]; then
            VERS=$OPTARG
        fi
        ;;
    \?)
      echo "DOCRELEASE: Invalid option: -$OPTARG"
      exit 1
      ;;
    :)
      echo "DOCRELEASE: Option -$OPTARG requires an argument."
      exit 1
      ;;
    h)
      echo "Usage: docrelease -u <URL> -v <version>
        URL specifies the URL of the .tar.gz package
        version specifies the output and version of the package"
        exit
      ;;
  esac
done

if [ ! "$URL" ]; then
    echo "Script demands a URL with -u."
    exit 1
fi
if [ ! "$VERS" ]; then
    echo "Script demands a version with -v. 5 is the default."
    VERS="5"
fi


FILE="${URL##*/}"
EXTENSION="${FILE##*.}"
echo "DOCRELEASE: url $URL"
echo "DOCRELEASE: file $FILE"
echo "DOCRELEASE: extension $EXTENSION"
echo "DOCRELEASE: version $VERS"
echo "DOCRELEASE: output  $VERS.tar.gz"

#Download package
if [ -f "$BASE/$FILE" ]; then
    echo "DOCRELEASE: $BASE/$FILE already exists. Will not download package."
else
    echo "DOCRELEASE: $BASE/$FILE does not exist. Will download package."
    WGET_ERROR=$(wget "$URL")
    if [ $? -ne 0 ]; then
        "DOCRELEASE: Error when downloading file."
        exit 1
    fi
fi

DIR=$(tar -tf $FILE | grep -o '^[^/]\+' | sort -u)
echo "DOCRELEASE: dir $DIR"

#Assume .tar.gz
if [ $EXTENSION = "gz" ]; then
    echo "DOCRELEASE: Untarring $FILE"
    tar zxf $FILE
    cd $BASE/$DIR
    ls
    ./configure -prefix $PWD/qtbase -opensource -confirm-license -release

    #build docs
    cd $BASE/$DIR/qtbase && make -j6 -s -w sub-src-qmake_all
    cd $BASE/$DIR/qtbase/src
    make -j6 -s -w sub-uic
    make -j6 -s -w sub-qdoc
    cd $BASE/$DIR
    make html_docs -j6
    #remove directories that are not part of the docs
    cd $BASE/$DIR/qtbase/doc/ && rm -rf src/ global/ README

    #print out useful information about the modules.
    echo "DOCRELEASE: PRINT DOCS" && ls && find . -name *-index.html
else
    echo "DOCRELEASE: Downloaded file must be a .tar.gz file"
    exit
fi

#Parse stage
############
if [ -d "$BASE/$DIR" ]; then
    echo "DOCRELEASE: Preparing to parse"
    mkdir $BASE/$DIR/$VERS
    ls

    cd $BASE/$DIR/

    #retrieve the parser
    wget doc-snapshot.qt-project.org/build/trollweb-qtdocs-parser.tar.gz
    tar xzf trollweb-qtdocs-parser.tar.gz
    cd trollweb-qtdocs-parser/

    #assume that the directories are there. Manual step.modules=$(ls -d */)
    cd $BASE/$DIR/qtbase/doc/
    ls -d */
    modules=$(ls -d */)

    #retrieve the parser
    cd $BASE/$DIR/trollweb-qtdocs-parser/

    for module in $modules
    do
        echo $module
        echo "DOCRELEASE: deleting $BASE/$DIR/$VERS/$module"
        rm -rf $RELEASE/$VERS/$module
        ./tw-qtdocs-parser $BASE/$DIR/qtbase/doc/$module $BASE/$DIR/$VERS/$module
    done

    cd $BASE/$DIR
    tar czf $VERS.tar.gz $VERS
else
    echo "DOCRELEASE: Doc Parsing Failed. Check results of built documentation."
    exit
fi