scripts / flightgear / fgaddon.d /
README
Files with name endind by .hangar are sourced (bash syntax).
Please have a look into the two provided to check how it is done

Each file must contains:
- variable `hangar` definition as an associative array with at least the
  following keys:
    name: the human identifier of the hangar
    url: the url of the remote repository this is the unique identifier for
         each hangar, can't be the same in more than one hangar)
    type: the type of repo (git, svn, ...) at the moment, only git and svn
          repos are known and verified by installation status routine
    path: the local path in which the remote repo (or part of it) is cloned
    active: is the hangar active (1) or not (0) 
    
- function `parse_repo_history` which describes how to get the hangar content
  (initial import and updates)
- function `getfromrepo` which describes how to get
- optional function `on_exit` to describe what to do when exiting the hangar

Some functions are provided by the main script to ease the database management:
- add_record <key> <value>
    this function record the key with the value, these
    keys are intended to be information for aircraft.
    Mandatory keys are:
      name     : the name of the aircraft
      revision : the revision from the repo
      date     : date of the last update
      author   : author of the commit

- get_record [key]
    returns the value recorded for the key if no key is
    provided, prints all the recorded keys in the form:
      key1 = value1
      key2 = value2
      ...  (maybe useful for debugging)

- add_aircraft
    adds aircraft in the database in a buffer table, ready to be
    integrated into the main aircrafts table by using `apply_revision` function.
    If one or more of the mandatory keys as decribed in `add_record` is or are
    missing, the function may exit as an error and the the whole script exits

- add_setxml_for_aircraft <aircraft> <-set.xml file>
    add in special buffer table the -set.xml entry for aircraft
    the trailing "-set.xml" is removed if found

- xmlgetnext
    in a while loop to read the XML content of a file, export $TAG
    (formatted) and $VALUE (not formatted) By design the first couple TAG/VALUE is
    always empty, some files have an unidentified issue that make enter teh while
    loop in an infinite loop.  To avoid this, please use the following syntax:

      unset xmlgetnext_empty_tag
      while xmlgetnext; do
          # PUT HERE YOUR STUFF
      done < /your/xml/file

- sqlite_request <SQLite request>
    perform the request on database (actually in
    a copied database which will be dumped into the original at the end of
    the script).
    Don't touch the original database, and always use this
    wrapper, unless you will lose your changes at the end.
    Moreover this wrapper write in a file /dev/shm/sqlite_request all the
    requests, so it is useful to debug, or just watch what is doing

- apply_revision
    use the buffered tables to feed the main tables with all the
    information it will find by parsing the new or updated aircrafts config files

Some variables are available
- $latest_revision the revision to starts the history remote retrieving,
  defaults to 1

- $tempid a single identifer to create temporary files (useful to get all the
  files generated by the script ending with the same ID)

Enjoy adding your preferred hangar :)