Thread: [Abtlinux-svn] SF.net SVN: abtlinux: [181] src/trunk/AbtLogManager.rb
Status: Alpha
Brought to you by:
eschabell
From: <esc...@us...> - 2006-11-15 14:17:57
|
Revision: 181 http://svn.sourceforge.net/abtlinux/?rev=181&view=rev Author: eschabell Date: 2006-11-15 06:17:51 -0800 (Wed, 15 Nov 2006) Log Message: ----------- Previous commit included log to journal functionality, working and placed in various implemented sections of abt. This fix completes the log to journal test successfully. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-11-15 14:13:36 UTC (rev 180) +++ src/trunk/AbtLogManager.rb 2006-11-15 14:17:51 UTC (rev 181) @@ -101,7 +101,7 @@ # # <b>PARAM</b> <i>String</i> - Message to be added to the log. # - # <b>RETURN</b> <i>void</i> + # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. ## def logToJournal( message ) require 'date' @@ -112,5 +112,6 @@ log = File.new($JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644) log.puts DateTime::now.to_s + ' : ' + message + return true end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-11-18 10:30:38
|
Revision: 196 http://svn.sourceforge.net/abtlinux/?rev=196&view=rev Author: eschabell Date: 2006-11-18 02:30:38 -0800 (Sat, 18 Nov 2006) Log Message: ----------- Modified logging timestamp method to use Time class instead of DateTime, testing literature shows significant speed degredation with DateTime class. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-11-17 15:18:33 UTC (rev 195) +++ src/trunk/AbtLogManager.rb 2006-11-18 10:30:38 UTC (rev 196) @@ -108,7 +108,7 @@ end log = File.new($JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644) - log.puts DateTime::now.to_s + ' : ' + message + log.puts Time.now.strftime( "%Y-%m-%d %H:%M:%S (%Z)" ) + " : #{message}" return true end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-11-18 15:21:40
|
Revision: 202 http://svn.sourceforge.net/abtlinux/?rev=202&view=rev Author: eschabell Date: 2006-11-18 07:21:40 -0800 (Sat, 18 Nov 2006) Log Message: ----------- Moved log directory check off into the constructor so we check each time we want to create this class. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-11-18 15:20:22 UTC (rev 201) +++ src/trunk/AbtLogManager.rb 2006-11-18 15:21:40 UTC (rev 202) @@ -53,7 +53,9 @@ # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize - + if ( !File.directory?( $ABT_LOGS ) ) + FileUtils.mkdir_p( $ABT_LOGS ) # initialize logs. + end end ## @@ -101,14 +103,12 @@ # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. ## def logToJournal( message ) - require 'date' + if ( log = File.new( $JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + log.puts "#{$TIMESTAMP} : #{message}" + log.close + return true + end - if ( !File.directory?( $JOURNAL_PATH ) ) - FileUtils.mkdir_p( $JOURNAL_PATH ) # initialize logs. - end - - log = File.new($JOURNAL, File::WRONLY|File::APPEND|File::CREAT, 0644) - log.puts Time.now.strftime( "%Y-%m-%d %H:%M:%S (%Z)" ) + " : #{message}" - return true + return false end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-12-03 12:51:23
|
Revision: 252 http://svn.sourceforge.net/abtlinux/?rev=252&view=rev Author: eschabell Date: 2006-12-03 04:51:24 -0800 (Sun, 03 Dec 2006) Log Message: ----------- Expanded the constructor to ensure all required directories exist. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-12-03 12:50:21 UTC (rev 251) +++ src/trunk/AbtLogManager.rb 2006-12-03 12:51:24 UTC (rev 252) @@ -48,14 +48,35 @@ public ## - # Constructor for the AbtLogManager. + # Constructor for the AbtLogManager. It ensures all needed logs paths are + # initialized. + # # # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize if ( !File.directory?( $ABT_LOGS ) ) - FileUtils.mkdir_p( $ABT_LOGS ) # initialize logs. + FileUtils.mkdir_p( $ABT_LOGS ) + self.logToJournal( "Created directory: #{$ABT_LOGS}." ) end + + if ( !File.directory?( $ABT_CACHES ) ) + FileUtils.mkdir_p( $ABT_CACHES ) + self.logToJournal( "Created directory: #{$ABT_CACHES}." ) + end + + if ( !File.directory?( $BUILD_LOCATION ) ) + FileUtils.mkdir_p( $BUILD_LOCATION ) + self.logToJournal( "Created directory: #{$BUILD_LOCATION}." ) + end + if ( !File.directory?( $PACKAGE_INSTALLED ) ) + FileUtils.mkdir_p( $PACKAGE_INSTALLED ) + self.logToJournal( "Created directory: #{$PACKAGE_INSTALLED}." ) + end + if ( !File.directory?( $SOURCES_REPOSITORY ) ) + FileUtils.mkdir_p( $SOURCES_REPOSITORY ) + self.logToJournal( "Created directory: #{$SOURCES_REPOSITORY}." ) + end end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2006-12-06 15:20:13
|
Revision: 256 http://svn.sourceforge.net/abtlinux/?rev=256&view=rev Author: eschabell Date: 2006-12-06 07:20:13 -0800 (Wed, 06 Dec 2006) Log Message: ----------- Patched to shorten initialize to single loop from Bas van Gils. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2006-12-03 13:03:21 UTC (rev 255) +++ src/trunk/AbtLogManager.rb 2006-12-06 15:20:13 UTC (rev 256) @@ -55,30 +55,16 @@ # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize - if ( !File.directory?( $ABT_LOGS ) ) - FileUtils.mkdir_p( $ABT_LOGS ) - self.logToJournal( "Created directory: #{$ABT_LOGS}." ) - end - - if ( !File.directory?( $ABT_CACHES ) ) - FileUtils.mkdir_p( $ABT_CACHES ) - self.logToJournal( "Created directory: #{$ABT_CACHES}." ) - end - - if ( !File.directory?( $BUILD_LOCATION ) ) - FileUtils.mkdir_p( $BUILD_LOCATION ) - self.logToJournal( "Created directory: #{$BUILD_LOCATION}." ) - end - if ( !File.directory?( $PACKAGE_INSTALLED ) ) - FileUtils.mkdir_p( $PACKAGE_INSTALLED ) - self.logToJournal( "Created directory: #{$PACKAGE_INSTALLED}." ) - end - if ( !File.directory?( $SOURCES_REPOSITORY ) ) - FileUtils.mkdir_p( $SOURCES_REPOSITORY ) - self.logToJournal( "Created directory: #{$SOURCES_REPOSITORY}." ) - end - end - + [$ABT_LOGS, $ABT_CACHES, $BUILD_LOCATION, $PACKAGE_INSTALLED, + $SOURCES_REPOSITORY].each { |dir| + + if ( ! File.directory?( dir ) ) + FileUtils.mkdir_p( dir ) + self.logToJournal( "Created directory: #{dir}." ) + end + } + end + ## # Provides logging of all files installed by given package. Should be called # as part of the install phase of the build. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-26 20:58:09
|
Revision: 304 http://svn.sourceforge.net/abtlinux/?rev=304&view=rev Author: eschabell Date: 2007-02-26 12:58:07 -0800 (Mon, 26 Feb 2007) Log Message: ----------- Added a few new directory checks to the constructor. Now able to log a package installation, creates an install log. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-02-26 20:56:16 UTC (rev 303) +++ src/trunk/AbtLogManager.rb 2007-02-26 20:58:07 UTC (rev 304) @@ -55,8 +55,8 @@ # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize - [$ABT_LOGS, $ABT_CACHES, $BUILD_LOCATION, $PACKAGE_INSTALLED, - $SOURCES_REPOSITORY].each { |dir| + [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, + $PACKAGE_CACHED, $ABT_TMP, $SOURCES_REPOSITORY].each { |dir| if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) @@ -75,7 +75,8 @@ # otherwise false. ## def logPackageInstall( package ) - excludedDirs = "/dev /proc /tmp /var/tmp /usr/src /sys" + # some dirs we will not add to an install log. + excluded_pattern = Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) require package sw = eval( "#{package.capitalize}.new" ) @@ -83,8 +84,8 @@ badLine = false # used to mark excluded lines from installwatch log. # our log locations. - installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}.install" - tmpInstallLog = "/tmp/#{details['Source location']}.watch" + 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 # into our install log. @@ -97,12 +98,13 @@ # GIVEN LINE, MATCH MEANS WE DO NOT LOG IT! IO.foreach( tmpInstallLog ) do |line| if ( line.split[1] == 'open' ) - self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excludedDirs}." ) - if ( line.split[2].match( excludedDirs ) ) + self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." ) + if ( line.split[2] =~ excluded_pattern ) self.logToJournal( "DEBUG: Found bad logLine!" ) badLine = true else - self.logToJournal( "DEBUG: #{excludedDirs} not matching #{line.split[2]}") + badLine = false + self.logToJournal( "DEBUG: #{excluded_pattern} not matching #{line.split[2]}") end if ( !badLine ) @@ -117,6 +119,8 @@ installFile.close end + # cleanup the tmp files. + File.delete( tmpInstallLog ) return true; end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-02-26 21:17:31
|
Revision: 308 http://svn.sourceforge.net/abtlinux/?rev=308&view=rev Author: eschabell Date: 2007-02-26 13:17:32 -0800 (Mon, 26 Feb 2007) Log Message: ----------- Cleaned out the TODO as this has been done! Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-02-26 21:09:47 UTC (rev 307) +++ src/trunk/AbtLogManager.rb 2007-02-26 21:17:32 UTC (rev 308) @@ -94,8 +94,6 @@ # include only the file names from open calls # and not part of the excluded range of directories. - #TODO: FIX THIS, NEEDS TO MATCH EACH LINE.SPLIT[2] TO THE - # GIVEN LINE, MATCH MEANS WE DO NOT LOG IT! IO.foreach( tmpInstallLog ) do |line| if ( line.split[1] == 'open' ) self.logToJournal( "DEBUG: checking: #{line.split[2]} against #{excluded_pattern}." ) 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-06-15 12:19:53
|
Revision: 340 http://svn.sourceforge.net/abtlinux/?rev=340&view=rev Author: eschabell Date: 2007-06-15 05:19:55 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Refactored log manager adding get method for log file locations, this intgrated into all existing methods. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 12:05:31 UTC (rev 339) +++ src/trunk/AbtLogManager.rb 2007-06-15 12:19:55 UTC (rev 340) @@ -31,6 +31,44 @@ private + ## + # Returns the path to given packages install log. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>String</i> - Full path to install log. + ## + def getLog( package, type ) + require "packages/#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + case type + + when 'install' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" + + when 'integrity' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.integrity" + + when 'tmpinstall' + log = "#{$ABT_TMP}/#{details['Source location']}.watch" + + when 'build' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.build" + + else + log = "" + + end + + return log + end + + public ## @@ -62,15 +100,13 @@ # otherwise false. ## def logPackageIntegrity( package ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + #require "packages/#{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" + installLog = getLog( package, 'install' ) + integrityLog = getLog( package, 'integrity' ) # get the installed files from the tmp file # into our install log. @@ -106,17 +142,12 @@ 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)+" ) - - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) badLine = false # used to mark excluded lines from installwatch log. # our log locations. - installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.install" - tmpInstallLog = "#{$ABT_TMP}/#{details['Source location']}.watch" + installLog = getLog( package, 'install' ) + tmpInstallLog = getLog( package, 'tmpinstall' ) # get the installed files from the tmp file # into our install log. @@ -157,12 +188,7 @@ # otherwise false. ## def logPackageBuild( package ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details - buildLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.build" - #self.logToJournal( "DEBUG: buildFile is - #{buildFile}" ) + buildLog = getLog( package, 'build' ) # make sure the build file exists. if ( !File.exist?( buildLog ) ) @@ -182,13 +208,32 @@ # 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) + system = AbtSystemManager.new + + if ( system.packageInstalled( package ) ) + require "packages/#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + # TODO: collect package source. + FileTest::exists?("#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" ) + # TODO: collect package install log. + + # TODO: collect package build log. + + # 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) + + return false # for now, once imlemented, need true + end + + return false # package not installed, can't cache it. end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:39:28
|
Revision: 343 http://svn.sourceforge.net/abtlinux/?rev=343&view=rev Author: eschabell Date: 2007-07-05 06:39:30 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Refactored log manager to use <<. Testing of this shows that it is not possible to do this outside the class itself, such as elsewhere in the code to replace logger.logToJournal( "text" ) with logger << logToJournal << "text". Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-07-05 13:06:54 UTC (rev 342) +++ src/trunk/AbtLogManager.rb 2007-07-05 13:39:30 UTC (rev 343) @@ -84,7 +84,7 @@ if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) - self.logToJournal( "Created directory: #{dir}." ) + self << logToJournal << "Created directory: #{dir}." end } end @@ -118,7 +118,7 @@ IO.foreach( installLog ) do |line| status = File.stat( line.chomp ) octal = sprintf( "%o", status.mode ) - integrityFile.puts "#{line.chomp}:#{octal}" + integrityFile << "#{line.chomp}:#{octal}\n" end installFile.close @@ -167,7 +167,7 @@ if ( !badLine ) #self.logToJournal( "DEBUG: adding line to installFile!") - installFile.puts line.split[2] + installFile << "#{line.split[2]}\n" end end end @@ -295,7 +295,7 @@ ## def logToJournal( message ) if ( log = File.new( $JOURNAL, "a+" ) ) - log.puts "#{$TIMESTAMP} : #{message}" + log << "#{$TIMESTAMP} : #{message}\n" log.close return true end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 11:42:16
|
Revision: 347 http://svn.sourceforge.net/abtlinux/?rev=347&view=rev Author: eschabell Date: 2007-07-16 04:42:14 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Removed reference to self, unneeded. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-07-15 20:09:20 UTC (rev 346) +++ src/trunk/AbtLogManager.rb 2007-07-16 11:42:14 UTC (rev 347) @@ -84,7 +84,7 @@ if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) - self << logToJournal << "Created directory: #{dir}." + logToJournal << "Created directory: #{dir}." end } end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |