Skip to content

Instantly share code, notes, and snippets.

@KurtJacobson
Last active October 1, 2018 19:11
Show Gist options
  • Save KurtJacobson/27c23eafa6fa3d45026705ce6ea8301d to your computer and use it in GitHub Desktop.
Save KurtJacobson/27c23eafa6fa3d45026705ce6ea8301d to your computer and use it in GitHub Desktop.
Script to clone, checkout and build a LinuxCNC branch RIP
#!/bin/bash
# default options
BRANCH="master"
DIRECTORY="$PWD/linuxcnc-dev"
# constants
BOLD=`tput bold`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
usage()
{
echo "Simple script for building LinuxCNC Run In Place (RIP)"
echo ""
echo "./lcnc_rip.sh"
echo " -h, --help display this help and exit"
echo " -b, --branch=master the git branch to build"
echo " -d, --directory=$PWD/linuxcnc-dev where to install the RIP"
echo ""
}
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
--branch | -b)
BRANCH=$VALUE
;;
--directory | -d)
DIRECTORY=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
# Replace ~ with $HOME in path
DIRECTORY="${DIRECTORY//\~/$HOME}"
echo "Cloning and building LinuxCNC-$BRANCH RIP in \"$DIRECTORY\""
mkdir -p $DIRECTORY
# cd $DIRECTORY
echo -e "\n${BOLD}Cloning source ...${RESET}"
if [ -d $DIRECTORY/.git ];
then
echo "Git repo already exists, updating ..."
else
echo "$DIRECTORY cloning git repo ..."
git clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
fi
cd linuxcnc-dev
git fetch origin $BRANCH
git checkout $BRANCH
echo -e "\n${BOLD}Generating package meta-data ...${RESET}"
cd debian
./configure uspace
cd ..
echo -e "\n${BOLD}Checking build dependencies ...${RESET}"
deps=$(dpkg-checkbuilddeps 2>&1 | sed 's/dpkg-checkbuilddeps:\serror:\sUnmet build dependencies: //g' | sed 's/[\(][^)]*[\)] //g')
if [ -z "$deps" ]
then
echo -e "${GREEN}All build dependencies are met!${RESET}"
else
echo -e "${RED}The following build dependencies have not been met:${RESET}"
echo $deps
read -p "Would you like to install these dependencies (y/n)? " -n 1 -r
echo # new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# install list of deps
sudo apt-get -y install $deps
else
echo "exiting the script ..."
exit
fi
fi
echo -e "\n${BOLD}Configuring ...${RESET}"
echo "entering $PWD/src"
cd src
./autogen.sh
./configure
echo -e "\n${BOLD}Compiling LinuxCNC ...${RESET}"
make -j4
sudo make setuid
@nkp216
Copy link

nkp216 commented Sep 2, 2018

added this line :
find . -type f -not -path '*/\.*' -exec grep -Il '.' {} \; | xargs -d '\n' -L 1 dos2unix -k
It works now , thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment