#!/bin/sh # Slackware build script for google-go-lang # Written by Eric Schultz eric at schultzter.ca # Taken over by Vincent Batts vbatts@hashbangbash.com # Adapted to slacky's standard by miklos < ardutu at gmail dot com > # Copyright (c) 2012 Eric Schultz # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. set -e # Basic information. PKGNAME=google-go-lang SRCNAME=go VERSION=${VERSION:-1.1.2} BUILD=${BUILD:-2} TAG=${TAG:-sl} ARCH=${ARCH:-x86_64} SOURCE="https://go.googlecode.com/files/${SRCNAME}${VERSION}.src.tar.gz" TAR= # empty = auto DIR="go" DOCS="AUTHORS CONTRIBUTORS LICENSE PATENTS README VERSION " SLKFILES="" # all files needed to the slackbuild (except slack-desc etc..) RELEASE=${RELEASE:-linux} # An EULA for non-free packages if [ -e EULA.TXT ];then more EULA.TXT echo "Do you accept terms? (yes/[no])": read ACCEPT if [ "$ACCEPT" != "yes" ];then echo; echo "SlackBuild Aborted!!" exit 1 fi fi # Does not touch following if not needed JOBS=${JOBS:--j2} CWD=$(pwd) TMP=${TMP:-/tmp/buildpkgs/$PKGNAME} PKG=$TMP/package-$PKGNAME OUTPUT=${OUTPUT:-$CWD} TAR=${TAR:-$(basename $SOURCE)} DIR=${DIR:-$(echo "$TAR"|sed -r 's/(\.tar|)(.gz|.bz2|.xz|)$//')} if [ ! -e "$CWD/$TAR" ];then wget "$SOURCE" -O "$CWD/$TAR" fi CHOST="i486" if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" LIBDIRSUFFIX="" GARCH="386" elif [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" GARCH="386" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" GARCH="386" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" CHOST="x86_64" GARCH="amd64" fi ### Preparing Source rm -rf $TMP mkdir -p $TMP $PKG/usr/lib${LIBDIRSUFFIX} $OUTPUT cd $PKG/usr/lib${LIBDIRSUFFIX} tar xvf $CWD/$TAR cd $DIR chown -R root:root . chmod -R u+w,go+r-w,a-s . export GOSRC="$(pwd)" export GOROOT="$(pwd)" export GOROOT_FINAL="/usr/lib${LIBDIRSUFFIX}/go" export GOOS="linux" export GOBIN="${GOROOT}/bin" export GOARCH="${GARCH}" mkdir -p "${GOBIN}" cd src LC_ALL=C \ PATH="$PATH:$GOBIN" \ #./all.bash ./make.bash cd .. install -Dm644 misc/bash/go $PKG/etc/bash_completion.d/go install -Dm644 misc/emacs/go-mode-load.el $PKG/usr/share/emacs/site-lisp/go-mode-load.el install -Dm644 misc/emacs/go-mode.el $PKG/usr/share/emacs/site-lisp/go-mode.el install -Dm644 misc/vim/syntax/go.vim $PKG/usr/share/vim/vimfiles/syntax/go.vim install -Dm644 misc/vim/ftdetect/gofiletype.vim $PKG/usr/share/vim/vimfiles/ftdetect/gofiletype.vim install -Dm644 misc/vim/ftplugin/go/fmt.vim $PKG/usr/share/vim/vimfiles/ftplugin/go/fmt.vim install -Dm644 misc/vim/ftplugin/go/import.vim $PKG/usr/share/vim/vimfiles/ftplugin/go/import.vim install -Dm644 misc/vim/indent/go.vim $PKG/usr/share/vim/vimfiles/indent/go.vim #mkdir -p misc lib src mkdir -p $PKG/usr/bin ln -sf /usr/lib${LIBDIRSUFFIX}/go/bin/go $PKG/usr/bin/go ln -sf /usr/lib${LIBDIRSUFFIX}/go/bin/godoc $PKG/usr/bin/godoc ln -sf /usr/lib${LIBDIRSUFFIX}/go/bin/gofmt $PKG/usr/bin/gofmt ln -sf /usr/lib${LIBDIRSUFFIX}/go/pkg/tool/linux_${GOARCH}/cgo $PKG/usr/bin/cgo #ln -sf /usr/lib${LIBDIRSUFFIX}/go/pkg/tool/linux_${GOARCH}/ebnflint $PKG/usr/bin/ebnflint # we'll just check for all of their compilers :-) for tool in 8a 8c 8g 8l 6a 6c 6g 6l 5a 5c 5g 5l ; do if [ -x $PKG/usr/lib${LIBDIRSUFFIX}/go/pkg/tool/linux_${GOARCH}/${tool} ] ; then ln -sf /usr/lib${LIBDIRSUFFIX}/go/pkg/tool/linux_${GOARCH}/${tool} $PKG/usr/bin/${tool} fi done # Put the profile scripts for setting PATH and env variables mkdir -p $PKG/etc/profile.d cat > $PKG/etc/profile.d/go.csh.new << EOF #!/bin/csh setenv GOOS linux setenv GOARCH ${GOARCH} setenv GOROOT /usr/lib${LIBDIRSUFFIX}/go EOF cat > $PKG/etc/profile.d/go.sh.new << EOF #!/bin/sh export GOOS="linux" export GOARCH="${GOARCH}" export GOROOT="/usr/lib${LIBDIRSUFFIX}/go" EOF chmod 0755 $PKG/etc/profile.d/go.csh.new chmod 0755 $PKG/etc/profile.d/go.sh.new #fix timestamp find $PKG/usr/lib${LIBDIRSUFFIX}/go/pkg -type f -exec touch '{}' + find $PKG/usr/lib${LIBDIRSUFFIX}/go/bin -type f -exec touch '{}' + # Documentations mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION cp -r $DOCS $PKG/usr/doc/$PKGNAME-$VERSION mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild cd $CWD for SB in $PKGNAME.SlackBuild slack-desc doinst.sh doinst.sh.gz EULA.TXT $SLKFILES;do [ -e $SB ]&&cp -r $SB $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/$SB done if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man find . -type f -exec gzip -9 {} \; for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi if [ -d $PKG/usr/info ]; then ( cd $PKG/usr/info find . -type f -exec gzip -9 {} \; for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi # Strip binary files ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true ) # Preparing to packaging mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc [ -e $CWD/doinst.sh ] && cat $CWD/doinst.sh > $PKG/install/doinst.sh [ -e $CWD/doinst.sh.gz ] && zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh cd $PKG chown -R root:root $PKG if [ -x "$(which requiredbuilder 2>/dev/null)" ];then requiredbuilder -y -v -s $CWD $PKG # add "-c -b" if you have binary files in /usr/share [ -e install/slack-required ]&&cat install/slack-required > $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/slack-required fi # Packaging /sbin/makepkg -l y -c n $OUTPUT/$PKGNAME-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz} if [ "$1" = "--cleanup" ]; then rm -rf $TMP fi