#!/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 -v 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