Board index FlightGear Development

FGUpdate.sh (*NIX Auto GIT downloader / Compiler / Updater)

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

FGUpdate.sh (*NIX Auto GIT downloader / Compiler / Updater)

Postby archy » Fri Jan 19, 2018 4:58 pm

I had this shell script laying around for a year now. I still use it as my main updater from the GIT development branch.

The script will download, compile and install FlightGear.
Later if you wanna update everything , go to same path you run the script first time and execute the script again. It will "git pull" and update everything from all repositories.

I made it mainly to learn some more shell scripting. But maybe someone else also benefit from it.

Repositories it downloads:
flightgear_flightgear
flightgear_simgear
flightgear_fgdata
flightgear_fgaddon (Edit script if dont want to download all aircraft and addons)

Still missing auto install of dependencies because not same on all *nixe'es, but maybe someone will further look into how make it auto-download and install dependencies also.

Code: Select all
#!/usr/bin/bash

alias cls='printf "\033c"'
shopt -s expand_aliases
cls

RED='\033[0;31m'
BLUE='\033[1;34m'
GREEN='\033[0;32m'
PURPLE='\033[0;35m' LIGHTPURPLE='\033[1;35m'
GREY='\033[0;37m' LIGHTGREY='\033[1;37m'
CYAN='\033[0;36m'
ORANGE='\033[0;33m'
YELLOW='\033[1;11m'
WHITE='\033[1;37m'
NOCOLOR='\033[0m'

VERSION="0.1-beta"
AUTHOR="Archy"
DIRECTORY_DEFAULT=$(pwd)/
LANGUAGE_BRANCH_DEVELOPMENT="dev"
LANGUAGE_BRANCH_STABLE="stable"
LANGUAGE_BRANCH_ALTERNATIVE="alt"

# Development repository
REPOSITORY_DEVELOPMENT_SIMGEAR="https://git.code.sf.net/p/flightgear/simgear"
REPOSITORY_DEVELOPMENT_FLIGHTGEAR="https://git.code.sf.net/p/flightgear/flightgear"
REPOSITORY_DEVELOPMENT_FGDATA="https://git.code.sf.net/p/flightgear/fgdata"
REPOSITORY_DEVELOPMENT_FGADDON="https://svn.code.sf.net/p/flightgear/fgaddon/trunk"

# Stable repository
REPOSITORY_STABLE_SIMGEAR=""
REPOSITORY_STABLE_FLIGHTGEAR=""
REPOSITORY_STABLE_FGDATA=""
REPOSITORY_STABLE_FGADDON=""


echo -e "${LIGHTPURPLE}Welcome to FlightGear's remote source installer ${GREEN}${VERSION}${NOCOLOR} by ${GREEN}${AUTHOR}${NOCOLOR}"
echo -e ""
echo -e "${WHITE}Choose you branch${NOCOLOR}${GREY} (Press ENTER for default)${NOCOLOR}"
printf "${CYAN}"
echo -e "${BRANCH_DEVELOPMENT} ${PURPLE}(default)${CYAN}"
echo -e "${BRANCH_STABLE}"
echo -e "${BRANCH_ALTERNATIVE}"
printf "${NOCOLOR}"
printf "branch: "
read branch

if ! [[ $branch == 'dev' ]]
then
   echo -e "${RED}This branch is not yet implemented. Use only dev branch at this moment!${NOCOLOR}"
   echo -e "${ORANGE}Falling back to default branch(${CYAN}dev${NOCOLOR})"
   REMOTE_SIMGEAR=$REPOSITORY_DEVELOPMENT_SIMGEAR
   REMOTE_FLIGHTGEAR=$REPOSITORY_DEVELOPMENT_FLIGHTGEAR
   REMOTE_FGDATA=$REPOSITORY_DEVELOPMENT_FGDATA
   REMOTE_FGADDON=$REPOSITORY_DEVELOPMENT_FGADDON
else
   REMOTE_SIMGEAR=$REPOSITORY_STABLE_SIMGEAR
   REMOTE_FLIGHTGEAR=$REPOSITORY_STABLE_FLIGHTGEAR
   REMOTE_FGDATA=$REPOSITORY_STABLE_FGDATA
   REMOTE_FGADDON=$REPOSITORY_STABLE_FGADDON
fi

echo -e ""
echo -e "${WHITE}Type the full installation path ${GREY}(Press ENTER for default)${NOCOLOR}"
printf "${CYAN}${DIRECTORY_DEFAULT}${NOCOLOR}:"
read install_path

fchar=$(echo ${install_path:0:1})

if [[ $fchar == '/' ]]
then
   DIRECTORY_INSTALL=$install_path
else
   DIRECTORY_INSTALL=$DIRECTORY_DEFAULT$install_path
fi


if ! [ -d $DIRECTORY_INSTALL ]
then
   echo -e ""
   echo -e "${RED}Warning! Installation path${CYAN} $DIRECTORY_INSTALL ${RED}does NOT exist!${NOCOLOR}"
   echo -e ""
   echo -e "${ORANGE}Create install path anyway? Or press ENTER to install in: ${CYAN}($DIRECTORY_DEFAULT)${NOCOLOR}"
   printf "(yes/no/ENTER):"
   read install_option

   case $install_option in
      yes)
         mkdir -p $DIRECTORY_INSTALL
         echo -e "${ORANGE}Installing in directory:  ${CYAN}$DIRECTORY_INSTALL${NOCOLOR}"
         ;;
      no)
         echo -e "${ORANGE}Aborting!"
         exit 0
         ;;
      *)
         DIRECTORY_INSTALL=$DIRECTORY_DEFAULT
         echo -e "${ORANGE}Installing in default directory: ${CYAN}$DIRECTORY_INSTALL${NOCOLOR}"
         ;;
   esac
fi

DIRECTORY_SIMGEAR="${DIRECTORY_INSTALL}flightgear-simgear"
DIRECTORY_FLIGHTGEAR="${DIRECTORY_INSTALL}flightgear-flightgear"
DIRECTORY_FGDATA="${DIRECTORY_INSTALL}flightgear-fgdata"
DIRECTORY_FGADDON="${DIRECTORY_INSTALL}flightgear-fgaddon"

######################## INSTALLING FGDATA ###############################
echo -e "${ORANGE}Installing FGData in directory ${CYAN} $DIRECTORY_FGDATA"

if [ -d "$DIRECTORY_FGDATA" ]
then
   cd $DIRECTORY_FGDATA
        echo -e "${ORANGE}Pulling FGData updates from remote sources ${NOCOLOR}"
   git pull
   echo -e "${GREEN}Pull completed${NOCOLOR}"
else
   echo -e "${ORANGE}Cloning FGData from remote source ${CYAN}($REMOTE_FGDATA)${NOCOLOR}"
#   git clone $REMOTE_FGDATA $DIRECTORY_FGDATA

   echo -e "${GREEN}Installation of FGData completed successfully!${NOCOLOR}"
fi


######################## INSTALLING FGADDON ###############################
echo -e "${ORANGE}Installing FGAddon in directory ${CYAN} $DIRECTORY_FGADDON"

if [ -d "$DIRECTORY_FGADDON" ]
then
   cd $DIRECTORY_FGADDON
        echo -e "${ORANGE}Updating FGAddon from remote sources ${NOCOLOR}"
   svn cleanup
   svn update
   echo -e "${GREEN}Update completed${NOCOLOR}"
else
   echo -e "${ORANGE}Installing FGAddon from remote source ${CYAN}($REMOTE_FGADDON)${NOCOLOR}"
#   svn checkout $REMOTE_FGADDON $DIRECTORY_FGADDON

   echo -e "${GREEN}Installation of FGAddon completed successfully!${NOCOLOR}"
fi


######################### INSTALLING SIMGEAR ###############################
echo -e "${ORANGE}Installing Simgear in directory ${CYAN}$DIRECTORY_SIMGEAR${NOCOLOR}"

if [ -d "$DIRECTORY_SIMGEAR" ]
then
   cd $DIRECTORY_SIMGEAR
        echo -e "${ORANGE}Pulling Simgear updates from remote sources ${NOCOLOR}"
   git pull
   echo -e "${GREEN}Pull completed${NOCOLOR}"
else
   echo -e "${ORANGE}Cloning Simgear from remote source ${CYAN}($REMOTE_SIMGEAR)${NOCOLOR}"
   git clone $REMOTE_SIMGEAR $DIRECTORY_SIMGEAR
   cd $DIRECTORY_SIMGEAR
   mkdir build
fi
cd build
echo -e "${ORANGE}Building, Recompiling and installs Simgear${NOCOLOR}"
cmake ../ -DCMAKE_BUILD_TYPE=Release
make
sudo make install
echo -e "${GREEN}Installation of Simgear completed successfully!${NOCOLOR}"

######################## INSTALLING FLIGHTGEAR ###############################
echo -e "${ORANGE}Installing Flightgear in directory ${CYAN} $DIRECTORY_FLIGHTGEAR"

if [ -d "$DIRECTORY_FLIGHTGEAR" ]
then
   cd $DIRECTORY_FLIGHTGEAR
        echo -e "${ORANGE}Pulling Flightgear updates from remote sources ${NOCOLOR}"
   git pull
   echo -e "${GREEN}Pull completed${NOCOLOR}"
else
   echo -e "${ORANGE}Cloning Flightgear from remote source ${CYAN}($REMOTE_FLIGHTGEAR)${NOCOLOR}"
   git clone $REMOTE_FLIGHTGEAR $DIRECTORY_FLIGHTGEAR
   cd $DIRECTORY_FLIGHTGEAR
   mkdir build
fi
cd build
echo -e "${ORANGE}Building, Recompiling and installs Flightgear${NOCOLOR}"
cmake ../ -DCMAKE_BUILD_TYPE=Release
make
sudo make install
echo -e "${GREEN}Installation of Flightgear completed successfully!${NOCOLOR}"



echo -e ""
echo -e "${YELLOW}Congratulation! FlightGear successfully downloaded, compiled and installed to your system.${NOCOLOR} Please enjoy the Free and Open Source Flight Simulator!"
echo -e ""
archy
 
Posts: 20
Joined: Sun Jan 29, 2017 12:28 am

Re: FGUpdate.sh (*NIX Auto GIT downloader / Compiler / Updat

Postby tonghuix » Sat Jan 20, 2018 3:06 am

Good job!

Could you please merge to this script? https://sourceforge.net/p/flightgear/fg ... compile.sh

Cause it has dependency installing.
FG Manual Chinese Translation https://github.com/tonghuix/getstart-zh
tonghuix
 
Posts: 119
Joined: Sun Nov 29, 2015 6:11 pm
Callsign: CPA112
IRC name: tonghuix
Version: next
OS: Debian Testing

Re: FGUpdate.sh (*NIX Auto GIT downloader / Compiler / Updat

Postby wkitty42 » Sat Jan 20, 2018 3:55 am

the scripts are two different animals... while they do the same thing, they do it in different ways... i would suggest that archy's script might have dependency capability added to it but please don't try to merge the two scripts together... that would be like merging a dog and a cat... they're both animals but...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9148
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: FGUpdate.sh (*NIX Auto GIT downloader / Compiler / Updat

Postby archy » Sat Jan 20, 2018 8:26 pm

Whooh.. I didnt know about there was another similarish script out there. Greate!

Looking at the code of download_and_compile.sh i see that it has the same missing feature of platform independence and that download_and_compile.sh has some close to 1000 lines of code, while FGUpdate.sh is still under 200 lines. And my concept about this script was to keep it short and simple. While also have the choice to pull from other version of flightgear (ex pull version 1.0 and install it) on all *NIX like distributions.

In download_and_compile.sh i see that it has code for auto install of dependencies but only under apt-get (only debian based distros).

But I am looking for some good ideas on how to do this in a "codewise" manner since i still want my script to be simple and easy to read and edit and work on all *NIX platforms.

My initial tought is to pull source code for each dependency from ex github, then auto compile and install everything. But then again will probably have some trouble with versioning?

Another way is pull dependencies from all distrubutions and package managers. But again this will be a lot of urls (sources) to manage and keep up to date with time.

Any ideas on which way is better to go about this?
archy
 
Posts: 20
Joined: Sun Jan 29, 2017 12:28 am


Return to Development

Who is online

Users browsing this forum: No registered users and 8 guests