#!/bin/sh ###################################################### # Build script for Core 11.0 # # # # See .info for details # ###################################################### # run the script as root so permissions work if [ `/usr/bin/id -u` -ne 0 ]; then echo "Need root privileges. exec(ing) under sudo" >&2 exec sudo $0 $@ fi ###################################################### # Configure extension creation parameters # ###################################################### EXTNAM=dropbear VERSION=2020.80 RELEASE=$EXTNAM-$VERSION SRCNAM=$RELEASE.tar.bz2 DOWNLOAD=https://matt.ucc.asn.au/dropbear/releases/$SRCNAM TMPDIR=/tmp/$EXTNAM cd $(dirname $0) BASEDIR=$PWD # pull in required tools must be run as user SUDO_USER stored in # /this script/-dep sudo -u $SUDO_USER tce-load -w `cat $0-dep` sudo -u $SUDO_USER tce-load -i `cat $0-dep` # download source if not present if [ ! -f $SRCNAM ] then wget $DOWNLOAD fi ###################################################### # Prepare extension creation # ###################################################### # Remove dirs and files left from previous creation rm -r -f $RELEASE rm -r -f $TMPDIR $TMPDIR-doc ###################################################### # Compile extension # ###################################################### # Export variables needed for compilation case $(uname -m) in i386 | i486 | i586 | i686 | x86) export CFLAGS="-march=i486 -mtune=i686" export CXXFLAGS="-march=i486 -mtune=i686" ;; x86_64) export CFLAGS="-flto -fuse-linker-plugin -mtune=generic" export CXXFLAGS="-flto -fuse-linker-plugin -mtune=generic" ;; arm*) export CFLAGS="" export CXXFLAGS="" ;; armv6*) export CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp" export CXXFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp" ;; armv7*) export CFLAGS="-march=armv7-a -mtune=cortex-a7 -mfpu=neon" export CXXFLAGS="-march=armv7-a -mtune=cortex-a7 -mfpu=neon" ;; *) echo "Unrecongized machine type please update script" exit 1 ;; esac export CFLAGS="$CFLAGS -Os" export CXXFLAGS="$CXXFLAGS -Os -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables" export LDFLAGS="-Wl,-O1" # verified no pthread_cancel so drop asynchronous-unwind-tables export CFLAGS="$CFLAGS -fno-asynchronous-unwind-tables" # Unpack source in current directory tar -xf $SRCNAM # Configure it cp localoptions.h $RELEASE cd $RELEASE ./configure --prefix=/usr/local --disable-lastlog # Compile make DESTDIR=$TMPDIR PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 || exit 1 make DESTDIR=$TMPDIR PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 strip || exit 1 touch /tmp/mark make DESTDIR=$TMPDIR PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 install || exit 1 mkdir -p $TMPDIR/usr/local/share/doc/dropbear/ cp LICENSE $TMPDIR/usr/local/share/doc/dropbear/ # Delete compilation work directory cd .. rm -r -f $RELEASE # Add TC specific files chown root:staff dropbear banner chmod a+x dropbear mkdir -p $TMPDIR/usr/local/etc/dropbear cp banner $TMPDIR/usr/local/etc/dropbear mkdir -p $TMPDIR/usr/local/etc/init.d cp dropbear $TMPDIR/usr/local/etc/init.d # add ssh link so scp does not break ln -s /usr/local/bin/dropbearmulti $TMPDIR/usr/local/bin/ssh # Adjust directory access rights find $TMPDIR/ -type d | xargs chmod -v 755; # Strip executables #find $TMPDIR | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded # Move files to doc extension mkdir -p $TMPDIR-doc/usr/local/ mv $TMPDIR/usr/local/share $TMPDIR-doc/usr/local/share # Move the license back for submitqc mkdir -p $TMPDIR/usr/local/share/doc/dropbear/ mv $TMPDIR-doc/usr/local/share/doc/dropbear/LICENSE $TMPDIR/usr/local/share/doc/dropbear/ rmdir $TMPDIR-doc/usr/local/share/doc/dropbear/ $TMPDIR-doc/usr/local/share/doc/ $TMPDIR-doc/usr/local/share/ ################################################### # Create base extension in temp dir # ################################################### cd $TMPDIR/.. mksquashfs $TMPDIR $EXTNAM.tcz -noappend -processors 1 cd $TMPDIR find ./usr -not -type d | sort | sed 's/^\.//' > ../$EXTNAM.tcz.list mv ../$EXTNAM.tcz ../$EXTNAM.tcz.list . # Create md5 file md5sum $EXTNAM.tcz > $EXTNAM.tcz.md5.txt # Put them all back in the starting directory mv $EXTNAM.tcz* $BASEDIR # Cleanup temp directory rm -r -f $TMPDIR ################################################### # Create doc extension in temp dir # ################################################### cd $TMPDIR-doc/.. mksquashfs $TMPDIR-doc $EXTNAM-doc.tcz -noappend -processors 1 cd $TMPDIR-doc find ./usr -not -type d | sort | sed 's/^\.//' > ../$EXTNAM-doc.tcz.list mv ../$EXTNAM-doc.tcz ../$EXTNAM-doc.tcz.list . # Create md5 file md5sum $EXTNAM-doc.tcz > $EXTNAM-doc.tcz.md5.txt # Put them all back in the starting directory mv $EXTNAM-doc.tcz* $BASEDIR # Cleanup temp directory rm -r -f $TMPDIR-doc