Thread: [Abtlinux-svn] SF.net SVN: abtlinux: [400] src/trunk (Page 6)
Status: Alpha
Brought to you by:
eschabell
From: <esc...@us...> - 2007-07-23 11:55:29
|
Revision: 400 http://svn.sourceforge.net/abtlinux/?rev=400&view=rev Author: eschabell Date: 2007-07-23 04:55:15 -0700 (Mon, 23 Jul 2007) Log Message: ----------- Removed purge logs functionality, this is not needed in our implementation. If a package is installed then it will have logs and removal removes the logs also. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtusage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-07-23 10:12:31 UTC (rev 399) +++ src/trunk/abt.rb 2007-07-23 11:55:15 UTC (rev 400) @@ -420,11 +420,6 @@ puts "Remove source caches for packages no longer installed." show.usage( "fix" ) -when "purge-logs" - # FIXME : purge-logs implementation. - puts "Remove log files for packages no longer installed." - show.usage( "fix" ) - when "verify-files" if ( ARGV.length == 2 ) options['package'] = ARGV[1] Modified: src/trunk/abtusage.rb =================================================================== --- src/trunk/abtusage.rb 2007-07-23 10:12:31 UTC (rev 399) +++ src/trunk/abtusage.rb 2007-07-23 11:55:15 UTC (rev 400) @@ -137,7 +137,6 @@ def usage_fix puts "\nfix:" puts " purge-src\t\t\t\tRemove source caches for packages no longer installed." - puts " purge-logs\t\t\t\tRemove log files for packages no longer installed." puts " verify-files [package]\t\tInstalled files are verified for given package." puts " verify-symlinks [package]\t\tSymlinks verified for given package." puts " verify-deps [package]\t\tDependency tree is verified for given package." This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-23 13:13:24
|
Revision: 403 http://svn.sourceforge.net/abtlinux/?rev=403&view=rev Author: eschabell Date: 2007-07-23 06:13:14 -0700 (Mon, 23 Jul 2007) Log Message: ----------- Implemented purge sources option in abt package manager. Implemented clean package sources method in the system manager. 18 unit tests to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtreportmanager.rb src/trunk/abtsystemmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-07-23 13:11:27 UTC (rev 402) +++ src/trunk/abt.rb 2007-07-23 13:13:14 UTC (rev 403) @@ -416,9 +416,20 @@ end when "purge-src" - # FIXME : purge-src implementation. - puts "Remove source caches for packages no longer installed." - show.usage( "fix" ) + if ( ARGV.length == 1 ) + # FIXME : purge-src implementation. + logger.to_journal( "Starting to purge sources from packages that are not installed.") + if ( system.cleanup_package_sources ) + puts "\nPurged sources from packages that are not installed." + logger.to_journal( "Finished purging sources from packages that are not installed.") + else + puts "\nUnable to complete a purge of sources from packages that are not installed, see journal." + logger.to_journal( "Cleanup of package sources encountered problems, see journal." ) + end + else + show.usage( "fix" ) + exit + end when "verify-files" if ( ARGV.length == 2 ) Modified: src/trunk/abtreportmanager.rb =================================================================== --- src/trunk/abtreportmanager.rb 2007-07-23 13:11:27 UTC (rev 402) +++ src/trunk/abtreportmanager.rb 2007-07-23 13:13:14 UTC (rev 403) @@ -212,7 +212,6 @@ def search_package_descriptions( searchText ) packageHash = Hash.new # has for values found. - # TODO: get packages installed list if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? return packageHash # empty hash, no entries. else Modified: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-07-23 13:11:27 UTC (rev 402) +++ src/trunk/abtsystemmanager.rb 2007-07-23 13:13:14 UTC (rev 403) @@ -72,11 +72,55 @@ # Removes all sources for packages that are not currently installed. Makes # use of install listing to determine package sources to keep. # + # <b>PARAM</b> <i>Boolean</i> - if false then removal of taballs done silently, default is + # true and removes with verbose output. + # # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise # false. ## - def cleanup_package_sources - return false + def cleanup_package_sources( verbose=true) + logger = AbtLogManager.new + sourcesArray = Array.new + + if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? + FileUtils.remove Dir.glob( "#{$SOURCES_REPOSITORY}/*" ), :verbose => verbose, :force => true + logger.to_journal( "Cleanup of package sources done, encountered an empty installation listing?" ) + return true + else + Dir.foreach( $PACKAGE_INSTALLED ) { |package| + if ( package != "." && package != "..") + # split the installed entry into two parts, + # the package name and the version number. + packageArray = package.split( "-" ) + packageName = packageArray[0] + + # create an array of installed package tarball names. + if ( File.exist?( "#{$PACKAGE_PATH}#{packageName}.rb" ) ) + require "#{$PACKAGE_PATH}#{packageName}" + sw = eval( "#{packageName.capitalize}.new" ) + sourcesArray.push( File.basename( sw.srcUrl ) ) + end + end + } + end + + if ( Dir.entries( $SOURCES_REPOSITORY ) - [ '.', '..' ] ).empty? + logger.to_journal( "Cleanup of package sources done, encountered an empty sources repository?" ) + return false + else + if ( verbose ) + puts "\nRemoving the following source files:" + puts "====================================" + end + + Dir.foreach( $SOURCES_REPOSITORY ) { |file| FileUtils.remove( file, :verbose => verbose, :force => true ) if ( file != "." && file != ".." && !sourcesArray.include?( file ) ) } + + if ( verbose ) + puts "====================================\n" + end + end + + 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-24 12:27:15
|
Revision: 406 http://svn.sourceforge.net/abtlinux/?rev=406&view=rev Author: eschabell Date: 2007-07-24 05:27:18 -0700 (Tue, 24 Jul 2007) Log Message: ----------- Refactoring to ensure each method was getting properly tested. It turned up a bug in log manager method log_package_install that was always returning true. With these fixes, all log manager tests are now passing. Modified Paths: -------------- src/trunk/abtlogmanager.rb src/trunk/testabtlogmanager.rb Modified: src/trunk/abtlogmanager.rb =================================================================== --- src/trunk/abtlogmanager.rb 2007-07-24 12:24:55 UTC (rev 405) +++ src/trunk/abtlogmanager.rb 2007-07-24 12:27:18 UTC (rev 406) @@ -169,6 +169,9 @@ end installFile.close + else + # no tmp install file, thus no install running. + return false end return true; Modified: src/trunk/testabtlogmanager.rb =================================================================== --- src/trunk/testabtlogmanager.rb 2007-07-24 12:24:55 UTC (rev 405) +++ src/trunk/testabtlogmanager.rb 2007-07-24 12:27:18 UTC (rev 406) @@ -34,48 +34,78 @@ # setup method for testing AbtLogManager. ## def setup - @log = AbtLogManager.new() + @logger = AbtLogManager.new + @manager = AbtPackageManager.new + @system = AbtSystemManager.new end ## # teardown method to cleanup after testing. ## def teardown + FileUtils.rm( "#{$ABT_TMP}/ipc-1.4.watch" ) if File.exist?( "#{$ABT_TMP}/ipc-1.2.watch" ) end ## # Test method for 'AbtLogManager.test_log_package_integrity()' ## def test_log_package_integrity() - assert( @log.log_package_integrity( "ipc" ), "test_log_package_integrity()" ) + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.log_package_integrity( "ipc" ), "test_log_package_integrity()" ) end ## # Test method for 'AbtLogManager.test_log_package_install()' ## def test_log_package_install() - assert( @log.log_package_install( "ipc" ), "test_log_package_install()" ) + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + # fill installwatch file. + File.open( "#{$ABT_TMP}/ipc-1.4.watch", "w" ) do |file| + file.puts "5 open /usr/local/bin/ipc #success" + file.puts "0 chmod /usr/local/bin/ipc 00600 #success" + file.puts "0 chown /usr/local/bin/ipc -1 -1 #success" + file.puts "0 chmod /usr/local/bin/ipc 00755 #success" + file.puts "5 open /usr/local/share/ipc/elemente #success" + file.puts "0 chmod /usr/local/share/ipc/elemente 00600 #success" + file.puts "0 chown /usr/local/share/ipc/elemente -1 -1 #success" + file.puts "0 chmod /usr/local/share/ipc/elemente 00644 #success" + end + + assert( @logger.log_package_install( "ipc" ), "test_log_package_install()" ) end ## # Test method for 'AbtLogManager.test_log_package_build()' ## def test_log_package_build() - assert( @log.log_package_build( "ipc" ), "test_log_package_build()" ) + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.log_package_build( "ipc" ), "test_log_package_build()" ) end ## # Test method for 'AbtLogManager.test_cache_package()' ## def test_cache_package() - assert( @log.cache_package( "ipc" ), "test_cache_package()" ) + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.cache_package( "ipc" ), "test_cache_package()" ) end ## # Test method for 'AbtLogManager.test_to_journal()' ## def test_to_journal() - assert( @log.to_journal( "Test message from AbtTestSuite." ), "test_to_journal()" ) + assert( @logger.to_journal( "Test message from AbtTestSuite." ), "test_to_journal()" ) end - end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-08-13 11:09:28
|
Revision: 422 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=422&view=rev Author: eschabell Date: 2007-08-13 04:09:30 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Fix for purge-src command, was not removing sources marked for removal due to relative path in rm command, now using complete path. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtsystemmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-08-12 19:13:31 UTC (rev 421) +++ src/trunk/abt.rb 2007-08-13 11:09:30 UTC (rev 422) @@ -424,7 +424,6 @@ when "purge-src" if ( ARGV.length == 1 ) - # FIXME : purge-src implementation. logger.to_journal( "Starting to purge sources from packages that are not installed.") if ( system.cleanup_package_sources ) puts "\nPurged sources from packages that are not installed." Modified: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-08-12 19:13:31 UTC (rev 421) +++ src/trunk/abtsystemmanager.rb 2007-08-13 11:09:30 UTC (rev 422) @@ -113,7 +113,7 @@ puts "====================================" end - Dir.foreach( $SOURCES_REPOSITORY ) { |file| FileUtils.remove( file, :verbose => verbose, :force => true ) if ( file != "." && file != ".." && !sourcesArray.include?( file ) ) } + Dir.foreach( $SOURCES_REPOSITORY ) { |file| FileUtils.remove( "#{$SOURCES_REPOSITORY}/#{file}", :verbose => verbose, :force => true ) if ( file != "." && file != ".." && !sourcesArray.include?( file ) ) } if ( verbose ) puts "====================================\n" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-08-16 19:10:06
|
Revision: 423 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=423&view=rev Author: eschabell Date: 2007-08-16 12:10:08 -0700 (Thu, 16 Aug 2007) Log Message: ----------- Implemented 'abt verify-integrity <package>'. Another unit test down, 17 to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtsystemmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-08-13 11:09:30 UTC (rev 422) +++ src/trunk/abt.rb 2007-08-16 19:10:08 UTC (rev 423) @@ -443,7 +443,7 @@ logger.to_journal( "Starting verifcation of files for package : #{options['package']}.") if system.verify_installed_files( options['package'] ) - puts "/nInstalled files verified for package : #{options['package']}" + puts "\nInstalled files verified for package : #{options['package']}" logger.to_journal( "Finished verifcation of files for package : #{options['package']}.") exit end @@ -477,10 +477,22 @@ when "verify-integrity" if ( ARGV.length == 2 ) - options['pkg'] = ARGV[1] - # FIXME : verify integrity of install pkg files implementation. - print "Verifiy integrity of installed files for " - puts "package : #{options['pkg']}" + options['package'] = ARGV[1] + logger.to_journal( "Starting verification of files for package : #{options['package']}.") + + integrityHash = system.verify_package_integrity( options['package'] ) + if integrityHash.empty? + puts "\nInstalled files integrity check completed without problems being detected for package : #{options['package']}" + logger.to_journal( "Finished verification of files for package : #{options['package']}.") + exit + end + + integrityHash.each_pair {|file, problem| + puts "Problem with #{file} from package #{problem}" + logger.to_journal( "Problem with #{file} from package #{problem}." ) + } + + puts "/nInstalled files integrity check failed for package : #{options['package']} failed, see journal." else show.usage( "fix" ) exit Modified: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-08-13 11:09:30 UTC (rev 422) +++ src/trunk/abtsystemmanager.rb 2007-08-16 19:10:08 UTC (rev 423) @@ -133,9 +133,8 @@ ## def verify_installed_files( package ) logger = AbtLogManager.new - system = AbtSystemManager.new - if !system.package_installed( package ) + if !package_installed( package ) logger.to_journal( "Unable to verify installed files for #{package}, it's not installed!") return false end @@ -189,10 +188,50 @@ # <b>PARAM</b> <i>String</i> - Package name. # # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise - # hash of problem files and their encountered errors. + # hash of problem files and their encountered errors. Hash has keys of + # file names and the values are the package name and the problem detected. ## def verify_package_integrity( package ) - return false + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + + logger = AbtLogManager.new + integrityHash = Hash.new # holds files failing interity check. + + if !File.exist?( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/#{sw.srcDir}.integrity" ) + logger.to_journal( "Unable to check file integrity for #{package}, integrity log missing!" ) + return integrityHash # empty hash, no entries. + else + + # FIXME: pickup each integrity file and check each entry (filename integrityvalue) + File.open( logger.get_log( package, "integrity" ) ).each { |line| + + # seperate the filepath and integrity value. + lineArray = line.split( ':' ) + + # check for existing file. + if !File.exist?( lineArray[0].chomp ) + logger.to_journal( "The file : #{lineArray[0].chomp} is missing for #{package}." ) + + # any failure or discrepency is added to hash: file => package + problem + integrityHash = integrityHash.merge( Hash[ lineArray[0].chomp => "#{package} - file missing." ] ) + end + + # passed existence check, now integrity check, need to ensure + # value computed matches our logged octal results. This requires + # computing the results, converting to octal, then chop off the + # first char by reversing the string and chopping the last (is + # there a better way?) char and then reversing those results. + octalResults = '%07o' % File.lstat( lineArray[0].chomp ).mode + + if lineArray[1].chomp != octalResults.reverse.chop.reverse + # any failure or discrepency is added to hash: file => package + problem + integrityHash = integrityHash.merge( Hash[ file => "#{package} #{sw.description}" ] ) + end + } + end + + return integrityHash end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-09-03 20:11:19
|
Revision: 425 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=425&view=rev Author: eschabell Date: 2007-09-03 13:11:20 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Refactored AbtLogManager class to remove to_journal method. This is now being provided by the core ruby Logger class. Further refactoring removes the usage of to_journal from the entire code base. Left behind TODO's for marking potential spot for more work as I take a closer look at the remaining AbtLogManager methods. Unit tests still at 17 failing. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtconfig.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/testabtlogmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abt.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -30,13 +30,20 @@ # Setup needed classes and get ready to parse arguments. ## manager = AbtPackageManager.new -logger = AbtLogManager.new # initializes all needed paths. +logger = Logger.new($JOURNAL) # initializes all needed paths. reporter = AbtReportManager.new downloader = AbtDownloadManager.new system = AbtSystemManager.new options = Hash.new show = AbtUsage.new +# setup timestamp. +logger.datetime_format = "%Y-%m-%d %H:%M:%S " + + +# TODO: used only until refactoring done. +myLogger = AbtLogManager.new + # deal with usage request. if ( ARGV.length == 0 || ( ARGV.length == 1 && ( ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help' ) ) ) show.usage( "all" ) @@ -53,13 +60,13 @@ when "install", "-i" if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) options['package'] = ARGV[1] - logger.to_journal( "Starting to install #{options['package']}" ) + logger.info( "Starting to install #{options['package']}" ) # return if already installed. if ( system.package_installed( options['package'] ) ) puts "\n*** Package #{options['package']} is installed, might want to try reinstall? ***" puts "\n\tabt reinstall #{options['package']}\n\n" - logger.to_journal( "Completed install of #{options['package']}." ) + logger.info( "Completed install of #{options['package']}." ) exit end @@ -67,15 +74,15 @@ puts "\n\n" puts "*** Completed install of #{options['package']}. ***" puts "\n\n" - logger.to_journal( "Completed install of #{options['package']}." ) + logger.info( "Completed install of #{options['package']}." ) - if ( logger.cache_package( options['package'] ) ) + if ( myLogger.cache_package( options['package'] ) ) puts "\n\n" puts "*** Completed caching of package #{options['package']}. ***" puts "\n\n" - logger.to_journal( "Caching completed for package #{options['package']}." ) + logger.info( "Caching completed for package #{options['package']}." ) else - logger.to_journal( "Caching of package #{options['package']} failed.") + logger.info( "Caching of package #{options['package']} failed.") end else puts "*** #{options['package'].capitalize} install failed, see journal. ***" @@ -88,7 +95,7 @@ when "reinstall", "-ri" if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) options['package'] = ARGV[1] - logger.to_journal( "Starting to reinstall #{options['package']}" ) + logger.info( "Starting to reinstall #{options['package']}" ) # check if already installed. if ( system.package_installed( options['package'] ) ) @@ -118,7 +125,7 @@ puts "\n\n" puts "*** Completed reinstall of #{options['package']}. ***" puts "\n\n" - logger.to_journal( "Completed reinstall of #{options['package']}." ) + logger.info( "Completed reinstall of #{options['package']}." ) else puts "*** #{options['package'].capitalize} reinstall failed, see journal. ***" end @@ -131,14 +138,14 @@ if ( ARGV.length == 2 ) options['package'] = ARGV[1] puts "Starting to remove #{options['package']}." - logger.to_journal( "Starting to remove #{options['package']}." ) + logger.info( "Starting to remove #{options['package']}." ) # return if not installed. if ( !( system.package_installed( options['package'] ) ) ) puts "\n\n" puts "*** No need to remove #{options['package']}, it was not installed! ***" puts "\n\n" - logger.to_journal( "Completed removal of #{options['package']}." ) + logger.info( "Completed removal of #{options['package']}." ) exit end @@ -147,7 +154,7 @@ puts "\n\n" puts "*** Completed removal of #{options['package']}. ***" puts "\n\n" - logger.to_journal( "Completed removal of #{options['package']}." ) + logger.info( "Completed removal of #{options['package']}." ) end else show.usage( "packages" ) @@ -179,7 +186,7 @@ when "search", "-s" if ( ARGV.length == 2 ) options['searchString'] = ARGV[1] - logger.to_journal( "Starting search of package descriptions for : #{options['searchString']}" ) + logger.info( "Starting search of package descriptions for : #{options['searchString']}" ) searchResults = reporter.search_package_descriptions( options['searchString'].chomp ) if ( searchResults.empty? ) puts "\nNothing found matching your search query." @@ -191,7 +198,7 @@ searchResults.each_pair { |name, description| puts "#{name} \t: #{description}" } end - logger.to_journal( "Completed search of package descriptions for : #{options['searchString']}" ) + logger.info( "Completed search of package descriptions for : #{options['searchString']}" ) else show.usage( "queries" ) exit @@ -210,10 +217,10 @@ when "show-details" if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) options['pkg'] = ARGV[1] - logger.to_journal( "Starting show details for #{options['pkg']}" ) + logger.info( "Starting show details for #{options['pkg']}" ) if ( reporter.show_package_details( options['pkg'] ) ) - logger.to_journal( "Completed show details for #{options['pkg']}" ) + logger.info( "Completed show details for #{options['pkg']}" ) else puts "Problems processing the details for #{options['pkg']}." end @@ -364,7 +371,7 @@ # abt news | -n when "news", "-n" - logger.to_journal( "Starting to retrieve AbTLinux news." ) + logger.info( "Starting to retrieve AbTLinux news." ) # abtlinux.org news feeds. puts "\n" @@ -385,24 +392,24 @@ # display the file contents. reporter.show_journal( $ABTNEWS_LOG ) - logger.to_journal( "Completed the retrieval of AbTLinux news." ) + logger.info( "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.to_journal( "Starting to download " + options['pkg'] ) + logger.info( "Starting to download " + options['pkg'] ) manager = AbtDownloadManager.new if ( manager.retrieve_package_source( options['pkg'], $SOURCES_REPOSITORY ) ) - logger.to_journal( "Finished download for " + options['pkg'] ) + logger.info( "Finished download for " + options['pkg'] ) puts "\n"; print "Downloading of #{options['pkg']} to #{$SOURCES_REPOSITORY} " puts "completed." puts "\n\n" else - logger.to_journal( "FAILURE to download " + options['pkg'] ) + logger.info( "FAILURE to download " + options['pkg'] ) puts "\n" puts "DOWNLOADING - failed to download source for #{options['pkg']}" puts "\n\n" @@ -424,13 +431,13 @@ when "purge-src" if ( ARGV.length == 1 ) - logger.to_journal( "Starting to purge sources from packages that are not installed.") + logger.info( "Starting to purge sources from packages that are not installed.") if ( system.cleanup_package_sources ) puts "\nPurged sources from packages that are not installed." - logger.to_journal( "Finished purging sources from packages that are not installed.") + logger.info( "Finished purging sources from packages that are not installed.") else puts "\nUnable to complete a purge of sources from packages that are not installed, see journal." - logger.to_journal( "Cleanup of package sources encountered problems, see journal." ) + logger.info( "Cleanup of package sources encountered problems, see journal." ) end else show.usage( "fix" ) @@ -440,15 +447,15 @@ when "verify-files" if ( ARGV.length == 2 ) options['package'] = ARGV[1] - logger.to_journal( "Starting verifcation of files for package : #{options['package']}.") + logger.info( "Starting verifcation of files for package : #{options['package']}.") if system.verify_installed_files( options['package'] ) puts "\nInstalled files verified for package : #{options['package']}" - logger.to_journal( "Finished verifcation of files for package : #{options['package']}.") + logger.info( "Finished verifcation of files for package : #{options['package']}.") exit end - logger.to_journal( "Finished verifcation of files for package : #{options['package']}.") + logger.info( "Finished verifcation of files for package : #{options['package']}.") puts "/nInstalled files verification for package : #{options['package']} failed, see journal." else show.usage( "fix" ) @@ -478,18 +485,18 @@ when "verify-integrity" if ( ARGV.length == 2 ) options['package'] = ARGV[1] - logger.to_journal( "Starting verification of files for package : #{options['package']}.") + logger.info( "Starting verification of files for package : #{options['package']}.") integrityHash = system.verify_package_integrity( options['package'] ) if integrityHash.empty? puts "\nInstalled files integrity check completed without problems being detected for package : #{options['package']}" - logger.to_journal( "Finished verification of files for package : #{options['package']}.") + logger.info( "Finished verification of files for package : #{options['package']}.") exit end integrityHash.each_pair {|file, problem| puts "Problem with #{file} from package #{problem}" - logger.to_journal( "Problem with #{file} from package #{problem}." ) + logger.info( "Problem with #{file} from package #{problem}." ) } puts "/nInstalled files integrity check failed for package : #{options['package']} failed, see journal." Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtconfig.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -38,6 +38,7 @@ require 'fileutils' require 'find' +require 'logger' require 'digest/sha1' # default paths / locations. @@ -47,7 +48,7 @@ $ABT_TMP = "/tmp/abt" $ABTNEWS_LOG = "#{$ABT_LOGS}/news.log" $BUILD_LOCATION = "/usr/src" -$JOURNAL = "#{$ABT_LOGS}/journal.log" +$JOURNAL = "#{$ABT_LOGS}/journal.log, File::WRONLY | File::APPEND | File::CREAT" # use logger.info. $PACKAGE_INSTALLED = "#{$ABT_STATE}/installed" $PACKAGE_CACHED = "#{$ABT_STATE}/cached" $PACKAGE_PATH = "#{$ABT_CACHES}/packages/" @@ -63,6 +64,7 @@ $REMOVE_BUILD_SOURCES = true $TIMESTAMP = Time.now.strftime( "%Y-%m-%d %H:%M:%S (%Z)" ) $PAGER_DEFAULT = "less -R -E -X -f" +$LOG_LEVEL = "Logger::DEBUG" # default URL listing. Modified: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtdownloadmanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -55,17 +55,17 @@ ## def retrieve_package_source( packageName, destination ) require "#{$PACKAGE_PATH}#{packageName}" - logger = AbtLogManager.new + logger = Logger.new($JOURNAL) package = eval( packageName.capitalize + '.new' ) if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) - logger.to_journal( "Download not needed, existing source found for #{packageName}" ) + logger.info( "Download not needed, existing source found for #{packageName}" ) return true end Dir.chdir( destination ) if ( system( "wget #{package.srcUrl}" ) ) - logger.to_journal( "Download completed for #{packageName}" ) + logger.info( "Download completed for #{packageName}" ) return true end @@ -98,7 +98,7 @@ require 'rss/1.0' require 'rss/2.0' newsLog = "" - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL) # ensure we have our news logfile. if ( cleanLog ) @@ -109,7 +109,7 @@ # pick up the abtlinux.org news feed. if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) - logger.to_journal( "Failed to retrieve news feed #{uri}." ) + logger.info( "Failed to retrieve news feed #{uri}." ) return false end @@ -121,8 +121,7 @@ end if ( rss.nil? ) - logger.to_journal( "Failed to display news feed as feed #{uri} " + - "is not RSS 1.0/2.0." ) + logger.info( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) return false else newsLog << "*** #{rss.channel.title} ***\n" @@ -169,16 +168,16 @@ # otherwise false. ## def validated( hashvalue, path ) - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) if hashvalue == Digest::SHA1.hexdigest( path ) puts "Source hash validated successfully..." - logger.to_journal( "Validated sources successfully..." ) + logger.info( "Validated sources successfully..." ) return true end puts "Source hash failed validation..." - logger.to_journal( "Validating sources failed..." ) + logger.info( "Validating sources failed..." ) return false end end Modified: src/trunk/abtlogmanager.rb =================================================================== --- src/trunk/abtlogmanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtlogmanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -78,12 +78,13 @@ # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize + logger = Logger.new( $JOURNAL ) [$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 ) - to_journal( "Created directory: #{dir}." ) + logger.info( "Created directory: #{dir}." ) end } end @@ -284,21 +285,4 @@ return false # package not installed, can't cache it. end - ## - # Provides logging of given message to the AbTLinux journal. Message logged - # with date timestamp. - # - # <b>PARAM</b> <i>String</i> - Message to be added to the log. - # - # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. - ## - def to_journal( message ) - if ( log = File.new( $JOURNAL, "a+" ) ) - log << "#{$TIMESTAMP} : #{message}\n" - log.close - return true - end - - return false - end end Modified: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtpackagemanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -92,8 +92,11 @@ require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) + # TODO: refactor myLogger: + myLogger = AbtLogManager.new + # get package details. details = sw.details @@ -103,7 +106,7 @@ puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) if ( !queuer.action_package_queue( package, "install", "add" ) ) - logger.to_journal( "Failed to add #{package} to install queue." ) + logger.info( "Failed to add #{package} to install queue." ) return false end @@ -111,48 +114,44 @@ puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) if ( !sw.pre ) - logger.to_journal( "Failed to process pre-section in the " + - "package description of #{package}." ) + logger.info( "Failed to process pre-section in the package description of #{package}." ) return false else - logger.to_journal( "Finished #{package} pre section." ) + logger.info( "Finished #{package} pre section." ) end # configure section. puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) if ( !sw.configure( verbose ) ) - logger.to_journal( "Failed to process configure section in the " + - "package description of #{package}." ) + logger.info( "Failed to process configure section in the package description of #{package}." ) return false else - logger.to_journal( "Finished #{package} configure section." ) + logger.info( "Finished #{package} configure section." ) end # build section. puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) if ( !sw.build( verbose ) ) - logger.to_journal( "Failed to process build section in the " + - "package description of #{package}." ) + logger.info( "Failed to process build section in the package description of #{package}." ) return false else - if ( !logger.log_package_build( sw.name.downcase ) ) - logger.to_journal( "Failed to create a package build log." ) + if ( !myLogger.log_package_build( sw.name.downcase ) ) + logger.info( "Failed to create a package build log." ) return false end - logger.to_journal( "Finished #{package} build section." ) + logger.info( "Finished #{package} build section." ) end # preinstall section. puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) if ( !sw.preinstall ) - logger.to_journal( "Failed to process preinstall section in the " + - "package description of #{package}." ) + logger.info( "Failed to process preinstall section in the package description of #{package}." ) return false else - logger.to_journal( "Finished #{package} preinstall section." ) + logger.info( "Finished #{package} preinstall section." ) end # install section. @@ -160,43 +159,42 @@ if ( !sw.install ) # rollback installed files if any and remove install log. - logger.to_journal( "Failed to process install section in the " + - "package description of #{package}." ) - logger.log_package_install( sw.name.downcase ) - logger.to_journal( "***Starting rollback of #{package} install and removing install log." ) + logger.info( "Failed to process install section in the package description of #{package}." ) + myLogger.log_package_install( sw.name.downcase ) + logger.info( "***Starting rollback of #{package} install and removing install log." ) roll_back( "install", details ) return false else - logger.log_package_install( sw.name.downcase ) - logger.log_package_integrity( sw.name.downcase ) + myLogger.log_package_install( sw.name.downcase ) + myLogger.log_package_integrity( sw.name.downcase ) # cleanup tmp files from installwatch. File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) - logger.to_journal( "Finished #{package} install section." ) + logger.info( "Finished #{package} install section." ) end # post section. puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) if ( !sw.post ) - logger.to_journal( "Failed to process post section in the package description of #{package}." ) + logger.info( "Failed to process post section in the package description of #{package}." ) return false else - logger.to_journal( "Finished #{package} post section." ) + logger.info( "Finished #{package} post section." ) end # clean out build sources. puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) if ( !sw.remove_build ) - logger.to_journal( "Failed to remove the build sources for #{package}." ) + logger.info( "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.action_package_queue( sw.name.downcase, "install", "remove" ) ) - logger.to_journal( "Failed to remove #{sw.name.downcase} from install queue." ) + logger.info( "Failed to remove #{sw.name.downcase} from install queue." ) end return true # install completed! @@ -213,22 +211,24 @@ # otherwise false. ## def reinstall_package( package ) - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) + # TODO: look into refactoring myLogger: + myLogger = AbtLogManager.new if ( install_package( package ) ) puts "\n\n" puts "*** Completed reinstall of #{package}. ***" puts "\n\n" - logger.to_journal( "Completed reinstall of #{package}." ) + logger.info( "Completed reinstall of #{package}." ) - if ( logger.cache_package( package ) ) + if ( myLogger.cache_package( package ) ) puts "\n\n" puts "*** Completed caching of package #{package}. ***" puts "\n\n" - logger.to_journal( "Caching completed for package #{package}." ) + logger.info( "Caching completed for package #{package}." ) return true else - logger.to_journal( "Caching of package #{package} failed.") + logger.info( "Caching of package #{package} failed.") end end @@ -246,7 +246,9 @@ def remove_package( package ) require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) - logger = AbtLogManager.new + # TODO: refactor myLogger. + myLogger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) # get package details. details = sw.details @@ -254,7 +256,7 @@ # TODO: something with possible /etc or other configure files before removal, check maybe integrity for changes since install? # remove listings in install log. - installLog = logger.get_log( package, 'install' ) + installLog = myLogger.get_log( package, 'install' ) # only process install log if it exists, continue on with # journal log warning. @@ -262,24 +264,24 @@ IO.foreach( installLog ) do |line| if File.exist?( line.chomp ) FileUtils.rm( line.chomp ) - logger.to_journal( "Removed file #{line.chomp} from #{package} install log.") + logger.info( "Removed file #{line.chomp} from #{package} install log.") else - logger.to_journal( "Unable to remove #{line.chomp} from #{package} install log, does not exist.") + logger.info( "Unable to remove #{line.chomp} from #{package} install log, does not exist.") # do not return false, removed is ok, just put warning in journal log. end end - logger.to_journal( "Removed files from #{File.basename( installLog )} for #{package}." ) + logger.info( "Removed files from #{File.basename( installLog )} for #{package}." ) else puts "Install log missing for #{package}, see journal..." - logger.to_journal( "Install log was missing for #{package}..." ) - logger.to_journal( "...continuing to remove package from install listing, but might have files still installed on system." ) + logger.info( "Install log was missing for #{package}..." ) + logger.info( "...continuing to remove package from install listing, but might have files still installed on system." ) end # remove entry in install listing. FileUtils.remove_dir( "#{$PACKAGE_INSTALLED}/#{details['Source location']}" ) - logger.to_journal( "Removed entry from installed packages." ) + logger.info( "Removed entry from installed packages." ) return true end Modified: src/trunk/abtqueuemanager.rb =================================================================== --- src/trunk/abtqueuemanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtqueuemanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -53,7 +53,7 @@ ## def action_package_queue( package, queue, action="add" ) require 'fileutils' - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) queueFile = "" # used to hold the queue location. # want to name install queue differently from log files. @@ -74,10 +74,9 @@ !checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( package ) ) log.puts "#{package}|#{$TIMESTAMP}" - logger.to_journal( "Added #{package} to #{queue} queue." ) + logger.info( "Added #{package} to #{queue} queue." ) else - logger.to_journal( - "Did not add #{package} to #{queue}, already exists." ) + logger.info( "Did not add #{package} to #{queue}, already exists." ) end log.close @@ -108,7 +107,7 @@ return true end - logger.to_journal( "Failed to open #{queueFile}." ) + logger.info( "Failed to open #{queueFile}." ) return false end end Modified: src/trunk/abtreportmanager.rb =================================================================== --- src/trunk/abtreportmanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtreportmanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -86,7 +86,7 @@ return true end - logger.to_journal( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) + logger.debug( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) return false end Modified: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/abtsystemmanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -79,12 +79,12 @@ # false. ## def cleanup_package_sources( verbose=true) - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) sourcesArray = Array.new if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? FileUtils.remove Dir.glob( "#{$SOURCES_REPOSITORY}/*" ), :verbose => verbose, :force => true - logger.to_journal( "Cleanup of package sources done, encountered an empty installation listing?" ) + logger.info( "Cleanup of package sources done, encountered an empty installation listing?" ) return true else Dir.foreach( $PACKAGE_INSTALLED ) { |package| @@ -105,7 +105,7 @@ end if ( Dir.entries( $SOURCES_REPOSITORY ) - [ '.', '..' ] ).empty? - logger.to_journal( "Cleanup of package sources done, encountered an empty sources repository?" ) + logger.info( "Cleanup of package sources done, encountered an empty sources repository?" ) return false else if ( verbose ) @@ -132,22 +132,24 @@ # otherwise false. ## def verify_installed_files( package ) - logger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) + # TODO: refactor myLogger: + myLogger = AbtLogManager.new if !package_installed( package ) - logger.to_journal( "Unable to verify installed files for #{package}, it's not installed!") + logger.info( "Unable to verify installed files for #{package}, it's not installed!") return false end - if !File.exist?( logger.get_log( package, 'install' ) ) - logger.to_journal( "Unable to verify installed files for #{package}, installed package but install log missing!" ) + if !File.exist?( myLogger.get_log( package, 'install' ) ) + logger.info( "Unable to verify installed files for #{package}, installed package but install log missing!" ) return false end failure = false # marker after checking all files to determine failure. - File.open( logger.get_log( package, "install" ) ).each { |line| + File.open( myLogger.get_log( package, "install" ) ).each { |line| if !File.exist?( line.chomp ) - logger.to_journal( "The file : #{line.chomp} is missing for #{package}." ) + logger.info( "The file : #{line.chomp} is missing for #{package}." ) failure = true end } @@ -195,23 +197,25 @@ require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) - logger = AbtLogManager.new + # TODO: refactor myLogger. + myLogger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) integrityHash = Hash.new # holds files failing interity check. if !File.exist?( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/#{sw.srcDir}.integrity" ) - logger.to_journal( "Unable to check file integrity for #{package}, integrity log missing!" ) + logger.info( "Unable to check file integrity for #{package}, integrity log missing!" ) return integrityHash # empty hash, no entries. else # FIXME: pickup each integrity file and check each entry (filename integrityvalue) - File.open( logger.get_log( package, "integrity" ) ).each { |line| + File.open( myLogger.get_log( package, "integrity" ) ).each { |line| # seperate the filepath and integrity value. lineArray = line.split( ':' ) # check for existing file. if !File.exist?( lineArray[0].chomp ) - logger.to_journal( "The file : #{lineArray[0].chomp} is missing for #{package}." ) + logger.info( "The file : #{lineArray[0].chomp} is missing for #{package}." ) # any failure or discrepency is added to hash: file => package + problem integrityHash = integrityHash.merge( Hash[ lineArray[0].chomp => "#{package} - file missing." ] ) Modified: src/trunk/testabtlogmanager.rb =================================================================== --- src/trunk/testabtlogmanager.rb 2007-08-16 19:10:58 UTC (rev 424) +++ src/trunk/testabtlogmanager.rb 2007-09-03 20:11:20 UTC (rev 425) @@ -105,10 +105,4 @@ assert( @logger.cache_package( "ipc" ), "test_cache_package()" ) end - ## - # Test method for 'AbtLogManager.test_to_journal()' - ## - def test_to_journal() - assert( @logger.to_journal( "Test message from AbtTestSuite." ), "test_to_journal()" ) - end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-09-18 20:22:02
|
Revision: 429 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=429&view=rev Author: eschabell Date: 2007-09-18 13:22:04 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Implemented retrieve package tree. This is part of the command 'abt package-repo add', the list and remove have been marked with todo's. Fixes another failing unit test, 16 to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtdownloadmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-09-18 20:19:00 UTC (rev 428) +++ src/trunk/abt.rb 2007-09-18 20:22:04 UTC (rev 429) @@ -527,8 +527,7 @@ end when "package-repo" - # FIXME : packge repo implementation. - # sort out that we have enough args. + case ARGV.length # add or remove called. @@ -538,8 +537,15 @@ # list called. when 2 + # FIXME: implements this. if ( ARGV[1] == "list" ) options['repoAction'] = ARGV[1] + logger.info "TODO: Listing package repositories." + elsif ARGV[1] == "add" || ARGV[1] == "remove" + # add or remove default repo. + options['repoAction'] = ARGV[1] + options['repoUri'] = "" + logger.info "Default AbTLinux Package Repository : #{options['repoAction']}." else show.usage( "maintenance" ) exit @@ -549,24 +555,51 @@ show.usage( "maintenance" ) exit end # case ARGV.length. - + + logger.info( "Starting package-repo : #{options['repoAction']}.") + # hook location based on action. case options['repoAction'] when "add" - puts "Adding package repository : " + options['repoUri'] - + if options['repoUri'].length > 0 + puts "Adding package repository : " + options['repoUri'] + if downloader.retrieve_package_tree( options['repoUri'] ) + puts "Added package tree : #{options['repoUri']}." + else + puts "Unable to add package tree : #{options['repoUri']}." + logger.error "Unable to add package tree : #{options['repoUri']}." + exit + end + else + puts "Adding package repository : Default AbTLinux Package Tree" + if downloader.retrieve_package_tree + puts "Added package tree : Default AbTLinux Package Tree}." + else + puts "Unable to add package tree : Default AbTLinux Package Tree." + logger.error "Unable to add package tree : Default AbTLinux Package Tree." + exit + end + end when "remove" - puts "Remove package repository : " + options['repoUri'] + # FIXME: implement this. + if options['repoUri'].length > 0 + puts "Removing package repository : " + options['repoUri'] + else + puts "Removing package repository : Default AbTLinux Package Tree" + end when "list" - puts "Display listing of package repositories." + # FIXME: implement this. + puts "TODO: Display listing of package repositories." else show.usage( "maintenance" ) exit end # case repoAction. + logger.info( "Starting package-repo : #{ARGV[1]} - #{ARGV[2]}.") + else show.usage( "all" ) end # case ARGV[0]. Modified: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-09-18 20:19:00 UTC (rev 428) +++ src/trunk/abtdownloadmanager.rb 2007-09-18 20:22:04 UTC (rev 429) @@ -80,7 +80,38 @@ # <b>RETURN</b> <i>boolean</i> - True if the package tree is retrieved, # otherwise false. ## - def retrieve_package_tree( packageTreeName ) + def retrieve_package_tree( packageTreeName="AbTLinux" ) + logger = Logger.new($JOURNAL) + + # check if package tree exists. + if File.directory?( $PACKAGE_PATH ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + if system( "svn update #{$PACKAGE_PATH}" ) + logger.info "Package tree updated (svn update)" + else + logger.error "Package tree unable to update (svn update)." + return false + end + else + # package directory exists, but is not a valid tree. + logger.error "Package tree exists, but is not valid svn tree." + return false + end + + else + + # pacakge directory does not exist, svn co. + if system( "svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}" ) + logger.info "Package tree installed (svn co)" + else + logger.error "Package tree not installed (svn co), problems!" + return false + end + + end + + 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-09-25 19:38:28
|
Revision: 431 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=431&view=rev Author: eschabell Date: 2007-09-25 12:38:31 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Update package tree implemented. Adjusted retrieve package tree functionality to no longer update. 15 unit tests to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtdownloadmanager.rb src/trunk/abtusage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-09-18 20:23:12 UTC (rev 430) +++ src/trunk/abt.rb 2007-09-25 19:38:31 UTC (rev 431) @@ -530,7 +530,7 @@ case ARGV.length - # add or remove called. + # add, remove or update called. when 3 options['repoAction'] = ARGV[1] options['repoUri'] = ARGV[2] @@ -541,11 +541,10 @@ if ( ARGV[1] == "list" ) options['repoAction'] = ARGV[1] logger.info "TODO: Listing package repositories." - elsif ARGV[1] == "add" || ARGV[1] == "remove" - # add or remove default repo. + elsif ARGV[1] == "add" || ARGV[1] == "remove" || ARGV[1] == "update" + # add, remove or update default repo. options['repoAction'] = ARGV[1] options['repoUri'] = "" - logger.info "Default AbTLinux Package Repository : #{options['repoAction']}." else show.usage( "maintenance" ) exit @@ -569,18 +568,39 @@ else puts "Unable to add package tree : #{options['repoUri']}." logger.error "Unable to add package tree : #{options['repoUri']}." + logger.info( "Finished package-repo : #{options['repoAction']}.") exit end else puts "Adding package repository : Default AbTLinux Package Tree" if downloader.retrieve_package_tree - puts "Added package tree : Default AbTLinux Package Tree}." + puts "Added package tree : Default AbTLinux Package Tree." else puts "Unable to add package tree : Default AbTLinux Package Tree." logger.error "Unable to add package tree : Default AbTLinux Package Tree." + logger.info( "Finished package-repo : #{options['repoAction']}.") exit end end + + when "update" + if options['repoUri'].length >= 0 + puts "Updating package repository : " + options['repoUri'] + if downloader.update_package_tree( options['repoUri'] ) + puts "Updated package tree : #{options['repoUri']}." + else + puts "Unable to update package tree : #{options['repoUri']}." + logger.error "Unable to update package tree : #{options['repoUri']}." + logger.info( "Finished package-repo : #{options['repoAction']}.") + exit + end + else + puts "Unable to update package tree : Default AbTLinux Package Tree." + logger.error "Unable to update package tree : Default AbTLinux Package Tree." + logger.info( "Finished package-repo : #{options['repoAction']}.") + exit + end + when "remove" # FIXME: implement this. if options['repoUri'].length > 0 @@ -598,7 +618,7 @@ exit end # case repoAction. - logger.info( "Starting package-repo : #{ARGV[1]} - #{ARGV[2]}.") + logger.info( "Finished package-repo : #{options['repoAction']}.") else show.usage( "all" ) Modified: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-09-18 20:23:12 UTC (rev 430) +++ src/trunk/abtdownloadmanager.rb 2007-09-25 19:38:31 UTC (rev 431) @@ -87,12 +87,8 @@ if File.directory?( $PACKAGE_PATH ) # check if svn directory. if File.directory?( "#{$PACKAGE_PATH}.svn" ) - if system( "svn update #{$PACKAGE_PATH}" ) - logger.info "Package tree updated (svn update)" - else - logger.error "Package tree unable to update (svn update)." - return false - end + logger.info "Package tree #{packageTreeName} already installed." + return true else # package directory exists, but is not a valid tree. logger.error "Package tree exists, but is not valid svn tree." @@ -186,7 +182,33 @@ # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, # otherwise false. ## - def update_package_tree + def update_package_tree( packageTreeName="AbTLinux" ) + logger = Logger.new($JOURNAL) + + # check if package tree exists. + if File.directory?( $PACKAGE_PATH ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + if system( "svn update #{$PACKAGE_PATH}" ) + logger.info "Package tree updated (svn update)" + else + logger.error "Package tree unable to update (svn update)." + return false + end + else + # package directory exists, but is not a valid tree. + logger.error "Package tree exists, but is not valid svn tree." + return false + end + + else + + # pacakge directory does not exist, svn co. + logger.error "Package tree not installed (svn co), problems!" + return false + end + + return true end ## Modified: src/trunk/abtusage.rb =================================================================== --- src/trunk/abtusage.rb 2007-09-18 20:23:12 UTC (rev 430) +++ src/trunk/abtusage.rb 2007-09-25 19:38:31 UTC (rev 431) @@ -152,9 +152,10 @@ def usage_maintenance puts "\nmaintenance:" puts " build-location [host]\t\tSets global location (default: localhost) for retrieving cached package builds." - puts " package-repo [add|remove|list] [URI]" - puts " add - add package repository to list." - puts " remove - remove a package repository from list." - puts " list - display current repository list.\n" + puts " package-repo [add|remove|update|list] [URI]" + puts " add - add package repository." + puts " remove - remove a package repository." + puts " update - update a package repository." + puts " list - display current repository listing.\n" end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-09-25 20:41:51
|
Revision: 435 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=435&view=rev Author: eschabell Date: 2007-09-25 13:41:52 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Refactored update package and package tree implementations to use the correct abt function call. Not passing two more unit tests, 14 to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtdownloadmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-09-25 20:40:23 UTC (rev 434) +++ src/trunk/abt.rb 2007-09-25 20:41:52 UTC (rev 435) @@ -421,12 +421,50 @@ when "update", "-u" if ( ARGV.length == 2 ) - options['updateItem'] = ARGV[1] - # FIXME : update package implementation. - puts "Updating item : #{options['updateItem']}" + + if ( ARGV[1].length > 0 || ARGV[1] == "tree" || ARGV[1].downcase == "abtlinux" ) + if ARGV[1].downcase == "tree" || ARGV[1].downcase == "abtlinux" + options['updateItem'] = "AbTLinux" + + puts "Start updating package tree : #{options['updateItem']}." + logger.info "Start updating package tree : #{options['updateItem']}." + + if downloader.update_package_tree( options['updateItem'] ) + puts "Updated package tree : #{options['updateItem']}." + else + puts "Unable to update package tree : #{options['updateItem']}." + logger.error "Unable to update package tree : #{options['updateItem']}." + logger.info( "Finished updating package tree : #{options['updateItem']}.") + exit + end + + logger.info( "Finished updating package tree : #{options['updateItem']}.") + + else + # assuming package to be updated. + options['updateItem'] = ARGV[1].downcase + + puts "Start updating package : #{options['updateItem']}." + logger.info "Start updating package : #{options['updateItem']}." + + if downloader.update_package( options['updateItem'] ) + puts "Updated package : #{options['updateItem']}." + else + puts "Unable to update package : #{options['updateItem']}." + logger.error "Unable to update package : #{options['updateItem']}." + logger.info( "Finished updating package : #{options['updateItem']}") + exit + end + + logger.info( "Finished updating package : #{options['updateItem']}") + end + else + show.usage( "downloads" ) + exit + end else - show.usage( "downloads" ) - exit + show.usage( "downloads" ) + exit end when "purge-src" @@ -530,7 +568,7 @@ case ARGV.length - # add, remove or update called. + # add or remove called. when 3 options['repoAction'] = ARGV[1] options['repoUri'] = ARGV[2] @@ -541,7 +579,7 @@ if ( ARGV[1] == "list" ) options['repoAction'] = ARGV[1] logger.info "TODO: Listing package repositories." - elsif ARGV[1] == "add" || ARGV[1] == "remove" || ARGV[1] == "update" + elsif ARGV[1] == "add" || ARGV[1] == "remove" # add, remove or update default repo. options['repoAction'] = ARGV[1] options['repoUri'] = "" @@ -582,26 +620,8 @@ exit end end - - when "update" - if options['repoUri'].length >= 0 - puts "Updating package repository : " + options['repoUri'] - if downloader.update_package_tree( options['repoUri'] ) - puts "Updated package tree : #{options['repoUri']}." - else - puts "Unable to update package tree : #{options['repoUri']}." - logger.error "Unable to update package tree : #{options['repoUri']}." - logger.info( "Finished package-repo : #{options['repoAction']}.") - exit - end - else - puts "Unable to update package tree : Default AbTLinux Package Tree." - logger.error "Unable to update package tree : Default AbTLinux Package Tree." - logger.info( "Finished package-repo : #{options['repoAction']}.") - exit - end - - when "remove" + + when "remove" # FIXME: implement this. if options['repoUri'].length > 0 puts "Removing package repository : " + options['repoUri'] Modified: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-09-25 20:40:23 UTC (rev 434) +++ src/trunk/abtdownloadmanager.rb 2007-09-25 20:41:52 UTC (rev 435) @@ -173,12 +173,38 @@ # <b>RETURN</b> <i>boolean</i> - True if the given package has been updated, # otherwise false. ## - def update_package + def update_package( packageName ) + logger = Logger.new($JOURNAL) + + # check if package exists in tree. + if File.exists?( "#{$PACKAGE_PATH}/#{packageName}.rb" ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + if system( "svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb" ) + logger.info "Package #{packageName.downcase} updated (svn update)" + else + logger.error "Package #{packageName.downcase} unable to update (svn update)." + return false + end + else + # package exists, but not an valid tree. + logger.error "Package #{packageName} exists, but not valid package tree (svn)." + return false + end + else + # package does not exist. + logger.error "Package is not installed, not possible to update!" + return false + end + + return true end ## # Updates the package tree. # + # <b>PARAM</b> <i>String</i> - the name of the tree to be updated, defaults to AbTLinux repo. + # # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, # otherwise false. ## @@ -200,12 +226,10 @@ logger.error "Package tree exists, but is not valid svn tree." return false end - else - - # pacakge directory does not exist, svn co. - logger.error "Package tree not installed (svn co), problems!" - return false + # package directory does not exist. + logger.error "Package tree not installed!" + return false end return true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-12-24 12:26:28
|
Revision: 437 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=437&view=rev Author: eschabell Date: 2007-12-24 04:26:30 -0800 (Mon, 24 Dec 2007) Log Message: ----------- Added directory setup for configuration files in /etc, also ensured logmanager checking for existence. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/abtlogmanager.rb Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-09-25 20:43:00 UTC (rev 436) +++ src/trunk/abtconfig.rb 2007-12-24 12:26:30 UTC (rev 437) @@ -46,6 +46,8 @@ $ABT_CACHES = "/var/spool/abt" $ABT_STATE = "/var/state/abt" $ABT_TMP = "/tmp/abt" +$ABT_CONFIG = "/etc/abt" +$ABT_LOCAL_CONFIG = "/etc/abt/local" $ABTNEWS_LOG = "#{$ABT_LOGS}/news.log" $BUILD_LOCATION = "/usr/src" $JOURNAL = "#{$ABT_LOGS}/journal.log" # use logger.info. Modified: src/trunk/abtlogmanager.rb =================================================================== --- src/trunk/abtlogmanager.rb 2007-09-25 20:43:00 UTC (rev 436) +++ src/trunk/abtlogmanager.rb 2007-12-24 12:26:30 UTC (rev 437) @@ -80,7 +80,7 @@ def initialize logger = Logger.new( $JOURNAL ) [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, - $PACKAGE_CACHED, $ABT_TMP, $SOURCES_REPOSITORY].each { |dir| + $PACKAGE_CACHED, $ABT_TMP, $ABT_CONFIG, $ABT_LOCAL_CONFIG, $SOURCES_REPOSITORY].each { |dir| if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-12-25 14:09:43
|
Revision: 442 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=442&view=rev Author: eschabell Date: 2007-12-25 06:09:47 -0800 (Tue, 25 Dec 2007) Log Message: ----------- Implemented freeze (and second run unfreezes a given package) and unfreeze package, updated usage to reflect new feature usage, and down to 13 unit tests. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtpackagemanager.rb src/trunk/abtusage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-12-25 14:08:25 UTC (rev 441) +++ src/trunk/abt.rb 2007-12-25 14:09:47 UTC (rev 442) @@ -176,10 +176,17 @@ when "freeze", "-f" if ( ARGV.length == 2 ) options['package'] = ARGV[1] - # FIXME : freeze package implementation. - puts "Holdinging package : #{options['package']} at current version." + logger.info( "Starting freeze of package : #{options['package']}" ) + puts "\nAttempting to freeze package #{options['package']}." + if ( !manager.freeze_package( options['package'] ) ) + puts "\nUnable to freeze package #{options['package']}, see journal for details." + end + + logger.info( "Completed (un)freeze of package : #{options['package']}" ) + puts "\nCompleted freeze of package : #{options['package']}" else show.usage( "packages" ) + logger.info( "Completed (un)freeze of package : #{options['package']}" ) exit end Modified: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-12-25 14:08:25 UTC (rev 441) +++ src/trunk/abtpackagemanager.rb 2007-12-25 14:09:47 UTC (rev 442) @@ -93,6 +93,7 @@ sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new logger = Logger.new( $JOURNAL ) + system = AbtSystemManager.new # TODO: refactor myLogger: myLogger = AbtLogManager.new @@ -100,6 +101,13 @@ # get package details. details = sw.details + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with install package call." + puts "\nPackage #{package} is frozen, can not proceed with install package call." + return false + end + # TODO: check deps # add to install queue. @@ -109,7 +117,7 @@ logger.info( "Failed to add #{package} to install queue." ) return false end - + # pre section. puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) @@ -214,7 +222,15 @@ logger = Logger.new( $JOURNAL ) # TODO: look into refactoring myLogger: myLogger = AbtLogManager.new + system = AbtSystemManager.new + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with reinstall package call." + puts "\nPackage #{package} is frozen, can not proceed with reinstall package call." + return false + end + if ( install_package( package ) ) puts "\n\n" puts "*** Completed reinstall of #{package}. ***" @@ -249,10 +265,18 @@ # TODO: refactor myLogger. myLogger = AbtLogManager.new logger = Logger.new( $JOURNAL ) + system = AbtSystemManager.new # get package details. details = sw.details + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with remove package call." + puts "\nPackage #{package} is frozen, can not proceed with remove package call." + return false + end + # TODO: something with possible /etc or other configure files before removal, check maybe integrity for changes since install? # remove listings in install log. @@ -296,12 +320,21 @@ # false. ## def downgrade_package( package, version ) + system = AbtSystemManager.new + + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with downgrade package call." + puts "\nPackage #{package} is frozen, can not proceed with downgrade package call." + return false + end + return false end ## # Freezes a given package. If successful will add give package to the frozen - # list. + # list. If the given package is already frozen, it will be released. # # <b>PARAM</b> <i>String</i> - the name of the package to be frozen. # @@ -315,23 +348,27 @@ logger = Logger.new( $JOURNAL ) system = AbtSystemManager.new - # get package details. - details = sw.details + if ( system.package_installed( package ) ) + if ( system.package_frozen( package ) ) + logger.info( "Package #{package} is already frozen!" ) - #if system.package_installed( package ) - # if system.package_frozen( package ) - # logger.info( "Package #{package} is already frozen!" ) - # return true - # end + # package already frozen, need to un-freeze by removing frozen.log + # file. + FileUtils.rm "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" + puts "\nPackage #{package} was frozen, it has now been relased for use." + logger.info "Package #{package} released : removed file #{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" + else + # place file in $PACKAGE_INSTALLED frozen.log with date. + frozen = File.open( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log", "w" ) + frozen.puts "#{$TIMESTAMP}" + frozen.close + logger.info( "Package #{package} is now frozen." ) + end - # FIXME: create file in $PACKAGE_INSTALLED frozen.log with date. - #frozen = File.open( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log", "w" ) - #frozen.puts "#{$TIMESTAMP}" - #frozen.close - # end - #end + return true + end - #logger.info( "Package #{package} is not installed, unable to freeze it." ) + logger.info( "Package #{package} is not installed, unable to freeze it." ) return false end Modified: src/trunk/abtusage.rb =================================================================== --- src/trunk/abtusage.rb 2007-12-25 14:08:25 UTC (rev 441) +++ src/trunk/abtusage.rb 2007-12-25 14:09:47 UTC (rev 442) @@ -78,6 +78,7 @@ puts " -r, remove [package]\t\tRemove given package." puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" + puts "\t\t\t\t\tIf the given package is already frozen, it will be released.\n" end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-12-26 09:06:36
|
Revision: 444 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=444&view=rev Author: eschabell Date: 2007-12-26 01:06:20 -0800 (Wed, 26 Dec 2007) Log Message: ----------- Refactored reinstall package call to check for frozen before asking to reinstall the package, simplifies output paths. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtpackagemanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-12-25 14:10:46 UTC (rev 443) +++ src/trunk/abt.rb 2007-12-26 09:06:20 UTC (rev 444) @@ -97,37 +97,13 @@ options['package'] = ARGV[1] logger.info( "Starting to reinstall #{options['package']}" ) - # check if already installed. - if ( system.package_installed( options['package'] ) ) - puts "\n*** Package #{options['package']} is already installed! ***\n" - puts "Are you sure you want to proceed with a reinstall? (y/n)" - - while answer = STDIN.gets - answer.chomp! - if answer == "y" - break - elsif answer == "n" - exit - else - puts "Are you sure you want to reinstall #{options['package']}? (y/n)" - end - end - else - puts "\n*** Package #{options['package']} is not installed, we will install it for you now! ***\n" - puts "Hit enter to continue..." - while continue = STDIN.gets - continue.chomp! - break - end - end - - if ( manager.reinstall_package( options['package'] ) ) + if ( manager.reinstall_package( options['package'] ) ) puts "\n\n" puts "*** Completed reinstall of #{options['package']}. ***" puts "\n\n" logger.info( "Completed reinstall of #{options['package']}." ) else - puts "*** #{options['package'].capitalize} reinstall failed, see journal. ***" + puts "\n*** Unable to reinstall package #{options['package'].capitalize}, see why in the journal. ***" end else show.usage( "packages" ) @@ -145,7 +121,7 @@ puts "\n\n" puts "*** No need to remove #{options['package']}, it was not installed! ***" puts "\n\n" - logger.info( "Completed removal of #{options['package']}." ) + logger.info( "Unabel to complete removal of #{options['package']}." ) exit end @@ -154,9 +130,14 @@ puts "\n\n" puts "*** Completed removal of #{options['package']}. ***" puts "\n\n" - logger.info( "Completed removal of #{options['package']}." ) + logger.info( "Unabel to complete removal of #{options['package']}." ) end + + puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" + logger.info( "Unabel to complete removal of #{options['package']}." ) else + puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" + logger.info( "Unabel to complete removal of #{options['package']}." ) show.usage( "packages" ) exit end Modified: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-12-25 14:10:46 UTC (rev 443) +++ src/trunk/abtpackagemanager.rb 2007-12-26 09:06:20 UTC (rev 444) @@ -231,6 +231,30 @@ return false end + # check if already installed. + if ( system.package_installed( options['package'] ) ) + puts "\n*** Package #{package} is already installed! ***\n" + puts "Are you sure you want to proceed with a reinstall? (y/n)" + + while answer = STDIN.gets + answer.chomp! + if answer == "y" + break + elsif answer == "n" + exit + else + puts "Are you sure you want to reinstall #{package}? (y/n)" + end + end + else + puts "\n*** Package #{package} is not installed, we will install it for you now! ***\n" + puts "Hit enter to continue..." + while continue = STDIN.gets + continue.chomp! + break + end + end + if ( install_package( package ) ) puts "\n\n" puts "*** Completed reinstall of #{package}. ***" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-12-27 19:11:10
|
Revision: 447 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=447&view=rev Author: eschabell Date: 2007-12-27 11:11:11 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Refactored unit tests and class to properly setup the frozen status of a package for the testing. Furthermore, allow automoted non-user querying build for re-install package method. Modified Paths: -------------- src/trunk/abtpackagemanager.rb src/trunk/testabtpackagemanager.rb Modified: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-12-27 19:09:13 UTC (rev 446) +++ src/trunk/abtpackagemanager.rb 2007-12-27 19:11:11 UTC (rev 447) @@ -214,11 +214,12 @@ # Reinstalls a given package. # # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. + # <b>PARAM</b> <i>Boolean</i> - query the user if false (default), otherwise true and skip query. # # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, # otherwise false. ## - def reinstall_package( package ) + def reinstall_package( package, automated_build=false ) logger = Logger.new( $JOURNAL ) # TODO: look into refactoring myLogger: myLogger = AbtLogManager.new @@ -232,20 +233,23 @@ end # check if already installed. - if ( system.package_installed( options['package'] ) ) - puts "\n*** Package #{package} is already installed! ***\n" - puts "Are you sure you want to proceed with a reinstall? (y/n)" + if ( system.package_installed( package ) ) + + if !automated_build + puts "\n*** Package #{package} is already installed! ***\n" + puts "Are you sure you want to proceed with a reinstall? (y/n)" - while answer = STDIN.gets - answer.chomp! - if answer == "y" - break - elsif answer == "n" - exit - else - puts "Are you sure you want to reinstall #{package}? (y/n)" - end - end + while answer = STDIN.gets + answer.chomp! + if answer == "y" + break + elsif answer == "n" + exit + else + puts "Are you sure you want to reinstall #{package}? (y/n)" + end + end + end else puts "\n*** Package #{package} is not installed, we will install it for you now! ***\n" puts "Hit enter to continue..." Modified: src/trunk/testabtpackagemanager.rb =================================================================== --- src/trunk/testabtpackagemanager.rb 2007-12-27 19:09:13 UTC (rev 446) +++ src/trunk/testabtpackagemanager.rb 2007-12-27 19:11:11 UTC (rev 447) @@ -55,6 +55,11 @@ ## def test_install_package if @system.package_installed( "ipc" ) + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + @manager.remove_package( "ipc" ) end @@ -69,7 +74,11 @@ @manager.install_package( "ipc" ) end - assert( @pkgMgr.reinstall_package( "ipc" ), "test_reinstall_package()" ) + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + + assert( @pkgMgr.reinstall_package( "ipc", true ), "test_reinstall_package()" ) end ## @@ -80,6 +89,10 @@ @manager.install_package( "ipc" ) end + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + assert( @pkgMgr.remove_package( "ipc" ), "test_remove_package()" ) end @@ -90,6 +103,10 @@ if !@system.package_installed( "ipc" ) @manager.install_package( "ipc" ) end + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end assert( @pkgMgr.downgrade_package( "ipc", "1.2" ), "test_downgrade_package()" ) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-12-29 18:25:42
|
Revision: 449 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=449&view=rev Author: eschabell Date: 2007-12-29 10:25:47 -0800 (Sat, 29 Dec 2007) Log Message: ----------- TODO markers added for methods yet to be implemented. This adds them to the Task list in eclipse, handy for finishing up the work planned. Modified Paths: -------------- src/trunk/abtdepengine.rb src/trunk/abtreportmanager.rb src/trunk/abtsystemmanager.rb Property Changed: ---------------- src/trunk/ Property changes on: src/trunk ___________________________________________________________________ Name: svn:ignore + .settings .project .loadpath Modified: src/trunk/abtdepengine.rb =================================================================== --- src/trunk/abtdepengine.rb 2007-12-27 19:26:34 UTC (rev 448) +++ src/trunk/abtdepengine.rb 2007-12-29 18:25:47 UTC (rev 449) @@ -39,6 +39,7 @@ # <b>RETURN</b> <i>AbtDepEngine</i> - an initialized AbtDepEngine object. ## def initialize + # TODO: implement this. end end Modified: src/trunk/abtreportmanager.rb =================================================================== --- src/trunk/abtreportmanager.rb 2007-12-27 19:26:34 UTC (rev 448) +++ src/trunk/abtreportmanager.rb 2007-12-29 18:25:47 UTC (rev 449) @@ -184,6 +184,7 @@ # hash of problem files and their encountered errors. ## def show_package_dependencies( package ) + # TODO: implement this. return false end @@ -195,6 +196,7 @@ # <b>RETURN</b> <i>void.</i> ## def show_untracked_files + # TODO: implement this. return false end @@ -231,6 +233,7 @@ # <b>RETURN</b> <i>void.</i> ## def show_file_owner( file ) + # TODO: implement this. return false end @@ -319,6 +322,7 @@ # false. ## def show_updates( target ) + # TODO: implement this. return false end @@ -328,6 +332,7 @@ # <b>RETURN</b> <i>void.</i> ## def generate_HTML_package_listing + # TODO: implement this. return false end end Modified: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-12-27 19:26:34 UTC (rev 448) +++ src/trunk/abtsystemmanager.rb 2007-12-29 18:25:47 UTC (rev 449) @@ -168,6 +168,7 @@ # or broken, otherwise false. ## def verify_symlinks( package ) + # TODO: implement this. return false end @@ -180,6 +181,7 @@ # false. ## def verify_package_depends( package ) + # TODO: implement this. return false end @@ -247,6 +249,7 @@ # false. ## def fix_package( package ) + # TODO: implement this. return false end @@ -259,6 +262,7 @@ # <b>RETURN</b> <i>boolean</i> - True if the URI is set, otherwise false. ## def set_central_repo( uri ) + # TODO: implement this. return false end @@ -272,6 +276,7 @@ # otherwise false. ## def set_package_tree_location( location ) + # TODO: implement this. return false end @@ -316,5 +321,4 @@ 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...> - 2007-12-31 12:49:45
|
Revision: 454 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=454&view=rev Author: eschabell Date: 2007-12-31 04:49:44 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Moved tests into apart test directory, also update tests with LOAD_PATH pointing to class lib locations. Added Paths: ----------- src/trunk/tests/ src/trunk/tests/testabtdepengine.rb src/trunk/tests/testabtdownloadmanager.rb src/trunk/tests/testabtlogmanager.rb src/trunk/tests/testabtpackage.rb src/trunk/tests/testabtpackagemanager.rb src/trunk/tests/testabtqueuemanager.rb src/trunk/tests/testabtreportmanager.rb src/trunk/tests/testabtsystemmanager.rb src/trunk/tests/testsuiteabt.rb Copied: src/trunk/tests/testabtdepengine.rb (from rev 450, src/trunk/testabtdepengine.rb) =================================================================== --- src/trunk/tests/testabtdepengine.rb (rev 0) +++ src/trunk/tests/testabtdepengine.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,55 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtdepengine.rb +# +# Unit testing for AbtDepEngine class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtDepEngine < Test::Unit::TestCase + + ## + # setup method for testing AbtDepEngine. + ## + def setup + @depEngine = AbtDepEngine.new + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtDepEngine.test_dep_engine()' + ## + def test_dep_engine + assert_equal( false, true, "test_dep_engine()" ) + end + +end Copied: src/trunk/tests/testabtdownloadmanager.rb (from rev 450, src/trunk/testabtdownloadmanager.rb) =================================================================== --- src/trunk/tests/testabtdownloadmanager.rb (rev 0) +++ src/trunk/tests/testabtdownloadmanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,97 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtdownloadmanager.rb +# +# Unit testing for AbtDownloadManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtDownloadManager < Test::Unit::TestCase + + ## + # setup method for testing AbtDownloadManager. + ## + def setup + @download = AbtDownloadManager.new + @manager = AbtPackageManager.new + @system = AbtSystemManager.new + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtDownloadManager.test_retrieve_package_source()' + ## + def test_retrieve_package_source() + # ensures download not needed. + FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + + assert( @download.retrieve_package_source( "ipc", "#{$SOURCES_REPOSITORY}" ), "test_retrieve_package_source()" ) + end + + ## + # Test method for 'AbtDownloadManager.test_retrieve_package_tree()' + ## + def test_retrieve_package_tree() + assert( @download.retrieve_package_tree( "dummy" ), "test_retrieve_package_tree()" ) + end + + ## + # Test method for 'AbtDownloadManager.test_retrieve_news_feed()' + ## + def test_retrieve_news_feed() + assert( @download.retrieve_news_feed( $ABTNEWS ), "test_retrieve_news_feed()" ) + end + + ## + # Test method for 'AbtDownloadManager.test_update_package()' + ## + def test_update_package() + assert( @download.update_package( "ipc") , "test_update_package()" ) + end + + ## + # Test method for 'AbtDownloadManager.test_update_package_tree()' + ## + def test_update_package_tree() + assert( @download.update_package_tree(), "test_update_package_tree()" ) + end + + ## + # Test method for 'AbtDownloadManager.test_validated()' + ## + def test_validated() + # ensure a tarball is available to test! + FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + + assert( @download.validated( 'e81278607b1d65dcb18c3613ec00fbf588b50319', "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ), "test_validated" ) + end +end Copied: src/trunk/tests/testabtlogmanager.rb (from rev 450, src/trunk/testabtlogmanager.rb) =================================================================== --- src/trunk/tests/testabtlogmanager.rb (rev 0) +++ src/trunk/tests/testabtlogmanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,110 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtlogmanager.rb +# +# Unit testing for AbtLogManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtLogManager < Test::Unit::TestCase + + ## + # setup method for testing AbtLogManager. + ## + def setup + @logger = AbtLogManager.new + @manager = AbtPackageManager.new + @system = AbtSystemManager.new + + # ensures download not needed. + FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + FileUtils.rm( "#{$ABT_TMP}/ipc-1.4.watch" ) if File.exist?( "#{$ABT_TMP}/ipc-1.2.watch" ) + end + + ## + # Test method for 'AbtLogManager.test_log_package_integrity()' + ## + def test_log_package_integrity() + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.log_package_integrity( "ipc" ), "test_log_package_integrity()" ) + end + + ## + # Test method for 'AbtLogManager.test_log_package_install()' + ## + def test_log_package_install() + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + # fill installwatch file. + File.open( "#{$ABT_TMP}/ipc-1.4.watch", "w" ) do |file| + file.puts "5 open /usr/local/bin/ipc #success" + file.puts "0 chmod /usr/local/bin/ipc 00600 #success" + file.puts "0 chown /usr/local/bin/ipc -1 -1 #success" + file.puts "0 chmod /usr/local/bin/ipc 00755 #success" + file.puts "5 open /usr/local/share/ipc/elemente #success" + file.puts "0 chmod /usr/local/share/ipc/elemente 00600 #success" + file.puts "0 chown /usr/local/share/ipc/elemente -1 -1 #success" + file.puts "0 chmod /usr/local/share/ipc/elemente 00644 #success" + end + + assert( @logger.log_package_install( "ipc" ), "test_log_package_install()" ) + end + + ## + # Test method for 'AbtLogManager.test_log_package_build()' + ## + def test_log_package_build() + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.log_package_build( "ipc" ), "test_log_package_build()" ) + end + + ## + # Test method for 'AbtLogManager.test_cache_package()' + ## + def test_cache_package() + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @logger.cache_package( "ipc" ), "test_cache_package()" ) + end + +end Copied: src/trunk/tests/testabtpackage.rb (from rev 450, src/trunk/testabtpackage.rb) =================================================================== --- src/trunk/tests/testabtpackage.rb (rev 0) +++ src/trunk/tests/testabtpackage.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,147 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' +$LOAD_PATH.unshift '../packages/' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' +require 'ipc' + +## +# testabtpackage.rb +# +# Unit testing for AbtPackage class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtPackage < Test::Unit::TestCase + + $nameTest = "Ipc" + $versionTest = "1.4" + $verbose = false + $srcDirTest = "#{$nameTest.downcase}-#{$versionTest}" + + $dataTest = { + 'name' => $nameTest, + 'execName' => $nameTest.downcase, + 'version' => $versionTest, + 'srcDir' => $srcDirTest, + 'homepage' => "http://isotopatcalc.sourceforge.net/" + } + + ## + # setup method for testing AbtPackage. + ## + def setup + @ipc = Ipc.new + + # ensures download not needed. + FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist? "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + FileUtils.rm_r "#{$BUILD_LOCATION}/#{$dataTest['srcDir']}", :verbose => true if File.exist? "#{$BUILD_LOCATION}/#{$dataTest['srcDir']}" + end + + ## + # Test method for 'AbtPackage.test_details()' + ## + def test_details + assert_equal( $dataTest['name'], @ipc.details['Package name'], "test_details(name)" ) + assert_equal( $dataTest['execName'], @ipc.details['Executable'], "test_details(execName)" ) + assert_equal( $dataTest['version'], @ipc.details['Version'], "test_details(version)" ) + assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], "test_details(srcDir)" ) + assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], "test_details(homepage)" ) + end + + ## + # Test method for 'AbtPackage.test_pre()' + ## + def test_pre + assert( @ipc.pre( $verbose ), "test_pre()" ) + end + + ## + # Test method for 'AbtPackage.test_configure()' + ## + def test_configure + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "test_configure(pre)" ) + end + assert( @ipc.configure( $verbose ), "test_configure(configure)" ) + end + + ## + # Test method for 'AbtPackage.test_build()' + ## + def test_build + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "test_build(pre)" ) + end + if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "test_build(configure)" ) + end + assert( @ipc.build( $verbose ), "test_build(build)" ) + end + + ## + # Test method for 'AbtPackage.test_preinstall()' + ## + def test_preinstall + assert( @ipc.preinstall( $verbose ), "test_preinstall()" ) + end + + ## + # Test method for 'AbtPackage.test_install()' + ## + def test_install + + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "test_install(pre)" ) + end + if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "test_install(configure)" ) + end + if ( !@ipc.build( $verbose ) ) + assert_equals( true, false, "test_install(build)" ) + end + if ( !@ipc.preinstall( $verbose ) ) + assert_equals( true, false, "test_install(install)" ) + end + assert( @ipc.install( $verbose ), "test_install(install)" ) + end + + ## + # Test method for 'AbtPackage.test_post()' + ## + def test_post + assert_equals( true, false, "test_post(pre)" ) if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "test_post(configure)" ) if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "test_post(build)" ) if ( !@ipc.build( $verbose ) ) + assert_equals( true, false, "test_post(preinstall)" ) if ( !@ipc.preinstall( $verbose ) ) + assert_equals( true, false, "test_post(install)" ) if ( !@ipc.install( $verbose ) ) + assert( @ipc.post( $verbose ), "test_post(post)" ) + end + +end Copied: src/trunk/tests/testabtpackagemanager.rb (from rev 450, src/trunk/testabtpackagemanager.rb) =================================================================== --- src/trunk/tests/testabtpackagemanager.rb (rev 0) +++ src/trunk/tests/testabtpackagemanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,134 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtpackagemanager.rb +# +# Unit testing for AbtPackageManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtPackageManager < Test::Unit::TestCase + + $verbose = false; # quiets testing output. + + ## + # setup method for testing AbtPackageManager. + ## + def setup + @pkgMgr = AbtPackageManager.new + @manager = AbtPackageManager.new + @system = AbtSystemManager.new + + # ensures download not needed. + FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtPackageManager.test_install_package()' + ## + def test_install_package + if @system.package_installed( "ipc" ) + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + + @manager.remove_package( "ipc" ) + end + + assert( @pkgMgr.install_package( "ipc", $verbose ), "test_install_package()" ) + end + + ## + # Test method for 'AbtPackageManager.test_reinstall_package()' + ## + def test_reinstall_package + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + + assert( @pkgMgr.reinstall_package( "ipc", true ), "test_reinstall_package()" ) + end + + ## + # Test method for 'AbtPackageManager.test_remove_package()' + ## + def test_remove_package + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + + assert( @pkgMgr.remove_package( "ipc" ), "test_remove_package()" ) + end + + ## + # Test method for 'AbtPackageManager.test_downgrade_package()' + ## + def test_downgrade_package + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + if @system.package_frozen( "ipc" ) + @manager.freeze_package( "ipc" ) + end + + assert( @pkgMgr.downgrade_package( "ipc", "1.2" ), "test_downgrade_package()" ) + end + + ## + # Test method for 'AbtPackageManager.test_freeze_package()' + ## + def test_freeze_package + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + if !@system.package_frozen( "ipc" ) + assert( @pkgMgr.freeze_package( "ipc" ), "test_freeze_package()" ) + + # need to return package to initial state, un-frozen. + @pkgMgr.freeze_package( "ipc" ) + else + assert( true ) + end + end + +end Copied: src/trunk/tests/testabtqueuemanager.rb (from rev 450, src/trunk/testabtqueuemanager.rb) =================================================================== --- src/trunk/tests/testabtqueuemanager.rb (rev 0) +++ src/trunk/tests/testabtqueuemanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,58 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtqueuemanager.rb +# +# Unit testing for AbtQueueManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtQueueManager < Test::Unit::TestCase + + ## + # setup method for testing AbtQueueManager. + ## + def setup + @queue = AbtQueueManager.new + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtQueueManager.action_package_queue()' + ## + def test_action_package_queue + assert( @queue.action_package_queue( "ipc", "install", "add" ), "test_action_package_queue(add)" ) + assert( @queue.action_package_queue( "ipc", "install" ), "test_action_package_queue(default add again)" ) + assert( @queue.action_package_queue( "ipc", "install", "remove" ), "test_action_package_queue(remove)" ) + + end + +end Copied: src/trunk/tests/testabtreportmanager.rb (from rev 450, src/trunk/testabtreportmanager.rb) =================================================================== --- src/trunk/tests/testabtreportmanager.rb (rev 0) +++ src/trunk/tests/testabtreportmanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,171 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtreportmanager.rb +# +# Unit testing for AbtReportManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtReportManager < Test::Unit::TestCase + + ## + # setup method for testing AbtReportManager. + ## + def setup + @report = AbtReportManager.new + @manager = AbtPackageManager.new + @system = AbtSystemManager.new + + # ensure tarball available without downloading. + FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + # TODO: if test package frozen, unfreeze it. + end + + ## + # Test method for 'AbtReportManager.test_show_package_details()' + ## + def test_show_package_details + assert( @report.show_package_details( "ipc" ), "test_show_package_details()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_installed_packages()' + ## + def test_show_installed_packages + # ensure test pacakge installed for listing. + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert_nil( @report.show_installed_packages(), "test_show_installed_packages()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_package_log()' + ## + def test_show_package_log + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @report.show_package_log( "ipc", "install" ), "test_show_package_log(install)" ) + assert( @report.show_package_log( "ipc", "build" ), "test_show_package_log(build)" ) + assert( @report.show_package_log( "ipc", "integrity" ), "test_show_package_log(integrity)" ) + end + + ## + # Test method for 'AbtReportManager.test_show_frozen_packages()' + ## + def test_show_frozen_packages + # ensure test package installed. + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + # ensure test package freeze. + if !@system.package_frozen( "ipc" ) + @manager.freeze_package "ipc" + end + + assert( @report.show_frozen_packages(), "test_show_frozen_packages()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_package_dependencies()' + ## + def test_show_package_dependencies + assert( false, "test_show_package_dependencies()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_untracked_files()' + ## + def test_show_untracked_files + assert( @report.show_untracked_files(), "test_show_untracked_files()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_journal()' + ## + def test_show_journal + assert( @report.show_journal( $JOURNAL ), "test_show_journal()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_file_owner()' + ## + def test_show_file_owner + # ensure package installed for testing file owner. + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @report.show_file_owner( "ipcFile" ), "test_show_file_owner()" ) + end + + ## + # Test method for 'AbtReportManager.test_search_package_descriptions()' + ## + def test_search_package_descriptions + expectedHash = Hash[ "ipc-1.4" => "IPC is a program that calculates the isotopic distribution of a given chemical formula."] + + assert_equal( @report.search_package_descriptions( "ipc" ), expectedHash, "test_search_package_descriptions()" ) + end + + ## + # Test method for 'AbtReportManager.test_show_queue()' + ## + def test_show_queue + assert_nil( @report.show_queue( "install" ), "test_show_queue(install)" ) + end + + ## + # Test method for 'AbtReportManager.test_show_updates()' + ## + def test_show_updates + assert( @report.show_updates( "ipc" ), "test_show_updates()" ) + end + + ## + # Test method for 'AbtReportManager.test_generate_HTML_package_listing()' + ## + def test_generate_HTML_package_listing + # ensure at least one package is installed. + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @report.generate_HTML_package_listing(), "test_generate_HTML_package_listing()" ) + end + +end Copied: src/trunk/tests/testabtsystemmanager.rb (from rev 450, src/trunk/testabtsystemmanager.rb) =================================================================== --- src/trunk/tests/testabtsystemmanager.rb (rev 0) +++ src/trunk/tests/testabtsystemmanager.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,136 @@ +#!/usr/bin/ruby -w + +$LOAD_PATH.unshift '../' + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtconfig' + +## +# testabtsystemmanager.rb +# +# Unit testing for AbtSystemManager class. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class TestAbtSystemManager < Test::Unit::TestCase + + ## + # setup method for testing AbtSystemManager. + ## + def setup + @system = AbtSystemManager.new + @manager = AbtPackageManager.new + + # ensure tarball availabe without downloading. + FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtSystemManager.test_cleanup_package_sources()' + ## + def test_cleanup_package_sources + # remove test package so that sources can be removed. + if @system.package_installed( "ipc" ) + @manager.remove_package( "ipc" ) + end + + # ensure tarball availabe without downloading. + FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) + + assert( @system.cleanup_package_sources(), "test_cleanup_package_sources()" ) + end + + ## + # Test method for 'AbtSystemManager.test_verify_installed_files()' + ## + def test_verify_installed_files + # ensure test package installed. + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @system.verify_installed_files( "ipc" ), "test_verify_installed_files()" ) + end + + ## + # Test method for 'AbtSystemManager.test_verify_symlinks()' + ## + def test_verify_symlinks + assert( @system.verify_symlinks( "dummy" ), "test_verify_symlinks()" ) + end + + ## + # Test method for 'AbtSystemManager.test_verify_package_depends()' + ## + def test_verify_package_depends + assert( @system.verify_package_depends( "dummy" ), "test_verify_package_depends()" ) + end + + ## + # Test method for 'AbtSystemManager.test_verify_package_integrity()' + ## + def test_verify_package_integrity + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @system.verify_package_integrity( "ipc" ), "test_verify_package_integrity()" ) + end + + ## + # Test method for 'AbtSystemManager.test_fix_package()' + ## + def test_fix_package + assert( @system.fix_package( "dummy" ), "test_fix_package()" ) + end + + ## + # Test method for 'AbtSystemManager.test_set_central_repo()' + ## + def test_set_central_repo + assert( @system.set_central_repo( "http://localhost" ), "test_set_central_repo()" ) + end + + ## + # Test method for 'AbtSystemManager.test_set_package_tree_location()' + ## + def test_set_package_tree_location + assert( @system.set_package_tree_location( "/var/lib/ericsPackages" ), "test_set_package_tree_location()" ) + end + + ## + # Test method for 'AbtSystemManager.test_package_installed()' + ## + def test_package_installed + if !@system.package_installed( "ipc" ) + @manager.install_package( "ipc" ) + end + + assert( @system.package_installed( "ipc" ), "test_package_installed()" ) + end + +end Copied: src/trunk/tests/testsuiteabt.rb (from rev 450, src/trunk/testsuiteabt.rb) =================================================================== --- src/trunk/tests/testsuiteabt.rb (rev 0) +++ src/trunk/tests/testsuiteabt.rb 2007-12-31 12:49:44 UTC (rev 454) @@ -0,0 +1,30 @@ +#!/usr/bin/ruby -w + +if ( Process.uid != 0 ) + puts "Enter root password:" + system( 'su -c ./testsuiteabt.rb root' ) + exit +end + +$LOAD_PATH.unshift '../' + +require 'test/unit' +require 'abtconfig' + +# By ensuring an install of the test package ipc +# is done prior to running unit tests, we are able +# to ensure that all needed directories, logs, etc +# are created prior to running the tests. If ipc is +# already installed, this process is not repleated. +# +# This speeds up the test suit by more than 10 sec +# on my machine. I get avg runs of around 17,5 sec. +# +require 'testabtpackagemanager' +require 'testabtlogmanager' +require 'testabtdownloadmanager' +require 'testabtpackage' +require 'testabtqueuemanager' +require 'testabtreportmanager' +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-12-31 12:54:09
|
Revision: 459 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=459&view=rev Author: eschabell Date: 2007-12-31 04:54:11 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Completes move of tests into apart test directory. Removed Paths: ------------- 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/testsuiteabt.rb Deleted: src/trunk/testabtdepengine.rb =================================================================== --- src/trunk/testabtdepengine.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtdepengine.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,53 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtdepengine.rb -# -# Unit testing for AbtDepEngine class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtDepEngine < Test::Unit::TestCase - - ## - # setup method for testing AbtDepEngine. - ## - def setup - @depEngine = AbtDepEngine.new - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtDepEngine.test_dep_engine()' - ## - def test_dep_engine - assert_equal( false, true, "test_dep_engine()" ) - end - -end Deleted: src/trunk/testabtdownloadmanager.rb =================================================================== --- src/trunk/testabtdownloadmanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtdownloadmanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,95 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtdownloadmanager.rb -# -# Unit testing for AbtDownloadManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtDownloadManager < Test::Unit::TestCase - - ## - # setup method for testing AbtDownloadManager. - ## - def setup - @download = AbtDownloadManager.new - @manager = AbtPackageManager.new - @system = AbtSystemManager.new - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtDownloadManager.test_retrieve_package_source()' - ## - def test_retrieve_package_source() - # ensures download not needed. - FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - - assert( @download.retrieve_package_source( "ipc", "#{$SOURCES_REPOSITORY}" ), "test_retrieve_package_source()" ) - end - - ## - # Test method for 'AbtDownloadManager.test_retrieve_package_tree()' - ## - def test_retrieve_package_tree() - assert( @download.retrieve_package_tree( "dummy" ), "test_retrieve_package_tree()" ) - end - - ## - # Test method for 'AbtDownloadManager.test_retrieve_news_feed()' - ## - def test_retrieve_news_feed() - assert( @download.retrieve_news_feed( $ABTNEWS ), "test_retrieve_news_feed()" ) - end - - ## - # Test method for 'AbtDownloadManager.test_update_package()' - ## - def test_update_package() - assert( @download.update_package( "ipc") , "test_update_package()" ) - end - - ## - # Test method for 'AbtDownloadManager.test_update_package_tree()' - ## - def test_update_package_tree() - assert( @download.update_package_tree(), "test_update_package_tree()" ) - end - - ## - # Test method for 'AbtDownloadManager.test_validated()' - ## - def test_validated() - # ensure a tarball is available to test! - FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - - assert( @download.validated( 'e81278607b1d65dcb18c3613ec00fbf588b50319', "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ), "test_validated" ) - end -end Deleted: src/trunk/testabtlogmanager.rb =================================================================== --- src/trunk/testabtlogmanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtlogmanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,108 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtlogmanager.rb -# -# Unit testing for AbtLogManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtLogManager < Test::Unit::TestCase - - ## - # setup method for testing AbtLogManager. - ## - def setup - @logger = AbtLogManager.new - @manager = AbtPackageManager.new - @system = AbtSystemManager.new - - # ensures download not needed. - FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - FileUtils.rm( "#{$ABT_TMP}/ipc-1.4.watch" ) if File.exist?( "#{$ABT_TMP}/ipc-1.2.watch" ) - end - - ## - # Test method for 'AbtLogManager.test_log_package_integrity()' - ## - def test_log_package_integrity() - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @logger.log_package_integrity( "ipc" ), "test_log_package_integrity()" ) - end - - ## - # Test method for 'AbtLogManager.test_log_package_install()' - ## - def test_log_package_install() - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - # fill installwatch file. - File.open( "#{$ABT_TMP}/ipc-1.4.watch", "w" ) do |file| - file.puts "5 open /usr/local/bin/ipc #success" - file.puts "0 chmod /usr/local/bin/ipc 00600 #success" - file.puts "0 chown /usr/local/bin/ipc -1 -1 #success" - file.puts "0 chmod /usr/local/bin/ipc 00755 #success" - file.puts "5 open /usr/local/share/ipc/elemente #success" - file.puts "0 chmod /usr/local/share/ipc/elemente 00600 #success" - file.puts "0 chown /usr/local/share/ipc/elemente -1 -1 #success" - file.puts "0 chmod /usr/local/share/ipc/elemente 00644 #success" - end - - assert( @logger.log_package_install( "ipc" ), "test_log_package_install()" ) - end - - ## - # Test method for 'AbtLogManager.test_log_package_build()' - ## - def test_log_package_build() - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @logger.log_package_build( "ipc" ), "test_log_package_build()" ) - end - - ## - # Test method for 'AbtLogManager.test_cache_package()' - ## - def test_cache_package() - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @logger.cache_package( "ipc" ), "test_cache_package()" ) - end - -end Deleted: src/trunk/testabtpackage.rb =================================================================== --- src/trunk/testabtpackage.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtpackage.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,144 +0,0 @@ -#!/usr/bin/ruby -w - -require "test/unit/testcase" -require "test/unit/autorunner" -require "abtconfig" -require "#{$PACKAGE_PATH}ipc" - -## -# testabtpackage.rb -# -# Unit testing for AbtPackage class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtPackage < Test::Unit::TestCase - - $nameTest = "Ipc" - $versionTest = "1.4" - $verbose = false - $srcDirTest = "#{$nameTest.downcase}-#{$versionTest}" - - $dataTest = { - 'name' => $nameTest, - 'execName' => $nameTest.downcase, - 'version' => $versionTest, - 'srcDir' => $srcDirTest, - 'homepage' => "http://isotopatcalc.sourceforge.net/" - } - - ## - # setup method for testing AbtPackage. - ## - def setup - @ipc = Ipc.new - - # ensures download not needed. - FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist? "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - FileUtils.rm_r "#{$BUILD_LOCATION}/#{$dataTest['srcDir']}", :verbose => true if File.exist? "#{$BUILD_LOCATION}/#{$dataTest['srcDir']}" - end - - ## - # Test method for 'AbtPackage.test_details()' - ## - def test_details - assert_equal( $dataTest['name'], @ipc.details['Package name'], "test_details(name)" ) - assert_equal( $dataTest['execName'], @ipc.details['Executable'], "test_details(execName)" ) - assert_equal( $dataTest['version'], @ipc.details['Version'], "test_details(version)" ) - assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], "test_details(srcDir)" ) - assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], "test_details(homepage)" ) - end - - ## - # Test method for 'AbtPackage.test_pre()' - ## - def test_pre - assert( @ipc.pre( $verbose ), "test_pre()" ) - end - - ## - # Test method for 'AbtPackage.test_configure()' - ## - def test_configure - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "test_configure(pre)" ) - end - assert( @ipc.configure( $verbose ), "test_configure(configure)" ) - end - - ## - # Test method for 'AbtPackage.test_build()' - ## - def test_build - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "test_build(pre)" ) - end - if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "test_build(configure)" ) - end - assert( @ipc.build( $verbose ), "test_build(build)" ) - end - - ## - # Test method for 'AbtPackage.test_preinstall()' - ## - def test_preinstall - assert( @ipc.preinstall( $verbose ), "test_preinstall()" ) - end - - ## - # Test method for 'AbtPackage.test_install()' - ## - def test_install - - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "test_install(pre)" ) - end - if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "test_install(configure)" ) - end - if ( !@ipc.build( $verbose ) ) - assert_equals( true, false, "test_install(build)" ) - end - if ( !@ipc.preinstall( $verbose ) ) - assert_equals( true, false, "test_install(install)" ) - end - assert( @ipc.install( $verbose ), "test_install(install)" ) - end - - ## - # Test method for 'AbtPackage.test_post()' - ## - def test_post - assert_equals( true, false, "test_post(pre)" ) if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "test_post(configure)" ) if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "test_post(build)" ) if ( !@ipc.build( $verbose ) ) - assert_equals( true, false, "test_post(preinstall)" ) if ( !@ipc.preinstall( $verbose ) ) - assert_equals( true, false, "test_post(install)" ) if ( !@ipc.install( $verbose ) ) - assert( @ipc.post( $verbose ), "test_post(post)" ) - end - -end Deleted: src/trunk/testabtpackagemanager.rb =================================================================== --- src/trunk/testabtpackagemanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtpackagemanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,132 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtpackagemanager.rb -# -# Unit testing for AbtPackageManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtPackageManager < Test::Unit::TestCase - - $verbose = false; # quiets testing output. - - ## - # setup method for testing AbtPackageManager. - ## - def setup - @pkgMgr = AbtPackageManager.new - @manager = AbtPackageManager.new - @system = AbtSystemManager.new - - # ensures download not needed. - FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtPackageManager.test_install_package()' - ## - def test_install_package - if @system.package_installed( "ipc" ) - - if @system.package_frozen( "ipc" ) - @manager.freeze_package( "ipc" ) - end - - @manager.remove_package( "ipc" ) - end - - assert( @pkgMgr.install_package( "ipc", $verbose ), "test_install_package()" ) - end - - ## - # Test method for 'AbtPackageManager.test_reinstall_package()' - ## - def test_reinstall_package - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - if @system.package_frozen( "ipc" ) - @manager.freeze_package( "ipc" ) - end - - assert( @pkgMgr.reinstall_package( "ipc", true ), "test_reinstall_package()" ) - end - - ## - # Test method for 'AbtPackageManager.test_remove_package()' - ## - def test_remove_package - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - if @system.package_frozen( "ipc" ) - @manager.freeze_package( "ipc" ) - end - - assert( @pkgMgr.remove_package( "ipc" ), "test_remove_package()" ) - end - - ## - # Test method for 'AbtPackageManager.test_downgrade_package()' - ## - def test_downgrade_package - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - if @system.package_frozen( "ipc" ) - @manager.freeze_package( "ipc" ) - end - - assert( @pkgMgr.downgrade_package( "ipc", "1.2" ), "test_downgrade_package()" ) - end - - ## - # Test method for 'AbtPackageManager.test_freeze_package()' - ## - def test_freeze_package - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - if !@system.package_frozen( "ipc" ) - assert( @pkgMgr.freeze_package( "ipc" ), "test_freeze_package()" ) - - # need to return package to initial state, un-frozen. - @pkgMgr.freeze_package( "ipc" ) - else - assert( true ) - end - end - -end Deleted: src/trunk/testabtqueuemanager.rb =================================================================== --- src/trunk/testabtqueuemanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtqueuemanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,56 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtqueuemanager.rb -# -# Unit testing for AbtQueueManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtQueueManager < Test::Unit::TestCase - - ## - # setup method for testing AbtQueueManager. - ## - def setup - @queue = AbtQueueManager.new - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtQueueManager.action_package_queue()' - ## - def test_action_package_queue - assert( @queue.action_package_queue( "ipc", "install", "add" ), "test_action_package_queue(add)" ) - assert( @queue.action_package_queue( "ipc", "install" ), "test_action_package_queue(default add again)" ) - assert( @queue.action_package_queue( "ipc", "install", "remove" ), "test_action_package_queue(remove)" ) - - end - -end Deleted: src/trunk/testabtreportmanager.rb =================================================================== --- src/trunk/testabtreportmanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtreportmanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,169 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtreportmanager.rb -# -# Unit testing for AbtReportManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtReportManager < Test::Unit::TestCase - - ## - # setup method for testing AbtReportManager. - ## - def setup - @report = AbtReportManager.new - @manager = AbtPackageManager.new - @system = AbtSystemManager.new - - # ensure tarball available without downloading. - FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - # TODO: if test package frozen, unfreeze it. - end - - ## - # Test method for 'AbtReportManager.test_show_package_details()' - ## - def test_show_package_details - assert( @report.show_package_details( "ipc" ), "test_show_package_details()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_installed_packages()' - ## - def test_show_installed_packages - # ensure test pacakge installed for listing. - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert_nil( @report.show_installed_packages(), "test_show_installed_packages()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_package_log()' - ## - def test_show_package_log - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @report.show_package_log( "ipc", "install" ), "test_show_package_log(install)" ) - assert( @report.show_package_log( "ipc", "build" ), "test_show_package_log(build)" ) - assert( @report.show_package_log( "ipc", "integrity" ), "test_show_package_log(integrity)" ) - end - - ## - # Test method for 'AbtReportManager.test_show_frozen_packages()' - ## - def test_show_frozen_packages - # ensure test package installed. - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - # ensure test package freeze. - if !@system.package_frozen( "ipc" ) - @manager.freeze_package "ipc" - end - - assert( @report.show_frozen_packages(), "test_show_frozen_packages()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_package_dependencies()' - ## - def test_show_package_dependencies - assert( false, "test_show_package_dependencies()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_untracked_files()' - ## - def test_show_untracked_files - assert( @report.show_untracked_files(), "test_show_untracked_files()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_journal()' - ## - def test_show_journal - assert( @report.show_journal( $JOURNAL ), "test_show_journal()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_file_owner()' - ## - def test_show_file_owner - # ensure package installed for testing file owner. - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @report.show_file_owner( "ipcFile" ), "test_show_file_owner()" ) - end - - ## - # Test method for 'AbtReportManager.test_search_package_descriptions()' - ## - def test_search_package_descriptions - expectedHash = Hash[ "ipc-1.4" => "IPC is a program that calculates the isotopic distribution of a given chemical formula."] - - assert_equal( @report.search_package_descriptions( "ipc" ), expectedHash, "test_search_package_descriptions()" ) - end - - ## - # Test method for 'AbtReportManager.test_show_queue()' - ## - def test_show_queue - assert_nil( @report.show_queue( "install" ), "test_show_queue(install)" ) - end - - ## - # Test method for 'AbtReportManager.test_show_updates()' - ## - def test_show_updates - assert( @report.show_updates( "ipc" ), "test_show_updates()" ) - end - - ## - # Test method for 'AbtReportManager.test_generate_HTML_package_listing()' - ## - def test_generate_HTML_package_listing - # ensure at least one package is installed. - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @report.generate_HTML_package_listing(), "test_generate_HTML_package_listing()" ) - end - -end Deleted: src/trunk/testabtsystemmanager.rb =================================================================== --- src/trunk/testabtsystemmanager.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testabtsystemmanager.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,134 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' - -## -# testabtsystemmanager.rb -# -# Unit testing for AbtSystemManager class. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class TestAbtSystemManager < Test::Unit::TestCase - - ## - # setup method for testing AbtSystemManager. - ## - def setup - @system = AbtSystemManager.new - @manager = AbtPackageManager.new - - # ensure tarball availabe without downloading. - FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtSystemManager.test_cleanup_package_sources()' - ## - def test_cleanup_package_sources - # remove test package so that sources can be removed. - if @system.package_installed( "ipc" ) - @manager.remove_package( "ipc" ) - end - - # ensure tarball availabe without downloading. - FileUtils.cp( "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true ) if !File.exist?( "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz" ) - - assert( @system.cleanup_package_sources(), "test_cleanup_package_sources()" ) - end - - ## - # Test method for 'AbtSystemManager.test_verify_installed_files()' - ## - def test_verify_installed_files - # ensure test package installed. - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @system.verify_installed_files( "ipc" ), "test_verify_installed_files()" ) - end - - ## - # Test method for 'AbtSystemManager.test_verify_symlinks()' - ## - def test_verify_symlinks - assert( @system.verify_symlinks( "dummy" ), "test_verify_symlinks()" ) - end - - ## - # Test method for 'AbtSystemManager.test_verify_package_depends()' - ## - def test_verify_package_depends - assert( @system.verify_package_depends( "dummy" ), "test_verify_package_depends()" ) - end - - ## - # Test method for 'AbtSystemManager.test_verify_package_integrity()' - ## - def test_verify_package_integrity - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @system.verify_package_integrity( "ipc" ), "test_verify_package_integrity()" ) - end - - ## - # Test method for 'AbtSystemManager.test_fix_package()' - ## - def test_fix_package - assert( @system.fix_package( "dummy" ), "test_fix_package()" ) - end - - ## - # Test method for 'AbtSystemManager.test_set_central_repo()' - ## - def test_set_central_repo - assert( @system.set_central_repo( "http://localhost" ), "test_set_central_repo()" ) - end - - ## - # Test method for 'AbtSystemManager.test_set_package_tree_location()' - ## - def test_set_package_tree_location - assert( @system.set_package_tree_location( "/var/lib/ericsPackages" ), "test_set_package_tree_location()" ) - end - - ## - # Test method for 'AbtSystemManager.test_package_installed()' - ## - def test_package_installed - if !@system.package_installed( "ipc" ) - @manager.install_package( "ipc" ) - end - - assert( @system.package_installed( "ipc" ), "test_package_installed()" ) - end - -end Deleted: src/trunk/testsuiteabt.rb =================================================================== --- src/trunk/testsuiteabt.rb 2007-12-31 12:53:26 UTC (rev 458) +++ src/trunk/testsuiteabt.rb 2007-12-31 12:54:11 UTC (rev 459) @@ -1,28 +0,0 @@ -#!/usr/bin/ruby -w - -if ( Process.uid != 0 ) - puts "Enter root password:" - system( 'su -c ./testsuiteabt.rb root' ) - exit -end - -require 'test/unit' -require 'abtconfig' - -# By ensuring an install of the test package ipc -# is done prior to running unit tests, we are able -# to ensure that all needed directories, logs, etc -# are created prior to running the tests. If ipc is -# already installed, this process is not repleated. -# -# This speeds up the test suit by more than 10 sec -# on my machine. I get avg runs of around 17,5 sec. -# -require 'testabtpackagemanager' -require 'testabtlogmanager' -require 'testabtdownloadmanager' -require 'testabtpackage' -require 'testabtqueuemanager' -require 'testabtreportmanager' -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-12-31 14:01:18
|
Revision: 460 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=460&view=rev Author: eschabell Date: 2007-12-31 06:01:22 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Moved core class libs into libs directory, this facilitates installations. Added Paths: ----------- src/trunk/libs/ src/trunk/libs/abtdepengine.rb src/trunk/libs/abtdownloadmanager.rb src/trunk/libs/abtlogmanager.rb src/trunk/libs/abtpackage.rb src/trunk/libs/abtpackagemanager.rb src/trunk/libs/abtqueuemanager.rb src/trunk/libs/abtreportmanager.rb src/trunk/libs/abtsystemmanager.rb src/trunk/libs/abtusage.rb Copied: src/trunk/libs/abtdepengine.rb (from rev 459, src/trunk/abtdepengine.rb) =================================================================== --- src/trunk/libs/abtdepengine.rb (rev 0) +++ src/trunk/libs/abtdepengine.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,45 @@ +#!/usr/bin/ruby -w + +## +# abtdepengine.rb +# +# AbtDepEngine class handles all dependency aspects of the AbTLinux system. It is +# part of a sub-project with it's own requirements document. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtDepEngine + + protected + + private + + public + + ## + # Constructor for the AbtDepEngine class. + # + # <b>RETURN</b> <i>AbtDepEngine</i> - an initialized AbtDepEngine object. + ## + def initialize + # TODO: implement this. + end + +end Copied: src/trunk/libs/abtdownloadmanager.rb (from rev 459, src/trunk/abtdownloadmanager.rb) =================================================================== --- src/trunk/libs/abtdownloadmanager.rb (rev 0) +++ src/trunk/libs/abtdownloadmanager.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,260 @@ +#!/usr/bin/ruby -w + +## +# abtdownloadmanager.rb +# +# AbtDownloadManager class handles all downloading of components needed for +# AbTLinux. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtDownloadManager + + protected + + private + + public + + ## + # Constructor for the AbtDownloadManager class. + # + # <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. + # + # <b>PARAM</b> <i>String</i> - the name of the package for which the source + # is to be downloaded. + # <b>PARAM</b> <i>String</i> - the path to the download destination. + # + # <b>RETURN</b> <i>boolean</i> - True if the package source has been + # downloaded, otherwise false. + ## + def retrieve_package_source( packageName, destination ) + require "#{$PACKAGE_PATH}#{packageName}" + logger = Logger.new($JOURNAL) + package = eval( packageName.capitalize + '.new' ) + + if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) + logger.info( "Download not needed, existing source found for #{packageName}" ) + return true + end + + Dir.chdir( destination ) + if ( system( "wget #{package.srcUrl}" ) ) + logger.info( "Download completed for #{packageName}" ) + return true + end + + return false # download failed. + end + + ## + # Downloads a given pacakge tree. + # + # <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. + ## + def retrieve_package_tree( packageTreeName="AbTLinux" ) + logger = Logger.new($JOURNAL) + + # check if package tree exists. + if File.directory?( $PACKAGE_PATH ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + logger.info "Package tree #{packageTreeName} already installed." + return true + else + # package directory exists, but is not a valid tree. + logger.error "Package tree exists, but is not valid svn tree." + return false + end + + else + + # pacakge directory does not exist, svn co. + if system( "svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}" ) + logger.info "Package tree installed (svn co)" + else + logger.error "Package tree not installed (svn co), problems!" + return false + end + + end + + return true + end + + ## + # Retrieves the given feed and displays the news items. + # + # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. + # <b>PARAM</b> <i>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 retrieve_news_feed( uri, cleanLog=true ) + require 'net/http' + require 'uri' + require 'rss/1.0' + require 'rss/2.0' + newsLog = "" + logger = Logger.new( $JOURNAL) + + # ensure we have our news logfile. + if ( cleanLog ) + newsLog = File.new( $ABTNEWS_LOG, "w+" ) + else + newsLog = File.new( $ABTNEWS_LOG, "a+" ) + end + + # pick up the abtlinux.org news feed. + if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) + logger.info( "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.info( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) + return false + else + newsLog << "*** #{rss.channel.title} ***\n" + + rss.items.each_with_index do |item, itemCount| + itemCount += 1 + newsLog << "#{itemCount} #{item.link} #{item.title}\n" + end + end + + newsLog << "\n\n" + newsLog.close + return true + + end + + ## + # Updates a given package with available patches (version updates). + # + # <b>PARAM</b> <i>String</i> - the name of the package to be updated. + # + # <b>RETURN</b> <i>boolean</i> - True if the given package has been updated, + # otherwise false. + ## + def update_package( packageName ) + logger = Logger.new($JOURNAL) + + # check if package exists in tree. + if File.exists?( "#{$PACKAGE_PATH}/#{packageName}.rb" ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + if system( "svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb" ) + logger.info "Package #{packageName.downcase} updated (svn update)" + else + logger.error "Package #{packageName.downcase} unable to update (svn update)." + return false + end + else + # package exists, but not an valid tree. + logger.error "Package #{packageName} exists, but not valid package tree (svn)." + return false + end + else + # package does not exist. + logger.error "Package is not installed, not possible to update!" + return false + end + + return true + end + + ## + # Updates the package tree. + # + # <b>PARAM</b> <i>String</i> - the name of the tree to be updated, defaults to AbTLinux repo. + # + # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, + # otherwise false. + ## + def update_package_tree( packageTreeName="AbTLinux" ) + logger = Logger.new($JOURNAL) + + # check if package tree exists. + if File.directory?( $PACKAGE_PATH ) + # check if svn directory. + if File.directory?( "#{$PACKAGE_PATH}.svn" ) + if system( "svn update #{$PACKAGE_PATH}" ) + logger.info "Package tree updated (svn update)" + else + logger.error "Package tree unable to update (svn update)." + return false + end + else + # package directory exists, but is not a valid tree. + logger.error "Package tree exists, but is not valid svn tree." + return false + end + else + # package directory does not exist. + logger.error "Package tree not installed!" + return false + end + + return true + end + + ## + # Validates the sources based on package hash value. + # + # <b>PARAM</b> <i>String</i> - security hash value from the packages description. + # <b>PARAM</b> <i>String</i> - source tarball location to be checked. + # + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. + ## + def validated( hashvalue, path ) + logger = Logger.new( $JOURNAL ) + + if hashvalue == Digest::SHA1.hexdigest( path ) + puts "Source hash validated successfully..." + logger.info( "Validated sources successfully..." ) + return true + end + + puts "Source hash failed validation..." + logger.info( "Validating sources failed..." ) + return false + end +end Copied: src/trunk/libs/abtlogmanager.rb (from rev 459, src/trunk/abtlogmanager.rb) =================================================================== --- src/trunk/libs/abtlogmanager.rb (rev 0) +++ src/trunk/libs/abtlogmanager.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,285 @@ +#!/usr/bin/ruby -w + +## +# abtlogmanager.rb +# +# AbtLogManager class handles all aspects of logging and access to existing logs +# within the AbTLinux system. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtLogManager + + protected + + private + + public + + ## + # 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 get_log( package, type ) + require "#{$PACKAGE_PATH}#{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" + + when 'configure' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.configure" + + else + log = "" + + end + + return log + end + + ## + # Constructor for the AbtLogManager. It ensures all needed logs paths are + # initialized. + # + # + # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. + ## + def initialize + logger = Logger.new( $JOURNAL ) + [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, $ABT_LIBS, + $PACKAGE_CACHED, $ABT_TMP, $ABT_CONFIG, $ABT_LOCAL_CONFIG, $SOURCES_REPOSITORY].each { |dir| + + if ( ! File.directory?( dir ) ) + FileUtils.mkdir_p( dir ) + logger.info( "Created directory: #{dir}." ) + end + } + 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 log_package_integrity( package ) + + # our log locations. + installLog = get_log( package, 'install' ) + integrityLog = get_log( package, '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 << "#{line.chomp}:#{octal}\n" + 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. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if install log created successfully, + # otherwise false. + ## + def log_package_install( package ) + # some dirs we will not add to an install log. + excluded_pattern = Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) + badLine = false # used to mark excluded lines from installwatch log. + + # our log locations. + installLog = get_log( package, 'install' ) + tmpInstallLog = get_log( package, 'tmpinstall' ) + + # get the installed files from the tmp file + # into our install log. + if ( File.exist?( tmpInstallLog ) ) + installFile = open( installLog, 'w') + + # include only the file names from open calls + # and not part of the excluded range of directories. + IO.foreach( tmpInstallLog ) do |line| + if ( line.split[1] == 'open' ) + if ( line.split[2] =~ excluded_pattern ) + badLine = true + else + badLine = false + end + + if ( !badLine ) + installFile << "#{line.split[2]}\n" + end + end + end + + installFile.close + else + # no tmp install file, thus no install running. + return false + end + + return true; + end + + ## + # Provides logging of all output produced during the build phase of the + # given package. Should be called as part of the install phase of the build. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if build log created successfully, + # otherwise false. + ## + def log_package_build( package ) + buildLog = get_log( package, 'build' ) + + # make sure the build file exists. + if ( !File.exist?( buildLog ) ) + return false + end + + return true + end + + ## + # Provides a complete log of the given packages build. Includes everything + # needed to duplicate the build at a later date. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if package cache created successfully, + # otherwise false. + ## + def cache_package( package ) + system = AbtSystemManager.new + + if ( system.package_installed( package ) ) + sw = eval( "#{package.capitalize}.new" ) + cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir + sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) + sourceFile = File.basename( sw.srcUrl ) + installLog = get_log( package, 'install' ) + buildLog = get_log( package, 'build' ) + configureLog = get_log( package, 'configure' ) + integrityLog = get_log( package, 'integrity' ) + packageFile = "#{$PACKAGE_PATH}#{package}.rb" + + + FileUtils.mkdir_p( cachedDir ) + + # collect package source. + if ( FileTest::exist?( sourcePath ) ) + FileUtils.copy_file( sourcePath, "#{cachedDir}/#{sourceFile}" ) + puts "\nCaching copy of #{package} source." + else + puts "\nUnable to cache copy of #{package} source." + end + + # collect package install log. + if ( FileTest::exist?( installLog ) ) + FileUtils.copy_file( installLog, "#{cachedDir}/#{sw.srcDir}.install" ) + puts "\nCaching copy of #{package} install log." + else + puts "\nUnable to cache copy of #{package} install log." + end + + # collect package build log. + if ( FileTest::exist?( buildLog ) ) + FileUtils.copy_file( buildLog, "#{cachedDir}/#{sw.srcDir}.build" ) + puts "\nCaching copy of #{package} build log." + else + puts "\nUnable to cache copy of #{package} build log." + end + + # collect package configure log. + if ( FileTest::exist?( configureLog ) ) + FileUtils.copy_file( configureLog, "#{cachedDir}/#{sw.srcDir}.configure" ) + puts "\nCaching copy of #{package} configure log." + else + puts "\nUnable to cache copy of #{package} configure log." + end + + # collect package integrity log. + if ( FileTest::exist?( integrityLog ) ) + FileUtils.copy_file( integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity" ) + puts "\nCaching copy of #{package} integrity log." + else + puts "\nUnable to cache copy of #{package} integrity log." + end + + # collect package description (class file). + if ( FileTest::exist?( packageFile ) ) + FileUtils.copy_file( packageFile, "#{cachedDir}/#{package}.rb" ) + puts "\nCaching copy of #{package} package description." + else + puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" + end + + # tar and bzip this directory (package-cache-version.tar.bz2) + Dir.chdir( $PACKAGE_CACHED ) + if ( system( "tar -cf #{sw.srcDir}.tar #{sw.srcDir}" ) && + system( "bzip2 -f #{sw.srcDir}.tar" ) ) + # last but not least, remove our tarball directory + FileUtils.rm_rf( cachedDir ) + return true + end + end + + return false # package not installed, can't cache it. + end + +end Copied: src/trunk/libs/abtpackage.rb (from rev 459, src/trunk/abtpackage.rb) =================================================================== --- src/trunk/libs/abtpackage.rb (rev 0) +++ src/trunk/libs/abtpackage.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,377 @@ +#!/usr/bin/ruby -w + +## +# 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. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtPackage + + protected + + ## + # Unpacks this packages source file into the standard build location. + # + # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, + # otherwise false. + ## + def unpack_sources + srcFile = File.basename( @srcUrl ) + sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" + unpackTool = "" + + # check for existing file in source repo. + if ( !File.exist?( sourcesToUnpack ) ) + return false + end + + # check if possible existing sources in build directory. + if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) + return true + end + + # determine which supported compression used [gz, tar, tgz, bz2, zip]. + compressionType = srcFile.split( '.' ) + + case compressionType.last + + when "gz" + unpackTool = "tar xzvf" + + when "tar" + unpackTool = "tar xvf" + + when "bz2" + unpackTool = "tar xjvf" + + when "tgz" + unpackTool = "tar xzvf" + + when "zip" + unpackTool = "unizp" + + else + # unsupported format. + return false + end + + Dir.chdir( $BUILD_LOCATION ) + if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) + return false + end + + return true + end + + private + + public + + # the name of the package. + attr_reader :name + + # the executable name for the package. + attr_reader :execName + + # the package version number. + attr_reader :version + + # the source directory for the package. + attr_reader :srcDir + + # the packages homepage. + attr_reader :homepage + + # the URL where this packages sources can be obtained. + attr_reader :srcUrl + + # list of dependsOn (DO) related package dependencies. + attr_reader :dependsOn + + # list of reliesOn (RO) related package dependencies. + attr_reader :reliesOn + + # list of optional reliesOn (oRO) related package dependencies. + attr_reader :optionalDO + + # list of optional dependsOn (oDO) related package dependencies. + attr_reader :optionalRO + + # security hash value of package sources. + attr_reader :hashCheck + + # list of available patches for this package. + attr_reader :patches + + # security hash value of this packages patches. + attr_reader :patchesHashCheck + + # available mirrors for this package. + attr_reader :mirrorPath + + # type of license this package has. + attr_reader :licence + + # the package description. + attr_reader :description + + + ## + # Constructor for an AbtPackage, requires all the packge details. + # + # <b>PARAM</b> <i>Hash</i> - hash containing all package data. + # + ## + def initialize( data ) + @name = data['name'] + @execName = data['execName'] + @version = data['version'] + @srcDir = data['srcDir'] + @homepage = data['homepage'] + @srcUrl = data['srcUrl'] + @dependsOn = data['dependsOn'] + @reliesOn = data['reliesOn'] + @optionalDO = data['optionalDO'] + @optionalRO = data['optionalRO'] + @hashCheck = data['hashCheck'] + @patches = data['patches'] + @patchesHashCheck = data['patchesHashCheck'] + @mirrorPath = data['mirrorPath'] + @license = data['license'] + @description = data['description'] + end + + ## + # Provides all the data needed for this AbtPackage. + # + # <b>RETURNS:</b> <i>hash</i> - Contains all AbtPackage + # attributes (constants). + ## + def details + return { + "Package name" => @name, + "Executable" => @execName, + "Version" => @version, + "Source location" => @srcDir, + "Homepage" => @homepage, + "Source uri" => @srcUrl, + "Depends On" => @dependsOn, + "Relies On" => @reliesOn, + "Optional DO" => @optionalDO, + "Optional RO" => @optionalRO, + "Security hash" => @hashCheck, + "Patches" => @patches, + "Patches hash" => @patchesHashCheck, + "Mirror" => @mirrorPath, + "License" => @license, + "Description" => @description + } + end + + ## + # 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( verbose=true ) + downloader = AbtDownloadManager.new + + # download sources. + if ( !downloader.retrieve_package_source( @name.downcase, $SOURCES_REPOSITORY ) ) + return false + end + + # validate sources sha1. + if ( !downloader.validated( @hashCheck, "#{$SOURCES_REPOSITORY}/#{File.basename( @srcUrl )}" ) ) + return false + end + + # unpack sources. + if ( !unpack_sources ) + return false + end + + # ensure we have an installed directory to use. + if ( ! File.directory?( "#{$PACKAGE_INSTALLED}/#{@srcDir}" ) ) + FileUtils.mkdir_p( "#{$PACKAGE_INSTALLED}/#{@srcDir}" ) + end + + # 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. + # + # <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( 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( command ) ) + puts "[AbtPackage.configure] - configure section failed." + return false + end + + puts "[AbtPackage.configure] - configure section completed!" if (verbose ) + return true + end + + ## + # 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( 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( command ) ) + puts "[AbtPackage.build] - build section failed." + return false + end + + puts "[AbtPackage.build] - build section completed!" if ( verbose ) + return true + end + + ## + # Any actions needed before the installation can occur will happen here, + # such as creating new user accounts, dealing with existing configuration + # files, etc. + # + # <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( verbose=true ) + # TODO: preinstall section create_group? + # TODO: preinstall section create_user? + return true; + end + + ## + # 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( 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( command ) ) + puts "[AbtPackage.install] - install section failed." + return false + end + + puts "[AbtPackage.install] - install section completed!" if ( verbose ) + return true + end + + ## + # 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( verbose=true ) + # 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. + ## + def remove_build + puts "Removings build..." + if ( $REMOVE_BUILD_SOURCES ) + buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" + + if ( !File.directory?( buildSourcesLocation ) ) + return true + end + + if ( !FileUtils.rm_rf buildSourcesLocation, :verbose => true ) + return false + end + end + + return true + end +end Copied: src/trunk/libs/abtpackagemanager.rb (from rev 459, src/trunk/abtpackagemanager.rb) =================================================================== --- src/trunk/libs/abtpackagemanager.rb (rev 0) +++ src/trunk/libs/abtpackagemanager.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,425 @@ +#!/usr/bin/ruby -w + +## +# abtpackagemanager.rb +# +# AbtPackageManager class will take care of the installation, removal, updating, +# downgrading and freezing of AbTLinux software packages. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtPackageManager + + protected + + 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 roll_back( 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 ) + if ( File.file?( line.chomp ) ) + File.delete( line.chomp ) + end + end + file.close + + # cleanup install log as it is incomplete. + File.delete( logFile ) + else + return false + end + + return true + end + + + public + + ## + # Constructor for AbtPackageManager. + # + # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized + # AbtPackageManager object. + ## + def initialize + end + + ## + # 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 install_package( package, verbose=true ) + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + queuer = AbtQueueManager.new + logger = Logger.new( $JOURNAL ) + system = AbtSystemManager.new + + # TODO: refactor myLogger: + myLogger = AbtLogManager.new + + # get package details. + details = sw.details + + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with install package call." + puts "\nPackage #{package} is frozen, can not proceed with install package call." + return false + end + + # TODO: check deps + + # add to install queue. + puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) + + if ( !queuer.action_package_queue( package, "install", "add" ) ) + logger.info( "Failed to add #{package} to install queue." ) + return false + end + + # pre section. + puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) + + if ( !sw.pre ) + logger.info( "Failed to process pre-section in the package description of #{package}." ) + return false + else + logger.info( "Finished #{package} pre section." ) + end + + # configure section. + puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) + + if ( !sw.configure( verbose ) ) + logger.info( "Failed to process configure section in the package description of #{package}." ) + return false + else + logger.info( "Finished #{package} configure section." ) + end + + # build section. + puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) + + if ( !sw.build( verbose ) ) + logger.info( "Failed to process build section in the package description of #{package}." ) + return false + else + if ( !myLogger.log_package_build( sw.name.downcase ) ) + logger.info( "Failed to create a package build log." ) + return false + end + logger.info( "Finished #{package} build section." ) + end + + # preinstall section. + puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) + + if ( !sw.preinstall ) + logger.info( "Failed to process preinstall section in the package description of #{package}." ) + return false + else + logger.info( "Finished #{package} preinstall section." ) + end + + # install section. + puts "\n*** Processing the INSTALL section for #{package}. ***" if ( verbose ) + + if ( !sw.install ) + # rollback installed files if any and remove install log. + logger.info( "Failed to process install section in the package description of #{package}." ) + myLogger.log_package_install( sw.name.downcase ) + logger.info( "***Starting rollback of #{package} install and removing install log." ) + roll_back( "install", details ) + return false + else + myLogger.log_package_install( sw.name.downcase ) + myLogger.log_package_integrity( sw.name.downcase ) + + # cleanup tmp files from installwatch. + File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) + + logger.info( "Finished #{package} install section." ) + end + + # post section. + puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) + + if ( !sw.post ) + logger.info( "Failed to process post section in the package description of #{package}." ) + return false + else + logger.info( "Finished #{package} post section." ) + end + + # clean out build sources. + puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) + + if ( !sw.remove_build ) + logger.info( "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.action_package_queue( sw.name.downcase, "install", "remove" ) ) + logger.info( "Failed to remove #{sw.name.downcase} from install queue." ) + end + + return true # install completed! + end + + # TODO: add install_cached_package( package ) + + ## + # Reinstalls a given package. + # + # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. + # <b>PARAM</b> <i>Boolean</i> - query the user if false (default), otherwise true and skip query. + # + # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, + # otherwise false. + ## + def reinstall_package( package, automated_build=false ) + logger = Logger.new( $JOURNAL ) + # TODO: look into refactoring myLogger: + myLogger = AbtLogManager.new + system = AbtSystemManager.new + + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with reinstall package call." + puts "\nPackage #{package} is frozen, can not proceed with reinstall package call." + return false + end + + # check if already installed. + if ( system.package_installed( package ) ) + + if !automated_build + puts "\n*** Package #{package} is already installed! ***\n" + puts "Are you sure you want to proceed with a reinstall? (y/n)" + + while answer = STDIN.gets + answer.chomp! + if answer == "y" + break + elsif answer == "n" + exit + else + puts "Are you sure you want to reinstall #{package}? (y/n)" + end + end + end + else + puts "\n*** Package #{package} is not installed, we will install it for you now! ***\n" + puts "Hit enter to continue..." + while continue = STDIN.gets + continue.chomp! + break + end + end + + if ( install_package( package ) ) + puts "\n\n" + puts "*** Completed reinstall of #{package}. ***" + puts "\n\n" + logger.info( "Completed reinstall of #{package}." ) + + if ( myLogger.cache_package( package ) ) + puts "\n\n" + puts "*** Completed caching of package #{package}. ***" + puts "\n\n" + logger.info( "Caching completed for package #{package}." ) + return true + else + logger.info( "Caching of package #{package} failed.") + end + end + + return false + end + + ## + # Removes a given package. + # + # <b>PARAM</b> <i>String</i> - the name of the package to be removed. + # + # <b>RETURN</b> <i>boolean</i> - True if the package is removed, otherwise + # false. + ## + def remove_package( package ) + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + # TODO: refactor myLogger. + myLogger = AbtLogManager.new + logger = Logger.new( $JOURNAL ) + system = AbtSystemManager.new + + # get package details. + details = sw.details + + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with remove package call." + puts "\nPackage #{package} is frozen, can not proceed with remove package call." + return false + end + + # TODO: something with possible /etc or other configure files before removal, check maybe integrity for changes since install? + + # remove listings in install log. + installLog = myLogger.get_log( package, 'install' ) + + # only process install log if it exists, continue on with + # journal log warning. + if File.exist?( installLog ) + IO.foreach( installLog ) do |line| + if File.exist?( line.chomp ) + FileUtils.rm( line.chomp ) + logger.info( "Removed file #{line.chomp} from #{package} install log.") + else + logger.info( "Unable to remove #{line.chomp} from #{package} install log, does not exist.") + # do not return false, removed is ok, just put warning in journal log. + end + end + + logger.info( "Removed files from #{File.basename( installLog )} for #{package}." ) + else + puts "Install log missing for #{package}, see journal..." + logger.info( "Install log was missing for #{package}..." ) + logger.info( "...continuing to remove package from install listing, but might have files still installed on system." ) + end + + + # remove entry in install listing. + FileUtils.remove_dir( "#{$PACKAGE_INSTALLED}/#{details['Source location']}" ) + logger.info( "Removed entry from installed packages." ) + return true + end + + ## + # Downgrades a given package. + # + # <b>PARAM</b> <i>String</i> - the name of the package to be downgraded. + # + # <b>PARAM</b> <i>String</i> - the version number to be downgraded to. + # + # <b>RETURN</b> <i>boolean</i> - True if the package is downgraded, otherwise + # false. + ## + def downgrade_package( package, version ) + system = AbtSystemManager.new + logger = Logger.new( $JOURNAL ) + + # check for frozen. + if ( system.package_frozen( package ) ) + logger.info "Package #{package} is frozen, can not proceed with downgrade package call." + puts "\nPackage #{package} is frozen, can not proceed with downgrade package call." + return false + end + + return false + end + + ## + # Freezes a given package. If successful will add give package to the frozen + # list. If the given package is already frozen, it will be released. + # + # <b>PARAM</b> <i>String</i> - the name of the package to be frozen. + # + # <b>RETURN</b> <i>boolean</i> - True if the package is frozen, otherwise + # false. + ## + def freeze_package( package ) + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + myLogger = AbtLogManager.new # TODO: refactor myLogger. + logger = Logger.new( $JOURNAL ) + system = AbtSystemManager.new + + if ( system.package_installed( package ) ) + if ( system.package_frozen( package ) ) + logger.info( "Package #{package} is already frozen!" ) + + # package already frozen, need to un-freeze by removing frozen.log + # file. + FileUtils.rm "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" + puts "\nPackage #{package} was frozen, it has now been relased for use." + logger.info "Package #{package} released : removed file #{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" + else + # place file in $PACKAGE_INSTALLED frozen.log with date. + frozen = File.open( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log", "w" ) + frozen.puts "#{$TIMESTAMP}" + frozen.close + logger.info( "Package #{package} is now frozen." ) + end + + return true + end + + logger.info( "Package #{package} is not installed, unable to freeze it." ) + return false + end + + ## + # Provides for a log through for root access using su. + # + # <b>PARAM</b> <i>Array</i> - the arguments passed to abt. + # + # <b>RETURN</b> <i>void</i> + ## + def root_login( arguments ) + if ( Process.uid != 0 ) + args = "" + puts "\nYou need to be root for accessing the requested functionality.\n" + puts "\nEnter root password:" + + for i in 0...ARGV.length + args = args + " " + ARGV[i] + end + + system( 'su -c "./abt ' + args + '" root' ) + exit + end + end +end Copied: src/trunk/libs/abtqueuemanager.rb (from rev 459, src/trunk/abtqueuemanager.rb) =================================================================== --- src/trunk/libs/abtqueuemanager.rb (rev 0) +++ src/trunk/libs/abtqueuemanager.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,113 @@ +#!/usr/bin/ruby -w + +## +# abtqueuemanager.rb +# +# AbtQueueManager class handles all AbTLinux queue interaction. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtQueueManager + + protected + + private + + public + + ## + # Constructor for the AbtQueueManager class. + # + # <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 + # be added twice and return succes. + # + # <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 action succeeds, otherwise false. + ## + def action_package_queue( package, queue, action="add" ) + require 'fileutils' + logger = Logger.new( $JOURNAL ) + 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 + + 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.info( "Added #{package} to #{queue} queue." ) + else + logger.info( "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 ) ) + # 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.info( "Failed to open #{queueFile}." ) + return false + end +end Copied: src/trunk/libs/abtreportmanager.rb (from rev 459, src/trunk/abtreportmanager.rb) =================================================================== --- src/trunk/libs/abtreportmanager.rb (rev 0) +++ src/trunk/libs/abtreportmanager.rb 2007-12-31 14:01:22 UTC (rev 460) @@ -0,0 +1,338 @@ +#!/usr/bin/ruby -w + +## +# abtreportmanager.rb +# +# AbtReportManager class handles all sort of report and query generation within +# the AbTLinux system. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright 2006, GPL. +# +# This file is part of AbTLinux. +# +# AbTLinux is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# details. +# +# You should have received a copy of the GNU General Public License along with +# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin +# St, Fifth Floor, Boston, MA 02110-1301 USA +## +class AbtReportManager + + protected + + private + + public + + ## + # Constructor for the AbtReportManager. + # + # <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. + ## + def show_package_details( package ) + require "#{$PACKAGE_PATH}#{package}" + + if ( package = eval( "#{package.capitalize}.new" ) ) + details = package.details + + puts "|=====================================" + puts "| Package name\t: #{details['Package name']}" + details.delete( "Package name" ) + puts "| Version\t: #{details['Version']}" + details.delete( "Version" ) + puts "| Homepage\t: #{details['Homepage']}" + details.delete( "Homepage" ) + puts "| Executable\t: #{details['Executable']}" + details.delete( "Executable" ) + puts "| Source uri\t: #{details['Source uri']}" + details.delete( "Source uri" ) + puts "| Description\t: #{details['Description']}" + details.delete( "Description" ) + puts "|=====================================" + puts "|=====================================" + + details.each do |name, value| + print "| #{name}\t" + + if ( name.length < 14 ) + print "\t" + end + + puts ": #{value}" + end + + puts "|=====================================" + return true + end + + logger.debug( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) + return false + end + + ## + # Display all packages installed and tracked by AbTLinux. + # + # <b>RETURN</b> <i>void.</i> + ## + def show_installed_packages + if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? + puts "\nNo AbTLinux packages are listed as installed, is your #{$PACKAGE_INSTALLED} empty?\n\n" + else + puts "\nInstalled AbTLinux packages:" + puts "============================" + Dir.foreach( $PACKAGE_INSTALLED ) { |package| puts package if package != "." && package != ".." } + puts "\n" + end + end + + ## + # Display the contents of the requested log for a given package. Possible + # log types are; configure, install, build and integrity. This method will return nothing + # if the package log is not installed. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>PARAM</b> <i>String</i> - log type. + # + # <b>RETURN</b> <i>void.</i> + ## + def show_package_log( package, logType ) + system = AbtSystemManager.new + logger = AbtLogManager.new + + # just return if package not installed, up to + # caller to message the user about why. + if !system.package_installed( package ) + return + end + + File.open( logger.get_log( package, logType ) ).each { |line| puts line } + end + + ## + # Display a list of the packages found in the frozen list. + # + # <b>RETURN</b> <i>hash</i> - a hash of the frozen packages, keys are package + # names and values are the frozen timestamps. + ## + def show_frozen_packages + + # determine if there are frozen pacakges. + frozenHash = Hash.new # has for values found. + + if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? + return Hash.new # empty hash, no entries. + else + Dir.foreach( $PACKAGE_INSTALLED ) { |package| + if ( package != "." && package != "..") + # split the installed entry into two parts, + # the package name and the version number. + #packageArray = package.split( "-" ) + #packageName = packageArray[0] + + # check for frozen log file. + if ( File.exist?( "#{$PACKAGE_INSTALLED}/#{package}/frozen.log" ) ) + # dump packgae + frozen.log timestamp in packageHash. + begin + file = File.new("#{$PACKAGE_INSTALLED}/#{package}/frozen.log", "r") + #while (line = file.gets) + line = file.gets + frozenHash = frozenHash.merge( Hash[ "#{package}" => "#{line}" ] ) + #end + file.close + rescue => error + puts "Exception: #{error}" + return false + end + end + end + } + end + + return frozenHash + end + + ## + # Provides access to dependency checking via the AbTLinux DepEngine. (This + # portal to the DepEngine will be expanded in apart sub-project, more + # details at a later date.) + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise + # hash of problem files and their encountered errors. + ## + def show_package_dependencies( package ) + # TODO: implement this. + return false + end + + ## + # Display all files not part of any installed AbTLinux package. This + # delivers a list of files that are not tracked by AbTLinux package + # management. + # + # <b>RETURN</b> <i>void.</i> + ## + def show_untracked_files + # TODO: implement this. + return false + end + + ## + # Display the AbTLinux journal file. + # + # <b> PARAM</b> <i>string</i> The complete path of the file to display. + # + # <b>RETURN</b> <i>iboolean</i> True if journal shown, otherwise false. + ## + def show_journal( fileName ) + if ( File.exist?( fileName ) ) + puts "\n\n" + puts "AbTLinux log:" + puts "=============" + log = IO.readlines( fileName ) + log.each{ |entry| puts entry } + puts "\n\n" + else + puts "\n\n" + puts "AbtLinux log ( #{File.basename( fileName )} ) " + + "is empty at this time." + puts "\n\n" + end + + return true + end + + ## + # Display the name of the package(s) that own the given file. + # + # <b>PARAM</b> <i>String</i> - a file name. + # + # <b>RETURN</b> <i>void.</i> + ## + def show_file_owner( file ) + # TODO: implement this. + return false + end + + ## + # Searches the installed package trees package descriptions for matching + # occurrances of the given search text. + # + # <b>PARAM</b> <i>String</i> - a search text. + # + # <b>RETURN</b> <i>hash</i> - a hash of the search results, keys are package + # names and values are matching descriptions. + ## + def search_package_descriptions( searchText ) + packageHash = Hash.new # has for values found. + + if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? + return packageHash # empty hash, no entries. + else + Dir.foreach( $PACKAGE_INSTALLED ) { |package| + if ( package != "." && package != "..") + # split the installed entry into two parts, + # the package name and the version number. + packageArray = package.split( "-" ) + packageName = packageArray[0] + + # check for match to name and description if the package file exists. + if ( File.exist?( "#{$PACKAGE_PATH}#{packageName}.rb" ) ) + require "#{$PACKAGE_PATH}#{packageName}" + sw = eval( "#{packageName.capitalize}.new" ) + + # add if matches name or description entries. + matchesArray = sw.description.scan( searchText ) + matchesArray = matchesArray.concat( packageName.scan( searchText ) ) + + if ( matchesArray.length > 0 ) + # matches so add to hash. + packageHash = packageHash.merge( Hash[ "#{package}" => "#{sw.description}" ] ) + end + end + end + } + end + + # finished search results. + return packageHash + end + + ## + # Displays the contents of the current queue based on the given queue. + # + # <b>PARAM</b> <i>String</i> - the type of queue to display such as install + # queue. + # + # <b>RETURN</b> <i>void.</i> + ## + def show_queue( queueType ) + + case queueType + + when "install" + if ( File.exist?( "#{$ABT_LOGS}/#{queueType}.queue" ) ) + puts "\n\n" + puts "AbTLinux #{queueType} queue:" + puts "=======================" + queue = IO.readlines( "#{$ABT_LOGS}/#{queueType}.queue" ) + queue.each{ |entry| puts entry } + puts "\n\n" + else + puts "\n\n" + puts "AbtLinux #{queueType} is empty at this time." + puts "\n\n" + end + else + puts "#{queueType.capitalize} is not an AbTLinux queue." + end + end + + ## + # Reports available updates for a given package or package tree based on the + # current system. + # + # <b>PARAM</b> <i>String</i> - the target of the update check, either a + # package name or a package tree name. + # + # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise + # false. + ## + def show_updates( target ) + # TODO: implement this. + return false + end + + ## + # Generates an HTML page of installed packages from installed packages list. + # + # <b>RETURN</b> <i>void.</i> + ## + def generate_HTML_package_listing + # TODO: implement ... [truncated message content] |
From: <esc...@us...> - 2007-12-31 14:27:12
|
Revision: 467 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=467&view=rev Author: eschabell Date: 2007-12-31 06:27:06 -0800 (Mon, 31 Dec 2007) Log Message: ----------- This completes the libs move. Removed Paths: ------------- src/trunk/abtdepengine.rb src/trunk/abtdownloadmanager.rb src/trunk/abtlogmanager.rb src/trunk/abtpackage.rb src/trunk/abtpackagemanager.rb src/trunk/abtqueuemanager.rb src/trunk/abtreportmanager.rb src/trunk/abtsystemmanager.rb src/trunk/abtusage.rb Deleted: src/trunk/abtdepengine.rb =================================================================== --- src/trunk/abtdepengine.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtdepengine.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,45 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtdepengine.rb -# -# AbtDepEngine class handles all dependency aspects of the AbTLinux system. It is -# part of a sub-project with it's own requirements document. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtDepEngine - - protected - - private - - public - - ## - # Constructor for the AbtDepEngine class. - # - # <b>RETURN</b> <i>AbtDepEngine</i> - an initialized AbtDepEngine object. - ## - def initialize - # TODO: implement this. - end - -end Deleted: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtdownloadmanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,260 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtdownloadmanager.rb -# -# AbtDownloadManager class handles all downloading of components needed for -# AbTLinux. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtDownloadManager - - protected - - private - - public - - ## - # Constructor for the AbtDownloadManager class. - # - # <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. - # - # <b>PARAM</b> <i>String</i> - the name of the package for which the source - # is to be downloaded. - # <b>PARAM</b> <i>String</i> - the path to the download destination. - # - # <b>RETURN</b> <i>boolean</i> - True if the package source has been - # downloaded, otherwise false. - ## - def retrieve_package_source( packageName, destination ) - require "#{$PACKAGE_PATH}#{packageName}" - logger = Logger.new($JOURNAL) - package = eval( packageName.capitalize + '.new' ) - - if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) - logger.info( "Download not needed, existing source found for #{packageName}" ) - return true - end - - Dir.chdir( destination ) - if ( system( "wget #{package.srcUrl}" ) ) - logger.info( "Download completed for #{packageName}" ) - return true - end - - return false # download failed. - end - - ## - # Downloads a given pacakge tree. - # - # <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. - ## - def retrieve_package_tree( packageTreeName="AbTLinux" ) - logger = Logger.new($JOURNAL) - - # check if package tree exists. - if File.directory?( $PACKAGE_PATH ) - # check if svn directory. - if File.directory?( "#{$PACKAGE_PATH}.svn" ) - logger.info "Package tree #{packageTreeName} already installed." - return true - else - # package directory exists, but is not a valid tree. - logger.error "Package tree exists, but is not valid svn tree." - return false - end - - else - - # pacakge directory does not exist, svn co. - if system( "svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}" ) - logger.info "Package tree installed (svn co)" - else - logger.error "Package tree not installed (svn co), problems!" - return false - end - - end - - return true - end - - ## - # Retrieves the given feed and displays the news items. - # - # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>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 retrieve_news_feed( uri, cleanLog=true ) - require 'net/http' - require 'uri' - require 'rss/1.0' - require 'rss/2.0' - newsLog = "" - logger = Logger.new( $JOURNAL) - - # ensure we have our news logfile. - if ( cleanLog ) - newsLog = File.new( $ABTNEWS_LOG, "w+" ) - else - newsLog = File.new( $ABTNEWS_LOG, "a+" ) - end - - # pick up the abtlinux.org news feed. - if ( !news = Net::HTTP.get( URI.parse( uri ) ) ) - logger.info( "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.info( "Failed to display news feed as feed #{uri} is not RSS 1.0/2.0." ) - return false - else - newsLog << "*** #{rss.channel.title} ***\n" - - rss.items.each_with_index do |item, itemCount| - itemCount += 1 - newsLog << "#{itemCount} #{item.link} #{item.title}\n" - end - end - - newsLog << "\n\n" - newsLog.close - return true - - end - - ## - # Updates a given package with available patches (version updates). - # - # <b>PARAM</b> <i>String</i> - the name of the package to be updated. - # - # <b>RETURN</b> <i>boolean</i> - True if the given package has been updated, - # otherwise false. - ## - def update_package( packageName ) - logger = Logger.new($JOURNAL) - - # check if package exists in tree. - if File.exists?( "#{$PACKAGE_PATH}/#{packageName}.rb" ) - # check if svn directory. - if File.directory?( "#{$PACKAGE_PATH}.svn" ) - if system( "svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb" ) - logger.info "Package #{packageName.downcase} updated (svn update)" - else - logger.error "Package #{packageName.downcase} unable to update (svn update)." - return false - end - else - # package exists, but not an valid tree. - logger.error "Package #{packageName} exists, but not valid package tree (svn)." - return false - end - else - # package does not exist. - logger.error "Package is not installed, not possible to update!" - return false - end - - return true - end - - ## - # Updates the package tree. - # - # <b>PARAM</b> <i>String</i> - the name of the tree to be updated, defaults to AbTLinux repo. - # - # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, - # otherwise false. - ## - def update_package_tree( packageTreeName="AbTLinux" ) - logger = Logger.new($JOURNAL) - - # check if package tree exists. - if File.directory?( $PACKAGE_PATH ) - # check if svn directory. - if File.directory?( "#{$PACKAGE_PATH}.svn" ) - if system( "svn update #{$PACKAGE_PATH}" ) - logger.info "Package tree updated (svn update)" - else - logger.error "Package tree unable to update (svn update)." - return false - end - else - # package directory exists, but is not a valid tree. - logger.error "Package tree exists, but is not valid svn tree." - return false - end - else - # package directory does not exist. - logger.error "Package tree not installed!" - return false - end - - return true - end - - ## - # Validates the sources based on package hash value. - # - # <b>PARAM</b> <i>String</i> - security hash value from the packages description. - # <b>PARAM</b> <i>String</i> - source tarball location to be checked. - # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, - # otherwise false. - ## - def validated( hashvalue, path ) - logger = Logger.new( $JOURNAL ) - - if hashvalue == Digest::SHA1.hexdigest( path ) - puts "Source hash validated successfully..." - logger.info( "Validated sources successfully..." ) - return true - end - - puts "Source hash failed validation..." - logger.info( "Validating sources failed..." ) - return false - end -end Deleted: src/trunk/abtlogmanager.rb =================================================================== --- src/trunk/abtlogmanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtlogmanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,285 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtlogmanager.rb -# -# AbtLogManager class handles all aspects of logging and access to existing logs -# within the AbTLinux system. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtLogManager - - protected - - private - - public - - ## - # 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 get_log( package, type ) - require "#{$PACKAGE_PATH}#{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" - - when 'configure' - log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/#{details['Source location']}.configure" - - else - log = "" - - end - - return log - end - - ## - # Constructor for the AbtLogManager. It ensures all needed logs paths are - # initialized. - # - # - # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. - ## - def initialize - logger = Logger.new( $JOURNAL ) - [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, $ABT_LIBS, - $PACKAGE_CACHED, $ABT_TMP, $ABT_CONFIG, $ABT_LOCAL_CONFIG, $SOURCES_REPOSITORY].each { |dir| - - if ( ! File.directory?( dir ) ) - FileUtils.mkdir_p( dir ) - logger.info( "Created directory: #{dir}." ) - end - } - 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 log_package_integrity( package ) - - # our log locations. - installLog = get_log( package, 'install' ) - integrityLog = get_log( package, '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 << "#{line.chomp}:#{octal}\n" - 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. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if install log created successfully, - # otherwise false. - ## - def log_package_install( package ) - # some dirs we will not add to an install log. - excluded_pattern = Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) - badLine = false # used to mark excluded lines from installwatch log. - - # our log locations. - installLog = get_log( package, 'install' ) - tmpInstallLog = get_log( package, 'tmpinstall' ) - - # get the installed files from the tmp file - # into our install log. - if ( File.exist?( tmpInstallLog ) ) - installFile = open( installLog, 'w') - - # include only the file names from open calls - # and not part of the excluded range of directories. - IO.foreach( tmpInstallLog ) do |line| - if ( line.split[1] == 'open' ) - if ( line.split[2] =~ excluded_pattern ) - badLine = true - else - badLine = false - end - - if ( !badLine ) - installFile << "#{line.split[2]}\n" - end - end - end - - installFile.close - else - # no tmp install file, thus no install running. - return false - end - - return true; - end - - ## - # Provides logging of all output produced during the build phase of the - # given package. Should be called as part of the install phase of the build. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if build log created successfully, - # otherwise false. - ## - def log_package_build( package ) - buildLog = get_log( package, 'build' ) - - # make sure the build file exists. - if ( !File.exist?( buildLog ) ) - return false - end - - return true - end - - ## - # Provides a complete log of the given packages build. Includes everything - # needed to duplicate the build at a later date. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if package cache created successfully, - # otherwise false. - ## - def cache_package( package ) - system = AbtSystemManager.new - - if ( system.package_installed( package ) ) - sw = eval( "#{package.capitalize}.new" ) - cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir - sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) - sourceFile = File.basename( sw.srcUrl ) - installLog = get_log( package, 'install' ) - buildLog = get_log( package, 'build' ) - configureLog = get_log( package, 'configure' ) - integrityLog = get_log( package, 'integrity' ) - packageFile = "#{$PACKAGE_PATH}#{package}.rb" - - - FileUtils.mkdir_p( cachedDir ) - - # collect package source. - if ( FileTest::exist?( sourcePath ) ) - FileUtils.copy_file( sourcePath, "#{cachedDir}/#{sourceFile}" ) - puts "\nCaching copy of #{package} source." - else - puts "\nUnable to cache copy of #{package} source." - end - - # collect package install log. - if ( FileTest::exist?( installLog ) ) - FileUtils.copy_file( installLog, "#{cachedDir}/#{sw.srcDir}.install" ) - puts "\nCaching copy of #{package} install log." - else - puts "\nUnable to cache copy of #{package} install log." - end - - # collect package build log. - if ( FileTest::exist?( buildLog ) ) - FileUtils.copy_file( buildLog, "#{cachedDir}/#{sw.srcDir}.build" ) - puts "\nCaching copy of #{package} build log." - else - puts "\nUnable to cache copy of #{package} build log." - end - - # collect package configure log. - if ( FileTest::exist?( configureLog ) ) - FileUtils.copy_file( configureLog, "#{cachedDir}/#{sw.srcDir}.configure" ) - puts "\nCaching copy of #{package} configure log." - else - puts "\nUnable to cache copy of #{package} configure log." - end - - # collect package integrity log. - if ( FileTest::exist?( integrityLog ) ) - FileUtils.copy_file( integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity" ) - puts "\nCaching copy of #{package} integrity log." - else - puts "\nUnable to cache copy of #{package} integrity log." - end - - # collect package description (class file). - if ( FileTest::exist?( packageFile ) ) - FileUtils.copy_file( packageFile, "#{cachedDir}/#{package}.rb" ) - puts "\nCaching copy of #{package} package description." - else - puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" - end - - # tar and bzip this directory (package-cache-version.tar.bz2) - Dir.chdir( $PACKAGE_CACHED ) - if ( system( "tar -cf #{sw.srcDir}.tar #{sw.srcDir}" ) && - system( "bzip2 -f #{sw.srcDir}.tar" ) ) - # last but not least, remove our tarball directory - FileUtils.rm_rf( cachedDir ) - return true - end - end - - return false # package not installed, can't cache it. - end - -end Deleted: src/trunk/abtpackage.rb =================================================================== --- src/trunk/abtpackage.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtpackage.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,377 +0,0 @@ -#!/usr/bin/ruby -w - -## -# 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. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtPackage - - protected - - ## - # Unpacks this packages source file into the standard build location. - # - # <b>RETURNS:</b> <i>boolean</i> - True if the completes sucessfully, - # otherwise false. - ## - def unpack_sources - srcFile = File.basename( @srcUrl ) - sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" - unpackTool = "" - - # check for existing file in source repo. - if ( !File.exist?( sourcesToUnpack ) ) - return false - end - - # check if possible existing sources in build directory. - if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) - return true - end - - # determine which supported compression used [gz, tar, tgz, bz2, zip]. - compressionType = srcFile.split( '.' ) - - case compressionType.last - - when "gz" - unpackTool = "tar xzvf" - - when "tar" - unpackTool = "tar xvf" - - when "bz2" - unpackTool = "tar xjvf" - - when "tgz" - unpackTool = "tar xzvf" - - when "zip" - unpackTool = "unizp" - - else - # unsupported format. - return false - end - - Dir.chdir( $BUILD_LOCATION ) - if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) - return false - end - - return true - end - - private - - public - - # the name of the package. - attr_reader :name - - # the executable name for the package. - attr_reader :execName - - # the package version number. - attr_reader :version - - # the source directory for the package. - attr_reader :srcDir - - # the packages homepage. - attr_reader :homepage - - # the URL where this packages sources can be obtained. - attr_reader :srcUrl - - # list of dependsOn (DO) related package dependencies. - attr_reader :dependsOn - - # list of reliesOn (RO) related package dependencies. - attr_reader :reliesOn - - # list of optional reliesOn (oRO) related package dependencies. - attr_reader :optionalDO - - # list of optional dependsOn (oDO) related package dependencies. - attr_reader :optionalRO - - # security hash value of package sources. - attr_reader :hashCheck - - # list of available patches for this package. - attr_reader :patches - - # security hash value of this packages patches. - attr_reader :patchesHashCheck - - # available mirrors for this package. - attr_reader :mirrorPath - - # type of license this package has. - attr_reader :licence - - # the package description. - attr_reader :description - - - ## - # Constructor for an AbtPackage, requires all the packge details. - # - # <b>PARAM</b> <i>Hash</i> - hash containing all package data. - # - ## - def initialize( data ) - @name = data['name'] - @execName = data['execName'] - @version = data['version'] - @srcDir = data['srcDir'] - @homepage = data['homepage'] - @srcUrl = data['srcUrl'] - @dependsOn = data['dependsOn'] - @reliesOn = data['reliesOn'] - @optionalDO = data['optionalDO'] - @optionalRO = data['optionalRO'] - @hashCheck = data['hashCheck'] - @patches = data['patches'] - @patchesHashCheck = data['patchesHashCheck'] - @mirrorPath = data['mirrorPath'] - @license = data['license'] - @description = data['description'] - end - - ## - # Provides all the data needed for this AbtPackage. - # - # <b>RETURNS:</b> <i>hash</i> - Contains all AbtPackage - # attributes (constants). - ## - def details - return { - "Package name" => @name, - "Executable" => @execName, - "Version" => @version, - "Source location" => @srcDir, - "Homepage" => @homepage, - "Source uri" => @srcUrl, - "Depends On" => @dependsOn, - "Relies On" => @reliesOn, - "Optional DO" => @optionalDO, - "Optional RO" => @optionalRO, - "Security hash" => @hashCheck, - "Patches" => @patches, - "Patches hash" => @patchesHashCheck, - "Mirror" => @mirrorPath, - "License" => @license, - "Description" => @description - } - end - - ## - # 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( verbose=true ) - downloader = AbtDownloadManager.new - - # download sources. - if ( !downloader.retrieve_package_source( @name.downcase, $SOURCES_REPOSITORY ) ) - return false - end - - # validate sources sha1. - if ( !downloader.validated( @hashCheck, "#{$SOURCES_REPOSITORY}/#{File.basename( @srcUrl )}" ) ) - return false - end - - # unpack sources. - if ( !unpack_sources ) - return false - end - - # ensure we have an installed directory to use. - if ( ! File.directory?( "#{$PACKAGE_INSTALLED}/#{@srcDir}" ) ) - FileUtils.mkdir_p( "#{$PACKAGE_INSTALLED}/#{@srcDir}" ) - end - - # 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. - # - # <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( 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( command ) ) - puts "[AbtPackage.configure] - configure section failed." - return false - end - - puts "[AbtPackage.configure] - configure section completed!" if (verbose ) - return true - end - - ## - # 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( 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( command ) ) - puts "[AbtPackage.build] - build section failed." - return false - end - - puts "[AbtPackage.build] - build section completed!" if ( verbose ) - return true - end - - ## - # Any actions needed before the installation can occur will happen here, - # such as creating new user accounts, dealing with existing configuration - # files, etc. - # - # <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( verbose=true ) - # TODO: preinstall section create_group? - # TODO: preinstall section create_user? - return true; - end - - ## - # 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( 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( command ) ) - puts "[AbtPackage.install] - install section failed." - return false - end - - puts "[AbtPackage.install] - install section completed!" if ( verbose ) - return true - end - - ## - # 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( verbose=true ) - # 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. - ## - def remove_build - puts "Removings build..." - if ( $REMOVE_BUILD_SOURCES ) - buildSourcesLocation = "#{$BUILD_LOCATION}/#{srcDir}" - - if ( !File.directory?( buildSourcesLocation ) ) - return true - end - - if ( !FileUtils.rm_rf buildSourcesLocation, :verbose => true ) - return false - end - end - - return true - end -end Deleted: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtpackagemanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,425 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtpackagemanager.rb -# -# AbtPackageManager class will take care of the installation, removal, updating, -# downgrading and freezing of AbTLinux software packages. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtPackageManager - - protected - - 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 roll_back( 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 ) - if ( File.file?( line.chomp ) ) - File.delete( line.chomp ) - end - end - file.close - - # cleanup install log as it is incomplete. - File.delete( logFile ) - else - return false - end - - return true - end - - - public - - ## - # Constructor for AbtPackageManager. - # - # <b>RETURN</b> <i>AbtPackageManager</i> - an initialized - # AbtPackageManager object. - ## - def initialize - end - - ## - # 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 install_package( package, verbose=true ) - require "#{$PACKAGE_PATH}#{package}" - sw = eval( "#{package.capitalize}.new" ) - queuer = AbtQueueManager.new - logger = Logger.new( $JOURNAL ) - system = AbtSystemManager.new - - # TODO: refactor myLogger: - myLogger = AbtLogManager.new - - # get package details. - details = sw.details - - # check for frozen. - if ( system.package_frozen( package ) ) - logger.info "Package #{package} is frozen, can not proceed with install package call." - puts "\nPackage #{package} is frozen, can not proceed with install package call." - return false - end - - # TODO: check deps - - # add to install queue. - puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) - - if ( !queuer.action_package_queue( package, "install", "add" ) ) - logger.info( "Failed to add #{package} to install queue." ) - return false - end - - # pre section. - puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) - - if ( !sw.pre ) - logger.info( "Failed to process pre-section in the package description of #{package}." ) - return false - else - logger.info( "Finished #{package} pre section." ) - end - - # configure section. - puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) - - if ( !sw.configure( verbose ) ) - logger.info( "Failed to process configure section in the package description of #{package}." ) - return false - else - logger.info( "Finished #{package} configure section." ) - end - - # build section. - puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) - - if ( !sw.build( verbose ) ) - logger.info( "Failed to process build section in the package description of #{package}." ) - return false - else - if ( !myLogger.log_package_build( sw.name.downcase ) ) - logger.info( "Failed to create a package build log." ) - return false - end - logger.info( "Finished #{package} build section." ) - end - - # preinstall section. - puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) - - if ( !sw.preinstall ) - logger.info( "Failed to process preinstall section in the package description of #{package}." ) - return false - else - logger.info( "Finished #{package} preinstall section." ) - end - - # install section. - puts "\n*** Processing the INSTALL section for #{package}. ***" if ( verbose ) - - if ( !sw.install ) - # rollback installed files if any and remove install log. - logger.info( "Failed to process install section in the package description of #{package}." ) - myLogger.log_package_install( sw.name.downcase ) - logger.info( "***Starting rollback of #{package} install and removing install log." ) - roll_back( "install", details ) - return false - else - myLogger.log_package_install( sw.name.downcase ) - myLogger.log_package_integrity( sw.name.downcase ) - - # cleanup tmp files from installwatch. - File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) - - logger.info( "Finished #{package} install section." ) - end - - # post section. - puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) - - if ( !sw.post ) - logger.info( "Failed to process post section in the package description of #{package}." ) - return false - else - logger.info( "Finished #{package} post section." ) - end - - # clean out build sources. - puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) - - if ( !sw.remove_build ) - logger.info( "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.action_package_queue( sw.name.downcase, "install", "remove" ) ) - logger.info( "Failed to remove #{sw.name.downcase} from install queue." ) - end - - return true # install completed! - end - - # TODO: add install_cached_package( package ) - - ## - # Reinstalls a given package. - # - # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. - # <b>PARAM</b> <i>Boolean</i> - query the user if false (default), otherwise true and skip query. - # - # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, - # otherwise false. - ## - def reinstall_package( package, automated_build=false ) - logger = Logger.new( $JOURNAL ) - # TODO: look into refactoring myLogger: - myLogger = AbtLogManager.new - system = AbtSystemManager.new - - # check for frozen. - if ( system.package_frozen( package ) ) - logger.info "Package #{package} is frozen, can not proceed with reinstall package call." - puts "\nPackage #{package} is frozen, can not proceed with reinstall package call." - return false - end - - # check if already installed. - if ( system.package_installed( package ) ) - - if !automated_build - puts "\n*** Package #{package} is already installed! ***\n" - puts "Are you sure you want to proceed with a reinstall? (y/n)" - - while answer = STDIN.gets - answer.chomp! - if answer == "y" - break - elsif answer == "n" - exit - else - puts "Are you sure you want to reinstall #{package}? (y/n)" - end - end - end - else - puts "\n*** Package #{package} is not installed, we will install it for you now! ***\n" - puts "Hit enter to continue..." - while continue = STDIN.gets - continue.chomp! - break - end - end - - if ( install_package( package ) ) - puts "\n\n" - puts "*** Completed reinstall of #{package}. ***" - puts "\n\n" - logger.info( "Completed reinstall of #{package}." ) - - if ( myLogger.cache_package( package ) ) - puts "\n\n" - puts "*** Completed caching of package #{package}. ***" - puts "\n\n" - logger.info( "Caching completed for package #{package}." ) - return true - else - logger.info( "Caching of package #{package} failed.") - end - end - - return false - end - - ## - # Removes a given package. - # - # <b>PARAM</b> <i>String</i> - the name of the package to be removed. - # - # <b>RETURN</b> <i>boolean</i> - True if the package is removed, otherwise - # false. - ## - def remove_package( package ) - require "#{$PACKAGE_PATH}#{package}" - sw = eval( "#{package.capitalize}.new" ) - # TODO: refactor myLogger. - myLogger = AbtLogManager.new - logger = Logger.new( $JOURNAL ) - system = AbtSystemManager.new - - # get package details. - details = sw.details - - # check for frozen. - if ( system.package_frozen( package ) ) - logger.info "Package #{package} is frozen, can not proceed with remove package call." - puts "\nPackage #{package} is frozen, can not proceed with remove package call." - return false - end - - # TODO: something with possible /etc or other configure files before removal, check maybe integrity for changes since install? - - # remove listings in install log. - installLog = myLogger.get_log( package, 'install' ) - - # only process install log if it exists, continue on with - # journal log warning. - if File.exist?( installLog ) - IO.foreach( installLog ) do |line| - if File.exist?( line.chomp ) - FileUtils.rm( line.chomp ) - logger.info( "Removed file #{line.chomp} from #{package} install log.") - else - logger.info( "Unable to remove #{line.chomp} from #{package} install log, does not exist.") - # do not return false, removed is ok, just put warning in journal log. - end - end - - logger.info( "Removed files from #{File.basename( installLog )} for #{package}." ) - else - puts "Install log missing for #{package}, see journal..." - logger.info( "Install log was missing for #{package}..." ) - logger.info( "...continuing to remove package from install listing, but might have files still installed on system." ) - end - - - # remove entry in install listing. - FileUtils.remove_dir( "#{$PACKAGE_INSTALLED}/#{details['Source location']}" ) - logger.info( "Removed entry from installed packages." ) - return true - end - - ## - # Downgrades a given package. - # - # <b>PARAM</b> <i>String</i> - the name of the package to be downgraded. - # - # <b>PARAM</b> <i>String</i> - the version number to be downgraded to. - # - # <b>RETURN</b> <i>boolean</i> - True if the package is downgraded, otherwise - # false. - ## - def downgrade_package( package, version ) - system = AbtSystemManager.new - logger = Logger.new( $JOURNAL ) - - # check for frozen. - if ( system.package_frozen( package ) ) - logger.info "Package #{package} is frozen, can not proceed with downgrade package call." - puts "\nPackage #{package} is frozen, can not proceed with downgrade package call." - return false - end - - return false - end - - ## - # Freezes a given package. If successful will add give package to the frozen - # list. If the given package is already frozen, it will be released. - # - # <b>PARAM</b> <i>String</i> - the name of the package to be frozen. - # - # <b>RETURN</b> <i>boolean</i> - True if the package is frozen, otherwise - # false. - ## - def freeze_package( package ) - require "#{$PACKAGE_PATH}#{package}" - sw = eval( "#{package.capitalize}.new" ) - myLogger = AbtLogManager.new # TODO: refactor myLogger. - logger = Logger.new( $JOURNAL ) - system = AbtSystemManager.new - - if ( system.package_installed( package ) ) - if ( system.package_frozen( package ) ) - logger.info( "Package #{package} is already frozen!" ) - - # package already frozen, need to un-freeze by removing frozen.log - # file. - FileUtils.rm "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" - puts "\nPackage #{package} was frozen, it has now been relased for use." - logger.info "Package #{package} released : removed file #{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log" - else - # place file in $PACKAGE_INSTALLED frozen.log with date. - frozen = File.open( "#{$PACKAGE_INSTALLED}/#{sw.srcDir}/frozen.log", "w" ) - frozen.puts "#{$TIMESTAMP}" - frozen.close - logger.info( "Package #{package} is now frozen." ) - end - - return true - end - - logger.info( "Package #{package} is not installed, unable to freeze it." ) - return false - end - - ## - # Provides for a log through for root access using su. - # - # <b>PARAM</b> <i>Array</i> - the arguments passed to abt. - # - # <b>RETURN</b> <i>void</i> - ## - def root_login( arguments ) - if ( Process.uid != 0 ) - args = "" - puts "\nYou need to be root for accessing the requested functionality.\n" - puts "\nEnter root password:" - - for i in 0...ARGV.length - args = args + " " + ARGV[i] - end - - system( 'su -c "./abt ' + args + '" root' ) - exit - end - end -end Deleted: src/trunk/abtqueuemanager.rb =================================================================== --- src/trunk/abtqueuemanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtqueuemanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,113 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtqueuemanager.rb -# -# AbtQueueManager class handles all AbTLinux queue interaction. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtQueueManager - - protected - - private - - public - - ## - # Constructor for the AbtQueueManager class. - # - # <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 - # be added twice and return succes. - # - # <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 action succeeds, otherwise false. - ## - def action_package_queue( package, queue, action="add" ) - require 'fileutils' - logger = Logger.new( $JOURNAL ) - 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 - - 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.info( "Added #{package} to #{queue} queue." ) - else - logger.info( "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 ) ) - # 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.info( "Failed to open #{queueFile}." ) - return false - end -end Deleted: src/trunk/abtreportmanager.rb =================================================================== --- src/trunk/abtreportmanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtreportmanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,338 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtreportmanager.rb -# -# AbtReportManager class handles all sort of report and query generation within -# the AbTLinux system. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright 2006, GPL. -# -# This file is part of AbTLinux. -# -# AbTLinux is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# details. -# -# You should have received a copy of the GNU General Public License along with -# AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin -# St, Fifth Floor, Boston, MA 02110-1301 USA -## -class AbtReportManager - - protected - - private - - public - - ## - # Constructor for the AbtReportManager. - # - # <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. - ## - def show_package_details( package ) - require "#{$PACKAGE_PATH}#{package}" - - if ( package = eval( "#{package.capitalize}.new" ) ) - details = package.details - - puts "|=====================================" - puts "| Package name\t: #{details['Package name']}" - details.delete( "Package name" ) - puts "| Version\t: #{details['Version']}" - details.delete( "Version" ) - puts "| Homepage\t: #{details['Homepage']}" - details.delete( "Homepage" ) - puts "| Executable\t: #{details['Executable']}" - details.delete( "Executable" ) - puts "| Source uri\t: #{details['Source uri']}" - details.delete( "Source uri" ) - puts "| Description\t: #{details['Description']}" - details.delete( "Description" ) - puts "|=====================================" - puts "|=====================================" - - details.each do |name, value| - print "| #{name}\t" - - if ( name.length < 14 ) - print "\t" - end - - puts ": #{value}" - end - - puts "|=====================================" - return true - end - - logger.debug( "[AbtReportManger::showPackageDetails] - failed to show details for ${package}." ) - return false - end - - ## - # Display all packages installed and tracked by AbTLinux. - # - # <b>RETURN</b> <i>void.</i> - ## - def show_installed_packages - if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? - puts "\nNo AbTLinux packages are listed as installed, is your #{$PACKAGE_INSTALLED} empty?\n\n" - else - puts "\nInstalled AbTLinux packages:" - puts "============================" - Dir.foreach( $PACKAGE_INSTALLED ) { |package| puts package if package != "." && package != ".." } - puts "\n" - end - end - - ## - # Display the contents of the requested log for a given package. Possible - # log types are; configure, install, build and integrity. This method will return nothing - # if the package log is not installed. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>PARAM</b> <i>String</i> - log type. - # - # <b>RETURN</b> <i>void.</i> - ## - def show_package_log( package, logType ) - system = AbtSystemManager.new - logger = AbtLogManager.new - - # just return if package not installed, up to - # caller to message the user about why. - if !system.package_installed( package ) - return - end - - File.open( logger.get_log( package, logType ) ).each { |line| puts line } - end - - ## - # Display a list of the packages found in the frozen list. - # - # <b>RETURN</b> <i>hash</i> - a hash of the frozen packages, keys are package - # names and values are the frozen timestamps. - ## - def show_frozen_packages - - # determine if there are frozen pacakges. - frozenHash = Hash.new # has for values found. - - if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? - return Hash.new # empty hash, no entries. - else - Dir.foreach( $PACKAGE_INSTALLED ) { |package| - if ( package != "." && package != "..") - # split the installed entry into two parts, - # the package name and the version number. - #packageArray = package.split( "-" ) - #packageName = packageArray[0] - - # check for frozen log file. - if ( File.exist?( "#{$PACKAGE_INSTALLED}/#{package}/frozen.log" ) ) - # dump packgae + frozen.log timestamp in packageHash. - begin - file = File.new("#{$PACKAGE_INSTALLED}/#{package}/frozen.log", "r") - #while (line = file.gets) - line = file.gets - frozenHash = frozenHash.merge( Hash[ "#{package}" => "#{line}" ] ) - #end - file.close - rescue => error - puts "Exception: #{error}" - return false - end - end - end - } - end - - return frozenHash - end - - ## - # Provides access to dependency checking via the AbTLinux DepEngine. (This - # portal to the DepEngine will be expanded in apart sub-project, more - # details at a later date.) - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise - # hash of problem files and their encountered errors. - ## - def show_package_dependencies( package ) - # TODO: implement this. - return false - end - - ## - # Display all files not part of any installed AbTLinux package. This - # delivers a list of files that are not tracked by AbTLinux package - # management. - # - # <b>RETURN</b> <i>void.</i> - ## - def show_untracked_files - # TODO: implement this. - return false - end - - ## - # Display the AbTLinux journal file. - # - # <b> PARAM</b> <i>string</i> The complete path of the file to display. - # - # <b>RETURN</b> <i>iboolean</i> True if journal shown, otherwise false. - ## - def show_journal( fileName ) - if ( File.exist?( fileName ) ) - puts "\n\n" - puts "AbTLinux log:" - puts "=============" - log = IO.readlines( fileName ) - log.each{ |entry| puts entry } - puts "\n\n" - else - puts "\n\n" - puts "AbtLinux log ( #{File.basename( fileName )} ) " + - "is empty at this time." - puts "\n\n" - end - - return true - end - - ## - # Display the name of the package(s) that own the given file. - # - # <b>PARAM</b> <i>String</i> - a file name. - # - # <b>RETURN</b> <i>void.</i> - ## - def show_file_owner( file ) - # TODO: implement this. - return false - end - - ## - # Searches the installed package trees package descriptions for matching - # occurrances of the given search text. - # - # <b>PARAM</b> <i>String</i> - a search text. - # - # <b>RETURN</b> <i>hash</i> - a hash of the search results, keys are package - # names and values are matching descriptions. - ## - def search_package_descriptions( searchText ) - packageHash = Hash.new # has for values found. - - if ( Dir.entries( $PACKAGE_INSTALLED ) - [ '.', '..' ] ).empty? - return packageHash # empty hash, no entries. - else - Dir.foreach( $PACKAGE_INSTALLED ) { |package| - if ( package != "." && package != "..") - # split the installed entry into two parts, - # the package name and the version number. - packageArray = package.split( "-" ) - packageName = packageArray[0] - - # check for match to name and description if the package file exists. - if ( File.exist?( "#{$PACKAGE_PATH}#{packageName}.rb" ) ) - require "#{$PACKAGE_PATH}#{packageName}" - sw = eval( "#{packageName.capitalize}.new" ) - - # add if matches name or description entries. - matchesArray = sw.description.scan( searchText ) - matchesArray = matchesArray.concat( packageName.scan( searchText ) ) - - if ( matchesArray.length > 0 ) - # matches so add to hash. - packageHash = packageHash.merge( Hash[ "#{package}" => "#{sw.description}" ] ) - end - end - end - } - end - - # finished search results. - return packageHash - end - - ## - # Displays the contents of the current queue based on the given queue. - # - # <b>PARAM</b> <i>String</i> - the type of queue to display such as install - # queue. - # - # <b>RETURN</b> <i>void.</i> - ## - def show_queue( queueType ) - - case queueType - - when "install" - if ( File.exist?( "#{$ABT_LOGS}/#{queueType}.queue" ) ) - puts "\n\n" - puts "AbTLinux #{queueType} queue:" - puts "=======================" - queue = IO.readlines( "#{$ABT_LOGS}/#{queueType}.queue" ) - queue.each{ |entry| puts entry } - puts "\n\n" - else - puts "\n\n" - puts "AbtLinux #{queueType} is empty at this time." - puts "\n\n" - end - else - puts "#{queueType.capitalize} is not an AbTLinux queue." - end - end - - ## - # Reports available updates for a given package or package tree based on the - # current system. - # - # <b>PARAM</b> <i>String</i> - the target of the update check, either a - # package name or a package tree name. - # - # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise - # false. - ## - def show_updates( target ) - # TODO: implement this. - return false - end - - ## - # Generates an HTML page of installed packages from installed packages list. - # - # <b>RETURN</b> <i>void.</i> - ## - def generate_HTML_package_listing - # TODO: implement this. - return false - end -end Deleted: src/trunk/abtsystemmanager.rb =================================================================== --- src/trunk/abtsystemmanager.rb 2007-12-31 14:26:27 UTC (rev 466) +++ src/trunk/abtsystemmanager.rb 2007-12-31 14:27:06 UTC (rev 467) @@ -1,324 +0,0 @@ -#!/usr/bin/ruby -w - -## -# abtsystemmanager.rb -# -# AbtSystemManager class handles all aspects of the AbTLinux system. It takes -# care of such tasks as cleanup, fixing, verification and management ... [truncated message content] |
From: <esc...@us...> - 2008-01-02 21:08:33
|
Revision: 473 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=473&view=rev Author: eschabell Date: 2008-01-02 13:08:23 -0800 (Wed, 02 Jan 2008) Log Message: ----------- Implemented show_package_dependencies, a simple readout of the package definition file. Added test for this feature. Only 11 unit tests to go! Modified Paths: -------------- src/trunk/abt.rb src/trunk/libs/abtreportmanager.rb src/trunk/tests/testabtreportmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-02 21:07:16 UTC (rev 472) +++ src/trunk/abt.rb 2008-01-02 21:08:23 UTC (rev 473) @@ -25,6 +25,25 @@ # St, Fifth Floor, Boston, MA 02110-1301 USA ## +# Check and install our library files. +# +$ABTLINUX_CLASS_LIBS = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/libs" + +if ( ! File.directory?( '/var/lib/abt' ) || Dir["/var/lib/abt"].empty? ) + puts "\nMissing needed AbTLinux library files at /var/lib/abt" + puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" + + # check for root login. + if ( Process.uid != 0 ) + puts "\nMust be root to fix library files." + exit + else + system( "svn co #{$ABTLINUX_CLASS_LIBS} /var/lib/abt/" ) + end + + $LOAD_PATH.unshift '/var/lib/abt/' +end + # Load our central configuration file. # $ABTLINUX_MAIN_CONFIG = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/abtconfig.rb" @@ -60,25 +79,7 @@ end end -# Check and install our library files. -# -$ABTLINUX_CLASS_LIBS = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/libs" -if ( ! File.directory?( '/var/lib/abt' ) || Dir["/var/lib/abt"].empty? ) - puts "\nMissing needed AbTLinux library files at /var/lib/abt" - puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" - - # check for root login. - if ( Process.uid != 0 ) - puts "\nMust be root to fix library files." - exit - else - system( "svn co #{$ABTLINUX_CLASS_LIBS} /var/lib/abt/" ) - end - - $LOAD_PATH.unshift '/var/lib/abt/' -end - ## # Setup needed classes and get ready to parse arguments. ## @@ -108,8 +109,6 @@ # And loading local file if found. if File.exist?( "/etc/abt/local/localconfig.rb" ) load '/etc/abt/local/localconfig.rb' -else - logger.info( "[abt.rb] No local configuration file found, not a problem, just informing." ) end @@ -341,10 +340,14 @@ end when "show-depends" - if ( ARGV.length == 2 ) - options['package'] = ARGV[1] - # FIXME : show package depends implementation. - puts "Display dependency tree for package : " + options['package'] + if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + options['pkg'] = ARGV[1] + logger.info( "Starting show depends for #{options['pkg']}" ) + if ( reporter.show_package_dependencies( options['pkg'] ) ) + logger.info( "Completed show depends for #{options['pkg']}" ) + else + puts "Problems showing the depends for #{options['pkg']}." + end else show.usage( "queries" ) exit Modified: src/trunk/libs/abtreportmanager.rb =================================================================== --- src/trunk/libs/abtreportmanager.rb 2008-01-02 21:07:16 UTC (rev 472) +++ src/trunk/libs/abtreportmanager.rb 2008-01-02 21:08:23 UTC (rev 473) @@ -184,7 +184,31 @@ # hash of problem files and their encountered errors. ## def show_package_dependencies( package ) - # TODO: implement this. + require "#{$PACKAGE_PATH}#{package}" + + if ( package = eval( "#{package.capitalize}.new" ) ) + details = package.details + + puts "|=====================================" + puts "| Package name\t\t: #{details['Package name']}" + puts "| Version\t\t: #{details['Version']}" + puts "|=====================================" + puts "|=====================================" + + if details['Depends On'].empty? && details['Relies On'].empty? && + details['Optional DO'].empty? && details['Optional RO'].empty? + puts "| No dependencies listed for this package." + else + puts "| Depends On\t\t: #{details['Depends On']}" if !details['Depends On'].empty? + puts "| Relies On\t\t: #{details['Relies On']}" if !details['Relies On'].empty? + puts "| Optional Depends On\t: #{details['Optional DO']}" if !details['Optional DO'].empty? + puts "| Optional Relies On\t: #{details['Optional RO']}" if !details['Optional RO'].empty? + end + + puts "|=====================================" + return true + end + return false end Modified: src/trunk/tests/testabtreportmanager.rb =================================================================== --- src/trunk/tests/testabtreportmanager.rb 2008-01-02 21:07:16 UTC (rev 472) +++ src/trunk/tests/testabtreportmanager.rb 2008-01-02 21:08:23 UTC (rev 473) @@ -167,5 +167,12 @@ assert( @report.generate_HTML_package_listing(), "test_generate_HTML_package_listing()" ) end - + + ## + # Test method for 'AbtReportManager.test_show_package_dependencies()' + ## + def test_show_package_dependencies + assert( @report.show_package_dependencies( "ipc" ), "test_show_package_dependencies()" ) + end + end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2008-01-11 20:25:51
|
Revision: 475 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=475&view=rev Author: eschabell Date: 2008-01-11 12:25:55 -0800 (Fri, 11 Jan 2008) Log Message: ----------- Mega cleanup of code as changed a few coding standards. Regenerated api docs. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abttemplate.rb 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/libs/abtdepengine_rb.html src/trunk/doc/files/libs/abtdownloadmanager_rb.html src/trunk/doc/files/libs/abtlogmanager_rb.html src/trunk/doc/files/libs/abtpackage_rb.html src/trunk/doc/files/libs/abtpackagemanager_rb.html src/trunk/doc/files/libs/abtqueuemanager_rb.html src/trunk/doc/files/libs/abtreportmanager_rb.html src/trunk/doc/files/libs/abtsystemmanager_rb.html src/trunk/doc/files/libs/abtusage_rb.html src/trunk/doc/files/tests/testabtdepengine_rb.html src/trunk/doc/files/tests/testabtdownloadmanager_rb.html src/trunk/doc/files/tests/testabtlogmanager_rb.html src/trunk/doc/files/tests/testabtpackage_rb.html src/trunk/doc/files/tests/testabtpackagemanager_rb.html src/trunk/doc/files/tests/testabtqueuemanager_rb.html src/trunk/doc/files/tests/testabtreportmanager_rb.html src/trunk/doc/files/tests/testabtsystemmanager_rb.html src/trunk/libs/abtdownloadmanager.rb src/trunk/libs/abtlogmanager.rb src/trunk/libs/abtpackage.rb src/trunk/libs/abtpackagemanager.rb src/trunk/libs/abtqueuemanager.rb src/trunk/libs/abtreportmanager.rb src/trunk/libs/abtsystemmanager.rb src/trunk/libs/abtusage.rb src/trunk/packages/fortune.rb src/trunk/packages/ipc.rb src/trunk/tests/testabtdepengine.rb src/trunk/tests/testabtdownloadmanager.rb src/trunk/tests/testabtlogmanager.rb src/trunk/tests/testabtpackage.rb src/trunk/tests/testabtpackagemanager.rb src/trunk/tests/testabtqueuemanager.rb src/trunk/tests/testabtreportmanager.rb src/trunk/tests/testabtsystemmanager.rb src/trunk/tests/testsuiteabt.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-02 21:10:48 UTC (rev 474) +++ src/trunk/abt.rb 2008-01-11 20:25:55 UTC (rev 475) @@ -29,16 +29,16 @@ # $ABTLINUX_CLASS_LIBS = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/libs" -if ( ! File.directory?( '/var/lib/abt' ) || Dir["/var/lib/abt"].empty? ) +if (! File.directory?('/var/lib/abt') || Dir["/var/lib/abt"].empty?) puts "\nMissing needed AbTLinux library files at /var/lib/abt" puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" # check for root login. - if ( Process.uid != 0 ) + if (Process.uid != 0) puts "\nMust be root to fix library files." exit else - system( "svn co #{$ABTLINUX_CLASS_LIBS} /var/lib/abt/" ) + system("svn co #{$ABTLINUX_CLASS_LIBS} /var/lib/abt/") end $LOAD_PATH.unshift '/var/lib/abt/' @@ -48,7 +48,7 @@ # $ABTLINUX_MAIN_CONFIG = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/abtconfig.rb" -if File.exist?( "/etc/abt/abtconfig.rb" ) +if File.exist?("/etc/abt/abtconfig.rb") $LOAD_PATH.unshift '/etc/abt/' load 'abtconfig.rb' else @@ -57,23 +57,23 @@ puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" # check for root login. - if ( Process.uid != 0 ) + if (Process.uid != 0) puts "\nMust be root to fix configuration files." exit else ["/etc/abt", "/etc/abt/local"].each { |dir| - if ( ! File.directory?( dir ) ) - FileUtils.mkdir_p( dir ) + if (! File.directory?(dir)) + FileUtils.mkdir_p(dir) puts "Created directory: #{dir}." end } - system( "svn export #{$ABTLINUX_MAIN_CONFIG} /etc/abt/abtconfig.rb" ) + system("svn export #{$ABTLINUX_MAIN_CONFIG} /etc/abt/abtconfig.rb") end $LOAD_PATH.unshift '/etc/abt/' load 'abtconfig.rb' - if File.exist?( "/etc/abt/local/localconfig.rb" ) + if File.exist?("/etc/abt/local/localconfig.rb") $LOAD_PATH.unshift '/etc/abt/local/' load 'localconfig.rb' end @@ -91,13 +91,13 @@ show = AbtUsage.new # deal with usage request. -if ( ARGV.length == 0 || ( ARGV.length == 1 && ( ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help' ) ) ) - show.usage( "all" ) +if (ARGV.length == 0 || (ARGV.length == 1 && (ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help'))) + show.usage("all") exit end # login as root for the rest. -manager.root_login( ARGV ) +manager.root_login(ARGV) # setup timestamp. logger = Logger.new($JOURNAL) # initializes all needed paths. @@ -107,7 +107,7 @@ myLogger = AbtLogManager.new # And loading local file if found. -if File.exist?( "/etc/abt/local/localconfig.rb" ) +if File.exist?("/etc/abt/local/localconfig.rb") load '/etc/abt/local/localconfig.rb' end @@ -117,125 +117,125 @@ # abt [ -i | install ] <package> when "install", "-i" - if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}#{ARGV[1]}.rb")) options['package'] = ARGV[1] - logger.info( "Starting to install #{options['package']}" ) + logger.info("Starting to install #{options['package']}") # return if already installed. - if ( system.package_installed( options['package'] ) ) + if (system.package_installed(options['package'])) puts "\n*** Package #{options['package']} is installed, might want to try reinstall? ***" puts "\n\tabt reinstall #{options['package']}\n\n" - logger.info( "Completed install of #{options['package']}." ) + logger.info("Completed install of #{options['package']}.") exit end - if ( manager.install_package( options['package'] ) ) + if (manager.install_package(options['package'])) puts "\n\n" puts "*** Completed install of #{options['package']}. ***" puts "\n\n" - logger.info( "Completed install of #{options['package']}." ) + logger.info("Completed install of #{options['package']}.") - if ( myLogger.cache_package( options['package'] ) ) + if (myLogger.cache_package(options['package'])) puts "\n\n" puts "*** Completed caching of package #{options['package']}. ***" puts "\n\n" - logger.info( "Caching completed for package #{options['package']}." ) + logger.info("Caching completed for package #{options['package']}.") else - logger.info( "Caching of package #{options['package']} failed.") + logger.info("Caching of package #{options['package']} failed.") end else puts "*** #{options['package'].capitalize} install failed, see journal. ***" end else - show.usage( "packages" ) + show.usage("packages") exit end when "reinstall", "-ri" - if ( ARGV.length == 2 && File.exist?( "#{$PACKAGE_PATH}#{ARGV[1]}.rb" ) ) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}#{ARGV[1]}.rb")) options['package'] = ARGV[1] - logger.info( "Starting to reinstall #{options['package']}" ) + logger.info("Starting to reinstall #{options['package']}") - if ( manager.reinstall_package( options['package'] ) ) + if (manager.reinstall_package(options['package'])) puts "\n\n" puts "*** Completed reinstall of #{options['package']}. ***" puts "\n\n" - logger.info( "Completed reinstall of #{options['package']}." ) + logger.info("Completed reinstall of #{options['package']}.") else puts "\n*** Unable to reinstall package #{options['package'].capitalize}, see why in the journal. ***" end else - show.usage( "packages" ) + show.usage("packages") exit end when "remove", "-r" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] puts "Starting to remove #{options['package']}." - logger.info( "Starting to remove #{options['package']}." ) + logger.info("Starting to remove #{options['package']}.") # return if not installed. - if ( !( system.package_installed( options['package'] ) ) ) + if (!(system.package_installed(options['package']))) puts "\n\n" puts "*** No need to remove #{options['package']}, it was not installed! ***" puts "\n\n" - logger.info( "Unabel to complete removal of #{options['package']}." ) + logger.info("Unabel to complete removal of #{options['package']}.") exit end # is installed, remove package. - if ( manager.remove_package( options['package'] ) ) + if (manager.remove_package(options['package'])) puts "\n\n" puts "*** Completed removal of #{options['package']}. ***" puts "\n\n" - logger.info( "Unabel to complete removal of #{options['package']}." ) + logger.info("Unabel to complete removal of #{options['package']}.") end puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" - logger.info( "Unabel to complete removal of #{options['package']}." ) + logger.info("Unabel to complete removal of #{options['package']}.") else puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" - logger.info( "Unabel to complete removal of #{options['package']}." ) - show.usage( "packages" ) + logger.info("Unabel to complete removal of #{options['package']}.") + show.usage("packages") exit end when "downgrade", "-dg" - if ( ARGV.length == 3 ) + if (ARGV.length == 3) options['version'] = ARGV[1] options['package'] = ARGV[2] # FIXME: downgrade pkg implementation. print "Downgradinging package : #{options['package']} " puts "to version : #{options['version']}" else - show.usage( "packages" ) + show.usage("packages") exit end when "freeze", "-f" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - logger.info( "Starting freeze of package : #{options['package']}" ) + logger.info("Starting freeze of package : #{options['package']}") puts "\nAttempting to freeze package #{options['package']}." - if ( !manager.freeze_package( options['package'] ) ) + if (!manager.freeze_package(options['package'])) puts "\nUnable to freeze package #{options['package']}, see journal for details." end - logger.info( "Completed (un)freeze of package : #{options['package']}" ) + logger.info("Completed (un)freeze of package : #{options['package']}") puts "\nCompleted freeze of package : #{options['package']}" else - show.usage( "packages" ) - logger.info( "Completed (un)freeze of package : #{options['package']}" ) + show.usage("packages") + logger.info("Completed (un)freeze of package : #{options['package']}") exit end when "search", "-s" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['searchString'] = ARGV[1] - logger.info( "Starting search of package descriptions for : #{options['searchString']}" ) - searchResults = reporter.search_package_descriptions( options['searchString'].chomp ) - if ( searchResults.empty? ) + logger.info("Starting search of package descriptions for : #{options['searchString']}") + searchResults = reporter.search_package_descriptions(options['searchString'].chomp) + if (searchResults.empty?) puts "\nNothing found matching your search query." exit else @@ -245,155 +245,155 @@ searchResults.each_pair { |name, description| puts "#{name} \t: #{description}" } end - logger.info( "Completed search of package descriptions for : #{options['searchString']}" ) + logger.info("Completed search of package descriptions for : #{options['searchString']}") else - show.usage( "queries" ) + show.usage("queries") exit end # abt -v | --version when "-v", "--version" - if ( ARGV.length == 1 ) + if (ARGV.length == 1) puts "Abt Package Manager version is : #{$ABT_VERSION}" else - show.usage( "queries" ) + show.usage("queries") exit end # abt show-details <package> when "show-details" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) options['pkg'] = ARGV[1] - logger.info( "Starting show details for #{options['pkg']}" ) + logger.info("Starting show details for #{options['pkg']}") - if ( reporter.show_package_details( options['pkg'] ) ) - logger.info( "Completed show details for #{options['pkg']}" ) + if (reporter.show_package_details(options['pkg'])) + logger.info("Completed show details for #{options['pkg']}") else puts "Problems processing the details for #{options['pkg']}." end else - show.usage( "queries" ) + show.usage("queries") end when "show-config" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - if !system.package_installed( options['package'] ) + if !system.package_installed(options['package']) puts "\nThe package #{options['package']} is not installed, can't show the configure log." exit end puts "\nDisplay configure log for package : #{options['package']}" puts "===============================\n" - reporter.show_package_log( options['package'], "configure" ) + reporter.show_package_log(options['package'], "configure") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-build" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - if !system.package_installed( options['package'] ) + if !system.package_installed(options['package']) puts "\nThe package #{options['package']} is not installed, can't show the build log." exit end puts "\nDisplay build log for package : #{options['package']}" puts "===============================\n" - reporter.show_package_log( options['package'], "build" ) + reporter.show_package_log(options['package'], "build") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-install" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - if !system.package_installed( options['package'] ) + if !system.package_installed(options['package']) puts "\nThe package #{options['package']} is not installed, can't show the install log." exit end puts "\nDisplay install log for package : #{options['package']}" puts "===============================\n" - reporter.show_package_log( options['package'], "install" ) + reporter.show_package_log(options['package'], "install") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-integrity" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - if !system.package_installed( options['package'] ) + if !system.package_installed(options['package']) puts "\nThe package #{options['package']} is not installed, can't show the integrity log." exit end puts "\nDisplay integrity log for package : #{options['package']}" puts "=================================\n" - reporter.show_package_log( options['package'], "integrity" ) + reporter.show_package_log(options['package'], "integrity") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-depends" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) options['pkg'] = ARGV[1] - logger.info( "Starting show depends for #{options['pkg']}" ) - if ( reporter.show_package_dependencies( options['pkg'] ) ) - logger.info( "Completed show depends for #{options['pkg']}" ) + logger.info("Starting show depends for #{options['pkg']}") + if (reporter.show_package_dependencies(options['pkg'])) + logger.info("Completed show depends for #{options['pkg']}") else puts "Problems showing the depends for #{options['pkg']}." end else - show.usage( "queries" ) + show.usage("queries") exit end when "show-files" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - if !system.package_installed( options['package'] ) + if !system.package_installed(options['package']) puts "\nThe package #{options['package']} is not installed, can't show it's installed files." exit end puts "\nDisplay installed files from package : #{options['package']}" puts "====================================\n" - reporter.show_package_log( options['package'], "install" ) + reporter.show_package_log(options['package'], "install") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-owner" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['fileName'] = ARGV[1] # FIXME : display a file owner implementation. puts "Display owning package for file : " + options['fileName'] else - show.usage( "queries" ) + show.usage("queries") exit end when "show-installed" - if ( ARGV.length == 1 ) + if (ARGV.length == 1) reporter.show_installed_packages() else - show.usage( "queries" ) + show.usage("queries") exit end when "show-frozen" - if ( ARGV.length == 1 ) - logger.info( "Starting display of frozen packages." ) + if (ARGV.length == 1) + logger.info("Starting display of frozen packages.") frozenResults = reporter.show_frozen_packages - if ( frozenResults.empty? ) + if (frozenResults.empty?) puts "\n\nNothing is frozen at this time.\n\n" - logger.info( "Completed display of frozen packages." ) + logger.info("Completed display of frozen packages.") exit else # we have results hash! @@ -407,110 +407,110 @@ #puts "===========================================" puts "\n\n" - logger.info( "Completed display of frozen packages." ) + logger.info("Completed display of frozen packages.") else - show.usage( "queries" ) + show.usage("queries") exit end when "show-untracked" # FIXME : show untracked files implementation. puts "Display all files on system not tracked by AbTLinux." - show.usage( "queries" ) + show.usage("queries") # abt show-journal when "show-journal" - reporter.show_journal( $JOURNAL ) + reporter.show_journal($JOURNAL) when "show-iqueue" - reporter.show_queue( "install" ) + reporter.show_queue("install") when "show-patches" # FIXME : show patches implementation. puts "Display currently available patches for installed package tree." - show.usage( "queries" ) + show.usage("queries") when "show-updates" # FIXME : show updates implementation. puts "Display package listing with available update versions." - show.usage( "generation" ) + show.usage("generation") when "html" # FIXME : generate html installed pkgs implementation. puts "Generate HTML page from installed packages:" puts " (package name with link to package website/version installed)" - show.usage( "generation" ) + show.usage("generation") # abt news | -n when "news", "-n" - logger.info( "Starting to retrieve AbTLinux news." ) + logger.info("Starting to retrieve AbTLinux news.") # abtlinux.org news feeds. puts "\n" - if ( !downloader.retrieve_news_feed( $ABTNEWS ) ) + if (!downloader.retrieve_news_feed($ABTNEWS)) puts "Failed to retrieve the AbTLinux news feed." end puts "\n" - if ( !downloader.retrieve_news_feed( $ABTNEWS_THREADS, false ) ) + if (!downloader.retrieve_news_feed($ABTNEWS_THREADS, false)) puts "Failed to retrieve the AbTLinux forum threads news feed." end puts "\n" - if ( !downloader.retrieve_news_feed( $ABTNEWS_POSTS, false ) ) + if (!downloader.retrieve_news_feed($ABTNEWS_POSTS, false)) puts "Failed to retrieve the AbTLinux new posts news feed." end # display the file contents. - reporter.show_journal( $ABTNEWS_LOG ) + reporter.show_journal($ABTNEWS_LOG) - logger.info( "Completed the retrieval of AbTLinux news." ) + logger.info("Completed the retrieval of AbTLinux news.") # abt [-d | download ] <package> when "download", "-d" - if ( ARGV.length == 2 && File.exist?( $PACKAGE_PATH + ARGV[1] + ".rb" ) ) + if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) options['pkg'] = ARGV[1] - logger.info( "Starting to download " + options['pkg'] ) + logger.info("Starting to download " + options['pkg']) manager = AbtDownloadManager.new - if ( manager.retrieve_package_source( options['pkg'], $SOURCES_REPOSITORY ) ) - logger.info( "Finished download for " + options['pkg'] ) + if (manager.retrieve_package_source(options['pkg'], $SOURCES_REPOSITORY)) + logger.info("Finished download for " + options['pkg']) puts "\n"; print "Downloading of #{options['pkg']} to #{$SOURCES_REPOSITORY} " puts "completed." puts "\n\n" else - logger.info( "FAILURE to download " + options['pkg'] ) + logger.info("FAILURE to download " + options['pkg']) puts "\n" puts "DOWNLOADING - failed to download source for #{options['pkg']}" puts "\n\n" end else - show.usage( "downloads" ) + show.usage("downloads") exit end when "update", "-u" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) - if ( ARGV[1].length > 0 || ARGV[1] == "tree" || ARGV[1].downcase == "abtlinux" ) + if (ARGV[1].length > 0 || ARGV[1] == "tree" || ARGV[1].downcase == "abtlinux") if ARGV[1].downcase == "tree" || ARGV[1].downcase == "abtlinux" options['updateItem'] = "AbTLinux" puts "Start updating package tree : #{options['updateItem']}." logger.info "Start updating package tree : #{options['updateItem']}." - if downloader.update_package_tree( options['updateItem'] ) + if downloader.update_package_tree(options['updateItem']) puts "Updated package tree : #{options['updateItem']}." else puts "Unable to update package tree : #{options['updateItem']}." logger.error "Unable to update package tree : #{options['updateItem']}." - logger.info( "Finished updating package tree : #{options['updateItem']}.") + logger.info("Finished updating package tree : #{options['updateItem']}.") exit end - logger.info( "Finished updating package tree : #{options['updateItem']}.") + logger.info("Finished updating package tree : #{options['updateItem']}.") else # assuming package to be updated. @@ -519,120 +519,120 @@ puts "Start updating package : #{options['updateItem']}." logger.info "Start updating package : #{options['updateItem']}." - if downloader.update_package( options['updateItem'] ) + if downloader.update_package(options['updateItem']) puts "Updated package : #{options['updateItem']}." else puts "Unable to update package : #{options['updateItem']}." logger.error "Unable to update package : #{options['updateItem']}." - logger.info( "Finished updating package : #{options['updateItem']}") + logger.info("Finished updating package : #{options['updateItem']}") exit end - logger.info( "Finished updating package : #{options['updateItem']}") + logger.info("Finished updating package : #{options['updateItem']}") end else - show.usage( "downloads" ) + show.usage("downloads") exit end else - show.usage( "downloads" ) + show.usage("downloads") exit end when "purge-src" - if ( ARGV.length == 1 ) - logger.info( "Starting to purge sources from packages that are not installed.") - if ( system.cleanup_package_sources ) + if (ARGV.length == 1) + logger.info("Starting to purge sources from packages that are not installed.") + if (system.cleanup_package_sources) puts "\nPurged sources from packages that are not installed." - logger.info( "Finished purging sources from packages that are not installed.") + logger.info("Finished purging sources from packages that are not installed.") else puts "\nUnable to complete a purge of sources from packages that are not installed, see journal." - logger.info( "Cleanup of package sources encountered problems, see journal." ) + logger.info("Cleanup of package sources encountered problems, see journal.") end else - show.usage( "fix" ) + show.usage("fix") exit end when "verify-files" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - logger.info( "Starting verifcation of files for package : #{options['package']}.") + logger.info("Starting verifcation of files for package : #{options['package']}.") - if system.verify_installed_files( options['package'] ) + if system.verify_installed_files(options['package']) puts "\nInstalled files verified for package : #{options['package']}" - logger.info( "Finished verifcation of files for package : #{options['package']}.") + logger.info("Finished verifcation of files for package : #{options['package']}.") exit end - logger.info( "Finished verifcation of files for package : #{options['package']}.") + logger.info("Finished verifcation of files for package : #{options['package']}.") puts "/nInstalled files verification for package : #{options['package']} failed, see journal." else - show.usage( "fix" ) + show.usage("fix") exit end when "verify-symlinks" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] # FIXME : verify symlinks for pkg implementation. puts "Symlinks verified for package : " + options['package'] else - show.usage( "fix" ) + show.usage("fix") exit end when "verify-deps" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] # FIXME : verify deps for pkg implementation. puts "Symlinks verified for package : " + options['package'] else - show.usage( "fix" ) + show.usage("fix") exit end when "verify-integrity" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['package'] = ARGV[1] - logger.info( "Starting verification of files for package : #{options['package']}.") + logger.info("Starting verification of files for package : #{options['package']}.") - integrityHash = system.verify_package_integrity( options['package'] ) + integrityHash = system.verify_package_integrity(options['package']) if integrityHash.empty? puts "\nInstalled files integrity check completed without problems being detected for package : #{options['package']}" - logger.info( "Finished verification of files for package : #{options['package']}.") + logger.info("Finished verification of files for package : #{options['package']}.") exit end integrityHash.each_pair {|file, problem| puts "Problem with #{file} from package #{problem}" - logger.info( "Problem with #{file} from package #{problem}." ) + logger.info("Problem with #{file} from package #{problem}.") } puts "/nInstalled files integrity check failed for package : #{options['package']} failed, see journal." else - show.usage( "fix" ) + show.usage("fix") exit end when "fix" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['pkg'] = ARGV[1] # FIXME : fix package impelmentation. puts "Package : #{options['pkg']} is verified and checked if needed." else - show.usage( "fix" ) + show.usage("fix") exit end when "build-location" - if ( ARGV.length == 2 ) + if (ARGV.length == 2) options['buildHost'] = ARGV[1] # FIXME : set global cache build location implementation. print "Sets global location for retrieving cached build packages " puts "to : #{options['buildHost']}" else - show.usage( "maintenance" ) + show.usage("maintenance") exit end @@ -648,7 +648,7 @@ # list called. when 2 # FIXME: implements this. - if ( ARGV[1] == "list" ) + if (ARGV[1] == "list") options['repoAction'] = ARGV[1] logger.info "TODO: Listing package repositories." elsif ARGV[1] == "add" || ARGV[1] == "remove" @@ -656,16 +656,16 @@ options['repoAction'] = ARGV[1] options['repoUri'] = "" else - show.usage( "maintenance" ) + show.usage("maintenance") exit end else - show.usage( "maintenance" ) + show.usage("maintenance") exit end # case ARGV.length. - logger.info( "Starting package-repo : #{options['repoAction']}.") + logger.info("Starting package-repo : #{options['repoAction']}.") # hook location based on action. case options['repoAction'] @@ -673,12 +673,12 @@ when "add" if options['repoUri'].length > 0 puts "Adding package repository : " + options['repoUri'] - if downloader.retrieve_package_tree( options['repoUri'] ) + if downloader.retrieve_package_tree(options['repoUri']) puts "Added package tree : #{options['repoUri']}." else puts "Unable to add package tree : #{options['repoUri']}." logger.error "Unable to add package tree : #{options['repoUri']}." - logger.info( "Finished package-repo : #{options['repoAction']}.") + logger.info("Finished package-repo : #{options['repoAction']}.") exit end else @@ -688,7 +688,7 @@ else puts "Unable to add package tree : Default AbTLinux Package Tree." logger.error "Unable to add package tree : Default AbTLinux Package Tree." - logger.info( "Finished package-repo : #{options['repoAction']}.") + logger.info("Finished package-repo : #{options['repoAction']}.") exit end end @@ -706,12 +706,12 @@ puts "TODO: Display listing of package repositories." else - show.usage( "maintenance" ) + show.usage("maintenance") exit end # case repoAction. - logger.info( "Finished package-repo : #{options['repoAction']}.") + logger.info("Finished package-repo : #{options['repoAction']}.") else - show.usage( "all" ) + show.usage("all") end # case ARGV[0]. Modified: src/trunk/abttemplate.rb =================================================================== --- src/trunk/abttemplate.rb 2008-01-02 21:10:48 UTC (rev 474) +++ src/trunk/abttemplate.rb 2008-01-11 20:25:55 UTC (rev 475) @@ -198,25 +198,25 @@ <script language="JavaScript" type="text/javascript"> // <![CDATA[ - function toggleSource( id ) + function toggleSource(id) { var elem var link - if( document.getElementById ) + if(document.getElementById) { - elem = document.getElementById( id ) - link = document.getElementById( "l_" + id ) + elem = document.getElementById(id) + link = document.getElementById("l_" + id) } - else if ( document.all ) + else if (document.all) { - elem = eval( "document.all." + id ) - link = eval( "document.all.l_" + id ) + elem = eval("document.all." + id) + link = eval("document.all.l_" + id) } else return false; - if( elem.style.display == "block" ) + if(elem.style.display == "block") { elem.style.display = "none" link.innerHTML = "show source" @@ -228,9 +228,9 @@ } } - function openCode( url ) + function openCode(url) { - window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" ) + window.open(url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes") } // ]]> </script> Modified: src/trunk/doc/classes/AbtDepEngine.html =================================================================== --- src/trunk/doc/classes/AbtDepEngine.html 2008-01-02 21:10:48 UTC (rev 474) +++ src/trunk/doc/classes/AbtDepEngine.html 2008-01-11 20:25:55 UTC (rev 475) @@ -11,25 +11,25 @@ <script language="JavaScript" type="text/javascript"> // <![CDATA[ - function toggleSource( id ) + function toggleSource(id) { var elem var link - if( document.getElementById ) + if(document.getElementById) { - elem = document.getElementById( id ) - link = document.getElementById( "l_" + id ) + elem = document.getElementById(id) + link = document.getElementById("l_" + id) } - else if ( document.all ) + else if (document.all) { - elem = eval( "document.all." + id ) - link = eval( "document.all.l_" + id ) + elem = eval("document.all." + id) + link = eval("document.all.l_" + id) } else return false; - if( elem.style.display == "block" ) + if(elem.style.display == "block") { elem.style.display = "none" link.innerHTML = "show source" @@ -41,9 +41,9 @@ } } - function openCode( url ) + function openCode(url) { - window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" ) + window.open(url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes") } // ]]> </script> Modified: src/trunk/doc/classes/AbtDownloadManager.html =================================================================== --- src/trunk/doc/classes/AbtDownloadManager.html 2008-01-02 21:10:48 UTC (rev 474) +++ src/trunk/doc/classes/AbtDownloadManager.html 2008-01-11 20:25:55 UTC (rev 475) @@ -11,25 +11,25 @@ <script language="JavaScript" type="text/javascript"> // <![CDATA[ - function toggleSource( id ) + function toggleSource(id) { var elem var link - if( document.getElementById ) + if(document.getElementById) { - elem = document.getElementById( id ) - link = document.getElementById( "l_" + id ) + elem = document.getElementById(id) + link = document.getElementById("l_" + id) } - else if ( document.all ) + else if (document.all) { - elem = eval( "document.all." + id ) - link = eval( "document.all.l_" + id ) + elem = eval("document.all." + id) + link = eval("document.all.l_" + id) } else return false; - if( elem.style.display == "block" ) + if(elem.style.display == "block") { elem.style.display = "none" link.innerHTML = "show source" @@ -41,9 +41,9 @@ } } - function openCode( url ) + function openCode(url) { - window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" ) + window.open(url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes") } // ]]> </script> @@ -161,7 +161,7 @@ <div class="sectiontitle">Public Instance methods</div> <div class="method"> <div class="title"> - <a name="M000015"></a><b>retrieve_news_feed</b>( uri, cleanLog=true ) + <a name="M000015"></a><b>retrieve_news_feed</b>(uri, cleanLog=true) </div> <div class="description"> <p> @@ -180,24 +180,24 @@ <div id="M000015_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 122</span> -122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_news_feed</span>( <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">cleanLog</span>=<span class="ruby-keyword kw">true</span> ) +122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_news_feed</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">cleanLog</span>=<span class="ruby-keyword kw">true</span>) 123: <span class="ruby-identifier">require</span> <span class="ruby-value str">'net/http'</span> 124: <span class="ruby-identifier">require</span> <span class="ruby-value str">'uri'</span> 125: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/1.0'</span> 126: <span class="ruby-identifier">require</span> <span class="ruby-value str">'rss/2.0'</span> 127: <span class="ruby-identifier">newsLog</span> = <span class="ruby-value str">""</span> -128: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$JOURNAL</span>) +128: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) 129: 130: <span class="ruby-comment cmt"># ensure we have our news logfile.</span> -131: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">cleanLog</span> ) -132: <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-value str">"w+"</span> ) +131: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">cleanLog</span>) +132: <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-value str">"w+"</span>) 133: <span class="ruby-keyword kw">else</span> -134: <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-value str">"a+"</span> ) +134: <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-value str">"a+"</span>) 135: <span class="ruby-keyword kw">end</span> 136: 137: <span class="ruby-comment cmt"># pick up the abtlinux.org news feed.</span> -138: <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> ) ) ) -139: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-node">"Failed to retrieve news feed #{uri}."</span> ) +138: <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>))) +139: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">"Failed to retrieve news feed #{uri}."</span>) 140: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> 141: <span class="ruby-keyword kw">end</span> 142: @@ -208,8 +208,8 @@ 147: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> 148: <span class="ruby-keyword kw">end</span> 149: -150: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">rss</span>.<span class="ruby-identifier">nil?</span> ) -151: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-node">"Failed to display news feed as feed #{uri} is not RSS 1.0/2.0."</span> ) +150: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">rss</span>.<span class="ruby-identifier">nil?</span>) +151: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">"Failed to display news feed as feed #{uri} is not RSS 1.0/2.0."</span>) 152: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> 153: <span class="ruby-keyword kw">else</span> 154: <span class="ruby-identifier">newsLog</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"*** #{rss.channel.title} ***\n"</span> @@ -231,7 +231,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000013"></a><b>retrieve_package_source</b>( packageName, destination ) + <a name="M000013"></a><b>retrieve_package_source</b>(packageName, destination) </div> <div class="description"> <p> @@ -253,19 +253,19 @@ <div id="M000013_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 56</span> -56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_package_source</span>( <span class="ruby-identifier">packageName</span>, <span class="ruby-identifier">destination</span> ) +56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_package_source</span>(<span class="ruby-identifier">packageName</span>, <span class="ruby-identifier">destination</span>) 57: <span class="ruby-identifier">require</span> <span class="ruby-node">"#{$PACKAGE_PATH}#{packageName}"</span> 58: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</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> ) +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>( <span class="ruby-node">"#{destination}/#{File.basename( package.srcUrl )}"</span> ) ) -62: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-node">"Download not needed, existing source found for #{packageName}"</span> ) +61: <span class="ruby-keyword kw">if</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-node">"#{destination}/#{File.basename(package.srcUrl)}"</span>)) +62: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">"Download not needed, existing source found for #{packageName}"</span>) 63: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> 64: <span class="ruby-keyword kw">end</span> 65: -66: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">destination</span> ) -67: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">system</span>( <span class="ruby-node">"wget #{package.srcUrl}"</span> ) ) -68: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-node">"Download completed for #{packageName}"</span> ) +66: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">destination</span>) +67: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">system</span>(<span class="ruby-node">"wget #{package.srcUrl}"</span>)) +68: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">"Download completed for #{packageName}"</span>) 69: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> 70: <span class="ruby-keyword kw">end</span> 71: @@ -277,7 +277,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000014"></a><b>retrieve_package_tree</b>( packageTreeName="AbTLinux" ) + <a name="M000014"></a><b>retrieve_package_tree</b>(packageTreeName="AbTLinux") </div> <div class="description"> <p> @@ -297,13 +297,13 @@ <div id="M000014_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 83</span> - 83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_package_tree</span>( <span class="ruby-identifier">packageTreeName</span>=<span class="ruby-value str">"AbTLinux"</span> ) + 83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve_package_tree</span>(<span class="ruby-identifier">packageTreeName</span>=<span class="ruby-value str">"AbTLinux"</span>) 84: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) 85: 86: <span class="ruby-comment cmt"># check if package tree exists.</span> - 87: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">$PACKAGE_PATH</span> ) + 87: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">$PACKAGE_PATH</span>) 88: <span class="ruby-comment cmt"># check if svn directory.</span> - 89: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span> ) + 89: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span>) 90: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"Package tree #{packageTreeName} already installed."</span> 91: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> 92: <span class="ruby-keyword kw">else</span> @@ -315,7 +315,7 @@ 98: <span class="ruby-keyword kw">else</span> 99: 100: <span class="ruby-comment cmt"># pacakge directory does not exist, svn co.</span> -101: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>( <span class="ruby-node">"svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}"</span> ) +101: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>(<span class="ruby-node">"svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}"</span>) 102: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-value str">"Package tree installed (svn co)"</span> 103: <span class="ruby-keyword kw">else</span> 104: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-value str">"Package tree not installed (svn co), problems!"</span> @@ -332,7 +332,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000016"></a><b>update_package</b>( packageName ) + <a name="M000016"></a><b>update_package</b>(packageName) </div> <div class="description"> <p> @@ -351,14 +351,14 @@ <div id="M000016_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 176</span> -176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_package</span>( <span class="ruby-identifier">packageName</span> ) -177: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) +176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_package</span>(<span class="ruby-identifier">packageName</span>) +177: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) 178: 179: <span class="ruby-comment cmt"># check if package exists in tree. </span> -180: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>( <span class="ruby-node">"#{$PACKAGE_PATH}/#{packageName}.rb"</span> ) +180: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-node">"#{$PACKAGE_PATH}/#{packageName}.rb"</span>) 181: <span class="ruby-comment cmt"># check if svn directory.</span> -182: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span> ) -183: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>( <span class="ruby-node">"svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb"</span> ) +182: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span>) +183: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>(<span class="ruby-node">"svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb"</span>) 184: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"Package #{packageName.downcase} updated (svn update)"</span> 185: <span class="ruby-keyword kw">else</span> 186: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"Package #{packageName.downcase} unable to update (svn update)."</span> @@ -383,7 +383,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000017"></a><b>update_package_tree</b>( packageTreeName="AbTLinux" ) + <a name="M000017"></a><b>update_package_tree</b>(packageTreeName="AbTLinux") </div> <div class="description"> <p> @@ -403,14 +403,14 @@ <div id="M000017_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 211</span> -211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_package_tree</span>( <span class="ruby-identifier">packageTreeName</span>=<span class="ruby-value str">"AbTLinux"</span> ) +211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_package_tree</span>(<span class="ruby-identifier">packageTreeName</span>=<span class="ruby-value str">"AbTLinux"</span>) 212: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) 213: 214: <span class="ruby-comment cmt"># check if package tree exists.</span> -215: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">$PACKAGE_PATH</span> ) +215: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">$PACKAGE_PATH</span>) 216: <span class="ruby-comment cmt"># check if svn directory.</span> -217: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span> ) -218: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>( <span class="ruby-node">"svn update #{$PACKAGE_PATH}"</span> ) +217: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-node">"#{$PACKAGE_PATH}.svn"</span>) +218: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">system</span>(<span class="ruby-node">"svn update #{$PACKAGE_PATH}"</span>) 219: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-value str">"Package tree updated (svn update)"</span> 220: <span class="ruby-keyword kw">else</span> 221: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-value str">"Package tree unable to update (svn update)."</span> @@ -435,7 +435,7 @@ </div> <div class="method"> <div class="title"> - <a name="M000018"></a><b>validated</b>( hashvalue, path ) + <a name="M000018"></a><b>validated</b>(hashvalue, path) </div> <div class="description"> <p> @@ -456,17 +456,17 @@ <div id="M000018_source" class="dyn-source"> <pre> <span class="ruby-comment cmt"># File libs/abtdownloadmanager.rb, line 247</span> -247: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validated</span>( <span class="ruby-identifier">hashvalue</span>, <span class="ruby-identifier">path</span> ) -248: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">$JOURNAL</span> ) +247: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validated</span>(<span class="ruby-identifier">hashvalue</span>, <span class="ruby-identifier">path</span>) +248: <span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$JOURNAL</span>) 249: -250: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hashvalue</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>( <span class="ruby-identifier">path</span> ) +250: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hashvalue</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">path</span>) 251: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"Source hash validated successfully..."</span> -252: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-value str">"Validated sources successfully..."</span> ) +252: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">"Validated sources successfully..."</span>) 253: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> 254: <span class="ruby-keyword kw">end</span> 255: 256: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"Source hash failed validation..."</span> -257: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>( <span class="ruby-value str">"Validating sources failed..."</span> ) +257: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">"Validating sources 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> </pre> Modified: src/trunk/doc/classes/AbtLogManager.html =================================================================== --- src/trunk/doc/classes/AbtLogManager.html 2008-01-02 21:10:48 UTC (rev 474) +++ src/trunk/doc/classes/AbtLogManager.html 2008-01-11 20:25:55 UTC (rev 475) @@ -11,25 +11,25 @@ <script language="JavaScript" type="text/javascript"> // <![CDATA[ - function toggleSource( id ) + function toggleSource(id) { var elem var link - if( document.getElementById ) + if(document.getElementById) { - elem = document.getElementById( id ) - link = document.getElementById( "l_" + id ) + elem = document.getElementById(id) + link = document.getElementById("l_" + id) } - else if ( document.all ) + else if (document.all) { - elem = eval( "document.all." + id ) - link = eval( "document.all.l_" + id ) + elem = eval("document.all." + id) + link = eval("document.all.l_" + id) } else return false; - if( elem.style.display == "block" ) + if(elem.style.display == "block") { elem.style.display = "none" link.innerHTML = "show source" @@ -41,9 +41,9 @@ } } - function openCode( url ) + function openCode(url) { - window.open... [truncated message content] |
From: <esc...@us...> - 2008-01-14 11:32:11
|
Revision: 478 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=478&view=rev Author: eschabell Date: 2008-01-14 03:32:04 -0800 (Mon, 14 Jan 2008) Log Message: ----------- Refactored cache package from logmanager to the package manager, makes more sense to me. Fixed unit tests to reflect move. Modified Paths: -------------- src/trunk/libs/abtlogmanager.rb src/trunk/libs/abtpackagemanager.rb src/trunk/tests/testabtlogmanager.rb src/trunk/tests/testabtpackagemanager.rb Modified: src/trunk/libs/abtlogmanager.rb =================================================================== --- src/trunk/libs/abtlogmanager.rb 2008-01-12 18:32:06 UTC (rev 477) +++ src/trunk/libs/abtlogmanager.rb 2008-01-14 11:32:04 UTC (rev 478) @@ -194,92 +194,5 @@ return true end - - ## - # Provides a complete log of the given packages build. Includes everything - # needed to duplicate the build at a later date. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if package cache created successfully, - # otherwise false. - ## - def cache_package(package) - system = AbtSystemManager.new - - if (system.package_installed(package)) - sw = eval("#{package.capitalize}.new") - cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir - sourcePath = $SOURCES_REPOSITORY + "/" + File.basename(sw.srcUrl) - sourceFile = File.basename(sw.srcUrl) - installLog = get_log(package, 'install') - buildLog = get_log(package, 'build') - configureLog = get_log(package, 'configure') - integrityLog = get_log(package, 'integrity') - packageFile = "#{$PACKAGE_PATH}#{package}.rb" - - - FileUtils.mkdir_p(cachedDir) - # collect package source. - if (FileTest::exist?(sourcePath)) - FileUtils.copy_file(sourcePath, "#{cachedDir}/#{sourceFile}") - puts "\nCaching copy of #{package} source." - else - puts "\nUnable to cache copy of #{package} source." - end - - # collect package install log. - if (FileTest::exist?(installLog)) - FileUtils.copy_file(installLog, "#{cachedDir}/#{sw.srcDir}.install") - puts "\nCaching copy of #{package} install log." - else - puts "\nUnable to cache copy of #{package} install log." - end - - # collect package build log. - if (FileTest::exist?(buildLog)) - FileUtils.copy_file(buildLog, "#{cachedDir}/#{sw.srcDir}.build") - puts "\nCaching copy of #{package} build log." - else - puts "\nUnable to cache copy of #{package} build log." - end - - # collect package configure log. - if (FileTest::exist?(configureLog)) - FileUtils.copy_file(configureLog, "#{cachedDir}/#{sw.srcDir}.configure") - puts "\nCaching copy of #{package} configure log." - else - puts "\nUnable to cache copy of #{package} configure log." - end - - # collect package integrity log. - if (FileTest::exist?(integrityLog)) - FileUtils.copy_file(integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity") - puts "\nCaching copy of #{package} integrity log." - else - puts "\nUnable to cache copy of #{package} integrity log." - end - - # collect package description (class file). - if (FileTest::exist?(packageFile)) - FileUtils.copy_file(packageFile, "#{cachedDir}/#{package}.rb") - puts "\nCaching copy of #{package} package description." - else - puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" - end - - # tar and bzip this directory (package-cache-version.tar.bz2) - Dir.chdir($PACKAGE_CACHED) - if (system("tar -cf #{sw.srcDir}.tar #{sw.srcDir}") && - system("bzip2 -f #{sw.srcDir}.tar")) - # last but not least, remove our tarball directory - FileUtils.rm_rf(cachedDir) - return true - end - end - - return false # package not installed, can't cache it. - end - end Modified: src/trunk/libs/abtpackagemanager.rb =================================================================== --- src/trunk/libs/abtpackagemanager.rb 2008-01-12 18:32:06 UTC (rev 477) +++ src/trunk/libs/abtpackagemanager.rb 2008-01-14 11:32:04 UTC (rev 478) @@ -221,8 +221,7 @@ ## def reinstall_package(package, automated_build=false) logger = Logger.new($JOURNAL) - # TODO: look into refactoring myLogger: - myLogger = AbtLogManager.new + manager = AbtPackageManager.new system = AbtSystemManager.new # check for frozen. @@ -265,7 +264,7 @@ puts "\n\n" logger.info("Completed reinstall of #{package}.") - if (myLogger.cache_package(package)) + if (manager.cache_package(package)) puts "\n\n" puts "*** Completed caching of package #{package}. ***" puts "\n\n" @@ -421,4 +420,93 @@ exit end end + + ## + # Provides a complete log of the given packages build. Includes everything + # needed to duplicate the build at a later date. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if package cache created successfully, + # otherwise false. + ## + def cache_package(package) + system = AbtSystemManager.new + logger = AbtLogManager.new + + if (system.package_installed(package)) + sw = eval("#{package.capitalize}.new") + cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir + sourcePath = $SOURCES_REPOSITORY + "/" + File.basename(sw.srcUrl) + sourceFile = File.basename(sw.srcUrl) + installLog = logger.get_log(package, 'install') + buildLog = logger.get_log(package, 'build') + configureLog = logger.get_log(package, 'configure') + integrityLog = logger.get_log(package, 'integrity') + packageFile = "#{$PACKAGE_PATH}#{package}.rb" + + + FileUtils.mkdir_p(cachedDir) + + # collect package source. + if (FileTest::exist?(sourcePath)) + FileUtils.copy_file(sourcePath, "#{cachedDir}/#{sourceFile}") + puts "\nCaching copy of #{package} source." + else + puts "\nUnable to cache copy of #{package} source." + end + + # collect package install log. + if (FileTest::exist?(installLog)) + FileUtils.copy_file(installLog, "#{cachedDir}/#{sw.srcDir}.install") + puts "\nCaching copy of #{package} install log." + else + puts "\nUnable to cache copy of #{package} install log." + end + + # collect package build log. + if (FileTest::exist?(buildLog)) + FileUtils.copy_file(buildLog, "#{cachedDir}/#{sw.srcDir}.build") + puts "\nCaching copy of #{package} build log." + else + puts "\nUnable to cache copy of #{package} build log." + end + + # collect package configure log. + if (FileTest::exist?(configureLog)) + FileUtils.copy_file(configureLog, "#{cachedDir}/#{sw.srcDir}.configure") + puts "\nCaching copy of #{package} configure log." + else + puts "\nUnable to cache copy of #{package} configure log." + end + + # collect package integrity log. + if (FileTest::exist?(integrityLog)) + FileUtils.copy_file(integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity") + puts "\nCaching copy of #{package} integrity log." + else + puts "\nUnable to cache copy of #{package} integrity log." + end + + # collect package description (class file). + if (FileTest::exist?(packageFile)) + FileUtils.copy_file(packageFile, "#{cachedDir}/#{package}.rb") + puts "\nCaching copy of #{package} package description." + else + puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" + end + + # tar and bzip this directory (package-cache-version.tar.bz2) + Dir.chdir($PACKAGE_CACHED) + if (system("tar -cf #{sw.srcDir}.tar #{sw.srcDir}") && + system("bzip2 -f #{sw.srcDir}.tar")) + # last but not least, remove our tarball directory + FileUtils.rm_rf(cachedDir) + return true + end + end + + return false # package not installed, can't cache it. + end + end Modified: src/trunk/tests/testabtlogmanager.rb =================================================================== --- src/trunk/tests/testabtlogmanager.rb 2008-01-12 18:32:06 UTC (rev 477) +++ src/trunk/tests/testabtlogmanager.rb 2008-01-14 11:32:04 UTC (rev 478) @@ -96,15 +96,4 @@ assert(@logger.log_package_build("ipc"), "test_log_package_build()") end - ## - # Test method for 'AbtLogManager.test_cache_package()' - ## - def test_cache_package() - if !@system.package_installed("ipc") - @manager.install_package("ipc") - end - - assert(@logger.cache_package("ipc"), "test_cache_package()") - end - end Modified: src/trunk/tests/testabtpackagemanager.rb =================================================================== --- src/trunk/tests/testabtpackagemanager.rb 2008-01-12 18:32:06 UTC (rev 477) +++ src/trunk/tests/testabtpackagemanager.rb 2008-01-14 11:32:04 UTC (rev 478) @@ -130,5 +130,16 @@ assert(true) end end - + + ## + # Test method for 'AbtLogManager.test_cache_package()' + ## + def test_cache_package() + if !@system.package_installed("ipc") + @manager.install_package("ipc") + end + + assert(@manager.cache_package("ipc"), "test_cache_package()") + end + end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2008-01-20 16:46:09
|
Revision: 479 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=479&view=rev Author: eschabell Date: 2008-01-20 08:45:39 -0800 (Sun, 20 Jan 2008) Log Message: ----------- Commented out the downgrade feature... this will be postponed for future implementation. After some discussion on the forums with LOW I have decided to comment this feature out and wait with it. Modified Paths: -------------- src/trunk/abt.rb src/trunk/libs/abtpackagemanager.rb src/trunk/libs/abtusage.rb src/trunk/tests/testabtpackagemanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-14 11:32:04 UTC (rev 478) +++ src/trunk/abt.rb 2008-01-20 16:45:39 UTC (rev 479) @@ -200,19 +200,22 @@ show.usage("packages") exit end + +## +# [POSTPONED FEATURE, TO BE ADDED AT LATER VERSION/DATE] +## +#when "downgrade", "-dg" +# if (ARGV.length == 3) +# options['version'] = ARGV[1] +# options['package'] = ARGV[2] +# # FIXME: downgrade pkg implementation. +# print "Downgradinging package : #{options['package']} " +# puts "to version : #{options['version']}" +# else +# show.usage("packages") +# exit +# end -when "downgrade", "-dg" - if (ARGV.length == 3) - options['version'] = ARGV[1] - options['package'] = ARGV[2] - # FIXME: downgrade pkg implementation. - 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] Modified: src/trunk/libs/abtpackagemanager.rb =================================================================== --- src/trunk/libs/abtpackagemanager.rb 2008-01-14 11:32:04 UTC (rev 478) +++ src/trunk/libs/abtpackagemanager.rb 2008-01-20 16:45:39 UTC (rev 479) @@ -337,7 +337,7 @@ end ## - # Downgrades a given package. + # Downgrades a given package. [POSTPONED FEATURE, TO BE ADDED AT LATER VERSION/DATE] # # <b>PARAM</b> <i>String</i> - the name of the package to be downgraded. # @@ -346,19 +346,19 @@ # <b>RETURN</b> <i>boolean</i> - True if the package is downgraded, otherwise # false. ## - def downgrade_package(package, version) - system = AbtSystemManager.new - logger = Logger.new($JOURNAL) - - # check for frozen. - if (system.package_frozen(package)) - logger.info "Package #{package} is frozen, can not proceed with downgrade package call." - puts "\nPackage #{package} is frozen, can not proceed with downgrade package call." - return false - end - - return false - end +# def downgrade_package(package, version) +# system = AbtSystemManager.new +# logger = Logger.new($JOURNAL) +# +# # check for frozen. +# if (system.package_frozen(package)) +# logger.info "Package #{package} is frozen, can not proceed with downgrade package call." +# puts "\nPackage #{package} is frozen, can not proceed with downgrade package call." +# return false +# end +# +# return false +# end ## # Freezes a given package. If successful will add give package to the frozen Modified: src/trunk/libs/abtusage.rb =================================================================== --- src/trunk/libs/abtusage.rb 2008-01-14 11:32:04 UTC (rev 478) +++ src/trunk/libs/abtusage.rb 2008-01-20 16:45:39 UTC (rev 479) @@ -76,9 +76,13 @@ puts " -i, install [package]\t\tInstall given package." puts " -ri, reinstall [package]\t\tReinstall given package." puts " -r, remove [package]\t\tRemove given package." - puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" - puts "\t\t\t\t\tIf the given package is already frozen, it will be released.\n" + puts "\t\t\t\t\tIf the given package is already frozen, it will be released.\n" + + ## + # [POSTPONED FEATURE, TO BE ADDED AT LATER VERSION/DATE] + ## + # puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." end ## Modified: src/trunk/tests/testabtpackagemanager.rb =================================================================== --- src/trunk/tests/testabtpackagemanager.rb 2008-01-14 11:32:04 UTC (rev 478) +++ src/trunk/tests/testabtpackagemanager.rb 2008-01-20 16:45:39 UTC (rev 479) @@ -98,20 +98,23 @@ assert(@pkgMgr.remove_package("ipc"), "test_remove_package()") end +## +# [POSTPONED FEATURE, TO BE ADDED AT LATER VERSION/DATE] +## ## # Test method for 'AbtPackageManager.test_downgrade_package()' ## - def test_downgrade_package - if !@system.package_installed("ipc") - @manager.install_package("ipc") - end - - if @system.package_frozen("ipc") - @manager.freeze_package("ipc") - end - - assert(@pkgMgr.downgrade_package("ipc", "1.2"), "test_downgrade_package()") - end +# def test_downgrade_package +# if !@system.package_installed("ipc") +# @manager.install_package("ipc") +# end +# +# if @system.package_frozen("ipc") +# @manager.freeze_package("ipc") +# end +# +# assert(@pkgMgr.downgrade_package("ipc", "1.2"), "test_downgrade_package()") +# end ## # Test method for 'AbtPackageManager.test_freeze_package()' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2008-01-20 20:25:59
|
Revision: 482 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=482&view=rev Author: eschabell Date: 2008-01-20 12:25:43 -0800 (Sun, 20 Jan 2008) Log Message: ----------- Refactored to include a DEFAULT_PREFIX for all paths used by abt, default is /usr/local. This means entire abt setup is in /usr/local/*. Many fixes applied throughout code base to facilitate this rework. Modified Paths: -------------- src/trunk/abt.rb src/trunk/abtconfig.rb src/trunk/libs/abtdownloadmanager.rb src/trunk/libs/abtlogmanager.rb src/trunk/libs/abtpackagemanager.rb src/trunk/libs/abtreportmanager.rb src/trunk/libs/abtsystemmanager.rb src/trunk/tests/testabtdownloadmanager.rb src/trunk/tests/testabtpackage.rb src/trunk/tests/testabtreportmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/abt.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -27,9 +27,10 @@ # Check and install our library files. # +$DEFAULT_PREFIX = "/usr/local" $ABTLINUX_CLASS_LIBS = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/libs" -if (! File.directory?('/var/lib/abt') || Dir["/var/lib/abt"].empty?) +if (! File.directory?("#{$DEFAULT_PREFIX}/var/lib/abt") || Dir["#{$DEFAULT_PREFIX}/var/lib/abt"].empty?) puts "\nMissing needed AbTLinux library files at /var/lib/abt" puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" @@ -38,18 +39,18 @@ puts "\nMust be root to fix library files." exit else - system("svn co #{$ABTLINUX_CLASS_LIBS} /var/lib/abt/") + system("svn co #{$ABTLINUX_CLASS_LIBS} #{$DEFAULT_PREFIX}/var/lib/abt/") end - $LOAD_PATH.unshift '/var/lib/abt/' + $LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/var/lib/abt/" end # Load our central configuration file. # $ABTLINUX_MAIN_CONFIG = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/abtconfig.rb" -if File.exist?("/etc/abt/abtconfig.rb") - $LOAD_PATH.unshift '/etc/abt/' +if File.exist?("#{$DEFAULT_PREFIX}/etc/abt/abtconfig.rb") + $LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/etc/abt/" load 'abtconfig.rb' else # missing configuration file, do some abt update? @@ -61,20 +62,20 @@ puts "\nMust be root to fix configuration files." exit else - ["/etc/abt", "/etc/abt/local"].each { |dir| + ["#{$DEFAULT_PREFIX}/etc/abt", "#{$DEFAULT_PREFIX}/etc/abt/local"].each { |dir| if (! File.directory?(dir)) FileUtils.mkdir_p(dir) puts "Created directory: #{dir}." end } - system("svn export #{$ABTLINUX_MAIN_CONFIG} /etc/abt/abtconfig.rb") + system("svn export #{$ABTLINUX_MAIN_CONFIG} #{$DEFAULT_PREFIX}/etc/abt/abtconfig.rb") end - $LOAD_PATH.unshift '/etc/abt/' + $LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/etc/abt/" load 'abtconfig.rb' - if File.exist?("/etc/abt/local/localconfig.rb") - $LOAD_PATH.unshift '/etc/abt/local/' + if File.exist?("#{$DEFAULT_PREFIX}/etc/abt/local/localconfig.rb") + $LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/etc/abt/local/" load 'localconfig.rb' end end @@ -107,8 +108,8 @@ myLogger = AbtLogManager.new # And loading local file if found. -if File.exist?("/etc/abt/local/localconfig.rb") - load '/etc/abt/local/localconfig.rb' +if File.exist?("#{$DEFAULT_PREFIX}/etc/abt/local/localconfig.rb") + load "#{$DEFAULT_PREFIX}/etc/abt/local/localconfig.rb" end @@ -117,7 +118,7 @@ # abt [ -i | install ] <package> when "install", "-i" - if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}#{ARGV[1]}.rb")) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}/#{ARGV[1]}.rb")) options['package'] = ARGV[1] logger.info("Starting to install #{options['package']}") @@ -135,7 +136,7 @@ puts "\n\n" logger.info("Completed install of #{options['package']}.") - if (myLogger.cache_package(options['package'])) + if (manager.cache_package(options['package'])) puts "\n\n" puts "*** Completed caching of package #{options['package']}. ***" puts "\n\n" @@ -152,7 +153,7 @@ end when "reinstall", "-ri" - if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}#{ARGV[1]}.rb")) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}/#{ARGV[1]}.rb")) options['package'] = ARGV[1] logger.info("Starting to reinstall #{options['package']}") @@ -180,7 +181,7 @@ puts "\n\n" puts "*** No need to remove #{options['package']}, it was not installed! ***" puts "\n\n" - logger.info("Unabel to complete removal of #{options['package']}.") + logger.info("Completed removal of #{options['package']}.") exit end @@ -189,11 +190,10 @@ puts "\n\n" puts "*** Completed removal of #{options['package']}. ***" puts "\n\n" - logger.info("Unabel to complete removal of #{options['package']}.") + logger.info("Complete removal of #{options['package']}.") + exit end - puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" - logger.info("Unabel to complete removal of #{options['package']}.") else puts "\n*** Unable to completed removal of #{options['package']}, see why in the journal. ***" logger.info("Unabel to complete removal of #{options['package']}.") @@ -265,7 +265,7 @@ # abt show-details <package> when "show-details" - if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}/#{ARGV[1]}.rb")) options['pkg'] = ARGV[1] logger.info("Starting show details for #{options['pkg']}") @@ -343,7 +343,7 @@ end when "show-depends" - if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}/#{ARGV[1]}.rb")) options['pkg'] = ARGV[1] logger.info("Starting show depends for #{options['pkg']}") if (reporter.show_package_dependencies(options['pkg'])) @@ -471,7 +471,7 @@ # abt [-d | download ] <package> when "download", "-d" - if (ARGV.length == 2 && File.exist?($PACKAGE_PATH + ARGV[1] + ".rb")) + if (ARGV.length == 2 && File.exist?("#{$PACKAGE_PATH}/#{ARGV[1]}.rb")) options['pkg'] = ARGV[1] logger.info("Starting to download " + options['pkg']) @@ -696,13 +696,13 @@ end end - when "remove" + when "remove" # FIXME: implement this. - if options['repoUri'].length > 0 - puts "Removing package repository : " + options['repoUri'] - else - puts "Removing package repository : Default AbTLinux Package Tree" - end + if options['repoUri'].length > 0 + puts "TODO: Removing package repository : " + options['repoUri'] + else + puts "TODO: Removing package repository : Default AbTLinux Package Tree" + end when "list" # FIXME: implement this. Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/abtconfig.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -1,6 +1,6 @@ #!/usr/bin/ruby -w - -$LOAD_PATH.unshift '/var/lib/abt/' +$DEFAULT_PREFIX = "/usr/local" +$LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/var/lib/abt/" ## # abtconfig.rb # @@ -43,19 +43,19 @@ require 'digest/sha1' # default paths / locations. -$ABT_LOGS = "/var/log/abt" -$ABT_CACHES = "/var/spool/abt" -$ABT_STATE = "/var/state/abt" +$ABT_LOGS = "#{$DEFAULT_PREFIX}/var/log/abt" +$ABT_CACHES = "#{$DEFAULT_PREFIX}/var/spool/abt" +$ABT_STATE = "#{$DEFAULT_PREFIX}/var/state/abt" $ABT_TMP = "/tmp/abt" -$ABT_CONFIG = "/etc/abt" -$ABT_LIBS = "/var/lib/abt" -$ABT_LOCAL_CONFIG = "/etc/abt/local" +$ABT_CONFIG = "#{$DEFAULT_PREFIX}/etc/abt" +$ABT_LIBS = "#{$DEFAULT_PREFIX}/var/lib/abt" +$ABT_LOCAL_CONFIG = "#{$DEFAULT_PREFIX}/etc/abt/local" $ABTNEWS_LOG = "#{$ABT_LOGS}/news.log" -$BUILD_LOCATION = "/usr/src" -$JOURNAL = "#{$ABT_LOGS}/journal.log" # use logger.info. +$BUILD_LOCATION = "#{$DEFAULT_PREFIX}/usr/src" +$JOURNAL = "#{$ABT_LOGS}/journal.log" # use logger.info. $PACKAGE_INSTALLED = "#{$ABT_STATE}/installed" $PACKAGE_CACHED = "#{$ABT_STATE}/cached" -$PACKAGE_PATH = "#{$ABT_CACHES}/packages/" +$PACKAGE_PATH = "#{$ABT_CACHES}/packages" $SOURCES_REPOSITORY = "#{$ABT_CACHES}/sources" @@ -64,7 +64,6 @@ $ABT_VERSION = "0.1" $BUILD_ARCHITECTURE = "i686" $BUILD_OPTIMIZATIONS = "strip" -$DEFAULT_PREFIX = "/usr/local" $REMOVE_BUILD_SOURCES = true $TIMESTAMP = Time.now.strftime( "%Y-%m-%d %H:%M:%S (%Z)" ) $PAGER_DEFAULT = "less -R -E -X -f" Modified: src/trunk/libs/abtdownloadmanager.rb =================================================================== --- src/trunk/libs/abtdownloadmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/libs/abtdownloadmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -54,7 +54,7 @@ # downloaded, otherwise false. ## def retrieve_package_source(packageName, destination) - require "#{$PACKAGE_PATH}#{packageName}" + require "#{$PACKAGE_PATH}/#{packageName}" logger = Logger.new($JOURNAL) package = eval(packageName.capitalize + '.new') @@ -81,12 +81,12 @@ # otherwise false. ## def retrieve_package_tree(packageTreeName="AbTLinux") - logger = Logger.new($JOURNAL) + logger = Logger.new($JOURNAL) # check if package tree exists. if File.directory?($PACKAGE_PATH) # check if svn directory. - if File.directory?("#{$PACKAGE_PATH}.svn") + if File.directory?("#{$PACKAGE_PATH}/.svn") logger.info "Package tree #{packageTreeName} already installed." return true else @@ -179,7 +179,7 @@ # check if package exists in tree. if File.exists?("#{$PACKAGE_PATH}/#{packageName}.rb") # check if svn directory. - if File.directory?("#{$PACKAGE_PATH}.svn") + if File.directory?("#{$PACKAGE_PATH}/.svn") if system("svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb") logger.info "Package #{packageName.downcase} updated (svn update)" else @@ -208,13 +208,14 @@ # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, # otherwise false. ## - def update_package_tree(packageTreeName="AbTLinux") - logger = Logger.new($JOURNAL) + #def update_package_tree(packageTreeName="AbTLinux") + def update_package_tree() + logger = Logger.new($JOURNAL) # check if package tree exists. if File.directory?($PACKAGE_PATH) # check if svn directory. - if File.directory?("#{$PACKAGE_PATH}.svn") + if File.directory?("#{$PACKAGE_PATH}/.svn") if system("svn update #{$PACKAGE_PATH}") logger.info "Package tree updated (svn update)" else Modified: src/trunk/libs/abtlogmanager.rb =================================================================== --- src/trunk/libs/abtlogmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/libs/abtlogmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -41,7 +41,7 @@ # <b>RETURN</b> <i>String</i> - Full path to install log. ## def get_log(package, type) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") details = sw.details Modified: src/trunk/libs/abtpackagemanager.rb =================================================================== --- src/trunk/libs/abtpackagemanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/libs/abtpackagemanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -89,7 +89,7 @@ # false. ## def install_package(package, verbose=true) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") queuer = AbtQueueManager.new logger = Logger.new($JOURNAL) @@ -251,11 +251,6 @@ end else puts "\n*** Package #{package} is not installed, we will install it for you now! ***\n" - puts "Hit enter to continue..." - while continue = STDIN.gets - continue.chomp! - break - end end if (install_package(package)) @@ -287,7 +282,7 @@ # false. ## def remove_package(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") # TODO: refactor myLogger. myLogger = AbtLogManager.new @@ -370,7 +365,7 @@ # false. ## def freeze_package(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") logger = Logger.new($JOURNAL) system = AbtSystemManager.new Modified: src/trunk/libs/abtreportmanager.rb =================================================================== --- src/trunk/libs/abtreportmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/libs/abtreportmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -51,7 +51,7 @@ # otherwise false. ## def show_package_details(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" if (package = eval("#{package.capitalize}.new")) details = package.details @@ -184,7 +184,7 @@ # hash of problem files and their encountered errors. ## def show_package_dependencies(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" if (package = eval("#{package.capitalize}.new")) details = package.details @@ -284,8 +284,8 @@ packageName = packageArray[0] # check for match to name and description if the package file exists. - if (File.exist?("#{$PACKAGE_PATH}#{packageName}.rb")) - require "#{$PACKAGE_PATH}#{packageName}" + if (File.exist?("#{$PACKAGE_PATH}/#{packageName}.rb")) + require "#{$PACKAGE_PATH}/#{packageName}" sw = eval("#{packageName.capitalize}.new") # add if matches name or description entries. Modified: src/trunk/libs/abtsystemmanager.rb =================================================================== --- src/trunk/libs/abtsystemmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/libs/abtsystemmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -196,7 +196,7 @@ # file names and the values are the package name and the problem detected. ## def verify_package_integrity(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") # TODO: refactor myLogger. @@ -290,7 +290,7 @@ # false. ## def package_installed(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") if (found_entry($PACKAGE_INSTALLED, sw.srcDir)) @@ -310,7 +310,7 @@ # false. ## def package_frozen(package) - require "#{$PACKAGE_PATH}#{package}" + require "#{$PACKAGE_PATH}/#{package}" sw = eval("#{package.capitalize}.new") # looking for frozen log file. Modified: src/trunk/tests/testabtdownloadmanager.rb =================================================================== --- src/trunk/tests/testabtdownloadmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/tests/testabtdownloadmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -92,6 +92,6 @@ # ensure a tarball is available to test! FileUtils.cp "#{$PACKAGE_PATH}/ipc-1.4.tar.gz", "#{$SOURCES_REPOSITORY}", :verbose => true if !File.exist?("#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz") - assert(@download.validated('e81278607b1d65dcb18c3613ec00fbf588b50319', "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz"), "test_validated") + assert(@download.validated('c7100a74f4f6cafa4607bc5bd68a1175a1876ecc', "#{$SOURCES_REPOSITORY}/ipc-1.4.tar.gz"), "test_validated") end end Modified: src/trunk/tests/testabtpackage.rb =================================================================== --- src/trunk/tests/testabtpackage.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/tests/testabtpackage.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -1,11 +1,12 @@ #!/usr/bin/ruby -w $LOAD_PATH.unshift '../' -$LOAD_PATH.unshift '/var/spool/abt/packages/' require 'test/unit/testcase' require 'test/unit/autorunner' require 'abtconfig' + +$LOAD_PATH.unshift "#{$DEFAULT_PREFIX}/var/spool/abt/packages/" require 'ipc' ## Modified: src/trunk/tests/testabtreportmanager.rb =================================================================== --- src/trunk/tests/testabtreportmanager.rb 2008-01-20 20:07:24 UTC (rev 481) +++ src/trunk/tests/testabtreportmanager.rb 2008-01-20 20:25:43 UTC (rev 482) @@ -101,13 +101,6 @@ end ## - # Test method for 'AbtReportManager.test_show_package_dependencies()' - ## - def test_show_package_dependencies - assert(false, "test_show_package_dependencies()") - end - - ## # Test method for 'AbtReportManager.test_show_untracked_files()' ## def test_show_untracked_files This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2008-01-27 09:19:12
|
Revision: 487 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=487&view=rev Author: eschabell Date: 2008-01-27 01:19:16 -0800 (Sun, 27 Jan 2008) Log Message: ----------- Adjusted startup to initialize logging directories as needed if missing. Modified Paths: -------------- src/trunk/abt.rb src/trunk/libs/abtlogmanager.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-21 21:53:38 UTC (rev 486) +++ src/trunk/abt.rb 2008-01-27 09:19:16 UTC (rev 487) @@ -101,7 +101,12 @@ system = AbtSystemManager.new options = Hash.new show = AbtUsage.new +myLogger = AbtLogManager.new # initializes all ABT directories if missing. +# setup timestamp. +logger = Logger.new($JOURNAL) # initializes all needed paths. +logger.datetime_format = "%Y-%m-%d %H:%M:%S " + # deal with usage request. if (ARGV.length == 0 || (ARGV.length == 1 && (ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help'))) show.usage("all") @@ -111,13 +116,6 @@ # login as root for the rest. manager.root_login(ARGV) -# setup timestamp. -logger = Logger.new($JOURNAL) # initializes all needed paths. -logger.datetime_format = "%Y-%m-%d %H:%M:%S " - -# TODO: used only until refactoring done. -myLogger = AbtLogManager.new - # And loading local file if found. if File.exist?("#{$DEFAULT_PREFIX}/etc/abt/local/localconfig.rb") load "#{$DEFAULT_PREFIX}/etc/abt/local/localconfig.rb" Modified: src/trunk/libs/abtlogmanager.rb =================================================================== --- src/trunk/libs/abtlogmanager.rb 2008-01-21 21:53:38 UTC (rev 486) +++ src/trunk/libs/abtlogmanager.rb 2008-01-27 09:19:16 UTC (rev 487) @@ -78,7 +78,12 @@ # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. ## def initialize - logger = Logger.new($JOURNAL) + if (! File.directory?($JOURNAL)) + # logging directory missing, create it! + FileUtils.mkdir_p($ABT_LOGS) + end + + logger = Logger.new($JOURNAL) [$ABT_LOGS, $ABT_CACHES, $ABT_STATE, $BUILD_LOCATION, $PACKAGE_INSTALLED, $ABT_LIBS, $PACKAGE_CACHED, $ABT_TMP, $ABT_CONFIG, $ABT_LOCAL_CONFIG, $SOURCES_REPOSITORY].each { |dir| This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2008-01-28 09:54:30
|
Revision: 492 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=492&view=rev Author: eschabell Date: 2008-01-28 01:54:36 -0800 (Mon, 28 Jan 2008) Log Message: ----------- Found the fix I was looking for to determine and deal with exit code of called system command, refactored abtpackage and abtdownloadmananger to use this. Modified Paths: -------------- src/trunk/abt.rb src/trunk/libs/abtdownloadmanager.rb src/trunk/libs/abtpackage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2008-01-27 21:35:54 UTC (rev 491) +++ src/trunk/abt.rb 2008-01-28 09:54:36 UTC (rev 492) @@ -532,7 +532,7 @@ puts "Start updating package tree : #{options['updateItem']}." logger.info "Start updating package tree : #{options['updateItem']}." - if downloader.update_package_tree(options['updateItem']) + if downloader.update_package_tree puts "Updated package tree : #{options['updateItem']}." else puts "Unable to update package tree : #{options['updateItem']}." Modified: src/trunk/libs/abtdownloadmanager.rb =================================================================== --- src/trunk/libs/abtdownloadmanager.rb 2008-01-27 21:35:54 UTC (rev 491) +++ src/trunk/libs/abtdownloadmanager.rb 2008-01-28 09:54:36 UTC (rev 492) @@ -59,12 +59,13 @@ package = eval(packageName.capitalize + '.new') if (File.exist?("#{destination}/#{File.basename(package.srcUrl)}")) - logger.info("Download not needed, existing source found for #{packageName}") + logger.info("Download not needed, existing source found for #{packageName}.") return true end Dir.chdir(destination) if !system("wget #{package.srcUrl}") + logger.error("Download failed, unable to retrieve package #{packageName} sources, exit code was #{$?.exitstatus}.") return false # download failed. end @@ -99,11 +100,11 @@ # pacakge directory does not exist, svn co. if !system("svn co #{$ABTLINUX_PACKAGES} #{$PACKAGE_PATH}") - logger.error "Package tree not installed (svn co), problems!" + logger.error "Package tree #{packageTreeName} not installed (svn co), exit status was #{$?.exitstatus}." return false end - logger.info "Package tree installed (svn co)" + logger.info "Package tree #{packageTreeName} installed (svn co)." end return true @@ -180,11 +181,11 @@ # check if svn directory. if File.directory?("#{$PACKAGE_PATH}/.svn") if !system("svn update #{$PACKAGE_PATH}/#{packageName.downcase}.rb") - logger.error "Package #{packageName.downcase} unable to update (svn update)." + logger.error "Package #{packageName.downcase} unable to update (svn update), exit status was #{$?.exitstatus}." return false end - logger.info "Package #{packageName.downcase} updated (svn update)" + logger.info "Package #{packageName.downcase} updated (svn update)." else # package exists, but not an valid tree. logger.error "Package #{packageName} exists, but not valid package tree (svn)." @@ -202,12 +203,9 @@ ## # Updates the package tree. # - # <b>PARAM</b> <i>String</i> - the name of the tree to be updated, defaults to AbTLinux repo. - # # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, # otherwise false. ## - #def update_package_tree(packageTreeName="AbTLinux") def update_package_tree() logger = Logger.new($JOURNAL) @@ -216,7 +214,7 @@ # check if svn directory. if File.directory?("#{$PACKAGE_PATH}/.svn") if !system("svn update #{$PACKAGE_PATH}") - logger.error "Package tree unable to update (svn update)." + logger.error "Package tree unable to update (svn update), exit status was #{$?.exitstatus}." return false end Modified: src/trunk/libs/abtpackage.rb =================================================================== --- src/trunk/libs/abtpackage.rb 2008-01-27 21:35:54 UTC (rev 491) +++ src/trunk/libs/abtpackage.rb 2008-01-28 09:54:36 UTC (rev 492) @@ -78,7 +78,9 @@ end Dir.chdir($BUILD_LOCATION) - if !system("#{unpackTool} #{sourcesToUnpack}") + output = `#{unpackTool} #{sourcesToUnpack}` + exitcode = $?.exitstatus + if (exitcode != 0) return false end @@ -251,13 +253,13 @@ end Dir.chdir("#{$BUILD_LOCATION}/#{@srcDir}") - - if !system(command) - puts "[AbtPackage.configure] - configure section failed." + + if !system(command) + puts "[AbtPackage.configure] - configure section failed, exit code was #{$?.exitstatus}." return false - end - - puts "[AbtPackage.configure] - configure section completed!" if (verbose) + end + + puts "[AbtPackage.configure] - configure section completed, exit code was #{$?.exitstatus}!" if (verbose) return true end @@ -281,11 +283,11 @@ Dir.chdir("#{$BUILD_LOCATION}/#{@srcDir}") if !system(command) - puts "[AbtPackage.build] - build section failed." + puts "[AbtPackage.build] - build section failed, exit code was #{$?.exitstatus}." return false end - puts "[AbtPackage.build] - build section completed!" if (verbose) + puts "[AbtPackage.build] - build section completed, exit code was #{$?.exitstatus}!" if (verbose) return true end @@ -329,11 +331,11 @@ Dir.chdir("#{$BUILD_LOCATION}/#{@srcDir}") if !system(command) - puts "[AbtPackage.install] - install section failed." + puts "[AbtPackage.install] - install section failed, exit code was #{$?.exitstatus}." return false end - puts "[AbtPackage.install] - install section completed!" if (verbose) + puts "[AbtPackage.install] - install section completed, exit code was #{$?.exitstatus}!" if (verbose) return true end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |