shadowproject/shadow

View on GitHub
contrib/gitian-descriptors/qt-win.yml

Summary

Maintainability
Test Coverage
---
name: "shadow-qt"
suites:
- "trusty"
architectures:
- "amd64"
packages: 
- "mingw-w64"
- "g++-mingw-w64"
- "faketime"
- "libz-dev"
- "ruby-full"
- "perl"
- "python"
- "m4"
- "bison"
- "gperf"
- "sharutils"
- "zip"
- "unzip"
reference_datetime: "2011-01-30 00:00:00"
remotes: []
files:
- "qt-everywhere-opensource-src-5.5.0.tar.xz"
- "shadow-deps-win32-gitian.tar.xz"
- "shadow-deps-win64-gitian.tar.xz"
- "flex-2.5.38.tar.gz"
script: |
  # Integrity Check
  echo "7ea2a16ecb8088e67db86b0835b887d5316121aeef9565d5d19be3d539a2c2af  qt-everywhere-opensource-src-5.5.0.tar.xz" | sha256sum -c
  echo "306264166531eecbb35ec645c425b1b5538e8ce3035d7bf599db0b2cc76c730f  shadow-deps-win32-gitian.tar.xz"           | sha256sum -c 
  echo "1c7c36ca02624fc2e0f026a84853217e84a9f27f8542a5b18d13164ea48edea7  shadow-deps-win64-gitian.tar.xz"           | sha256sum -c 
  echo "80f7c7188d7611e47e47d2a70c8ef65026c1cf71ddeb4ace9b1be5b8a76ffbd2  flex-2.5.38.tar.gz"                        | sha256sum -c
  # Defines
  export TZ=UTC
  INDIR=$HOME/build
  TEMPDIR=$HOME/tmp
  # Qt: workaround for determinism in resource ordering
  #  Qt5's rcc uses a QHash to store the files for the resource.
  #  A security fix in QHash makes the ordering of keys to be different on every run
  #  (https://qt.gitorious.org/qt/qtbase/commit/c01eaa438200edc9a3bbcd8ae1e8ded058bea268).
  #  This is good in general but qrc shouldn't be doing a traversal over a randomized container.
  #  The thorough solution would be to use QMap instead of QHash, but this requires patching Qt.
  #  For now luckily there is a test mode that forces a fixed seed.
  export QT_RCC_TEST=1
  #
  export OLDPATH="$PATH"
  export OLDINCLUDE="$INCLUDE"
  export OLDLIB="$LIB"
  
  for BITS in 32 64; do # for architectures
    #
    INSTALLPREFIX=$HOME/staging${BITS}
    BUILDDIR=$HOME/build${BITS}
    DEPSDIR=$HOME/deps${BITS}
    if [ "$BITS" == "32" ]; then
      HOST=i686-w64-mingw32
    else
      HOST=x86_64-w64-mingw32
    fi
    #
    export PATH="$DEPSDIR/lib:$OLDPATH"
    export INCLUDE="$DEPSDIR/include:$OLDINCLUDE"
    export LIB="$DEPSDIR/lib:$OLDLIB"
    export PATH="$DEPSDIR/bin:$PATH"
    
    #
    mkdir -p $INSTALLPREFIX $INSTALLPREFIX/host/bin $DEPSDIR $BUILDDIR
    #
    cd $BUILDDIR
    #
    tar xzf $INDIR/flex-2.5.38.tar.gz
    cd flex-2.5.38
    ./configure --prefix=$DEPSDIR
    make
    make install
    cd ..
    #
    # Need mingw-compiled openssl from shadow-deps:
    cd $DEPSDIR
    tar xf $INDIR/shadow-deps-win${BITS}-gitian.tar.xz
    #
    ln -sf $DEPSDIR/lib/libsicudt.a $DEPSDIR/lib/libicudt.a
    ln -sf $DEPSDIR/lib/libsicuin.a $DEPSDIR/lib/libicuin.a
    ln -sf $DEPSDIR/lib/libsicuio.a $DEPSDIR/lib/libicuio.a
    ln -sf $DEPSDIR/lib/libsicule.a $DEPSDIR/lib/libicule.a
    ln -sf $DEPSDIR/lib/libsiculx.a $DEPSDIR/lib/libiculx.a
    ln -sf $DEPSDIR/lib/libsicutest.a $DEPSDIR/lib/libicutest.a
    ln -sf $DEPSDIR/lib/libsicutu.a $DEPSDIR/lib/libicutu.a
    ln -sf $DEPSDIR/lib/libsicuuc.a $DEPSDIR/lib/libicuuc.a
    #
    cd $BUILDDIR
    #
    tar xf $INDIR/qt-everywhere-opensource-src-5.5.0.tar.xz
    #
    cd qt-everywhere-opensource-src-5.5.0
    QTDIR=$BUILDDIR/qt-everywhere-opensource-src-5.5.0
    
    sed -i 's,\.exe,,' "$QTDIR/qtwebkit/Tools/qmake/mkspecs/features/functions.prf"
    sed -i 's,\win_flex,flex,' "$QTDIR/qtwebkit/Tools/qmake/mkspecs/features/default_pre.prf"
    #
    # TODO: find better fix !?
    sed -i 's/FLT_MANT_DIG/24/' "$QTDIR/qtwebkit/Source/WebCore/html/StepRange.cpp"
    sed -i 's/DBL_MANT_DIG/53/' "$QTDIR/qtwebkit/Source/WebCore/html/StepRange.cpp"
    #
    #
    SPECNAME="win32-g++"
    SPECFILE="qtbase/mkspecs/${SPECNAME}/qmake.conf"
    sed 's/qt_instdate=`date +%Y-%m-%d`/qt_instdate=2011-01-30/' -i qtbase/configure
    #sed 's/EXTRA_LFLAGS=\n/EXTRA_LFLAGS= --enable-deterministic-ld\n/' -i qtbase/configure
    sed --posix "s|QMAKE_CFLAGS            = -pipe -fno-keep-inline-dllexport|QMAKE_CFLAGS\t\t= -pipe -fno-keep-inline-dllexport -isystem /usr/$HOST/include/ -frandom-seed=qtbuild -I$DEPSDIR/include|" -i ${SPECFILE}
    #sed --posix "s|QMAKE_LFLAGS            =|QMAKE_LFLAGS\t\t= -L$DEPSDIR/lib --enable-deterministic-ld|" -i ${SPECFILE}
    sed --posix "s|QMAKE_LFLAGS            =|QMAKE_LFLAGS\t\t= -L$DEPSDIR/lib|" -i ${SPECFILE}
    sed "s/src_plugins.depends = src_sql src_xml src_network/src_plugins.depends = src_xml src_network/" -i qtbase/src/src.pro
    #sed "s|X11/extensions/XIproto.h|X11/X.h|"     -i qtbase/src/plugins/platforms/xcb/qxcbxsettings.cpp
    # Before we tried to pass arguments to ar (static linking) in using QMAKE_LIB, however
    #  qt removes the arguments for ar and provides a script which makes it impossible to pass the determinism flag -
    #  so rather than try to replace ar, post-process all libraries and plugins at the end.
    #
    # Don't load faketime while compiling Qt, qmake will get stuck in nearly infinite loops
    #export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
    #export FAKETIME=$REFERENCE_DATETIME
    #
    # fputs not in std namespace?
    #sed 's/std::fputs/fputs/' -i $QTDIR/qttools/src/windeployqt/main.cpp
    #
    CONFIG_OPTS="
    -opensource
    -confirm-license
    -release
    -static
    -xplatform $SPECNAME
    -no-audio-backend
    -no-glib
    -no-dbus
    -no-cups
    -no-iconv
    -no-gif
    -no-freetype
    -no-nis
    -no-pch
    -no-qml-debug
    -nomake examples
    -nomake tests
    -no-feature-style-windowsmobile
    -no-feature-style-windowsce
    -no-sql-db2
    -no-sql-ibase
    -no-sql-oci
    -no-sql-tds
    -no-sql-mysql
    -no-sql-odbc
    -no-sql-psql
    -no-sql-sqlite
    -no-sql-sqlite2
    -prefix $INSTALLPREFIX
    -bindir ${INSTALLPREFIX}/host/bin
    -device-option CROSS_COMPILE=${HOST}-
    -icu
    -v
    -qt-libpng
    -qt-libjpeg
    -system-zlib
    -qt-pcre
    -no-pulseaudio
    -no-openvg
    -no-opengl
    -no-xrender
    -no-alsa
    -no-mtdev
    -no-mitshm
    -no-kms
    -no-reduce-relocations
    -no-egl
    -no-eglfs
    -no-linuxfb
    -no-xinput2
    -no-libudev
    -no-gstreamer
    -optimized-qmake
    -skip qtwinextras
    -skip qtandroidextras
    -skip qtmacextras
    -skip qtx11extras
    -skip qtsvg
    -skip qtxmlpatterns
    -skip qtdeclarative
    -skip qtquickcontrols
    -skip qtmultimedia
    -skip qtactiveqt
    -skip qtlocation
    -skip qtsensors
    -skip qtconnectivity
    -skip qtwebsockets
    -skip qtwebchannel
    -skip qtwebkit-examples
    -skip qtimageformats
    -skip qtgraphicaleffects
    -skip qtscript
    -skip qtquick1
    -skip qtwayland
    -skip qtserialport
    -skip qtenginio
    -skip qtwebengine
    -skip qt3d
    -skip qtcanvas3d
    -skip qtdoc"
    OPENSSL_LIBS="-L$DEPSDIR/lib -lssl -lcrypto -lgdi32" ./configure $CONFIG_OPTS
    #
    #make qmake_all
    #cd qtbase
    #make -C src sub-corelib sub-network sub-widgets sub-gui sub-plugins sub-testlib
    #make -C src sub-corelib-install_subtargets sub-network-install_subtargets sub-widgets-install_subtargets sub-gui-install_subtargets sub-plugins-install_subtargets sub-testlib-install_subtargets
    #make -C ../qttools/src/linguist/lrelease
    #make -C ../qttools/src/linguist/lrelease install_target
    #make -C ../qttranslations
    #make -C ../qttranslations install_subtargets
    make $MAKEOPTS
    make $MAKEOPTS install
    #
    cd $QTDIR/qtwebkit
    sed 's,type nul,cat /dev/null,' -i Source/WebCore/DerivedSources.pri
    for TARGET in Source/WebCore/Target.pri Source/WebKit2/Target.pri Source/JavaScriptCore/Target.pri Source/ThirdParty/leveldb/Target.pri Source/ThirdParty/ANGLE/Target.pri Source/WebKit/WebKit1.pro Source/WTF/WTF.pro
    do
       sed --posix 's/^CONFIG += staticlib optimize_full/CONFIG(shared, static|shared): CONFIG += staticlib optimize_full\nCONFIG(static, static|shared): CONFIG += optimize_full/' -i $TARGET
       sed 's/^CONFIG += staticlib/CONFIG(shared, static|shared): CONFIG += staticlib/' -i $TARGET
       echo "CONFIG(static, static|shared) {
             target.path = \$\$[QT_INSTALL_LIBS]
             INSTALLS += target
             }" >> $TARGET
    done
    $INSTALLPREFIX/host/bin/qmake CONFIG+="release static"
    make
    make install
    #
    # post-process all generated libraries and plugins to be deterministic
    # extract them to a temporary directory then re-build them deterministically
    for LIB in $(find $INSTALLPREFIX -name *.a); do
        rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR
        $HOST-ar xv $LIB | cut -b5- > /tmp/list.txt
        rm $LIB
        $HOST-ar crsD $LIB $(cat /tmp/list.txt)
    done
    #
    cd $INSTALLPREFIX
    # Remove unused non-deterministic stuff
    rm host/bin/qtpaths.exe lib/libQt5Bootstrap.a lib/libQt5Bootstrap.la
    # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date
    export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
    export FAKETIME=$REFERENCE_DATETIME
    find -print0 | xargs -r0 touch # fix up timestamps before packaging
    find | sort | tar --no-recursion -cJf $OUTDIR/qt-win${BITS}-5.5.0-gitian.tar.xz -T -
    unset LD_PRELOAD
    unset FAKETIME
    rm -rf $BUILDDIR
  done # for BITS in