Last active
October 1, 2018 19:11
-
-
Save KurtJacobson/27c23eafa6fa3d45026705ce6ea8301d to your computer and use it in GitHub Desktop.
Script to clone, checkout and build a LinuxCNC branch RIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
dpkg-checkbuilddeps checks the installed packages in the system .
By default, debian/control is read.
But there are no files debian/control in the sources (https://github.com/LinuxCNC/linuxcnc/tree/master/debian)
but here it is already there (http://buildbot.linuxcnc.org/dists/precise/master-rt/source/)
Without it, the script does not work(for me)
ps
sorry for the font (for some reason it is not editable)