#!/bin/sh # $Id$ # Copyright 2013, 2014, 2015 Eric Hameleers, Eindhoven, NL # All rights reserved. # # Permission to use, copy, modify, and distribute this software for # any purpose with or without fee is hereby granted, provided that # the above copyright notice and this permission notice appear in all # copies. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ----------------------------------------------------------------------------- # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # For: chromium-dev # Descr: Open Source version of Chrome Web Browser (Development version) # URL: http://www.chromium.org/ # Build needs: - multilib gcc & glibc for compiling the Native Client (64-bit); # - libelf with '-D_FILE_OFFSET_BITS=64' added to CFLAGS (32-bit); # - ninja. # - Internet access (for downloading the nacl/pnacl toolchain bins) # Needs: # Changelog: # 39.0.2138.3-1: # 31/aug/2014 by Eric Hameleers # 39.0.2138.3-2: # 31/aug/2014 by Eric Hameleers # * Fixed the the use of .config/chromium-dev directory name. # 39.0.2145.4-1: # 06/sep/2014 by Eric Hameleers # * Update. # 41.0.2236.0-1: # 09/dec/2014 by Eric Hameleers # * Update. # 41.0.2251.0-1: # 31/dec/2014 by Eric Hameleers # * Update. # 42.0.2311.22-1: # 09/mar/2015 by Eric Hameleers # * Update. # 43.0.2327.5-1: # 10/mar/2015 by Eric Hameleers # * Update. # 44.0.2398.0-1: # 14/may/2015 by Eric Hameleers # * Update. # 45.0.2414.0-1: # 02/jun/2015 by Eric Hameleers # * Update. # 46.0.2478.0-1: # 12/aug/2015 by Eric Hameleers # * Update. # 48.0.2535.0-1: # 16/oct/2015 by Eric Hameleers # * Update. # 49.0.2593.0-1: # 26/dec/2015 by Eric Hameleers # * Update. # # Run 'sh chromium-dev.SlackBuild' to build a Slackware package. # The package (.txz) and .txt file as well as build logs are created in /tmp . # Install it using 'installpkg'. # # ----------------------------------------------------------------------------- SRCNAM=chromium SRCEXT=${SRCEXT:-"-dev"} # "-dev" = development build; "" = stable build PRGNAM=${SRCNAM}${SRCEXT} # chromium or chromium-dev VERSION=${VERSION:-49.0.2593.0} BUILD=${BUILD:-1} TAG=${TAG:-alien} # Differentiate between stable and development releases: if [ "x$SRCEXT" = "x-dev" ]; then RPMCHAN="unstable" CRFLAGS="CHROMIUM_DEV_FLAGS" CRUSERFLAGS="CHROMIUM_DEV_USER_FLAGS" BINTREE="-unstable" else RPMCHAN="stable" CRFLAGS="CHROMIUM_FLAGS" CRUSERFLAGS="CHROMIUM_USER_FLAGS" BINTREE="" fi # By default the ffmpeg library is built statically into the chromium binary. # You can also build a shared library libffmpeg.so (formerly libffmpegsumo.so): USE_FFMPEG=${USE_FFMPEG:-shared} # other option is "static" # You can build without NaCl (native client) if you set USE_NACL to "0", # but you'll lose some Chrome functionality like using in-browser applications: USE_NACL=${USE_NACL:-1} # Use the clang compiler. Results in faster build and smaller binaries. # I default this to "off" because it is untested: USE_CLANG=${USE_CLANG:-0} # If you don't want to enable support for Widevine CDM # (content decryption module) say "0" here. USE_CDM=${USE_CDM:-1} # If you are OK with the "OK Google" hotwording feature which will # automatically download a binary blob with proprietary code, set this to "1". # Some people object to a download without consent so it is disabled by default: USE_HOTWORD=${USE_HOTWORD:-0} # Find the version of Widevine using this commandline on the chrome binary. # Note that the chrome binary RPM needs to have the same version # as our chromium sources: # rpm2cpio ${SOURCE[1]} | cpio --to-stdout -i ./opt/google/chrome${BINTREE}/chrome 2>&1 | strings | grep -C 1 " (version:" | tail -1 RPMSUB=${RPMSUB:-"-1"} WIDEVINE_VERSION="1.4.8.824" # CHROME_VERSION="49.0.2593.0" DOCS="AUTHORS DEPS LICENSE README*" # Where do we look for sources? SRCDIR=$(cd $(dirname $0); pwd) # Place to build (TMP) package (PKG) and output (OUTPUT) the program: TMP=${TMP:-/tmp/build} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} # Visible directory listing of anything Chrome related is: # http://gsdview.appspot.com/ # Official location (non-browsable) of the above is: # https://commondatastorage.googleapis.com/ # This package is built with Alien's Google API keys for Chromium. # The keys are contained in the file "chromium_apikeys". # If you want to rebuild this package, you can use my API keys, however: # you are not allowed to re-distribute these keys!! # You can also obtain your own, see: # http://www.chromium.org/developers/how-tos/api-keys # Or else you can simply compile without API keys. This will disable stuff like # browser sync and other functionality which accesses Google APIs. # The following variables must be set: # _google_api_key # _google_default_client_id # _google_default_client_secret if [ -f ${HOME}/.chromium_apikeys ]; then . ${HOME}/.chromium_apikeys elif [ -f ${SRCDIR}/chromium_apikeys ]; then . ${SRCDIR}/chromium_apikeys else _google_api_key=" " _google_default_client_id=" " _google_default_client_secret=" " cat <&1 | strings | grep -C 1 ' (version:' | tail -1)\" # CHROME_VERSION=\"$VERSION\"" fi exit 0 fi # --- PACKAGE BUILDING --- echo "++" echo "|| $PRGNAM-$VERSION" echo "++" cd $TMP/tmp-$PRGNAM echo "Extracting the source archive(s) for $PRGNAM..." tar -xf ${SOURCE[0]} cd ${SRCNAM}-${VERSION} # Patches: touch $OUTPUT/patch-${PRGNAM}.log # Enable VAAPI hardware decoding on Linux platform: cat $SRCDIR/patches/chromium_vaapi.patch | patch -p1 --verbose \ 2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log if [ "$ARCH" != "x86_64" ]; then # For now, disable NaCl except on x86_64 because the precompiled toolchain is # only available for that architecture at the moment. echo "** Not building NaCL - architecture '$ARCH' is currently unsupported." USE_NACL=0 fi if [ $USE_CDM -eq 1 ]; then # Add support for widevine cdm to this build. # Note that the resulting Slackware package will *not* include the # proprietary Widevine CDM, only the adapter library which is built from OSS. # Also note that it is no longer required to extract the Widevine CDM from # the chrome RPM in order to compile the adapter library. We do it anyway, # but only to determine the version of the Widevine library. # To compile, we just add one #define - see https://crbug.com/473866 sed '14i#define WIDEVINE_CDM_VERSION_STRING "'$WIDEVINE_VERSION'"' \ -i third_party/widevine/cdm/stub/widevine_cdm_version.h fi if [ "x$SRCEXT" = "x-dev" ]; then # Save configuration in ~/.config/chromium-dev": sed -e "s|'filename': 'chromium-browser'|'filename': '${PRGNAM}'|" \ -e "s|'confdir': 'chromium'|'confdir': '${PRGNAM}'|" \ -i chrome/chrome_exe.gypi sed -e 's|config_dir.Append("chromium")|config_dir.Append("'${PRGNAM}'")|' \ -e 's|config_dir.Append("chrome-frame")|config_dir.Append("'chrome-frame$SRCEXT}'")|' \ -i chrome/common/chrome_paths_linux.cc fi if [ "$USE_CLANG" = "1" ]; then # clang doesn't support this option yet: sed -e '/-Wno-absolute-value/d' -i build/common.gypi # -Dclang=1 uses clang instead of gcc. # -Dclang_use_chrome_plugins=1 fails with clang 3.5 - disable for now. CLANG_OPTS=" -Dclang=1 -Dclang_use_chrome_plugins=0" export CC="clang" export CXX="clang++" else CLANG_OPTS=" -Dclang=0" fi chown -R root:root . chmod -R u+w,go+r-w,a+X-s . echo Building ... if [ ${USE_NACL} -eq 1 ]; then DNACL=0 else DNACL=1 fi export -n LDFLAGS="$SLKLDFLAGS" export -n CXXFLAGS="$SLKCFLAGS" export -n CFLAGS="$SLKCFLAGS -Wno-unused-local-typedefs" _chromium_conf=( ${CLANG_OPTS} -Ddisable_glibc=1 -Denable_hotwording=${USE_HOTWORD} -Denable_pepper_cdms=1 -Denable_webrtc=1 -Denable_widevine=${USE_CDM} -Dffmpeg_branding=Chrome -Dffmpeg_component=${USE_FFMPEG}_library -Dgoogle_api_key=$_google_api_key -Dgoogle_default_client_id=$_google_default_client_id -Dgoogle_default_client_secret=$_google_default_client_secret -Dicu_use_data_file_flag=0 -Dlinux_sandbox_path=/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/chrome_sandbox -Dlinux_strip_binary=1 -Dlinux_use_bundled_binutils=0 -Dlinux_use_bundled_gold=0 -Dlinux_use_gold_binary=0 -Dlinux_use_gold_flags=0 -Dlogging_like_official_build=1 -Dproprietary_codecs=1 -Dremove_webcore_debug_symbols=1 -Dusb_ids_path=/usr/share/hwdata/usb.ids -Duse_allocator=none -Duse_gconf=0 -Duse_kerberos=0 -Duse_pulseaudio=0 -Duse_sysroot=0 -Duse_system_bzip2=1 -Duse_system_flac=1 -Duse_system_ffmpeg=0 -Duse_system_harfbuzz=0 -Duse_system_icu=0 -Duse_system_libevent=1 -Duse_system_libjpeg=0 -Duse_system_libpng=0 -Duse_system_libxml=0 -Duse_system_libxslt=0 -Duse_system_nspr=1 -Duse_system_opus=0 -Duse_system_snappy=0 -Duse_system_openssl=1 -Duse_system_xdg_utils=1 -Duse_system_yasm=1 -Duse_system_zlib=0 -Dwerror= -Drelease_extra_cflags="$CFLAGS" -Dtarget_arch=${TARGETARCH} -Ddisable_nacl=${DNACL} -Ddisable_sse2=${DSSE} ) #-Dlinux_link_gsettings=1 #-Dlinux_link_libpci=1 #-Dlinux_link_pulseaudio=0 # Download the NaCL toolchains: if [ ${USE_NACL} -eq 1 ]; then # We do not need arm_trusted on x86: build/download_nacl_toolchains.py --packages nacl_x86_newlib,pnacl_newlib,pnacl_translator sync --extract \ 2>&1 | tee $OUTPUT/nacl_dl-${PRGNAM}.log fi # Do not make the build fail, see Chromium issue #386097: third_party/libaddressinput/chromium/tools/update-strings.py \ 2>&1 | tee $OUTPUT/update_strings-${PRGNAM}.log # Do not make the build fail, see https://groups.google.com/a/chromium.org/d/topic/chromium-packagers/9JX1N2nf4PU/discussion : touch chrome/test/data/webui/i18n_process_css_test.html # Unbundle the libraries which we use from the system: build/linux/unbundle/replace_gyp_files.py "${_chromium_conf[@]}" \ 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log # Generate the ninja build files: build/gyp_chromium --depth=. "${_chromium_conf[@]}" \ 2>&1 | tee $OUTPUT/gyp-${PRGNAM}.log # Compile everything: ninja -C out/Release \ pdf chrome chrome_sandbox chromedriver widevinecdmadapter clearkeycdm \ 2>&1 | tee $OUTPUT/ninja-${PRGNAM}.log # Manually install everything: # The main binary: install -D out/Release/chrome $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/${PRGNAM} # The sandbox: install -D -m4755 -o root -g root out/Release/chrome_sandbox \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/chrome-sandbox # The Chromium implementation of the WebDriver wire protocol # (automated testing of web apps): install -D out/Release/chromedriver $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/chromedriver # Copy over the remaining binaries: cp -a \ out/Release/*.pak \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ if [ -f out/Release/libffmpeg*.so ]; then cp -a \ out/Release/libffmpeg*.so \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ elif [ -f out/Release/lib/libffmpeg.so ]; then mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/lib/ cp -a \ out/Release/lib/libffmpeg.so \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/lib/ fi if [ -f out/Release/natives_blob.bin ]; then cp -a \ out/Release/{natives_blob.bin,snapshot_blob.bin} \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ fi if [ ${USE_NACL} -eq 1 ]; then # Native Client files: cp -a \ out/Release/nacl_helper{,_bootstrap,_nonsfi} \ out/Release/nacl_irt_*.nexe \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ fi if [ $USE_CDM -eq 1 ]; then # Widevine and ClearKey CDM adapter: cp -a \ out/Release/libwidevinecdmadapter.so \ out/Release/libclearkeycdm.so \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ fi # Manually strip binaries so that 'nacl_irt_*.nexe' is left intact strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/{${PRGNAM},chrome-sandbox} \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/chromedriver if [ -f $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/libffmpeg*.so ]; then strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/libffmpeg*.so elif [ -f $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/lib/libffmpeg*.so ]; then strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/lib/libffmpeg*.so fi if [ ${USE_NACL} -eq 1 ]; then strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/nacl_helper{,_bootstrap,_nonsfi} fi if [ ${USE_CDM} -eq 1 ]; then strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/libwidevinecdmadapter.so \ $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/libclearkeycdm.so fi # Add locales: cp -a out/Release/locales $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ cp -a out/Release/pseudo_locales $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ ln -s locales $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/remoting_locales # Add resource files: cp -a out/Release/resources $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ # Install a man page: install -D -m0644 out/Release/chrome.1 $PKG/usr/man/man1/${PRGNAM}.1 # Without this file, chromium refuses to start: cp -a third_party/icu/source/data/in/icudtl.dat $PKG/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/ # Install a wrapper script: install -D -m0755 $SRCDIR/${PRGNAM}.sh $PKG/usr/bin/${PRGNAM} sed \ -e "s/@PRGNAM@/${PRGNAM}/g" \ -e "s/@SRCEXT@/${SRCEXT}/g" \ -e "s/@LIBDIRSUFFIX@/${LIBDIRSUFFIX}/g" \ -e "s/@CRFLAGS@/${CRFLAGS}/g" \ -e "s/@CRUSERFLAGS@/${CRUSERFLAGS}/g" \ -i $PKG/usr/bin/${PRGNAM} # Make the chromedriver available in the $PATH : ln -s ../lib${LIBDIRSUFFIX}/${PRGNAM}/chromedriver $PKG/usr/bin/chromedriver${SRCEXT} # Install desktop icons: for size in 16 32; do install -D -m0644 \ chrome/app/theme/default_100_percent/chromium/product_logo_$size.png \ $PKG/usr/share/icons/hicolor/${size}x${size}/apps/${PRGNAM}.png done for size in 22 24 48 64 128 256; do install -D -m0644 \ chrome/app/theme/chromium/product_logo_$size.png \ $PKG/usr/share/icons/hicolor/${size}x${size}/apps/${PRGNAM}.png done # Add a desktop file: install -D -m0644 \ $SRCDIR/${PRGNAM}.desktop $PKG/usr/share/applications/${PRGNAM}.desktop # Move the 'default' file into place. # This allows users to override command-line options: mkdir -p $PKG/etc/${PRGNAM} cat $SRCDIR/${PRGNAM}.default | sed \ -e "s/@PRGNAM@/${PRGNAM}/g" \ -e "s/@SRCEXT@/${SRCEXT}/g" \ -e "s/@CRFLAGS@/${CRFLAGS}/g" \ -e "s/@CRUSERFLAGS@/${CRUSERFLAGS}/g" \ -e "s/@LIBDIRSUFFIX@/${LIBDIRSUFFIX}/g" \ > $PKG/etc/${PRGNAM}/00-default.conf.new # Add this to the doinst.sh: mkdir -p $PKG/install cat <> $PKG/install/doinst.sh # Handle the incoming configuration files: config() { for infile in \$1; do NEW="\$infile" OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... done } config etc/${PRGNAM}/00-default.conf.new # Update the desktop database: if [ -x usr/bin/update-desktop-database ]; then chroot . /usr/bin/update-desktop-database usr/share/applications > /dev/null 2>&1 fi # Update hicolor theme cache: if [ -d usr/share/icons/hicolor ]; then if [ -x /usr/bin/gtk-update-icon-cache ]; then chroot . /usr/bin/gtk-update-icon-cache -f -t usr/share/icons/hicolor 1> /dev/null 2> /dev/null fi fi # Update the mime database: if [ -x usr/bin/update-mime-database ]; then chroot . /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1 fi EOINS # Add documentation: mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION find $PKG/usr/doc -type f -exec chmod 644 {} \; # Compress the man page(s): if [ -d $PKG/usr/man ]; then find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done fi # Add a package description: mkdir -p $PKG/install cat $SRCDIR/slack-desc${SRCEXT} > $PKG/install/slack-desc # Build the package: cd $PKG makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz} 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log cd $OUTPUT md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz} > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz}.md5 cd - cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt # Restore the original umask: umask ${_UMASK_}