123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- #!/bin/bash
- [% c("var/setarch") -%]
- [% c("var/set_default_env") -%]
- [% IF c("var/windows") -%]
- mkdir -p /var/tmp/dist
- tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/gcc') %]
- hgccdir=/var/tmp/dist/gcc
- # We need a link to our GCC, otherwise the system cc gets used which points to
- # /usr/bin/gcc.
- ln -s gcc $hgccdir/bin/cc
- # Make sure our GCC (as host compiler) get used. We do that before
- # compiler setup so that mingw is first in the PATH.
- export LD_LIBRARY_PATH=$hgccdir/lib64
- export PATH=$hgccdir/bin:$PATH
- [% END -%]
- [% IF c("var/linux-arm") -%]
- [% pc('gcc-cross', 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ 'gcc-cross') }) %]
- # Work around missing libraries. Maybe there's a better way?
- #ln -s -T /usr/include/fontconfig /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include/fontconfig
- #ln -s -T /usr/include/ft2build.h /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include/ft2build.h
- #ln -s -T /usr/include/X11 /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include/X11
- # Work around try2
- #crossdepsdir=/var/tmp/dist/cross-deps-chroot
- #mkdir -p $crossdepsdir
- #fakeroot /usr/sbin/qemu-debootstrap --arch=armhf --variant=minbase --include=libgtk2.0-dev,libdbus-glib-1-dev,libxt-dev,libpulse-dev,libgconf2-dev,libx11-xcb-dev,libmpc2 wheezy $crossdepsdir
- #cp --archive --no-clobber $crossdepsdir/usr/include/* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include/
- #cp --archive --no-clobber $crossdepsdir/usr/lib/arm-linux-gnueabihf/lib*.so* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/
- # Work around try3
- crossdepsdir=/var/tmp/dist/cross-deps-chroot
- mkdir -p $crossdepsdir
- pushd $crossdepsdir
- apt-get --option "APT::Architecture=armhf" download $(apt-rdepends libgtk2.0-dev:armhf libdbus-glib-1-dev:armhf libxt-dev:armhf libpulse-dev:armhf libgconf2-dev:armhf libx11-xcb-dev:armhf libmpc2:armhf|grep -v "^ "|grep -v "debconf-2.0"|grep -v "libc-dev"|grep -v "libz-dev")
- #apt-get download $(apt-rdepends libgtk2.0-dev:armhf libdbus-glib-1-dev:armhf libxt-dev:armhf libpulse-dev:armhf libgconf2-dev:armhf libx11-xcb-dev:armhf libmpc2:armhf|grep -v "^ "|grep -v "debconf-2.0"|grep -v "libc-dev"|grep -v "libz-dev"|sed 's/:armhf//'|sed 's/$/:armhf/')
- #apt-get download $(apt-rdepends libgtk2.0-dev:armhf libdbus-glib-1-dev:armhf libxt-dev:armhf libpulse-dev:armhf libgconf2-dev:armhf libx11-xcb-dev:armhf libmpc2:armhf|grep -v "^ "|grep -v "debconf-2.0"|grep -v "libc-dev"|grep -v "libz-dev"|sed 's/:armhf//'|sed 's/$/:all/')
- #apt-get download libdbus-glib-1-dev:armhf libgconf2-dev:armhf libgtk2.0-dev:armhf libmpc2:armhf libpulse-dev:armhf libx11-6:armhf libx11-xcb-dev:armhf libx11-xcb1:armhf libxcb1:armhf libxcb-shm0:armhf libxext6:armhf libxt-dev:armhf libxt6:armhf
- for PACKAGE in ./*.deb; do
- dpkg -x $PACKAGE ./
- done
- popd
- cp --archive --no-clobber $crossdepsdir/usr/include/* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include/
- cp --archive --no-clobber $crossdepsdir/usr/lib/arm-linux-gnueabihf/lib*.so* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/
- # Workaround for: /usr/bin/ld.gold.real: error: cannot open /var/tmp/dist/gcc-cross/lib/gcc/arm-linux-gnueabihf/6.4.0/../../../../arm-linux-gnueabihf/lib/libglib-2.0.so: No such file or directory
- cp --archive --no-clobber $crossdepsdir/lib/arm-linux-gnueabihf/libglib*.so* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/
- cp --archive $crossdepsdir/lib/arm-linux-gnueabihf/libglib-2.0.so.0 /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/libglib-2.0.so
- cp --archive --no-clobber $crossdepsdir/lib/arm-linux-gnueabihf/libdbus*.so* /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/
- cp --archive $crossdepsdir/lib/arm-linux-gnueabihf/libdbus-1.so.3 /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/libdbus-1.so
- [% END -%]
- [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
- distdir=/var/tmp/dist/[% project %]
- mkdir -p /var/tmp/build
- [% IF c("var/windows") -%]
- mingwdir=/var/tmp/dist/mingw-w64
- mkdir -p $mingwdir/helpers
- cat > $mingwdir/helpers/[% c("arch") %]-w64-mingw32-g++ << 'EOF'
- #!/bin/sh
- /var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-g++ [% c("var/LDFLAGS") %] [% c("var/CFLAGS") %] "$@"
- EOF
- cat > $mingwdir/helpers/[% c("arch") %]-w64-mingw32-gcc << 'EOF'
- #!/bin/sh
- /var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-gcc [% c("var/LDFLAGS") %] [% c("var/CFLAGS") %] "$@"
- EOF
- cat > $mingwdir/helpers/[% c("arch") %]-w64-mingw32-ld << 'EOF'
- #!/bin/sh
- /var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-ld [% c("var/LDFLAGS") %] "$@"
- EOF
- chmod +x $mingwdir/helpers/*
- export PATH="$mingwdir/helpers:$PATH"
- [% END -%]
- [% IF c("var/linux") %]
- mkdir -p /var/tmp/dist
- tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
- export PATH="/var/tmp/dist/binutils/bin:$PATH"
- [% END -%]
- [% IF c("var/linux") && ! c("var/release") -%]
- tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/selfrando') %]
- # Selfrando wrapper
- export PATH="/var/tmp/dist/selfrando/Tools/TorBrowser/tc-wrapper/:$PATH"
- # We need to avoid the shuffling while building as this breaks compilation
- export SELFRANDO_skip_shuffle=
- [% END -%]
- tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
- [% IF c("var/osx") %]
- mkdir -p $distdir/TorBrowser.app/Contents/MacOS
- [% ELSE %]
- mkdir -p $distdir/Browser
- [% END %]
- [% IF c("var/linux") %]
- mkdir -p $distdir/Debug/Browser/
- [% END %]
- cd /var/tmp/build/[% project %]-[% c("version") %]
- mv -f $rootdir/[% c('input_files_by_name/mozconfig') %] .mozconfig
- [% IF c("var/asan") -%]
- mv -f .mozconfig-asan .mozconfig
- # Without disabling LSan our build is blowing up:
- # https://bugs.torproject.org/10599#comment:52
- export ASAN_OPTIONS="detect_leaks=0"
- [% END -%]
- eval $(perl $rootdir/get-moz-build-date [% c("var/copyright_year") %] $(cat browser/config/version.txt))
- if [ -z $MOZ_BUILD_DATE ]
- then
- echo "MOZ_BUILD_DATE is not set"
- exit 1
- fi
- [% IF c("var/windows") %]
- # FIXME
- # Ideally, using LDFLAGS (and e.g. DLLFLAGS for NSS) would be enough to get
- # all Firefox libraries linked against msvcr100. Alas, this does not hold for
- # NSPR. Without patching it we get a "missing entry points for _strcmpi in
- # msvcr100.dll". Now, this should be fixed in rev>=6179 as the def file there
- # contains a proper patch according to the mingw-w64 developers.
- # However, even with this patch the _strcmpi issue is still popping up,
- # probably due to a bug in our current linking setup. The small patch below
- # is therefore just a workaround which should get fixed but is at least
- # justified as the signature of _strcmpi and _stricmp is the same, see:
- # http://msdn.microsoft.com/en-us/library/k59z8dwe.aspx.
- sed 's/strcmpi/stricmp/' -i nsprpub/pr/src/linking/prlink.c
- export HOST_LDFLAGS=" "
- export LDFLAGS="-specs=/var/tmp/dist/mingw-w64/msvcr100.spec"
- # Our flags don't get passed to NSS. We need to do that manually using an
- # obscure one.
- export DLLFLAGS="-specs=/var/tmp/dist/mingw-w64/msvcr100.spec"
- # Make sure widl is not inserting random timestamps, see #21837.
- export WIDL_TIME_OVERRIDE="0"
- [% END %]
- [% IF c("var/osname") == "linux-i686" -%]
- export LDFLAGS=-m32
- export CFLAGS=-m32
- export CC='gcc -m32'
- [% END -%]
- [% IF c("var/windows-x86_64") %]
- patch -p1 < $rootdir/STL_win64.patch
- [% END -%]
- [% IF c("var/linux-arm") %]
- patch -p1 < $rootdir/jsnativestack_unistd_armhf.patch
- [% END -%]
- rm -f configure
- rm -f js/src/configure
- make -f client.mk configure CONFIGURE_ARGS="--with-tor-browser-version=[% c("var/torbrowser_version") %] --with-distribution-id=org.torproject --enable-update-channel=[% c("var/torbrowser_update_channel") %] --enable-bundled-fonts"
- make -j[% c("buildconf/num_procs") %] -f client.mk build
- make -C obj-* package INNER_MAKE_PACKAGE=true
- [% IF c("var/osx") %]
- cp -a obj-macos/dist/firefox/* $distdir
- # Remove firefox-bin (we don't use it, see ticket #10126)
- rm -f $distdir/TorBrowser.app/Contents/MacOS/firefox-bin
- # Adjust the Info.plist file
- INFO_PLIST=$distdir/TorBrowser.app/Contents/Info.plist
- mv $INFO_PLIST tmp.plist
- python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > $INFO_PLIST
- rm -f tmp.plist
- [% END %]
- [% IF c("var/linux") %]
- cp -a obj-*/dist/firefox/* $distdir/Browser/
- # Remove firefox-bin (we don't use it, see ticket #10126)
- rm -f $distdir/Browser/firefox-bin
- # TODO: There goes FIPS-140.. We could upload these somewhere unique and
- # subsequent builds could test to see if they've been uploaded before...
- # But let's find out if it actually matters first..
- rm -f $distdir/Browser/*.chk
- [% END %]
- [% IF c("var/windows-x86_64") -%]
- mv $rootdir/msvcr100-x86_64.dll $rootdir/msvcr100.dll
- [% END -%]
- [% IF c("var/windows") %]
- cp -a obj-*/dist/firefox/* $distdir/Browser/
- cp -a $rootdir/msvcr100.dll $distdir/Browser
- cp -a $gcclibs/libssp-0.dll $distdir/Browser
- [% END %]
- [% IF c("var/linux-arm") -%]
- cp -a /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/libssp.so* $distdir/Browser
- [% END %]
- # Make MAR-based update tools available for use during the bundle phase.
- # Note that mar and mbsdiff are standalone tools, compiled for the build
- # host's architecture. We also include signmar, certutil, and the libraries
- # they require; these utilities and libraries are built for the target
- # architecture.
- MARTOOLS=$distdir/mar-tools
- mkdir -p $MARTOOLS
- cp -p config/createprecomplete.py $MARTOOLS/
- cp -p tools/update-packaging/*.sh $MARTOOLS/
- cp -p obj-*/dist/host/bin/mar $MARTOOLS/
- cp -p obj-*/dist/host/bin/mbsdiff $MARTOOLS/
- [% IF c("var/linux") %]
- cp -p obj-*/modules/libmar/tool/signmar $MARTOOLS/
- cp -p obj-*/security/nss/cmd/certutil/certutil $MARTOOLS/
- NSS_LIBS="libfreeblpriv3.so libmozsqlite3.so libnss3.so libnssdbm3.so libnssutil3.so libsmime3.so libsoftokn3.so libssl3.so"
- NSPR_LIBS="libnspr4.so libplc4.so libplds4.so"
- for LIB in $NSS_LIBS $NSPR_LIBS; do
- cp -p obj-*/dist/bin/$LIB $MARTOOLS/
- done
- [% END %]
- cd $distdir
- [% IF c("var/linux") %]
- # If cross-compiling, use the target objcopy/strip
- [% IF c("var/linux-arm") -%]
- TARGET_OBJCOPY="/var/tmp/dist/gcc-cross/bin/arm-linux-gnueabihf-objcopy"
- TARGET_STRIP="/var/tmp/dist/gcc-cross/bin/arm-linux-gnueabihf-strip"
- [% ELSE %]
- TARGET_OBJCOPY="objcopy"
- TARGET_STRIP="strip"
- [% END %]
- # Strip and generate debuginfo for the firefox binary that we keep, all *.so
- # files, the plugin-container, and the updater (see ticket #10126)
- for LIB in Browser/*.so Browser/firefox Browser/plugin-container Browser/updater
- do
- $TARGET_OBJCOPY --only-keep-debug $LIB Debug/$LIB
- $TARGET_STRIP $LIB
- $TARGET_OBJCOPY --add-gnu-debuglink=./Debug/$LIB $LIB
- done
- [% END %]
- # Re-zipping the omni.ja files is not needed to make them reproductible,
- # however if we don't re-zip them, the files become corrupt when we
- # update them using 'zip' and firefox will silently fail to load some
- # parts.
- [% IF c("var/windows") || c("var/linux") %]
- [% c("var/rezip", { rezip_file => 'Browser/omni.ja' }) %]
- [% c("var/rezip", { rezip_file => 'Browser/browser/omni.ja' }) %]
- [% ELSIF c("var/osx") %]
- [% c("var/rezip", { rezip_file => 'TorBrowser.app/Contents/Resources/omni.ja' }) %]
- [% c("var/rezip", { rezip_file => 'TorBrowser.app/Contents/Resources/browser/omni.ja' }) %]
- [% END %]
- [% IF c("var/windows") %]
- cp $rootdir/msvcr100.dll Browser/
- cp $gcclibs/libssp-0.dll Browser/
- [% END %]
- [% IF c("var/linux-arm") -%]
- cp /var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib/libssp.so* Browser/
- [% END %]
- mkdir -p [% dest_dir _ '/' _ c('filename') %]
- [%
- IF c("var/osx");
- SET browserdir='TorBrowser.app/Contents';
- ELSE;
- SET browserdir='Browser';
- END;
- %]
- [% c('tar', {
- tar_src => [ browserdir ],
- tar_args => '-czf ' _ dest_dir _ '/' _ c('filename') _ '/tor-browser.tar.gz',
- }) %]
- [% IF c("var/linux") %]
- [% c('tar', {
- tar_src => [ 'Debug' ],
- tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/tor-browser-debug.tar.xz',
- }) %]
- [% END %]
- [% c('zip', {
- zip_src => [ 'mar-tools' ],
- zip_args => dest_dir _ '/' _ c('filename') _ '/' _ c('var/martools_filename'),
- }) %]
|