Board index FlightGear Development New features

Ubuntu Aircraft Packages

Discussion and requests for new features. Please note that FlightGear developers are volunteers and may or may not be able to consider these requests.

Ubuntu Aircraft Packages

Postby Chris10 » Tue Apr 13, 2010 10:04 am

This is following up from this post I made. My aim was to package all flightgear aircraft for ubuntu so that they can be installed easily. This is the first time I have used bash and the Debian packaging system. I thought the best way of doing this would be to write a bash script to take a aircraft in the .zip archive and convert it to a ubuntu source/binary package. This can then be uploaded to repository's/ppa's or just installed as a deb.

I have a working script (when the package is installed it puts the aircraft files in the right directory), but the package metadata (version, copyright, etc...) is incomplete/wrong. I used this script to create the packages in my Flightgear Aircraft PPA. These are only testing packages and should not be used on a stable system as I have done very little testing myself.

Unfortunately I am going to be very busy over the next few months and while I hope to develop this further, I will have no time to do so, however I feel I have got off to a good start and this could now be continued by others. I have attached the full script to this post.

To further this the script needs to be improved by someone with some experience maintaining debian/ubuntu packages and its my aim that a ppa similar to mine can be created on the flghtgear project in launchpad for use by everyone.

Chris
Chris10
 
Posts: 40
Joined: Tue Sep 22, 2009 7:27 pm

Re: Ubuntu Aircraft Packages

Postby Chris10 » Sun Jul 04, 2010 12:46 pm

I have now completed my second version of this, I now have in my launchpad ppa packages for all the flightgear aircraft. These are available for ubuntu users (lucid or maverick) and allow the installation of aircraft by the apt system. This is far superior to having to download, unpack and move the aircraft files yourself.

In contrast to the previous version it makes a good guess at the version, copyright and other metadata whilst building the package.

The packages are named "fgfs-aircraft-X" where X is the aircraft name that you would use with flightgear to use that plane. For instance the English Electric Lightning would be installed by running apt-get install fgfs-aircraft-lightning. For more details visit my ppa.

This is the new copy of the python script used to generate the packages.
Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Name: fgfs-apc stands for FlightGear Flight Simulator - Aircraft Package Creator
# Usage: execute in the directory contianing the .zip aircraft files, and packages will be made and uploaded to launchpad
# TODO: command line options (target file, ppa name, source or binary package, etc)

from xml.dom import minidom
import os, os.path, re, sys, zipfile, datetime, commands

for filename in os.listdir (os.getcwd()):
   if re.search('.zip', filename) is not None:

      date = datetime.datetime.now()
      dateRFC822 = commands.getoutput('date -R')
      #print 'Date: '+dateRFC822
      #print date.strftime('%a, %d %b %Y %H:%M:%S %z')

      packagingDirectory=os.getcwd()+'/'

      aircraftName=''
      for part in range(len(re.split('_',filename))-1):
         if part>0:
            aircraftName=aircraftName+'_'
         aircraftName=aircraftName+re.split('_',filename)[part]
            
      
      packageSourceDirectory=packagingDirectory+'fgfs-aircraft-'+aircraftName.lower()+'/'
      os.mkdir(packageSourceDirectory)

      #print 'Processing ' + aircraftName
      zfobj = zipfile.ZipFile(filename)
      for name in zfobj.namelist():
         if name.endswith('/'):
            os.mkdir(os.path.join(packageSourceDirectory, name))
         else:
            outfile = open(os.path.join(packageSourceDirectory, name), 'wb')
            outfile.write(zfobj.read(name))
            outfile.close()
      # Parse set.xml
      aircraftDirectory = packageSourceDirectory+aircraftName+'/'

      description = None
      aircraftVersion = None
      status = None
      author = None

      for filename in os.listdir (aircraftDirectory):
         if re.search('-set.xml', filename) is not None:
            print 'Using ' + filename
            try:
               xmldoc = minidom.parse(aircraftDirectory+filename)
               print 'Using ' + filename
               break
            except Exception:
               print 'Found bad file ' + filename

      while xmldoc is not None:

         #print xmldoc.toxml()
 
         if len(xmldoc.getElementsByTagName('description')) == 1 and description is None:
            try:
               description = xmldoc.getElementsByTagName('description')[0].firstChild.nodeValue
               #print 'Description: '+description
            except Exception:
               print 'Error parsing description'

         if len(xmldoc.getElementsByTagName('aircraft-version')) == 1 and aircraftVersion is None:
            try:
               aircraftVersion = xmldoc.getElementsByTagName('aircraft-version')[0].firstChild.nodeValue
               #print 'Version: '+aircraftVersion
            except Exception:
               print 'Error parsing version'

         if len(xmldoc.getElementsByTagName('status')) == 1 and status is None:
            try:
               status = xmldoc.getElementsByTagName('status')[0].firstChild.nodeValue
               #print 'Status: '+status
            except Exception:
               print 'Error parsing status'

         if len(xmldoc.getElementsByTagName('author')) == 1 and author is None:
            try:
               author = xmldoc.getElementsByTagName('author')[0].firstChild.nodeValue
               #print 'Author: '+author
            except Exception:
               print 'Error parsing author'

         if len(xmldoc.getElementsByTagName('PropertyList')) == 1:
            if len(xmldoc.getElementsByTagName('PropertyList')[0].attributes) != 0:
               try:
                  xmldoc = minidom.parse(aircraftDirectory+xmldoc.getElementsByTagName('PropertyList')[0].attributes["include"].value)
                  print 'Using ' + filename
               except Exception:
                  xmldoc = None
                  print 'Found bad file ' + filename
            else:
               #print 'Finished parsing metadata'
               xmldoc = None

      if aircraftVersion is None:
         aircraftVersion = str(0.1)
      aircraftFullVersion = aircraftVersion+'-0ppa4'

      if description is None:
         description = aircraftName + 'aircraft model for the Flightgear Flight Simulator'

      if status is None:
         status='alpha'

      if author is None:
         author='Unknown'

      os.rename(packageSourceDirectory,packagingDirectory+'/fgfs-aircraft-'+aircraftName.lower()+'-'+aircraftVersion)
      packageSourceDirectory = packagingDirectory+'/fgfs-aircraft-'+aircraftName.lower()+'-'+aircraftVersion+'/'
      aircraftDirectory=packageSourceDirectory+aircraftName+'/'

      os.system('tar -caf "fgfs-aircraft-'+aircraftName.lower()+'_'+aircraftVersion+'.orig.tar.gz" '+
               '"fgfs-aircraft-'+aircraftName.lower()+'-'+aircraftVersion+'"')

      os.mkdir(packageSourceDirectory+'debian/')

      controlFile = open(packageSourceDirectory+'/debian/control', 'w')
      controlFile.write('Source: fgfs-aircraft-'+aircraftName.lower()+'\n'+
                        'Section: games\n'+
                        'Priority: optional\n'+
                        'Maintainer: Christopher Baines <cbaines8@gmail.com>\n'+
                        'Standards-Version: 3.8.4\n'+
                        'Build-Depends: debhelper (>= 7)\n'+
                        'Homepage: http://www.flightgear.org\n'+
                        '\n'+
                        'Package: fgfs-aircraft-'+aircraftName.lower()+'\n'+
                        'Section: games\n'+
                        'Depends: fgfs-base, ${misc:Depends}\n'+
                        'Architecture: all\n'+
                        'Description: ' +description + '\n'+
                        ' For use with the Flightgear Flight Simulator\n'+
                        ' Status: '+status
                        )
      controlFile.close()

      copyrightFile = open(packageSourceDirectory+'/debian/copyright', 'w')
      copyrightFile.write('This work was packaged for Debian by:\n'+
                        '   Chris Baines <cbaines8@gmail.com> on '+str(dateRFC822)+'\n'+
                        '\n'+
                        'It was downloaded from:\n'+
                        '   http://www.flightgear.org/\n'+
                        '\n'+
                        'Upstream author:\n'+
                        '   '+author+'\n'+
                        '\n'+
                        'License:\n'+
                        '   Licence infomation can be found in the '+aircraftName+' directory\n'+
                        '\n'+
                        'The Debian packaging is:\n'+
                        '   Copyright (C) '+str(date.year)+' Chris Baines <cbaines8@gmail.com>\n'+
                        '   You can redistribute it and/or modify\n'+
                        '   it under the terms of the GNU General Public License as published by\n'+
                        '   Free Software Foundation; either version 2 of the License, or\n'+
                        '   (at your option) any later version.\n')
      copyrightFile.close()

      changelogFile = open(packageSourceDirectory+'/debian/changelog', 'w')
      changelogFile.write('fgfs-aircraft-'+aircraftName.lower()+' ('+aircraftFullVersion+') maverick; urgency=low\n'+
                        '\n'+
                        '  * Initial release\n'+
                        '\n'+
                        ' -- Christopher Baines <cbaines8@gmail.com>  '+str(dateRFC822)
                        )
      changelogFile.close()

      rulesFile = open(packageSourceDirectory+'/debian/rules', 'w')
      rulesFile.write('#!/usr/bin/make -f\n'+
                     '\n'+
                     'clean:\n'+
                     '\n'+
                     'install:\n'+
                     '   dh_installdirs -i\n'+
                     '\n'+
                     'build:\n'+
                     '\n'+
                     'binary-indep: install\n'+
                     '   dh_testdir -i\n'+
                     '   dh_testroot -i\n'+
                     '   dh_fixperms -i\n'+
                     '   dh_installdeb -i\n'+
                     '   dh_install -i\n'+
                     '   dh_gencontrol -i\n'+
                     '   dh_md5sums -i\n'+
                     '   dh_builddeb -i\n'+
                     '\n'+
                     '\n'+
                     'binary-arch:\n'+
                     '\n'+
                     'binary: binary-indep\n'+
                     '\n'
                     )
      rulesFile.close()

      installFile = open(packageSourceDirectory+'/debian/install', 'w')
      installFile.write(aircraftName+'/    /usr/share/games/FlightGear/Aircraft/\n')
      installFile.close()

      compatFile = open(packageSourceDirectory+'/debian/compat', 'w')
      compatFile.write('7\n')
      compatFile.close()

      os.chdir(packageSourceDirectory)
      # -S build source package
      os.system('debuild -S')
      os.chdir(packagingDirectory)
      print os.system('dput -s ppa:cbaines/fgfs-aircraft "fgfs-aircraft-'+aircraftName.lower()+'_'+aircraftFullVersion+'_source.changes"')


Chris
Last edited by Chris10 on Mon Jul 05, 2010 9:33 pm, edited 2 times in total.
Chris10
 
Posts: 40
Joined: Tue Sep 22, 2009 7:27 pm

Re: Ubuntu Aircraft Packages

Postby simbabeat » Sun Jul 04, 2010 5:08 pm

Why not just use GIT on ubuntu to get them? we already have that script.
User avatar
simbabeat
 
Posts: 3408
Joined: Sat Sep 12, 2009 12:19 am

Re: Ubuntu Aircraft Packages

Postby Chris10 » Sun Jul 04, 2010 6:05 pm

Because ubuntu and debian use an apt system to manage system components, this is integrated in to the operating system. I was experimenting with extending flightgear's integration with ubuntu.

I have never used the method you talk about, but I think on many points the debian way is superior. Firstly its the standard and using it makes the users life easier. It also allows for integration with all the other system components, like the software centre or synaptic. I think also it offers more functionality, when you upgrade your system you will get the flightgear upgrades as well, no messing around with version's. I was looking at experimenting with a user friendly way of doing it (point and click), not a developer level script.

Installation of flightgear is done by apt, so installation of flightgear addons/components should be done by apt, or problems with upgrades, removals and re-installations will start to occur.

Chris
Chris10
 
Posts: 40
Joined: Tue Sep 22, 2009 7:27 pm

Re: Ubuntu Aircraft Packages

Postby Oby » Sun Jul 04, 2010 10:03 pm

Fantastisc work! I hope you can evolve this further, and include FGFS, FGRUN and Atlas in your PPA :)
Oby
 
Posts: 28
Joined: Mon Jun 14, 2010 8:39 pm

Re: Ubuntu Aircraft Packages

Postby Sealbhach » Mon Jul 05, 2010 1:26 am

This sounds like a great idea Chris. It will be very helpful to newcomers.

.
Sealbhach
 
Posts: 934
Joined: Wed Jun 30, 2010 9:17 am

Re: Ubuntu Aircraft Packages

Postby Canseco » Mon Jul 05, 2010 10:38 am

Great adition. I have a ppa and wanted to make debs of 2.0.0 git and fgo.

Thx for your efforts.
System specs:
AMD Ahtlon 64 X2 Dual Core 2.2 GHz, ASUS M2N4-SLI,3 GB DDR2 800 MHz
Nvidia GT240 1GB 1440x900, 25-30 fps
Canseco
 
Posts: 194
Joined: Wed Jan 06, 2010 12:53 pm
Callsign: Canseco
Version: Git
OS: GNU/Linux

Re: Ubuntu Aircraft Packages

Postby Chris10 » Mon Jul 05, 2010 4:08 pm

I am part way through building debs for flightgear, the flightgear base package, fgrun and some of the scenery. I hope to have the stable packages and daily builds on my ppa soon. In the end I hope to add these packages properly to debian, but I want to improve my understanding before then. I will upload the packaging script asap.

Chris
Chris10
 
Posts: 40
Joined: Tue Sep 22, 2009 7:27 pm

Re: Ubuntu Aircraft Packages

Postby Oby » Wed Jul 14, 2010 8:53 am

Fantastic! Be sure to give us a word when this is uploaded to your PPA :) I would be more than happy to help out by testing these packages, seeing as I am a full time ubuntu user that's tired of using Git.
Oby
 
Posts: 28
Joined: Mon Jun 14, 2010 8:39 pm

Re: Ubuntu Aircraft Packages

Postby Groucho » Wed Jul 14, 2010 9:12 am

Chris10 wrote:I am part way through building debs for flightgear, the flightgear base package, fgrun and some of the scenery. I hope to have the stable packages and daily builds on my ppa soon. In the end I hope to add these packages properly to debian, but I want to improve my understanding before then. I will upload the packaging script asap.


Please consider for the daily builds that often dependent packages will have to be updated also. This mostly affects simgear (quite often) and OpenSceneGraph (not that often, but frequently).
I often encounter situations where OSG, simgear, flightgear and the base packages are out of sync after updating from GIT. This might also lead to cases where the aircraft packages from your PPA are installed but may not fit the daily build development state.
Best would indeed be to package everything from the GIT repository (including aircrafts which are in the base repo).
_____________________________________
Callsign: D-HARP
Flight locations: TNCM, TKPK, EDNY, LOWI
Aircrafts
Helis: EC130, Bo105, UH-1, R22
Twins/Jets: Aerostar, CRJ-200
User avatar
Groucho
 
Posts: 1212
Joined: Sun Jun 17, 2007 10:28 am
Location: Airborne Lake Constance/Germany
Callsign: D-HARP
Version: GIT
OS: Kubuntu

Re: Ubuntu Aircraft Packages

Postby ethan3391 » Wed Jul 14, 2010 9:31 pm

This is going to be awesome.

I now use Ubuntu 10.04 about 99% of the time and I can't wait to be able to install the latest snapshots of FlightGear to this computer through apt-get. Not to mention the ability to update it with update manager.

Some people have been talking about an fgrun for linux, but the last time I had FG on my Ubuntu machine it used a command line input. Have they made an FGRun for Linux now?
What one fool can do, another can. (simian proverb published in the book, Calculus Made Easy by, Silvanus P. Thompson)
ethan3391
 
Posts: 183
Joined: Fri Jul 04, 2008 11:21 pm
Location: Ga, USA

Re: Ubuntu Aircraft Packages

Postby Oby » Wed Jul 14, 2010 9:34 pm

Yes, Fgrun also exists on Linux. And, from what has been posted previously in this thread, it will be packaged in the PPA :)
Oby
 
Posts: 28
Joined: Mon Jun 14, 2010 8:39 pm

Re: Ubuntu Aircraft Packages

Postby ethan3391 » Wed Jul 14, 2010 11:02 pm

Glad to hear it. That will make it a lot easier to work flightgear. I repeat, this is going to be awesome!!!!!
What one fool can do, another can. (simian proverb published in the book, Calculus Made Easy by, Silvanus P. Thompson)
ethan3391
 
Posts: 183
Joined: Fri Jul 04, 2008 11:21 pm
Location: Ga, USA

Re: Ubuntu Aircraft Packages

Postby Hooray » Thu Jul 15, 2010 8:29 pm

Oby wrote:Yes, Fgrun also exists on Linux. And, from what has been posted previously in this thread, it will be packaged in the PPA :)


umm, fgrun has been around for like at least 7-8 years I think, if not longer.
And it being based on FLTK, it has also worked under Linux ever since...

It's really not that fgrun is in any way windows specific.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12173
Joined: Tue Mar 25, 2008 8:40 am

Re: Ubuntu Aircraft Packages

Postby ethan3391 » Thu Jul 15, 2010 9:33 pm

As I said after your other post FGRun was not implemented on Linux until apparently very recently. Prior to some recent date, FGRun was not on any Linux distributions of FlightGear. You haven't run FG on Linux for long, have you.
What one fool can do, another can. (simian proverb published in the book, Calculus Made Easy by, Silvanus P. Thompson)
ethan3391
 
Posts: 183
Joined: Fri Jul 04, 2008 11:21 pm
Location: Ga, USA

Next

Return to New features

Who is online

Users browsing this forum: No registered users and 1 guest