#!/bin/sh # $Id$ # Copyright 2013 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. # # Build procedure is based on Arch Linux PKGBUILD and SlackBuild.Org script. # ----------------------------------------------------------------------------- # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # For: chromium # Descr: Open Source version of Chrome Web Browser # URL: http://www.chromium.org/ # Build needs: multilib (for the Native Client) # Needs: # Changelog: # 31.0.1650.57-1: # 18/Nov/2013 by Eric Hameleers # * Initial build. # # Run 'sh chromium.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'. # # ----------------------------------------------------------------------------- PRGNAM=chromium VERSION=${VERSION:-31.0.1650.57} TOOLREV=12181 BUILD=${BUILD:-1} NUMJOBS=${NUMJOBS:" -j4 "} TAG=${TAG:-alien} DOCS="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. # If you want to rebuild this package, either obtain your own, 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 will 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 cat <&1 | tee -a $OUTPUT/patch-${PRGNAM}.log # Adapt for Slackware's libelf include file location: cat $SRCDIR/patches/chromium_libelf_includes.patch | patch -p0 --verbose \ 2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log chown -R root:root . chmod -R u+w,go+r-w,a+X-s . echo Building ... # Prepare Native Client (NaCL) toolchain: mkdir -p native_client/toolchain/{.tars,pnacl_translator} ln -s "$SRCDIR/naclsdk_nacl_linux_x86-${TOOLREV}.tgz" \ native_client/toolchain/.tars/naclsdk_linux_x86.tgz ln -s "$SRCDIR/naclsdk_pnacl_linux_x86-${TOOLREV}.tgz" \ native_client/toolchain/.tars/naclsdk_pnacl_linux_x86.tgz ln -s "$SRCDIR/naclsdk_pnacl_translator-${TOOLREV}.tgz" \ native_client/toolchain/.tars/naclsdk_pnacl_translator.tgz ln -s "$SRCDIR/naclsdk_pnacl_translator-${TOOLREV}.tgz.sha1hash" \ native_client/toolchain/pnacl_translator/SOURCE_SHA1 export -n LDFLAGS="$SLKLDFLAGS" export -n CXXFLAGS="$SLKCFLAGS" export -n CFLAGS="$SLKCFLAGS -Wno-unused-local-typedefs" _chromium_conf=( -Dgoogle_api_key=$_google_api_key -Dgoogle_default_client_id=$_google_default_client_id -Dgoogle_default_client_secret=$_google_default_client_secret -Dwerror= -Dlinux_sandbox_path=/usr/lib${LIBDIRSUFFIX}/chromium/chrome_sandbox -Dlinux_strip_binary=1 -Dlinux_use_gold_binary=0 -Dlinux_use_gold_flags=0 -Dlinux_use_tcmalloc=0 -Dlogging_like_official_build=1 -Dffmpeg_branding=Chrome -Dproprietary_codecs=1 -Ddisable_glibc=1 -Ddisable_nacl=1 -Duse_gconf=0 -Duse_kerberos=0 -Duse_pulseaudio=0 -Duse_system_bzip2=1 -Duse_system_flac=1 -Duse_system_ffmpeg=0 -Duse_system_harfbuzz=1 -Duse_system_icu=1 -Duse_system_libevent=1 -Duse_system_libjpeg=0 -Duse_system_libpng=0 -Duse_system_libxml=1 -Duse_system_libxstl=1 -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 -Drelease_extra_cflags="$CFLAGS" -Dtarget_arch=${TARGETARCH} -Ddisable_sse2=${DSSE} ) #-Dlinux_link_gsettings=1 #-Dlinux_link_libpci=1 #-Dlinux_link_pulseaudio=0 build/linux/unbundle/replace_gyp_files.py "${_chromium_conf[@]}" \ 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log build/gyp_chromium -f make --depth=. "${_chromium_conf[@]}" \ 2>&1 | tee $OUTPUT/gyp-${PRGNAM}.log make $NUMJOBS chrome chrome_sandbox BUILDTYPE=Release V=1 \ 2>&1 | tee $OUTPUT/make-${PRGNAM}.log # Manually install everything: # The main binary: install -D out/Release/chrome $PKG/usr/lib${LIBDIRSUFFIX}/chromium/chromium # The sandbox: install -D -m4755 -o root -g root out/Release/chrome_sandbox \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/chrome-sandbox # Native Client files: cp -a \ out/Release/{*.pak,libffmpegsumo.so,nacl_helper{,_bootstrap}} \ out/Release/{libppGoogleNaClPluginChrome.so,nacl_irt_*.nexe} \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/ # Manually strip binaries so that 'nacl_irt_*.nexe' is left intact strip --strip-unneeded \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/{chromium,chrome-sandbox} \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/nacl_helper{,_bootstrap} \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/libffmpegsumo.so \ $PKG/usr/lib${LIBDIRSUFFIX}/chromium/libppGoogleNaClPluginChrome.so # Add locales: cp -a out/Release/locales $PKG/usr/lib${LIBDIRSUFFIX}/chromium/ # Install a man page: install -D -m0644 out/Release/chrome.1 $PKG/usr/man/man1/chromium.1 # Install a wrapper script: install -D -m0755 $SRCDIR/chromium.sh $PKG/usr/bin/chromium sed -i -e "s/@LIBDIRSUFFIX@/${LIBDIRSUFFIX}/g" $PKG/usr/bin/chromium # 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/chromium.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/chromium.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: install -D -m0644 $SRCDIR/${PRGNAM}.default $PKG/etc/default/${PRGNAM}.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/default/${PRGNAM}.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 > $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_}