#!/bin/sh # # init_build # VERSION="1.2" die() { printf '%s\n' "$1" >&2 exit 1 } OS=$(uname -s) if [ "$OS" = Linux ] then [ -z "$(whereis -b git | cut -d: -f2)" ] && die "Please install git" elif [ "$OS" = FreeBSD ] then [ -z "$(whereis -b git | cut -d: -f2)" ] && die "Please install git" [ -z "$(which gmake)" ] && die "Please install gmake" elif [ "$OS" = Darwin ] then [ -z "$(which git)" ] && die "Please install git" fi # Check that the script is not run by root [ "$(id -u)" -eq 0 ] && die "DO NOT run this as root" show_help() { cat <&2 ;; *) ;; esac if [ $help -eq 1 ] then show_help exit fi [ "${top_directory%?}/" = "${top_directory}" ] && top_directory="${top_directory%?}" mkdir -p $top_directory cd $top_directory [ -d "$top_directory/huskybse/.git" ] && cd huskybse && { git pull; cd ..; } || \ git clone https://github.com/huskyproject/huskybse.git huskymak=huskybse/huskymak.cfg [ "$OS" = FreeBSD ] && huskymak=huskybse/huskymak.cfg.bsd [ "$OS" = Darwin ] && huskymak=huskybse/huskymak.cfg.macos [ "$OS:0:5" = MINGW ] && huskymak=huskybse/huskymak.cfg.mgw cp -f -p huskybse/Makefile Makefile cp -f -p $huskymak huskymak.cfg.new cp -f -p huskybse/script/build.sh build.sh if [ -f huskymak.cfg ] then if [ -n "$(diff $huskymak huskymak.cfg)" ] then mv -f huskymak.cfg huskymak.cfg.old cp -p $huskymak huskymak.cfg echo echo "########################################################################" echo "Your huskymak.cfg was renamed to huskymak.cfg.old" echo "Now you need to make changes to \"$top_directory/huskymak.cfg\"" echo "per your requirements and then run \"$top_directory/build.sh\"." echo "########################################################################" echo fi else cp -p $huskymak huskymak.cfg echo echo "########################################################################" echo "Now you need to make changes to \"$top_directory/huskymak.cfg\"" echo "per your requirements and then run \"$top_directory/build.sh\"." echo "########################################################################" echo fi