#!/bin/bash # # Slackware build script for android-tools # Thanks to the Arch linux maintainers for the makefiles # Copyright 2016, 2017 Philip van der Hoeven, Almere, NL # 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. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=android-tools VERSION=${VERSION:-29.0.5} SRC1=avb-355c69ae673220da533696c44acbfa489702d1ff.tar.gz SRC2=base-d634d2306033599c00b83e68c9ecb60e3206d40c.tar.gz SRC3=boringssl-a7a75f208caea8a303615724d4cc5f4e8dfb9695.tar.gz SRC4=core-fa4254a53a368a8f9b6604442eace6a7b6b63b6d.tar.gz SRC5=e2fsprogs-5fab03bbdc3789515748af8181b9e82dd99beb3b.tar.gz SRC6=extras-6748c3dd53494096ffeebfeeb12e3b3efad90a83.tar.gz SRC7=f2fs-tools-39ec3b4c2edc136d32392ddc7a7f222b4c68e88c.tar.gz SRC8=mkbootimg-e29814dcf6434e8d14379062e4ea1c1b58ff11d0.tar.gz SRC9=native-b9005758dcf78f89c6640ffb119b5b527a417928.tar.gz SRC10=selinux-9e188fde016babc76150098e0ab288e053cf92e2.tar.gz BUILD=${BUILD:-1} TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $TMP/android-tools mkdir $TMP/android-tools cd $TMP/android-tools mkdir avb tar -xvf $CWD/$SRC1 -C avb mkdir base tar -xvf $CWD/$SRC2 -C base mkdir boringssl tar -xvf $CWD/$SRC3 -C boringssl mkdir core tar -xvf $CWD/$SRC4 -C core mkdir e2fsprogs tar -xvf $CWD/$SRC5 -C e2fsprogs mkdir extras tar -xvf $CWD/$SRC6 -C extras mkdir f2fs-tools tar -xvf $CWD/$SRC7 -C f2fs-tools mkdir mkbootimg tar -xvf $CWD/$SRC8 -C mkbootimg mkdir native tar -xvf $CWD/$SRC9 -C native mkdir selinux tar -xvf $CWD/$SRC10 -C selinux cp -a $CWD/deployagent.jar . # generate_build.rb borrowed from Arch Linux # And thanks to Alan Alberghini for the make_ext4fs patch. PKGVER=$VERSION LDFLAGS='-Wl,-z,relro,-z,now' ruby $CWD/generate_build.rb > build.ninja cd core patch -p1 < $CWD/fix_build_core.patch cd .. 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 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; # Build boringssl mkdir -p boringssl/build cd boringssl/build cmake -GNinja .. "${NINJA:=ninja}" $NINJA crypto/libcrypto.a cd ../.. $NINJA mkdir -p $PKG/usr/bin install -D -m 0755 adb $PKG/usr/bin/adb install -D -m 0755 fastboot $PKG/usr/bin/fastboot install -D -m 0755 mke2fs.android $PKG/usr/bin/mke2fs.android install -D -m 0755 e2fsdroid $PKG/usr/bin/e2fsdroid install -D -m 0755 ext2simg $PKG/usr/bin/ext2simg install -D -m 0755 avb/avbtool $PKG/usr/bin/avbtool install -D -m 0755 mkbootimg/mkbootimg.py $PKG/usr/bin/mkbootimg install -D -m 0755 mkbootimg/unpack_bootimg.py $PKG/usr/bin/unpack_bootimg install -D -m 0644 $CWD/bash_completion.fastboot $PKG/usr/share/bash-completion/completions/fastboot find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}