introduce shared linux shell code / externalize distribution check
This commit is contained in:
parent
343a728911
commit
9c51bfc60c
73
build-mg.sh
73
build-mg.sh
|
@ -61,7 +61,7 @@ cd ${SCRIPTDIR}
|
|||
# will warn about it later.
|
||||
# Instead of editing this variable, consider creating a symbolic link:
|
||||
# ln -s ../../google-breakpad google-breakpad
|
||||
BREAKPAD_ROOT="$(dirname $(readlink -f $0))/google-breakpad/"
|
||||
BREAKPAD_ROOT="$SCRIPTDIR/google-breakpad/"
|
||||
|
||||
# CMake options
|
||||
# The default configuration works fine for regular developers and is also used
|
||||
|
@ -71,8 +71,7 @@ BREAKPAD_ROOT="$(dirname $(readlink -f $0))/google-breakpad/"
|
|||
EXTRA_CMAKE_OPTIONS=
|
||||
|
||||
# Build threads
|
||||
# By default we use all available CPU cores to build.
|
||||
# Pass '1core' as first command line argument to use only one.
|
||||
# By default we use all physical CPU cores to build.
|
||||
NUMCORES=`lscpu -p | grep -cv '^#'`
|
||||
echo "CPU cores detected: $NUMCORES"
|
||||
if [ "$NUMCORES" = '' ]; then NUMCORES=1; fi
|
||||
|
@ -81,76 +80,24 @@ echo "CPU cores to be used: $NUMCORES"
|
|||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# Load shared functions
|
||||
|
||||
. $SCRIPTDIR/mk/linux/mg_shared.sh
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ $MAKE_ONLY = 0 ]; then
|
||||
mkdir -p build
|
||||
fi
|
||||
|
||||
cd build
|
||||
CURRENTDIR="$(dirname $(readlink -f $0))"
|
||||
|
||||
if [ $MAKE_ONLY = 0 ]; then
|
||||
if [ -f 'CMakeCache.txt' ]; then rm -f 'CMakeCache.txt'; fi
|
||||
fi
|
||||
|
||||
# Get distribution and architecture details
|
||||
if [ `which lsb_release`'x' = 'x' ]
|
||||
then
|
||||
lsb=0
|
||||
if [ -e /etc/debian_version ]; then distribution='Debian'; release='unknown release version'; codename=`cat /etc/debian_version`; fi
|
||||
if [ -e /etc/SuSE-release ]; then distribution='SuSE'; release='unknown release version'; codename=`cat /etc/SuSE-release`; fi
|
||||
if [ -e /etc/fedora-release ]; then distribution='Fedora'; release='unknown release version'; codename=`cat /etc/fedora-release`; fi
|
||||
if [ -e /etc/redhat-release ]; then distribution='Redhat'; release='unknown release version'; codename=`cat /etc/redhat-release`; fi
|
||||
if [ -e /etc/mandrake-release ]; then distribution='Mandrake'; release='unknown release version'; codename=`cat /etc/mandrake-release`; fi
|
||||
else
|
||||
lsb=1
|
||||
|
||||
# lsb_release output by example:
|
||||
#
|
||||
# $ lsb_release -i
|
||||
# Distributor ID: Ubuntu
|
||||
#
|
||||
# $ lsb_release -d
|
||||
# Description: Ubuntu 12.04 LTS
|
||||
#
|
||||
# $ lsb_release -r
|
||||
# Release: 12.04
|
||||
#
|
||||
# $ lsb_release -c
|
||||
# Codename: precise
|
||||
|
||||
distribution=`lsb_release -i | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
release=`lsb_release -r | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
codename=`lsb_release -c | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
|
||||
# Some distribution examples:
|
||||
#
|
||||
# OpenSuSE 11.4
|
||||
#LSB Version: n/a
|
||||
#Distributor ID: SUSE LINUX
|
||||
#Description: openSUSE 11.4 (x86_64)
|
||||
#Release: 11.4
|
||||
#Codename: Celadon
|
||||
#
|
||||
# OpenSuSE 12.1
|
||||
#LSB support: 1
|
||||
#Distribution: SUSE LINUX
|
||||
#Release: 12.1
|
||||
#Codename: Asparagus
|
||||
#
|
||||
# Arch
|
||||
#LSB Version: n/a
|
||||
#Distributor ID: archlinux
|
||||
#Description: Arch Linux
|
||||
#Release: rolling
|
||||
#Codename: n/a
|
||||
#
|
||||
# Ubuntu 12.04
|
||||
#Distributor ID: Ubuntu
|
||||
#Description: Ubuntu 12.04 LTS
|
||||
#Release: 12.04
|
||||
#Codename: precise
|
||||
fi
|
||||
architecture=`uname -m`
|
||||
# Included from shared functions
|
||||
detect_system
|
||||
|
||||
echo 'We have detected the following system:'
|
||||
echo ' [ '"$distribution"' ] [ '"$release"' ] [ '"$codename"' ] [ '"$architecture"' ]'
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
# Copyright (c) 2013 Mark Vejvoda under GNU GPL v3.0+
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Requires:
|
||||
# - curl, built with SSL support, in $PATH
|
||||
# - wget, built with SSL support, in $PATH
|
||||
# - 7z (command line utility of 7-zip), in $PATH
|
||||
# - Coverity Scan Build Tool, in $PATH
|
||||
#
|
||||
|
||||
|
||||
# Default to English language output so we can understand your bug reports
|
||||
export LANG=C
|
||||
|
@ -12,14 +20,8 @@ export LANG=C
|
|||
CURRENTDIR="$(dirname $(readlink -f $0))"
|
||||
echo "Script path [${CURRENTDIR}]"
|
||||
|
||||
#
|
||||
# Upload Coverity s
|
||||
# Requires:
|
||||
# - data\glest_game\curl.exe, built with SSL support: http://curl.haxx.se/download.html
|
||||
# - ..\..\data\glest_game\wget.exe (should get installed automatically during a build)
|
||||
# - ..\..\data\glest_game\7z.exe (should get installed automatically during a build)
|
||||
# - Coverity Scan Build Tool installed and in %PATH%
|
||||
#
|
||||
# Load shared functions
|
||||
. $CURRENTDIR/mg_shared.sh
|
||||
|
||||
# Project name (case sensitive)
|
||||
PROJECT=MegaGlest
|
||||
|
@ -42,36 +44,10 @@ fi
|
|||
# echo "Read config values: TOKEN [$TOKEN] EMAIL [$EMAIL] COVERITY_ANALYSIS_ROOT [$COVERITY_ANALYSIS_ROOT] NUMCORES [${NUMCORES}]"
|
||||
# exit 1
|
||||
|
||||
# Description of this build (can be any string)
|
||||
# Determine distro title, release, codename
|
||||
LSB_PATH=$(which lsb_release)
|
||||
if [ '${LSB_PATH}x' = 'x' ] ; then
|
||||
lsb=0
|
||||
if [ -e /etc/debian_version ]
|
||||
then distribution='Debian'; release='unknown release version'; codename=`cat /etc/debian_version`
|
||||
elif [ -e /etc/SuSE-release ]
|
||||
then distribution='SuSE'; release='unknown release version'; codename=`cat /etc/SuSE-release`
|
||||
elif [ -e /etc/redhat-release ]
|
||||
then
|
||||
if [ -e /etc/fedora-release ]
|
||||
then distribution='Fedora'; release='unknown release version'; codename=`cat /etc/fedora-release`
|
||||
else distribution='Redhat'; release='unknown release version'; codename=`cat /etc/redhat-release`
|
||||
fi
|
||||
elif [ -e /etc/fedora-release ]
|
||||
then distribution='Fedora'; release='unknown release version'; codename=`cat /etc/fedora-release`
|
||||
elif [ -e /etc/mandrake-release ]
|
||||
then distribution='Mandrake'; release='unknown release version'; codename=`cat /etc/mandrake-release`
|
||||
fi
|
||||
else
|
||||
lsb=1
|
||||
|
||||
distribution=$(lsb_release -i | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }')
|
||||
release=$(lsb_release -r | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }')
|
||||
codename=$(lsb_release -c | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }')
|
||||
fi
|
||||
# Included from shared functions
|
||||
detect_system
|
||||
|
||||
computername=$(hostname)
|
||||
architecture=$(uname -m)
|
||||
#DESCRIPTION=${distribution}-${release}-${architecture}_${computername}
|
||||
DESCRIPTION=${distribution}-${architecture}_${computername}
|
||||
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Functions shared by several scripts
|
||||
#
|
||||
|
||||
|
||||
function detect_system {
|
||||
# Determine distro title, release, codename
|
||||
#
|
||||
# Input:
|
||||
# -/-
|
||||
#
|
||||
# Output:
|
||||
# No direct output, but the following variables are set:
|
||||
# lsb: whether (1) or not (0) system information was retrieved from 'lsb_release'
|
||||
# distribution: detected Linux distribution (string)
|
||||
# release: detected distribution release / version (string)
|
||||
# codename: codename of the detected Linux distribution (string)
|
||||
# architecture: detected machine architecture (string)
|
||||
|
||||
if [[ `which lsb_release` = '' ]]
|
||||
then
|
||||
lsb=0
|
||||
if [ -e /etc/debian_version ]
|
||||
then
|
||||
distribution='Debian'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/debian_version`
|
||||
elif [ -e /etc/SuSE-release ]
|
||||
then
|
||||
distribution='SuSE'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/SuSE-release`
|
||||
elif [ -e /etc/redhat-release ]
|
||||
then
|
||||
if [ -e /etc/fedora-release ]
|
||||
then
|
||||
distribution='Fedora'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/fedora-release`
|
||||
else
|
||||
distribution='Redhat'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/redhat-release`
|
||||
fi
|
||||
elif [ -e /etc/fedora-release ]
|
||||
then
|
||||
distribution='Fedora'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/fedora-release`
|
||||
elif [ -e /etc/mandrake-release ]
|
||||
then
|
||||
distribution='Mandrake'
|
||||
release='unknown release version'
|
||||
codename=`cat /etc/mandrake-release`
|
||||
fi
|
||||
else
|
||||
lsb=1
|
||||
|
||||
distribution=`lsb_release -i | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
release=`lsb_release -r | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
codename=`lsb_release -c | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
|
||||
# Some distribution examples:
|
||||
#
|
||||
# OpenSuSE 11.4
|
||||
# LSB Version: n/a
|
||||
# Distributor ID: SUSE LINUX
|
||||
# Description: openSUSE 11.4 (x86_64)
|
||||
# Release: 11.4
|
||||
# Codename: Celadon
|
||||
#
|
||||
# OpenSuSE 12.1
|
||||
# LSB support: 1
|
||||
# Distribution: SUSE LINUX
|
||||
# Release: 12.1
|
||||
# Codename: Asparagus
|
||||
#
|
||||
# Arch
|
||||
# LSB Version: n/a
|
||||
# Distributor ID: archlinux
|
||||
# Description: Arch Linux
|
||||
# Release: rolling
|
||||
# Codename: n/a
|
||||
#
|
||||
# Ubuntu 12.04
|
||||
# Distributor ID: Ubuntu
|
||||
# Description: Ubuntu 12.04 LTS
|
||||
# Release: 12.04
|
||||
# Codename: precise
|
||||
fi
|
||||
architecture=`uname -m`
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Use this script to install build dependencies on a number of Linux platforms
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@ -9,6 +9,12 @@
|
|||
|
||||
LANG=C
|
||||
|
||||
SCRIPTDIR="$(dirname $(readlink -f $0))"
|
||||
gitcommit=`git log -1 --pretty=tformat:"%H" $SCRIPTDIR/../..`
|
||||
|
||||
# Load shared functions
|
||||
. $SCRIPTDIR/mg_shared.sh
|
||||
|
||||
# Got root?
|
||||
if [ `id -u`'x' != '0x' ]
|
||||
then
|
||||
|
@ -32,80 +38,8 @@ else
|
|||
fi
|
||||
|
||||
|
||||
mypath=`readlink -f $0 | xargs dirname`
|
||||
gitcommit=`git log -1 --pretty=tformat:"%H" $mypath/../..`
|
||||
|
||||
|
||||
# Determine distro title, release, codename
|
||||
if [ `which lsb_release`'x' = 'x' ]
|
||||
then
|
||||
lsb=0
|
||||
if [ -e /etc/debian_version ]
|
||||
then distribution='Debian'; release='unknown release version'; codename=`cat /etc/debian_version`
|
||||
elif [ -e /etc/SuSE-release ]
|
||||
then distribution='SuSE'; release='unknown release version'; codename=`cat /etc/SuSE-release`
|
||||
elif [ -e /etc/redhat-release ]
|
||||
then
|
||||
if [ -e /etc/fedora-release ]
|
||||
then distribution='Fedora'; release='unknown release version'; codename=`cat /etc/fedora-release`
|
||||
else distribution='Redhat'; release='unknown release version'; codename=`cat /etc/redhat-release`
|
||||
fi
|
||||
elif [ -e /etc/fedora-release ]
|
||||
then distribution='Fedora'; release='unknown release version'; codename=`cat /etc/fedora-release`
|
||||
elif [ -e /etc/mandrake-release ]
|
||||
then distribution='Mandrake'; release='unknown release version'; codename=`cat /etc/mandrake-release`
|
||||
fi
|
||||
else
|
||||
lsb=1
|
||||
|
||||
# lsb_release output by example:
|
||||
#
|
||||
# $ lsb_release -i
|
||||
# Distributor ID: Ubuntu
|
||||
#
|
||||
# $ lsb_release -d
|
||||
# Description: Ubuntu 12.04 LTS
|
||||
#
|
||||
# $ lsb_release -r
|
||||
# Release: 12.04
|
||||
#
|
||||
# $ lsb_release -c
|
||||
# Codename: precise
|
||||
|
||||
distribution=`lsb_release -i | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
release=`lsb_release -r | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
codename=`lsb_release -c | awk -F':' '{ gsub(/^[ \t]*/,"",$2); print $2 }'`
|
||||
|
||||
# Some distribution examples:
|
||||
#
|
||||
# OpenSuSE 11.4
|
||||
#LSB Version: n/a
|
||||
#Distributor ID: SUSE LINUX
|
||||
#Description: openSUSE 11.4 (x86_64)
|
||||
#Release: 11.4
|
||||
#Codename: Celadon
|
||||
#
|
||||
# OpenSuSE 12.1
|
||||
#LSB support: 1
|
||||
#Distribution: SUSE LINUX
|
||||
#Release: 12.1
|
||||
#Codename: Asparagus
|
||||
#
|
||||
# Arch
|
||||
#LSB Version: n/a
|
||||
#Distributor ID: archlinux
|
||||
#Description: Arch Linux
|
||||
#Release: rolling
|
||||
#Codename: n/a
|
||||
#
|
||||
# Ubuntu 12.04
|
||||
#Distributor ID: Ubuntu
|
||||
#Description: Ubuntu 12.04 LTS
|
||||
#Release: 12.04
|
||||
#Codename: precise
|
||||
fi
|
||||
|
||||
architecture=`uname -m`
|
||||
# Included from shared functions
|
||||
detect_system
|
||||
|
||||
echo 'We have detected the following system:'
|
||||
echo ' [ '"$distribution"' ] [ '"$release"' ] [ '"$codename"' ] [ '"$architecture"' ]'
|
||||
|
@ -122,7 +56,7 @@ unsupported_distribution () {
|
|||
echo ''
|
||||
echo 'Please report a bug at http://bugs.megaglest.org providing the following information:'
|
||||
echo '--- snip ---'
|
||||
echo 'SVN version: '"$gitcommit"
|
||||
echo 'Git revision: '"$gitcommit"
|
||||
echo 'LSB support: '"$lsb"
|
||||
echo 'Distribution: '"$distribution"
|
||||
echo 'Release: '"$release"
|
||||
|
@ -139,7 +73,7 @@ unsupported_release () {
|
|||
echo ''
|
||||
echo 'Please report a bug at http://bugs.megaglest.org providing the following information:'
|
||||
echo '--- snip ---'
|
||||
echo 'SVN version: '"$gitcommit"
|
||||
echo 'Git revision: '"$gitcommit"
|
||||
echo 'LSB support: '"$lsb"
|
||||
echo 'Distribution: '"$distribution"
|
||||
echo 'Release: '"$release"
|
||||
|
@ -160,7 +94,7 @@ error_during_installation () {
|
|||
echo ''
|
||||
echo 'Please report a bugs at http://bugs.megaglest.org providing the following information:'
|
||||
echo '--- snip ---'
|
||||
echo 'SVN version: '"$gitcommit"
|
||||
echo 'Git revision: '"$gitcommit"
|
||||
echo 'LSB support: '"$lsb"
|
||||
echo 'Distribution: '"$distribution"
|
||||
echo 'Release: '"$release"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Use this script to install build dependencies on a number of Linux platforms
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@ -6,28 +6,56 @@
|
|||
# Rewritten by Tom Reynolds <tomreyn@megaglest.org>
|
||||
# Copyright (c) 2012 Mark Vejvoda, Tom Reynolds under GNU GPL v3.0
|
||||
|
||||
SCRIPTDIR="$(dirname $(readlink -f $0))"
|
||||
|
||||
# Load shared functions
|
||||
. $SCRIPTDIR/../../../mk/linux/mg_shared.sh
|
||||
|
||||
echo 'Downloading Javascript libraries...'
|
||||
wget http://code.jquery.com/jquery-1.5.2.js -O media/jquery-1.5.min.js
|
||||
wget http://www.datatables.net/download/build/jquery.dataTables.min.js -O media/jquery.dataTables.min.js
|
||||
|
||||
echo 'Installing dependencies...'
|
||||
# This should actually use /etc/issue
|
||||
if [ -f /etc/fedora-release ]; then
|
||||
echo 'Fedora...'
|
||||
#sudo yum groupinstall "Development Tools"
|
||||
#sudo yum install subversion automake autoconf autogen jam
|
||||
elif [ -f /etc/SuSE-release ]; then
|
||||
echo '(Open)SuSE...'
|
||||
sudo zypper install graphviz-perl perl-GraphViz perl-Config-IniFiles perl-PerlMagick
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
echo 'Debian / Ubuntu...'
|
||||
sudo apt-get install perl graphviz libgraphviz-perl libconfig-inifiles-perl perlmagick
|
||||
#sudo apt-get install libimage-size-perl
|
||||
else
|
||||
echo 'ERROR: Unknown distribution. Stopping here.' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo 'Detecting system and installing dependencies...'
|
||||
# Included from shared functions
|
||||
detect_system
|
||||
|
||||
echo 'We have detected the following system:'
|
||||
echo ' [ '"$distribution"' ] [ '"$release"' ] [ '"$codename"' ] [ '"$architecture"' ]'
|
||||
|
||||
|
||||
case $distribution in
|
||||
SuSE|SUSE?LINUX|Opensuse)
|
||||
case $release in
|
||||
*)
|
||||
echo '(Open)SuSE...'
|
||||
sudo zypper install graphviz-perl perl-GraphViz perl-Config-IniFiles perl-PerlMagick
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
Fedora)
|
||||
case $release in
|
||||
*)
|
||||
echo 'Fedora...'
|
||||
#sudo yum groupinstall "Development Tools"
|
||||
#sudo yum install subversion automake autoconf autogen jam
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
Debian|Ubuntu|LinuxMint)
|
||||
case $release in
|
||||
*)
|
||||
echo 'Debian / Ubuntu...'
|
||||
sudo apt-get install perl graphviz libgraphviz-perl libconfig-inifiles-perl perlmagick
|
||||
#sudo apt-get install libimage-size-perl
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo 'ERROR: Unknown distribution. Stopping here.' >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
echo ''
|
||||
echo 'To run the techtree html builder edit mg.ini and run the script as follows:'
|
||||
echo 'To create techtree HTML pages copy / edit megapack.ini and run the script:'
|
||||
echo './convert_faction_xml2html.pl megapack.ini'
|
||||
|
|
Loading…
Reference in New Issue