iridium-browser / tracker

Iridium Browser tracker and wiki.
https://iridiumbrowser.de
158 stars 8 forks source link

Void Linux binary build #252

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi! I'm currently trying to make a build of Iridium on Void Linux but have never done anything like this before and am not too sure where to start. Void uses a binary package manager (xbps) and can build packages similarily to Arch's PKGBUILD. Using a template file you can tell xbps what build dependencies are required, where to pull files from, and how to build the binary. Currently my template looks like this:

# Template file for 'iridium'
pkgname=iridium
version=2019.04.73
revision=1
#wrksrc=
#create_wrksrc=yes
#archs="i686 x86_64"
#build_style=gnu-configure
#configure_args=""
#make_build_args=""
#make_install_args=""
#conf_files=""
#make_dirs="/var/log/dir 0755 root root"
hostmakedepends="bison python dpkg gperf yasm hwids libatomic-devel clang libglib-devel nodejs perl pkgconf pkg-config ninja libevent-devel"
makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel libXi-devel libgcrypt-devel libgnome-keyring-devel cups-devel elfutils-devel libXcomposite-devel speech-dispatcher-devel libXrandr-devel mit-krb5-devel libXScrnSaver-devel alsa-lib-devel snappy-devel libdrm-devel libxml2-devel libxslt-devel pulseaudio-devel libexif-devel libXcursor-devel libflac-devel speex-devel libmtp-devel libwebp-devel libjpeg-turbo-devel libevent-devel harfbuzz-devel json-c-devel minizip-devel jsoncpp-devel zlib-devel libcap-devel libXdamage-devel re2-devel fontconfig-devel freetype-devel opus-devel ffmpeg-devel libva-devel"
depends="libexif dejavu-fonts-ttf desktop-file-utils hicolor-icon-theme hwids xdg-utils"
short_desc="An attempt at creating a safer, faster, and more stable browser"
maintainer=" <>"
license="BSD-3-Clause"
homepage="https://iridiumbrowser.de/"
distfiles="https://downloads.iridiumbrowser.de/deb/pool/main/i/iridium-browser/iridium-browser_2019.04.73-1iridium0_amd64.deb"
checksum=12c64bec477ffe5b998994bcd7f1078abff3691edc1c25cd4792e0e59b78ba90

build_options="clang"
desc_option_clang="Use clang to build"
build_options_default="clang"

The documentation for building packages on Void is here (https://github.com/void-linux/void-packages/blob/master/Manual.md) and the guide for contributing is here (https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md)

From what I've read the template also needs a build script and it looks like some build scripts are already packaged with xbps. Since there is already a Chromium package on Void I've been using that to supplement (i.e. finding equivelent packages and getting a build script). Currently the script in the template file looks like this:

post_extract() {
    # Use the file at run time instead of effectively compiling it in
    sed 's|//third_party/usb_ids/usb.ids|/usr/share/hwdata/usb.ids|g' \
        -i services/device/public/cpp/usb/BUILD.gn

    # use system nodejs
    mkdir -p third_party/node/linux/node-linux-x64/bin
    ln -sf /usr/bin/node third_party/node/linux/node-linux-x64/bin/node

    if [ -z "$build_option_clang" ]; then
        # Work around bug in blink in which GCC 6 optimizes away null pointer checks
        # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833524
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68853#c2
        sed -i '/config("compiler")/ a cflags_cc = [ "-fno-delete-null-pointer-checks" ]' \
            build/config/linux/BUILD.gn
    fi
}
do_configure() {
    local system="" conf=()
    export -n CFLAGS CXXFLAGS LDFLAGS

    if [ "$build_option_clang" ]; then
        export CC=clang
        export CXX=clang++
    fi

    # Use system-provided libraries.
    # TODO: use_system_hunspell (upstream changes needed).
    # TODO: use_system_libsrtp.
    # TODO: use_system_libusb (http://crbug.com/266149).
    # TODO: use_system_ssl (http://crbug.com/58087).
    # TODO: use_system_sqlite (http://crbug.com/22208).
    # TODO: use_system_icu (segfaults)
    # XXX xtraeme: broken currently
    # use_system_protobuf
    # use_system_v8=1
    # use_system_zlib=1
    # use_system_libvpx=1
    # bzip2 jsoncpp minizip xdg_utils speex
    system="
        ffmpeg
        flac
        fontconfig
        harfbuzz-ng
        libdrm
        libevent
        libjpeg
        libpng
        libwebp
        libxml
        libxslt
        opus
        re2
        snappy
        yasm
    "

    # remove build scripts for system provided dependencies - basically does the
    # same as the bundeled script to remove bundeled libs, but this way we don't
    # have to list the remaining libs
    for LIB in ${system} libjpeg_turbo; do
        find -type f -path "*third_party/$LIB/*" \
            \! -path "*third_party/$LIB/chromium/*" \
            \! -path "*third_party/$LIB/google/*" \
            \! -path './base/third_party/icu/*' \
            \! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \
            \! -path './third_party/yasm/run_yasm.py' \
            \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
            -delete
    done

    # switch to system provided dependencies
    python2 build/linux/unbundle/replace_gn_files.py --system-libraries ${system}

    python2 third_party/libaddressinput/chromium/tools/update-strings.py

    # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
    # Note: These are for Void Linux use ONLY.
    conf+=(
        'google_api_key="AIzaSyA9gWazKaHaNIPPg2hrMj6_ZSG8AFmq738"'
        'google_default_client_id="126659149423-hoo6ickbk3p1u2qjsdsp0ddciurfvb4t.apps.googleusercontent.com"'
        'google_default_client_secret="_ozIx2D-DKm_se_2NPwV4l5b"'
    )

    conf+=(
        'enable_nacl=false'
        'enable_nacl_nonsfi=false'
        "is_clang=$(vopt_if clang true false)"
        'is_debug=false'
        'clang_use_chrome_plugins=false'
        'custom_toolchain="//build/toolchain/linux/unbundle:default"'
        'host_toolchain="//build/toolchain/linux/unbundle:default"'
        'blink_symbol_level=0'
        'symbol_level=0'
        'icu_use_data_file=true'
        'use_allocator="none"'
        'use_allocator_shim=false'
        'use_cups=true'
        'use_pulseaudio=true'
        'use_sysroot=false'
        'use_system_harfbuzz=true'
        'enable_widevine=true'
        'enable_hangout_services_extension=true'
        'is_desktop_linux=true'
    )

    #  Jumbo/Unity builds: https://chromium.googlesource.com/chromium/src/+/master/docs/jumbo.md
    conf+=( "use_jumbo_build=$(vopt_if jumbo_build true false)" )

    # Enable VAAPI - hardware accelerated video decoding.
    conf+=(
        "use_vaapi=true"
    )

    conf+=(
        "closure_compile=$(vopt_if js_optimize true false)"
    )

    # Use explicit library dependencies instead of dlopen.
    # GN only has "link_pulseaudio", the other options used before are not available atm
    # linux_link_cups=true
    # linux_link_gsettings=true
    # linux_link_libpci=true
    # linux_link_libspeechd=true
    # libspeechd_h_prefix=\"speech-dispatcher/\""
    conf+=( 'link_pulseaudio=true' )

    # Never use bundled binutils/gold binary.
    conf+=(
        "binutils_path=\"${XBPS_CROSS_BASE}/usr/bin\""
        "gold_path=\"${XBPS_CROSS_BASE}/usr/bin/ld.gold\""
        'linux_use_bundled_binutils=false'
        'use_custom_libcxx=false'
        'use_lld=false'
    )

    # XXX: gold broken with musl
    case "${XBPS_TARGET_MACHINE}" in
    *-musl) conf+=( 'use_gold=false' ) ;;
    *) conf+=( 'use_gold=true' ) ;;
    esac

    # Always support proprietary codecs.
    # Enable H.264 support in bundled ffmpeg.
    conf+=(
        'proprietary_codecs=true'
        'ffmpeg_branding="Chrome"'
    )

    # Make sure that -Werror doesn't get added to CFLAGS by the build system.
    # Depending on GCC version the warnings are different and we don't want
    # the build to fail because of that.
    conf+=(
        'treat_warnings_as_errors=false'
        'fatal_linker_warnings=false'
    )

    # Save space by removing DLOG and DCHECK messages (about 6% reduction).
    # conf+=" logging_like_official_build=true"
    conf+=( fieldtrial_testing_like_official_build=true )

    case "${XBPS_TARGET_MACHINE}" in
        x86_64*) conf+=( 'target_cpu="x64"' ) ;;
        i686*) conf+=( 'target_cpu="x86"' ) ;;
        arm*) conf+=( 'target_cpu="arm"' ) ;;
        aarch64*) conf+=( 'target_cpu="arm64"' ) ;;
    esac

    export LDFLAGS="-pthread"

    AR="ar" CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD LD=$CXX_FOR_BUILD \
    python2 tools/gn/bootstrap/bootstrap.py -s -v \
        --gn-gen-args "${conf[*]}"

    out/Release/gn gen out/Release --args="${conf[*]}"
}
do_build() {
    ninja -C out/Release ${makejobs} chrome chromedriver mksnapshot
}
do_install() {
    vinstall out/Release/chrome 755 usr/lib/${pkgname} ${pkgname}
    vinstall out/Release/chromedriver 755 usr/lib/${pkgname} chromedriver

    cp out/Release/{*.pak,*.bin} ${DESTDIR}/usr/lib/chromium
    cp -a out/Release/locales ${DESTDIR}/usr/lib/chromium

    vinstall ${FILESDIR}/chromium.desktop 644 usr/share/applications

    vinstall out/Release/icudtl.dat 0644 usr/lib/chromium

    for size in 22 24 48 64 128 256; do
        install -Dm644 "chrome/app/theme/chromium/product_logo_${size}.png" \
        ${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
    done
    for size in 16 32; do
        install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_${size}.png" \
        ${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
    done

    vbin ${FILESDIR}/chromium.sh chromium
    vlicense LICENSE
    ln -s /usr/lib/chromium/chromedriver ${DESTDIR}/usr/bin/chromedriver
}

It's a copy of the script found in the Chromium template (https://github.com/void-linux/void-packages/blob/master/srcpkgs/chromium/template) minus some patches.

I've been trying to consolidate what I've found in the Chromium template with what I've found in the Sources file here (https://downloads.iridiumbrowser.de/deb/dists/stable/snapshots/2019.04.73-20190520/main/source/) and the Packages file here (https://downloads.iridiumbrowser.de/deb/dists/stable/snapshots/2019.04.73-20190520/main/binary-amd64/Packages) but even with all of this I've still been running into a lot of compiling errors (things like => ERROR: iridium-2019.04.73_1: unknown distfile suffix for iridium-browser_2019.04.73-1iridium0_amd64.deb. or => ERROR: iridium-2019.04.73_1: cannot find iridium-browser_2019.04.73-1iridium0.debian.tar.xz, use 'xbps-src fetch' first.)

Haha like I said I'm very new to this so I wasn't too surprised but I'm not really sure where to go from here. I still have questions about whether or not I'm pulling the right dependencies or from the right distribution (since Void uses binary packages). If anyone would be able to help me I would greatly appriciate it!

Also I apoligize for being so wordy, and thank you for taking your time to read this. The template file that I'm using is attatched below (it's linked as template.txt but normally is should just be template). Thank you again!

template.txt

ghost commented 5 years ago

Okay so after researching a little bit I realized I was able to extract the .deb package and install it from there! Full template file:

# Template file for 'iridium-browser'
pkgname=iridium-browser
version=2019.04.73
revision=1
archs="x86_64"
build_style=fetch
hostmakedepends="bison clang gperf libatomic-devel libevent-devel libglib-devel ninja python"
makedepends="alsa-lib-devel at-spi2-atk-devel at-spi2-core-devel atk-devel cups-devel elfutils-devel eudev-libudev-devel expat-devel ffmpeg-devel fontconfig-devel freetype-devel GConf-devel gdk-pixbuf-devel glibc gtk+-devel gtk+3-devel harfbuzz-devel icu-devel json-c-devel jsoncpp-devel libcap-devel libdbus-c++-devel libdrm-devel libevent-devel libexif-devel libffi-devel libflac-devel libgcc-devel libgcrypt-devel libgnome-keyring-devel libjpeg-turbo-devel libmtp-devel libpng-devel libressl-devel libsrtp-devel libstdc++-devel libva-devel libwebp-devel libX11-devel libxcb-devel libXcomposite-devel libXcursor-devel libXdamage-devel libXext-devel libXfixes-devel libXi-devel libxkbcommon-devel libxml2-devel libXrandr-devel libXrender-devel libXScrnSaver-devel libxslt-devel libXtst-devel minizip-devel mit-krb5-devel nspr-devel nss-devel opus-devel pango-devel pciutils-devel plib-devel protobuf protobuf-devel pulseaudio-devel re2-devel snappy-devel speech-dispatcher-devel speex-devel xss-lock zlib-devel"
depends="desktop-file-utils hicolor-icon-theme libexif xdg-utils"
short_desc="Chromium based web browser with a focus on privacy"
maintainer="Austin R <austin.riddell@tutanota.com>"
license="BSD-3-Clause"
homepage="https://iridiumbrowser.de/"
distfiles="https://downloads.iridiumbrowser.de/deb/pool/main/i/iridium-browser/${pkgname}_${version}-1iridium0_amd64.deb"
checksum=12c64bec477ffe5b998994bcd7f1078abff3691edc1c25cd4792e0e59b78ba90

do_extract() {
    ar x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${pkgname}_${version}-1iridium0_amd64.deb
    tar xf data.tar.xz
}

do_install() {
    vcopy etc /
    vcopy usr /
}

post_install() {
    vlicense LICENSE
    vlicense LICENSE.BSD
}

void-packages PR: https://github.com/void-linux/void-packages/pull/14795

ghost commented 5 years ago

Updated template (realized I didn't need to import all the dependencies):

# Template file for 'iridium-browser'
pkgname=iridium-browser
version=2019.04.73
revision=1
archs="x86_64"
build_style=fetch
depends="desktop-file-utils hicolor-icon-theme libexif xdg-utils"
short_desc="Chromium based web browser with a focus on privacy"
maintainer="Austin R <austin.riddell@tutanota.com>"
license="BSD-3-Clause"
homepage="https://iridiumbrowser.de/"
distfiles="https://downloads.iridiumbrowser.de/deb/pool/main/i/iridium-browser/${pkgname}_${version}-1iridium0_amd64.deb"
checksum=12c64bec477ffe5b998994bcd7f1078abff3691edc1c25cd4792e0e59b78ba90

do_extract() {
    ar x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${pkgname}_${version}-1iridium0_amd64.deb
    tar xf data.tar.xz
}

do_install() {
    vcopy etc /
    vcopy usr /
}

post_install() {
    vlicense usr/share/doc/iridium-browser/copyright
}