Avoiding multiple downloads of FGData on Linux

From FlightGear wiki
Revision as of 17:11, 25 May 2013 by Callahanp (talk | contribs) (cleanup and final wording edits.)
Jump to navigation Jump to search

download_and_compile.sh can build either the next/master branch, or the stable version of flightgear.

When building different versions of flightgear, its important to note that each version has its own version of fgdata, and flightgear will check the version to ensure it is compatible.

Since fgdata is so large, it makes sense to download the whole thing only once. You can keep versions of it separately from the install tree that download_and_compile.sh creates and create symbolic links to them before using the script. That way when you decide to rebuild from scratch, at least the fgdata will remain.

The instructions below tell how to do this for existing or new uses of download_and_compile.sh. The tecnical details are not dependent on where you put your builds. You can use the directory scheme I use or your own existing scheme.

The concept as a whole works great. I've been using it for months. The instructions are a work in progress and have yet to be fully tested. The initial use case may have a bug related to allowing fgdata to be created through a link. I'm not sure that will work. I may need to tweak the initial directions.

The main ideas

  • you may only need one copy of each version of fgdata you are working with
  • fgdata normally lives as a sub-directory in install/fgfs/
  • install/fgdata can be a symbolic link to fgdata's real directory location

Technical Points and command examples

  • mkdir -p install/fgfs will create the install directory and subdirectory if either does not yet exist
  • mv can move a directory
  • cp -R will copy a directory recursively.
  • ln -s targetname linkname creates linkname as a symbolic link to the target. The target may or may not yet exist and that's ok.
  • Important: You can move the flightgear source directories and download_and_compile.sh to different folders at will. Git will not care. All the git specific files move right along with the sources. Its the same for svn. However, the same does not hold true for the files created during a build by cmake. The build and install folders cannot be moved because the files in them have hard coded paths in some cases. They'll need to be deleted and rebuilt.

Background info

I do my builds of different versions and options in separate sub-directories under ~/work/fg. Sometimes I'll create an extra tree for debugging purposes. I don't want to have to copy all of fgdata just to do the work on a debug version. I also copy the sources for the various components to avoid re downloading those as well. In download_and_compile.sh, Git takes care of any changes needed to switch to between master and stable as needed.

Here's how I handle fgdata..

Normally fgdata lands in install/fgfs. I've moved my 2.10.0 and 2.11.0 fgdata versions and replaced them with symbolic links to the new location as needed. Its as simple as that.

Detailed directions:

1. Create a directory for each version of fgdata you are going to use

mkdir -p ~/work/fg/fgdata_2.10.0
mkdir -p ~/work/fg/fgdata_2.11.0

Eventually a particular version of fgdata will be in ~/work/fg/fgdata_2.10.0/fgdata. Do not create an empty ~/work/fg/fgdata_2.10.0/fgdata. Git will do that for you when necessary.

2. Create a directory for each version or variation of flightgear you want to build.

download_and_compile.sh will be run from these directories

Mine are sub-directories of ~/work/fg for example:

mkdir -p ~/work/fg/master
mkdir -p ~/work/fg/stable
mkdir -p ~/work/fg/master_debug
mkdir -p ~/work/fg/master_debug_rti

Note that I never build at the ~/work/fg level. download_and_compile.sh is always run from a sub-directory

3. Ensure that there is an install/fgfs for each build directory.

mkdir -p ~/work/fg/master/install/fgfs
mkdir -p ~/work/fg/stable/install/fgfs
mkdir -p ~/work/fg/master_debug/install/fgfs
mkdir -p ~/work/fg/master_debug_rti/install/fgfs

4. Create symbolic links for each of your builds to the appropriate fgdata container.
 The containers do not have to have anything in them, but when you run the script the containers need to exist.

For example:

ln -s /home/userid/work/fg/fgdata_2.10.0/fgdata  ~/work/fg/stable/install/fgfs/fgdata
ln -s /home/userid/work/fg/fgdata_2.11.0/fgdata  ~/work/fg/master/install/fgfs/fgdata

and so forth. If you need to delete your install directory, do so and then recreate using mkdir -p install/fgfs and recreate the link.

5. retrofit prevous use of download_and_compile.sh

Skip this step if you are building for the first time or are starting fresh. If you've used download_and_compile.sh before, you may already have either version of fgdata, its in the install/fgfs directory.

We're going to move it. Not copy it, move it.

From the directory where you ran download_and_compile:

 mv install/fgfs/fgdata ~/work/fg/fgdata_2.11.0
 ln -s /home/userid/work/fg/fgdata_2.11.0/fgdata  install/fgfs/fgdata

If you want to adopt my tree naming scheme, then move the source directories for the various components to the appropriate build directory such as ~/work/fg/master. Note that you cannot move the build and install directories. They'll be rebuilt in the new location. The rebuild is needed because we use Cmake.

Test to see that everything is hooked up.

./download_and_compile.sh FGDATA

(this may not work... you may need to do ALL first. Remove this if it does work)

6. Do you first build of flightgear

Skip this step if you did step 5

If you've never used download_and_compile.sh before you're ready to go.

cp download_and_compile.sh ~/work/fg/master
cd ~/work/fg/master
./download_and_compile.sh ALL

That will build just about everything.

7. Prepare to build another version.
In step 1, we created a spot for two fgdata versions.  So far only one is actually there, fgdata_2.11.0/fgdata.  Lets fix that so we don't have to download another copy for 2.10.0

cd ~/work/fg/fgdata_2.10.0
cp -r ~/work/fg/fgdata_2.11.0 fgdata

That's right, we just made a copy of 2.11.0's fgdata and are calling it 2.10.0.

The next step makes it acutally 2.10.0

cd ~/work/fg/stable
./download_and_compile.sh -s FGDATA

That was easy. There are not all that many differences between 2.10.0 and 2.11.0 so git took care of it quickly and efficiently


8. Build Stable

cd ~/work/fg/stable
cp -R ~/work/fg/master/download_and_compile.sh ./
cp -R ~/work/fg/master/fgfs ./
cp -R ~/work/fg/master/plib ./
cp -R ~/work/fg/master/simgear ./
cp -R ~/work/fg/master/OpenSceneGraph ./
cp -R ~/work/fg/master/fgrun ./
cp -R ~/work/fg/master/fgcom ./
cp -R ~/work/fg/master/fgcomgui ./
ls -lah install/fgfs/fgdata # show the symlink to fgdata
ls  install/fgfs/fgdata # make sure there's something there.

Now you can build stable

./download_and_compile.sh -s ALL

9. Building with options

You can use download_and_compile to build master or stable with various options such as -i for openrti or -g to build a debug version.

You can do that in your master or stable that you just built without these options by deleting the install directories and using the options you want to rebuild with. (remember to redo the link as in step 3 if you delete install/fgfs. The link will go, but ~/work/fgdata_*/fgdata will stay.)

An alternative is to use a separate directory. All that's needed is that link to fgdata before you start.

Three of the download_and_compile.sh options actually build differently.

-i builds with OpenRTI -e builds with –with-eventinput -g builds for debugging

If you create a separate directory with the correct install/fgfs/fgdata symbolic link, you can build either master or stable with any of these options, independently of your main builds in master or stable.

You have choices. You can use the options in ~/work/fg/stable and ~/work/fg/master, or you can do things in separate directories. Whatever suits your purpose.