From Joomla! Documentation

I vote for some additional code in the preflight method, since everybody should check against a suitable version prior to install. Here is the code from the v1.6 preflight method example. I will wait for a week, before adding it to the page. Maybe there are suggestions for V2.5, that should be merged into this code, before we publish it. --gorgonz 06:05, 26 May 2012 (CDT)

First we must add some private members to the com_helloWorldInstallerScript class

/*
* The release value to be displayed and checked against throughout this file.
*/private$release='1.0';/*
* Find mimimum required joomla version for this extension. It will be read from the version attribute (install tag) in the manifest file
*/private$minimum_joomla_release='2.5.0';

And here is the implementation

/*
* $parent is the class calling this method.
* $type is the type of change (install, update or discover_install, not uninstall).
* preflight runs before anything else and while the extracted files are in the uploaded temp folder.
* If preflight returns false, Joomla will abort the update and undo everything already done.
*/function preflight($type,$parent){// this component does not work with Joomla releases prior to 2.5// abort if the current Joomla release is older$jversion=new JVersion();// Extract the version number from the manifest. This will overwrite the 1.0 value set above $this->release=$parent->get("manifest")->version;// Find mimimum required joomla version$this->minimum_joomla_release=$parent->get("manifest")->attributes()->version;if(version_compare($jversion->getShortVersion(),$this->minimum_joomla_release,'lt')){
Jerror::raiseWarning(null,'Cannot install com_helloWorld update in a Joomla release prior to '.$this->minimum_joomla_release);returnfalse;}// abort if the component being installed is not newer than the currently installed versionif($type=='update'){$oldRelease=$this->getParam('version');$rel=$oldRelease.' to '.$this->release;if(version_compare($this->release,$oldRelease,'le')){
Jerror::raiseWarning(null,'Incorrect version sequence. Cannot upgrade '.$rel);returnfalse;}}else{$rel=$this->release;}echo'<p>'. JText::_('COM_HELLOWORLD_UPDATE_PREFLIGHT_'.$type.' '.$rel).'</p>';}