abtlinux-svn Mailing List for ABout Time Linux (AbTLinux) (Page 10)
Status: Alpha
Brought to you by:
eschabell
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(12) |
Apr
(4) |
May
(61) |
Jun
(5) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
(29) |
Nov
(89) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(4) |
Feb
(33) |
Mar
(12) |
Apr
|
May
(2) |
Jun
(13) |
Jul
(76) |
Aug
(7) |
Sep
(21) |
Oct
|
Nov
|
Dec
(33) |
2008 |
Jan
(32) |
Feb
(24) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(10) |
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 09:52:43
|
Revision: 335 http://svn.sourceforge.net/abtlinux/?rev=335&view=rev Author: eschabell Date: 2007-06-15 02:52:43 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Last refactoring sorted out this tests problems, can now check on package logging. Modified Paths: -------------- src/trunk/TestAbtLogManager.rb Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-06-14 15:44:32 UTC (rev 334) +++ src/trunk/TestAbtLogManager.rb 2007-06-15 09:52:43 UTC (rev 335) @@ -54,10 +54,9 @@ ## # Test method for 'AbtLogManager.testLogPackageInstall()' ## - # FIXME: sort out a setup for this test. - #def testLogPackageInstall() - # assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) - #end + def testLogPackageInstall() + assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) + end ## # Test method for 'AbtLogManager.testLogPackageBuild()' 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:44:30
|
Revision: 334 http://svn.sourceforge.net/abtlinux/?rev=334&view=rev Author: eschabell Date: 2007-06-14 08:44:32 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Moved unit testing for AbTLogManager up to front of test suite, this ensures a clean system running the tests for the first time will create all needed directories and files before a test is run that needs them. Added comment to this effect to prevent future moving of the first test. Modified Paths: -------------- src/trunk/testSuiteAbt.rb Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-06-14 15:42:53 UTC (rev 333) +++ src/trunk/testSuiteAbt.rb 2007-06-14 15:44:32 UTC (rev 334) @@ -9,11 +9,11 @@ require 'test/unit' require 'abtconfig' -require 'TestAbtDepEngine' +require 'TestAbtLogManager' # test this first ensures all dirs created. require 'TestAbtDownloadManager' -require 'TestAbtLogManager' require 'TestAbtPackage' require 'TestAbtPackageManager' require 'TestAbtQueueManager' require 'TestAbtReportManager' -require 'TestAbtSystemManager' \ No newline at end of file +require 'TestAbtSystemManager' +require 'TestAbtDepEngine' 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-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 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 08:59:35
|
Revision: 330 http://svn.sourceforge.net/abtlinux/?rev=330&view=rev Author: eschabell Date: 2007-06-14 01:59:34 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Added flexmock project link for more info. Modified Paths: -------------- src/trunk/README-UnitTests Modified: src/trunk/README-UnitTests =================================================================== --- src/trunk/README-UnitTests 2007-06-14 08:58:38 UTC (rev 329) +++ src/trunk/README-UnitTests 2007-06-14 08:59:34 UTC (rev 330) @@ -6,3 +6,5 @@ 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/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-14 08:58:48
|
Revision: 329 http://svn.sourceforge.net/abtlinux/?rev=329&view=rev Author: eschabell Date: 2007-06-14 01:58:38 -0700 (Thu, 14 Jun 2007) Log Message: ----------- About to make use of a mocking library (flexmock) so need to tell you how to add it to your installation. Added Paths: ----------- src/trunk/README-UnitTests Added: src/trunk/README-UnitTests =================================================================== --- src/trunk/README-UnitTests (rev 0) +++ src/trunk/README-UnitTests 2007-06-14 08:58:38 UTC (rev 329) @@ -0,0 +1,8 @@ +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. 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:25:36
|
Revision: 328 http://svn.sourceforge.net/abtlinux/?rev=328&view=rev Author: eschabell Date: 2007-05-04 05:25:37 -0700 (Fri, 04 May 2007) Log Message: ----------- Updated api-docs. Modified Paths: -------------- src/trunk/doc/classes/AbtDepEngine.html src/trunk/doc/classes/AbtDownloadManager.html src/trunk/doc/classes/AbtLogManager.html src/trunk/doc/classes/AbtPackage.html src/trunk/doc/classes/AbtPackageManager.html src/trunk/doc/classes/AbtQueueManager.html src/trunk/doc/classes/AbtReportManager.html src/trunk/doc/classes/AbtSystemManager.html src/trunk/doc/classes/AbtUsage.html src/trunk/doc/classes/TestAbtDepEngine.html src/trunk/doc/classes/TestAbtDownloadManager.html src/trunk/doc/classes/TestAbtLogManager.html src/trunk/doc/classes/TestAbtPackage.html src/trunk/doc/classes/TestAbtPackageManager.html src/trunk/doc/classes/TestAbtQueueManager.html src/trunk/doc/classes/TestAbtReportManager.html src/trunk/doc/classes/TestAbtSystemManager.html src/trunk/doc/created.rid src/trunk/doc/dot/f_0.dot src/trunk/doc/dot/f_0.png src/trunk/doc/dot/f_1.dot src/trunk/doc/dot/f_1.png src/trunk/doc/dot/f_10.dot src/trunk/doc/dot/f_10.png src/trunk/doc/dot/f_11.dot src/trunk/doc/dot/f_11.png src/trunk/doc/dot/f_12.dot src/trunk/doc/dot/f_12.png src/trunk/doc/dot/f_13.dot src/trunk/doc/dot/f_13.png src/trunk/doc/dot/f_14.dot src/trunk/doc/dot/f_14.png src/trunk/doc/dot/f_15.dot src/trunk/doc/dot/f_15.png src/trunk/doc/dot/f_16.dot src/trunk/doc/dot/f_16.png src/trunk/doc/dot/f_2.dot src/trunk/doc/dot/f_2.png src/trunk/doc/dot/f_3.dot src/trunk/doc/dot/f_3.png src/trunk/doc/dot/f_4.dot src/trunk/doc/dot/f_4.png src/trunk/doc/dot/f_5.dot src/trunk/doc/dot/f_5.png src/trunk/doc/dot/f_6.dot src/trunk/doc/dot/f_6.png src/trunk/doc/dot/f_7.dot src/trunk/doc/dot/f_7.png src/trunk/doc/dot/f_8.dot src/trunk/doc/dot/f_8.png src/trunk/doc/dot/f_9.dot src/trunk/doc/dot/f_9.png src/trunk/doc/files/AbtDepEngine_rb.html src/trunk/doc/files/AbtDownloadManager_rb.html src/trunk/doc/files/AbtLogManager_rb.html src/trunk/doc/files/AbtPackageManager_rb.html src/trunk/doc/files/AbtPackage_rb.html src/trunk/doc/files/AbtQueueManager_rb.html src/trunk/doc/files/AbtReportManager_rb.html src/trunk/doc/files/AbtSystemManager_rb.html src/trunk/doc/files/AbtUsage_rb.html src/trunk/doc/files/TestAbtDepEngine_rb.html src/trunk/doc/files/TestAbtDownloadManager_rb.html src/trunk/doc/files/TestAbtLogManager_rb.html src/trunk/doc/files/TestAbtPackageManager_rb.html src/trunk/doc/files/TestAbtPackage_rb.html src/trunk/doc/files/TestAbtQueueManager_rb.html src/trunk/doc/files/TestAbtReportManager_rb.html src/trunk/doc/files/TestAbtSystemManager_rb.html src/trunk/doc/fr_method_index.html Modified: src/trunk/doc/classes/AbtDepEngine.html =================================================================== --- src/trunk/doc/classes/AbtDepEngine.html 2007-05-04 12:15:26 UTC (rev 327) +++ src/trunk/doc/classes/AbtDepEngine.html 2007-05-04 12:25:37 UTC (rev 328) @@ -76,9 +76,9 @@ <div id="content"> <table cellpadding='0' cellspacing='0' border='0' width="100%"><tr><td align="center"> <map id="map" name="map"> - <area shape="rect" coords="27,50,136,98" href="AbtDepEngine.html" alt="AbtDepEngine" /> + <area shape="rect" coords="27,50,133,98" href="AbtDepEngine.html" alt="AbtDepEngine" /> </map> -<img src="../dot/f_0.png" usemap="#map" border="0" alt="dot/f_0.png"> +<img src="../dot/f_0.png" usemap="#map" border="0" alt="TopLevel" /> </td></tr></table> <div class="description"><p> @@ -86,7 +86,7 @@ </p> <p> <a href="AbtDepEngine.html">AbtDepEngine</a> class handles all dependency -aspects of the AbTLinux system. It is part of a sub-project with it‘s +aspects of the AbTLinux system. It is part of a sub-project with it’s own requirements document. </p> <p> Modified: src/trunk/doc/classes/AbtDownloadManager.html =================================================================== --- src/trunk/doc/classes/AbtDownloadManager.html 2007-05-04 12:15:26 UTC (rev 327) +++ src/trunk/doc/classes/AbtDownloadManager.html 2007-05-04 12:25:37 UTC (rev 328) @@ -78,7 +78,7 @@ <map id="map" name="map"> <area shape="rect" coords="27,50,176,98" href="AbtDownloadManager.html" alt="AbtDownloadManager" /> </map> -<img src="../dot/f_1.png" usemap="#map" border="0" alt="dot/f_1.png"> +<img src="../dot/f_1.png" usemap="#map" border="0" alt="TopLevel" /> </td></tr></table> <div class="description"><p> Modified: src/trunk/doc/classes/AbtLogManager.html =================================================================== --- src/trunk/doc/classes/AbtLogManager.html 2007-05-04 12:15:26 UTC (rev 327) +++ src/trunk/doc/classes/AbtLogManager.html 2007-05-04 12:25:37 UTC (rev 328) @@ -76,9 +76,9 @@ <div id="content"> <table cellpadding='0' cellspacing='0' border='0' width="100%"><tr><td align="center"> <map id="map" name="map"> - <area shape="rect" coords="27,50,144,98" href="AbtLogManager.html" alt="AbtLogManager" /> + <area shape="rect" coords="27,50,141,98" href="AbtLogManager.html" alt="AbtLogManager" /> </map> -<img src="../dot/f_2.png" usemap="#map" border="0" alt="dot/f_2.png"> +<img src="../dot/f_2.png" usemap="#map" border="0" alt="TopLevel" /> </td></tr></table> <div class="description"><p> @@ -120,9 +120,9 @@ <li><a href="#M000066">cachePackage</a></li> <li><a href="#M000065">logPackageBuild</a></li> <li><a href="#M000064">logPackageInstall</a></li> - <li><a href="#M000062">logPackageIntegrity</a></li> + <li><a href="#M000063">logPackageIntegrity</a></li> <li><a href="#M000067">logToJournal</a></li> - <li><a href="#M000063">new</a></li> + <li><a href="#M000062">new</a></li> </ul> @@ -133,7 +133,7 @@ <div class="sectiontitle">Public Class methods</div> <div class="method"> <div class="title"> - <a name="M000063"></a><b>new</b>() + <a name="M000062"></a><b>new</b>() </div> <div class="description"> <p> @@ -146,20 +146,20 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p> - <div id="M000063_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p> + <div id="M000062_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 58</span> -58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> -59: [<span class="ruby-identifier">$ABT_LOGS</span>, <span class="ruby-identifier">$ABT_CACHES</span>, <span class="ruby-identifier">$ABT_STATE</span>, <span class="ruby-identifier">$BUILD_LOCATION</span>, <span class="ruby-identifier">$PACKAGE_INSTALLED</span>, -60: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> -61: -62: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) ) -63: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-identifier">dir</span> ) -64: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Created directory: #{dir}."</span> ) -65: <span class="ruby-keyword kw">end</span> -66: } -67: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 43</span> +43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> +44: [<span class="ruby-identifier">$ABT_LOGS</span>, <span class="ruby-identifier">$ABT_CACHES</span>, <span class="ruby-identifier">$ABT_STATE</span>, <span class="ruby-identifier">$BUILD_LOCATION</span>, <span class="ruby-identifier">$PACKAGE_INSTALLED</span>, +45: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> +46: +47: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) ) +48: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-identifier">dir</span> ) +49: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Created directory: #{dir}."</span> ) +50: <span class="ruby-keyword kw">end</span> +51: } +52: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -186,16 +186,16 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000066_source')" id="l_M000066_source">show source</a> ]</p> <div id="M000066_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 158</span> -158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) -159: <span class="ruby-comment cmt"># TODO: collect package source.</span> -160: <span class="ruby-comment cmt"># TODO: collect package install log. </span> -161: <span class="ruby-comment cmt"># TODO: collect package build log. </span> -162: <span class="ruby-comment cmt"># TODO: collect package configure log. </span> -163: <span class="ruby-comment cmt"># TODO: collect package integrity log.</span> -164: <span class="ruby-comment cmt"># TODO: collect package description (class file).</span> -165: <span class="ruby-comment cmt"># TODO: tar and bzip this directory (package-cache-version.tar.bz2) </span> -166: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 184</span> +184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) +185: <span class="ruby-comment cmt"># TODO: collect package source.</span> +186: <span class="ruby-comment cmt"># TODO: collect package install log. </span> +187: <span class="ruby-comment cmt"># TODO: collect package build log. </span> +188: <span class="ruby-comment cmt"># TODO: collect package configure log. </span> +189: <span class="ruby-comment cmt"># TODO: collect package integrity log.</span> +190: <span class="ruby-comment cmt"># TODO: collect package description (class file).</span> +191: <span class="ruby-comment cmt"># TODO: tar and bzip this directory (package-cache-version.tar.bz2) </span> +192: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -221,22 +221,22 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000065_source')" id="l_M000065_source">show source</a> ]</p> <div id="M000065_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 133</span> -133: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">package</span> ) -134: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> -135: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) -136: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> -137: <span class="ruby-identifier">buildFile</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> -138: <span class="ruby-node">"/#{details['Source location']}.build"</span> -139: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: buildFile is - #{buildFile}" )</span> -140: -141: <span class="ruby-comment cmt"># make sure the build file exists.</span> -142: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">buildFile</span> ) ) -143: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -144: <span class="ruby-keyword kw">end</span> -145: -146: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -147: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 159</span> +159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">package</span> ) +160: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> +161: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) +162: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> +163: <span class="ruby-identifier">buildLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> +164: <span class="ruby-node">"/#{details['Source location']}.build"</span> +165: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: buildFile is - #{buildFile}" )</span> +166: +167: <span class="ruby-comment cmt"># make sure the build file exists.</span> +168: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">buildLog</span> ) ) +169: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +170: <span class="ruby-keyword kw">end</span> +171: +172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +173: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -262,119 +262,145 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show source</a> ]</p> <div id="M000064_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 78</span> - 78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">package</span> ) - 79: <span class="ruby-comment cmt"># some dirs we will not add to an install log.</span> - 80: <span class="ruby-identifier">excluded_pattern</span> = - 81: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) - 82: - 83: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> - 84: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) - 85: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> - 86: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> - 87: - 88: <span class="ruby-comment cmt"># our log locations.</span> - 89: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> - 90: <span class="ruby-node">"/#{details['Source location']}.install"</span> - 91: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> - 92: - 93: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> - 94: <span class="ruby-comment cmt"># into our install log.</span> - 95: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) - 96: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) - 97: - 98: <span class="ruby-comment cmt"># include only the file names from open calls</span> - 99: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> -100: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> -101: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) -102: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) -103: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: Found bad logLine!" )</span> -104: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> -105: <span class="ruby-keyword kw">else</span> -106: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> -107: <span class="ruby-keyword kw">end</span> -108: -109: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">badLine</span> ) -110: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: adding line to installFile!")</span> -111: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] -112: <span class="ruby-keyword kw">end</span> -113: <span class="ruby-keyword kw">end</span> -114: <span class="ruby-keyword kw">end</span> -115: -116: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">close</span> -117: <span class="ruby-keyword kw">end</span> -118: -119: <span class="ruby-comment cmt"># cleanup the tmp files.</span> -120: <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">tmpInstallLog</span> ) -121: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; -122: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 106</span> +106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">package</span> ) +107: <span class="ruby-comment cmt"># some dirs we will not add to an install log.</span> +108: <span class="ruby-identifier">excluded_pattern</span> = +109: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) +110: +111: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> +112: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) +113: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> +114: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> +115: +116: <span class="ruby-comment cmt"># our log locations.</span> +117: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> +118: <span class="ruby-node">"/#{details['Source location']}.install"</span> +119: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> +120: +121: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> +122: <span class="ruby-comment cmt"># into our install log.</span> +123: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) +124: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) +125: +126: <span class="ruby-comment cmt"># include only the file names from open calls</span> +127: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> +128: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> +129: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) +130: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) +131: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: Found bad logLine!" )</span> +132: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> +133: <span class="ruby-keyword kw">else</span> +134: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> +135: <span class="ruby-keyword kw">end</span> +136: +137: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">badLine</span> ) +138: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: adding line to installFile!")</span> +139: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] +140: <span class="ruby-keyword kw">end</span> +141: <span class="ruby-keyword kw">end</span> +142: <span class="ruby-keyword kw">end</span> +143: +144: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">close</span> +145: <span class="ruby-keyword kw">end</span> +146: +147: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; +148: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000067"></a><b>logToJournal</b>( message ) + <a name="M000063"></a><b>logPackageIntegrity</b>( package ) </div> <div class="description"> <p> -Provides logging of given message to the AbTLinux journal. Message logged -with date timestamp. +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. </p> <p> -<b>PARAM</b> <em>String</em> - Message to be added to the log. +<b>PARAM</b> <em>String</em> - Package name. </p> <p> -<b>RETURN</b> <em>boolean</em> True if logged, otherwise false. +<b>RETURN</b> <em>boolean</em> - True if integrity log created +successfully, otherwise false. </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000067_source')" id="l_M000067_source">show source</a> ]</p> - <div id="M000067_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p> + <div id="M000063_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 176</span> -176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) -177: <span class="ruby-keyword kw">if</span> ( -178: <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( -179: <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) -180: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> -181: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> -182: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -183: <span class="ruby-keyword kw">end</span> -184: -185: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -186: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 64</span> +64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageIntegrity</span>( <span class="ruby-identifier">package</span> ) +65: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> +66: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) +67: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> +68: +69: <span class="ruby-comment cmt"># our log locations.</span> +70: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> +71: <span class="ruby-node">"/#{details['Source location']}.install"</span> +72: <span class="ruby-identifier">integrityLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> +73: <span class="ruby-node">"/#{details['Source location']}.integrity"</span> +74: +75: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> +76: <span class="ruby-comment cmt"># into our install log.</span> +77: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">installLog</span> ) ) +78: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'r'</span> ) +79: <span class="ruby-identifier">integrityFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">integrityLog</span>, <span class="ruby-value str">'w'</span> ) +80: +81: <span class="ruby-comment cmt"># get the integrity for each file, initially just permissions. </span> +82: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">installLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> +83: <span class="ruby-identifier">status</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span> ) +84: <span class="ruby-identifier">octal</span> = <span class="ruby-identifier">sprintf</span>( <span class="ruby-value str">"%o"</span>, <span class="ruby-identifier">status</span>.<span class="ruby-identifier">mode</span> ) +85: <span class="ruby-identifier">integrityFile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{line.chomp}:#{octal}"</span> +86: <span class="ruby-keyword kw">end</span> +87: +88: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">close</span> +89: <span class="ruby-identifier">integrityFile</span>.<span class="ruby-identifier">close</span> +90: <span class="ruby-keyword kw">else</span> +91: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># no install log!</span> +92: <span class="ruby-keyword kw">end</span> +93: +94: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; +95: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> -<div class="sectiontitle">Protected Instance methods</div> <div class="method"> <div class="title"> - <a name="M000062"></a><b>logPackageIntegrity</b>( package ) + <a name="M000067"></a><b>logToJournal</b>( message ) </div> <div class="description"> <p> -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. +Provides logging of given message to the AbTLinux journal. Message logged +with date timestamp. </p> <p> -<b>PARAM</b> <em>String</em> - Package name. +<b>PARAM</b> <em>String</em> - Message to be added to the log. </p> <p> -<b>RETURN</b> <em>boolean</em> - True if integrity log created -successfully, otherwise false. +<b>RETURN</b> <em>boolean</em> True if logged, otherwise false. </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p> - <div id="M000062_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000067_source')" id="l_M000067_source">show source</a> ]</p> + <div id="M000067_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 42</span> -42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageIntegrity</span>( <span class="ruby-identifier">package</span> ) -43: <span class="ruby-comment cmt"># TODO: implement logPackageIntegrity.</span> -44: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 202</span> +202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) +203: <span class="ruby-keyword kw">if</span> ( +204: <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( +205: <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) +206: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> +207: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> +208: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +209: <span class="ruby-keyword kw">end</span> +210: +211: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +212: <span class="ruby-keyword kw">end</span> </pre> </div> </div> Modified: src/trunk/doc/classes/AbtPackage.html =================================================================== --- src/trunk/doc/classes/AbtPackage.html 2007-05-04 12:15:26 UTC (rev 327) +++ src/trunk/doc/classes/AbtPackage.html 2007-05-04 12:25:37 UTC (rev 328) @@ -78,7 +78,7 @@ <map id="map" name="map"> <area shape="rect" coords="27,50,120,98" href="AbtPackage.html" alt="AbtPackage" /> </map> -<img src="../dot/f_3.png" usemap="#map" border="0" alt="dot/f_3.png"> +<img src="../dot/f_3.png" usemap="#map" border="0" alt="TopLevel" /> </td></tr></table> <div class="description"><p> @@ -90,8 +90,7 @@ inheriting from this class (class Fortune < <a href="AbtPackage.html">AbtPackage</a>) one picks up all supported standard functions for the abt <a href="AbtPackage.html">AbtPackage</a> manager to -make use of the <a href="AbtPackage.html#M000025">new</a> <a -href="AbtPackage.html">AbtPackage</a>. +make use of the new <a href="AbtPackage.html">AbtPackage</a>. </p> <p> Created by Eric D. Schabell <er...@ab...> Copyright 2006, GPL. @@ -108,8 +107,8 @@ <p> AbTLinux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more <a -href="AbtPackage.html#M000026">details</a>. +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. </p> <p> You should have received a copy of the GNU General Public License along @@ -310,7 +309,7 @@ <div class="description"> <p> Constructor for an <a href="AbtPackage.html">AbtPackage</a>, requires all -the packge <a href="AbtPackage.html#M000026">details</a>. +the packge details. </p> <p> <b>PARAM</b> <em>Hash</em> - hash containing all package data. @@ -346,7 +345,7 @@ <div class="sectiontitle">Public Instance methods</div> <div class="method"> <div class="title"> - <a name="M000029"></a><b>build</b>() + <a name="M000029"></a><b>build</b>( verbose=true ) </div> <div class="description"> <p> @@ -354,6 +353,10 @@ running ‘make’. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, otherwise false. </p> @@ -362,38 +365,46 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000029_source')" id="l_M000029_source">show source</a> ]</p> <div id="M000029_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 261</span> -261: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span> -262: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) -263: -264: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( -265: <span class="ruby-node">"make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build"</span> ) ) -266: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section failed."</span> -267: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -268: <span class="ruby-keyword kw">end</span> -269: -270: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section completed!"</span> -271: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -272: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 277</span> +277: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +278: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">verbose</span> ) +279: <span class="ruby-identifier">command</span> = <span class="ruby-node">"make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build"</span> +280: <span class="ruby-keyword kw">else</span> +281: <span class="ruby-identifier">command</span> = <span class="ruby-node">"make > #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build 2>&1"</span> +282: <span class="ruby-keyword kw">end</span> +283: +284: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) +285: +286: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-identifier">command</span> ) ) +287: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section failed."</span> +288: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +289: <span class="ruby-keyword kw">end</span> +290: +291: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section completed!"</span> <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">verbose</span> ) +292: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +293: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000028"></a><b>configure</b>() + <a name="M000028"></a><b>configure</b>( verbose=true ) </div> <div class="description"> <p> -Here we manage the ./<a href="AbtPackage.html#M000028">configure</a> step -(or equivalent). We need to give ./<a -href="AbtPackage.html#M000028">configure</a> (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. +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. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, otherwise false. </p> @@ -402,19 +413,26 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000028_source')" id="l_M000028_source">show source</a> ]</p> <div id="M000028_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 241</span> -241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span> -242: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) -243: -244: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-node">"./configure --prefix=#{$DEFAULT_PREFIX} | tee "</span> <span class="ruby-operator">+</span> -245: <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure"</span> ) ) -246: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.configure] - configure section failed."</span> -247: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -248: <span class="ruby-keyword kw">end</span> -249: -250: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.configure] - configure section completed!"</span> -251: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -252: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 247</span> +247: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +248: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">verbose</span> ) +249: <span class="ruby-identifier">command</span> = <span class="ruby-node">"./configure --prefix=#{$DEFAULT_PREFIX} | tee "</span> <span class="ruby-operator">+</span> +250: <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure"</span> +251: <span class="ruby-keyword kw">else</span> +252: <span class="ruby-identifier">command</span> = <span class="ruby-node">"./configure --prefix=#{$DEFAULT_PREFIX} 1> "</span> <span class="ruby-operator">+</span> +253: <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure 2>&1"</span> +254: <span class="ruby-keyword kw">end</span> +255: +256: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) +257: +258: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-identifier">command</span> ) ) +259: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.configure] - configure section failed."</span> +260: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +261: <span class="ruby-keyword kw">end</span> +262: +263: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"\nDEBUG: [AbtPackage.configure] - configure section completed!"</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">verbose</span> ) +264: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +265: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -464,13 +482,17 @@ </div> <div class="method"> <div class="title"> - <a name="M000031"></a><b>install</b>() + <a name="M000031"></a><b>install</b>( verbose=true ) </div> <div class="description"> <p> All files to be installed are installed here. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, otherwise false. </p> @@ -479,29 +501,35 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000031_source')" id="l_M000031_source">show source</a> ]</p> <div id="M000031_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 294</span> -294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">install</span> -295: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) -296: -297: <span class="ruby-comment cmt"># TODO: install section, can this be done without installwatch?</span> -298: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-value str">"installwatch --transl=no --backup=no "</span> <span class="ruby-operator">+</span> -299: <span class="ruby-value str">"--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys "</span> <span class="ruby-operator">+</span> -300: <span class="ruby-node">"--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install"</span> ) ) -301: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.install] - install section failed."</span> -302: <span class="ruby-comment cmt"># TODO: install section, rollback any installed files (use install log).</span> -303: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -304: <span class="ruby-keyword kw">end</span> -305: -306: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.install] - install section completed!"</span> -307: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -308: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 321</span> +321: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">install</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +322: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">verbose</span> ) +323: <span class="ruby-identifier">command</span> = <span class="ruby-value str">"installwatch --transl=no --backup=no "</span> <span class="ruby-operator">+</span> +324: <span class="ruby-value str">"--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys "</span> <span class="ruby-operator">+</span> +325: <span class="ruby-node">"--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install"</span> +326: <span class="ruby-keyword kw">else</span> +327: <span class="ruby-identifier">command</span> = <span class="ruby-value str">"installwatch --transl=no --backup=no "</span> <span class="ruby-operator">+</span> +328: <span class="ruby-value str">"--exclude=/dev,/proc,/tmp,/var/tmp,/usr/src,/sys "</span> <span class="ruby-operator">+</span> +329: <span class="ruby-node">"--logfile=#{$ABT_TMP}/#{@srcDir}.watch make install >/dev/null"</span> +330: <span class="ruby-keyword kw">end</span> +331: +332: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) +333: +334: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-identifier">command</span> ) ) +335: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.install] - install section failed."</span> +336: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +337: <span class="ruby-keyword kw">end</span> +338: +339: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.install] - install section completed!"</span> <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">verbose</span> ) +340: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +341: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000032"></a><b>post</b>() + <a name="M000032"></a><b>post</b>( verbose=true ) </div> <div class="description"> <p> @@ -509,6 +537,10 @@ for example. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, otherwise false. </p> @@ -517,18 +549,18 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000032_source')" id="l_M000032_source">show source</a> ]</p> <div id="M000032_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 317</span> -317: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span> -318: <span class="ruby-comment cmt"># TODO: implement post section install init scripts service</span> -319: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -320: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 353</span> +353: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +354: <span class="ruby-comment cmt"># TODO: implement post section install init scripts service</span> +355: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +356: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000027"></a><b>pre</b>() + <a name="M000027"></a><b>pre</b>( verbose=true ) </div> <div class="description"> <p> @@ -536,6 +568,10 @@ unpacking it, downloading and applying patches. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if completes sucessfully, otherwise false. </p> @@ -544,47 +580,51 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000027_source')" id="l_M000027_source">show source</a> ]</p> <div id="M000027_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 204</span> -204: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pre</span> -205: <span class="ruby-identifier">downloader</span> = <span class="ruby-constant">AbtDownloadManager</span>.<span class="ruby-identifier">new</span> -206: -207: <span class="ruby-comment cmt"># download sources.</span> -208: <span class="ruby-keyword kw">if</span> ( -209: <span class="ruby-operator">!</span><span class="ruby-identifier">downloader</span>.<span class="ruby-identifier">retrievePackageSource</span>( -210: <span class="ruby-ivar">@name</span>.<span class="ruby-identifier">downcase</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span> ) ) -211: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -212: <span class="ruby-keyword kw">end</span> -213: -214: <span class="ruby-comment cmt"># unpack sources.</span> -215: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unpackSources</span> ) -216: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -217: <span class="ruby-keyword kw">end</span> -218: -219: <span class="ruby-comment cmt"># ensure we have an installed directory to use.</span> -220: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}"</span> ) ) -221: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}"</span> ) -222: <span class="ruby-keyword kw">end</span> -223: -224: <span class="ruby-comment cmt"># TODO: implement pre section retrieve patches?</span> -225: <span class="ruby-comment cmt"># TODO: implement pre section apply patches?</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 207</span> +207: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pre</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +208: <span class="ruby-identifier">downloader</span> = <span class="ruby-constant">AbtDownloadManager</span>.<span class="ruby-identifier">new</span> +209: +210: <span class="ruby-comment cmt"># download sources.</span> +211: <span class="ruby-keyword kw">if</span> ( +212: <span class="ruby-operator">!</span><span class="ruby-identifier">downloader</span>.<span class="ruby-identifier">retrievePackageSource</span>( +213: <span class="ruby-ivar">@name</span>.<span class="ruby-identifier">downcase</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span> ) ) +214: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +215: <span class="ruby-keyword kw">end</span> +216: +217: <span class="ruby-comment cmt"># unpack sources.</span> +218: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unpackSources</span> ) +219: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +220: <span class="ruby-keyword kw">end</span> +221: +222: <span class="ruby-comment cmt"># ensure we have an installed directory to use.</span> +223: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}"</span> ) ) +224: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{@srcDir}"</span> ) +225: <span class="ruby-keyword kw">end</span> 226: -227: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -228: <span class="ruby-keyword kw">end</span> +227: <span class="ruby-comment cmt"># TODO: implement pre section retrieve patches?</span> +228: <span class="ruby-comment cmt"># TODO: implement pre section apply patches?</span> +229: +230: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +231: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000030"></a><b>preinstall</b>() + <a name="M000030"></a><b>preinstall</b>( verbose=true ) </div> <div class="description"> <p> Any actions needed before the installation can occur will happen here, such -as creating <a href="AbtPackage.html#M000025">new</a> user accounts, -dealing with existing configuration files, etc. +as creating new user accounts, dealing with existing configuration files, +etc. </p> <p> +<b>PARAM</b> <em>boolean</em> - true if you want to see the verbose output, +otherwise false. Defaults to true. +</p> +<p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, otherwise false. </p> @@ -593,12 +633,12 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000030_source')" id="l_M000030_source">show source</a> ]</p> <div id="M000030_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 282</span> -282: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">preinstall</span> -283: <span class="ruby-comment cmt"># TODO: preinstall section create_group?</span> -284: <span class="ruby-comment cmt"># TODO: preinstall section create_user?</span> -285: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; -286: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 306</span> +306: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">preinstall</span>( <span class="ruby-identifier">verbose</span>=<span class="ruby-keyword kw">true</span> ) +307: <span class="ruby-comment cmt"># TODO: preinstall section create_group?</span> +308: <span class="ruby-comment cmt"># TODO: preinstall section create_user?</span> +309: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; +310: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -609,8 +649,7 @@ </div> <div class="description"> <p> -Cleans up this packages source <a href="AbtPackage.html#M000029">build</a> -directory. +Cleans up this packages source build directory. </p> <p> <b>RETURNS:</b> <em>boolean</em> - True if the completes sucessfully, @@ -621,22 +660,23 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000033_source')" id="l_M000033_source">show source</a> ]</p> <div id="M000033_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 328</span> -328: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">removeBuild</span> -329: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">$REMOVE_BUILD_SOURCES</span> ) -330: <span class="ruby-identifier">buildSourcesLocation</span> = <span class="ruby-node">"#{$BUILD_LOCATION}/#{srcDir}"</span> -331: -332: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">buildSourcesLocation</span> ) ) -333: <span class="ruby-keyword kw">return</span> <span class="r... [truncated message content] |
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-03-06 21:38:35
|
Revision: 326 http://svn.sourceforge.net/abtlinux/?rev=326&view=rev Author: eschabell Date: 2007-03-06 13:38:36 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Fixed to run the actual test for logging package integrity. Another test passed, 27 to go! Modified Paths: -------------- src/trunk/TestAbtLogManager.rb Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-03-06 21:36:43 UTC (rev 325) +++ src/trunk/TestAbtLogManager.rb 2007-03-06 21:38:36 UTC (rev 326) @@ -48,8 +48,7 @@ # Test method for 'AbtLogManager.testLogPackageIntegrity()' ## def testLogPackageIntegrity() - #assert( @log.logPackageIntegrity( "ipc" ), "testLogPackageIntegrity()" ) - assert( false, "testLogPackageIntegrity()" ) + assert( @log.logPackageIntegrity( "ipc" ), "testLogPackageIntegrity()" ) 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-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-05 20:39:39
|
Revision: 323 http://svn.sourceforge.net/abtlinux/?rev=323&view=rev Author: eschabell Date: 2007-03-05 12:39:40 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Implemented a check for already installed package on install call. Modified Paths: -------------- src/trunk/abt.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-03-05 20:38:59 UTC (rev 322) +++ src/trunk/abt.rb 2007-03-05 20:39:40 UTC (rev 323) @@ -62,6 +62,19 @@ options['package'] = ARGV[1] logger.logToJournal( "Starting to install #{options['package']}" ) + # return if already installed. + require 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']}. ***" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-05 20:38:58
|
Revision: 322 http://svn.sourceforge.net/abtlinux/?rev=322&view=rev Author: eschabell Date: 2007-03-05 12:38:59 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Fixed typo, concat of a string must be done with + at end of string and not on the newline. Modified Paths: -------------- src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-05 20:13:26 UTC (rev 321) +++ src/trunk/AbtPackageManager.rb 2007-03-05 20:38:59 UTC (rev 322) @@ -63,8 +63,8 @@ # cleanup install log as it is incomplete. File.delete( logFile ) else - puts "DEBUG: attempt to use APM:rollBack( type ) incorrectly, " - + "unsupported type?" + puts "DEBUG: attempt to use APM:rollBack( type ) incorrectly, " + + "unsupported type?" return false end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-05 20:13:42
|
Revision: 321 http://svn.sourceforge.net/abtlinux/?rev=321&view=rev Author: eschabell Date: 2007-03-05 12:13:26 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Created new private method rollBack which ensures proper cleanup on package section failures, currently only for install. Implemented rollback within the installation of a package should install fail somewhere in the middle, removes installed files and removes the install log before aborting installation run. Another test passing, 28 to go! Modified Paths: -------------- src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-03-05 20:11:00 UTC (rev 320) +++ src/trunk/AbtPackageManager.rb 2007-03-05 20:13:26 UTC (rev 321) @@ -31,6 +31,47 @@ private + ## + # Attempts to roll back a type of action. Current supported types are + # install. Removes installed files and logs as needed. + # + # <b>PARAM</b> <i>String</i> - the type of rollback option to attempt. + # <b>PARAM</b> <i>Array</i> - The details of the package for which the + # rollback action is being called. + # + # <b>RETURN</b> <i>boolean</i> - True if the action rolls back, otherwise + # false. + ## + def rollBack( type, details ) + logFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/" + + case type + when "install" + logFile = logFile + "#{details['Source location']}.install" + + file = File.new( logFile, "r" ) + while ( line = file.gets ) + #puts "DEBUG: about to remove ***#{line.chomp}***" + if ( File.file?( line.chomp ) ) + File.delete( line.chomp ) + else + puts "DEBUG: file not exist? ***#{File.basename( line.chomp )}***" + end + end + file.close + + # cleanup install log as it is incomplete. + File.delete( logFile ) + else + puts "DEBUG: attempt to use APM:rollBack( type ) incorrectly, " + + "unsupported type?" + return false + end + + return true + end + + public ## @@ -115,9 +156,13 @@ # install section. puts "\n*** Processing the INSTALL section for #{package}. ***" if ( !sw.install ) + # rollback installed files if any and remove install log. logger.logToJournal( "Failed to process install section in the " + "package description of #{package}." ) - # FIXME: APM rollback any installed files (use install log). + logger.logPackageInstall( sw.name.downcase ) + logger.logToJournal( + "***Starting rollback of #{package} install and removing install log." ) + self.rollBack( "install", details ) return false else logger.logPackageInstall( sw.name.downcase ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-03-05 20:11:04
|
Revision: 320 http://svn.sourceforge.net/abtlinux/?rev=320&view=rev Author: eschabell Date: 2007-03-05 12:11:00 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Refactored name of log file to match naming convention. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-03-05 11:04:01 UTC (rev 319) +++ src/trunk/AbtLogManager.rb 2007-03-05 20:11:00 UTC (rev 320) @@ -134,12 +134,12 @@ require package sw = eval( "#{package.capitalize}.new" ) details = sw.details - buildFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + buildLog = "#{$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 ) ) + if ( !File.exist?( buildLog ) ) return false end 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-03 13:58:56
|
Revision: 318 http://svn.sourceforge.net/abtlinux/?rev=318&view=rev Author: eschabell Date: 2007-03-03 05:58:57 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Regenerated api docs. Modified Paths: -------------- src/trunk/doc/classes/AbtDepEngine.html src/trunk/doc/classes/AbtDownloadManager.html src/trunk/doc/classes/AbtLogManager.html src/trunk/doc/classes/AbtPackage.html src/trunk/doc/classes/AbtPackageManager.html src/trunk/doc/classes/AbtQueueManager.html src/trunk/doc/classes/AbtReportManager.html src/trunk/doc/classes/AbtSystemManager.html src/trunk/doc/classes/AbtUsage.html src/trunk/doc/classes/TestAbtDepEngine.html src/trunk/doc/classes/TestAbtDownloadManager.html src/trunk/doc/classes/TestAbtLogManager.html src/trunk/doc/classes/TestAbtPackage.html src/trunk/doc/classes/TestAbtPackageManager.html src/trunk/doc/classes/TestAbtQueueManager.html src/trunk/doc/classes/TestAbtReportManager.html src/trunk/doc/classes/TestAbtSystemManager.html src/trunk/doc/created.rid src/trunk/doc/files/AbtDepEngine_rb.html src/trunk/doc/files/AbtDownloadManager_rb.html src/trunk/doc/files/AbtLogManager_rb.html src/trunk/doc/files/AbtPackageManager_rb.html src/trunk/doc/files/AbtPackage_rb.html src/trunk/doc/files/AbtQueueManager_rb.html src/trunk/doc/files/AbtReportManager_rb.html src/trunk/doc/files/AbtSystemManager_rb.html src/trunk/doc/files/TestAbtDepEngine_rb.html src/trunk/doc/files/TestAbtDownloadManager_rb.html src/trunk/doc/files/TestAbtLogManager_rb.html src/trunk/doc/files/TestAbtPackageManager_rb.html src/trunk/doc/files/TestAbtPackage_rb.html src/trunk/doc/files/TestAbtQueueManager_rb.html src/trunk/doc/files/TestAbtReportManager_rb.html src/trunk/doc/files/TestAbtSystemManager_rb.html src/trunk/doc/fr_method_index.html Modified: src/trunk/doc/classes/AbtDepEngine.html =================================================================== --- src/trunk/doc/classes/AbtDepEngine.html 2007-03-03 13:57:38 UTC (rev 317) +++ src/trunk/doc/classes/AbtDepEngine.html 2007-03-03 13:58:57 UTC (rev 318) @@ -118,7 +118,7 @@ <div class="sectiontitle">Methods</div> <ul> - <li><a href="#M000086">new</a></li> + <li><a href="#M000091">new</a></li> </ul> @@ -129,7 +129,7 @@ <div class="sectiontitle">Public Class methods</div> <div class="method"> <div class="title"> - <a name="M000086"></a><b>new</b>() + <a name="M000091"></a><b>new</b>() </div> <div class="description"> <p> @@ -141,8 +141,8 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000086_source')" id="l_M000086_source">show source</a> ]</p> - <div id="M000086_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000091_source')" id="l_M000091_source">show source</a> ]</p> + <div id="M000091_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File AbtDepEngine.rb, line 41</span> 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> Modified: src/trunk/doc/classes/AbtDownloadManager.html =================================================================== --- src/trunk/doc/classes/AbtDownloadManager.html 2007-03-03 13:57:38 UTC (rev 317) +++ src/trunk/doc/classes/AbtDownloadManager.html 2007-03-03 13:58:57 UTC (rev 318) @@ -150,9 +150,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show source</a> ]</p> <div id="M000011_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 41</span> -41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> -42: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 42</span> +42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> +43: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -178,51 +178,54 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show source</a> ]</p> <div id="M000014_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 94</span> - 94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieveNewsFeed</span>( <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">cleanLog</span> = <span class="ruby-value str">"false"</span> ) - 95: <span class="ruby-identifier">require</span> <span class="ruby-value str">'net/http'</span> - 96: <span class="ruby-identifier">require</span> <span class="ruby-value str">'uri'</span> - 97: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/1.0'</span> - 98: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/2.0'</span> - 99: <span class="ruby-identifier">newsLog</span> = <span class="ruby-value str">""</span> -100: -101: <span class="ruby-comment cmt"># ensure we have our news logfile.</span> -102: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">cleanLog</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"true"</span> ) -103: <span class="ruby-identifier">newsLog</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$ABTNEWS_LOG</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">TRUNC</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">644</span> ) -104: <span class="ruby-keyword kw">else</span> -105: <span class="ruby-identifier">newsLog</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$ABTNEWS_LOG</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">644</span> ) -106: <span class="ruby-keyword kw">end</span> -107: -108: <span class="ruby-comment cmt"># pick up the abtlinux.org news feed.</span> -109: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">news</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get</span>( <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>( <span class="ruby-identifier">uri</span> ) ) ) -110: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to retrieve news feed #{uri}."</span> ) -111: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -112: <span class="ruby-keyword kw">end</span> -113: -114: <span class="ruby-comment cmt"># display the feeds.</span> -115: <span class="ruby-identifier">rss</span> = <span class="ruby-keyword kw">nil</span> -116: <span class="ruby-keyword kw">begin</span> -117: <span class="ruby-identifier">rss</span> = <span class="ruby-constant">RSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">news</span>, <span class="ruby-keyword kw">false</span>) -118: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> -119: <span class="ruby-keyword kw">end</span> -120: -121: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">rss</span>.<span class="ruby-identifier">nil?</span> ) -122: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to display news feed as feed #{uri} is not RSS 1.0/2.0."</span> ) -123: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -124: <span class="ruby-keyword kw">else</span> -125: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"*** #{rss.channel.title} ***"</span> -126: -127: <span class="ruby-identifier">rss</span>.<span class="ruby-identifier">items</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span>, <span class="ruby-identifier">itemCount</span><span class="ruby-operator">|</span> -128: <span class="ruby-identifier">itemCount</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -129: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{itemCount} #{item.link} #{item.title}"</span> -130: <span class="ruby-keyword kw">end</span> -131: <span class="ruby-keyword kw">end</span> -132: -133: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"\n"</span> -134: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">close</span> -135: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -136: -137: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 97</span> + 97: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieveNewsFeed</span>( <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">cleanLog</span> = <span class="ruby-value str">"false"</span> ) + 98: <span class="ruby-identifier">require</span> <span class="ruby-value str">'net/http'</span> + 99: <span class="ruby-identifier">require</span> <span class="ruby-value str">'uri'</span> +100: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/1.0'</span> +101: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/2.0'</span> +102: <span class="ruby-identifier">newsLog</span> = <span class="ruby-value str">""</span> +103: +104: <span class="ruby-comment cmt"># ensure we have our news logfile.</span> +105: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">cleanLog</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"true"</span> ) +106: <span class="ruby-identifier">newsLog</span> = +107: <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$ABTNEWS_LOG</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">TRUNC</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">644</span> ) +108: <span class="ruby-keyword kw">else</span> +109: <span class="ruby-identifier">newsLog</span> = +110: <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$ABTNEWS_LOG</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">644</span> ) +111: <span class="ruby-keyword kw">end</span> +112: +113: <span class="ruby-comment cmt"># pick up the abtlinux.org news feed.</span> +114: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">news</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get</span>( <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>( <span class="ruby-identifier">uri</span> ) ) ) +115: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to retrieve news feed #{uri}."</span> ) +116: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +117: <span class="ruby-keyword kw">end</span> +118: +119: <span class="ruby-comment cmt"># display the feeds.</span> +120: <span class="ruby-identifier">rss</span> = <span class="ruby-keyword kw">nil</span> +121: <span class="ruby-keyword kw">begin</span> +122: <span class="ruby-identifier">rss</span> = <span class="ruby-constant">RSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">news</span>, <span class="ruby-keyword kw">false</span>) +123: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> +124: <span class="ruby-keyword kw">end</span> +125: +126: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">rss</span>.<span class="ruby-identifier">nil?</span> ) +127: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to display news feed as feed #{uri} "</span> <span class="ruby-operator">+</span> +128: <span class="ruby-value str">"is not RSS 1.0/2.0."</span> ) +129: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +130: <span class="ruby-keyword kw">else</span> +131: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"*** #{rss.channel.title} ***"</span> +132: +133: <span class="ruby-identifier">rss</span>.<span class="ruby-identifier">items</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span>, <span class="ruby-identifier">itemCount</span><span class="ruby-operator">|</span> +134: <span class="ruby-identifier">itemCount</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +135: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{itemCount} #{item.link} #{item.title}"</span> +136: <span class="ruby-keyword kw">end</span> +137: <span class="ruby-keyword kw">end</span> +138: +139: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"\n"</span> +140: <span class="ruby-identifier">newsLog</span>.<span class="ruby-identifier">close</span> +141: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +142: +143: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -250,25 +253,27 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000012_source')" id="l_M000012_source">show source</a> ]</p> <div id="M000012_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 55</span> -55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrievePackageSource</span>( <span class="ruby-identifier">packageName</span>, <span class="ruby-identifier">destination</span> ) -56: <span class="ruby-identifier">require</span> <span class="ruby-identifier">packageName</span> -57: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">AbtLogManager</span>.<span class="ruby-identifier">new</span> -58: <span class="ruby-identifier">package</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-identifier">packageName</span>.<span class="ruby-identifier">capitalize</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.new'</span> ) -59: -60: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">destination</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>( <span class="ruby-identifier">package</span>.<span class="ruby-identifier">srcUrl</span> ) ) ) -61: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"Download not needed, existing source found for "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">packageName</span> ) -62: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -63: <span class="ruby-keyword kw">end</span> -64: -65: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">destination</span> ) -66: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">system</span>( <span class="ruby-node">"wget #{package.srcUrl}"</span> ) ) -67: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"Download completed for "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">packageName</span> ) -68: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -69: <span class="ruby-keyword kw">end</span> -70: -71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># download failed.</span> -72: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 56</span> +56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrievePackageSource</span>( <span class="ruby-identifier">packageName</span>, <span class="ruby-identifier">destination</span> ) +57: <span class="ruby-identifier">require</span> <span class="ruby-identifier">packageName</span> +58: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">AbtLogManager</span>.<span class="ruby-identifier">new</span> +59: <span class="ruby-identifier">package</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-identifier">packageName</span>.<span class="ruby-identifier">capitalize</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.new'</span> ) +60: +61: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( +62: <span class="ruby-identifier">destination</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>( <span class="ruby-identifier">package</span>.<span class="ruby-identifier">srcUrl</span> ) ) ) +63: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"Download not needed, existing source "</span> <span class="ruby-operator">+</span> +64: <span class="ruby-value str">"found for "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">packageName</span> ) +65: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +66: <span class="ruby-keyword kw">end</span> +67: +68: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">destination</span> ) +69: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">system</span>( <span class="ruby-node">"wget #{package.srcUrl}"</span> ) ) +70: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"Download completed for "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">packageName</span> ) +71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +72: <span class="ruby-keyword kw">end</span> +73: +74: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># download failed.</span> +75: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -294,9 +299,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000013_source')" id="l_M000013_source">show source</a> ]</p> <div id="M000013_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 82</span> -82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrievePackageTree</span>( <span class="ruby-identifier">packageTreeName</span> ) -83: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 85</span> +85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrievePackageTree</span>( <span class="ruby-identifier">packageTreeName</span> ) +86: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -321,9 +326,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000015_source')" id="l_M000015_source">show source</a> ]</p> <div id="M000015_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 147</span> -147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">updatePackage</span> -148: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 153</span> +153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">updatePackage</span> +154: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -345,9 +350,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000016_source')" id="l_M000016_source">show source</a> ]</p> <div id="M000016_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 156</span> -156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">updatePackageTree</span> -157: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtDownloadManager.rb, line 162</span> +162: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">updatePackageTree</span> +163: <span class="ruby-keyword kw">end</span> </pre> </div> </div> Modified: src/trunk/doc/classes/AbtLogManager.html =================================================================== --- src/trunk/doc/classes/AbtLogManager.html 2007-03-03 13:57:38 UTC (rev 317) +++ src/trunk/doc/classes/AbtLogManager.html 2007-03-03 13:58:57 UTC (rev 318) @@ -117,12 +117,12 @@ <div class="sectiontitle">Methods</div> <ul> - <li><a href="#M000064">cachePackage</a></li> - <li><a href="#M000063">logPackageBuild</a></li> - <li><a href="#M000062">logPackageInstall</a></li> - <li><a href="#M000060">logPackageIntegrity</a></li> - <li><a href="#M000065">logToJournal</a></li> - <li><a href="#M000061">new</a></li> + <li><a href="#M000066">cachePackage</a></li> + <li><a href="#M000065">logPackageBuild</a></li> + <li><a href="#M000064">logPackageInstall</a></li> + <li><a href="#M000062">logPackageIntegrity</a></li> + <li><a href="#M000067">logToJournal</a></li> + <li><a href="#M000063">new</a></li> </ul> @@ -133,7 +133,7 @@ <div class="sectiontitle">Public Class methods</div> <div class="method"> <div class="title"> - <a name="M000061"></a><b>new</b>() + <a name="M000063"></a><b>new</b>() </div> <div class="description"> <p> @@ -146,13 +146,13 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000061_source')" id="l_M000061_source">show source</a> ]</p> - <div id="M000061_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p> + <div id="M000063_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File AbtLogManager.rb, line 58</span> 58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> 59: [<span class="ruby-identifier">$ABT_LOGS</span>, <span class="ruby-identifier">$ABT_CACHES</span>, <span class="ruby-identifier">$ABT_STATE</span>, <span class="ruby-identifier">$BUILD_LOCATION</span>, <span class="ruby-identifier">$PACKAGE_INSTALLED</span>, -60: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> +60: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> 61: 62: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) ) 63: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-identifier">dir</span> ) @@ -167,7 +167,7 @@ <div class="sectiontitle">Public Instance methods</div> <div class="method"> <div class="title"> - <a name="M000064"></a><b>cachePackage</b>( package ) + <a name="M000066"></a><b>cachePackage</b>( package ) </div> <div class="description"> <p> @@ -183,19 +183,26 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show source</a> ]</p> - <div id="M000064_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000066_source')" id="l_M000066_source">show source</a> ]</p> + <div id="M000066_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 157</span> -157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) -158: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 158</span> +158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) +159: <span class="ruby-comment cmt"># TODO: collect package source.</span> +160: <span class="ruby-comment cmt"># TODO: collect package install log. </span> +161: <span class="ruby-comment cmt"># TODO: collect package build log. </span> +162: <span class="ruby-comment cmt"># TODO: collect package configure log. </span> +163: <span class="ruby-comment cmt"># TODO: collect package integrity log.</span> +164: <span class="ruby-comment cmt"># TODO: collect package description (class file).</span> +165: <span class="ruby-comment cmt"># TODO: tar and bzip this directory (package-cache-version.tar.bz2) </span> +166: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000063"></a><b>logPackageBuild</b>( package ) + <a name="M000065"></a><b>logPackageBuild</b>( package ) </div> <div class="description"> <p> @@ -211,31 +218,32 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p> - <div id="M000063_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000065_source')" id="l_M000065_source">show source</a> ]</p> + <div id="M000065_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File AbtLogManager.rb, line 133</span> 133: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">package</span> ) 134: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> 135: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) 136: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> -137: <span class="ruby-identifier">buildFile</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.build"</span> -138: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: buildFile is - #{buildFile}" )</span> -139: -140: <span class="ruby-comment cmt"># make sure the build file exists.</span> -141: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">buildFile</span> ) ) -142: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -143: <span class="ruby-keyword kw">end</span> -144: -145: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -146: <span class="ruby-keyword kw">end</span> +137: <span class="ruby-identifier">buildFile</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> +138: <span class="ruby-node">"/#{details['Source location']}.build"</span> +139: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: buildFile is - #{buildFile}" )</span> +140: +141: <span class="ruby-comment cmt"># make sure the build file exists.</span> +142: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">buildFile</span> ) ) +143: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +144: <span class="ruby-keyword kw">end</span> +145: +146: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +147: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000062"></a><b>logPackageInstall</b>( package ) + <a name="M000064"></a><b>logPackageInstall</b>( package ) </div> <div class="description"> <p> @@ -251,39 +259,39 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p> - <div id="M000062_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show source</a> ]</p> + <div id="M000064_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File AbtLogManager.rb, line 78</span> 78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">package</span> ) 79: <span class="ruby-comment cmt"># some dirs we will not add to an install log.</span> - 80: <span class="ruby-identifier">excluded_pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) - 81: - 82: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> - 83: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) - 84: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> - 85: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> - 86: - 87: <span class="ruby-comment cmt"># our log locations.</span> - 88: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.install"</span> - 89: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> - 90: - 91: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> - 92: <span class="ruby-comment cmt"># into our install log.</span> - 93: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) - 94: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) - 95: - 96: <span class="ruby-comment cmt"># include only the file names from open calls</span> - 97: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> - 98: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> - 99: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) -100: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." )</span> -101: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) -102: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: Found bad logLine!" )</span> -103: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> -104: <span class="ruby-keyword kw">else</span> -105: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> -106: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}")</span> + 80: <span class="ruby-identifier">excluded_pattern</span> = + 81: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) + 82: + 83: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> + 84: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) + 85: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> + 86: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> + 87: + 88: <span class="ruby-comment cmt"># our log locations.</span> + 89: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}"</span> <span class="ruby-operator">+</span> + 90: <span class="ruby-node">"/#{details['Source location']}.install"</span> + 91: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> + 92: + 93: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> + 94: <span class="ruby-comment cmt"># into our install log.</span> + 95: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) + 96: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) + 97: + 98: <span class="ruby-comment cmt"># include only the file names from open calls</span> + 99: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> +100: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> +101: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) +102: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) +103: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: Found bad logLine!" )</span> +104: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> +105: <span class="ruby-keyword kw">else</span> +106: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> 107: <span class="ruby-keyword kw">end</span> 108: 109: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">badLine</span> ) @@ -306,7 +314,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000065"></a><b>logToJournal</b>( message ) + <a name="M000067"></a><b>logToJournal</b>( message ) </div> <div class="description"> <p> @@ -321,19 +329,21 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000065_source')" id="l_M000065_source">show source</a> ]</p> - <div id="M000065_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000067_source')" id="l_M000067_source">show source</a> ]</p> + <div id="M000067_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 168</span> -168: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) -169: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) -170: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> -171: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> -172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -173: <span class="ruby-keyword kw">end</span> -174: -175: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -176: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 176</span> +176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) +177: <span class="ruby-keyword kw">if</span> ( +178: <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( +179: <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) +180: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> +181: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> +182: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +183: <span class="ruby-keyword kw">end</span> +184: +185: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +186: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -341,7 +351,7 @@ <div class="sectiontitle">Protected Instance methods</div> <div class="method"> <div class="title"> - <a name="M000060"></a><b>logPackageIntegrity</b>( package ) + <a name="M000062"></a><b>logPackageIntegrity</b>( package ) </div> <div class="description"> <p> @@ -358,8 +368,8 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000060_source')" id="l_M000060_source">show source</a> ]</p> - <div id="M000060_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p> + <div id="M000062_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File AbtLogManager.rb, line 42</span> 42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageIntegrity</span>( <span class="ruby-identifier">package</span> ) Modified: src/trunk/doc/classes/AbtPackage.html =================================================================== --- src/trunk/doc/classes/AbtPackage.html 2007-03-03 13:57:38 UTC (rev 317) +++ src/trunk/doc/classes/AbtPackage.html 2007-03-03 13:58:57 UTC (rev 318) @@ -90,7 +90,7 @@ inheriting from this class (class Fortune < <a href="AbtPackage.html">AbtPackage</a>) one picks up all supported standard functions for the abt <a href="AbtPackage.html">AbtPackage</a> manager to -make use of the <a href="AbtPackage.html#M000024">new</a> <a +make use of the <a href="AbtPackage.html#M000025">new</a> <a href="AbtPackage.html">AbtPackage</a>. </p> <p> @@ -109,7 +109,7 @@ AbTLinux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more <a -href="AbtPackage.html#M000025">details</a>. +href="AbtPackage.html#M000026">details</a>. </p> <p> You should have received a copy of the GNU General Public License along @@ -122,16 +122,16 @@ <div class="sectiontitle">Methods</div> <ul> - <li><a href="#M000028">build</a></li> - <li><a href="#M000027">configure</a></li> - <li><a href="#M000025">details</a></li> - <li><a href="#M000030">install</a></li> - <li><a href="#M000024">new</a></li> - <li><a href="#M000031">post</a></li> - <li><a href="#M000026">pre</a></li> - <li><a href="#M000029">preinstall</a></li> - <li><a href="#M000032">removeBuild</a></li> - <li><a href="#M000023">unpackSources</a></li> + <li><a href="#M000029">build</a></li> + <li><a href="#M000028">configure</a></li> + <li><a href="#M000026">details</a></li> + <li><a href="#M000031">install</a></li> + <li><a href="#M000025">new</a></li> + <li><a href="#M000032">post</a></li> + <li><a href="#M000027">pre</a></li> + <li><a href="#M000030">preinstall</a></li> + <li><a href="#M000033">removeBuild</a></li> + <li><a href="#M000024">unpackSources</a></li> </ul> @@ -305,40 +305,40 @@ <div class="sectiontitle">Public Class methods</div> <div class="method"> <div class="title"> - <a name="M000024"></a><b>new</b>( data ) + <a name="M000025"></a><b>new</b>( data ) </div> <div class="description"> <p> Constructor for an <a href="AbtPackage.html">AbtPackage</a>, requires all -the packge <a href="AbtPackage.html#M000025">details</a>. +the packge <a href="AbtPackage.html#M000026">details</a>. </p> <p> <b>PARAM</b> <em>Hash</em> - hash containing all package data. </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000024_source')" id="l_M000024_source">show source</a> ]</p> - <div id="M000024_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000025_source')" id="l_M000025_source">show source</a> ]</p> + <div id="M000025_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 150</span> -150: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">data</span> ) -151: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'name'</span>] -152: <span class="ruby-ivar">@execName</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'execName'</span>] -153: <span class="ruby-ivar">@version</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'version'</span>] -154: <span class="ruby-ivar">@srcDir</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'srcDir'</span>] -155: <span class="ruby-ivar">@homepage</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'homepage'</span>] -156: <span class="ruby-ivar">@srcUrl</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'srcUrl'</span>] -157: <span class="ruby-ivar">@dependsOn</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'dependsOn'</span>] -158: <span class="ruby-ivar">@reliesOn</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'reliesOn'</span>] -159: <span class="ruby-ivar">@optionalDO</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'optionalDO'</span>] -160: <span class="ruby-ivar">@optionalRO</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'optionalRO'</span>] -161: <span class="ruby-ivar">@hashCheck</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'hashCheck'</span>] -162: <span class="ruby-ivar">@patches</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'patches'</span>] -163: <span class="ruby-ivar">@patchesHashCheck</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'patchesHashCheck'</span>] -164: <span class="ruby-ivar">@mirrorPath</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'mirrorPath'</span>] -165: <span class="ruby-ivar">@license</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'license'</span>] -166: <span class="ruby-ivar">@description</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'description'</span>] -167: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 151</span> +151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">data</span> ) +152: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'name'</span>] +153: <span class="ruby-ivar">@execName</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'execName'</span>] +154: <span class="ruby-ivar">@version</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'version'</span>] +155: <span class="ruby-ivar">@srcDir</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'srcDir'</span>] +156: <span class="ruby-ivar">@homepage</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'homepage'</span>] +157: <span class="ruby-ivar">@srcUrl</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'srcUrl'</span>] +158: <span class="ruby-ivar">@dependsOn</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'dependsOn'</span>] +159: <span class="ruby-ivar">@reliesOn</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'reliesOn'</span>] +160: <span class="ruby-ivar">@optionalDO</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'optionalDO'</span>] +161: <span class="ruby-ivar">@optionalRO</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'optionalRO'</span>] +162: <span class="ruby-ivar">@hashCheck</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'hashCheck'</span>] +163: <span class="ruby-ivar">@patches</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'patches'</span>] +164: <span class="ruby-ivar">@patchesHashCheck</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'patchesHashCheck'</span>] +165: <span class="ruby-ivar">@mirrorPath</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'mirrorPath'</span>] +166: <span class="ruby-ivar">@license</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'license'</span>] +167: <span class="ruby-ivar">@description</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value str">'description'</span>] +168: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -346,7 +346,7 @@ <div class="sectiontitle">Public Instance methods</div> <div class="method"> <div class="title"> - <a name="M000028"></a><b>build</b>() + <a name="M000029"></a><b>build</b>() </div> <div class="description"> <p> @@ -359,35 +359,35 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000028_source')" id="l_M000028_source">show source</a> ]</p> - <div id="M000028_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000029_source')" id="l_M000029_source">show source</a> ]</p> + <div id="M000029_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 252</span> -252: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span> -253: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) -254: -255: <span class="ruby-comment cmt"># TODO: not some better way to deal with this than system and tee?</span> -256: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-node">"make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build"</span> ) ) -257: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section failed."</span> -258: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -259: <span class="ruby-keyword kw">end</span> -260: -261: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section completed!"</span> -262: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -263: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 261</span> +261: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span> +262: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) +263: +264: <span class="ruby-keyword kw">if</span>( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( +265: <span class="ruby-node">"make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build"</span> ) ) +266: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section failed."</span> +267: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +268: <span class="ruby-keyword kw">end</span> +269: +270: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.build] - build section completed!"</span> +271: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +272: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div class="method"> <div class="title"> - <a name="M000027"></a><b>configure</b>() + <a name="M000028"></a><b>configure</b>() </div> <div class="description"> <p> -Here we manage the ./<a href="AbtPackage.html#M000027">configure</a> step +Here we manage the ./<a href="AbtPackage.html#M000028">configure</a> step (or equivalent). We need to give ./<a -href="AbtPackage.html#M000027">configure</a> (or autogen.sh, or whatever) +href="AbtPackage.html#M000028">configure</a> (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 @@ -399,29 +399,29 @@ </p> </div> <div class="sourcecode"> - <p class="source-link">[ <a href="javascript:toggleSource('M000027_source')" id="l_M000027_source">show source</a> ]</p> - <div id="M000027_source" class="dyn-source"> + <p class="source-link">[ <a href="javascript:toggleSource('M000028_source')" id="l_M000028_source">show source</a> ]</p> + <div id="M000028_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackage.rb, line 234</span> -234: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span> -235: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"</span> ) -236: -237: <span class="ruby-comment cmt"># TODO: not some better way to deal with this than system and tee?</span> -238: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">system</span>( <span class="ruby-node">"./configure --prefix=#{$DEFAULT_PREFIX} | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure"</span> ) ) -239: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.configure] - configure section failed."</span> -240: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -241: <span class="ruby-keyword kw">end</span> -242: -243: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"DEBUG: [AbtPackage.configure] - configure section completed!"</span> -244: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -245: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackage.rb, line 241</span> +241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span> +242: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-node">"#{$BUILD_LOCATION}/#{@srcDir}"<... [truncated message content] |
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-03 13:38:51
|
Revision: 316 http://svn.sourceforge.net/abtlinux/?rev=316&view=rev Author: eschabell Date: 2007-03-03 05:38:48 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Updated the todo's for the task list. Formatted code including 80 column limit. Modified Paths: -------------- src/trunk/AbtPackage.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-03-01 20:13:59 UTC (rev 315) +++ src/trunk/AbtPackage.rb 2007-03-03 13:38:48 UTC (rev 316) @@ -3,10 +3,10 @@ ## # AbtPackage.rb # -# AbtPackage class provides an interface to AbtPackage creation within AbTLinux. By -# inheriting from this class (class Fortune < AbtPackage) one picks up all -# supported standard functions for the abt AbtPackage manager to make use of the -# new AbtPackage. +# AbtPackage class provides an interface to AbtPackage creation within +# AbTLinux. By inheriting from this class (class Fortune < AbtPackage) one +# picks up all supported standard functions for the abt AbtPackage manager +# to make use of the new AbtPackage. # # Created by Eric D. Schabell <er...@ab...> # Copyright 2006, GPL. @@ -34,7 +34,8 @@ ## # Unpacks this packages source file into the standard build location. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## def unpackSources srcFile = File.basename( @srcUrl ) @@ -169,7 +170,8 @@ ## # Provides all the data needed for this AbtPackage. # - # <b>RETURNS:</b> <i>hash</i> - Contains all AbtPackage attributes (constants). + # <b>RETURNS:</b> <i>hash</i> - Contains all AbtPackage + # attributes (constants). ## def details return { @@ -196,13 +198,16 @@ # 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. + # <b>RETURNS:</b> <i>boolean</i> - True if completes sucessfully, + # otherwise false. ## def pre downloader = AbtDownloadManager.new # download sources. - if ( !downloader.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) + if ( + !downloader.retrievePackageSource( + @name.downcase, $SOURCES_REPOSITORY ) ) return false end @@ -216,26 +221,28 @@ FileUtils.mkdir_p( "#{$PACKAGE_INSTALLED}/#{@srcDir}" ) end - # TODO: retrieve patches? - # TODO: apply patches? + # TODO: implement pre section retrieve patches? + # TODO: implement pre section 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 - # dependencies. + # 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. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## 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}/#{@srcDir}.configure" ) ) + if ( !system( "./configure --prefix=#{$DEFAULT_PREFIX} | tee " + + "#{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.configure" ) ) puts "DEBUG: [AbtPackage.configure] - configure section failed." return false end @@ -245,15 +252,17 @@ end ## - # Here is where the actual builing of the software starts, for example running 'make'. + # Here is where the actual builing of the software starts, + # for example running 'make'. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## 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}/#{@srcDir}.build" ) ) + if( !system( + "make | tee #{$PACKAGE_INSTALLED}/#{@srcDir}/#{@srcDir}.build" ) ) puts "DEBUG: [AbtPackage.build] - build section failed." return false end @@ -263,30 +272,34 @@ end ## - # Any actions needed before the installation can occur will happen here, such as creating - # new user accounts, dealing with existing configuration files, etc. + # Any actions needed before the installation can occur will happen here, + # such as creating new user accounts, dealing with existing configuration + # files, etc. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## def preinstall - # TODO: create_group? - # TODO: create_user? + # TODO: preinstall section create_group? + # TODO: preinstall section create_user? return true; end ## # All files to be installed are installed here. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## def install - # TODO: implement. 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=#{$ABT_TMP}/#{@srcDir}.watch make install" ) ) + # 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: rollback any installed files (use install log). + # TODO: install section, rollback any installed files (use install log). return false end @@ -295,19 +308,22 @@ end ## - # Last bits of installation. adding the service for automatic start in init.d for example. + # Last bits of installation. adding the service for automatic + # start in init.d for example. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## def post - # TODO: install init scripts service + # TODO: implement post section install init scripts service return true end ## # Cleans up this packages source build directory. # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. ## def removeBuild if ( $REMOVE_BUILD_SOURCES ) 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-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-02-28 22:10:23
|
Revision: 314 http://svn.sourceforge.net/abtlinux/?rev=314&view=rev Author: eschabell Date: 2007-02-28 14:05:11 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Regenerated api docs. Modified Paths: -------------- src/trunk/doc/classes/AbtLogManager.html src/trunk/doc/classes/AbtPackage.html src/trunk/doc/classes/AbtPackageManager.html src/trunk/doc/classes/AbtQueueManager.html src/trunk/doc/classes/TestAbtQueueManager.html src/trunk/doc/created.rid src/trunk/doc/files/AbtLogManager_rb.html src/trunk/doc/files/AbtPackageManager_rb.html src/trunk/doc/files/AbtPackage_rb.html src/trunk/doc/files/AbtQueueManager_rb.html src/trunk/doc/files/TestAbtQueueManager_rb.html src/trunk/doc/fr_method_index.html Modified: src/trunk/doc/classes/AbtLogManager.html =================================================================== --- src/trunk/doc/classes/AbtLogManager.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/classes/AbtLogManager.html 2007-02-28 22:05:11 UTC (rev 314) @@ -149,17 +149,17 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000061_source')" id="l_M000061_source">show source</a> ]</p> <div id="M000061_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 57</span> -57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> -58: [<span class="ruby-identifier">$ABT_LOGS</span>, <span class="ruby-identifier">$ABT_CACHES</span>, <span class="ruby-identifier">$ABT_STATE</span>, <span class="ruby-identifier">$BUILD_LOCATION</span>, <span class="ruby-identifier">$PACKAGE_INSTALLED</span>, -59: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> -60: -61: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) ) -62: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-identifier">dir</span> ) -63: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Created directory: #{dir}."</span> ) -64: <span class="ruby-keyword kw">end</span> -65: } -66: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 58</span> +58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> +59: [<span class="ruby-identifier">$ABT_LOGS</span>, <span class="ruby-identifier">$ABT_CACHES</span>, <span class="ruby-identifier">$ABT_STATE</span>, <span class="ruby-identifier">$BUILD_LOCATION</span>, <span class="ruby-identifier">$PACKAGE_INSTALLED</span>, +60: <span class="ruby-identifier">$PACKAGE_CACHED</span>, <span class="ruby-identifier">$ABT_TMP</span>, <span class="ruby-identifier">$SOURCES_REPOSITORY</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> +61: +62: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) ) +63: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>( <span class="ruby-identifier">dir</span> ) +64: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Created directory: #{dir}."</span> ) +65: <span class="ruby-keyword kw">end</span> +66: } +67: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -186,9 +186,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show source</a> ]</p> <div id="M000064_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 146</span> -146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) -147: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 157</span> +157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachePackage</span>( <span class="ruby-identifier">package</span> ) +158: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -214,9 +214,21 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p> <div id="M000063_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 134</span> -134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">package</span> ) -135: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 133</span> +133: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">package</span> ) +134: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> +135: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) +136: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> +137: <span class="ruby-identifier">buildFile</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.build"</span> +138: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: buildFile is - #{buildFile}" )</span> +139: +140: <span class="ruby-comment cmt"># make sure the build file exists.</span> +141: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">buildFile</span> ) ) +142: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +143: <span class="ruby-keyword kw">end</span> +144: +145: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +146: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -242,54 +254,52 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p> <div id="M000062_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 77</span> - 77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">package</span> ) - 78: <span class="ruby-comment cmt"># some dirs we will not add to an install log.</span> - 79: <span class="ruby-identifier">excluded_pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) - 80: - 81: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> - 82: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) - 83: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> - 84: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> - 85: - 86: <span class="ruby-comment cmt"># our log locations.</span> - 87: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.install"</span> - 88: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> - 89: - 90: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> - 91: <span class="ruby-comment cmt"># into our install log.</span> - 92: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) - 93: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) - 94: - 95: <span class="ruby-comment cmt"># include only the file names from open calls</span> - 96: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> - 97: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> - 98: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) - 99: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: checking: #{line.split[2]} against #{excluded_pattern}."</span> ) -100: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) -101: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"DEBUG: Found bad logLine!"</span> ) -102: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> -103: <span class="ruby-keyword kw">else</span> -104: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> -105: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: #{excluded_pattern} not matching #{line.split[2]}"</span>) -106: <span class="ruby-keyword kw">end</span> -107: -108: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">badLine</span> ) -109: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"DEBUG: adding line to installFile!"</span>) -110: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] -111: <span class="ruby-keyword kw">else</span> -112: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: found a badLine, not adding #{line.split[2]}"</span>) -113: <span class="ruby-keyword kw">end</span> -114: <span class="ruby-keyword kw">end</span> -115: <span class="ruby-keyword kw">end</span> -116: -117: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">close</span> -118: <span class="ruby-keyword kw">end</span> -119: -120: <span class="ruby-comment cmt"># cleanup the tmp files.</span> -121: <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">tmpInstallLog</span> ) -122: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; -123: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 78</span> + 78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">package</span> ) + 79: <span class="ruby-comment cmt"># some dirs we will not add to an install log.</span> + 80: <span class="ruby-identifier">excluded_pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+"</span> ) + 81: + 82: <span class="ruby-identifier">require</span> <span class="ruby-identifier">package</span> + 83: <span class="ruby-identifier">sw</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"#{package.capitalize}.new"</span> ) + 84: <span class="ruby-identifier">details</span> = <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">details</span> + 85: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># used to mark excluded lines from installwatch log.</span> + 86: + 87: <span class="ruby-comment cmt"># our log locations.</span> + 88: <span class="ruby-identifier">installLog</span> = <span class="ruby-node">"#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.install"</span> + 89: <span class="ruby-identifier">tmpInstallLog</span> = <span class="ruby-node">"#{$ABT_TMP}/#{details['Source location']}.watch"</span> + 90: + 91: <span class="ruby-comment cmt"># get the installed files from the tmp file</span> + 92: <span class="ruby-comment cmt"># into our install log.</span> + 93: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-identifier">tmpInstallLog</span> ) ) + 94: <span class="ruby-identifier">installFile</span> = <span class="ruby-identifier">open</span>( <span class="ruby-identifier">installLog</span>, <span class="ruby-value str">'w'</span>) + 95: + 96: <span class="ruby-comment cmt"># include only the file names from open calls</span> + 97: <span class="ruby-comment cmt"># and not part of the excluded range of directories.</span> + 98: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">tmpInstallLog</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> + 99: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'open'</span> ) +100: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." )</span> +101: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-identifier">excluded_pattern</span> ) +102: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: Found bad logLine!" )</span> +103: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">true</span> +104: <span class="ruby-keyword kw">else</span> +105: <span class="ruby-identifier">badLine</span> = <span class="ruby-keyword kw">false</span> +106: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}")</span> +107: <span class="ruby-keyword kw">end</span> +108: +109: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">badLine</span> ) +110: <span class="ruby-comment cmt">#self.logToJournal( "DEBUG: adding line to installFile!")</span> +111: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">2</span>] +112: <span class="ruby-keyword kw">end</span> +113: <span class="ruby-keyword kw">end</span> +114: <span class="ruby-keyword kw">end</span> +115: +116: <span class="ruby-identifier">installFile</span>.<span class="ruby-identifier">close</span> +117: <span class="ruby-keyword kw">end</span> +118: +119: <span class="ruby-comment cmt"># cleanup the tmp files.</span> +120: <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">tmpInstallLog</span> ) +121: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>; +122: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -314,16 +324,16 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000065_source')" id="l_M000065_source">show source</a> ]</p> <div id="M000065_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtLogManager.rb, line 157</span> -157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) -158: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) -159: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> -160: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> -161: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -162: <span class="ruby-keyword kw">end</span> -163: -164: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -165: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtLogManager.rb, line 168</span> +168: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logToJournal</span>( <span class="ruby-identifier">message</span> ) +169: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$JOURNAL</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) +170: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{$TIMESTAMP} : #{message}"</span> +171: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> +172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +173: <span class="ruby-keyword kw">end</span> +174: +175: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +176: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -353,7 +363,8 @@ <pre> <span class="ruby-comment cmt"># File AbtLogManager.rb, line 42</span> 42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logPackageIntegrity</span>( <span class="ruby-identifier">package</span> ) -43: <span class="ruby-keyword kw">end</span> +43: <span class="ruby-comment cmt"># TODO: implement logPackageIntegrity.</span> +44: <span class="ruby-keyword kw">end</span> </pre> </div> </div> Modified: src/trunk/doc/classes/AbtPackage.html =================================================================== --- src/trunk/doc/classes/AbtPackage.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/classes/AbtPackage.html 2007-02-28 22:05:11 UTC (rev 314) @@ -518,7 +518,7 @@ <pre> <span class="ruby-comment cmt"># File AbtPackage.rb, line 302</span> 302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span> -303: <span class="ruby-comment cmt"># TODO: implement me!</span> +303: <span class="ruby-comment cmt"># TODO: install init scripts service</span> 304: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> 305: <span class="ruby-keyword kw">end</span> </pre> Modified: src/trunk/doc/classes/AbtPackageManager.html =================================================================== --- src/trunk/doc/classes/AbtPackageManager.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/classes/AbtPackageManager.html 2007-02-28 22:05:11 UTC (rev 314) @@ -182,9 +182,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000044_source')" id="l_M000044_source">show source</a> ]</p> <div id="M000044_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 163</span> -163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">downgradePackage</span>( <span class="ruby-identifier">package</span>, <span class="ruby-identifier">version</span> ) -164: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 177</span> +177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">downgradePackage</span>( <span class="ruby-identifier">package</span>, <span class="ruby-identifier">version</span> ) +178: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -210,9 +210,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000045_source')" id="l_M000045_source">show source</a> ]</p> <div id="M000045_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 175</span> -175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">freezePackage</span>( <span class="ruby-identifier">package</span> ) -176: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 189</span> +189: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">freezePackage</span>( <span class="ruby-identifier">package</span> ) +190: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -251,7 +251,7 @@ 62: 63: <span class="ruby-comment cmt"># add to install queue.</span> 64: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Adding #{package} to the INSTALL QUEUE. ***"</span> - 65: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">queuer</span>.<span class="ruby-identifier">addPackageToQueue</span>( <span class="ruby-identifier">package</span>, <span class="ruby-value str">"install"</span> ) ) + 65: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">queuer</span>.<span class="ruby-identifier">actionPackageQueue</span>( <span class="ruby-identifier">package</span>, <span class="ruby-value str">"install"</span>, <span class="ruby-value str">"add"</span> ) ) 66: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to add #{package} to install queue."</span> ) 67: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> 68: <span class="ruby-keyword kw">end</span> @@ -280,42 +280,56 @@ 91: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process build section in the package description of #{package}."</span> ) 92: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> 93: <span class="ruby-keyword kw">else</span> - 94: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} build section."</span> ) - 95: <span class="ruby-keyword kw">end</span> - 96: - 97: <span class="ruby-comment cmt"># preinstall section.</span> - 98: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Processing the PREINSTALL section for #{package}. ***"</span> - 99: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">preinstall</span> ) -100: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process preinstall section in the package description of #{package}."</span> ) -101: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -102: <span class="ruby-keyword kw">else</span> -103: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} preinstall section."</span> ) -104: <span class="ruby-keyword kw">end</span> -105: -106: <span class="ruby-comment cmt"># install section.</span> -107: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Processing the INSTALL section for #{package}. ***"</span> -108: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">install</span> ) -109: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process install section in the package description of #{package}."</span> ) -110: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -111: <span class="ruby-keyword kw">else</span> -112: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-value str">"ipc"</span> ) -113: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} install section."</span> ) -114: <span class="ruby-keyword kw">end</span> -115: -116: -117: <span class="ruby-comment cmt"># TODO: finish up the following steps per install scenario:</span> -118: <span class="ruby-comment cmt">#</span> -119: <span class="ruby-comment cmt"># post section</span> -120: <span class="ruby-comment cmt"># remove build sources.</span> -121: <span class="ruby-comment cmt">#</span> -122: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Cleaning up the sources for #{package}. ***"</span> -123: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">removeBuild</span> ) -124: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to remove the build sources for #{package}."</span> ) -125: <span class="ruby-comment cmt">#return false # commented out as this is not a reason to fail.</span> -126: <span class="ruby-keyword kw">end</span> -127: -128: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -129: <span class="ruby-keyword kw">end</span> + 94: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logPackageBuild</span>( <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">downcase</span> ) ) + 95: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-value str">"Failed to create a package build log."</span> ) + 96: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> + 97: <span class="ruby-keyword kw">end</span> + 98: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} build section."</span> ) + 99: <span class="ruby-keyword kw">end</span> +100: +101: <span class="ruby-comment cmt"># preinstall section.</span> +102: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Processing the PREINSTALL section for #{package}. ***"</span> +103: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">preinstall</span> ) +104: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process preinstall section in the package description of #{package}."</span> ) +105: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +106: <span class="ruby-keyword kw">else</span> +107: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} preinstall section."</span> ) +108: <span class="ruby-keyword kw">end</span> +109: +110: <span class="ruby-comment cmt"># install section.</span> +111: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Processing the INSTALL section for #{package}. ***"</span> +112: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">install</span> ) +113: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process install section in the package description of #{package}."</span> ) +114: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +115: <span class="ruby-keyword kw">else</span> +116: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logPackageInstall</span>( <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">downcase</span> ) +117: <span class="ruby-comment cmt"># TODO: logger.logPackageIntegrity( sw.name.downcase )</span> +118: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} install section."</span> ) +119: <span class="ruby-keyword kw">end</span> +120: +121: <span class="ruby-comment cmt"># post section.</span> +122: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Processing the POST section for #{package}. ***"</span> +123: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">post</span> ) +124: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to process post section in the package description of #{package}."</span> ) +125: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +126: <span class="ruby-keyword kw">else</span> +127: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"DEBUG: finished #{package} post section."</span> ) +128: <span class="ruby-keyword kw">end</span> +129: +130: <span class="ruby-comment cmt"># clean out build sources. </span> +131: <span class="ruby-identifier">puts</span> <span class="ruby-node">"\n*** Cleaning up the sources for #{package}. ***"</span> +132: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">sw</span>.<span class="ruby-identifier">removeBuild</span> ) +133: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to remove the build sources for #{package}."</span> ) +134: <span class="ruby-comment cmt">#return false # commented out as this is not a reason to fail.</span> +135: <span class="ruby-keyword kw">end</span> +136: +137: <span class="ruby-comment cmt"># remove pacakge from install queue.</span> +138: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span><span class="ruby-identifier">queuer</span>.<span class="ruby-identifier">actionPackageQueue</span>( <span class="ruby-identifier">sw</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">downcase</span>, <span class="ruby-value str">"install"</span>, <span class="ruby-value str">"remove"</span> ) ) +139: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to remove #{sw.name.donwcase} from install queue."</span> ) +140: <span class="ruby-keyword kw">end</span> +141: +142: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt"># install completed!</span> +143: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -340,9 +354,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000042_source')" id="l_M000042_source">show source</a> ]</p> <div id="M000042_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 139</span> -139: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reinstallPackage</span>( <span class="ruby-identifier">package</span> ) -140: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 153</span> +153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reinstallPackage</span>( <span class="ruby-identifier">package</span> ) +154: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -367,9 +381,9 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000043_source')" id="l_M000043_source">show source</a> ]</p> <div id="M000043_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 150</span> -150: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">removePackage</span>( <span class="ruby-identifier">package</span> ) -151: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 164</span> +164: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">removePackage</span>( <span class="ruby-identifier">package</span> ) +165: <span class="ruby-keyword kw">end</span> </pre> </div> </div> @@ -393,20 +407,20 @@ <p class="source-link">[ <a href="javascript:toggleSource('M000046_source')" id="l_M000046_source">show source</a> ]</p> <div id="M000046_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 185</span> -185: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rootLogin</span>( <span class="ruby-identifier">arguments</span> ) -186: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">Process</span>.<span class="ruby-identifier">uid</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> ) -187: <span class="ruby-identifier">args</span> = <span class="ruby-value str">""</span> -188: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"\nEnter root password:"</span> -189: -190: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">length</span> -191: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-value str">" "</span> <span class="ruby-operator">+</span> <span class="ruby-constant">ARGV</span>[<span class="ruby-identifier">i</span>] -192: <span class="ruby-keyword kw">end</span> -193: -194: <span class="ruby-identifier">system</span>( <span class="ruby-value str">'su -c "./abt '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'" root'</span> ) -195: <span class="ruby-identifier">exit</span> -196: <span class="ruby-keyword kw">end</span> -197: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtPackageManager.rb, line 199</span> +199: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rootLogin</span>( <span class="ruby-identifier">arguments</span> ) +200: <span class="ruby-keyword kw">if</span> ( <span class="ruby-constant">Process</span>.<span class="ruby-identifier">uid</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> ) +201: <span class="ruby-identifier">args</span> = <span class="ruby-value str">""</span> +202: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"\nEnter root password:"</span> +203: +204: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">length</span> +205: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-value str">" "</span> <span class="ruby-operator">+</span> <span class="ruby-constant">ARGV</span>[<span class="ruby-identifier">i</span>] +206: <span class="ruby-keyword kw">end</span> +207: +208: <span class="ruby-identifier">system</span>( <span class="ruby-value str">'su -c "./abt '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'" root'</span> ) +209: <span class="ruby-identifier">exit</span> +210: <span class="ruby-keyword kw">end</span> +211: <span class="ruby-keyword kw">end</span> </pre> </div> </div> Modified: src/trunk/doc/classes/AbtQueueManager.html =================================================================== --- src/trunk/doc/classes/AbtQueueManager.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/classes/AbtQueueManager.html 2007-02-28 22:05:11 UTC (rev 314) @@ -117,7 +117,7 @@ <div class="sectiontitle">Methods</div> <ul> - <li><a href="#M000085">addPackageToQueue</a></li> + <li><a href="#M000085">actionPackageQueue</a></li> <li><a href="#M000084">new</a></li> </ul> @@ -155,56 +155,81 @@ <div class="sectiontitle">Public Instance methods</div> <div class="method"> <div class="title"> - <a name="M000085"></a><b>addPackageToQueue</b>( package, queue ) + <a name="M000085"></a><b>actionPackageQueue</b>( package, queue, action="add" ) </div> <div class="description"> <p> -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. </p> <p> -<b>PARAM</b> <em>String</em> - the package to be added to the queue. -<b>PARAM</b> <em>String</em> - the queue to add the package to. +<b>PARAM</b> <em>String</em> - the package to be added/removed. +<b>PARAM</b> <em>String</em> - the queue. </p> <p> -<b>RETURN</b> <em>boolean</em> - true if package added/exists to/in install -queue, otherwise false. +<b>RETURN</b> <em>boolean</em> - true if action succeeds, otherwise false. </p> </div> <div class="sourcecode"> <p class="source-link">[ <a href="javascript:toggleSource('M000085_source')" id="l_M000085_source">show source</a> ]</p> <div id="M000085_source" class="dyn-source"> <pre> - <span class="ruby-comment cmt"># File AbtQueueManager.rb, line 54</span> -54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">addPackageToQueue</span>( <span class="ruby-identifier">package</span>, <span class="ruby-identifier">queue</span> ) -55: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">AbtLogManager</span>.<span class="ruby-identifier">new</span> -56: -57: <span class="ruby-comment cmt"># want to name install queue differently from log files.</span> -58: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">queue</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'install'</span> ) -59: <span class="ruby-identifier">queueFile</span> = <span class="ruby-node">"#{$ABT_LOGS}/#{queue}.queue"</span> -60: <span class="ruby-keyword kw">else</span> -61: <span class="ruby-identifier">queueFile</span> = <span class="ruby-node">"#{$ABT_LOGS}/#{queue}.log"</span> -62: <span class="ruby-keyword kw">end</span> -63: -64: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">queueFile</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) -65: <span class="ruby-comment cmt"># pickup queue contents to ensure no duplicates.</span> -66: <span class="ruby-identifier">checkingQueue</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">readlines</span>( <span class="ruby-identifier">queueFile</span> ) -67: -68: <span class="ruby-comment cmt"># check if package exists, otherwise add.</span> -69: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">checkingQueue</span>.<span class="ruby-identifier">collect</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">split</span>( <span class="ruby-value str">'|'</span> )[<span class="ruby-value">0</span>] }.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">package</span> ) ) -70: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{package}|#{$TIMESTAMP}"</span> -71: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Added #{package} to #{queue} queue."</span> ) -72: <span class="ruby-keyword kw">else</span> -73: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Did not add #{package} to #{queue}, already exists."</span> ) -74: <span class="ruby-keyword kw">end</span> -75: -76: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> -77: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> -78: <span class="ruby-keyword kw">end</span> -79: -80: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to open #{queueFile}."</span> ) -81: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> -82: <span class="ruby-keyword kw">end</span> + <span class="ruby-comment cmt"># File AbtQueueManager.rb, line 53</span> + 53: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">actionPackageQueue</span>( <span class="ruby-identifier">package</span>, <span class="ruby-identifier">queue</span>, <span class="ruby-identifier">action</span>=<span class="ruby-value str">"add"</span> ) + 54: <span class="ruby-identifier">require</span> <span class="ruby-value str">'fileutils'</span> + 55: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">AbtLogManager</span>.<span class="ruby-identifier">new</span> + 56: <span class="ruby-identifier">queueFile</span> = <span class="ruby-value str">""</span> <span class="ruby-comment cmt"># used to hold the queue location.</span> + 57: + 58: <span class="ruby-comment cmt"># want to name install queue differently from log files.</span> + 59: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">queue</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'install'</span> ) + 60: <span class="ruby-identifier">queueFile</span> = <span class="ruby-node">"#{$ABT_LOGS}/#{queue}.queue"</span> + 61: <span class="ruby-keyword kw">else</span> + 62: <span class="ruby-identifier">queueFile</span> = <span class="ruby-node">"#{$ABT_LOGS}/#{queue}.log"</span> + 63: <span class="ruby-keyword kw">end</span> + 64: + 65: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">action</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"add"</span>) + 66: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">queueFile</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) + 67: <span class="ruby-comment cmt"># pickup queue contents to ensure no duplicates.</span> + 68: <span class="ruby-identifier">checkingQueue</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">readlines</span>( <span class="ruby-identifier">queueFile</span> ) + 69: + 70: <span class="ruby-comment cmt"># check if package exists, otherwise add.</span> + 71: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">checkingQueue</span>.<span class="ruby-identifier">collect</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">split</span>( <span class="ruby-value str">'|'</span> )[<span class="ruby-value">0</span>] }.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">package</span> ) ) + 72: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{package}|#{$TIMESTAMP}"</span> + 73: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Added #{package} to #{queue} queue."</span> ) + 74: <span class="ruby-keyword kw">else</span> + 75: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Did not add #{package} to #{queue}, already exists."</span> ) + 76: <span class="ruby-keyword kw">end</span> + 77: + 78: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> + 79: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> + 80: <span class="ruby-keyword kw">end</span> + 81: <span class="ruby-keyword kw">end</span> + 82: + 83: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">action</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"remove"</span> ) + 84: <span class="ruby-comment cmt"># remove entry from given queue.</span> + 85: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">queueFile</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">APPEND</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span>, <span class="ruby-value">0644</span> ) ) + 86: <span class="ruby-comment cmt"># use temp file to filter out entry to be removed.</span> + 87: <span class="ruby-identifier">temp</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queueFile</span> <span class="ruby-operator">+</span> <span class="ruby-value str">".tmp"</span>, <span class="ruby-value str">"a+"</span>) + 88: + 89: <span class="ruby-comment cmt"># now check for line to be removed.</span> + 90: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>( <span class="ruby-identifier">queueFile</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> + 91: <span class="ruby-identifier">entryName</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>( <span class="ruby-value str">'|'</span> )[<span class="ruby-value">0</span>] + 92: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">entryName</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">package</span>.<span class="ruby-identifier">downcase</span> ) + 93: <span class="ruby-identifier">temp</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span> + 94: <span class="ruby-keyword kw">end</span> + 95: <span class="ruby-keyword kw">end</span> + 96: + 97: <span class="ruby-identifier">temp</span>.<span class="ruby-identifier">close</span> + 98: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>( <span class="ruby-identifier">temp</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">queueFile</span> ) + 99: <span class="ruby-keyword kw">end</span> +100: +101: <span class="ruby-identifier">log</span>.<span class="ruby-identifier">close</span> +102: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> +103: <span class="ruby-keyword kw">end</span> +104: +105: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">logToJournal</span>( <span class="ruby-node">"Failed to open #{queueFile}."</span> ) +106: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> +107: <span class="ruby-keyword kw">end</span> </pre> </div> </div> Modified: src/trunk/doc/classes/TestAbtQueueManager.html =================================================================== --- src/trunk/doc/classes/TestAbtQueueManager.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/classes/TestAbtQueueManager.html 2007-02-28 22:05:11 UTC (rev 314) @@ -118,7 +118,7 @@ <div class="sectiontitle">Methods</div> <ul> <li><a href="#M000076">setup</a></li> - <li><a href="#M000077">testAddPackageToQueue</a></li> + <li><a href="#M000077">testActionPackageQueue</a></li> </ul> @@ -151,12 +151,12 @@ </div> <div class="method"> <div class="title"> - <a name="M000077"></a><b>testAddPackageToQueue</b>() + <a name="M000077"></a><b>testActionPackageQueue</b>() </div> <div class="description"> <p> Test method for ‘<a -href="AbtQueueManager.html#M000085">AbtQueueManager.addPackageToQueue</a>()’ +href="AbtQueueManager.html#M000085">AbtQueueManager.actionPackageQueue</a>()’ </p> </div> <div class="sourcecode"> @@ -164,8 +164,8 @@ <div id="M000077_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File TestAbtQueueManager.rb, line 45</span> -45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testAddPackageToQueue</span> -46: <span class="ruby-identifier">assert</span>( <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">addPackageToQueue</span>( <span class="ruby-value str">"ipc"</span>, <span class="ruby-value str">"install"</span> ), <span class="ruby-value str">"testQueueManager()"</span> ) +45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testActionPackageQueue</span> +46: <span class="ruby-identifier">assert</span>( <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">actionPackageQueue</span>( <span class="ruby-value str">"ipc"</span>, <span class="ruby-value str">"install"</span>, <span class="ruby-value str">"add"</span> ), <span class="ruby-value str">"testQueueManager()"</span> ) 47: <span class="ruby-keyword kw">end</span> </pre> </div> Modified: src/trunk/doc/created.rid =================================================================== --- src/trunk/doc/created.rid 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/created.rid 2007-02-28 22:05:11 UTC (rev 314) @@ -1 +1 @@ -Mon Feb 26 22:15:33 +0100 2007 +Wed Feb 28 23:02:20 +0100 2007 Modified: src/trunk/doc/files/AbtLogManager_rb.html =================================================================== --- src/trunk/doc/files/AbtLogManager_rb.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/files/AbtLogManager_rb.html 2007-02-28 22:05:11 UTC (rev 314) @@ -63,7 +63,7 @@ </tr> <tr> <td>Modified:</td> - <td>Mon Feb 26 22:15:30 +0100 2007</td> + <td>Wed Feb 28 23:02:04 +0100 2007</td> </tr> </table> </td></tr> Modified: src/trunk/doc/files/AbtPackageManager_rb.html =================================================================== --- src/trunk/doc/files/AbtPackageManager_rb.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/files/AbtPackageManager_rb.html 2007-02-28 22:05:11 UTC (rev 314) @@ -63,7 +63,7 @@ </tr> <tr> <td>Modified:</td> - <td>Mon Feb 26 22:06:38 +0100 2007</td> + <td>Wed Feb 28 23:02:04 +0100 2007</td> </tr> </table> </td></tr> Modified: src/trunk/doc/files/AbtPackage_rb.html =================================================================== --- src/trunk/doc/files/AbtPackage_rb.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/files/AbtPackage_rb.html 2007-02-28 22:05:11 UTC (rev 314) @@ -63,7 +63,7 @@ </tr> <tr> <td>Modified:</td> - <td>Mon Feb 26 22:06:38 +0100 2007</td> + <td>Wed Feb 28 23:02:04 +0100 2007</td> </tr> </table> </td></tr> Modified: src/trunk/doc/files/AbtQueueManager_rb.html =================================================================== --- src/trunk/doc/files/AbtQueueManager_rb.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/files/AbtQueueManager_rb.html 2007-02-28 22:05:11 UTC (rev 314) @@ -63,7 +63,7 @@ </tr> <tr> <td>Modified:</td> - <td>Sun Feb 25 14:26:25 +0100 2007</td> + <td>Wed Feb 28 23:02:04 +0100 2007</td> </tr> </table> </td></tr> @@ -113,6 +113,10 @@ </p> </div> + <div class="sectiontitle">Required Files</div> + <ul> + <li>fileutils</li> + </ul> Modified: src/trunk/doc/files/TestAbtQueueManager_rb.html =================================================================== --- src/trunk/doc/files/TestAbtQueueManager_rb.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/files/TestAbtQueueManager_rb.html 2007-02-28 22:05:11 UTC (rev 314) @@ -63,7 +63,7 @@ </tr> <tr> <td>Modified:</td> - <td>Sun Feb 25 23:01:24 +0100 2007</td> + <td>Wed Feb 28 23:02:04 +0100 2007</td> </tr> </table> </td></tr> Modified: src/trunk/doc/fr_method_index.html =================================================================== --- src/trunk/doc/fr_method_index.html 2007-02-28 22:03:33 UTC (rev 313) +++ src/trunk/doc/fr_method_index.html 2007-02-28 22:05:11 UTC (rev 314) @@ -41,7 +41,7 @@ <body> <div class="banner">Methods</div> <div class="entries"> -<a href="classes/AbtQueueManager.html#M000085">addPackageToQueue (AbtQueueManager)</a><br> +<a href="classes/AbtQueueManager.html#M000085">ac... [truncated message content] |
From: <esc...@us...> - 2007-02-28 22:10:23
|
Revision: 312 http://svn.sourceforge.net/abtlinux/?rev=312&view=rev Author: eschabell Date: 2007-02-28 13:59:29 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Small clarification for the TODO, better readability in the task listing. Modified Paths: -------------- src/trunk/AbtPackage.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-02-28 21:17:25 UTC (rev 311) +++ src/trunk/AbtPackage.rb 2007-02-28 21:59:29 UTC (rev 312) @@ -300,7 +300,7 @@ # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, otherwise false. ## def post - # TODO: implement me! + # TODO: install init scripts service return true end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |