slackbuilds/d/UNUSED/go/go.SlackBuild
2013-04-13 10:15:10 +02:00

122 lines
2.8 KiB
Bash
Executable file

#!/bin/sh -x
# variables
VERSION=${VERSION:-$(date +%F | tr - .)}
BUILD=1
TAG=cyco
OUTPUT=/tmp
TMP=/tmp/$TAG
CWD=$(pwd)
PRGNAM=$(basename $CWD)
PKG=$TMP/pkg-$PRGNAM
ARCH=$(uname -m)
PREFIX=/usr
REPOSITORY=/home/installs/SlackBuilds/repositories/$PRGNAM
# nettoyage préalable
rm -fr $PKG $TMP/$PRGNAM-$VERSION
mkdir -p $PKG
GOARCH=amd64
case $ARCH in
x86_64)
GOARCH=amd64
;;
"i?86")
GOARCH=386
;;
*)
GOARCH=arm
esac
# mise en place
cd $TMP
[ ! -e $REPOSITORY ] \
&& hg clone -u release https://code.google.com/p/go $REPOSITORY \
|| (cd $REPOSITORY && hg pull -u)
mkdir -p $PKG$PREFIX/lib$(echo $ARCH | grep -o "64")
cp -R $REPOSITORY $PKG$PREFIX/lib$(echo $ARCH | grep -o "64")/
rm -fr $PKG$PREFIX/lib$(echo $ARCH | grep -o "64")/$PRGNAM/.hg*
cd $PKG$PREFIX/lib$(echo $ARCH | grep -o "64")/$PRGNAM/src
./all.bash
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 640 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
cd $PRGNAM/misc/emacs
find . -type f -name \*.el -exec emacs -batch -f batch-byte-compile {} \;
mkdir -p $PKG$PREFIX/share/emacs/site-lisp/
cd $PKG$PREFIX/share/emacs/site-lisp/
ln -s ../../../$PRGNAM/misc/emacs golang
mkdir -p $PKG/etc/profile.d
cat <<EOF > $PKG/etc/profile.d/$PRGNAM.sh
#!/bin/sh
export GOROOT=$PREFIX/$PRGNAM
export GOBIN=\$GOROOT/bin
export GOOS=linux
export GOARCH=$GOARCH
export PATH=\$PATH:\$GOBIN
EOF
chmod +x $PKG/etc/profile.d/$PRGNAM.sh
cat <<EOF > $PKG/etc/profile.d/$PRGNAM.csh
#!/bin/csh
setenv GOROOT $PREFIX/$PRGNAM
setenv GOBIN \$GOROOT/bin
setenv GOOS linux
setenv GOARCH $GOARCH
setenv PATH \$PATH:\$GOBIN
EOF
chmod +x $PKG/etc/profile.d/$PRGNAM.csh
mkdir -p $PKG$PREFIX/doc
cd $PKG$PREFIX/doc
ln -s ../$PRGNAM/doc $PRGNAM-$VERSION
# correction
cd $PKG
chown -R root:root *
[ -d $PKG/usr/man ] && find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
# embaumement
mkdir -p $PKG/install
cat <<EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
$PRGNAM: $PRGNAM (a systems programming language)
$PRGNAM:
$PRGNAM: Go is…
$PRGNAM: …simple
$PRGNAM: …fast
$PRGNAM: …safe
$PRGNAM: …concurrent
$PRGNAM: …fun
$PRGNAM: …open source
$PRGNAM:
$PRGNAM: http://weekly.golang.org/
EOF
# empaquetage
makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr - .)-$ARCH-$BUILD$TAG.txz