Thread: [Abtlinux-svn] SF.net SVN: abtlinux: [259] src/trunk (Page 4)
Status: Alpha
Brought to you by:
eschabell
From: <esc...@us...> - 2006-12-06 19:52:18
|
Revision: 259 http://svn.sourceforge.net/abtlinux/?rev=259&view=rev Author: eschabell Date: 2006-12-06 11:52:18 -0800 (Wed, 06 Dec 2006) Log Message: ----------- Migrated 'cd' calls out of system calls. Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtPackage.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2006-12-06 19:47:46 UTC (rev 258) +++ src/trunk/AbtDownloadManager.rb 2006-12-06 19:52:18 UTC (rev 259) @@ -63,7 +63,8 @@ return true end - if ( systemMgr.runSystemCall( "cd " + destination + "; wget " + package.srcUrl ) ) + Dir.chdir( destination ) + if ( systemMgr.runSystemCall( "wget #{package.srcUrl}" ) ) logger.logToJournal( "Download completed for " + packageName ) return true end Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2006-12-06 19:47:46 UTC (rev 258) +++ src/trunk/AbtPackage.rb 2006-12-06 19:52:18 UTC (rev 259) @@ -81,7 +81,8 @@ #logger = AbtLogManager.new #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) - if ( !systemMgr.runSystemCall( "cd #{$BUILD_LOCATION}; #{unpackTool} #{sourcesToUnpack}" ) ) + Dir.chdir( $BUILD_LOCATION ) + if ( !systemMgr.runSystemCall( "#{unpackTool} #{sourcesToUnpack}" ) ) return false end @@ -234,8 +235,9 @@ # TODO: this should not use tee, but in wrapper deal with stdout to file. # also need to expand directory with @srcDir/@srcDir.configure. - command = "cd #{buildSite}; ./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/{@srcDir}.configure" + command = "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/{@srcDir}.configure" + Dir.chdir( buildSite ) if ( !systemMgr.runSystemCall( command ) ) return false end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-12-07 15:41:14
|
Revision: 264 http://svn.sourceforge.net/abtlinux/?rev=264&view=rev Author: eschabell Date: 2006-12-07 07:41:09 -0800 (Thu, 07 Dec 2006) Log Message: ----------- Changed all tabs to spaces, enables all editors to view code the same way. I finally made this decision for AbTLinux coding standard. Modified Paths: -------------- src/trunk/AbtDepEngine.rb src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb src/trunk/AbtQueueManager.rb src/trunk/AbtReportManager.rb src/trunk/AbtSystemManager.rb src/trunk/AbtUsage.rb src/trunk/abt.rb src/trunk/abtconfig.rb Modified: src/trunk/AbtDepEngine.rb =================================================================== --- src/trunk/AbtDepEngine.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtDepEngine.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtDepEngine.rb +# AbtDepEngine.rb # # AbtDepEngine class handles all dependency aspects of the AbTLinux system. It is # part of a sub-project with it's own requirements document. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,17 +28,17 @@ class AbtDepEngine protected - + private - + public ## # Constructor for the AbtDepEngine class. # - # <b>RETURN</b> <i>AbtDepEngine</i> - an initialized AbtDepEngine object. + # <b>RETURN</b> <i>AbtDepEngine</i> - an initialized AbtDepEngine object. ## def initialize end - + end \ No newline at end of file Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtDownloadManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtDownloadManager.rb +# AbtDownloadManager.rb # # AbtDownloadManager class handles all downloading of components needed for # AbTLinux. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,22 +28,22 @@ class AbtDownloadManager protected - + private - + public ## # Constructor for the AbtDownloadManager class. # - # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized AbtDownloadManager object. + # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized AbtDownloadManager object. ## def initialize end - + ## # Downloads a given package source. If the file already exists, returns - # true as if download completed. + # true as if download completed. # # <b>PARAM</b> <i>String</i> - the name of the package for which the source # is to be downloaded. @@ -53,25 +53,25 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require packageName - logger = AbtLogManager.new - systemMgr = AbtSystemManager.new - package = eval( packageName.capitalize + '.new' ) - - if ( File.exist?( destination + "/" + File.basename( package.srcUrl ) ) ) - logger.logToJournal( "Download not needed, existing source found for " + packageName ) - return true - end + require packageName + logger = AbtLogManager.new + systemMgr = AbtSystemManager.new + package = eval( packageName.capitalize + '.new' ) - Dir.chdir( destination ) - if ( systemMgr.runSystemCall( "wget #{package.srcUrl}" ) ) - logger.logToJournal( "Download completed for " + packageName ) - return true - end + if ( File.exist?( destination + "/" + File.basename( package.srcUrl ) ) ) + logger.logToJournal( "Download not needed, existing source found for " + packageName ) + return true + end - return false # download failed. + Dir.chdir( destination ) + if ( systemMgr.runSystemCall( "wget #{package.srcUrl}" ) ) + logger.logToJournal( "Download completed for " + packageName ) + return true + end + + return false # download failed. end - + ## # Downloads a given pacakge tree. # @@ -82,61 +82,61 @@ ## def retrievePackageTree( packageTreeName ) end - + ## # Retrieves the given feed and displays the news items. # - # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, - # otherwise it will be appended. + # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. + # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, + # otherwise it will be appended. # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been # retrieved, otherwise false. ## def retrieveNewsFeed( uri, cleanLog = "false" ) - require 'net/http' - require 'uri' - require 'rss/1.0' - require 'rss/2.0' - newsLog = "" + require 'net/http' + require 'uri' + require 'rss/1.0' + require 'rss/2.0' + newsLog = "" - # ensure we have our news logfile. - if ( cleanLog == "true" ) - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) - else - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) - end - - # pick up the abtlinux.org news feed. - if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) - logger.logToJournal( "Failed to retrieve news feed #{uri}." ) - return false - end + # ensure we have our news logfile. + if ( cleanLog == "true" ) + newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) + else + newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) + end - # display the feeds. - rss = nil - begin - rss = RSS::Parser.parse(news, false) - rescue RSS::Error - end - - if ( rss.nil? ) - logger.logToJournal( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) - return false - else - newsLog.puts "*** #{rss.channel.title} ***" - - rss.items.each_with_index do |item, itemCount| - itemCount += 1 - newsLog.puts "#{itemCount} #{item.link} #{item.title}" - end - end + # pick up the abtlinux.org news feed. + if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) + logger.logToJournal( "Failed to retrieve news feed #{uri}." ) + return false + end - newsLog.puts "\n" - newsLog.close - return true + # display the feeds. + rss = nil + begin + rss = RSS::Parser.parse(news, false) + rescue RSS::Error + end + if ( rss.nil? ) + logger.logToJournal( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) + return false + else + newsLog.puts "*** #{rss.channel.title} ***" + + rss.items.each_with_index do |item, itemCount| + itemCount += 1 + newsLog.puts "#{itemCount} #{item.link} #{item.title}" + end + end + + newsLog.puts "\n" + newsLog.close + return true + end - + ## # Updates a given package with available patches (version updates). # @@ -147,7 +147,7 @@ ## def updatePackage end - + ## # Updates the package tree. # @@ -156,5 +156,5 @@ ## def updatePackageTree end - + end Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtLogManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtLogManager.rb +# AbtLogManager.rb # # AbtLogManager class handles all aspects of logging and access to existing logs # within the AbTLinux system. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,49 +28,49 @@ class AbtLogManager protected - + ## # Provides logging of the integrity of all installed files for the given # package. Will be called as part of the logging done during the install # phase. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if integrity log created successfully, # otherwise false. ## def logPackageIntegrity( package ) end - - + + private public ## - # Constructor for the AbtLogManager. It ensures all needed logs paths are + # Constructor for the AbtLogManager. It ensures all needed logs paths are # initialized. - # # - # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. + # + # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize - [$ABT_LOGS, $ABT_CACHES, $BUILD_LOCATION, $PACKAGE_INSTALLED, - $SOURCES_REPOSITORY].each { |dir| - - if ( ! File.directory?( dir ) ) - FileUtils.mkdir_p( dir ) - self.logToJournal( "Created directory: #{dir}." ) - end - } - end - + [$ABT_LOGS, $ABT_CACHES, $BUILD_LOCATION, $PACKAGE_INSTALLED, + $SOURCES_REPOSITORY].each { |dir| + + if ( ! File.directory?( dir ) ) + FileUtils.mkdir_p( dir ) + self.logToJournal( "Created directory: #{dir}." ) + end + } + end + ## # Provides logging of all files installed by given package. Should be called # as part of the install phase of the build. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if install log created successfully, # otherwise false. ## @@ -80,9 +80,9 @@ ## # Provides logging of all output produced during the build phase of the # given package. Should be called as part of the install phase of the build. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if build log created successfully, # otherwise false. ## @@ -92,9 +92,9 @@ ## # Provides a complete log of the given packages build. Includes everything # needed to duplicate the build at a later date. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if package cache created successfully, # otherwise false. ## @@ -104,18 +104,18 @@ ## # Provides logging of given message to the AbTLinux journal. Message logged # with date timestamp. - # + # # <b>PARAM</b> <i>String</i> - Message to be added to the log. - # + # # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. ## def logToJournal( message ) - if ( log = File.new( $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) - log.puts "#{$TIMESTAMP} : #{message}" - log.close - return true - end + if ( log = File.new( $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + log.puts "#{$TIMESTAMP} : #{message}" + log.close + return true + end - return false + return false end end Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtPackage.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtPackage.rb +# AbtPackage.rb # # AbtPackage class provides an interface to AbtPackage creation within AbTLinux. By # inheriting from this class (class Fortune < AbtPackage) one picks up all @@ -22,126 +22,126 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtPackage - -protected - - ## - # Unpacks this packages source file into the standard build location. - # + + protected + + ## + # Unpacks this packages source file into the standard build location. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. - ## - def unpackSources - systemMgr = AbtSystemManager.new - srcFile = File.basename( @srcUrl ) - sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" - unpackTool = "" + ## + def unpackSources + systemMgr = AbtSystemManager.new + srcFile = File.basename( @srcUrl ) + sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" + unpackTool = "" - # check for existing file in source repo. - if ( !File.exist?( sourcesToUnpack ) ) - return false - end + # check for existing file in source repo. + if ( !File.exist?( sourcesToUnpack ) ) + return false + end - # check if possible existing sources in build directory. - if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) - return true - end + # check if possible existing sources in build directory. + if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) + return true + end - # determine which supported compression used [gz, tar, tgz, bz2, zip]. - compressionType = srcFile.split( '.' ) + # determine which supported compression used [gz, tar, tgz, bz2, zip]. + compressionType = srcFile.split( '.' ) - case compressionType.last + case compressionType.last - when "gz" - unpackTool = "tar xzvf" + when "gz" + unpackTool = "tar xzvf" - when "tar" - unpackTool = "tar xvf" + when "tar" + unpackTool = "tar xvf" - when "bz2" - unpackTool = "tar xjvf" + when "bz2" + unpackTool = "tar xjvf" - when "tgz" - unpackTool = "tar xzvf" - - when "zip" - unpackTool = "unizp" + when "tgz" + unpackTool = "tar xzvf" - else - # unsupported format. - return false - end - - # DEBUG: - #logger = AbtLogManager.new - #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) + when "zip" + unpackTool = "unizp" - Dir.chdir( $BUILD_LOCATION ) - if ( !systemMgr.runSystemCall( "#{unpackTool} #{sourcesToUnpack}" ) ) - return false - end + else + # unsupported format. + return false + end - return true - end + # DEBUG: + #logger = AbtLogManager.new + #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) -private - -public - + Dir.chdir( $BUILD_LOCATION ) + if ( !systemMgr.runSystemCall( "#{unpackTool} #{sourcesToUnpack}" ) ) + return false + end + + return true + end + + private + + public + # the name of the package. attr_reader :name - + # the executable name for the package. attr_reader :execName - + # the package version number. attr_reader :version - + # the source directory for the package. attr_reader :srcDir - + # the packages homepage. attr_reader :homepage - + # the URL where this packages sources can be obtained. attr_reader :srcUrl - + # list of dependsOn (DO) related package dependencies. attr_reader :dependsOn - + # list of reliesOn (RO) related package dependencies. attr_reader :reliesOn - + # list of optional reliesOn (oRO) related package dependencies. attr_reader :optionalDO # list of optional dependsOn (oDO) related package dependencies. attr_reader :optionalRO - + # security hash value of package sources. attr_reader :hashCheck - + # list of available patches for this package. attr_reader :patches - + # security hash value of this packages patches. attr_reader :patchesHashCheck - + # available mirrors for this package. attr_reader :mirrorPath - + # type of license this package has. attr_reader :licence - + # the package description. attr_reader :description - - + + ## # Constructor for an AbtPackage, requires all the packge details. # @@ -149,118 +149,119 @@ # ## def initialize( data ) - @name = data['name'] - @execName = data['execName'] - @version = data['version'] - @srcDir = data['srcDir'] - @homepage = data['homepage'] - @srcUrl = data['srcUrl'] - @dependsOn = data['dependsOn'] - @reliesOn = data['reliesOn'] - @optionalDO = data['optionalDO'] - @optionalRO = data['optionalRO'] - @hashCheck = data['hashCheck'] - @patches = data['patches'] + @name = data['name'] + @execName = data['execName'] + @version = data['version'] + @srcDir = data['srcDir'] + @homepage = data['homepage'] + @srcUrl = data['srcUrl'] + @dependsOn = data['dependsOn'] + @reliesOn = data['reliesOn'] + @optionalDO = data['optionalDO'] + @optionalRO = data['optionalRO'] + @hashCheck = data['hashCheck'] + @patches = data['patches'] @patchesHashCheck = data['patchesHashCheck'] - @mirrorPath = data['mirrorPath'] - @license = data['license'] - @description = data['description'] + @mirrorPath = data['mirrorPath'] + @license = data['license'] + @description = data['description'] end - + ## # Provides all the data needed for this AbtPackage. # # <b>RETURNS:</b> <i>hash</i> - Contains all AbtPackage attributes (constants). ## def details - return { - "Package name" => @name, - "Executable" => @execName, - "Version" => @version, - "Source location" => @srcDir, - "Homepage" => @homepage, - "Source uri" => @srcUrl, - "Depends On" => @dependsOn, - "Relies On" => @reliesOn, - "Optional DO" => @optionalDO, - "Optional RO" => @optionalRO, - "Security hash" => @hashCheck, - "Patches" => @patches, - "Patches hash" => @patchesHashCheck, - "Mirror" => @mirrorPath, - "License" => @license, - "Description" => @description - } + return { + "Package name" => @name, + "Executable" => @execName, + "Version" => @version, + "Source location" => @srcDir, + "Homepage" => @homepage, + "Source uri" => @srcUrl, + "Depends On" => @dependsOn, + "Relies On" => @reliesOn, + "Optional DO" => @optionalDO, + "Optional RO" => @optionalRO, + "Security hash" => @hashCheck, + "Patches" => @patches, + "Patches hash" => @patchesHashCheck, + "Mirror" => @mirrorPath, + "License" => @license, + "Description" => @description + } end - + ## - # Preliminary work will happen here such as downloading the tarball, + # Preliminary work will happen here such as downloading the tarball, # unpacking it, downloading and applying patches. # # <b>RETURNS:</b> <i>boolean</i> - True if completes sucessfully, otherwise false. ## def pre - downloader = AbtDownloadManager.new + downloader = AbtDownloadManager.new - # download sources. - if ( !downloader.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) - return false - end + # download sources. + if ( !downloader.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) + return false + end - # unpack sources. - if ( !self.unpackSources ) - return false - end + # unpack sources. + if ( !self.unpackSources ) + return false + end - # TODO: create_group? - # TODO: create_user? - # TODO: retrieve patches? - # TODO: apply patches? - - return true + # TODO: create_group? + # TODO: create_user? + # TODO: retrieve patches? + # TODO: apply patches? + + return true end - + ## - # Here we manage the ./configure step (or equivalent). We need to give ./configure - # (or autogen.sh, or whatever) the correct options so files are to be placed later in the - # right directories, so doc files and man pages are all in the same common location, etc. - # Don't forget too that it's here where we interact with the user in case there are optionnal + # Here we manage the ./configure step (or equivalent). We need to give ./configure + # (or autogen.sh, or whatever) the correct options so files are to be placed later in the + # right directories, so doc files and man pages are all in the same common location, etc. + # Don't forget too that it's here where we interact with the user in case there are optionnal # dependencies. # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def configure - systemMgr = AbtSystemManager.new - buildSite = "#{$BUILD_LOCATION}/#{@srcDir}" + systemMgr = AbtSystemManager.new + buildSite = "#{$BUILD_LOCATION}/#{@srcDir}" - # TODO: this should not use tee, but in wrapper deal with stdout to file. - # also need to expand directory with @srcDir/@srcDir.configure. - #command = "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/{@srcDir}.configure" - command = "./configure --prefix=#{$DEFAULT_PREFIX}" + # TODO: this should not use tee, but in wrapper deal with stdout to file. + # also need to expand directory with @srcDir/@srcDir.configure. + #command = "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/{@srcDir}.configure" + Dir.chdir( buildSite ) + stdin, stdout, stderr = + Open3.popen3( "./configure --prefix=#{$DEFAULT_PREFIX}" ) - Dir.chdir( buildSite ) - stdin, stdout, stderr = Open3.popen3( command ) + # check for errors. + if ( !stderr.eof ) + # TODO: put this in failure file. + puts "DEBUG: [AbtPackage.configure] - stderr:" + puts stderr.read + return false + else + puts "DEBUG: [AbtPackage.configure] - nothing in stderr." + end - # check for errors. - if ( !stderr.eof ) - puts "DEBUG: [AbtPackage.configure] - stderr:" - puts stderr.read - return false - else - puts "DEBUG: [AbtPackage.configure] - nothing in stderr." - end - - # check for output. - if ( !stdout.eof ) - puts "DEBUG: [AbtPackage.configure] - stdout:" - puts stdout.read - else - puts "DEBUG: [AbtPackage.configure] - nothing in stdout." - end - - return true + # check for output. + if ( !stdout.eof ) + # TODO: put this in #{$PACKAGE_INSTALLED}/{@srcDir}.configure. + puts "DEBUG: [AbtPackage.configure] - stdout:" + puts stdout.read + else + puts "DEBUG: [AbtPackage.configure] - nothing in stdout." + end + + return true end - + ## # Here is where the actual builing of the software starts, for example running 'make'. # @@ -268,7 +269,7 @@ ## def build end - + ## # Any actions needed before the installation can occur will happen here, such as creating # new user accounts, dealing with existing configuration files, etc. @@ -285,7 +286,7 @@ ## def install end - + ## # Last bits of installation. adding the service for automatic start in init.d for example. # @@ -294,24 +295,24 @@ def post end - ## - # Cleans up this packages source build directory. - # + ## + # Cleans up this packages source build directory. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. - ## - def removeBuild - if ( $REMOVE_BUILD_SOURCES ) - buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" + ## + def removeBuild + if ( $REMOVE_BUILD_SOURCES ) + buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" - if ( !File.directory?( buildSourcesLocation ) ) - return true - end + if ( !File.directory?( buildSourcesLocation ) ) + return true + end - if ( !FileUtils.rm_rf buildSourcesLocation, :verbose => true ) - return false - end - end + if ( !FileUtils.rm_rf buildSourcesLocation, :verbose => true ) + return false + end + end - return true - end + return true + end end Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtPackageManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtPackageManager.rb +# AbtPackageManager.rb # # AbtPackageManager class will take care of the installation, removal, updating, # downgrading and freezing of AbTLinux software packages. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -36,7 +36,7 @@ ## # Constructor for AbtPackageManager. # - # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized AbtPackageManager object. + # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized AbtPackageManager object. ## def initialize end @@ -50,59 +50,59 @@ # false. ## def installPackage( package ) - require package - sw = eval( "#{package.capitalize}.new" ) - queuer = AbtQueueManager.new - logger = AbtLogManager.new + require package + sw = eval( "#{package.capitalize}.new" ) + queuer = AbtQueueManager.new + logger = AbtLogManager.new - # TODO: initialize pkg install directory ($PACKAGE_INSTALLED/@srcDir), - # should this fail we have to clean this dir up, move to failure - # location? - # On success, need to cache contents in cache dir. - - # get package details. - details = sw.details + # TODO: initialize pkg install directory ($PACKAGE_INSTALLED/@srcDir), + # should this fail we have to clean this dir up, move to failure + # location? + # On success, need to cache contents in cache dir. - # TODO: check deps - - # add to install queue. - if ( !queuer.addPackageToQueue( package, "install" ) ) - logger.logToJournal( "Failed to add #{package} to install queue." ) - return false - end + # get package details. + details = sw.details - # pre section. - if ( !sw.pre ) - logger.logToJournal( "Failed to process pre-section in the package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: finished #{package} pre section." ) - end + # TODO: check deps - # configure section. - if ( !sw.configure ) - logger.logToJournal( "Failed to process configure section in the package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: finished #{package} configure section." ) - end + # add to install queue. + if ( !queuer.addPackageToQueue( package, "install" ) ) + logger.logToJournal( "Failed to add #{package} to install queue." ) + return false + end + # pre section. + if ( !sw.pre ) + logger.logToJournal( "Failed to process pre-section in the package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} pre section." ) + end + + # configure section. + if ( !sw.configure ) + logger.logToJournal( "Failed to process configure section in the package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} configure section." ) + end + # TODO: finish up the following steps per install scenario: - # - # build section - # pre install section - # install section - # post section - # remove build sources. - # - if ( !sw.removeBuild ) - logger.logToJournal( "Failed to remove the build sources for #{package}." ) - #return false # commented out as this is not a reason to fail. - end + # + # build section + # pre install section + # install section + # post section + # remove build sources. + # + if ( !sw.removeBuild ) + logger.logToJournal( "Failed to remove the build sources for #{package}." ) + #return false # commented out as this is not a reason to fail. + end - return true + return true end - + ## # Reinstalls a given package. # @@ -113,7 +113,7 @@ ## def reinstallPackage( package ) end - + ## # Removes a given package. # @@ -124,7 +124,7 @@ ## def removePackage( package ) end - + ## # Downgrades a given package. # @@ -137,7 +137,7 @@ ## def downgradePackage( package, version ) end - + ## # Freezes a given package. If successful will add give package to the frozen # list. @@ -154,22 +154,22 @@ # Provides for a log through for root access using su. # # <b>PARAM</b> <i>Array</i> - the arguments passed to abt. - # + # # <b>RETURN</b> <i>void</i> ## def rootLogin( arguments ) - systemMgr = AbtSystemManager.new + systemMgr = AbtSystemManager.new - if ( Process.uid != 0 ) - args = "" - puts "\nEnter root password:" + if ( Process.uid != 0 ) + args = "" + puts "\nEnter root password:" - for i in 0...ARGV.length - args = args + " " + ARGV[i] - end + for i in 0...ARGV.length + args = args + " " + ARGV[i] + end - systemMgr.runSystemCall( 'su -c "./abt ' + args + '" root' ) - exit - end + systemMgr.runSystemCall( 'su -c "./abt ' + args + '" root' ) + exit + end end end Modified: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtQueueManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtQueueManager.rb +# AbtQueueManager.rb # # AbtQueueManager class handles all AbTLinux queue interaction. # @@ -19,7 +19,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -27,60 +27,60 @@ class AbtQueueManager protected - + private - + public ## # Constructor for the AbtQueueManager class. # - # <b>RETURN</b> <i>AbtQueueManager</i> - an initialized AbtQueueManager object. + # <b>RETURN</b> <i>AbtQueueManager</i> - an initialized AbtQueueManager object. ## def initialize end - - ## - # Add a given package to the given queue. If package already in - # the queue then it will not be added twice and return a positive - # answer. - # - # <b>PARAM</b> <i>String</i> - the package to be added to the queue. - # <b>PARAM</b> <i>String</i> - the queue to add the package to. - # - # <b>RETURN</b> <i>boolean</i> - true if package added/exists to/in install - # queue, otherwise false. - ## - def addPackageToQueue( package, queue ) - queueFile = "#{$ABT_LOGS}/#{queue}.log" - logger = AbtLogManager.new - if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) - # pickup queue contents to ensure no duplicates. - checkingQueue = IO.readlines( queueFile ) + ## + # Add a given package to the given queue. If package already in + # the queue then it will not be added twice and return a positive + # answer. + # + # <b>PARAM</b> <i>String</i> - the package to be added to the queue. + # <b>PARAM</b> <i>String</i> - the queue to add the package to. + # + # <b>RETURN</b> <i>boolean</i> - true if package added/exists to/in install + # queue, otherwise false. + ## + def addPackageToQueue( package, queue ) + queueFile = "#{$ABT_LOGS}/#{queue}.log" + logger = AbtLogManager.new - # endsure no duplicates. - matched = false - checkingQueue.each do |entry| - entryName = entry.split( '|' ) - if ( entryName[0] == package ) - matched = true - end - end - - # check if package exists, otherwise add. - if ( !matched ) - log.puts "#{package}|#{$TIMESTAMP}" - logger.logToJournal( "Added #{package} to #{queue} queue." ) - else - logger.logToJournal( "Did not add #{package} to #{queue}, already exists." ) - end - - log.close - return true - end + if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + # pickup queue contents to ensure no duplicates. + checkingQueue = IO.readlines( queueFile ) - logger.logToJournal( "Failed to open #{queueFile}." ) - return false - end + # endsure no duplicates. + matched = false + checkingQueue.each do |entry| + entryName = entry.split( '|' ) + if ( entryName[0] == package ) + matched = true + end + end + + # check if package exists, otherwise add. + if ( !matched ) + log.puts "#{package}|#{$TIMESTAMP}" + logger.logToJournal( "Added #{package} to #{queue} queue." ) + else + logger.logToJournal( "Did not add #{package} to #{queue}, already exists." ) + end + + log.close + return true + end + + logger.logToJournal( "Failed to open #{queueFile}." ) + return false + end end Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtReportManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtReportManager.rb +# AbtReportManager.rb # # AbtReportManager class handles all sort of report and query generation within # the AbTLinux system. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,15 +28,15 @@ class AbtReportManager protected - + private - + public ## # Constructor for the AbtReportManager. # - # <b>RETURN</b> <i>AbtReportManager</i> - an initialized Report1Manager object. + # <b>RETURN</b> <i>AbtReportManager</i> - an initialized Report1Manager object. ## def initialize end @@ -50,43 +50,43 @@ # false. ## def showPackageDetails( package ) - require package + require package - if ( package = eval( "#{package.capitalize}.new" ) ) - details = package.details + if ( package = eval( "#{package.capitalize}.new" ) ) + details = package.details - puts "|=====================================" - puts "| Package name\t: #{details['Package name']}" - details.delete( "Package name" ) - puts "| Version\t: #{details['Version']}" - details.delete( "Version" ) - puts "| Homepage\t: #{details['Homepage']}" - details.delete( "Homepage" ) - puts "| Executable\t: #{details['Executable']}" - details.delete( "Executable" ) - puts "| Source uri\t: #{details['Source uri']}" - details.delete( "Source uri" ) - puts "| Description\t: #{details['Description']}" - details.delete( "Description" ) - puts "|=====================================" - puts "|=====================================" + puts "|=====================================" + puts "| Package name\t: #{details['Package name']}" + details.delete( "Package name" ) + puts "| Version\t: #{details['Version']}" + details.delete( "Version" ) + puts "| Homepage\t: #{details['Homepage']}" + details.delete( "Homepage" ) + puts "| Executable\t: #{details['Executable']}" + details.delete( "Executable" ) + puts "| Source uri\t: #{details['Source uri']}" + details.delete( "Source uri" ) + puts "| Description\t: #{details['Description']}" + details.delete( "Description" ) + puts "|=====================================" + puts "|=====================================" - details.each do |name, value| - print "| #{name}\t" - - if ( name.length < 14 ) - print "\t" - end + details.each do |name, value| + print "| #{name}\t" - puts ": #{value}" - end + if ( name.length < 14 ) + print "\t" + end - puts "|=====================================" - return true - end + puts ": #{value}" + end - logger.logToJournal( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) - return false + puts "|=====================================" + return true + end + + logger.logToJournal( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) + return false end ## @@ -108,9 +108,9 @@ # <b>RETURN</b> <i>void.</i> ## def showPackageLog( package, logType ) - # install log - # build log - # integrity log + # install log + # build log + # integrity log end ## @@ -131,7 +131,7 @@ # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise # hash of problem files and their encountered errors. ## - def showPackageDependencies( package ) + def showPackageDependencies( package ) end ## @@ -143,31 +143,31 @@ ## def showUntrackedFiles end - + ## # Display the AbTLinux journal file. # - # <b> PARAM</b> <i>string</i> The complete path of the file to display. - # + # <b> PARAM</b> <i>string</i> The complete path of the file to display. + # # <b>RETURN</b> <i>iboolean</i> True if journal shown, otherwise false. ## def showJournal( fileName ) - if ( File.exist?( fileName ) ) - puts "\n\n" - puts "AbTLinux log:" - puts "=============" - log = IO.readlines( fileName ) - log.each{ |entry| puts entry } - puts "\n\n" - else - puts "\n\n" - puts "AbtLinux log ( #{File.basename( fileName )} ) is empty at this time." - puts "\n\n" - end + if ( File.exist?( fileName ) ) + puts "\n\n" + puts "AbTLinux log:" + puts "=============" + log = IO.readlines( fileName ) + log.each{ |entry| puts entry } + puts "\n\n" + else + puts "\n\n" + puts "AbtLinux log ( #{File.basename( fileName )} ) is empty at this time." + puts "\n\n" + end - return true + return true end - + ## # Display the name of the package(s) that own the given file. # @@ -177,11 +177,11 @@ ## def showFileOwner( file ) end - + ## # Searches the installed package trees package descriptions for matching # occurrances of the given search text. - # + # # <b>PARAM</b> <i>String</i> - a search text. # # <b>RETURN</b> <i>hash</i> - a hash of the search results, keys are package @@ -192,39 +192,39 @@ ## # Displays the contents of the current queue based on the given queue. - # + # # <b>PARAM</b> <i>String</i> - the type of queue to display such as install # queue. # # <b>RETURN</b> <i>void.</i> ## def showQueue( queueType ) - queueFile = "#{$ABT_LOGS}/#{queueType}.log" - case queueType + queueFile = "#{$ABT_LOGS}/#{queueType}.log" + case queueType - when "install" - if ( File.exist?( queueFile ) ) - puts "\n\n" - puts "AbTLinux #{queueType} queue:" - puts "=======================" - queue = IO.readlines( queueFile ) - queue.each{ |entry| puts entry } - puts "\n\n" - else - puts "\n\n" - puts "AbtLinux #{queueType} is empty at this time." - puts "\n\n" - end + when "install" + if ( File.exist?( queueFile ) ) + puts "\n\n" + puts "AbTLinux #{queueType} queue:" + puts "=======================" + queue = IO.readlines( queueFile ) + queue.each{ |entry| puts entry } + puts "\n\n" + else + puts "\n\n" + puts "AbtLinux #{queueType} is empty at this time." + puts "\n\n" + end - else - puts "#{queueType.capitalize} is not an AbTLinux queue." - end + else + puts "#{queueType.capitalize} is not an AbTLinux queue." + end end ## # Reports available updates for a given package or package tree based on the # current system. - # + # # <b>PARAM</b> <i>String</i> - the target of the update check, either a # package name or a package tree name. # @@ -233,10 +233,10 @@ ## def showUpdates( target ) end - + ## # Generates an HTML page of installed packages from installed packages list. - # + # # <b>RETURN</b> <i>void.</i> ## def generateHTMLPackageListing Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtSystemManager.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtSystemManager.rb +# AbtSystemManager.rb # # AbtSystemManager class handles all aspects of the AbTLinux system. It takes # care of such tasks as cleanup, fixing, verification and management of @@ -21,7 +21,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,15 +29,15 @@ class AbtSystemManager protected - + private - + public ## # Constructor for the System manager # - # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized AbtSystemManager object. + # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized AbtSystemManager object. ## def initialize end @@ -45,7 +45,7 @@ ## # Removes all sources for packages that are not currently installed. Makes # use of install listing to determine package sources to keep. - # + # # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise # false. ## @@ -54,7 +54,7 @@ ## # All logs for packages not in install list are cleaned off the system. - # + # # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise # false. ## @@ -63,9 +63,9 @@ ## # Checks if files from given package install list are actually installed. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if no installed files are missing, otherwise # false. ## @@ -74,9 +74,9 @@ ## # Checks if given packages installed symlinks are broken or missing. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if no symlinks found missing or broken, otherwise # false. ## @@ -85,9 +85,9 @@ ## # Checks the given packages dependencies for missing or broken dependencies. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if dependencies intact, otherwise # false. ## @@ -97,64 +97,64 @@ ## # Checks the given packages installed files against the integrity log for # changes to installed files. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise # hash of problem files and their encountered errors. ## - def verifyPackageIntegrity( package ) + def verifyPackageIntegrity( package ) end ## # Fixes the given package. - # + # # <b>PARAM</b> <i>String</i> - Package name. - # + # # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise # false. ## def fixPackage( package ) end - + ## # Sets the URI of a central repository for pre-compiled packages. # # <b>PARAM</b> <i>String</i> - the URI where the central repository is # located. - # + # # <b>RETURN</b> <i>boolean</i> - True if the URI is set, otherwise false. ## def setCentralRepo( uri ) end - + ## # Sets the location where the package tree is to be downloaded from, can be # set to a local location. # # <b>PARAM</b> <i>String</i> - the location of the package tree. - # + # # <b>RETURN</b> <i>boolean</i> - True if the package tree location is set, - # otherwise false. + # otherwise false. ## def setPackageTreeLocation( location ) end - + ## # Our in house system call wrapper. Used to control any system calls made in - # abt. Need to sort out tracking of stderr, stdout, stdin with open3? + # abt. Need to sort out tracking of stderr, stdout, stdin with open3? # Eventually replace any need for system here. # # <b>PARAM</b> <i>String</i> - the call to pass to system. - # - # <b>RETURN</b> <i>boolean</i> - True if system call successful, otherwise + # + # <b>RETURN</b> <i>boolean</i> - True if system call successful, otherwise # false. ## def runSystemCall( command ) - if ( !system( command ) ) - return false - end + if ( !system( command ) ) + return false + end - return true + return true end end Modified: src/trunk/AbtUsage.rb =================================================================== --- src/trunk/AbtUsage.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/AbtUsage.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,10 +1,10 @@ #!/usr/bin/ruby -I./packages ## -# AbtUsage.rb +# AbtUsage.rb # # The usage reporting class for AbTLinux. -# +# # Created by Eric D. Schabell <er...@ab...> # Copyright November 2006, GPL. # @@ -19,140 +19,140 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtUsage - ## - # The main usage method, displays either a given section or all sections. - # - # <b>PARAM</b> <i>String</i> - the name of the help section to be shown. - # - # <b>RETURN</b> <i>void</i> - ## - def usage( section ) - puts "Usage: abt.rb [options]\n\n" + ## + # The main usage method, displays either a given section or all sections. + # + # <b>PARAM</b> <i>String</i> - the name of the help section to be shown. + # + # <b>RETURN</b> <i>void</i> + ## + def usage( section ) + puts "Usage: abt.rb [options]\n\n" - case section + case section - when "packages" - usagePackages - - when "queries" - usageQueries + when "packages" + usagePackages - when "generation" - usageGeneration + when "queries" + usageQueries - when "downloads" - usageDownloads + when "generation" + usageGeneration - when "fix" - usageFix + when "downloads" + usageDownloads - when "maintenance" - usageMaintenance - - else - usagePackages - usageQueries - usageGeneration - usageDownloads - usageFix - usageMaintenance - end - end + when "fix" + usageFix - ## - # The usage information for the packages commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usagePackages - puts "\npackages:" - puts " -i, install [package]\t\tInstall given package." - puts " -ri, reinstall [package]\t\tReinstall given package." - puts " -r, remove [package]\t\tRemove given package." - puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." - puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" - end + when "maintenance" + usageMaintenance - ## - # The usage information for the query commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageQueries - puts "\nqueries:" - puts " -s, search [string | regexp ]\tSearch package descriptions for given input." - puts " -v, --version\t\t\tShow abt package manager version." - puts " show-details [package]\t\tShow give package details." - puts " show-build [package]\t\tShow build log of given package." - puts " show-depends [package]\t\tShow the dependency tree of given package." - puts " show-files [package]\t\tShow all installed files from given package." - puts " show-owner [file]\t\tShow the package owning given file." - puts " show-installed\t\t\tShow list of all installed packages." - puts " show-frozen\t\t\t\tShow list of all frozen packages." - puts " show-untracked\t\t\tShow all files on system not tracked by AbTLinux." - puts " show-journal\t\t\t\tShow the system journal." - puts " show-iqueue\t\t\t\tShow the contents of the install queue." - puts " show-patches\t\t\t\tShow the current available patches for installed package tree.\n" - end + else + usagePackages + usageQueries + usageGeneration + usageDownloads + usageFix + usageMaintenance + end + end - ## - # The usage information for the generation commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageGeneration - puts "\ngeneration:" - puts " show-updates\t\tShow a package listing with available update versions." - puts " html\t\t\tGenerate HTML page from installed packages:" - puts " \t\t\t\t(package name with hyperlink to package website and version installed)\n" - end + ## + # The usage information for the packages commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usagePackages + puts "\npackages:" + puts " -i, install [package]\t\tInstall given package." + puts " -ri, reinstall [package]\t\tReinstall given package." + puts " -r, remove [package]\t\tRemove given package." + puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." + puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" + end - ## - # The usage information for the download commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageDownloads - puts "\ndownloads:" - puts " -d, download [package]\t\tRetrieve given package sources." - puts " -u, update [package]|[tree]\tUpdate given package or tree from AbTLinux repository." - puts " -n, news\t\t\t\tDisplays newsfeeds from AbTLinux website.\n" - end + ## + # The usage information for the query commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageQueries + puts "\nqueries:" + puts " -s, search [string | regexp ]\tSearch package descriptions for given input." + puts " -v, --version\t\t\tShow abt package manager version." + puts " show-details [package]\t\tShow give package details." + puts " show-build [package]\t\tShow build log of given package." + puts " show-depends [package]\t\tShow the dependency tree of given package." + puts " show-files [package]\t\tShow all installed files from given package." + puts " show-owner [file]\t\tShow the package owning given file." + puts " show-installed\t\t\tShow list of all installed packages." + puts " show-frozen\t\t\t\tShow list of all frozen packages." + puts " show-untracked\t\t\tShow all files on system not tracked by AbTLinux." + puts " show-journal\t\t\t\tShow the system journal." + puts " show-iqueue\t\t\t\tShow the contents of the install queue." + puts " show-patches\t\t\t\tShow the current available patches for installed package tree.\n" + end - ## - # The usage information for the fix commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageFix - puts "\nfix:" - puts " purge-src\t\t\t\tRemove source caches for packages no longer installed." - puts " purge-logs\t\t\t\tRemove log files for packages no longer installed." - puts " verify-files [package]\t\tInstalled files are verified for given package." - puts " verify-symlinks [package]\t\tSymlinks verified for given package." - puts " verify-deps [package]\t\tDependency tree is verified for given package." - puts " verify-integrity [package]\t\tVerify integrity of installed files for given package." - puts " fix [package]\t\tGiven package is verified and fixed if needed.\n" - end + ## + # The usage information for the generation commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageGeneration + puts "\ngeneration:" + puts " show-updates\t\tShow a package listing with available update versions." + puts " html\t\t\tGenerate HTML page from installed packages:" + puts " \t\t\t\t(package name with hyperlink to package website and version installed)\n" + end - ## - # The usage information for the maintenance commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageMaintenance - puts "\nmaintenance:" - puts " build-location [host]\t\tSets global location (default: localhost) for retrieving cached package builds." - puts " package-repo [add|remove|list] [URI]" - puts " add - add package repository to list." - puts " remove - remove a package repository from list." - puts " list - display current repository list.\n" - end + ## + # The usage information for the download commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageDownloads + puts "\ndownloads:" + puts " -d, download [package]\t\tRetrieve given package sources." + puts " -u, update [package]|[tree]\tUpdate given package or tree from AbTLinux repository." + puts " -n, news\t\t\t\tDisplays newsfeeds from AbTLinux website.\n" + end + + ## + # The usage information for the fix commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageFix + puts "\nfix:" + puts " purge-src\t\t\t\tRemove source caches for packages no longer installed." + puts " purge-logs\t\t\t\tRemove log files for packages no longer installed." + puts " verify-files [package]\t\tInstalled files are verified for given package." + puts " verify-symlinks [package]\t\tSymlinks verified for given package." + puts " verify-deps [package]\t\tDependency tree is verified for given package." + puts " verify-integrity [package]\t\tVerify integrity of installed files for given package." + puts " fix [package]\t\tGiven package is verified and fixed if needed.\n" + end + + ## + # The usage information for the maintenance commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageMaintenance + puts "\nmaintenance:" + puts " build-location [host]\t\tSets global location (default: localhost) for retrieving cached package builds." + puts " package-repo [add|remove|list] [URI]" + puts " add - add package repository to list." + puts " remove - remove a package repository from list." + puts " list - display current repository list.\n" + end end Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2006-12-07 12:38:48 UTC (rev 263) +++ src/trunk/abt.rb 2006-12-07 15:41:09 UTC (rev 264) @@ -1,10 +1,10 @@ #!/usr/bin/ruby -wI./packages ## -# abt.rb +# abt.rb # -# The central package manager script to run all ABout Time Linux tasks. -# +# The central package manager script to run all ABout Time Linux tasks. +# # Created by Eric D. Schabell <er...@ab...> # Copyright July 2006, GPL. # @@ -19,7 +19,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -48,7 +48,7 @@ # deal with usage request. if ( ARGV.length == 0 ) - show.usage( "all" ) + show.usage( "all" ) end # login as root for the rest. @@ -57,331 +57,331 @@ # parse arguments. case ARGV[0] - # abt [ -i | install ] <package> - when "install", "-i" - if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) - options['package'] = ARGV[1] - logger.logToJournal( "Starting to install #{options['package']}" ) - - if ( manager.installPackage( options['package'] ) ) - puts "\n\n" - puts "Completed install of #{options['package']}." - puts "\n\n" - logger.logToJournal( "Completed install of #{options['package']}." ) - else - puts "#{options['package'].capitalize} install failed, see journal." - end + # abt [ -i | install ] <package> + when "install", "-i" + if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) + options['package'] = ARGV[1] + logger.logToJournal( "Starting to install #{options['package']}" ) - #reporter.showQueue( "install" ); # DEBUG. - else - show.usage( "packages" ) - exit - end - - when "reinstall", "-ri" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Reinstalling package : " + options['package'] - else - show.usage( "packages" ) - exit - end - - when "remove", "-r" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Removing package : " + options['package'] - else - show.usage( "packages" ) - exit - end - - when "downgrade", "-dg" - if ( ARGV.length == 3 ) - options['version'] = ARGV[1] - options['package'] = ARGV[2] - print "Downgradinging package : #{options['package']} " - puts "to version : #{options['version']}" - else - show.usage( "packages" ) - exit - end - - when "freeze", "-f" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Holdinging package : #{options['package']} at current version." - else - show.usage( "packages" ) - exit - end - - when "search", "-s" - if ( ARGV.length == 2 ) - options['searchString'] = ARGV[1] - puts "Searching package descriptions for : #{options['searchString']}" - else - show.usage( "queries" ) - exit - end - - # abt -v | --version - when "-v", "--version" - if ( ARGV.length == 1 ) - puts "Abt Package Manager version is : #{$ABT_VERSION}" - else - show.usage( "queries" ) - exit - end + if ( manager.installPackage( options['package'] ) ) + puts "\n\n" + puts "Completed install of #{options['package']}." + puts "\n\n" + logger.logToJournal( "Completed install of #{options['package']}." ) + else + puts "#{options['package'].capitalize} install failed, see journal." + end - # abt show-details <package> - when "show-details" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) - options['pkg'] = ARGV[1] - logger.logToJournal( "Starting show details for #{options['pkg']}" ) - - if ( reporter.showPackageDetails( options['pkg'] ) ) - logger.logToJournal( "Completed show details for #{options['pkg']}" ) - else - puts "Problems processing the details for #{options['pkg']}." - end - else - show.usage( "queries" ) - end - - when "show-build" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Display build log for package : " + options['package'] - else - show.usage( "queries" ) - exit - end + #reporter.showQueue( "install" ); # DEBUG. + else + show.usage( "packages" ) + exit + end + when "reinst... [truncated message content] |
From: <esc...@us...> - 2006-12-28 23:43:31
|
Revision: 268 http://svn.sourceforge.net/abtlinux/?rev=268&view=rev Author: eschabell Date: 2006-12-28 15:43:31 -0800 (Thu, 28 Dec 2006) Log Message: ----------- Removed wrapper, rolled back usage of shell and applied system calls to all locations (shell is generating many undocumented warnings). Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb src/trunk/AbtSystemManager.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2006-12-28 23:29:55 UTC (rev 267) +++ src/trunk/AbtDownloadManager.rb 2006-12-28 23:43:31 UTC (rev 268) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtDownloadManager.rb +# AbtDownloadManager.rb # # AbtDownloadManager class handles all downloading of components needed for # AbTLinux. @@ -20,7 +20,7 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. -# +# # You should have received a copy of the GNU General Public License along with # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,22 +28,22 @@ class AbtDownloadManager protected - + private - + public ## # Constructor for the AbtDownloadManager class. # - # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized AbtDownloadManager object. + # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized AbtDownloadManager object. ## def initialize end - + ## # Downloads a given package source. If the file already exists, returns - # true as if download completed. + # true as if download completed. # # <b>PARAM</b> <i>String</i> - the name of the package for which the source # is to be downloaded. @@ -53,26 +53,24 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require packageName - require "shell" - Shell.def_system_command "wget" - logger = AbtLogManager.new - package = eval( packageName.capitalize + '.new' ) + require packageName + logger = AbtLogManager.new + package = eval( packageName.capitalize + '.new' ) + + if ( File.exist?( destination + "/" + File.basename( package.srcUrl ) ) ) + logger.logToJournal( "Download not needed, existing source found for " + packageName ) + return true + end - if ( File.exist?( destination + "/" + File.basename( package.srcUrl ) ) ) - logger.logToJournal( "Download not needed, existing source found for " + packageName ) - return true - end + Dir.chdir( destination ) + if ( system( "wget #{package.srcUrl}" ) ) + logger.logToJournal( "Download completed for " + packageName ) + return true + end - retrieve = Shell.cd( destination ) - if ( retrieve.wget( package.srcUrl ) ) - logger.logToJournal( "Download completed for " + packageName ) - return true - end - - return false # download failed. + return false # download failed. end - + ## # Downloads a given pacakge tree. # @@ -83,61 +81,61 @@ ## def retrievePackageTree( packageTreeName ) end - + ## # Retrieves the given feed and displays the news items. # - # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, - # otherwise it will be appended. + # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. + # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, + # otherwise it will be appended. # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been # retrieved, otherwise false. ## def retrieveNewsFeed( uri, cleanLog = "false" ) - require 'net/http' - require 'uri' - require 'rss/1.0' - require 'rss/2.0' - newsLog = "" + require 'net/http' + require 'uri' + require 'rss/1.0' + require 'rss/2.0' + newsLog = "" - # ensure we have our news logfile. - if ( cleanLog == "true" ) - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) - else - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) - end + # ensure we have our news logfile. + if ( cleanLog == "true" ) + newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) + else + newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) + end + + # pick up the abtlinux.org news feed. + if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) + logger.logToJournal( "Failed to retrieve news feed #{uri}." ) + return false + end - # pick up the abtlinux.org news feed. - if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) - logger.logToJournal( "Failed to retrieve news feed #{uri}." ) - return false - end + # display the feeds. + rss = nil + begin + rss = RSS::Parser.parse(news, false) + rescue RSS::Error + end + + if ( rss.nil? ) + logger.logToJournal( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) + return false + else + newsLog.puts "*** #{rss.channel.title} ***" + + rss.items.each_with_index do |item, itemCount| + itemCount += 1 + newsLog.puts "#{itemCount} #{item.link} #{item.title}" + end + end - # display the feeds. - rss = nil - begin - rss = RSS::Parser.parse(news, false) - rescue RSS::Error - end + newsLog.puts "\n" + newsLog.close + return true - if ( rss.nil? ) - logger.logToJournal( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) - return false - else - newsLog.puts "*** #{rss.channel.title} ***" - - rss.items.each_with_index do |item, itemCount| - itemCount += 1 - newsLog.puts "#{itemCount} #{item.link} #{item.title}" - end - end - - newsLog.puts "\n" - newsLog.close - return true - end - + ## # Updates a given package with available patches (version updates). # @@ -148,7 +146,7 @@ ## def updatePackage end - + ## # Updates the package tree. # @@ -157,5 +155,5 @@ ## def updatePackageTree end - + end Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2006-12-28 23:29:55 UTC (rev 267) +++ src/trunk/AbtPackage.rb 2006-12-28 23:43:31 UTC (rev 268) @@ -37,7 +37,6 @@ # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def unpackSources - systemMgr = AbtSystemManager.new srcFile = File.basename( @srcUrl ) sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" unpackTool = "" @@ -82,7 +81,7 @@ #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) Dir.chdir( $BUILD_LOCATION ) - if ( !systemMgr.runSystemCall( "#{unpackTool} #{sourcesToUnpack}" ) ) + if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) return false end @@ -230,7 +229,6 @@ # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def configure - systemMgr = AbtSystemManager.new buildSite = "#{$BUILD_LOCATION}/#{@srcDir}" # TODO: this should not use tee, but in wrapper deal with stdout to file. Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2006-12-28 23:29:55 UTC (rev 267) +++ src/trunk/AbtPackageManager.rb 2006-12-28 23:43:31 UTC (rev 268) @@ -158,8 +158,6 @@ # <b>RETURN</b> <i>void</i> ## def rootLogin( arguments ) - systemMgr = AbtSystemManager.new - if ( Process.uid != 0 ) args = "" puts "\nEnter root password:" @@ -168,7 +166,7 @@ args = args + " " + ARGV[i] end - systemMgr.runSystemCall( 'su -c "./abt ' + args + '" root' ) + system( 'su -c "./abt ' + args + '" root' ) exit end end Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2006-12-28 23:29:55 UTC (rev 267) +++ src/trunk/AbtSystemManager.rb 2006-12-28 23:43:31 UTC (rev 268) @@ -139,22 +139,4 @@ ## def setPackageTreeLocation( location ) end - - ## - # Our in house system call wrapper. Used to control any system calls made in - # abt. Need to sort out tracking of stderr, stdout, stdin with open3? - # Eventually replace any need for system here. - # - # <b>PARAM</b> <i>String</i> - the call to pass to system. - # - # <b>RETURN</b> <i>boolean</i> - True if system call successful, otherwise - # false. - ## - def runSystemCall( command ) - if ( !system( command ) ) - return false - end - - return true - end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-12-29 21:10:03
|
Revision: 272 http://svn.sourceforge.net/abtlinux/?rev=272&view=rev Author: eschabell Date: 2006-12-29 13:10:02 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Naming of install queue moved off the generic <name>.log format to install.queue. Modified Paths: -------------- src/trunk/AbtQueueManager.rb src/trunk/AbtReportManager.rb Modified: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2006-12-29 14:00:52 UTC (rev 271) +++ src/trunk/AbtQueueManager.rb 2006-12-29 21:10:02 UTC (rev 272) @@ -52,9 +52,15 @@ # queue, otherwise false. ## def addPackageToQueue( package, queue ) - queueFile = "#{$ABT_LOGS}/#{queue}.log" logger = AbtLogManager.new + # want to name install queue differently from log files. + if ( queue == 'install' ) + queueFile = "#{$ABT_LOGS}/#{queue}.queue" + else + queueFile = "#{$ABT_LOGS}/#{queue}.log" + end + if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) # pickup queue contents to ensure no duplicates. checkingQueue = IO.readlines( queueFile ) Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2006-12-29 14:00:52 UTC (rev 271) +++ src/trunk/AbtReportManager.rb 2006-12-29 21:10:02 UTC (rev 272) @@ -199,15 +199,15 @@ # <b>RETURN</b> <i>void.</i> ## def showQueue( queueType ) - queueFile = "#{$ABT_LOGS}/#{queueType}.log" + case queueType when "install" - if ( File.exist?( queueFile ) ) + if ( File.exist?( "#{$ABT_LOGS}/#{queueType}.queue" ) ) puts "\n\n" puts "AbTLinux #{queueType} queue:" puts "=======================" - queue = IO.readlines( queueFile ) + queue = IO.readlines( "#{$ABT_LOGS}/#{queueType}.queue" ) queue.each{ |entry| puts entry } puts "\n\n" else @@ -215,7 +215,6 @@ puts "AbtLinux #{queueType} is empty at this time." puts "\n\n" end - else puts "#{queueType.capitalize} is not an AbTLinux queue." end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-12-29 21:47:35
|
Revision: 273 http://svn.sourceforge.net/abtlinux/?rev=273&view=rev Author: eschabell Date: 2006-12-29 13:47:33 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Implemented show-iqueue. Passing another test after adjusted assert to work as it should, not as I thought it would. Modified Paths: -------------- src/trunk/TestAbtReportManager.rb src/trunk/abt.rb Modified: src/trunk/TestAbtReportManager.rb =================================================================== --- src/trunk/TestAbtReportManager.rb 2006-12-29 21:10:02 UTC (rev 272) +++ src/trunk/TestAbtReportManager.rb 2006-12-29 21:47:33 UTC (rev 273) @@ -1,4 +1,4 @@ -#!/usr/bin/ruby -w +#!/usr/bin/ruby -wI./packages require 'test/unit/testcase' require 'test/unit/autorunner' @@ -107,7 +107,11 @@ # Test method for 'AbtReportManager.testShowQueue()' ## def testShowQueue - assert( @report.showQueue( "install" ), "testShowQueue()" ) + if ( @report.showQueue( "install" ) ) + assert ( false, "testShowQueue()" ) + else + assert ( true, "testShowQueue()" ) + end end ## Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2006-12-29 21:10:02 UTC (rev 272) +++ src/trunk/abt.rb 2006-12-29 21:47:33 UTC (rev 273) @@ -203,8 +203,7 @@ reporter.showJournal( $JOURNAL ) when "show-iqueue" - puts "Display contents of install queue." - show.usage( "queries" ) + reporter.showQueue( "install" ) when "show-patches" puts "Display currently available patches for installed package tree." This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-01-23 18:44:19
|
Revision: 279 http://svn.sourceforge.net/abtlinux/?rev=279&view=rev Author: eschabell Date: 2007-01-23 10:44:18 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Dumped the open3 helper class, is not very good to have to wait for output until the end of a configure run. Modified Paths: -------------- src/trunk/AbtPackage.rb src/trunk/abt.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-01-08 22:24:40 UTC (rev 278) +++ src/trunk/AbtPackage.rb 2007-01-23 18:44:18 UTC (rev 279) @@ -235,28 +235,14 @@ # also need to expand directory with @srcDir/@srcDir.configure. #command = "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/{@srcDir}.configure" Dir.chdir( buildSite ) - stdin, stdout, stderr = - Open3.popen3( "./configure --prefix=#{$DEFAULT_PREFIX}" ) - - # check for errors. - if ( !stderr.eof ) + + if ( !system( "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/#{@srcDir}.configure" ) ) # TODO: put this in failure file. - puts "DEBUG: [AbtPackage.configure] - stderr:" - puts stderr.read + puts "DEBUG: [AbtPackage.configure] - unable to configure." return false - else - puts "DEBUG: [AbtPackage.configure] - nothing in stderr." end - # check for output. - if ( !stdout.eof ) - # TODO: put this in #{$PACKAGE_INSTALLED}/{@srcDir}.configure. - puts "DEBUG: [AbtPackage.configure] - stdout:" - puts stdout.read - else - puts "DEBUG: [AbtPackage.configure] - nothing in stdout." - end - + puts "DEBUG: [AbtPackage.configure] - configure went fine!" return true end Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-01-08 22:24:40 UTC (rev 278) +++ src/trunk/abt.rb 2007-01-23 18:44:18 UTC (rev 279) @@ -33,7 +33,6 @@ require 'AbtSystemManager' require 'AbtUsage' require 'fileutils' -require 'open3' ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-25 13:06:18
|
Revision: 287 http://svn.sourceforge.net/abtlinux/?rev=287&view=rev Author: eschabell Date: 2007-02-25 05:06:17 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Small fixes to get tests for AbtQueueManager running solo. Modified Paths: -------------- src/trunk/AbtQueueManager.rb src/trunk/TestAbtQueueManager.rb Modified: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2007-02-25 12:45:43 UTC (rev 286) +++ src/trunk/AbtQueueManager.rb 2007-02-25 13:06:17 UTC (rev 287) @@ -53,13 +53,13 @@ ## def addPackageToQueue( package, queue ) logger = AbtLogManager.new - - # want to name install queue differently from log files. - if ( queue == 'install' ) - queueFile = "#{$ABT_LOGS}/#{queue}.queue" - else + + # want to name install queue differently from log files. + if ( queue == 'install' ) + queueFile = "#{$ABT_LOGS}/#{queue}.queue" + else queueFile = "#{$ABT_LOGS}/#{queue}.log" - end + end if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) # pickup queue contents to ensure no duplicates. Modified: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-02-25 12:45:43 UTC (rev 286) +++ src/trunk/TestAbtQueueManager.rb 2007-02-25 13:06:17 UTC (rev 287) @@ -2,7 +2,9 @@ require 'test/unit/testcase' require 'test/unit/autorunner' +require 'abtconfig' require 'AbtQueueManager' +require 'AbtLogManager' ## # TestAbtQueueManager.rb This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-25 20:31:09
|
Revision: 291 http://svn.sourceforge.net/abtlinux/?rev=291&view=rev Author: eschabell Date: 2007-02-25 12:31:08 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Moved the todo's for create user/group to preinstall. Updated test to use pre method, now passing another test! Modified Paths: -------------- src/trunk/AbtPackage.rb src/trunk/TestAbtPackage.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-02-25 13:30:20 UTC (rev 290) +++ src/trunk/AbtPackage.rb 2007-02-25 20:31:08 UTC (rev 291) @@ -210,9 +210,7 @@ if ( !self.unpackSources ) return false end - - # TODO: create_group? - # TODO: create_user? + # TODO: retrieve patches? # TODO: apply patches? @@ -268,6 +266,9 @@ # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def preinstall + # TODO: create_group? + # TODO: create_user? + return true; end ## Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-02-25 13:30:20 UTC (rev 290) +++ src/trunk/TestAbtPackage.rb 2007-02-25 20:31:08 UTC (rev 291) @@ -86,7 +86,7 @@ # Test method for 'AbtPackage.testPre()' ## def testPre - assert_equal( false, true, "testPre()" ) + assert( @fortune.pre(), "testPre()" ) end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-25 22:03:01
|
Revision: 295 http://svn.sourceforge.net/abtlinux/?rev=295&view=rev Author: eschabell Date: 2007-02-25 14:03:01 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Refactored all unit tests to move to ipc package for testing as this is a configure, make, make install build that is more complete than the fortune package. Down to 31 tests failing! Modified Paths: -------------- src/trunk/TestAbtDownloadManager.rb src/trunk/TestAbtLogManager.rb src/trunk/TestAbtPackage.rb src/trunk/TestAbtPackageManager.rb src/trunk/TestAbtQueueManager.rb src/trunk/TestAbtReportManager.rb Modified: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtDownloadManager.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -5,7 +5,6 @@ require 'abtconfig' require 'AbtDownloadManager' require 'AbtLogManager' -#require 'packages/fortune' ## # TestAbtDownloadManager.rb @@ -44,7 +43,7 @@ # Test method for 'AbtDownloadManager.testRetrievePackageSource()' ## def testRetrievePackageSource() - assert( @download.retrievePackageSource( "fortune", "/tmp" ), "testRetrievePackageSource()" ) + assert( @download.retrievePackageSource( "ipc", "/tmp" ), "testRetrievePackageSource()" ) end ## @@ -74,6 +73,4 @@ def testUpdatePackageTree() assert( @download.updatePackageTree(), "testUpdatePackageTree()" ) end - - end Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtLogManager.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -42,7 +42,7 @@ # Test method for 'AbtLogManager.testLogPackageIntegrity()' ## def testLogPackageIntegrity() - #assert( @log.logPackageIntegrity( "fortune" ), "testLogPackageIntegrity()" ) + #assert( @log.logPackageIntegrity( "ipc" ), "testLogPackageIntegrity()" ) assert( false, "testLogPackageIntegrity()" ) end @@ -50,21 +50,21 @@ # Test method for 'AbtLogManager.testLogPackageInstall()' ## def testLogPackageInstall() - assert( @log.logPackageInstall( "fortune" ), "testLogPackageInstall()" ) + assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) end ## # Test method for 'AbtLogManager.testLogPackageBuild()' ## def testLogPackageBuild() - assert( @log.logPackageBuild( "fortune" ), "testLogPackageBuild()" ) + assert( @log.logPackageBuild( "ipc" ), "testLogPackageBuild()" ) end ## # Test method for 'AbtLogManager.testCachePackage()' ## def testCachePackage() - assert( @log.cachePackage( "fortune" ), "testCachePackage()" ) + assert( @log.cachePackage( "ipc" ), "testCachePackage()" ) end ## Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtPackage.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -37,7 +37,7 @@ $versionTest = "1.4" $srcDirTest = "#{$nameTest.downcase}-#{$versionTest}" - $data = { + $dataTest = { 'name' => $nameTest, 'execName' => $nameTest.downcase, 'version' => $versionTest, @@ -49,55 +49,55 @@ # setup method for testing AbtPackage. ## def setup - @sw = Ipc.new + @ipc = Ipc.new end ## # Test method for 'AbtPackage.testDetails()' ## def testDetails - assert_equal( $data['name'], @sw.details['Package name'], "testDetails()" ) - assert_equal( $data['execName'], @sw.details['Executable'], "testDetails()" ) - assert_equal( $data['version'], @sw.details['Version'], "testDetails()" ) - assert_equal( $data['srcDir'], @sw.details['Source location'], "testDetails()" ) - assert_equal( $data['homepage'], @sw.details['Homepage'], "testDetails()" ) + assert_equal( $dataTest['name'], @ipc.details['Package name'], "testDetails()" ) + assert_equal( $dataTest['execName'], @ipc.details['Executable'], "testDetails()" ) + assert_equal( $dataTest['version'], @ipc.details['Version'], "testDetails()" ) + assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], "testDetails()" ) + assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], "testDetails()" ) end ## # Test method for 'AbtPackage.testPre()' ## def testPre - assert( @sw.pre(), "testPre()" ) + assert( @ipc.pre(), "testPre()" ) end ## # Test method for 'AbtPackage.testConfigure()' ## def testConfigure - if ( !@sw.pre() ) + if ( !@ipc.pre() ) assert_equals( true, false, "testConfigure()" ) end - assert( @sw.configure(), "testConfigure()" ) + assert( @ipc.configure(), "testConfigure()" ) end ## # Test method for 'AbtPackage.testBuild()' ## def testBuild - if ( !@sw.pre() ) + if ( !@ipc.pre() ) assert_equals( true, false, "testConfigure()" ) end - if ( !@sw.configure() ) + if ( !@ipc.configure() ) assert_equals( true, false, "testConfigure()" ) end - assert( @sw.build(), "testBuild()" ) + assert( @ipc.build(), "testBuild()" ) end ## # Test method for 'AbtPackage.testPreinstall()' ## def testPreinstall - assert( @sw.preinstall(), "testPreinstall()" ) + assert( @ipc.preinstall(), "testPreinstall()" ) end ## @@ -111,7 +111,7 @@ # Test method for 'AbtPackage.testPost()' ## def testPost - assert( @sw.post(), "testPost()" ) + assert( @ipc.post(), "testPost()" ) end end Modified: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtPackageManager.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -41,35 +41,35 @@ # Test method for 'AbtPackageManager.testInstallPackage()' ## def testInstallPackage - assert( @pkgMgr.installPackage( "fortune" ), "testInstallPackage()" ) + assert( @pkgMgr.installPackage( "ipc" ), "testInstallPackage()" ) end ## # Test method for 'AbtPackageManager.testReinstallPackage()' ## def testReinstallPackage - assert( @pkgMgr.reinstallPackage( "fortune" ), "testReinstallPackage()" ) + assert( @pkgMgr.reinstallPackage( "ipc" ), "testReinstallPackage()" ) end ## # Test method for 'AbtPackageManager.testRemovePackage()' ## def testRemovePackage - assert( @pkgMgr.removePackage( "fortune" ), "testRemovePackage()" ) + assert( @pkgMgr.removePackage( "ipc" ), "testRemovePackage()" ) end ## # Test method for 'AbtPackageManager.testDowngradePackage()' ## def testDowngradePackage - assert( @pkgMgr.downgradePackage( "fortune", "1.2" ), "testDowngradePackage()" ) + assert( @pkgMgr.downgradePackage( "ipc", "1.2" ), "testDowngradePackage()" ) end ## # Test method for 'AbtPackageManager.testFreezePackage()' ## def testFreezePackage - assert( @pkgMgr.freezePackage( "fortune" ), "testFreezePackage()" ) + assert( @pkgMgr.freezePackage( "ipc" ), "testFreezePackage()" ) end end Modified: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtQueueManager.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -43,7 +43,7 @@ # Test method for 'AbtQueueManager.addPackageToQueue()' ## def testAddPackageToQueue - assert( @queue.addPackageToQueue( "fortune", "install" ), "testQueueManager()" ) + assert( @queue.addPackageToQueue( "ipc", "install" ), "testQueueManager()" ) end end Modified: src/trunk/TestAbtReportManager.rb =================================================================== --- src/trunk/TestAbtReportManager.rb 2007-02-25 21:26:06 UTC (rev 294) +++ src/trunk/TestAbtReportManager.rb 2007-02-25 22:03:01 UTC (rev 295) @@ -42,7 +42,7 @@ # Test method for 'AbtReportManager.testShowPackageDetails()' ## def testShowPackageDetails - assert( @report.showPackageDetails( "fortune" ), "testShowPackageDetails()" ) + assert( @report.showPackageDetails( "ipc" ), "testShowPackageDetails()" ) end ## @@ -56,9 +56,9 @@ # Test method for 'AbtReportManager.testShowPackageLog()' ## def testShowPackageLog - assert( @report.showPackageLog( "fortune", "install" ), "testShowPackageLog()" ) - assert( @report.showPackageLog( "fortune", "build" ), "testShowPackageLog()" ) - assert( @report.showPackageLog( "fortune", "integrity" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "install" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "build" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "integrity" ), "testShowPackageLog()" ) end ## @@ -72,7 +72,6 @@ # Test method for 'AbtReportManager.testShowPackageDependencies()' ## def testShowPackageDependencies - #assert( @report.showPackageDependencies( "fortune" ), "testShowPackageDependencies()" ) assert( false, "testShowPackageDependencies()" ) end @@ -94,7 +93,7 @@ # Test method for 'AbtReportManager.testShowFileOwner()' ## def testShowFileOwner - assert( @report.showFileOwner( "fortuneFile" ), "testShowFileOwner()" ) + assert( @report.showFileOwner( "ipcFile" ), "testShowFileOwner()" ) end ## @@ -119,7 +118,7 @@ # Test method for 'AbtReportManager.testShowUpdates()' ## def testShowUpdates - assert( @report.showUpdates( "fortune" ), "testShowUpdates()" ) + assert( @report.showUpdates( "ipc" ), "testShowUpdates()" ) end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-26 13:11:00
|
Revision: 297 http://svn.sourceforge.net/abtlinux/?rev=297&view=rev Author: eschabell Date: 2007-02-26 05:11:00 -0800 (Mon, 26 Feb 2007) Log Message: ----------- Placed todo in install method for AbtPackage class. Added preinstall to AbtPackageManager installPackage method. Updated tests to test correctly for this. Modified Paths: -------------- src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb src/trunk/TestAbtPackage.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-02-25 22:04:14 UTC (rev 296) +++ src/trunk/AbtPackage.rb 2007-02-26 13:11:00 UTC (rev 297) @@ -277,6 +277,8 @@ # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def install + # TODO: implement. + return true; end ## Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-02-25 22:04:14 UTC (rev 296) +++ src/trunk/AbtPackageManager.rb 2007-02-26 13:11:00 UTC (rev 297) @@ -87,18 +87,25 @@ logger.logToJournal( "DEBUG: finished #{package} configure section." ) end - # build section - if ( !sw.build ) + # build section. + if ( !sw.build ) logger.logToJournal( "Failed to process build section in the package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} build section." ) end + # preinstall section. + if ( !sw.preinstall ) + logger.logToJournal( "Failed to process preinstall section in the package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} preinstall section." ) + end + # TODO: finish up the following steps per install scenario: # - # pre install section # install section # post section # remove build sources. Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-02-25 22:04:14 UTC (rev 296) +++ src/trunk/TestAbtPackage.rb 2007-02-26 13:11:00 UTC (rev 297) @@ -85,10 +85,10 @@ ## def testBuild if ( !@ipc.pre() ) - assert_equals( true, false, "testConfigure()" ) + assert_equals( true, false, "testBuild()" ) end if ( !@ipc.configure() ) - assert_equals( true, false, "testConfigure()" ) + assert_equals( true, false, "testBuild()" ) end assert( @ipc.build(), "testBuild()" ) end @@ -104,13 +104,40 @@ # Test method for 'AbtPackage.testInstall()' ## def testInstall - assert_equal( false, true, "testInstall()" ) + if ( !@ipc.pre() ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.configure() ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.build() ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.preinstall() ) + assert_equals( true, false, "testInstall()" ) + end + assert( @ipc.install(), "testInstall()" ) end ## # Test method for 'AbtPackage.testPost()' ## def testPost + if ( !@ipc.pre() ) + assert_equals( true, false, "testPost()" ) + end + if ( !@ipc.configure() ) + assert_equals( true, false, "testPost()" ) + end + if ( !@ipc.build() ) + assert_equals( true, false, "testPost()" ) + end + if ( !@ipc.preinstall() ) + assert_equals( true, false, "testPost()" ) + end + if ( !@ipc.install() ) + assert_equals( true, false, "testPost()" ) + end assert( @ipc.post(), "testPost()" ) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-26 16:18:27
|
Revision: 298 http://svn.sourceforge.net/abtlinux/?rev=298&view=rev Author: eschabell Date: 2007-02-26 08:18:20 -0800 (Mon, 26 Feb 2007) Log Message: ----------- Working on logPackageInstall, still need to get installwatch log parsed to ignore my list of dirs (/dev, /proc, etc). Left big TODO for that. Ran the ruby formatter over these classes, removes whitespaces etc. Added install section processing. Except for the install log above it works fine. Another test done! Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-02-26 13:11:00 UTC (rev 297) +++ src/trunk/AbtLogManager.rb 2007-02-26 16:18:20 UTC (rev 298) @@ -26,9 +26,9 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtLogManager - -protected - + + protected + ## # Provides logging of the integrity of all installed files for the given # package. Will be called as part of the logging done during the install @@ -41,12 +41,12 @@ ## def logPackageIntegrity( package ) end - - -private - -public - + + + private + + public + ## # Constructor for the AbtLogManager. It ensures all needed logs paths are # initialized. @@ -56,15 +56,15 @@ ## def initialize [$ABT_LOGS, $ABT_CACHES, $BUILD_LOCATION, $PACKAGE_INSTALLED, - $SOURCES_REPOSITORY].each { |dir| - + $SOURCES_REPOSITORY].each { |dir| + if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) self.logToJournal( "Created directory: #{dir}." ) end } end - + ## # Provides logging of all files installed by given package. Should be called # as part of the install phase of the build. @@ -75,8 +75,51 @@ # otherwise false. ## def logPackageInstall( package ) + excludedDirs = "/dev /proc /tmp /var/tmp /usr/src /sys" + + require package + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + badLine = false # used to mark excluded lines from installwatch log. + + # our log locations. + installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}.install" + tmpInstallLog = "/tmp/#{details['Source location']}.watch" + + # get the installed files from the tmp file + # into our install log. + if ( File.exist?( tmpInstallLog ) ) + installFile = open( installLog, 'w') + + # include only the file names from open calls + # and not part of the excluded range of directories. + #TODO: FIX THIS, NEEDS TO MATCH EACH LINE.SPLIT[2] TO THE + # GIVEN LINE, MATCH MEANS WE DO NOT LOG IT! + IO.foreach( tmpInstallLog ) do |line| + if ( line.split[1] == 'open' ) + self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excludedDirs}." ) + if ( line.split[2].match( excludedDirs ) ) + self.logToJournal( "DEBUG: Found bad logLine!" ) + badLine = true + else + self.logToJournal( "DEBUG: #{excludedDirs} not matching #{line.split[2]}") + end + + if ( !badLine ) + self.logToJournal( "DEBUG: adding line to installFile!") + installFile.puts line.split[2] + else + self.logToJournal( "DEBUG: found a badLine, not adding #{line.split[2]}") + end + end + end + + installFile.close + end + + return true; end - + ## # Provides logging of all output produced during the build phase of the # given package. Should be called as part of the install phase of the build. @@ -88,7 +131,7 @@ ## def logPackageBuild( package ) end - + ## # Provides a complete log of the given packages build. Includes everything # needed to duplicate the build at a later date. @@ -100,7 +143,7 @@ ## def cachePackage( package ) end - + ## # Provides logging of given message to the AbTLinux journal. Message logged # with date timestamp. @@ -115,7 +158,7 @@ log.close return true end - + return false end end Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-02-26 13:11:00 UTC (rev 297) +++ src/trunk/AbtPackage.rb 2007-02-26 16:18:20 UTC (rev 298) @@ -28,9 +28,9 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtPackage - + protected - + ## # Unpacks this packages source file into the standard build location. # @@ -40,107 +40,107 @@ srcFile = File.basename( @srcUrl ) sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" unpackTool = "" - + # check for existing file in source repo. if ( !File.exist?( sourcesToUnpack ) ) return false end - + # check if possible existing sources in build directory. if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) return true end - + # determine which supported compression used [gz, tar, tgz, bz2, zip]. compressionType = srcFile.split( '.' ) - + case compressionType.last - + when "gz" unpackTool = "tar xzvf" - + when "tar" unpackTool = "tar xvf" - + when "bz2" unpackTool = "tar xjvf" - + when "tgz" unpackTool = "tar xzvf" - + when "zip" unpackTool = "unizp" - + else # unsupported format. return false end - + # DEBUG: #logger = AbtLogManager.new #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) - + Dir.chdir( $BUILD_LOCATION ) if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) return false end - + return true end - + private - + public - + # the name of the package. attr_reader :name - + # the executable name for the package. attr_reader :execName - + # the package version number. attr_reader :version - + # the source directory for the package. attr_reader :srcDir - + # the packages homepage. attr_reader :homepage - + # the URL where this packages sources can be obtained. attr_reader :srcUrl - + # list of dependsOn (DO) related package dependencies. attr_reader :dependsOn - + # list of reliesOn (RO) related package dependencies. attr_reader :reliesOn - + # list of optional reliesOn (oRO) related package dependencies. attr_reader :optionalDO - + # list of optional dependsOn (oDO) related package dependencies. attr_reader :optionalRO - + # security hash value of package sources. attr_reader :hashCheck - + # list of available patches for this package. attr_reader :patches - + # security hash value of this packages patches. attr_reader :patchesHashCheck - + # available mirrors for this package. attr_reader :mirrorPath - + # type of license this package has. attr_reader :licence - + # the package description. attr_reader :description - - + + ## # Constructor for an AbtPackage, requires all the packge details. # @@ -165,7 +165,7 @@ @license = data['license'] @description = data['description'] end - + ## # Provides all the data needed for this AbtPackage. # @@ -191,7 +191,7 @@ "Description" => @description } end - + ## # Preliminary work will happen here such as downloading the tarball, # unpacking it, downloading and applying patches. @@ -200,12 +200,12 @@ ## def pre downloader = AbtDownloadManager.new - + # download sources. if ( !downloader.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) return false end - + # unpack sources. if ( !self.unpackSources ) return false @@ -213,10 +213,10 @@ # TODO: retrieve patches? # TODO: apply patches? - + return true end - + ## # Here we manage the ./configure step (or equivalent). We need to give ./configure # (or autogen.sh, or whatever) the correct options so files are to be placed later in the @@ -228,18 +228,17 @@ ## def configure Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - + # TODO: not some better way to deal with this than system and tee? - if ( !system( "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/#{@srcDir}.configure" ) ) - # TODO: put this in failure file. - puts "DEBUG: [AbtPackage.configure] - unable to configure." + if ( !system( "./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/#{@srcDir}.configure" ) ) + puts "DEBUG: [AbtPackage.configure] - configure section failed." return false end - - puts "DEBUG: [AbtPackage.configure] - configure went fine!" + + puts "DEBUG: [AbtPackage.configure] - configure section completed!" return true end - + ## # Here is where the actual builing of the software starts, for example running 'make'. # @@ -247,18 +246,17 @@ ## def build Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - + # TODO: not some better way to deal with this than system and tee? - if( !system( "make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}.build" ) ) - # TODO: put this in failure file. - puts "DEBUG: [AbtPackage.build] - unable to build." + if( !system( "make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}.build" ) ) + puts "DEBUG: [AbtPackage.build] - build section failed." return false - end - - puts "DEBUG: [AbtPackage.build] - build went fine!" + end + + puts "DEBUG: [AbtPackage.build] - build section completed!" return true end - + ## # Any actions needed before the installation can occur will happen here, such as creating # new user accounts, dealing with existing configuration files, etc. @@ -270,7 +268,7 @@ # TODO: create_user? return true; end - + ## # All files to be installed are installed here. # @@ -278,9 +276,19 @@ ## def install # TODO: implement. - return true; + Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) + + # TODO: can this be done without installwatch? + if( !system( "installwatch --transl=no --backup=no --exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys --logfile=/tmp/#{@srcDir}.watch make install" ) ) + puts "DEBUG: [AbtPackage.install] - install section failed." + # TODO: rollback any installed files (use install log). + return false + end + + puts "DEBUG: [AbtPackage.install] - install section completed!" + return true end - + ## # Last bits of installation. adding the service for automatic start in init.d for example. # @@ -290,7 +298,7 @@ # TODO: implement me! return true end - + ## # Cleans up this packages source build directory. # @@ -299,16 +307,16 @@ def removeBuild if ( $REMOVE_BUILD_SOURCES ) buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" - + if ( !File.directory?( buildSourcesLocation ) ) return true end - + if ( !FileUtils.rm_rf buildSourcesLocation, :verbose => true ) return false end end - + return true end end Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-02-26 13:11:00 UTC (rev 297) +++ src/trunk/AbtPackageManager.rb 2007-02-26 16:18:20 UTC (rev 298) @@ -26,13 +26,13 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtPackageManager - -protected - -private - -public - + + protected + + private + + public + ## # Constructor for AbtPackageManager. # @@ -40,7 +40,7 @@ ## def initialize end - + ## # Installs a given package. # @@ -54,23 +54,23 @@ sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new logger = AbtLogManager.new - + # TODO: initialize pkg install directory ($PACKAGE_INSTALLED/@srcDir), # should this fail we have to clean this dir up, move to failure # location? # On success, need to cache contents in cache dir. - + # get package details. details = sw.details - + # TODO: check deps - + # add to install queue. if ( !queuer.addPackageToQueue( package, "install" ) ) logger.logToJournal( "Failed to add #{package} to install queue." ) return false end - + # pre section. if ( !sw.pre ) logger.logToJournal( "Failed to process pre-section in the package description of #{package}." ) @@ -78,7 +78,7 @@ else logger.logToJournal( "DEBUG: finished #{package} pre section." ) end - + # configure section. if ( !sw.configure ) logger.logToJournal( "Failed to process configure section in the package description of #{package}." ) @@ -86,15 +86,15 @@ else logger.logToJournal( "DEBUG: finished #{package} configure section." ) end - + # build section. - if ( !sw.build ) + if ( !sw.build ) logger.logToJournal( "Failed to process build section in the package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} build section." ) end - + # preinstall section. if ( !sw.preinstall ) logger.logToJournal( "Failed to process preinstall section in the package description of #{package}." ) @@ -103,10 +103,18 @@ logger.logToJournal( "DEBUG: finished #{package} preinstall section." ) end - + # install section. + if ( !sw.install ) + logger.logToJournal( "Failed to process install section in the package description of #{package}." ) + return false + else + logger.logPackageInstall( "ipc" ) + logger.logToJournal( "DEBUG: finished #{package} install section." ) + end + + # TODO: finish up the following steps per install scenario: # - # install section # post section # remove build sources. # @@ -114,10 +122,10 @@ logger.logToJournal( "Failed to remove the build sources for #{package}." ) #return false # commented out as this is not a reason to fail. end - + return true end - + ## # Reinstalls a given package. # @@ -128,7 +136,7 @@ ## def reinstallPackage( package ) end - + ## # Removes a given package. # @@ -139,7 +147,7 @@ ## def removePackage( package ) end - + ## # Downgrades a given package. # @@ -152,7 +160,7 @@ ## def downgradePackage( package, version ) end - + ## # Freezes a given package. If successful will add give package to the frozen # list. @@ -164,7 +172,7 @@ ## def freezePackage( package ) end - + ## # Provides for a log through for root access using su. # @@ -176,11 +184,11 @@ if ( Process.uid != 0 ) args = "" puts "\nEnter root password:" - + for i in 0...ARGV.length args = args + " " + ARGV[i] end - + system( 'su -c "./abt ' + args + '" root' ) exit end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-28 20:52:57
|
Revision: 310 http://svn.sourceforge.net/abtlinux/?rev=310&view=rev Author: eschabell Date: 2007-02-28 12:51:05 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Now verifing that build and installs are logged. Removed hard coded (was from testing) call to logging methods, based now on package name. Added task TODO for logging package integrity. Commented out debug lines from logging of package install. Implemented build logging method. Down to 29 tests failing! Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-02-26 21:18:06 UTC (rev 309) +++ src/trunk/AbtLogManager.rb 2007-02-28 20:51:05 UTC (rev 310) @@ -40,6 +40,7 @@ # otherwise false. ## def logPackageIntegrity( package ) + # TODO: implement logPackageIntegrity. end @@ -96,20 +97,18 @@ # and not part of the excluded range of directories. IO.foreach( tmpInstallLog ) do |line| if ( line.split[1] == 'open' ) - self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." ) + #self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." ) if ( line.split[2] =~ excluded_pattern ) - self.logToJournal( "DEBUG: Found bad logLine!" ) + #self.logToJournal( "DEBUG: Found bad logLine!" ) badLine = true else badLine = false - self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}") + #self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}") end if ( !badLine ) - self.logToJournal( "DEBUG: adding line to installFile!") + #self.logToJournal( "DEBUG: adding line to installFile!") installFile.puts line.split[2] - else - self.logToJournal( "DEBUG: found a badLine, not adding #{line.split[2]}") end end end @@ -132,6 +131,18 @@ # otherwise false. ## def logPackageBuild( package ) + require package + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + buildFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.build" + #self.logToJournal( "DEBUG: buildFile is - #{buildFile}" ) + + # make sure the build file exists. + if ( !File.exist?( buildFile ) ) + return false + end + + return true end ## Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-02-26 21:18:06 UTC (rev 309) +++ src/trunk/AbtPackageManager.rb 2007-02-28 20:51:05 UTC (rev 310) @@ -91,6 +91,10 @@ logger.logToJournal( "Failed to process build section in the package description of #{package}." ) return false else + if ( !logger.logPackageBuild( sw.name.downcase ) ) + logger.logToJournal( "Failed to create a package build log." ) + return false + end logger.logToJournal( "DEBUG: finished #{package} build section." ) end @@ -109,7 +113,7 @@ logger.logToJournal( "Failed to process install section in the package description of #{package}." ) return false else - logger.logPackageInstall( "ipc" ) + logger.logPackageInstall( sw.name.downcase ) logger.logToJournal( "DEBUG: finished #{package} install section." ) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-28 22:10:24
|
Revision: 313 http://svn.sourceforge.net/abtlinux/?rev=313&view=rev Author: eschabell Date: 2007-02-28 14:03:33 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Refactored addPackageToQueue to actionPackageQueue, very generic with regards to queue name and action to be performed (for now just add and remove). Completed installPackage, includes removal of build sources, log generation for configure, build, install and removal from the install queue! Added some task listing TODO's in the needed places. Modified Paths: -------------- src/trunk/AbtPackageManager.rb src/trunk/AbtQueueManager.rb Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-02-28 21:59:29 UTC (rev 312) +++ src/trunk/AbtPackageManager.rb 2007-02-28 22:03:33 UTC (rev 313) @@ -62,7 +62,7 @@ # add to install queue. puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" - if ( !queuer.addPackageToQueue( package, "install" ) ) + if ( !queuer.actionPackageQueue( package, "install", "add" ) ) logger.logToJournal( "Failed to add #{package} to install queue." ) return false end @@ -114,22 +114,32 @@ return false else logger.logPackageInstall( sw.name.downcase ) + # TODO: logger.logPackageIntegrity( sw.name.downcase ) logger.logToJournal( "DEBUG: finished #{package} install section." ) end - - - # TODO: finish up the following steps per install scenario: - # - # post section - # remove build sources. - # + + # post section. + puts "\n*** Processing the POST section for #{package}. ***" + if ( !sw.post ) + logger.logToJournal( "Failed to process post section in the package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} post section." ) + end + + # clean out build sources. puts "\n*** Cleaning up the sources for #{package}. ***" if ( !sw.removeBuild ) logger.logToJournal( "Failed to remove the build sources for #{package}." ) #return false # commented out as this is not a reason to fail. end + + # remove pacakge from install queue. + if ( !queuer.actionPackageQueue( sw.name.downcase, "install", "remove" ) ) + logger.logToJournal( "Failed to remove #{sw.name.donwcase} from install queue." ) + end - return true + return true # install completed! end ## Modified: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2007-02-28 21:59:29 UTC (rev 312) +++ src/trunk/AbtQueueManager.rb 2007-02-28 22:03:33 UTC (rev 313) @@ -41,43 +41,68 @@ end ## - # Add a given package to the given queue. If package already in - # the queue then it will not be added twice and return a positive - # answer. + # Add/Remove a given package to the given queue. + # If adding a package already in the queue then it will not + # be added twice and return succes. # - # <b>PARAM</b> <i>String</i> - the package to be added to the queue. - # <b>PARAM</b> <i>String</i> - the queue to add the package to. + # <b>PARAM</b> <i>String</i> - the package to be added/removed. + # <b>PARAM</b> <i>String</i> - the queue. # - # <b>RETURN</b> <i>boolean</i> - true if package added/exists to/in install - # queue, otherwise false. + # <b>RETURN</b> <i>boolean</i> - true if action succeeds, otherwise false. ## - def addPackageToQueue( package, queue ) + def actionPackageQueue( package, queue, action="add" ) + require 'fileutils' logger = AbtLogManager.new + queueFile = "" # used to hold the queue location. + + # want to name install queue differently from log files. + if ( queue == 'install' ) + queueFile = "#{$ABT_LOGS}/#{queue}.queue" + else + queueFile = "#{$ABT_LOGS}/#{queue}.log" + end - # want to name install queue differently from log files. - if ( queue == 'install' ) - queueFile = "#{$ABT_LOGS}/#{queue}.queue" - else - queueFile = "#{$ABT_LOGS}/#{queue}.log" - end + if ( action == "add") + if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + # pickup queue contents to ensure no duplicates. + checkingQueue = IO.readlines( queueFile ) + + # check if package exists, otherwise add. + if ( ! checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( package ) ) + log.puts "#{package}|#{$TIMESTAMP}" + logger.logToJournal( "Added #{package} to #{queue} queue." ) + else + logger.logToJournal( "Did not add #{package} to #{queue}, already exists." ) + end + + log.close + return true + end + end - if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) - # pickup queue contents to ensure no duplicates. - checkingQueue = IO.readlines( queueFile ) - - # check if package exists, otherwise add. - if ( ! checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( package ) ) - log.puts "#{package}|#{$TIMESTAMP}" - logger.logToJournal( "Added #{package} to #{queue} queue." ) - else - logger.logToJournal( "Did not add #{package} to #{queue}, already exists." ) + if ( action == "remove" ) + # remove entry from given queue. + if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + # use temp file to filter out entry to be removed. + temp = File.new(queueFile + ".tmp", "a+") + + # now check for line to be removed. + IO.foreach( queueFile ) do |line| + entryName = line.split( '|' )[0] + if ( entryName != package.downcase ) + temp.puts line + end + end + + temp.close + FileUtils.mv( temp.path, queueFile ) end - + log.close return true end - + logger.logToJournal( "Failed to open #{queueFile}." ) return false - end + end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-01 20:13:58
|
Revision: 315 http://svn.sourceforge.net/abtlinux/?rev=315&view=rev Author: eschabell Date: 2007-03-01 12:13:59 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Added some todo tasks to LogManager. Found the unit testing teardown I was looking for to help with testing cleanups, added to all test classes. Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/TestAbtDepEngine.rb src/trunk/TestAbtDownloadManager.rb src/trunk/TestAbtLogManager.rb src/trunk/TestAbtPackage.rb src/trunk/TestAbtPackageManager.rb src/trunk/TestAbtQueueManager.rb src/trunk/TestAbtReportManager.rb src/trunk/TestAbtSystemManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/AbtLogManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -155,6 +155,13 @@ # otherwise false. ## def cachePackage( package ) + # TODO: collect package source. + # TODO: collect package install log. + # TODO: collect package build log. + # TODO: collect package configure log. + # TODO: collect package integrity log. + # TODO: collect package description (class file). + # TODO: tar and bzip this directory (package-cache-version.tar.bz2) end ## Modified: src/trunk/TestAbtDepEngine.rb =================================================================== --- src/trunk/TestAbtDepEngine.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtDepEngine.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -38,6 +38,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtDepEngine.testDepEngine()' ## def testDepEngine Modified: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtDownloadManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -40,6 +40,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtDownloadManager.testRetrievePackageSource()' ## def testRetrievePackageSource() Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtLogManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -39,6 +39,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtLogManager.testLogPackageIntegrity()' ## def testLogPackageIntegrity() Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtPackage.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -53,6 +53,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtPackage.testDetails()' ## def testDetails Modified: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtPackageManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -38,6 +38,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtPackageManager.testInstallPackage()' ## def testInstallPackage Modified: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtQueueManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -40,6 +40,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtQueueManager.actionPackageQueue()' ## def testActionPackageQueue Modified: src/trunk/TestAbtReportManager.rb =================================================================== --- src/trunk/TestAbtReportManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtReportManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -39,6 +39,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtReportManager.testShowPackageDetails()' ## def testShowPackageDetails Modified: src/trunk/TestAbtSystemManager.rb =================================================================== --- src/trunk/TestAbtSystemManager.rb 2007-02-28 22:05:11 UTC (rev 314) +++ src/trunk/TestAbtSystemManager.rb 2007-03-01 20:13:59 UTC (rev 315) @@ -38,6 +38,12 @@ end ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## # Test method for 'AbtSystemManager.testCleanupPackageSources()' ## def testCleanupPackageSources This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-03 13:57:38
|
Revision: 317 http://svn.sourceforge.net/abtlinux/?rev=317&view=rev Author: eschabell Date: 2007-03-03 05:57:38 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Updated all files with ruby code formatter and ensured all lines withing 80 column limit. Modified Paths: -------------- src/trunk/AbtDepEngine.rb src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/AbtQueueManager.rb src/trunk/AbtReportManager.rb src/trunk/AbtSystemManager.rb src/trunk/TestAbtDepEngine.rb src/trunk/TestAbtDownloadManager.rb src/trunk/TestAbtLogManager.rb src/trunk/TestAbtPackage.rb src/trunk/TestAbtPackageManager.rb src/trunk/TestAbtQueueManager.rb src/trunk/TestAbtReportManager.rb src/trunk/TestAbtSystemManager.rb src/trunk/abt.rb src/trunk/testSuiteAbt.rb Modified: src/trunk/AbtDepEngine.rb =================================================================== --- src/trunk/AbtDepEngine.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtDepEngine.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -26,13 +26,13 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtDepEngine - -protected - -private - -public - + + protected + + private + + public + ## # Constructor for the AbtDepEngine class. # @@ -40,5 +40,5 @@ ## def initialize end - + end \ No newline at end of file Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtDownloadManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -26,24 +26,25 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtDownloadManager - -protected -private + protected -public - + private + + public + ## # Constructor for the AbtDownloadManager class. # - # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized AbtDownloadManager object. + # <b>RETURN</b> <i>AbtDownloadManager</i> - an initialized + # AbtDownloadManager object. ## def initialize end ## # Downloads a given package source. If the file already exists, returns - # true as if download completed. + # true as if download completed. # # <b>PARAM</b> <i>String</i> - the name of the package for which the source # is to be downloaded. @@ -53,22 +54,24 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require packageName - logger = AbtLogManager.new - package = eval( packageName.capitalize + '.new' ) - - if ( File.exist?( destination + "/" + File.basename( package.srcUrl ) ) ) - logger.logToJournal( "Download not needed, existing source found for " + packageName ) - return true - end - - Dir.chdir( destination ) - if ( system( "wget #{package.srcUrl}" ) ) - logger.logToJournal( "Download completed for " + packageName ) - return true - end - - return false # download failed. + require packageName + logger = AbtLogManager.new + package = eval( packageName.capitalize + '.new' ) + + if ( File.exist?( + destination + "/" + File.basename( package.srcUrl ) ) ) + logger.logToJournal( "Download not needed, existing source " + + "found for " + packageName ) + return true + end + + Dir.chdir( destination ) + if ( system( "wget #{package.srcUrl}" ) ) + logger.logToJournal( "Download completed for " + packageName ) + return true + end + + return false # download failed. end ## @@ -76,8 +79,8 @@ # # <b>PARAM</b> <i>String</i> - the name of the package tree to be retrieved. # - # <b>RETURN</b> <i>boolean</i> - True if the package tree is retrieved, otherwise - # false. + # <b>RETURN</b> <i>boolean</i> - True if the package tree is retrieved, + # otherwise false. ## def retrievePackageTree( packageTreeName ) end @@ -85,55 +88,58 @@ ## # Retrieves the given feed and displays the news items. # - # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, - # otherwise it will be appended. + # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. + # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, + # otherwise it will be appended. # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been # retrieved, otherwise false. ## def retrieveNewsFeed( uri, cleanLog = "false" ) - require 'net/http' - require 'uri' - require 'rss/1.0' - require 'rss/2.0' - newsLog = "" - - # ensure we have our news logfile. - if ( cleanLog == "true" ) - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) - else - newsLog = File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) - end - - # pick up the abtlinux.org news feed. - if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) - logger.logToJournal( "Failed to retrieve news feed #{uri}." ) - return false - end - - # display the feeds. - rss = nil - begin - rss = RSS::Parser.parse(news, false) - rescue RSS::Error - end - - if ( rss.nil? ) - logger.logToJournal( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) - return false - else - newsLog.puts "*** #{rss.channel.title} ***" - - rss.items.each_with_index do |item, itemCount| - itemCount += 1 - newsLog.puts "#{itemCount} #{item.link} #{item.title}" - end - end - - newsLog.puts "\n" - newsLog.close - return true - + require 'net/http' + require 'uri' + require 'rss/1.0' + require 'rss/2.0' + newsLog = "" + + # ensure we have our news logfile. + if ( cleanLog == "true" ) + newsLog = + File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) + else + newsLog = + File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) + end + + # pick up the abtlinux.org news feed. + if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) + logger.logToJournal( "Failed to retrieve news feed #{uri}." ) + return false + end + + # display the feeds. + rss = nil + begin + rss = RSS::Parser.parse(news, false) + rescue RSS::Error + end + + if ( rss.nil? ) + logger.logToJournal( "Failed to display news feed as feed #{uri} " + + "is not RSS 1.0/2.0." ) + return false + else + newsLog.puts "*** #{rss.channel.title} ***" + + rss.items.each_with_index do |item, itemCount| + itemCount += 1 + newsLog.puts "#{itemCount} #{item.link} #{item.title}" + end + end + + newsLog.puts "\n" + newsLog.close + return true + end ## Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtLogManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -57,7 +57,7 @@ ## def initialize [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, - $PACKAGE_CACHED, $ABT_TMP, $SOURCES_REPOSITORY].each { |dir| + $PACKAGE_CACHED, $ABT_TMP, $SOURCES_REPOSITORY].each { |dir| if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) @@ -77,7 +77,8 @@ ## def logPackageInstall( package ) # some dirs we will not add to an install log. - excluded_pattern = Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) + excluded_pattern = + Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) require package sw = eval( "#{package.capitalize}.new" ) @@ -85,7 +86,8 @@ badLine = false # used to mark excluded lines from installwatch log. # our log locations. - installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.install" + installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" tmpInstallLog = "#{$ABT_TMP}/#{details['Source location']}.watch" # get the installed files from the tmp file @@ -97,13 +99,11 @@ # and not part of the excluded range of directories. IO.foreach( tmpInstallLog ) do |line| if ( line.split[1] == 'open' ) - #self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." ) if ( line.split[2] =~ excluded_pattern ) #self.logToJournal( "DEBUG: Found bad logLine!" ) badLine = true else badLine = false - #self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}") end if ( !badLine ) @@ -134,7 +134,8 @@ require package sw = eval( "#{package.capitalize}.new" ) details = sw.details - buildFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.build" + buildFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.build" #self.logToJournal( "DEBUG: buildFile is - #{buildFile}" ) # make sure the build file exists. @@ -173,7 +174,9 @@ # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. ## def logToJournal( message ) - if ( log = File.new( $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + if ( + log = File.new( + $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) log.puts "#{$TIMESTAMP} : #{message}" log.close return true Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtPackageManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -36,7 +36,8 @@ ## # Constructor for AbtPackageManager. # - # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized AbtPackageManager object. + # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized + # AbtPackageManager object. ## def initialize end @@ -70,7 +71,8 @@ # pre section. puts "\n*** Processing the PRE section for #{package}. ***" if ( !sw.pre ) - logger.logToJournal( "Failed to process pre-section in the package description of #{package}." ) + logger.logToJournal( "Failed to process pre-section in the " + + "package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} pre section." ) @@ -79,7 +81,8 @@ # configure section. puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( !sw.configure ) - logger.logToJournal( "Failed to process configure section in the package description of #{package}." ) + logger.logToJournal( "Failed to process configure section in the " + + "package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} configure section." ) @@ -88,7 +91,8 @@ # build section. puts "\n*** Processing the BUILD section for #{package}. ***" if ( !sw.build ) - logger.logToJournal( "Failed to process build section in the package description of #{package}." ) + logger.logToJournal( "Failed to process build section in the " + + "package description of #{package}." ) return false else if ( !logger.logPackageBuild( sw.name.downcase ) ) @@ -101,7 +105,8 @@ # preinstall section. puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( !sw.preinstall ) - logger.logToJournal( "Failed to process preinstall section in the package description of #{package}." ) + logger.logToJournal( "Failed to process preinstall section in the " + + "package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} preinstall section." ) @@ -110,33 +115,37 @@ # install section. puts "\n*** Processing the INSTALL section for #{package}. ***" if ( !sw.install ) - logger.logToJournal( "Failed to process install section in the package description of #{package}." ) + logger.logToJournal( "Failed to process install section in the " + + "package description of #{package}." ) return false else logger.logPackageInstall( sw.name.downcase ) # TODO: logger.logPackageIntegrity( sw.name.downcase ) logger.logToJournal( "DEBUG: finished #{package} install section." ) end - + # post section. puts "\n*** Processing the POST section for #{package}. ***" if ( !sw.post ) - logger.logToJournal( "Failed to process post section in the package description of #{package}." ) + logger.logToJournal( "Failed to process post section in the " + + "package description of #{package}." ) return false else logger.logToJournal( "DEBUG: finished #{package} post section." ) end - + # clean out build sources. puts "\n*** Cleaning up the sources for #{package}. ***" if ( !sw.removeBuild ) - logger.logToJournal( "Failed to remove the build sources for #{package}." ) + logger.logToJournal( "Failed to remove the build sources for " + + "#{package}." ) #return false # commented out as this is not a reason to fail. end - + # remove pacakge from install queue. if ( !queuer.actionPackageQueue( sw.name.downcase, "install", "remove" ) ) - logger.logToJournal( "Failed to remove #{sw.name.donwcase} from install queue." ) + logger.logToJournal( "Failed to remove #{sw.name.donwcase} " + + "from install queue." ) end return true # install completed! @@ -147,8 +156,8 @@ # # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. # - # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, otherwise - # false. + # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, + # otherwise false. ## def reinstallPackage( package ) end Modified: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtQueueManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -25,21 +25,22 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtQueueManager - -protected - -private - -public - + + protected + + private + + public + ## # Constructor for the AbtQueueManager class. # - # <b>RETURN</b> <i>AbtQueueManager</i> - an initialized AbtQueueManager object. + # <b>RETURN</b> <i>AbtQueueManager</i> - an initialized + # AbtQueueManager object. ## def initialize end - + ## # Add/Remove a given package to the given queue. # If adding a package already in the queue then it will not @@ -54,7 +55,7 @@ require 'fileutils' logger = AbtLogManager.new queueFile = "" # used to hold the queue location. - + # want to name install queue differently from log files. if ( queue == 'install' ) queueFile = "#{$ABT_LOGS}/#{queue}.queue" @@ -63,26 +64,33 @@ end if ( action == "add") - if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + if ( + log = File.new( + queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) # pickup queue contents to ensure no duplicates. checkingQueue = IO.readlines( queueFile ) - + # check if package exists, otherwise add. - if ( ! checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( package ) ) + if ( + !checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( + package ) ) log.puts "#{package}|#{$TIMESTAMP}" logger.logToJournal( "Added #{package} to #{queue} queue." ) else - logger.logToJournal( "Did not add #{package} to #{queue}, already exists." ) + logger.logToJournal( + "Did not add #{package} to #{queue}, already exists." ) end - + log.close return true end end - + if ( action == "remove" ) # remove entry from given queue. - if ( log = File.new( queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + if ( + log = File.new( + queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) # use temp file to filter out entry to be removed. temp = File.new(queueFile + ".tmp", "a+") Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtReportManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -26,35 +26,36 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtReportManager - -protected - -private - -public - + + protected + + private + + public + ## # Constructor for the AbtReportManager. # - # <b>RETURN</b> <i>AbtReportManager</i> - an initialized Report1Manager object. + # <b>RETURN</b> <i>AbtReportManager</i> - an initialized + # Report1Manager object. ## def initialize end - + ## # Display all data for a given package. # # <b>PARAM</b> <i>String</i> - Package name. # - # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise - # false. + # <b>RETURN</b> <i>boolean</i> - True if completes without error, + # otherwise false. ## def showPackageDetails( package ) require package - + if ( package = eval( "#{package.capitalize}.new" ) ) details = package.details - + puts "|=====================================" puts "| Package name\t: #{details['Package name']}" details.delete( "Package name" ) @@ -70,25 +71,26 @@ details.delete( "Description" ) puts "|=====================================" puts "|=====================================" - + details.each do |name, value| print "| #{name}\t" - + if ( name.length < 14 ) print "\t" end - + puts ": #{value}" end - + puts "|=====================================" return true end - - logger.logToJournal( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) + + logger.logToJournal( "[AbtReportManger::showPackageDetails] - failed" + + "to show details for ${package}." ) return false end - + ## # Display all packages installed and tracked by AbTLinux. # @@ -96,7 +98,7 @@ ## def showInstalledPackages end - + ## # Display the contents of the requested log for a given package. Possible # log types are; install, build and integrity. @@ -112,7 +114,7 @@ # build log # integrity log end - + ## # Display a list of the packages found in the frozen list. # @@ -120,7 +122,7 @@ ## def showFrozenPackages end - + ## # Provides access to dependency checking via the AbTLinux DepEngine. (This # portal to the DepEngine will be expanded in apart sub-project, more @@ -133,7 +135,7 @@ ## def showPackageDependencies( package ) end - + ## # Display all files not part of any installed AbTLinux package. This # delivers a list of files that are not tracked by AbTLinux package @@ -143,7 +145,7 @@ ## def showUntrackedFiles end - + ## # Display the AbTLinux journal file. # @@ -161,13 +163,14 @@ puts "\n\n" else puts "\n\n" - puts "AbtLinux log ( #{File.basename( fileName )} ) is empty at this time." + puts "AbtLinux log ( #{File.basename( fileName )} ) " + + "is empty at this time." puts "\n\n" end - + return true end - + ## # Display the name of the package(s) that own the given file. # @@ -177,7 +180,7 @@ ## def showFileOwner( file ) end - + ## # Searches the installed package trees package descriptions for matching # occurrances of the given search text. @@ -189,7 +192,7 @@ ## def searchPackageDescriptions( searchText ) end - + ## # Displays the contents of the current queue based on the given queue. # @@ -201,7 +204,7 @@ def showQueue( queueType ) case queueType - + when "install" if ( File.exist?( "#{$ABT_LOGS}/#{queueType}.queue" ) ) puts "\n\n" @@ -219,7 +222,7 @@ puts "#{queueType.capitalize} is not an AbTLinux queue." end end - + ## # Reports available updates for a given package or package tree based on the # current system. @@ -232,7 +235,7 @@ ## def showUpdates( target ) end - + ## # Generates an HTML page of installed packages from installed packages list. # @@ -240,5 +243,5 @@ ## def generateHTMLPackageListing end - + end Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/AbtSystemManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -27,21 +27,22 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class AbtSystemManager - -protected - -private - -public - + + protected + + private + + public + ## # Constructor for the System manager # - # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized AbtSystemManager object. + # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized + # AbtSystemManager object. ## def initialize end - + ## # Removes all sources for packages that are not currently installed. Makes # use of install listing to determine package sources to keep. @@ -51,7 +52,7 @@ ## def cleanupPackageSources end - + ## # All logs for packages not in install list are cleaned off the system. # @@ -60,29 +61,29 @@ ## def cleanupLogs end - + ## # Checks if files from given package install list are actually installed. # # <b>PARAM</b> <i>String</i> - Package name. # - # <b>RETURN</b> <i>boolean</i> - True if no installed files are missing, otherwise - # false. + # <b>RETURN</b> <i>boolean</i> - True if no installed files are missing, + # otherwise false. ## def verifyInstalledFiles( package ) end - + ## # Checks if given packages installed symlinks are broken or missing. # # <b>PARAM</b> <i>String</i> - Package name. # - # <b>RETURN</b> <i>boolean</i> - True if no symlinks found missing or broken, otherwise - # false. + # <b>RETURN</b> <i>boolean</i> - True if no symlinks found missing + # or broken, otherwise false. ## def verifySymlinks( package ) end - + ## # Checks the given packages dependencies for missing or broken dependencies. # @@ -93,7 +94,7 @@ ## def verifyPackageDepends( package ) end - + ## # Checks the given packages installed files against the integrity log for # changes to installed files. @@ -105,7 +106,7 @@ ## def verifyPackageIntegrity( package ) end - + ## # Fixes the given package. # @@ -116,7 +117,7 @@ ## def fixPackage( package ) end - + ## # Sets the URI of a central repository for pre-compiled packages. # @@ -127,7 +128,7 @@ ## def setCentralRepo( uri ) end - + ## # Sets the location where the package tree is to be downloaded from, can be # set to a local location. Modified: src/trunk/TestAbtDepEngine.rb =================================================================== --- src/trunk/TestAbtDepEngine.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtDepEngine.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -29,7 +29,7 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtDepEngine < Test::Unit::TestCase - + ## # setup method for testing AbtDepEngine. ## Modified: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtDownloadManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -31,7 +31,7 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtDownloadManager < Test::Unit::TestCase - + ## # setup method for testing AbtDownloadManager. ## @@ -49,30 +49,32 @@ # Test method for 'AbtDownloadManager.testRetrievePackageSource()' ## def testRetrievePackageSource() - assert( @download.retrievePackageSource( "ipc", "/tmp" ), "testRetrievePackageSource()" ) + assert( @download.retrievePackageSource( "ipc", "/tmp" ), + "testRetrievePackageSource()" ) end ## # Test method for 'AbtDownloadManager.testRetrievePackageTree()' ## def testRetrievePackageTree() - assert( @download.retrievePackageTree( "dummy" ), "testRetrievePackageTree()" ) + assert( @download.retrievePackageTree( "dummy" ), + "testRetrievePackageTree()" ) end - + ## # Test method for 'AbtDownloadManager.testRetrieveNewsFeed()' ## def testRetrieveNewsFeed() assert( @download.retrieveNewsFeed( $ABTNEWS ), "testRetrieveNewsFeed()" ) end - + ## # Test method for 'AbtDownloadManager.testUpdatePackage()' ## def testUpdatePackage() assert( @download.updatePackage(), "testUpdatePackage()" ) end - + ## # Test method for 'AbtDownloadManager.testUpdatePackageTree()' ## Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtLogManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -30,7 +30,7 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtLogManager < Test::Unit::TestCase - + ## # setup method for testing AbtLogManager. ## @@ -59,26 +59,27 @@ #def testLogPackageInstall() # assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) #end - + ## # Test method for 'AbtLogManager.testLogPackageBuild()' ## def testLogPackageBuild() assert( @log.logPackageBuild( "ipc" ), "testLogPackageBuild()" ) end - + ## # Test method for 'AbtLogManager.testCachePackage()' ## def testCachePackage() assert( @log.cachePackage( "ipc" ), "testCachePackage()" ) end - + ## # Test method for 'AbtLogManager.testLogToJournal()' ## def testLogToJournal() - assert( @log.logToJournal( "Test message from AbtTestSuite." ), "testLogToJournal()" ) + assert( @log.logToJournal( "Test message from AbtTestSuite." ), + "testLogToJournal()" ) end - + end Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtPackage.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -32,11 +32,11 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtPackage < Test::Unit::TestCase - + $nameTest = "Ipc" $versionTest = "1.4" $srcDirTest = "#{$nameTest.downcase}-#{$versionTest}" - + $dataTest = { 'name' => $nameTest, 'execName' => $nameTest.downcase, @@ -44,14 +44,14 @@ 'srcDir' => $srcDirTest, 'homepage' => "http://isotopatcalc.sourceforge.net/" } - + ## # setup method for testing AbtPackage. ## def setup @ipc = Ipc.new end - + ## # teardown method to cleanup after testing. ## @@ -62,11 +62,16 @@ # Test method for 'AbtPackage.testDetails()' ## def testDetails - assert_equal( $dataTest['name'], @ipc.details['Package name'], "testDetails()" ) - assert_equal( $dataTest['execName'], @ipc.details['Executable'], "testDetails()" ) - assert_equal( $dataTest['version'], @ipc.details['Version'], "testDetails()" ) - assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], "testDetails()" ) - assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], "testDetails()" ) + assert_equal( $dataTest['name'], @ipc.details['Package name'], + "testDetails()" ) + assert_equal( $dataTest['execName'], @ipc.details['Executable'], + "testDetails()" ) + assert_equal( $dataTest['version'], @ipc.details['Version'], + "testDetails()" ) + assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], + "testDetails()" ) + assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], + "testDetails()" ) end ## @@ -75,7 +80,7 @@ def testPre assert( @ipc.pre(), "testPre()" ) end - + ## # Test method for 'AbtPackage.testConfigure()' ## @@ -85,7 +90,7 @@ end assert( @ipc.configure(), "testConfigure()" ) end - + ## # Test method for 'AbtPackage.testBuild()' ## @@ -98,19 +103,19 @@ end assert( @ipc.build(), "testBuild()" ) end - + ## # Test method for 'AbtPackage.testPreinstall()' ## def testPreinstall assert( @ipc.preinstall(), "testPreinstall()" ) end - + ## # Test method for 'AbtPackage.testInstall()' ## def testInstall - if ( !@ipc.pre() ) + if ( !@ipc.pre() ) assert_equals( true, false, "testInstall()" ) end if ( !@ipc.configure() ) @@ -124,7 +129,7 @@ end assert( @ipc.install(), "testInstall()" ) end - + ## # Test method for 'AbtPackage.testPost()' ## @@ -146,5 +151,5 @@ end assert( @ipc.post(), "testPost()" ) end - + end Modified: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtPackageManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -29,14 +29,14 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtPackageManager < Test::Unit::TestCase - + ## # setup method for testing AbtPackageManager. ## def setup @pkgMgr = AbtPackageManager.new() end - + ## # teardown method to cleanup after testing. ## @@ -49,33 +49,33 @@ def testInstallPackage assert( @pkgMgr.installPackage( "ipc" ), "testInstallPackage()" ) end - + ## # Test method for 'AbtPackageManager.testReinstallPackage()' ## def testReinstallPackage assert( @pkgMgr.reinstallPackage( "ipc" ), "testReinstallPackage()" ) end - + ## # Test method for 'AbtPackageManager.testRemovePackage()' ## def testRemovePackage assert( @pkgMgr.removePackage( "ipc" ), "testRemovePackage()" ) end - + ## # Test method for 'AbtPackageManager.testDowngradePackage()' ## def testDowngradePackage assert( @pkgMgr.downgradePackage( "ipc", "1.2" ), "testDowngradePackage()" ) end - + ## # Test method for 'AbtPackageManager.testFreezePackage()' ## def testFreezePackage assert( @pkgMgr.freezePackage( "ipc" ), "testFreezePackage()" ) end - + end Modified: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtQueueManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -31,7 +31,7 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtQueueManager < Test::Unit::TestCase - + ## # setup method for testing AbtQueueManager. ## @@ -49,7 +49,8 @@ # Test method for 'AbtQueueManager.actionPackageQueue()' ## def testActionPackageQueue - assert( @queue.actionPackageQueue( "ipc", "install", "add" ), "testQueueManager()" ) + assert( @queue.actionPackageQueue( "ipc", "install", "add" ), + "testQueueManager()" ) end - + end Modified: src/trunk/TestAbtReportManager.rb =================================================================== --- src/trunk/TestAbtReportManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtReportManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -30,14 +30,14 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtReportManager < Test::Unit::TestCase - + ## # setup method for testing AbtReportManager. ## def setup @report = AbtReportManager.new() end - + ## # teardown method to cleanup after testing. ## @@ -50,88 +50,92 @@ def testShowPackageDetails assert( @report.showPackageDetails( "ipc" ), "testShowPackageDetails()" ) end - + ## # Test method for 'AbtReportManager.testShowInstalledPackages()' ## def testShowInstalledPackages assert( @report.showInstalledPackages(), "testShowInstalledPackages()" ) end - + ## # Test method for 'AbtReportManager.testShowPackageLog()' ## def testShowPackageLog - assert( @report.showPackageLog( "ipc", "install" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "install" ), + "testShowPackageLog()" ) assert( @report.showPackageLog( "ipc", "build" ), "testShowPackageLog()" ) - assert( @report.showPackageLog( "ipc", "integrity" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "integrity" ), + "testShowPackageLog()" ) end - + ## # Test method for 'AbtReportManager.testShowFrozenPackages()' ## def testShowFrozenPackages assert( @report.showFrozenPackages(), "testShowFrozenPackages()" ) end - + ## # Test method for 'AbtReportManager.testShowPackageDependencies()' ## def testShowPackageDependencies assert( false, "testShowPackageDependencies()" ) end - + ## # Test method for 'AbtReportManager.testShowUntrackedFiles()' ## def testShowUntrackedFiles assert( @report.showUntrackedFiles(), "testShowUntrackedFiles()" ) end - + ## # Test method for 'AbtReportManager.testShowJournal()' ## def testShowJournal assert( @report.showJournal( $JOURNAL ), "testShowJournal()" ) end - + ## # Test method for 'AbtReportManager.testShowFileOwner()' ## def testShowFileOwner assert( @report.showFileOwner( "ipcFile" ), "testShowFileOwner()" ) end - + ## # Test method for 'AbtReportManager.testSearchPackageDescriptions()' ## def testSearchPackageDescriptions - assert( @report.searchPackageDescriptions( "Special text" ), "testSearchPackageDescriptions()" ) + assert( @report.searchPackageDescriptions( "Special text" ), + "testSearchPackageDescriptions()" ) end - + ## # Test method for 'AbtReportManager.testShowQueue()' ## def testShowQueue - if ( @report.showQueue( "install" ) ) - assert(false, "testShowQueue()") - else - assert(true, "testShowQueue()") - end + if ( @report.showQueue( "install" ) ) + assert(false, "testShowQueue()") + else + assert(true, "testShowQueue()") + end end - + ## # Test method for 'AbtReportManager.testShowUpdates()' ## def testShowUpdates assert( @report.showUpdates( "ipc" ), "testShowUpdates()" ) end - + ## # Test method for 'AbtReportManager.testGenerateHTMLPackageListing()' ## def testGenerateHTMLPackageListing - assert( @report.generateHTMLPackageListing(), "testGenerateHTMLPackageListing()" ) + assert( @report.generateHTMLPackageListing(), + "testGenerateHTMLPackageListing()" ) end - + end Modified: src/trunk/TestAbtSystemManager.rb =================================================================== --- src/trunk/TestAbtSystemManager.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/TestAbtSystemManager.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -29,81 +29,83 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtSystemManager < Test::Unit::TestCase - + ## # setup method for testing AbtSystemManager. ## def setup @sys = AbtSystemManager.new() end - + ## # teardown method to cleanup after testing. ## def teardown end - + ## # Test method for 'AbtSystemManager.testCleanupPackageSources()' ## def testCleanupPackageSources assert( @sys.cleanupPackageSources(), "testCleanupPackageSources()" ) end - + ## # Test method for 'AbtSystemManager.testCleanupLogs()' ## def testCleanupLogs assert( @sys.cleanupLogs(), "testCleanupLogs()" ) end - + ## # Test method for 'AbtSystemManager.testVerifyInstalledFiles()' ## def testVerifyInstalledFiles assert( @sys.verifyInstalledFiles( "dummy" ), "testVerifyInstalledFiles()" ) end - + ## # Test method for 'AbtSystemManager.testVerifySymlinks()' ## def testVerifySymlinks assert( @sys.verifySymlinks( "dummy" ), "testVerifySymlinks()" ) end - + ## # Test method for 'AbtSystemManager.testVerifyPackageDepends()' ## def testVerifyPackageDepends assert( @sys.verifyPackageDepends( "dummy" ), "testVerifyPackageDepends()" ) end - + ## # Test method for 'AbtSystemManager.testVerifyPackageIntegrity()' ## def testVerifyPackageIntegrity - assert( @sys.verifyPackageIntegrity( "dummy" ), "testVerifyPackageIntegrity()" ) + assert( @sys.verifyPackageIntegrity( "dummy" ), + "testVerifyPackageIntegrity()" ) end - + ## # Test method for 'AbtSystemManager.testFixPackage()' ## def testFixPackage assert( @sys.fixPackage( "dummy" ), "testFixPackage()" ) end - + ## # Test method for 'AbtSystemManager.testSetCentralRepo()' ## def testSetCentralRepo assert( @sys.setCentralRepo( "http://localhost" ), "testSetCentralRepo()" ) end - + ## # Test method for 'AbtSystemManager.testSetPackageTreeLocation()' ## def testSetPackageTreeLocation - assert( @sys.setPackageTreeLocation( "/var/lib/ericsPackages" ), "testSetPackageTreeLocation()" ) + assert( @sys.setPackageTreeLocation( "/var/lib/ericsPackages" ), + "testSetPackageTreeLocation()" ) end - + end Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/abt.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -55,331 +55,332 @@ # parse arguments. case ARGV[0] - + # abt [ -i | install ] <package> - when "install", "-i" - if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) - options['package'] = ARGV[1] - logger.logToJournal( "Starting to install #{options['package']}" ) - - if ( manager.installPackage( options['package'] ) ) - puts "\n\n" - puts "*** Completed install of #{options['package']}. ***" - puts "\n\n" - logger.logToJournal( "Completed install of #{options['package']}." ) - else - puts "*** #{options['package'].capitalize} install failed, see journal. ***" - end - - #reporter.showQueue( "install" ); # DEBUG. +when "install", "-i" + if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) + options['package'] = ARGV[1] + logger.logToJournal( "Starting to install #{options['package']}" ) + + if ( manager.installPackage( options['package'] ) ) + puts "\n\n" + puts "*** Completed install of #{options['package']}. ***" + puts "\n\n" + logger.logToJournal( "Completed install of #{options['package']}." ) else - show.usage( "packages" ) - exit + puts "*** #{options['package'].capitalize} install failed, " + + "see journal. ***" end - - when "reinstall", "-ri" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Reinstalling package : " + options['package'] - else - show.usage( "packages" ) - exit - end - - when "remove", "-r" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Removing package : " + options['package'] - else - show.usage( "packages" ) - exit - end - - when "downgrade", "-dg" - if ( ARGV.length == 3 ) - options['version'] = ARGV[1] - options['package'] = ARGV[2] - print "Downgradinging package : #{options['package']} " - puts "to version : #{options['version']}" - else - show.usage( "packages" ) - exit - end - - when "freeze", "-f" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Holdinging package : #{options['package']} at current version." - else - show.usage( "packages" ) - exit - end - - when "search", "-s" - if ( ARGV.length == 2 ) - options['searchString'] = ARGV[1] - puts "Searching package descriptions for : #{options['searchString']}" - else - show.usage( "queries" ) - exit - end - + + #reporter.showQueue( "install" ); # DEBUG. + else + show.usage( "packages" ) + exit + end + +when "reinstall", "-ri" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Reinstalling package : " + options['package'] + else + show.usage( "packages" ) + exit + end + +when "remove", "-r" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Removing package : " + options['package'] + else + show.usage( "packages" ) + exit + end + +when "downgrade", "-dg" + if ( ARGV.length == 3 ) + options['version'] = ARGV[1] + options['package'] = ARGV[2] + print "Downgradinging package : #{options['package']} " + puts "to version : #{options['version']}" + else + show.usage( "packages" ) + exit + end + +when "freeze", "-f" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Holdinging package : #{options['package']} at current version." + else + show.usage( "packages" ) + exit + end + +when "search", "-s" + if ( ARGV.length == 2 ) + options['searchString'] = ARGV[1] + puts "Searching package descriptions for : #{options['searchString']}" + else + show.usage( "queries" ) + exit + end + # abt -v | --version - when "-v", "--version" - if ( ARGV.length == 1 ) - puts "Abt Package Manager version is : #{$ABT_VERSION}" - else - show.usage( "queries" ) - exit - end - +when "-v", "--version" + if ( ARGV.length == 1 ) + puts "Abt Package Manager version is : #{$ABT_VERSION}" + else + show.usage( "queries" ) + exit + end + # abt show-details <package> - when "show-details" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) - options['pkg'] = ARGV[1] - logger.logToJournal( "Starting show details for #{options['pkg']}" ) - - if ( reporter.showPackageDetails( options['pkg'] ) ) - logger.logToJournal( "Completed show details for #{options['pkg']}" ) - else - puts "Problems processing the details for #{options['pkg']}." - end +when "show-details" + if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + options['pkg'] = ARGV[1] + logger.logToJournal( "Starting show details for #{options['pkg']}" ) + + if ( reporter.showPackageDetails( options['pkg'] ) ) + logger.logToJournal( "Completed show details for #{options['pkg']}" ) else - show.usage( "queries" ) + puts "Problems processing the details for #{options['pkg']}." end - - when "show-build" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Display build log for package : " + options['package'] - else - show.usage( "queries" ) - exit - end - - - when "show-depends" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Display dependency tree for package : " + options['package'] - else - show.usage( "queries" ) - exit - end - - when "show-files" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Display installed files from package : " + options['package'] - else - show.usage( "queries" ) - exit - end - - when "show-owner" - if ( ARGV.length == 2 ) - options['fileName'] = ARGV[1] - puts "Display owning package for file : " + options['fileName'] - else - show.usage( "queries" ) - exit - end - - when "show-installed" - puts "Display all installed packages." + else show.usage( "queries" ) - - when "show-frozen" - puts "Display all packages frozen at current version." + end + +when "show-build" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Display build log for package : " + options['package'] + else show.usage( "queries" ) - - when "show-untracked" - puts "Display all files on system not tracked by AbTLinux." + exit + end + + +when "show-depends" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Display dependency tree for package : " + options['package'] + else show.usage( "queries" ) - + exit + end + +when "show-files" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Display installed files from package : " + options['package'] + else + show.usage( "queries" ) + exit + end + +when "show-owner" + if ( ARGV.length == 2 ) + options['fileName'] = ARGV[1] + puts "Display owning package for file : " + options['fileName'] + else + show.usage( "queries" ) + exit + end + +when "show-installed" + puts "Display all installed packages." + show.usage( "queries" ) + +when "show-frozen" + puts "Display all packages frozen at current version." + show.usage( "queries" ) + +when "show-untracked" + puts "Display all files on system not tracked by AbTLinux." + show.usage( "queries" ) + # abt show-journal - when "show-journal" - reporter.showJournal( $JOURNAL ) - - when "show-iqueue" - reporter.showQueue( "install" ) - - when "show-patches" - puts "Display currently available patches for installed package tree." - show.usage( "queries" ) - - when "show-updates" - puts "Display package listing with available update versions." - show.usage( "generation" ) - - when "html" - puts "Generate HTML page from installed packages:" - puts " (package name with link to package website/version installed)" - show.usage( "generation" ) - +when "show-journal" + reporter.showJournal( $JOURNAL ) + +when "show-iqueue" + reporter.showQueue( "install" ) + +when "show-patches" + puts "Display currently available patches for installed package tree." + show.usage( "queries" ) + +when "show-updates" + puts "Display package listing with available update versions." + show.usage( "generation" ) + +when "html" + puts "Generate HTML page from installed packages:" + puts " (package name with link to package website/version installed)" + show.usage( "generation" ) + # abt news | -n - when "news", "-n" - logger.logToJournal( "Starting to retrieve AbTLinux news." ) - - # abtlinux.org news feeds. - puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS , "true" ) ) - puts "Failed to retrieve the AbTLinux news feed." - end - - puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS_THREADS ) ) - puts "Failed to retrieve the AbTLinux forum threads news feed." - end - - puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS_POSTS ) ) - puts "Failed to retrieve the AbTLinux new posts news feed." - end - - # display the file contents. - reporter.showJournal( $ABTNEWS_LOG ) - - logger.logToJournal( "Completed the retrieval of AbTLinux news." ) - +when "news", "-n" + logger.logToJournal( "Starting to retrieve AbTLinux news." ) + + # abtlinux.org news feeds. + puts "\n" + if ( !downloader.retrieveNewsFeed( $ABTNEWS , "true" ) ) + puts "Failed to retrieve the AbTLinux news feed." + end + + puts "\n" + if ( !downloader.retrieveNewsFeed( $ABTNEWS_THREADS ) ) + puts "Failed to retrieve the AbTLinux forum threads news feed." + end + + puts "\n" + if ( !downloader.retrieveNewsFeed( $ABTNEWS_POSTS ) ) + puts "Failed to retrieve the AbTLinux new posts news feed." + end + + # display the file contents. + reporter.showJournal( $ABTNEWS_LOG ) + + logger.logToJournal( "Completed the retrieval of AbTLinux news." ) + # abt [-d | download ] <package> - when "download", "-d" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) - options['pkg'] = ARGV[1] - logger.logToJournal( "Starting to download " + options['pkg'] ) - - manager = AbtDownloadManager.new - - if ( manager.retrievePackageSource( options['pkg'], $SOURCES_REPOSITORY ) ) - logger.logToJournal( "Finished download for " + options['pkg'] ) - puts "\n"; - print "Downloading of #{options['pkg']} to #{$SOURCES_REPOSITORY} " - puts "completed." - puts "\n\n" - else - logger.logToJournal( "FAILURE to download " + options['pkg'] ) - puts "\n" - puts "DOWNLOADING - failed to download source for #{options['pkg']}" - puts "\n\n" - end +when "download", "-d" + if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + options['pkg'] = ARGV[1] + logger.logToJournal( "Starting to download " + options['pkg'] ) + + manager = AbtDownloadManager.new + + if ( manager.retrievePackageSource( options['pkg'], $SOURCES_REPOSITORY ) ) + logger.logToJournal( "Finished download for " + options['pkg'] ) + puts "\n"; + print "Downloading of #{options['pkg']} to #{$SOURCES_REPOSITORY} " + puts "completed." + puts "\n\n" else - show.usage( "downloads" ) - exit + logger.logToJournal( "FAILURE to download " + options['pkg'] ) + puts "\n" + puts "DOWNLOADING - failed to download source for #{options['pkg']}" + puts "\n\n" end - - when "update", "-u" - if ( ARGV.length == 2 ) - options['updateItem'] = ARGV[1] - puts "Updating item : #{options['updateItem']}" - else - show.usage( "downloads" ) - exit - end - - when "purge-src" - puts "Remove source caches for packages no longer installed." + else + show.usage( "downloads" ) + exit + end + +when "update", "-u" + if ( ARGV.length == 2 ) + options['updateItem'] = ARGV[1] + puts "Updating item : #{options['updateItem']}" + else + show.usage( "downloads" ) + exit + end + +when "purge-src" + puts "Remove source caches for packages no longer installed." + show.usage( "fix" ) + +when "purge-logs" + puts "Remove log files for packages no longer installed." + show.usage( "fix" ) + +when "verify-files" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Installed files verified for package : " + options['package'] + else show.usage( "fix" ) - - when "purge-logs" - puts "Remove log files for packages no longer installed." + exit + end + +when "verify-symlinks" + if ( ARGV.length == 2 ) + options['package'] = ARGV[1] + puts "Symlinks verified for package : " + options['package'] + else show.usage( "fix" ) - - when "verify-files" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Installed files verified for package : " + options['package'] - else - show.usage( "fix" ) - exit - end - - when "verify-symlinks" - if ( ARGV.length == 2 ) + exit + end + +when "verify-deps" + if ( ARGV.length == 2 ) options['package'] = ARGV[1] puts "Symlinks verified for package : " + options['package'] else show.usage( "fix" ) exit end - - when "verify-deps" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - puts "Symlinks verified for package : " + options['package'] + +when "verify-integrity" + if ( ARGV.length == 2 ) + options['pkg'] = ARGV[1] + print "Verifiy integrity of installed files for " + puts "package : #{options['pkg']}" + else + show.usage( "fix" ) + exit + end + +when "fix" + if ( ARGV.length == 2 ) + options['pkg'] = ARGV[1] + puts "Package : #{options['pkg']} is verified and checked if needed." + else + show.usage( "fix" ) + exit + end + +when "build-location" + if ( ARGV.length == 2 ) + options['buildHost'] = ARGV[1] + print "Sets global location for retrieving cached build packages " + puts "to : #{options['buildHost']}" + else + show.usage( "maintenance" ) + exit + end + +when "package-repo" + # sort out that we have enough args. + case ARGV.length + + # add or remove called. + when 3 + options['repoAction'] = ARGV[1] + options['repoUri'] = ARGV[2] + + # list called. + when 2 + if ( ARGV[1] == "list" ) + options['repoAction'] = ARGV[1] else - show.usage( "fix" ) - exit - end - - when "verify-integrity" - if ( ARGV.length == 2 ) - options['pkg'] = ARGV[1] - print "Verifiy integrity of installed files for " - puts "package : #{options['pkg']}" - else - show.usage( "fix" ) - exit - end - - when "fix" - if ( ARGV.length == 2 ) - options['pkg'] = ARGV[1] - puts "Package : #{options['pkg']} is verified and checked if needed." - else - show.usage( "fix" ) - exit - end - - when "build-location" - if ( ARGV.length == 2 ) - options['buildHost'] = ARGV[1] - print "Sets global location for retrieving cached build packages " - puts "to : #{options['buildHost']}" - else show.usage( "maintenance" ) exit end - - when "package-repo" - # sort out that we have enough args. - case ARGV.length - - # add or remove called. - when 3 - options['repoAction'] = ARGV[1] - options['repoUri'] = ARGV[2] - - # list called. - when 2 - if ( ARGV[1] == "list" ) - options['repoAction'] = ARGV[1] - else - show.usage( "maintenance" ) - exit - end - - else - show.usage( "maintenance" ) - exit - end # case ARGV.length. - - # hook location based on action. - case options['repoAction'] - - when "add" - puts "Adding package repository : " + options['repoUri'] - - when "remove" - puts "Remove package repository : " + options['repoUri'] - - when "list" - puts "Display listing of package repositories." - - else - show.usage( "maintenance" ) - exit - end # case repoAction. - + else - show.usage( "all" ) + show.usage( "maintenance" ) + exit + end # case ARGV.length. + + # hook location based on action. + case options['repoAction'] + + when "add" + puts "Adding package repository : " + options['repoUri'] + + when "remove" + puts "Remove package repository : " + options['repoUri'] + + when "list" + puts "Display listing of package repositories." + + else + show.usage( "maintenance" ) + exit + end # case repoAction. + +else + show.usage( "all" ) end # case ARGV[0]. Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-03-03 13:38:48 UTC (rev 316) +++ src/trunk/testSuiteAbt.rb 2007-03-03 13:57:38 UTC (rev 317) @@ -1,9 +1,9 @@ #!/usr/bin/ruby -wI./packages if ( Process.uid != 0 ) - puts "Enter root password:" - system( 'su -c ./testSuiteAbt.rb root' ) - exit + puts "Enter root password:" + system( 'su -c ./testSuiteAbt.rb root' ) + exit end require 'test/unit' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-05 11:04:04
|
Revision: 319 http://svn.sourceforge.net/abtlinux/?rev=319&view=rev Author: eschabell Date: 2007-03-05 03:04:01 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Updated classes todo task markers changing some more urgent ones to fixme's, this organizes my task list a bit better. Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb src/trunk/TestAbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-03-03 13:58:57 UTC (rev 318) +++ src/trunk/AbtLogManager.rb 2007-03-05 11:04:01 UTC (rev 319) @@ -40,7 +40,7 @@ # otherwise false. ## def logPackageIntegrity( package ) - # TODO: implement logPackageIntegrity. + # FIXME: implement logPackageIntegrity. end Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-03-03 13:58:57 UTC (rev 318) +++ src/trunk/AbtPackage.rb 2007-03-05 11:04:01 UTC (rev 319) @@ -294,12 +294,10 @@ def install Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - # TODO: install section, can this be done without installwatch? if( !system( "installwatch --transl=no --backup=no " + "--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys " + "--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install" ) ) puts "DEBUG: [AbtPackage.install] - install section failed." - # TODO: install section, rollback any installed files (use install log). return false end Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-03 13:58:57 UTC (rev 318) +++ src/trunk/AbtPackageManager.rb 2007-03-05 11:04:01 UTC (rev 319) @@ -117,10 +117,11 @@ if ( !sw.install ) logger.logToJournal( "Failed to process install section in the " + "package description of #{package}." ) + # FIXME: APM rollback any installed files (use install log). return false else logger.logPackageInstall( sw.name.downcase ) - # TODO: logger.logPackageIntegrity( sw.name.downcase ) + # FIXME: logger.logPackageIntegrity( sw.name.downcase ). logger.logToJournal( "DEBUG: finished #{package} install section." ) end Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-03-03 13:58:57 UTC (rev 318) +++ src/trunk/TestAbtLogManager.rb 2007-03-05 11:04:01 UTC (rev 319) @@ -55,7 +55,7 @@ ## # Test method for 'AbtLogManager.testLogPackageInstall()' ## - # TODO: sort out a setup for this test. + # FIXME: sort out a setup for this test. #def testLogPackageInstall() # assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) #end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-06 20:27:13
|
Revision: 324 http://svn.sourceforge.net/abtlinux/?rev=324&view=rev Author: eschabell Date: 2007-03-06 12:25:54 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Moved the call to delete the tmp file from install watch to the pacakgeManager as this should be done after all the logging is done (both install and integrity logs). Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-03-05 20:39:40 UTC (rev 323) +++ src/trunk/AbtLogManager.rb 2007-03-06 20:25:54 UTC (rev 324) @@ -116,8 +116,6 @@ installFile.close end - # cleanup the tmp files. - File.delete( tmpInstallLog ) return true; end Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-05 20:39:40 UTC (rev 323) +++ src/trunk/AbtPackageManager.rb 2007-03-06 20:25:54 UTC (rev 324) @@ -166,7 +166,11 @@ return false else logger.logPackageInstall( sw.name.downcase ) - # FIXME: logger.logPackageIntegrity( sw.name.downcase ). + # FIXME: logger.logPackageIntegrity( sw.name.downcase ) + + # cleanup tmp files from installwatch. + File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) + logger.logToJournal( "DEBUG: finished #{package} install section." ) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-06 21:36:43
|
Revision: 325 http://svn.sourceforge.net/abtlinux/?rev=325&view=rev Author: eschabell Date: 2007-03-06 13:36:43 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Implemented logging of package integrity, currently only with file permissions. Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-03-06 20:25:54 UTC (rev 324) +++ src/trunk/AbtLogManager.rb 2007-03-06 21:36:43 UTC (rev 325) @@ -29,21 +29,6 @@ protected - ## - # Provides logging of the integrity of all installed files for the given - # package. Will be called as part of the logging done during the install - # phase. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if integrity log created successfully, - # otherwise false. - ## - def logPackageIntegrity( package ) - # FIXME: implement logPackageIntegrity. - end - - private public @@ -67,6 +52,49 @@ end ## + # Provides logging of the integrity of all installed files for the given + # package. Will be called as part of the logging done during the install + # phase. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if integrity log created successfully, + # otherwise false. + ## + def logPackageIntegrity( package ) + require package + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + # our log locations. + installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" + integrityLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.integrity" + + # get the installed files from the tmp file + # into our install log. + if ( File.exist?( installLog ) ) + installFile = open( installLog, 'r' ) + integrityFile = open( integrityLog, 'w' ) + + # get the integrity for each file, initially just permissions. + IO.foreach( installLog ) do |line| + status = File.stat( line.chomp ) + octal = sprintf( "%o", status.mode ) + integrityFile.puts "#{line.chomp}:#{octal}" + end + + installFile.close + integrityFile.close + else + return false # no install log! + end + + return true; + end + + ## # Provides logging of all files installed by given package. Should be called # as part of the install phase of the build. # Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-06 20:25:54 UTC (rev 324) +++ src/trunk/AbtPackageManager.rb 2007-03-06 21:36:43 UTC (rev 325) @@ -166,7 +166,7 @@ return false else logger.logPackageInstall( sw.name.downcase ) - # FIXME: logger.logPackageIntegrity( sw.name.downcase ) + logger.logPackageIntegrity( sw.name.downcase ) # cleanup tmp files from installwatch. File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-05-04 12:15:28
|
Revision: 327 http://svn.sourceforge.net/abtlinux/?rev=327&view=rev Author: eschabell Date: 2007-05-04 05:15:26 -0700 (Fri, 04 May 2007) Log Message: ----------- Added verbose variable that defaults to true for console output of installation process, but allows us to set the unit testing to false and remove much of the repeated output during testing. Modified Paths: -------------- src/trunk/AbtPackage.rb src/trunk/AbtPackageManager.rb src/trunk/TestAbtPackage.rb src/trunk/TestAbtPackageManager.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-03-06 21:38:36 UTC (rev 326) +++ src/trunk/AbtPackage.rb 2007-05-04 12:15:26 UTC (rev 327) @@ -198,10 +198,13 @@ # Preliminary work will happen here such as downloading the tarball, # unpacking it, downloading and applying patches. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if completes sucessfully, # otherwise false. ## - def pre + def pre( verbose=true ) downloader = AbtDownloadManager.new # download sources. @@ -235,19 +238,29 @@ # Don't forget too that it's here where we interact with the user in # case there are optionnal dependencies. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, # otherwise false. ## - def configure + def configure( verbose=true ) + if ( verbose ) + command = "./configure --prefix=#{$DEFAULT_PREFIX} | tee " + + "#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure" + else + command = "./configure --prefix=#{$DEFAULT_PREFIX} 1> " + + "#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure 2>&1" + end + Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - if ( !system( "./configure --prefix=#{$DEFAULT_PREFIX} | tee " + - "#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure" ) ) + if ( !system( command ) ) puts "DEBUG: [AbtPackage.configure] - configure section failed." return false end - puts "DEBUG: [AbtPackage.configure] - configure section completed!" + puts "\nDEBUG: [AbtPackage.configure] - configure section completed!" if (verbose ) return true end @@ -255,19 +268,27 @@ # Here is where the actual builing of the software starts, # for example running 'make'. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, # otherwise false. ## - def build + def build( verbose=true ) + if ( verbose ) + command = "make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build" + else + command = "make > #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build 2>&1" + end + Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - if( !system( - "make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build" ) ) + if( !system( command ) ) puts "DEBUG: [AbtPackage.build] - build section failed." return false end - puts "DEBUG: [AbtPackage.build] - build section completed!" + puts "DEBUG: [AbtPackage.build] - build section completed!" if ( verbose ) return true end @@ -276,10 +297,13 @@ # such as creating new user accounts, dealing with existing configuration # files, etc. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, # otherwise false. ## - def preinstall + def preinstall( verbose=true ) # TODO: preinstall section create_group? # TODO: preinstall section create_user? return true; @@ -288,20 +312,31 @@ ## # All files to be installed are installed here. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, # otherwise false. ## - def install + def install( verbose=true ) + if ( verbose ) + command = "installwatch --transl=no --backup=no " + + "--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys " + + "--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install" + else + command = "installwatch --transl=no --backup=no " + + "--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys " + + "--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install >/dev/null" + end + Dir.chdir( "#{$BUILD_LOCATION}/#{@srcDir}" ) - if( !system( "installwatch --transl=no --backup=no " + - "--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys " + - "--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install" ) ) + if( !system( command ) ) puts "DEBUG: [AbtPackage.install] - install section failed." return false end - puts "DEBUG: [AbtPackage.install] - install section completed!" + puts "DEBUG: [AbtPackage.install] - install section completed!" if ( verbose ) return true end @@ -309,10 +344,13 @@ # Last bits of installation. adding the service for automatic # start in init.d for example. # + # <b>PARAM</b> <i>boolean</i> - true if you want to see the verbose output, + # otherwise false. Defaults to true. + # # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, # otherwise false. ## - def post + def post( verbose=true ) # TODO: implement post section install init scripts service return true end @@ -324,6 +362,7 @@ # otherwise false. ## def removeBuild + puts "Removings build..." if ( $REMOVE_BUILD_SOURCES ) buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" @@ -335,7 +374,7 @@ return false end end - + return true end end Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-06 21:38:36 UTC (rev 326) +++ src/trunk/AbtPackageManager.rb 2007-05-04 12:15:26 UTC (rev 327) @@ -87,11 +87,13 @@ # Installs a given package. # # <b>PARAM</b> <i>String</i> - the name of the package to be installed. + # <b>PARAM</b> <i>boolean</i> - true for verbose output from the process, + # otherwise false. Default is true. # # <b>RETURN</b> <i>boolean</i> - True if the package is installed, otherwise # false. ## - def installPackage( package ) + def installPackage( package, verbose=true ) require package sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new @@ -103,14 +105,16 @@ # TODO: check deps # add to install queue. - puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" + puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) + if ( !queuer.actionPackageQueue( package, "install", "add" ) ) logger.logToJournal( "Failed to add #{package} to install queue." ) return false end # pre section. - puts "\n*** Processing the PRE section for #{package}. ***" + puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) + if ( !sw.pre ) logger.logToJournal( "Failed to process pre-section in the " + "package description of #{package}." ) @@ -120,8 +124,9 @@ end # configure section. - puts "\n*** Processing the CONFIGURE section for #{package}. ***" - if ( !sw.configure ) + puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) + + if ( !sw.configure( verbose ) ) logger.logToJournal( "Failed to process configure section in the " + "package description of #{package}." ) return false @@ -130,8 +135,9 @@ end # build section. - puts "\n*** Processing the BUILD section for #{package}. ***" - if ( !sw.build ) + puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) + + if ( !sw.build( verbose ) ) logger.logToJournal( "Failed to process build section in the " + "package description of #{package}." ) return false @@ -144,7 +150,8 @@ end # preinstall section. - puts "\n*** Processing the PREINSTALL section for #{package}. ***" + puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) + if ( !sw.preinstall ) logger.logToJournal( "Failed to process preinstall section in the " + "package description of #{package}." ) @@ -154,7 +161,8 @@ end # install section. - puts "\n*** Processing the INSTALL section for #{package}. ***" + puts "\n*** Processing the INSTALL section for #{package}. ***" if ( verbose ) + if ( !sw.install ) # rollback installed files if any and remove install log. logger.logToJournal( "Failed to process install section in the " + @@ -175,7 +183,8 @@ end # post section. - puts "\n*** Processing the POST section for #{package}. ***" + puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) + if ( !sw.post ) logger.logToJournal( "Failed to process post section in the " + "package description of #{package}." ) @@ -185,7 +194,8 @@ end # clean out build sources. - puts "\n*** Cleaning up the sources for #{package}. ***" + puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) + if ( !sw.removeBuild ) logger.logToJournal( "Failed to remove the build sources for " + "#{package}." ) Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-03-06 21:38:36 UTC (rev 326) +++ src/trunk/TestAbtPackage.rb 2007-05-04 12:15:26 UTC (rev 327) @@ -35,6 +35,7 @@ $nameTest = "Ipc" $versionTest = "1.4" + $verbose = false $srcDirTest = "#{$nameTest.downcase}-#{$versionTest}" $dataTest = { @@ -78,78 +79,69 @@ # Test method for 'AbtPackage.testPre()' ## def testPre - assert( @ipc.pre(), "testPre()" ) + assert( @ipc.pre( $verbose ), "testPre()" ) end ## # Test method for 'AbtPackage.testConfigure()' ## def testConfigure - if ( !@ipc.pre() ) + if ( !@ipc.pre( $verbose ) ) assert_equals( true, false, "testConfigure()" ) end - assert( @ipc.configure(), "testConfigure()" ) + assert( @ipc.configure( $verbose ), "testConfigure()" ) end ## # Test method for 'AbtPackage.testBuild()' ## def testBuild - if ( !@ipc.pre() ) + if ( !@ipc.pre( $verbose ) ) assert_equals( true, false, "testBuild()" ) end - if ( !@ipc.configure() ) + if ( !@ipc.configure( $verbose ) ) assert_equals( true, false, "testBuild()" ) end - assert( @ipc.build(), "testBuild()" ) + assert( @ipc.build( $verbose ), "testBuild()" ) end ## # Test method for 'AbtPackage.testPreinstall()' ## def testPreinstall - assert( @ipc.preinstall(), "testPreinstall()" ) + assert( @ipc.preinstall( $verbose ), "testPreinstall()" ) end ## # Test method for 'AbtPackage.testInstall()' ## def testInstall - if ( !@ipc.pre() ) + + if ( !@ipc.pre( $verbose ) ) assert_equals( true, false, "testInstall()" ) end - if ( !@ipc.configure() ) + if ( !@ipc.configure( $verbose ) ) assert_equals( true, false, "testInstall()" ) end - if ( !@ipc.build() ) + if ( !@ipc.build( $verbose ) ) assert_equals( true, false, "testInstall()" ) end - if ( !@ipc.preinstall() ) + if ( !@ipc.preinstall( $verbose ) ) assert_equals( true, false, "testInstall()" ) end - assert( @ipc.install(), "testInstall()" ) + assert( @ipc.install( $verbose ), "testInstall()" ) end ## # Test method for 'AbtPackage.testPost()' ## def testPost - if ( !@ipc.pre() ) - assert_equals( true, false, "testPost()" ) - end - if ( !@ipc.configure() ) - assert_equals( true, false, "testPost()" ) - end - if ( !@ipc.build() ) - assert_equals( true, false, "testPost()" ) - end - if ( !@ipc.preinstall() ) - assert_equals( true, false, "testPost()" ) - end - if ( !@ipc.install() ) - assert_equals( true, false, "testPost()" ) - end - assert( @ipc.post(), "testPost()" ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.build( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.preinstall( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.install( $verbose ) ) + assert( @ipc.post( $verbose ), "testPost()" ) end end Modified: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-03-06 21:38:36 UTC (rev 326) +++ src/trunk/TestAbtPackageManager.rb 2007-05-04 12:15:26 UTC (rev 327) @@ -29,6 +29,8 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## class TestAbtPackageManager < Test::Unit::TestCase + + $verbose = false; # quiets testing output. ## # setup method for testing AbtPackageManager. @@ -47,7 +49,7 @@ # Test method for 'AbtPackageManager.testInstallPackage()' ## def testInstallPackage - assert( @pkgMgr.installPackage( "ipc" ), "testInstallPackage()" ) + assert( @pkgMgr.installPackage( "ipc", $verbose ), "testInstallPackage()" ) end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-14 11:50:16
|
Revision: 331 http://svn.sourceforge.net/abtlinux/?rev=331&view=rev Author: eschabell Date: 2007-06-14 04:50:18 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Adding flexmock library into our tree, this makes it available for immediate usage without gem installation. Added Paths: ----------- src/trunk/flexmock/ src/trunk/flexmock/argument_matchers.rb src/trunk/flexmock/argument_types.rb src/trunk/flexmock/base.rb src/trunk/flexmock/composite.rb src/trunk/flexmock/core.rb src/trunk/flexmock/core_class_methods.rb src/trunk/flexmock/default_framework_adapter.rb src/trunk/flexmock/expectation.rb src/trunk/flexmock/expectation_director.rb src/trunk/flexmock/mock_container.rb src/trunk/flexmock/noop.rb src/trunk/flexmock/partial_mock.rb src/trunk/flexmock/recorder.rb src/trunk/flexmock/rspec.rb src/trunk/flexmock/test_unit.rb src/trunk/flexmock/test_unit_integration.rb src/trunk/flexmock/validators.rb Removed Paths: ------------- src/trunk/README-UnitTests Deleted: src/trunk/README-UnitTests =================================================================== --- src/trunk/README-UnitTests 2007-06-14 08:59:34 UTC (rev 330) +++ src/trunk/README-UnitTests 2007-06-14 11:50:18 UTC (rev 331) @@ -1,10 +0,0 @@ -To run the unit tests you will need to make use of the flexmock gem, to -install this run: - -gem install flexmock - -I am trying to use this to mock up package objects to prevent downloading, -actual configure, build and install runs while providing unit testing for -these methods. - -For information on usage and such, see http://onestepback.org/software/flexmock/ Added: src/trunk/flexmock/argument_matchers.rb =================================================================== --- src/trunk/flexmock/argument_matchers.rb (rev 0) +++ src/trunk/flexmock/argument_matchers.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,57 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. +# +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + #################################################################### + # Match any object + class AnyMatcher + def ===(target) + true + end + def inspect + "ANY" + end + end + + #################################################################### + # Match only things that are equal. + class EqualMatcher + def initialize(obj) + @obj = obj + end + def ===(target) + @obj == target + end + def inspect + "==(#{@obj.inspect})" + end + end + + ANY = AnyMatcher.new + + #################################################################### + # Match only things where the block evaluates to true. + class ProcMatcher + def initialize(&block) + @block = block + end + def ===(target) + @block.call(target) + end + def inspect + "on{...}" + end + end + + +end Added: src/trunk/flexmock/argument_types.rb =================================================================== --- src/trunk/flexmock/argument_types.rb (rev 0) +++ src/trunk/flexmock/argument_types.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/argument_matchers' + +class FlexMock + + #################################################################### + # Include this module in your test class if you wish to use the +eq+ + # and +any+ argument matching methods without a prefix. (Otherwise + # use <tt>FlexMock.any</tt> and <tt>FlexMock.eq(obj)</tt>. + # + module ArgumentTypes + # Return an argument matcher that matches any argument. + def any + ANY + end + + # Return an argument matcher that only matches things equal to + # (==) the given object. + def eq(obj) + EqualMatcher.new(obj) + end + + # Return an argument matcher that matches any object, that when + # passed to the supplied block, will cause the block to return + # true. + def on(&block) + ProcMatcher.new(&block) + end + end + extend ArgumentTypes + +end Added: src/trunk/flexmock/base.rb =================================================================== --- src/trunk/flexmock/base.rb (rev 0) +++ src/trunk/flexmock/base.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/core' + +require 'flexmock/default_framework_adapter' +require 'flexmock/expectation_director' +require 'flexmock/expectation' +require 'flexmock/argument_matchers' +require 'flexmock/argument_types' +require 'flexmock/validators' +require 'flexmock/recorder' +require 'flexmock/mock_container' +require 'flexmock/partial_mock' \ No newline at end of file Added: src/trunk/flexmock/composite.rb =================================================================== --- src/trunk/flexmock/composite.rb (rev 0) +++ src/trunk/flexmock/composite.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# +# Created by Jim Weirich on 2007-04-14. +# Copyright (c) 2007. All rights reserved. + +require 'flexmock/noop' + +class FlexMock + +end \ No newline at end of file Added: src/trunk/flexmock/core.rb =================================================================== --- src/trunk/flexmock/core.rb (rev 0) +++ src/trunk/flexmock/core.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,205 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. +# +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/composite' + +###################################################################### +# FlexMock is a flexible mock object framework for supporting testing. +# +# FlexMock has a simple interface that's easy to remember, and leaves +# the hard stuff to all those other mock object implementations. +# +# Basic Usage: +# +# m = flexmock("name") +# m.should_receive(:upcase).with("stuff"). +# and_return("STUFF") +# m.should_receive(:downcase).with(String). +# and_return { |s| s.downcase }.once +# +# With Test::Unit Integration: +# +# class TestSomething < Test::Unit::TestCase +# include FlexMock::TestCase +# +# def test_something +# m = flexmock("name") +# m.should_receive(:hi).and_return("Hello") +# m.hi +# end +# end +# +# Note: When using Test::Unit integeration, don't forget to include +# FlexMock::TestCase. Also, if you override +teardown+, make sure you +# call +super+. +# +class FlexMock + attr_reader :mock_name, :mock_groups + attr_accessor :mock_current_order, :mock_container + + # Create a FlexMock object with the given name. The name is used in + # error messages. + def initialize(name="unknown") + @mock_name = name + @expectations = Hash.new + @allocated_order = 0 + @mock_current_order = 0 + @mock_container = nil + @mock_groups = {} + @ignore_missing = false + @verified = false + end + + # Handle all messages denoted by +sym+ by calling the given block + # and passing any parameters to the block. If we know exactly how + # many calls are to be made to a particular method, we may check + # that by passing in the number of expected calls as a second + # paramter. + def mock_handle(sym, expected_count=nil, &block) # :nodoc: + self.should_receive(sym).times(expected_count).returns(&block) + end + + # Verify that each method that had an explicit expected count was + # actually called that many times. + def mock_verify + return if @verified + @verified = true + mock_wrap do + @expectations.each do |sym, handler| + handler.mock_verify + end + end + end + + # Teardown and infrastructure setup for this mock. + def mock_teardown + end + + # Allocation a new order number from the mock. + def mock_allocate_order + @allocated_order += 1 + end + + # Ignore all undefined (missing) method calls. + def should_ignore_missing + @ignore_missing = true + end + alias mock_ignore_missing should_ignore_missing + + # Handle missing methods by attempting to look up a handler. + def method_missing(sym, *args, &block) + mock_wrap do + if handler = @expectations[sym] + args << block if block_given? + handler.call(*args) + else + super(sym, *args, &block) unless @ignore_missing + end + end + end + + # Save the original definition of respond_to? for use a bit later. + alias mock_respond_to? respond_to? + + # Override the built-in respond_to? to include the mocked methods. + def respond_to?(sym) + super || (@expectations[sym] ? true : @ignore_missing) + end + + # Override the built-in +method+ to include the mocked methods. + def method(sym) + @expectations[sym] || super + rescue NameError => ex + if @ignore_missing + proc { } + else + raise ex + end + end + + # :call-seq: + # mock.should_receive(:method_name) + # mock.should_receive(:method1, method2, ...) + # mock.should_receive(:meth1 => result1, :meth2 => result2, ...) + # + # Declare that the mock object should receive a message with the given name. + # + # If more than one method name is given, then the mock object should expect + # to receive all the listed melthods. If a hash of method name/value pairs + # is given, then the each method will return the associated result. Any + # expectations applied to the result of +should_receive+ will be applied to + # all the methods defined in the argument list. + # + # An expectation object for the method name is returned as the result of + # this method. Further expectation constraints can be added by chaining to + # the result. + # + # See Expectation for a list of declarators that can be used. + # + def should_receive(*args) + FlexMock.should_receive(args) do |sym| + @expectations[sym] ||= ExpectationDirector.new(sym) + result = Expectation.new(self, sym) + @expectations[sym] << result + override_existing_method(sym) if mock_respond_to?(sym) + result + end + end + + # Declare that the mock object should expect methods by providing a + # recorder for the methods and having the user invoke the expected + # methods in a block. Further expectations may be applied the + # result of the recording call. + # + # Example Usage: + # + # mock.should_expect do |record| + # record.add(Integer, 4) { |a, b| + # a + b + # }.at_least.once + # + def should_expect + yield Recorder.new(self) + end + + private + + # Wrap a block of code so the any assertion errors are wrapped so + # that the mock name is added to the error message . + def mock_wrap(&block) + yield + rescue FlexMock.framework_adapter.assertion_failed_error => ex + raise FlexMock.framework_adapter.assertion_failed_error, + "in mock '#{@mock_name}': #{ex.message}", + ex.backtrace + end + + + # Override the existing definition of method +sym+ in the mock. + # Most methods depend on the method_missing trick to be invoked. + # However, if the method already exists, it will not call + # method_missing. This method defines a singleton method on the + # mock to explicitly invoke the method_missing logic. + def override_existing_method(sym) + sclass.class_eval <<-EOS + def #{sym}(*args, &block) + method_missing(:#{sym}, *args, &block) + end + EOS + end + + # Return the singleton class of the mock object. + def sclass + class << self; self; end + end +end + +require 'flexmock/core_class_methods' \ No newline at end of file Added: src/trunk/flexmock/core_class_methods.rb =================================================================== --- src/trunk/flexmock/core_class_methods.rb (rev 0) +++ src/trunk/flexmock/core_class_methods.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,92 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + class << self + attr_reader :framework_adapter + + # :call-seq: + # should_receive(args) { |symbol| ... } + # + # This method provides common handling for the various should_receive + # argument lists. It sorts out the differences between symbols, arrays and + # hashes, and identifies the method names specified by each. As each + # method name is identified, create a mock expectation for it using the + # supplied block. + def should_receive(args) # :nodoc: + result = CompositeExpectation.new + args.each do |arg| + case arg + when Hash + arg.each do |k,v| + result.add(yield(k.to_sym).and_return(v)) + end + when Symbol, String + result.add(yield(arg.to_sym)) + end + end + result + end + + # Class method to make sure that verify is called at the end of a + # test. One mock object will be created for each name given to + # the use method. The mocks will be passed to the block as + # arguments. If no names are given, then a single anonymous mock + # object will be created. + # + # At the end of the use block, each mock object will be verified + # to make sure the proper number of calls have been made. + # + # Usage: + # + # FlexMock.use("name") do |mock| # Creates a mock named "name" + # mock.should_receive(:meth). + # returns(0).once + # end # mock is verified here + # + # NOTE: If you include FlexMock::TestCase into your test case + # file, you can create mocks that will be automatically verified in + # the test teardown by using the +flexmock+ method. + # + def use(*names) + names = ["unknown"] if names.empty? + got_excecption = false + mocks = names.collect { |n| new(n) } + yield(*mocks) + rescue Exception => ex + got_exception = true + raise + ensure + mocks.each do |mock| + mock.mock_verify unless got_exception + end + end + + # Class method to format a method name and argument list as a nice + # looking string. + def format_args(sym, args) # :nodoc: + if args + "#{sym}(#{args.collect { |a| a.inspect }.join(', ')})" + else + "#{sym}(*args)" + end + end + + # Check will assert the block returns true. If it doesn't, an + # assertion failure is triggered with the given message. + def check(msg, &block) # :nodoc: + FlexMock.framework_adapter.assert_block(msg, &block) + end + end + +end \ No newline at end of file Added: src/trunk/flexmock/default_framework_adapter.rb =================================================================== --- src/trunk/flexmock/default_framework_adapter.rb (rev 0) +++ src/trunk/flexmock/default_framework_adapter.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + class DefaultFrameworkAdapter + def assert_block(msg, &block) + unless yield + fail assertion_failed_error, msg + end + end + + def assert_equal(a, b, msg=nil) + assert_block(msg || "Expected equal") { a == b } + end + + class AssertionFailedError < StandardError; end + def assertion_failed_error + AssertionFailedError + end + end +end \ No newline at end of file Added: src/trunk/flexmock/expectation.rb =================================================================== --- src/trunk/flexmock/expectation.rb (rev 0) +++ src/trunk/flexmock/expectation.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,334 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + + #################################################################### + # An Expectation is returned from each +should_receive+ message sent + # to mock object. Each expectation records how a message matching + # the message name (argument to +should_receive+) and the argument + # list (given by +with+) should behave. Mock expectations can be + # recorded by chaining the declaration methods defined in this + # class. + # + # For example: + # + # mock.should_receive(:meth).with(args).and_returns(result) + # + class Expectation + + attr_reader :expected_args, :order_number + attr_accessor :mock + + # Create an expectation for a method named +sym+. + def initialize(mock, sym) + @mock = mock + @sym = sym + @expected_args = nil + @count_validators = [] + @count_validator_class = ExactCountValidator + @actual_count = 0 + @return_value = nil + @return_block = lambda { @return_value } + @order_number = nil + end + + def to_s + FlexMock.format_args(@sym, @expected_args) + end + + # Verify the current call with the given arguments matches the + # expectations recorded in this object. + def verify_call(*args) + validate_order + @actual_count += 1 + @return_block.call(*args) + end + + # Is this expectation eligible to be called again? It is eligible + # only if all of its count validators agree that it is eligible. + def eligible? + @count_validators.all? { |v| v.eligible?(@actual_count) } + end + + # Validate that the order + def validate_order + return if @order_number.nil? + FlexMock.check("method #{to_s} called out of order " + + "(expected order #{@order_number}, was #{@mock.mock_current_order})") { + @order_number >= @mock.mock_current_order + } + @mock.mock_current_order = @order_number + end + private :validate_order + + # Validate the correct number of calls have been made. Called by + # the teardown process. + def mock_verify + @count_validators.each do |v| + v.validate(@actual_count) + end + end + + # Does the argument list match this expectation's argument + # specification. + def match_args(args) + # TODO: Rethink this: + # return false if @expected_args.nil? + return true if @expected_args.nil? + return false if args.size != @expected_args.size + (0...args.size).all? { |i| match_arg(@expected_args[i], args[i]) } + end + + # Does the expected argument match the corresponding actual value. + def match_arg(expected, actual) + expected === actual || + expected == actual || + ( Regexp === expected && expected === actual.to_s ) + end + + # Declare that the method should expect the given argument list. + def with(*args) + @expected_args = args + self + end + + # Declare that the method should be called with no arguments. + def with_no_args + with + end + + # Declare that the method can be called with any number of + # arguments of any type. + def with_any_args + @expected_args = nil + self + end + + # :call-seq: + # and_return(value) + # and_return(value, value, ...) + # and_return { |*args| code } + # + # Declare that the method returns a particular value (when the + # argument list is matched). + # + # * If a single value is given, it will be returned for all matching + # calls. + # * If multiple values are given, each value will be returned in turn for + # each successive call. If the number of matching calls is greater + # than the number of values, the last value will be returned for + # the extra matching calls. + # * If a block is given, it is evaluated on each call and its + # value is returned. + # + # For example: + # + # mock.should_receive(:f).returns(12) # returns 12 + # + # mock.should_receive(:f).with(String). # returns an + # returns { |str| str.upcase } # upcased string + # + # +and_return+ is an alias for +returns+. + # + def and_return(*args, &block) + @return_block = + if block_given? + block + else + lambda { args.size == 1 ? args.first : args.shift } + end + self + end + alias :returns :and_return # :nodoc: + + # Declare that the method may be called any number of times. + def zero_or_more_times + at_least.never + end + + # Declare that the method is called +limit+ times with the + # declared argument list. This may be modified by the +at_least+ + # and +at_most+ declarators. + def times(limit) + @count_validators << @count_validator_class.new(self, limit) unless limit.nil? + @count_validator_class = ExactCountValidator + self + end + + # Declare that the method is never expected to be called with the + # given argument list. This may be modified by the +at_least+ and + # +at_most+ declarators. + def never + times(0) + end + + # Declare that the method is expected to be called exactly once + # with the given argument list. This may be modified by the + # +at_least+ and +at_most+ declarators. + def once + times(1) + end + + # Declare that the method is expected to be called exactly twice + # with the given argument list. This may be modified by the + # +at_least+ and +at_most+ declarators. + def twice + times(2) + end + + # Modifies the next call count declarator (+times+, +never+, + # +once+ or +twice+) so that the declarator means the method is + # called at least that many times. + # + # E.g. method f must be called at least twice: + # + # mock.should_receive(:f).at_least.twice + # + def at_least + @count_validator_class = AtLeastCountValidator + self + end + + # Modifies the next call count declarator (+times+, +never+, + # +once+ or +twice+) so that the declarator means the method is + # called at most that many times. + # + # E.g. method f must be called no more than twice + # + # mock.should_receive(:f).at_most.twice + # + def at_most + @count_validator_class = AtMostCountValidator + self + end + + # Declare that the given method must be called in order. All + # ordered method calls must be received in the order specified by + # the ordering of the +should_receive+ messages. Receiving a + # methods out of the specified order will cause a test failure. + # + # If the user needs more fine control over ordering + # (e.g. specifying that a group of messages may be received in any + # order as long as they all come after another group of messages), + # a _group_ _name_ may be specified in the +ordered+ calls. All + # messages within the same group may be received in any order. + # + # For example, in the following, messages +flip+ and +flop+ may be + # received in any order (because they are in the same group), but + # must occur strictly after +start+ but before +end+. The message + # +any_time+ may be received at any time because it is not + # ordered. + # + # m = FlexMock.new + # m.should_receive(:any_time) + # m.should_receive(:start).ordered + # m.should_receive(:flip).ordered(:flip_flop_group) + # m.should_receive(:flop).ordered(:flip_flop_group) + # m.should_receive(:end).ordered + # + def ordered(group_name=nil) + if group_name.nil? + @order_number = @mock.mock_allocate_order + elsif (num = @mock.mock_groups[group_name]) + @order_number = num + else + @order_number = @mock.mock_allocate_order + @mock.mock_groups[group_name] = @order_number + end + self + end + end + + ########################################################################## + # A composite expectation allows several expectations to be grouped into a + # single composite and then apply the same constraints to all expectations + # in the group. + class CompositeExpectation + + # Initialize the composite expectation. + def initialize + @expectations = [] + end + + # Add an expectation to the composite. + def add(expectation) + @expectations << expectation + end + + # Apply the constraint method to all expectations in the composite. + def method_missing(sym, *args, &block) + @expectations.each do |expectation| + expectation.send(sym, *args, &block) + end + self + end + + # The following methods return a value, so we make an arbitrary choice + # and return the value for the first expectation in the composite. + + # Return the order number of the first expectation in the list. + def order_number + @expectations.first.order_number + end + + # Return the associated mock object. + def mock + @expectations.first.mock + end + + # Start a new method expectation. The following constraints will be + # applied to the new expectation. + def should_receive(*args, &block) + @expectations.first.mock.should_receive(*args, &block) + end + + # Return a string representations + def to_s + if @expectations.size > 1 + "[" + @expectations.collect { |e| e.to_s }.join(', ') + "]" + else + @expectations.first.to_s + end + end + end + + ########################################################################## + # An expectation recorder records any expectations received and plays them + # back on demand. This is used to collect the expectations in the blockless + # version of the new_instances call. + # + class ExpectationRecorder + + # Initialize the recorder. + def initialize + @expectations = [] + end + + # Save any incoming messages to be played back later. + def method_missing(sym, *args, &block) + @expectations << [sym, args, block] + self + end + + # Apply the recorded messages to the given object in a chaining fashion + # (i.e. the result of the previous call is used as the target of the next + # call). + def apply(mock) + obj = mock + @expectations.each do |sym, args, block| + obj = obj.send(sym, *args, &block) + end + end + end +end Added: src/trunk/flexmock/expectation_director.rb =================================================================== --- src/trunk/flexmock/expectation_director.rb (rev 0) +++ src/trunk/flexmock/expectation_director.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + + #################################################################### + # The expectation director is responsible for routing calls to the + # correct expectations for a given argument list. + # + class ExpectationDirector + + # Create an ExpectationDirector for a mock object. + def initialize(sym) + @sym = sym + @expectations = [] + @expected_order = nil + end + + # Invoke the expectations for a given set of arguments. + # + # First, look for an expectation that matches the arguements and + # is eligible to be called. Failing that, look for a expectation + # that matches the arguments (at this point it will be ineligible, + # but at least we will get a good failure message). Finally, + # check for expectations that don't have any argument matching + # criteria. + def call(*args) + exp = @expectations.find { |e| e.match_args(args) && e.eligible? } || + @expectations.find { |e| e.match_args(args) } + FlexMock.check("no matching handler found for " + + FlexMock.format_args(@sym, args)) { ! exp.nil? } + exp.verify_call(*args) + end + + # Append an expectation to this director. + def <<(expectation) + @expectations << expectation + end + + # Do the post test verification for this directory. Check all the + # expectations. + def mock_verify + @expectations.each do |exp| + exp.mock_verify + end + end + end + +end Added: src/trunk/flexmock/mock_container.rb =================================================================== --- src/trunk/flexmock/mock_container.rb (rev 0) +++ src/trunk/flexmock/mock_container.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,159 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + + #################################################################### + # Mock container methods + # + # Include this module in to get integration with FlexMock. When + # this module is included, mocks may be created with a simple call + # to the +flexmock+ method. Mocks created with via the method call + # will automatically be verified in the teardown of the test case. + # + module MockContainer + # Do the flexmock specific teardown stuff. If you need finer control, + # you can use either +flexmock_verify+ or +flexmock_close+. + def flexmock_teardown + flexmock_verify if passed? + ensure + flexmock_close + end + + # Perform verification on all mocks in the container. + def flexmock_verify + @flexmock_created_mocks ||= [] + @flexmock_created_mocks.each do |m| + m.mock_verify + end + end + + # Close all the mock objects in the container. Closing a mock object + # restores any original behavior that was displaced by the mock. + def flexmock_close + @flexmock_created_mocks ||= [] + @flexmock_created_mocks.each do |m| + m.mock_teardown + end + @flexmock_created_mocks = [] + end + + # Create a mocking object in the FlexMock framework. The +flexmock+ + # method has a number of options available, depending on just what + # kind of mocking object your require. Mocks created via +flexmock+ + # will be automatically verify during the teardown phase of your + # test framework. + # + # :call-seq: + # flexmock() { |mock| ... } + # flexmock(name) { |mock| ... } + # flexmock(expect_hash) { |mock| ... } + # flexmock(name, expect_hash) { |mock| ... } + # flexmock(real_object) { |mock| ... } + # flexmock(real_object, name) { |mock| ... } + # flexmock(real_object, name, expect_hash) { |mock| ... } + # flexmock(:base, string, name, expect_hash) { |mock| ... } + # + # name :: + # Name of the mock object. If no name is given, "unknown" is used for + # full mocks and "flexmock(<em>real_object</em>)" is used for partial + # mocks. + # + # expect_hash :: + # Hash table of method names and values. Each method/value pair is + # used to setup a simple expectation so that if the mock object + # receives a message matching an entry in the table, it returns + # the associated value. No argument our call count constraints are + # added. Using an expect_hash is identical to calling: + # + # mock.should_receive(method_name).and_return(value) + # + # for each of the method/value pairs in the hash. + # + # real_object :: + # If a real object is given, then a partial mock is constructed + # using the real_object as a base. Partial mocks (formally referred + # to as stubs) behave as a mock object when an expectation is matched, + # and otherwise will behave like the original object. This is useful + # when you want to use a real object for testing, but need to mock out + # just one or two methods. + # + # :base :: + # Forces the following argument to be used as the base of a + # partial mock object. This explicit tag is only needed if you + # want to use a string or a symbol as the mock base (string and + # symbols would normally be interpretted as the mock name). + # + # &block :: + # If a block is given, then the mock object is passed to the block and + # expectations may be configured within the block. + # + def flexmock(*args) + name = nil + quick_defs = {} + stub_target = nil + while ! args.empty? + case args.first + when :base + args.shift + stub_target = args.shift + when String, Symbol + name = args.shift.to_s + when Hash + quick_defs = args.shift + else + stub_target = args.shift + end + end + if stub_target + mock = flexmock_make_stub(stub_target, name) + else + mock = FlexMock.new(name || "unknown") + end + flexmock_quick_define(mock, quick_defs) + yield(mock) if block_given? + flexmock_remember(mock) + mock + end + alias flexstub flexmock + + private + + # Create a PartialMock for the given object. Use +name+ as the name + # of the mock object. + def flexmock_make_stub(obj, name) + name ||= "flexmock(#{obj.class.to_s})" + obj.instance_eval { + @flexmock_proxy ||= PartialMock.new(obj, FlexMock.new(name)) + } + obj.instance_variable_get("@flexmock_proxy") + end + + # Create a set of mocked methods from a hash. + def flexmock_quick_define(mock, defs) + defs.each do |method, value| + mock.should_receive(method).and_return(value) + end + mock + end + + # Remember the mock object / stub in the mock container. + def flexmock_remember(mocking_object) + @flexmock_created_mocks ||= [] + @flexmock_created_mocks << mocking_object + mocking_object.mock_container = self + mocking_object + end + end + +end Added: src/trunk/flexmock/noop.rb =================================================================== --- src/trunk/flexmock/noop.rb (rev 0) +++ src/trunk/flexmock/noop.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +# No-op include file. Used as a kludge so that only the comments in the +# core.rb file are applied to the FlexMock class. \ No newline at end of file Added: src/trunk/flexmock/partial_mock.rb =================================================================== --- src/trunk/flexmock/partial_mock.rb (rev 0) +++ src/trunk/flexmock/partial_mock.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,231 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + + # ######################################################################### + # PartialMock is used to mate the mock framework to an existing object. The + # object is "enhanced" with a reference to a mock object (stored in + # <tt>@flexmock_mock</tt>). When the +should_receive+ method is sent to the + # proxy, it overrides the existing object's method by creating singleton + # method that forwards to the mock. When testing is complete, PartialMock + # will erase the mocking infrastructure from the object being mocked (e.g. + # remove instance variables and mock singleton methods). + # + class PartialMock + attr_reader :mock, :mock_groups + attr_accessor :mock_current_order, :mock_container + + # Initialize a PartialMock object. + def initialize(obj, mock) + @obj = obj + @mock = mock + @method_definitions = {} + @methods_proxied = [] + @allocated_order = 0 + @mock_current_order = 0 + @mock_groups = {} + end + + # :call-seq: + # should_receive(:method_name) + # should_receive(:method1, method2, ...) + # should_receive(:meth1 => result1, :meth2 => result2, ...) + # + # Declare that the partial mock should receive a message with the given + # name. + # + # If more than one method name is given, then the mock object should + # expect to receive all the listed melthods. If a hash of method + # name/value pairs is given, then the each method will return the + # associated result. Any expectations applied to the result of + # +should_receive+ will be applied to all the methods defined in the + # argument list. + # + # An expectation object for the method name is returned as the result of + # this method. Further expectation constraints can be added by chaining + # to the result. + # + # See Expectation for a list of declarators that can be used. + def should_receive(*args) + FlexMock.should_receive(args) do |sym| + unless @methods_proxied.include?(sym) + hide_existing_method(sym) + @methods_proxied << sym + end + ex = @mock.should_receive(sym) + ex.mock = self + ex + end + end + + # :call-seq: + # new_instances.should_receive(...) + # new_instances { |instance| instance.should_receive(...) } + # + # new_instances is a short cut method for overriding the behavior of any + # new instances created via a mocked class object. + # + # By default, new_instances will mock the behaviour of the :new and + # :allocate methods. If you wish to mock a different set of class + # methods, just pass a list of symbols to as arguments. + # + # For example, to stub only objects created by :make (and not :new + # or :allocate), use: + # + # flexmock(ClassName).new_instances(:make).should_receive(...) + # + def new_instances(*allocators, &block) + fail ArgumentError, "new_instances requires a Class to stub" unless Class === @obj + allocators = [:new, :allocate] if allocators.empty? + result = ExpectationRecorder.new + allocators.each do |m| + self.should_receive(m).and_return { |*args| + new_obj = invoke_original(m, args) + mock = mock_container.flexmock(new_obj) + block.call(mock) if block_given? + result.apply(mock) + new_obj + } + end + result + end + + # any_instance is present for backwards compatibility with version 0.5.0. + # @deprecated + def any_instance(&block) + $stderr.puts "any_instance is deprecated, use new_instances instead." + new_instances(&block) + end + + # Invoke the original definition of method on the object supported by + # the stub. + def invoke_original(method, args) + method_proc = @method_definitions[method] + method_proc.call(*args) + end + private :invoke_original + + # Verify that the mock has been properly called. After verification, + # detach the mocking infrastructure from the existing object. + def mock_verify + @mock.mock_verify + end + + # Remove all traces of the mocking framework from the existing object. + def mock_teardown + if ! detached? + @methods_proxied.each do |method_name| + remove_current_method(method_name) + restore_original_definition(method_name) + end + @obj.instance_variable_set("@flexmock_proxy", nil) + @obj = nil + end + end + + # Allocation a new order number from the mock. + def mock_allocate_order + @allocated_order += 1 + end + + private + + # The singleton class of the object. + def sclass + class << @obj; self; end + end + + # Is the current method a singleton method in the object we are + # mocking? + def singleton?(method_name) + @obj.methods(false).include?(method_name.to_s) + end + + # Hide the existing method definition with a singleton defintion + # that proxies to our mock object. If the current definition is a + # singleton, we need to record the definition and remove it before + # creating our own singleton method. If the current definition is + # not a singleton, all we need to do is override it with our own + # singleton. + def hide_existing_method(method_name) + if @obj.respond_to?(method_name) + new_alias = new_name(method_name) + unless @obj.respond_to?(new_alias) + sclass.class_eval do + alias_method(new_alias, method_name) + end + end + my_object = @obj + @method_definitions[method_name] = Proc.new { |*args| + block = nil + if Proc === args.last + block = args.last + args = args[0...-1] + end + my_object.send(new_alias, *args, &block) + } + end + remove_current_method(method_name) if singleton?(method_name) + define_proxy_method(method_name) + end + + # Define a proxy method that forwards to our mock object. The + # proxy method is defined as a singleton method on the object + # being mocked. + def define_proxy_method(method_name) + if method_name.to_s =~ /=$/ + sclass.class_eval %{ + def #{method_name}(*args, &block) + @flexmock_proxy.mock.__send__(:#{method_name}, *args, &block) + end + } + else + sclass.class_eval %{ + def #{method_name}(*args, &block) + @flexmock_proxy.mock.#{method_name}(*args, &block) + end + } + end + end + + # Restore the original singleton defintion for method_name that + # was saved earlier. + def restore_original_definition(method_name) + method_def = @method_definitions[method_name] + if method_def + the_alias = new_name(method_name) + sclass.class_eval do + alias_method(method_name, the_alias) + end + end + end + + # Remove the current method if it is a singleton method of the + # object being mocked. + def remove_current_method(method_name) + sclass.class_eval { remove_method(method_name) } + end + + # Have we been detached from the existing object? + def detached? + @obj.nil? + end + + # Generate a name to be used to alias the original behavior. + def new_name(old_name) + "flexmock_original_behavior_for_#{old_name}" + end + + end +end Added: src/trunk/flexmock/recorder.rb =================================================================== --- src/trunk/flexmock/recorder.rb (rev 0) +++ src/trunk/flexmock/recorder.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/argument_types' + +class FlexMock + + #################################################################### + # Translate arbitrary method calls into expectations on the given + # mock object. + # + class Recorder + include FlexMock::ArgumentTypes + + # Create a method recorder for the mock +mock+. + def initialize(mock) + @mock = mock + @strict = false + end + + # Place the record in strict mode. While recording expectations + # in strict mode, the following will be true. + # + # * All expectations will be expected in the order they were + # recorded. + # * All expectations will be expected once. + # * All arguments will be placed in exact match mode, + # including regular expressions and class objects. + # + # Strict mode is usually used when giving the recorder to a known + # good algorithm. Strict mode captures the exact sequence of + # calls and validate that the code under test performs the exact + # same sequence of calls. + # + # The recorder may exit strict mode via a + # <tt>should_be_strict(false)</tt> call. Non-strict expectations + # may be recorded at that point, or even explicit expectations + # (using +should_receieve+) can be specified. + # + def should_be_strict(is_strict=true) + @strict = is_strict + end + + # Is the recorder in strict mode? + def strict? + @strict + end + + # Record an expectation for receiving the method +sym+ with the + # given arguments. + def method_missing(sym, *args, &block) + expectation = @mock.should_receive(sym).and_return(&block) + if strict? + args = args.collect { |arg| eq(arg) } + expectation.with(*args).ordered.once + else + expectation.with(*args) + end + expectation + end + end + +end Added: src/trunk/flexmock/rspec.rb =================================================================== --- src/trunk/flexmock/rspec.rb (rev 0) +++ src/trunk/flexmock/rspec.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/base' + +class FlexMock + + class RSpecFrameworkAdapter + def assert_block(msg, &block) + Spec::Expectations.fail_with(msg) unless yield + end + + def assert_equal(a, b, msg=nil) + message = msg || "Expected equal" + assert_block(message + "\n<#{a}> expected, but was\n<#{b}>") { a == b } + end + + class AssertionFailedError < StandardError; end + def assertion_failed_error + Spec::Expectations::ExpectationNotMetError + end + end + + @framework_adapter = RSpecFrameworkAdapter.new + +end \ No newline at end of file Added: src/trunk/flexmock/test_unit.rb =================================================================== --- src/trunk/flexmock/test_unit.rb (rev 0) +++ src/trunk/flexmock/test_unit.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/test_unit_integration' + +module Test + module Unit + class TestCase + include FlexMock::ArgumentTypes + include FlexMock::MockContainer + + # Alias the original teardown behavior for later use. + alias :flexmock_original_teardown :teardown + + # Teardown the test case, verifying any mocks that might have been + # defined in this test case. + def teardown + flexmock_teardown + flexmock_original_teardown + end + + end + end +end \ No newline at end of file Added: src/trunk/flexmock/test_unit_integration.rb =================================================================== --- src/trunk/flexmock/test_unit_integration.rb (rev 0) +++ src/trunk/flexmock/test_unit_integration.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,53 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'test/unit' +require 'flexmock/base' + +class FlexMock + + #################################################################### + # Test::Unit::TestCase Integration. + # + # Include this module in any TestCase class in a Test::Unit test + # suite to get integration with FlexMock. When this module is + # included, the mock container methods (e.g. flexmock(), flexstub()) + # will be available. + # + # <b>Note:</b> If you define a +teardown+ method in the test case, + # <em>dont' forget to invoke the +super+ method!</em> Failure to + # invoke super will cause all mocks to not be verified. + # + module TestCase + include ArgumentTypes + include MockContainer + + # Teardown the test case, verifying any mocks that might have been + # defined in this test case. + def teardown + super + flexmock_teardown + end + + end + + #################################################################### + # Adapter for adapting FlexMock to the Test::Unit framework. + # + class TestUnitFrameworkAdapter + include Test::Unit::Assertions + def assertion_failed_error + Test::Unit::AssertionFailedError + end + end + + @framework_adapter = TestUnitFrameworkAdapter.new +end Added: src/trunk/flexmock/validators.rb =================================================================== --- src/trunk/flexmock/validators.rb (rev 0) +++ src/trunk/flexmock/validators.rb 2007-06-14 11:50:18 UTC (rev 331) @@ -0,0 +1,77 @@ +#!/usr/bin/env ruby + +#--- +# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (ji...@we...). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#+++ + +require 'flexmock/noop' + +class FlexMock + + #################################################################### + # Base class for all the count validators. + # + class CountValidator + def initialize(expectation, limit) + @exp = expectation + @limit = limit + end + + # If the expectation has been called +n+ times, is it still + # eligible to be called again? The default answer compares n to + # the established limit. + def eligible?(n) + n < @limit + end + end + + #################################################################### + # Validator for exact call counts. + # + class ExactCountValidator < CountValidator + # Validate that the method expectation was called exactly +n+ + # times. + def validate(n) + FlexMock.framework_adapter.assert_equal @limit, n, + "method '#{@exp}' called incorrect number of times" + end + end + + #################################################################### + # Validator for call counts greater than or equal to a limit. + # + class AtLeastCountValidator < CountValidator + # Validate the method expectation was called no more than +n+ + # times. + def validate(n) + FlexMock.framework_adapter.assert_block( + "Method '#{@exp}' should be called at least #{@limit} times,\n" + + "only called #{n} times") { n >= @limit } + end + + # If the expectation has been called +n+ times, is it still + # eligible to be called again? Since this validator only + # establishes a lower limit, not an upper limit, then the answer + # is always true. + def eligible?(n) + true + end + end + + #################################################################### + # Validator for call counts less than or equal to a limit. + # + class AtMostCountValidator < CountValidator + # Validate the method expectation was called at least +n+ times. + def validate(n) + FlexMock.framework_adapter.assert_block( + "Method '#{@exp}' should be called at most #{@limit} times,\n" + + "only called #{n} times") { n <= @limit } + end + end +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-14 13:09:47
|
Revision: 332 http://svn.sourceforge.net/abtlinux/?rev=332&view=rev Author: eschabell Date: 2007-06-14 06:09:43 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Migrated all requires into the abtconfig file so only have to include one file elsewhere. Went through the unit tests and got rid of all errors (was due to packages being included incorrectly). Now succeeding on 44/44 tests running with 27 failures (these need to be implemented still). Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/AbtReportManager.rb src/trunk/abt.rb src/trunk/abtconfig.rb src/trunk/testSuiteAbt.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/AbtDownloadManager.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -54,7 +54,7 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require packageName + require "packages/#{packageName}" logger = AbtLogManager.new package = eval( packageName.capitalize + '.new' ) Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/AbtLogManager.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -62,7 +62,7 @@ # otherwise false. ## def logPackageIntegrity( package ) - require package + require "packages/#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details @@ -108,7 +108,7 @@ excluded_pattern = Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) - require package + require "packages/#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details badLine = false # used to mark excluded lines from installwatch log. @@ -157,7 +157,7 @@ # otherwise false. ## def logPackageBuild( package ) - require package + require "packages/#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details buildLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/AbtPackageManager.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -94,7 +94,7 @@ # false. ## def installPackage( package, verbose=true ) - require package + require "packages/#{package}" sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new logger = AbtLogManager.new Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/AbtReportManager.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -51,7 +51,7 @@ # otherwise false. ## def showPackageDetails( package ) - require package + require "packages/#{package}" if ( package = eval( "#{package.capitalize}.new" ) ) details = package.details Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/abt.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -25,16 +25,7 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## require 'abtconfig' -require 'AbtDownloadManager' -require 'AbtLogManager' -require 'AbtPackageManager' -require 'AbtQueueManager' -require 'AbtReportManager' -require 'AbtSystemManager' -require 'AbtUsage' -require 'fileutils' - ## # Setup needed classes and get ready to parse arguments. ## Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/abtconfig.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -25,6 +25,17 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## +# global requires. +require 'AbtDownloadManager' +require 'AbtLogManager' +require 'AbtPackageManager' +require 'AbtQueueManager' +require 'AbtReportManager' +require 'AbtSystemManager' +require 'AbtUsage' + +require 'fileutils' + # default paths / locations. $ABT_LOGS = "/var/log/abt" $ABT_CACHES = "/var/spool/abt" Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-06-14 11:50:18 UTC (rev 331) +++ src/trunk/testSuiteAbt.rb 2007-06-14 13:09:43 UTC (rev 332) @@ -8,7 +8,7 @@ require 'test/unit' require 'abtconfig' -require 'fileutils' + require 'TestAbtDepEngine' require 'TestAbtDownloadManager' require 'TestAbtLogManager' @@ -16,4 +16,4 @@ require 'TestAbtPackageManager' require 'TestAbtQueueManager' require 'TestAbtReportManager' -require 'TestAbtSystemManager' +require 'TestAbtSystemManager' \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-14 15:42:52
|
Revision: 333 http://svn.sourceforge.net/abtlinux/?rev=333&view=rev Author: eschabell Date: 2007-06-14 08:42:53 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Refactored newsfeed download method to default to clearing any existing log. Refactored all file.new calls to use simpler syntax. Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/abt.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-06-14 13:09:43 UTC (rev 332) +++ src/trunk/AbtDownloadManager.rb 2007-06-14 15:42:53 UTC (rev 333) @@ -89,25 +89,24 @@ # Retrieves the given feed and displays the news items. # # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>String</i> - pass the value 'true' to empty the log file, - # otherwise it will be appended. + # <b>PARAM</b> <i>boolean</i> - default is to emplty the log file, + # passing 'false' will append to news file. # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been # retrieved, otherwise false. ## - def retrieveNewsFeed( uri, cleanLog = "false" ) + def retrieveNewsFeed( uri, cleanLog=true ) require 'net/http' require 'uri' require 'rss/1.0' require 'rss/2.0' newsLog = "" + logger = AbtLogManager.new # ensure we have our news logfile. - if ( cleanLog == "true" ) - newsLog = - File.new( $ABTNEWS_LOG, File::WRONLY|File::TRUNC|File::CREAT, 644 ) + if ( cleanLog ) + newsLog = File.new( $ABTNEWS_LOG, "w+" ) else - newsLog = - File.new( $ABTNEWS_LOG, File::WRONLY|File::APPEND|File::CREAT, 644 ) + newsLog = File.new( $ABTNEWS_LOG, "a+" ) end # pick up the abtlinux.org news feed. Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-14 13:09:43 UTC (rev 332) +++ src/trunk/AbtLogManager.rb 2007-06-14 15:42:53 UTC (rev 333) @@ -200,9 +200,7 @@ # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. ## def logToJournal( message ) - if ( - log = File.new( - $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + if ( log = File.new( $JOURNAL, "a+" ) ) log.puts "#{$TIMESTAMP} : #{message}" log.close return true Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-14 13:09:43 UTC (rev 332) +++ src/trunk/abt.rb 2007-06-14 15:42:53 UTC (rev 333) @@ -228,17 +228,17 @@ # abtlinux.org news feeds. puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS , "true" ) ) + if ( !downloader.retrieveNewsFeed( $ABTNEWS ) ) puts "Failed to retrieve the AbTLinux news feed." end puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS_THREADS ) ) + if ( !downloader.retrieveNewsFeed( $ABTNEWS_THREADS, false ) ) puts "Failed to retrieve the AbTLinux forum threads news feed." end puts "\n" - if ( !downloader.retrieveNewsFeed( $ABTNEWS_POSTS ) ) + if ( !downloader.retrieveNewsFeed( $ABTNEWS_POSTS, false ) ) puts "Failed to retrieve the AbTLinux new posts news feed." end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 10:32:11
|
Revision: 336 http://svn.sourceforge.net/abtlinux/?rev=336&view=rev Author: eschabell Date: 2007-06-15 03:32:13 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Created unit test to detect if package is installed. Wrote packageInstalled to determine if package is installed, some cleanup of requires also necessary. Modified Paths: -------------- src/trunk/AbtSystemManager.rb src/trunk/TestAbtSystemManager.rb src/trunk/abtconfig.rb Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2007-06-15 09:52:43 UTC (rev 335) +++ src/trunk/AbtSystemManager.rb 2007-06-15 10:32:13 UTC (rev 336) @@ -32,6 +32,31 @@ private + ## + # Determines if given file is in given directory. + # + # <b>PARAM</b> <i>String</i> - directory path to search. + # <b>PARAM</b> <i>String</i> - entry we are looking for in given directory. + # + # <b>RETURN</b> <i>boolean</i> - True if entry found in given directory, + # otherwise false. + ## + def foundEntry( directory, name ) + Find.find( directory ) do |path| + + Find.prune if [".", ".."].include? path + case name + when String + return true if File.basename( path ) == name + else + raise ArgumentError + end + + end + + return false # match not found. + end + public ## @@ -140,4 +165,27 @@ ## def setPackageTreeLocation( location ) end -end + + ## + # Checks if the given package is installed by checking for entry in the + # installed directory. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if package installed, otherwise + # false. + ## + def packageInstalled( package ) + require "packages/#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + if ( foundEntry( $PACKAGE_INSTALLED, sw.srcDir ) ) + return true + end + + + return false + end + +end \ No newline at end of file Modified: src/trunk/TestAbtSystemManager.rb =================================================================== --- src/trunk/TestAbtSystemManager.rb 2007-06-15 09:52:43 UTC (rev 335) +++ src/trunk/TestAbtSystemManager.rb 2007-06-15 10:32:13 UTC (rev 336) @@ -2,7 +2,7 @@ require 'test/unit/testcase' require 'test/unit/autorunner' -require 'AbtSystemManager' +require 'abtconfig' ## # TestAbtSystemManager.rb @@ -107,5 +107,12 @@ assert( @sys.setPackageTreeLocation( "/var/lib/ericsPackages" ), "testSetPackageTreeLocation()" ) end + + ## + # Test method for 'AbtSystemManager.testPackageInstalled()' + ## + def testPackageInstalled + assert( @sys.packageInstalled( "ipc" ), "testPackageInstalled()" ) + end end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-06-15 09:52:43 UTC (rev 335) +++ src/trunk/abtconfig.rb 2007-06-15 10:32:13 UTC (rev 336) @@ -35,6 +35,7 @@ require 'AbtUsage' require 'fileutils' +require 'find' # default paths / locations. $ABT_LOGS = "/var/log/abt" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 14:08:21
|
Revision: 341 http://svn.sourceforge.net/abtlinux/?rev=341&view=rev Author: eschabell Date: 2007-06-15 07:08:23 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Implemented log managers cache package. Refactored abt install to make use of this automatically after a successful install. Expanded the packages path to now be on the system. (I have just symlinked this location to my svn checkout root location) Changed helper message when a package is called for installation, but is all ready installed. In this case it suggests trying reinstalling it. Another test passing, 26 to go, all unit tests for AbTLogManager are now passing! Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/abt.rb src/trunk/abtconfig.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/AbtLogManager.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -211,26 +211,75 @@ system = AbtSystemManager.new if ( system.packageInstalled( package ) ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + sw = eval( "#{package.capitalize}.new" ) + cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir + sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) + sourceFile = File.basename( sw.srcUrl ) + installLog = getLog( package, 'install' ) + buildLog = getLog( package, 'install' ) + configureLog = getLog( package, 'install' ) + integrityLog = getLog( package, 'install' ) + packageFile = "#{$PACKAGE_PATH}#{package}.rb" - # TODO: collect package source. - FileTest::exists?("#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.install" ) - # TODO: collect package install log. - # TODO: collect package build log. + FileUtils.mkdir_p( cachedDir ) + + # collect package source. + if ( FileTest::exist?( sourcePath ) ) + FileUtils.copy_file( sourcePath, "#{cachedDir}/#{sourceFile}" ) + puts "\nCaching copy of #{package} source." + else + puts "\nUnable to cache copy of #{package} source." + end + + # collect package install log. + if ( FileTest::exist?( installLog ) ) + FileUtils.copy_file( installLog, "#{cachedDir}/#{sw.srcDir}.install" ) + puts "\nCaching copy of #{package} install log." + else + puts "\nUnable to cache copy of #{package} install log." + end - # TODO: collect package configure log. + # collect package build log. + if ( FileTest::exist?( buildLog ) ) + FileUtils.copy_file( buildLog, "#{cachedDir}/#{sw.srcDir}.build" ) + puts "\nCaching copy of #{package} build log." + else + puts "\nUnable to cache copy of #{package} build log." + end - # TODO: collect package integrity log. + # collect package configure log. + if ( FileTest::exist?( configureLog ) ) + FileUtils.copy_file( configureLog, "#{cachedDir}/#{sw.srcDir}.configure" ) + puts "\nCaching copy of #{package} configure log." + else + puts "\nUnable to cache copy of #{package} configure log." + end + + # collect package integrity log. + if ( FileTest::exist?( integrityLog ) ) + FileUtils.copy_file( integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity" ) + puts "\nCaching copy of #{package} integrity log." + else + puts "\nUnable to cache copy of #{package} integrity log." + end - # TODO: collect package description (class file). + # collect package description (class file). + if ( FileTest::exist?( packageFile ) ) + FileUtils.copy_file( packageFile, "#{cachedDir}/#{package}.rb" ) + puts "\nCaching copy of #{package} package description." + else + puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" + end - # TODO: tar and bzip this directory (package-cache-version.tar.bz2) - - return false # for now, once imlemented, need true + # tar and bzip this directory (package-cache-version.tar.bz2) + Dir.chdir( $PACKAGE_CACHED ) + if ( system( "tar -cf #{sw.srcDir}.tar #{sw.srcDir}" ) && + system( "bzip2 -f #{sw.srcDir}.tar" ) ) + # last but not least, remove our tarball directory + FileUtils.rm_rf( cachedDir ) + return true + end end return false # package not installed, can't cache it. Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/AbtPackageManager.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -98,7 +98,8 @@ # first check if installed. system = AbtSystemManager.new if ( system.packageInstalled( package ) ) - puts "\nPackage #{package} is installed, might want to try reinstall?" + puts "\n*** Package #{package} is installed, might want to try reinstall? ***" + puts "'abt reinstall #{package}'" return true end Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/abt.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -54,28 +54,29 @@ logger.logToJournal( "Starting to install #{options['package']}" ) # return if already installed. - require options['package'] + require "packages/#{options['package']}" sw = eval( "#{options['package'].capitalize}.new" ) - if ( File.directory?( - "#{$PACKAGE_INSTALLED}/#{sw.details['Source location']}" ) ) - puts "\n\n" - puts "*** Package #{options['package']} already installed, " + - "try 'abt reinstall #{options['package']}' ***" - puts "\n\n" - exit - end - if ( manager.installPackage( options['package'] ) ) puts "\n\n" puts "*** Completed install of #{options['package']}. ***" puts "\n\n" logger.logToJournal( "Completed install of #{options['package']}." ) + + if ( logger.cachePackage( options['package'] ) ) + puts "\n\n" + puts "*** Completed caching of package #{options['package']}. ***" + puts "\n\n" + logger.logToJournal( "\nCaching completed for package #{options['package']}." ) + else + logger.logToJournal( "\nCaching of package #{options['package']} failed.") + end else puts "*** #{options['package'].capitalize} install failed, " + "see journal. ***" end + #reporter.showQueue( "install" ); # DEBUG. else show.usage( "packages" ) Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/abtconfig.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -47,7 +47,7 @@ $JOURNAL = "#{$ABT_LOGS}/journal.log" $PACKAGE_INSTALLED = "#{$ABT_STATE}/installed" $PACKAGE_CACHED = "#{$ABT_STATE}/cached" -$PACKAGE_PATH = "./packages/" +$PACKAGE_PATH = "#{$ABT_CACHES}/packages/" $SOURCES_REPOSITORY = "#{$ABT_CACHES}/sources" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:06:54
|
Revision: 342 http://svn.sourceforge.net/abtlinux/?rev=342&view=rev Author: eschabell Date: 2007-07-05 06:06:54 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Refactored the code base to make use of global packages location. As we don't have package installation (repository) yet, you will need to symlink from the global location to the pacakges directory in trunk. Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/AbtReportManager.rb src/trunk/AbtSystemManager.rb src/trunk/TestAbtPackage.rb src/trunk/abt.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtDownloadManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -54,7 +54,7 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require "packages/#{packageName}" + require "#{$PACKAGE_PATH}#{packageName}" logger = AbtLogManager.new package = eval( packageName.capitalize + '.new' ) Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtLogManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -39,7 +39,7 @@ # <b>RETURN</b> <i>String</i> - Full path to install log. ## def getLog( package, type ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details @@ -100,7 +100,7 @@ # otherwise false. ## def logPackageIntegrity( package ) - #require "packages/#{package}" + #require "#{$PACKAGE_PATH}#{package}" #sw = eval( "#{package.capitalize}.new" ) #details = sw.details Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtPackageManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -103,7 +103,7 @@ return true end - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new logger = AbtLogManager.new Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtReportManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -51,7 +51,7 @@ # otherwise false. ## def showPackageDetails( package ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" if ( package = eval( "#{package.capitalize}.new" ) ) details = package.details Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtSystemManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -176,7 +176,7 @@ # false. ## def packageInstalled( package ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/TestAbtPackage.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -1,11 +1,11 @@ #!/usr/bin/ruby -w -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' -require 'AbtPackage' -require 'AbtDownloadManager' -require 'packages/ipc' +require "test/unit/testcase" +require "test/unit/autorunner" +require "abtconfig" +require "AbtPackage" +require "AbtDownloadManager" +require "#{$PACKAGE_PATH}ipc" ## # TestAbtPackage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/abt.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -54,7 +54,7 @@ logger.logToJournal( "Starting to install #{options['package']}" ) # return if already installed. - require "packages/#{options['package']}" + require "#{$PACKAGE_PATH}#{options['package']}" sw = eval( "#{options['package'].capitalize}.new" ) if ( manager.installPackage( options['package'] ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |