#!/bin/sh # Copyright 2017 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 AUTHOR 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. PKGNAM=rustc VERSION=${VERSION:-$(echo $PKGNAM-*.tar.gz | cut -d - -f 2)} NUMJOBS=${NUMJOBS:-" -j7 "} BUILD=${BUILD:-1} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i686 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM if [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" TRIPLE="$ARCH-unknown-linux-gnu" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" TRIPLE="$ARCH-unknown-linux-gnu" elif [ "$ARCH" = "arm" ]; then SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" LIBDIRSUFFIX="" TRIPLE="armv7-unknown-linux-gnueabihf" else echo "$ARCH is unsupported" ; exit 1 fi # Bootstrapping from scratch, set the channel and date from src/stage0.txt BOOTSTRAP_CHANNEL=$(tar -x $PKGNAM-$VERSION-src/src/stage0.txt -f $PKGNAM-$VERSION-src.tar.gz -O | grep ^rust | cut -d\ -f2 | cut -d- -f1) BOOTSTRAP_DATE=$(tar -x $PKGNAM-$VERSION-src/src/stage0.txt -f $PKGNAM-$VERSION-src.tar.gz -O | grep ^rust | cut -d\ -f2 | cut -d- -f2-4) BOOTSTRAP_CARGO=$(tar -x $PKGNAM-$VERSION-src/src/stage0.txt -f $PKGNAM-$VERSION-src.tar.gz -O | grep ^cargo | cut -d\ -f2) rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf $PKGNAM-$VERSION-src tar xvf $CWD/$PKGNAM-$VERSION-src.tar.gz || exit 1 cd $PKGNAM-$VERSION-src chown -R root:root . find -L . \ \( -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 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; ## Bootstrapping using rustbuild needs these #mkdir -p build/cache/$BOOTSTRAP_DATE build/cache/$BOOTSTRAP_CARGO #ln -s $CWD/bootstrap/rust-std-$BOOTSTRAP_CHANNEL-$TRIPLE.tar.gz \ # build/cache/$BOOTSTRAP_DATE/ #ln -s $CWD/bootstrap/rustc-$BOOTSTRAP_CHANNEL-$TRIPLE.tar.gz \ # build/cache/$BOOTSTRAP_DATE/ #ln -s $CWD/bootstrap/cargo-nightly-$TRIPLE.tar.gz \ # build/cache/$BOOTSTRAP_CARGO/ # Bootstrapping *not* using rustbuild needs this mkdir -p dl ln -s $CWD/bootstrap/rustc-$BOOTSTRAP_CHANNEL-$TRIPLE.tar.gz dl/ # rustbuild seems not mature yet: make install ignores DESTDIR :/ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --datadir=/usr/share \ --docdir=/usr/doc/$PKGNAM-$VERSION \ --release-channel=stable \ --disable-rustbuild \ --disable-jemalloc \ --disable-codegen-tests \ --build=$TRIPLE make $NUMJOBS VERBOSE=1 || exit 1 make DESTDIR="$PKG" VERBOSE=1 install || exit 1 ( cd $PKG/usr/lib$LIBDIRSUFFIX/rustlib rm components manifest-rustc rust-installer-version install.log uninstall.sh cd .. ln -sf rustlib/$ARCH-unknown-linux-gnu/lib/*.so . ) # Compress and if needed symlink the man pages: if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man for manpagedir in $(find . -type d -name "man*") ; do ( cd $manpagedir for eachpage in $( find . -type l -maxdepth 1) ; do ln -s $( readlink $eachpage ).gz $eachpage.gz rm $eachpage done gzip -9 *.? ) done ) fi find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION cp -a *.md COPYRIGHT LICENSE-APACHE LICENSE-MIT $PKG/usr/doc/$PKGNAM-$VERSION cat $CWD/$PKGNAM.SlackBuild > $PKG/usr/doc/$PKGNAM-$VERSION/$PKGNAM.SlackBuild mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cd $PKG /sbin/makepkg -l y -c n $TMP/rustc-$VERSION-$ARCH-$BUILD.txz