abtlinux-svn Mailing List for ABout Time Linux (AbTLinux) (Page 9)
Status: Alpha
Brought to you by:
eschabell
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(12) |
Apr
(4) |
May
(61) |
Jun
(5) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
(29) |
Nov
(89) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(4) |
Feb
(33) |
Mar
(12) |
Apr
|
May
(2) |
Jun
(13) |
Jul
(76) |
Aug
(7) |
Sep
(21) |
Oct
|
Nov
|
Dec
(33) |
2008 |
Jan
(32) |
Feb
(24) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(10) |
From: <esc...@us...> - 2007-07-16 13:32:47
|
Revision: 361 http://svn.sourceforge.net/abtlinux/?rev=361&view=rev Author: eschabell Date: 2007-07-16 06:32:49 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated dog generation and usage classes to rubified file names. Modified Paths: -------------- src/trunk/abtconfig.rb Added Paths: ----------- src/trunk/abtusage.rb src/trunk/docgen.sh Removed Paths: ------------- src/trunk/AbtUsage.rb src/trunk/docGen.sh Deleted: src/trunk/AbtUsage.rb =================================================================== --- src/trunk/AbtUsage.rb 2007-07-16 13:31:07 UTC (rev 360) +++ src/trunk/AbtUsage.rb 2007-07-16 13:32:49 UTC (rev 361) @@ -1,158 +0,0 @@ -#!/usr/bin/ruby -I./packages - -## -# AbtUsage.rb -# -# The usage reporting class for AbTLinux. -# -# Created by Eric D. Schabell <er...@ab...> -# Copyright November 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 AbtUsage - - ## - # The main usage method, displays either a given section or all sections. - # - # <b>PARAM</b> <i>String</i> - the name of the help section to be shown. - # - # <b>RETURN</b> <i>void</i> - ## - def usage( section ) - puts "Usage: abt.rb [options]\n\n" - - case section - - when "packages" - usagePackages - - when "queries" - usageQueries - - when "generation" - usageGeneration - - when "downloads" - usageDownloads - - when "fix" - usageFix - - when "maintenance" - usageMaintenance - - else - usagePackages - usageQueries - usageGeneration - usageDownloads - usageFix - usageMaintenance - end - end - - ## - # The usage information for the packages commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usagePackages - puts "\npackages:" - puts " -i, install [package]\t\tInstall given package." - puts " -ri, reinstall [package]\t\tReinstall given package." - puts " -r, remove [package]\t\tRemove given package." - puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." - puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" - end - - ## - # The usage information for the query commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageQueries - puts "\nqueries:" - puts " -s, search [string | regexp ]\tSearch package descriptions for given input." - puts " -v, --version\t\t\tShow abt package manager version." - puts " show-details [package]\t\tShow give package details." - puts " show-build [package]\t\tShow build log of given package." - puts " show-depends [package]\t\tShow the dependency tree of given package." - puts " show-files [package]\t\tShow all installed files from given package." - puts " show-owner [file]\t\tShow the package owning given file." - puts " show-installed\t\t\tShow list of all installed packages." - puts " show-frozen\t\t\t\tShow list of all frozen packages." - puts " show-untracked\t\t\tShow all files on system not tracked by AbTLinux." - puts " show-journal\t\t\t\tShow the system journal." - puts " show-iqueue\t\t\t\tShow the contents of the install queue." - puts " show-patches\t\t\t\tShow the current available patches for installed package tree.\n" - end - - ## - # The usage information for the generation commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageGeneration - puts "\ngeneration:" - puts " show-updates\t\tShow a package listing with available update versions." - puts " html\t\t\tGenerate HTML page from installed packages:" - puts " \t\t\t\t(package name with hyperlink to package website and version installed)\n" - end - - ## - # The usage information for the download commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageDownloads - puts "\ndownloads:" - puts " -d, download [package]\t\tRetrieve given package sources." - puts " -u, update [package]|[tree]\tUpdate given package or tree from AbTLinux repository." - puts " -n, news\t\t\t\tDisplays newsfeeds from AbTLinux website.\n" - end - - ## - # The usage information for the fix commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageFix - puts "\nfix:" - puts " purge-src\t\t\t\tRemove source caches for packages no longer installed." - puts " purge-logs\t\t\t\tRemove log files for packages no longer installed." - puts " verify-files [package]\t\tInstalled files are verified for given package." - puts " verify-symlinks [package]\t\tSymlinks verified for given package." - puts " verify-deps [package]\t\tDependency tree is verified for given package." - puts " verify-integrity [package]\t\tVerify integrity of installed files for given package." - puts " fix [package]\t\tGiven package is verified and fixed if needed.\n" - end - - ## - # The usage information for the maintenance commands. - # - # <b>RETURN</b> <i>void</i> - ## - def usageMaintenance - puts "\nmaintenance:" - puts " build-location [host]\t\tSets global location (default: localhost) for retrieving cached package builds." - puts " package-repo [add|remove|list] [URI]" - puts " add - add package repository to list." - puts " remove - remove a package repository from list." - puts " list - display current repository list.\n" - end -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 13:31:07 UTC (rev 360) +++ src/trunk/abtconfig.rb 2007-07-16 13:32:49 UTC (rev 361) @@ -34,7 +34,7 @@ require 'abtqueuemanager' require 'abtreportmanager' require 'abtsystemmanager' -require 'AbtUsage' +require 'abtusage' require 'fileutils' require 'find' Copied: src/trunk/abtusage.rb (from rev 358, src/trunk/AbtUsage.rb) =================================================================== --- src/trunk/abtusage.rb (rev 0) +++ src/trunk/abtusage.rb 2007-07-16 13:32:49 UTC (rev 361) @@ -0,0 +1,158 @@ +#!/usr/bin/ruby -I./packages + +## +# abtusage.rb +# +# The usage reporting class for AbTLinux. +# +# Created by Eric D. Schabell <er...@ab...> +# Copyright November 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 AbtUsage + + ## + # The main usage method, displays either a given section or all sections. + # + # <b>PARAM</b> <i>String</i> - the name of the help section to be shown. + # + # <b>RETURN</b> <i>void</i> + ## + def usage( section ) + puts "Usage: abt.rb [options]\n\n" + + case section + + when "packages" + usagePackages + + when "queries" + usageQueries + + when "generation" + usageGeneration + + when "downloads" + usageDownloads + + when "fix" + usageFix + + when "maintenance" + usageMaintenance + + else + usagePackages + usageQueries + usageGeneration + usageDownloads + usageFix + usageMaintenance + end + end + + ## + # The usage information for the packages commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usagePackages + puts "\npackages:" + puts " -i, install [package]\t\tInstall given package." + puts " -ri, reinstall [package]\t\tReinstall given package." + puts " -r, remove [package]\t\tRemove given package." + puts " -dg, downgrade [version] [package]\tDowngrade given package to given version." + puts " -f, freeze [package]\t\tHolds given package at current version, prevents upgrades.\n" + end + + ## + # The usage information for the query commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageQueries + puts "\nqueries:" + puts " -s, search [string | regexp ]\tSearch package descriptions for given input." + puts " -v, --version\t\t\tShow abt package manager version." + puts " show-details [package]\t\tShow give package details." + puts " show-build [package]\t\tShow build log of given package." + puts " show-depends [package]\t\tShow the dependency tree of given package." + puts " show-files [package]\t\tShow all installed files from given package." + puts " show-owner [file]\t\tShow the package owning given file." + puts " show-installed\t\t\tShow list of all installed packages." + puts " show-frozen\t\t\t\tShow list of all frozen packages." + puts " show-untracked\t\t\tShow all files on system not tracked by AbTLinux." + puts " show-journal\t\t\t\tShow the system journal." + puts " show-iqueue\t\t\t\tShow the contents of the install queue." + puts " show-patches\t\t\t\tShow the current available patches for installed package tree.\n" + end + + ## + # The usage information for the generation commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageGeneration + puts "\ngeneration:" + puts " show-updates\t\tShow a package listing with available update versions." + puts " html\t\t\tGenerate HTML page from installed packages:" + puts " \t\t\t\t(package name with hyperlink to package website and version installed)\n" + end + + ## + # The usage information for the download commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageDownloads + puts "\ndownloads:" + puts " -d, download [package]\t\tRetrieve given package sources." + puts " -u, update [package]|[tree]\tUpdate given package or tree from AbTLinux repository." + puts " -n, news\t\t\t\tDisplays newsfeeds from AbTLinux website.\n" + end + + ## + # The usage information for the fix commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageFix + puts "\nfix:" + puts " purge-src\t\t\t\tRemove source caches for packages no longer installed." + puts " purge-logs\t\t\t\tRemove log files for packages no longer installed." + puts " verify-files [package]\t\tInstalled files are verified for given package." + puts " verify-symlinks [package]\t\tSymlinks verified for given package." + puts " verify-deps [package]\t\tDependency tree is verified for given package." + puts " verify-integrity [package]\t\tVerify integrity of installed files for given package." + puts " fix [package]\t\tGiven package is verified and fixed if needed.\n" + end + + ## + # The usage information for the maintenance commands. + # + # <b>RETURN</b> <i>void</i> + ## + def usageMaintenance + puts "\nmaintenance:" + puts " build-location [host]\t\tSets global location (default: localhost) for retrieving cached package builds." + puts " package-repo [add|remove|list] [URI]" + puts " add - add package repository to list." + puts " remove - remove a package repository from list." + puts " list - display current repository list.\n" + end +end Deleted: src/trunk/docGen.sh =================================================================== --- src/trunk/docGen.sh 2007-07-16 13:31:07 UTC (rev 360) +++ src/trunk/docGen.sh 2007-07-16 13:32:49 UTC (rev 361) @@ -1,53 +0,0 @@ -#!/bin/bash -#=============================================================================== -# -# FILE: docgen.sh -# -# USAGE: ./docgen.sh -# -# DESCRIPTION: Generates AbTLinux Package Manager API documentation. -# -# BUGS: --- -# NOTES: --- -# AUTHOR: Eric D. Schabell <er...@ab...> -# VERSION: 1.0 -# CREATED: 05/14/2006 10:31:24 AM CEST -# REVISION: --- -#=============================================================================== - -TEMPLATE="./abttemplate.rb"; -FILES="abtdepengine.rb - abtdownloadmanager.rb - abtlogmanager.rb - abtpackage.rb - abtpackagemanager.rb - abtqueuemanager.rb - abtreportmanager.rb - abtsystemmanager.rb - abtusage.rb - testabtdepengine.rb - testabtdownloadmanager.rb - testabtlogmanager.rb - testabtpackage.rb - testabtpackagemanager.rb - testabtqueuemanager.rb - testabtreportmanager.rb - testabtsystemmanager.rb - "; - -# run the actual doc generation. -rdoc --diagram \ - --template $TEMPLATE \ - --fileboxes \ - --inline-source \ - --line-numbers \ - --main AbtPackageManager \ - --title "AbTLinux Package Manager API" \ - $FILES - -# remove old tarball and refresh with new docs. -#rm ./doc.tar.bz2 -#tar cf doc.tar ./doc -#bzip2 doc.tar - -# end docGen.sh Copied: src/trunk/docgen.sh (from rev 360, src/trunk/docGen.sh) =================================================================== --- src/trunk/docgen.sh (rev 0) +++ src/trunk/docgen.sh 2007-07-16 13:32:49 UTC (rev 361) @@ -0,0 +1,53 @@ +#!/bin/bash +#=============================================================================== +# +# FILE: docgen.sh +# +# USAGE: ./docgen.sh +# +# DESCRIPTION: Generates AbTLinux Package Manager API documentation. +# +# BUGS: --- +# NOTES: --- +# AUTHOR: Eric D. Schabell <er...@ab...> +# VERSION: 1.0 +# CREATED: 05/14/2006 10:31:24 AM CEST +# REVISION: --- +#=============================================================================== + +TEMPLATE="./abttemplate.rb"; +FILES="abtdepengine.rb + abtdownloadmanager.rb + abtlogmanager.rb + abtpackage.rb + abtpackagemanager.rb + abtqueuemanager.rb + abtreportmanager.rb + abtsystemmanager.rb + abtusage.rb + testabtdepengine.rb + testabtdownloadmanager.rb + testabtlogmanager.rb + testabtpackage.rb + testabtpackagemanager.rb + testabtqueuemanager.rb + testabtreportmanager.rb + testabtsystemmanager.rb + "; + +# run the actual doc generation. +rdoc --diagram \ + --template $TEMPLATE \ + --fileboxes \ + --inline-source \ + --line-numbers \ + --main AbtPackageManager \ + --title "AbTLinux Package Manager API" \ + $FILES + +# remove old tarball and refresh with new docs. +#rm ./doc.tar.bz2 +#tar cf doc.tar ./doc +#bzip2 doc.tar + +# end docGen.sh This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 13:31:07
|
Revision: 360 http://svn.sourceforge.net/abtlinux/?rev=360&view=rev Author: eschabell Date: 2007-07-16 06:31:07 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Refactored docGen to use new file names. Modified Paths: -------------- src/trunk/docGen.sh Modified: src/trunk/docGen.sh =================================================================== --- src/trunk/docGen.sh 2007-07-16 13:24:01 UTC (rev 359) +++ src/trunk/docGen.sh 2007-07-16 13:31:07 UTC (rev 360) @@ -1,9 +1,9 @@ #!/bin/bash #=============================================================================== # -# FILE: docGen.sh +# FILE: docgen.sh # -# USAGE: ./docGen.sh +# USAGE: ./docgen.sh # # DESCRIPTION: Generates AbTLinux Package Manager API documentation. # @@ -15,24 +15,24 @@ # REVISION: --- #=============================================================================== -TEMPLATE="./abtTemplate.rb"; -FILES="AbtDepEngine.rb - AbtDownloadManager.rb - AbtLogManager.rb - AbtPackage.rb - AbtPackageManager.rb - AbtQueueManager.rb - AbtReportManager.rb - AbtSystemManager.rb - AbtUsage.rb - TestAbtDepEngine.rb - TestAbtDownloadManager.rb - TestAbtLogManager.rb - TestAbtPackage.rb - TestAbtPackageManager.rb - TestAbtQueueManager.rb - TestAbtReportManager.rb - TestAbtSystemManager.rb +TEMPLATE="./abttemplate.rb"; +FILES="abtdepengine.rb + abtdownloadmanager.rb + abtlogmanager.rb + abtpackage.rb + abtpackagemanager.rb + abtqueuemanager.rb + abtreportmanager.rb + abtsystemmanager.rb + abtusage.rb + testabtdepengine.rb + testabtdownloadmanager.rb + testabtlogmanager.rb + testabtpackage.rb + testabtpackagemanager.rb + testabtqueuemanager.rb + testabtreportmanager.rb + testabtsystemmanager.rb "; # run the actual doc generation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 13:24:02
|
Revision: 359 http://svn.sourceforge.net/abtlinux/?rev=359&view=rev Author: eschabell Date: 2007-07-16 06:24:01 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated system manager class and test class to rubified file names. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/abtsystemmanager.rb src/trunk/testabtsystemmanager.rb Removed Paths: ------------- src/trunk/AbtSystemManager.rb src/trunk/TestAbtSystemManager.rb Deleted: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2007-07-16 13:20:14 UTC (rev 358) +++ src/trunk/AbtSystemManager.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -1,191 +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 of -# settings within the 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 AbtSystemManager - - protected - - private - - ## - # Determines if given file is in given directory. - # - # <b>PARAM</b> <i>String</i> - directory path to search. - # <b>PARAM</b> <i>String</i> - entry we are looking for in given directory. - # - # <b>RETURN</b> <i>boolean</i> - True if entry found in given directory, - # otherwise false. - ## - def foundEntry( directory, name ) - Find.find( directory ) do |path| - - Find.prune if [".", ".."].include? path - case name - when String - return true if File.basename( path ) == name - else - raise ArgumentError - end - - end - - return false # match not found. - end - - public - - ## - # Constructor for the System manager - # - # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized - # AbtSystemManager object. - ## - def initialize - end - - ## - # Removes all sources for packages that are not currently installed. Makes - # use of install listing to determine package sources to keep. - # - # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise - # false. - ## - def cleanupPackageSources - end - - ## - # All logs for packages not in install list are cleaned off the system. - # - # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise - # false. - ## - def cleanupLogs - end - - ## - # Checks if files from given package install list are actually installed. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if no installed files are missing, - # otherwise false. - ## - def verifyInstalledFiles( package ) - end - - ## - # Checks if given packages installed symlinks are broken or missing. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if no symlinks found missing - # or broken, otherwise false. - ## - def verifySymlinks( package ) - end - - ## - # Checks the given packages dependencies for missing or broken dependencies. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if dependencies intact, otherwise - # false. - ## - def verifyPackageDepends( package ) - end - - ## - # Checks the given packages installed files against the integrity log for - # changes to installed files. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise - # hash of problem files and their encountered errors. - ## - def verifyPackageIntegrity( package ) - end - - ## - # Fixes the given package. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise - # false. - ## - def fixPackage( package ) - end - - ## - # Sets the URI of a central repository for pre-compiled packages. - # - # <b>PARAM</b> <i>String</i> - the URI where the central repository is - # located. - # - # <b>RETURN</b> <i>boolean</i> - True if the URI is set, otherwise false. - ## - def setCentralRepo( uri ) - end - - ## - # Sets the location where the package tree is to be downloaded from, can be - # set to a local location. - # - # <b>PARAM</b> <i>String</i> - the location of the package tree. - # - # <b>RETURN</b> <i>boolean</i> - True if the package tree location is set, - # otherwise false. - ## - def setPackageTreeLocation( location ) - end - - ## - # Checks if the given package is installed by checking for entry in the - # installed directory. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if package installed, otherwise - # false. - ## - def packageInstalled( package ) - require "#{$PACKAGE_PATH}#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details - - if ( foundEntry( $PACKAGE_INSTALLED, sw.srcDir ) ) - return true - end - - - return false - end - -end \ No newline at end of file Deleted: src/trunk/TestAbtSystemManager.rb =================================================================== --- src/trunk/TestAbtSystemManager.rb 2007-07-16 13:20:14 UTC (rev 358) +++ src/trunk/TestAbtSystemManager.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -1,118 +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 - @sys = AbtSystemManager.new() - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtSystemManager.testCleanupPackageSources()' - ## - def testCleanupPackageSources - assert( @sys.cleanupPackageSources(), "testCleanupPackageSources()" ) - end - - ## - # Test method for 'AbtSystemManager.testCleanupLogs()' - ## - def testCleanupLogs - assert( @sys.cleanupLogs(), "testCleanupLogs()" ) - end - - ## - # Test method for 'AbtSystemManager.testVerifyInstalledFiles()' - ## - def testVerifyInstalledFiles - assert( @sys.verifyInstalledFiles( "dummy" ), "testVerifyInstalledFiles()" ) - end - - ## - # Test method for 'AbtSystemManager.testVerifySymlinks()' - ## - def testVerifySymlinks - assert( @sys.verifySymlinks( "dummy" ), "testVerifySymlinks()" ) - end - - ## - # Test method for 'AbtSystemManager.testVerifyPackageDepends()' - ## - def testVerifyPackageDepends - assert( @sys.verifyPackageDepends( "dummy" ), "testVerifyPackageDepends()" ) - end - - ## - # Test method for 'AbtSystemManager.testVerifyPackageIntegrity()' - ## - def testVerifyPackageIntegrity - assert( @sys.verifyPackageIntegrity( "dummy" ), - "testVerifyPackageIntegrity()" ) - end - - ## - # Test method for 'AbtSystemManager.testFixPackage()' - ## - def testFixPackage - assert( @sys.fixPackage( "dummy" ), "testFixPackage()" ) - end - - ## - # Test method for 'AbtSystemManager.testSetCentralRepo()' - ## - def testSetCentralRepo - assert( @sys.setCentralRepo( "http://localhost" ), "testSetCentralRepo()" ) - end - - ## - # Test method for 'AbtSystemManager.testSetPackageTreeLocation()' - ## - def testSetPackageTreeLocation - assert( @sys.setPackageTreeLocation( "/var/lib/ericsPackages" ), - "testSetPackageTreeLocation()" ) - end - - ## - # Test method for 'AbtSystemManager.testPackageInstalled()' - ## - def testPackageInstalled - assert( @sys.packageInstalled( "ipc" ), "testPackageInstalled()" ) - end - -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 13:20:14 UTC (rev 358) +++ src/trunk/abtconfig.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -33,7 +33,7 @@ require 'abtdepengine' require 'abtqueuemanager' require 'abtreportmanager' -require 'AbtSystemManager' +require 'abtsystemmanager' require 'AbtUsage' require 'fileutils' Copied: src/trunk/abtsystemmanager.rb (from rev 358, src/trunk/AbtSystemManager.rb) =================================================================== --- src/trunk/abtsystemmanager.rb (rev 0) +++ src/trunk/abtsystemmanager.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -0,0 +1,191 @@ +#!/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 of +# settings within the 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 AbtSystemManager + + protected + + private + + ## + # Determines if given file is in given directory. + # + # <b>PARAM</b> <i>String</i> - directory path to search. + # <b>PARAM</b> <i>String</i> - entry we are looking for in given directory. + # + # <b>RETURN</b> <i>boolean</i> - True if entry found in given directory, + # otherwise false. + ## + def foundEntry( directory, name ) + Find.find( directory ) do |path| + + Find.prune if [".", ".."].include? path + case name + when String + return true if File.basename( path ) == name + else + raise ArgumentError + end + + end + + return false # match not found. + end + + public + + ## + # Constructor for the System manager + # + # <b>RETURN</b> <i>AbtSystemManager</i> - an initialized + # AbtSystemManager object. + ## + def initialize + end + + ## + # Removes all sources for packages that are not currently installed. Makes + # use of install listing to determine package sources to keep. + # + # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise + # false. + ## + def cleanupPackageSources + end + + ## + # All logs for packages not in install list are cleaned off the system. + # + # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise + # false. + ## + def cleanupLogs + end + + ## + # Checks if files from given package install list are actually installed. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if no installed files are missing, + # otherwise false. + ## + def verifyInstalledFiles( package ) + end + + ## + # Checks if given packages installed symlinks are broken or missing. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if no symlinks found missing + # or broken, otherwise false. + ## + def verifySymlinks( package ) + end + + ## + # Checks the given packages dependencies for missing or broken dependencies. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if dependencies intact, otherwise + # false. + ## + def verifyPackageDepends( package ) + end + + ## + # Checks the given packages installed files against the integrity log for + # changes to installed files. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>hash</i> - Empty hash if no problems found, otherwise + # hash of problem files and their encountered errors. + ## + def verifyPackageIntegrity( package ) + end + + ## + # Fixes the given package. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if completes without error, otherwise + # false. + ## + def fixPackage( package ) + end + + ## + # Sets the URI of a central repository for pre-compiled packages. + # + # <b>PARAM</b> <i>String</i> - the URI where the central repository is + # located. + # + # <b>RETURN</b> <i>boolean</i> - True if the URI is set, otherwise false. + ## + def setCentralRepo( uri ) + end + + ## + # Sets the location where the package tree is to be downloaded from, can be + # set to a local location. + # + # <b>PARAM</b> <i>String</i> - the location of the package tree. + # + # <b>RETURN</b> <i>boolean</i> - True if the package tree location is set, + # otherwise false. + ## + def setPackageTreeLocation( location ) + end + + ## + # Checks if the given package is installed by checking for entry in the + # installed directory. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if package installed, otherwise + # false. + ## + def packageInstalled( package ) + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + if ( foundEntry( $PACKAGE_INSTALLED, sw.srcDir ) ) + return true + end + + + return false + end + +end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 13:20:14 UTC (rev 358) +++ src/trunk/testSuiteAbt.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -28,5 +28,5 @@ require 'testabtpackage' require 'testabtqueuemanager' require 'testabtreportmanager' -require 'TestAbtSystemManager' +require 'testabtsystemmanager' require 'testabtdepengine' Copied: src/trunk/testabtsystemmanager.rb (from rev 358, src/trunk/TestAbtSystemManager.rb) =================================================================== --- src/trunk/testabtsystemmanager.rb (rev 0) +++ src/trunk/testabtsystemmanager.rb 2007-07-16 13:24:01 UTC (rev 359) @@ -0,0 +1,118 @@ +#!/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 + @sys = AbtSystemManager.new() + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtSystemManager.testCleanupPackageSources()' + ## + def testCleanupPackageSources + assert( @sys.cleanupPackageSources(), "testCleanupPackageSources()" ) + end + + ## + # Test method for 'AbtSystemManager.testCleanupLogs()' + ## + def testCleanupLogs + assert( @sys.cleanupLogs(), "testCleanupLogs()" ) + end + + ## + # Test method for 'AbtSystemManager.testVerifyInstalledFiles()' + ## + def testVerifyInstalledFiles + assert( @sys.verifyInstalledFiles( "dummy" ), "testVerifyInstalledFiles()" ) + end + + ## + # Test method for 'AbtSystemManager.testVerifySymlinks()' + ## + def testVerifySymlinks + assert( @sys.verifySymlinks( "dummy" ), "testVerifySymlinks()" ) + end + + ## + # Test method for 'AbtSystemManager.testVerifyPackageDepends()' + ## + def testVerifyPackageDepends + assert( @sys.verifyPackageDepends( "dummy" ), "testVerifyPackageDepends()" ) + end + + ## + # Test method for 'AbtSystemManager.testVerifyPackageIntegrity()' + ## + def testVerifyPackageIntegrity + assert( @sys.verifyPackageIntegrity( "dummy" ), + "testVerifyPackageIntegrity()" ) + end + + ## + # Test method for 'AbtSystemManager.testFixPackage()' + ## + def testFixPackage + assert( @sys.fixPackage( "dummy" ), "testFixPackage()" ) + end + + ## + # Test method for 'AbtSystemManager.testSetCentralRepo()' + ## + def testSetCentralRepo + assert( @sys.setCentralRepo( "http://localhost" ), "testSetCentralRepo()" ) + end + + ## + # Test method for 'AbtSystemManager.testSetPackageTreeLocation()' + ## + def testSetPackageTreeLocation + assert( @sys.setPackageTreeLocation( "/var/lib/ericsPackages" ), + "testSetPackageTreeLocation()" ) + end + + ## + # Test method for 'AbtSystemManager.testPackageInstalled()' + ## + def testPackageInstalled + assert( @sys.packageInstalled( "ipc" ), "testPackageInstalled()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 13:20:13
|
Revision: 358 http://svn.sourceforge.net/abtlinux/?rev=358&view=rev Author: eschabell Date: 2007-07-16 06:20:14 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated report manager class and test class to rubified file names. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/abtreportmanager.rb src/trunk/testabtreportmanager.rb Removed Paths: ------------- src/trunk/AbtReportManager.rb src/trunk/TestAbtReportManager.rb Deleted: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2007-07-16 13:03:02 UTC (rev 357) +++ src/trunk/AbtReportManager.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -1,247 +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 showPackageDetails( 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.logToJournal( "[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 showInstalledPackages - end - - ## - # Display the contents of the requested log for a given package. Possible - # log types are; install, build and integrity. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>PARAM</b> <i>String</i> - log type. - # - # <b>RETURN</b> <i>void.</i> - ## - def showPackageLog( package, logType ) - # install log - # build log - # integrity log - end - - ## - # Display a list of the packages found in the frozen list. - # - # <b>RETURN</b> <i>void.</i> - ## - def showFrozenPackages - end - - ## - # Provides access to dependency checking via the AbTLinux DepEngine. (This - # portal to the DepEngine will be expanded in apart sub-project, more - # 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 showPackageDependencies( package ) - end - - ## - # Display all files not part of any installed AbTLinux package. This - # delivers a list of files that are not tracked by AbTLinux package - # management. - # - # <b>RETURN</b> <i>void.</i> - ## - def showUntrackedFiles - 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 showJournal( fileName ) - if ( File.exist?( fileName ) ) - puts "\n\n" - puts "AbTLinux log:" - puts "=============" - log = IO.readlines( fileName ) - log.each{ |entry| puts entry } - puts "\n\n" - else - puts "\n\n" - puts "AbtLinux log ( #{File.basename( fileName )} ) " + - "is empty at this time." - puts "\n\n" - end - - 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 showFileOwner( file ) - end - - ## - # Searches the installed package trees package descriptions for matching - # occurrances of the given search text. - # - # <b>PARAM</b> <i>String</i> - a search text. - # - # <b>RETURN</b> <i>hash</i> - a hash of the search results, keys are package - # names and values are matching descriptions. - ## - def searchPackageDescriptions( searchText ) - 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 showQueue( 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 showUpdates( target ) - end - - ## - # Generates an HTML page of installed packages from installed packages list. - # - # <b>RETURN</b> <i>void.</i> - ## - def generateHTMLPackageListing - end - -end Deleted: src/trunk/TestAbtReportManager.rb =================================================================== --- src/trunk/TestAbtReportManager.rb 2007-07-16 13:03:02 UTC (rev 357) +++ src/trunk/TestAbtReportManager.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -1,141 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' -require 'AbtReportManager' - -## -# 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() - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtReportManager.testShowPackageDetails()' - ## - def testShowPackageDetails - assert( @report.showPackageDetails( "ipc" ), "testShowPackageDetails()" ) - end - - ## - # Test method for 'AbtReportManager.testShowInstalledPackages()' - ## - def testShowInstalledPackages - assert( @report.showInstalledPackages(), "testShowInstalledPackages()" ) - end - - ## - # Test method for 'AbtReportManager.testShowPackageLog()' - ## - def testShowPackageLog - assert( @report.showPackageLog( "ipc", "install" ), - "testShowPackageLog()" ) - assert( @report.showPackageLog( "ipc", "build" ), "testShowPackageLog()" ) - assert( @report.showPackageLog( "ipc", "integrity" ), - "testShowPackageLog()" ) - end - - ## - # Test method for 'AbtReportManager.testShowFrozenPackages()' - ## - def testShowFrozenPackages - assert( @report.showFrozenPackages(), "testShowFrozenPackages()" ) - end - - ## - # Test method for 'AbtReportManager.testShowPackageDependencies()' - ## - def testShowPackageDependencies - assert( false, "testShowPackageDependencies()" ) - end - - ## - # Test method for 'AbtReportManager.testShowUntrackedFiles()' - ## - def testShowUntrackedFiles - assert( @report.showUntrackedFiles(), "testShowUntrackedFiles()" ) - end - - ## - # Test method for 'AbtReportManager.testShowJournal()' - ## - def testShowJournal - assert( @report.showJournal( $JOURNAL ), "testShowJournal()" ) - end - - ## - # Test method for 'AbtReportManager.testShowFileOwner()' - ## - def testShowFileOwner - assert( @report.showFileOwner( "ipcFile" ), "testShowFileOwner()" ) - end - - ## - # Test method for 'AbtReportManager.testSearchPackageDescriptions()' - ## - def testSearchPackageDescriptions - assert( @report.searchPackageDescriptions( "Special text" ), - "testSearchPackageDescriptions()" ) - end - - ## - # Test method for 'AbtReportManager.testShowQueue()' - ## - def testShowQueue - if ( @report.showQueue( "install" ) ) - assert(false, "testShowQueue()") - else - assert(true, "testShowQueue()") - end - end - - ## - # Test method for 'AbtReportManager.testShowUpdates()' - ## - def testShowUpdates - assert( @report.showUpdates( "ipc" ), "testShowUpdates()" ) - end - - ## - # Test method for 'AbtReportManager.testGenerateHTMLPackageListing()' - ## - def testGenerateHTMLPackageListing - assert( @report.generateHTMLPackageListing(), - "testGenerateHTMLPackageListing()" ) - end - -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 13:03:02 UTC (rev 357) +++ src/trunk/abtconfig.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -32,7 +32,7 @@ require 'abtpackage' require 'abtdepengine' require 'abtqueuemanager' -require 'AbtReportManager' +require 'abtreportmanager' require 'AbtSystemManager' require 'AbtUsage' Copied: src/trunk/abtreportmanager.rb (from rev 357, src/trunk/AbtReportManager.rb) =================================================================== --- src/trunk/abtreportmanager.rb (rev 0) +++ src/trunk/abtreportmanager.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -0,0 +1,247 @@ +#!/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 showPackageDetails( 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.logToJournal( "[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 showInstalledPackages + end + + ## + # Display the contents of the requested log for a given package. Possible + # log types are; install, build and integrity. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>PARAM</b> <i>String</i> - log type. + # + # <b>RETURN</b> <i>void.</i> + ## + def showPackageLog( package, logType ) + # install log + # build log + # integrity log + end + + ## + # Display a list of the packages found in the frozen list. + # + # <b>RETURN</b> <i>void.</i> + ## + def showFrozenPackages + end + + ## + # Provides access to dependency checking via the AbTLinux DepEngine. (This + # portal to the DepEngine will be expanded in apart sub-project, more + # 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 showPackageDependencies( package ) + end + + ## + # Display all files not part of any installed AbTLinux package. This + # delivers a list of files that are not tracked by AbTLinux package + # management. + # + # <b>RETURN</b> <i>void.</i> + ## + def showUntrackedFiles + 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 showJournal( fileName ) + if ( File.exist?( fileName ) ) + puts "\n\n" + puts "AbTLinux log:" + puts "=============" + log = IO.readlines( fileName ) + log.each{ |entry| puts entry } + puts "\n\n" + else + puts "\n\n" + puts "AbtLinux log ( #{File.basename( fileName )} ) " + + "is empty at this time." + puts "\n\n" + end + + 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 showFileOwner( file ) + end + + ## + # Searches the installed package trees package descriptions for matching + # occurrances of the given search text. + # + # <b>PARAM</b> <i>String</i> - a search text. + # + # <b>RETURN</b> <i>hash</i> - a hash of the search results, keys are package + # names and values are matching descriptions. + ## + def searchPackageDescriptions( searchText ) + 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 showQueue( 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 showUpdates( target ) + end + + ## + # Generates an HTML page of installed packages from installed packages list. + # + # <b>RETURN</b> <i>void.</i> + ## + def generateHTMLPackageListing + end + +end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 13:03:02 UTC (rev 357) +++ src/trunk/testSuiteAbt.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -27,6 +27,6 @@ require 'testabtdownloadmanager' require 'testabtpackage' require 'testabtqueuemanager' -require 'TestAbtReportManager' +require 'testabtreportmanager' require 'TestAbtSystemManager' require 'testabtdepengine' Copied: src/trunk/testabtreportmanager.rb (from rev 357, src/trunk/TestAbtReportManager.rb) =================================================================== --- src/trunk/testabtreportmanager.rb (rev 0) +++ src/trunk/testabtreportmanager.rb 2007-07-16 13:20:14 UTC (rev 358) @@ -0,0 +1,140 @@ +#!/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() + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtReportManager.testShowPackageDetails()' + ## + def testShowPackageDetails + assert( @report.showPackageDetails( "ipc" ), "testShowPackageDetails()" ) + end + + ## + # Test method for 'AbtReportManager.testShowInstalledPackages()' + ## + def testShowInstalledPackages + assert( @report.showInstalledPackages(), "testShowInstalledPackages()" ) + end + + ## + # Test method for 'AbtReportManager.testShowPackageLog()' + ## + def testShowPackageLog + assert( @report.showPackageLog( "ipc", "install" ), + "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "build" ), "testShowPackageLog()" ) + assert( @report.showPackageLog( "ipc", "integrity" ), + "testShowPackageLog()" ) + end + + ## + # Test method for 'AbtReportManager.testShowFrozenPackages()' + ## + def testShowFrozenPackages + assert( @report.showFrozenPackages(), "testShowFrozenPackages()" ) + end + + ## + # Test method for 'AbtReportManager.testShowPackageDependencies()' + ## + def testShowPackageDependencies + assert( false, "testShowPackageDependencies()" ) + end + + ## + # Test method for 'AbtReportManager.testShowUntrackedFiles()' + ## + def testShowUntrackedFiles + assert( @report.showUntrackedFiles(), "testShowUntrackedFiles()" ) + end + + ## + # Test method for 'AbtReportManager.testShowJournal()' + ## + def testShowJournal + assert( @report.showJournal( $JOURNAL ), "testShowJournal()" ) + end + + ## + # Test method for 'AbtReportManager.testShowFileOwner()' + ## + def testShowFileOwner + assert( @report.showFileOwner( "ipcFile" ), "testShowFileOwner()" ) + end + + ## + # Test method for 'AbtReportManager.testSearchPackageDescriptions()' + ## + def testSearchPackageDescriptions + assert( @report.searchPackageDescriptions( "Special text" ), + "testSearchPackageDescriptions()" ) + end + + ## + # Test method for 'AbtReportManager.testShowQueue()' + ## + def testShowQueue + if ( @report.showQueue( "install" ) ) + assert(false, "testShowQueue()") + else + assert(true, "testShowQueue()") + end + end + + ## + # Test method for 'AbtReportManager.testShowUpdates()' + ## + def testShowUpdates + assert( @report.showUpdates( "ipc" ), "testShowUpdates()" ) + end + + ## + # Test method for 'AbtReportManager.testGenerateHTMLPackageListing()' + ## + def testGenerateHTMLPackageListing + assert( @report.generateHTMLPackageListing(), + "testGenerateHTMLPackageListing()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 13:03:01
|
Revision: 357 http://svn.sourceforge.net/abtlinux/?rev=357&view=rev Author: eschabell Date: 2007-07-16 06:03:02 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Adjusted comments. Modified Paths: -------------- src/trunk/abtqueuemanager.rb src/trunk/testabtqueuemanager.rb Modified: src/trunk/abtqueuemanager.rb =================================================================== --- src/trunk/abtqueuemanager.rb 2007-07-16 13:01:57 UTC (rev 356) +++ src/trunk/abtqueuemanager.rb 2007-07-16 13:03:02 UTC (rev 357) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtQueueManager.rb +# abtqueuemanager.rb # # AbtQueueManager class handles all AbTLinux queue interaction. # Modified: src/trunk/testabtqueuemanager.rb =================================================================== --- src/trunk/testabtqueuemanager.rb 2007-07-16 13:01:57 UTC (rev 356) +++ src/trunk/testabtqueuemanager.rb 2007-07-16 13:03:02 UTC (rev 357) @@ -5,7 +5,7 @@ require 'abtconfig' ## -# TestAbtQueueManager.rb +# testabtqueuemanager.rb # # Unit testing for AbtQueueManager class. # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 13:01:55
|
Revision: 356 http://svn.sourceforge.net/abtlinux/?rev=356&view=rev Author: eschabell Date: 2007-07-16 06:01:57 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated queue manager class and test class, including references to rubified file names. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/abtqueuemanager.rb src/trunk/testabtqueuemanager.rb Removed Paths: ------------- src/trunk/AbtQueueManager.rb src/trunk/TestAbtQueueManager.rb Deleted: src/trunk/AbtQueueManager.rb =================================================================== --- src/trunk/AbtQueueManager.rb 2007-07-16 12:51:00 UTC (rev 355) +++ src/trunk/AbtQueueManager.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -1,116 +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 actionPackageQueue( package, queue, action="add" ) - require 'fileutils' - logger = AbtLogManager.new - queueFile = "" # used to hold the queue location. - - # want to name install queue differently from log files. - if ( queue == 'install' ) - queueFile = "#{$ABT_LOGS}/#{queue}.queue" - else - queueFile = "#{$ABT_LOGS}/#{queue}.log" - end - - if ( action == "add") - if ( - log = File.new( - queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) - # pickup queue contents to ensure no duplicates. - checkingQueue = IO.readlines( queueFile ) - - # check if package exists, otherwise add. - if ( - !checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( - package ) ) - log.puts "#{package}|#{$TIMESTAMP}" - logger.logToJournal( "Added #{package} to #{queue} queue." ) - else - logger.logToJournal( - "Did not add #{package} to #{queue}, already exists." ) - end - - log.close - return true - end - end - - if ( action == "remove" ) - # remove entry from given queue. - if ( - log = File.new( - queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) - # use temp file to filter out entry to be removed. - temp = File.new(queueFile + ".tmp", "a+") - - # now check for line to be removed. - IO.foreach( queueFile ) do |line| - entryName = line.split( '|' )[0] - if ( entryName != package.downcase ) - temp.puts line - end - end - - temp.close - FileUtils.mv( temp.path, queueFile ) - end - - log.close - return true - end - - logger.logToJournal( "Failed to open #{queueFile}." ) - return false - end -end Deleted: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-07-16 12:51:00 UTC (rev 355) +++ src/trunk/TestAbtQueueManager.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -1,54 +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.actionPackageQueue()' - ## - def testActionPackageQueue - assert( @queue.actionPackageQueue( "ipc", "install", "add" ), - "testQueueManager()" ) - end - -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 12:51:00 UTC (rev 355) +++ src/trunk/abtconfig.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -31,7 +31,7 @@ require 'abtpackagemanager' require 'abtpackage' require 'abtdepengine' -require 'AbtQueueManager' +require 'abtqueuemanager' require 'AbtReportManager' require 'AbtSystemManager' require 'AbtUsage' Copied: src/trunk/abtqueuemanager.rb (from rev 353, src/trunk/AbtQueueManager.rb) =================================================================== --- src/trunk/abtqueuemanager.rb (rev 0) +++ src/trunk/abtqueuemanager.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -0,0 +1,116 @@ +#!/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 actionPackageQueue( package, queue, action="add" ) + require 'fileutils' + logger = AbtLogManager.new + queueFile = "" # used to hold the queue location. + + # want to name install queue differently from log files. + if ( queue == 'install' ) + queueFile = "#{$ABT_LOGS}/#{queue}.queue" + else + queueFile = "#{$ABT_LOGS}/#{queue}.log" + end + + if ( action == "add") + if ( + log = File.new( + queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + # pickup queue contents to ensure no duplicates. + checkingQueue = IO.readlines( queueFile ) + + # check if package exists, otherwise add. + if ( + !checkingQueue.collect{ |i| i.split( '|' )[0] }.include?( + package ) ) + log.puts "#{package}|#{$TIMESTAMP}" + logger.logToJournal( "Added #{package} to #{queue} queue." ) + else + logger.logToJournal( + "Did not add #{package} to #{queue}, already exists." ) + end + + log.close + return true + end + end + + if ( action == "remove" ) + # remove entry from given queue. + if ( + log = File.new( + queueFile, File::WRONLY|File::APPEND|File::CREAT, 0644 ) ) + # use temp file to filter out entry to be removed. + temp = File.new(queueFile + ".tmp", "a+") + + # now check for line to be removed. + IO.foreach( queueFile ) do |line| + entryName = line.split( '|' )[0] + if ( entryName != package.downcase ) + temp.puts line + end + end + + temp.close + FileUtils.mv( temp.path, queueFile ) + end + + log.close + return true + end + + logger.logToJournal( "Failed to open #{queueFile}." ) + return false + end +end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 12:51:00 UTC (rev 355) +++ src/trunk/testSuiteAbt.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -26,7 +26,7 @@ require 'testabtlogmanager' require 'testabtdownloadmanager' require 'testabtpackage' -require 'TestAbtQueueManager' +require 'testabtqueuemanager' require 'TestAbtReportManager' require 'TestAbtSystemManager' require 'testabtdepengine' Copied: src/trunk/testabtqueuemanager.rb (from rev 353, src/trunk/TestAbtQueueManager.rb) =================================================================== --- src/trunk/testabtqueuemanager.rb (rev 0) +++ src/trunk/testabtqueuemanager.rb 2007-07-16 13:01:57 UTC (rev 356) @@ -0,0 +1,54 @@ +#!/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.actionPackageQueue()' + ## + def testActionPackageQueue + assert( @queue.actionPackageQueue( "ipc", "install", "add" ), + "testQueueManager()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 12:50:58
|
Revision: 355 http://svn.sourceforge.net/abtlinux/?rev=355&view=rev Author: eschabell Date: 2007-07-16 05:51:00 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Some comments adjusted in the class descriptions, they needed the new file names. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/abtdepengine.rb src/trunk/abtdownloadmanager.rb src/trunk/abtlogmanager.rb src/trunk/abtpackagemanager.rb src/trunk/packages/ipc.rb src/trunk/testSuiteAbt.rb src/trunk/testabtdepengine.rb src/trunk/testabtlogmanager.rb src/trunk/testabtpackagemanager.rb Added Paths: ----------- src/trunk/testabtpackage.rb Removed Paths: ------------- src/trunk/TestAbtPackage.rb Deleted: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/TestAbtPackage.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,145 +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 - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtPackage.testDetails()' - ## - def testDetails - assert_equal( $dataTest['name'], @ipc.details['Package name'], - "testDetails()" ) - assert_equal( $dataTest['execName'], @ipc.details['Executable'], - "testDetails()" ) - assert_equal( $dataTest['version'], @ipc.details['Version'], - "testDetails()" ) - assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], - "testDetails()" ) - assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], - "testDetails()" ) - end - - ## - # Test method for 'AbtPackage.testPre()' - ## - def testPre - assert( @ipc.pre( $verbose ), "testPre()" ) - end - - ## - # Test method for 'AbtPackage.testConfigure()' - ## - def testConfigure - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "testConfigure()" ) - end - assert( @ipc.configure( $verbose ), "testConfigure()" ) - end - - ## - # Test method for 'AbtPackage.testBuild()' - ## - def testBuild - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "testBuild()" ) - end - if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "testBuild()" ) - end - assert( @ipc.build( $verbose ), "testBuild()" ) - end - - ## - # Test method for 'AbtPackage.testPreinstall()' - ## - def testPreinstall - assert( @ipc.preinstall( $verbose ), "testPreinstall()" ) - end - - ## - # Test method for 'AbtPackage.testInstall()' - ## - def testInstall - - if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "testInstall()" ) - end - if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "testInstall()" ) - end - if ( !@ipc.build( $verbose ) ) - assert_equals( true, false, "testInstall()" ) - end - if ( !@ipc.preinstall( $verbose ) ) - assert_equals( true, false, "testInstall()" ) - end - assert( @ipc.install( $verbose ), "testInstall()" ) - end - - ## - # Test method for 'AbtPackage.testPost()' - ## - def testPost - assert_equals( true, false, "testPost()" ) if ( !@ipc.pre( $verbose ) ) - assert_equals( true, false, "testPost()" ) if ( !@ipc.configure( $verbose ) ) - assert_equals( true, false, "testPost()" ) if ( !@ipc.build( $verbose ) ) - assert_equals( true, false, "testPost()" ) if ( !@ipc.preinstall( $verbose ) ) - assert_equals( true, false, "testPost()" ) if ( !@ipc.install( $verbose ) ) - assert( @ipc.post( $verbose ), "testPost()" ) - end - -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/abtconfig.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -30,6 +30,7 @@ require 'abtlogmanager' require 'abtpackagemanager' require 'abtpackage' +require 'abtdepengine' require 'AbtQueueManager' require 'AbtReportManager' require 'AbtSystemManager' Modified: src/trunk/abtdepengine.rb =================================================================== --- src/trunk/abtdepengine.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/abtdepengine.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtDepEngine.rb +# abtdepengine.rb # # AbtDepEngine class handles all dependency aspects of the AbTLinux system. It is # part of a sub-project with it's own requirements document. @@ -41,4 +41,4 @@ def initialize end -end \ No newline at end of file +end Modified: src/trunk/abtdownloadmanager.rb =================================================================== --- src/trunk/abtdownloadmanager.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/abtdownloadmanager.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtDownloadManager.rb +# abtdownloadmanager.rb # # AbtDownloadManager class handles all downloading of components needed for # AbTLinux. Modified: src/trunk/abtlogmanager.rb =================================================================== --- src/trunk/abtlogmanager.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/abtlogmanager.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtLogManager.rb +# abtlogmanager.rb # # AbtLogManager class handles all aspects of logging and access to existing logs # within the AbTLinux system. Modified: src/trunk/abtpackagemanager.rb =================================================================== --- src/trunk/abtpackagemanager.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/abtpackagemanager.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,7 +1,7 @@ #!/usr/bin/ruby -w ## -# AbtPackageManager.rb +# abtpackagemanager.rb # # AbtPackageManager class will take care of the installation, removal, updating, # downgrading and freezing of AbTLinux software packages. Modified: src/trunk/packages/ipc.rb =================================================================== --- src/trunk/packages/ipc.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/packages/ipc.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -1,6 +1,6 @@ #!/usr/bin/ruby -w -require "AbtPackage" +require "abtpackage" ## # ipc.rb Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/testSuiteAbt.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -25,7 +25,7 @@ require 'testabtpackagemanager' require 'testabtlogmanager' require 'testabtdownloadmanager' -require 'TestAbtPackage' +require 'testabtpackage' require 'TestAbtQueueManager' require 'TestAbtReportManager' require 'TestAbtSystemManager' Modified: src/trunk/testabtdepengine.rb =================================================================== --- src/trunk/testabtdepengine.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/testabtdepengine.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -2,10 +2,10 @@ require 'test/unit/testcase' require 'test/unit/autorunner' -require 'abtdepengine' +require 'abtconfig' ## -# TestAbtDepEngine.rb +# testabtdepengine.rb # # Unit testing for AbtDepEngine class. # Modified: src/trunk/testabtlogmanager.rb =================================================================== --- src/trunk/testabtlogmanager.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/testabtlogmanager.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -5,7 +5,7 @@ require 'abtconfig' ## -# TestAbtLogManager.rb +# testabtlogmanager.rb # # Unit testing for AbtLogManager class. # Copied: src/trunk/testabtpackage.rb (from rev 354, src/trunk/TestAbtPackage.rb) =================================================================== --- src/trunk/testabtpackage.rb (rev 0) +++ src/trunk/testabtpackage.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -0,0 +1,145 @@ +#!/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 + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtPackage.testDetails()' + ## + def testDetails + assert_equal( $dataTest['name'], @ipc.details['Package name'], + "testDetails()" ) + assert_equal( $dataTest['execName'], @ipc.details['Executable'], + "testDetails()" ) + assert_equal( $dataTest['version'], @ipc.details['Version'], + "testDetails()" ) + assert_equal( $dataTest['srcDir'], @ipc.details['Source location'], + "testDetails()" ) + assert_equal( $dataTest['homepage'], @ipc.details['Homepage'], + "testDetails()" ) + end + + ## + # Test method for 'AbtPackage.testPre()' + ## + def testPre + assert( @ipc.pre( $verbose ), "testPre()" ) + end + + ## + # Test method for 'AbtPackage.testConfigure()' + ## + def testConfigure + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "testConfigure()" ) + end + assert( @ipc.configure( $verbose ), "testConfigure()" ) + end + + ## + # Test method for 'AbtPackage.testBuild()' + ## + def testBuild + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "testBuild()" ) + end + if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "testBuild()" ) + end + assert( @ipc.build( $verbose ), "testBuild()" ) + end + + ## + # Test method for 'AbtPackage.testPreinstall()' + ## + def testPreinstall + assert( @ipc.preinstall( $verbose ), "testPreinstall()" ) + end + + ## + # Test method for 'AbtPackage.testInstall()' + ## + def testInstall + + if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.build( $verbose ) ) + assert_equals( true, false, "testInstall()" ) + end + if ( !@ipc.preinstall( $verbose ) ) + assert_equals( true, false, "testInstall()" ) + end + assert( @ipc.install( $verbose ), "testInstall()" ) + end + + ## + # Test method for 'AbtPackage.testPost()' + ## + def testPost + assert_equals( true, false, "testPost()" ) if ( !@ipc.pre( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.configure( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.build( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.preinstall( $verbose ) ) + assert_equals( true, false, "testPost()" ) if ( !@ipc.install( $verbose ) ) + assert( @ipc.post( $verbose ), "testPost()" ) + end + +end Modified: src/trunk/testabtpackagemanager.rb =================================================================== --- src/trunk/testabtpackagemanager.rb 2007-07-16 12:30:36 UTC (rev 354) +++ src/trunk/testabtpackagemanager.rb 2007-07-16 12:51:00 UTC (rev 355) @@ -5,7 +5,7 @@ require 'abtconfig' ## -# TestAbtPackageManager.rb +# testabtpackagemanager.rb # # Unit testing for AbtPackageManager class. # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 12:30:36
|
Revision: 354 http://svn.sourceforge.net/abtlinux/?rev=354&view=rev Author: eschabell Date: 2007-07-16 05:30:36 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated package class and references to rubified name. Modified Paths: -------------- src/trunk/TestAbtPackage.rb src/trunk/abtconfig.rb Added Paths: ----------- src/trunk/abtpackage.rb Removed Paths: ------------- src/trunk/AbtPackage.rb Deleted: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-07-16 12:26:55 UTC (rev 353) +++ src/trunk/AbtPackage.rb 2007-07-16 12:30:36 UTC (rev 354) @@ -1,378 +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 unpackSources - srcFile = File.basename( @srcUrl ) - sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" - unpackTool = "" - - # check for existing file in source repo. - if ( !File.exist?( sourcesToUnpack ) ) - return false - end - - # check if possible existing sources in build directory. - if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) - return true - end - - # determine which supported compression used [gz, tar, tgz, bz2, zip]. - compressionType = srcFile.split( '.' ) - - case compressionType.last - - when "gz" - unpackTool = "tar xzvf" - - when "tar" - unpackTool = "tar xvf" - - when "bz2" - unpackTool = "tar xjvf" - - when "tgz" - unpackTool = "tar xzvf" - - when "zip" - unpackTool = "unizp" - - else - # unsupported format. - return false - end - - # DEBUG: - #logger = AbtLogManager.new - #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) - - Dir.chdir( $BUILD_LOCATION ) - if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) - return false - end - - return true - end - - private - - public - - # the name of the package. - attr_reader :name - - # the executable name for the package. - attr_reader :execName - - # the package version number. - attr_reader :version - - # the source directory for the package. - attr_reader :srcDir - - # the packages homepage. - attr_reader :homepage - - # the URL where this packages sources can be obtained. - attr_reader :srcUrl - - # list of dependsOn (DO) related package dependencies. - attr_reader :dependsOn - - # list of reliesOn (RO) related package dependencies. - attr_reader :reliesOn - - # list of optional reliesOn (oRO) related package dependencies. - attr_reader :optionalDO - - # list of optional dependsOn (oDO) related package dependencies. - attr_reader :optionalRO - - # security hash value of package sources. - attr_reader :hashCheck - - # list of available patches for this package. - attr_reader :patches - - # security hash value of this packages patches. - attr_reader :patchesHashCheck - - # available mirrors for this package. - attr_reader :mirrorPath - - # type of license this package has. - attr_reader :licence - - # the package description. - attr_reader :description - - - ## - # Constructor for an AbtPackage, requires all the packge details. - # - # <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.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) - return false - end - - # unpack sources. - if ( !self.unpackSources ) - 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 "DEBUG: [AbtPackage.configure] - configure section failed." - return false - end - - puts "\nDEBUG: [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 "DEBUG: [AbtPackage.build] - build section failed." - return false - end - - puts "DEBUG: [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 "DEBUG: [AbtPackage.install] - install section failed." - return false - end - - puts "DEBUG: [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 removeBuild - 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 Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-07-16 12:26:55 UTC (rev 353) +++ src/trunk/TestAbtPackage.rb 2007-07-16 12:30:36 UTC (rev 354) @@ -3,7 +3,6 @@ require "test/unit/testcase" require "test/unit/autorunner" require "abtconfig" -require "AbtPackage" require "#{$PACKAGE_PATH}ipc" ## Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 12:26:55 UTC (rev 353) +++ src/trunk/abtconfig.rb 2007-07-16 12:30:36 UTC (rev 354) @@ -29,6 +29,7 @@ require 'abtdownloadmanager' require 'abtlogmanager' require 'abtpackagemanager' +require 'abtpackage' require 'AbtQueueManager' require 'AbtReportManager' require 'AbtSystemManager' Copied: src/trunk/abtpackage.rb (from rev 353, src/trunk/AbtPackage.rb) =================================================================== --- src/trunk/abtpackage.rb (rev 0) +++ src/trunk/abtpackage.rb 2007-07-16 12:30:36 UTC (rev 354) @@ -0,0 +1,378 @@ +#!/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 unpackSources + srcFile = File.basename( @srcUrl ) + sourcesToUnpack = "#{$SOURCES_REPOSITORY}/#{srcFile}" + unpackTool = "" + + # check for existing file in source repo. + if ( !File.exist?( sourcesToUnpack ) ) + return false + end + + # check if possible existing sources in build directory. + if ( File.directory?( "#{$BUILD_LOCATION}/#{@srcDir}" ) ) + return true + end + + # determine which supported compression used [gz, tar, tgz, bz2, zip]. + compressionType = srcFile.split( '.' ) + + case compressionType.last + + when "gz" + unpackTool = "tar xzvf" + + when "tar" + unpackTool = "tar xvf" + + when "bz2" + unpackTool = "tar xjvf" + + when "tgz" + unpackTool = "tar xzvf" + + when "zip" + unpackTool = "unizp" + + else + # unsupported format. + return false + end + + # DEBUG: + #logger = AbtLogManager.new + #logger.logToJournal( "DEBUG: unpack tool will be '#{unpackTool}'." ) + + Dir.chdir( $BUILD_LOCATION ) + if ( !system( "#{unpackTool} #{sourcesToUnpack}" ) ) + return false + end + + return true + end + + private + + public + + # the name of the package. + attr_reader :name + + # the executable name for the package. + attr_reader :execName + + # the package version number. + attr_reader :version + + # the source directory for the package. + attr_reader :srcDir + + # the packages homepage. + attr_reader :homepage + + # the URL where this packages sources can be obtained. + attr_reader :srcUrl + + # list of dependsOn (DO) related package dependencies. + attr_reader :dependsOn + + # list of reliesOn (RO) related package dependencies. + attr_reader :reliesOn + + # list of optional reliesOn (oRO) related package dependencies. + attr_reader :optionalDO + + # list of optional dependsOn (oDO) related package dependencies. + attr_reader :optionalRO + + # security hash value of package sources. + attr_reader :hashCheck + + # list of available patches for this package. + attr_reader :patches + + # security hash value of this packages patches. + attr_reader :patchesHashCheck + + # available mirrors for this package. + attr_reader :mirrorPath + + # type of license this package has. + attr_reader :licence + + # the package description. + attr_reader :description + + + ## + # Constructor for an AbtPackage, requires all the packge details. + # + # <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.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) + return false + end + + # unpack sources. + if ( !self.unpackSources ) + 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 "DEBUG: [AbtPackage.configure] - configure section failed." + return false + end + + puts "\nDEBUG: [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 "DEBUG: [AbtPackage.build] - build section failed." + return false + end + + puts "DEBUG: [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 "DEBUG: [AbtPackage.install] - install section failed." + return false + end + + puts "DEBUG: [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 removeBuild + 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 12:26:53
|
Revision: 353 http://svn.sourceforge.net/abtlinux/?rev=353&view=rev Author: eschabell Date: 2007-07-16 05:26:55 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated package manager class and test class along with references to rubified file names. Modified Paths: -------------- src/trunk/abtconfig.rb src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/abtpackagemanager.rb src/trunk/testabtpackagemanager.rb Removed Paths: ------------- src/trunk/AbtPackageManager.rb src/trunk/TestAbtPackageManager.rb Deleted: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-07-16 12:17:21 UTC (rev 352) +++ src/trunk/AbtPackageManager.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -1,290 +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 rollBack( type, details ) - logFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/" - - case type - when "install" - logFile = logFile + "#{details['Source location']}.install" - - file = File.new( logFile, "r" ) - while ( line = file.gets ) - #puts "DEBUG: about to remove ***#{line.chomp}***" - if ( File.file?( line.chomp ) ) - File.delete( line.chomp ) - else - puts "DEBUG: file not exist? ***#{File.basename( line.chomp )}***" - end - end - file.close - - # cleanup install log as it is incomplete. - File.delete( logFile ) - else - puts "DEBUG: attempt to use APM:rollBack( type ) incorrectly, " + - "unsupported type?" - return false - end - - return true - end - - - public - - ## - # 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 installPackage( package, verbose=true ) - - # first check if installed. - system = AbtSystemManager.new - if ( system.packageInstalled( package ) ) - puts "\n*** Package #{package} is installed, might want to try reinstall? ***" - puts "'abt reinstall #{package}'" - return true - end - - require "#{$PACKAGE_PATH}#{package}" - sw = eval( "#{package.capitalize}.new" ) - queuer = AbtQueueManager.new - logger = AbtLogManager.new - - # get package details. - details = sw.details - - # TODO: check deps - - # add to install queue. - puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) - - if ( !queuer.actionPackageQueue( package, "install", "add" ) ) - logger.logToJournal( "Failed to add #{package} to install queue." ) - return false - end - - # pre section. - puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) - - if ( !sw.pre ) - logger.logToJournal( "Failed to process pre-section in the " + - "package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: finished #{package} pre section." ) - end - - # configure section. - puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) - - if ( !sw.configure( verbose ) ) - logger.logToJournal( "Failed to process configure section in the " + - "package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: finished #{package} configure section." ) - end - - # build section. - puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) - - if ( !sw.build( verbose ) ) - logger.logToJournal( "Failed to process build section in the " + - "package description of #{package}." ) - return false - else - if ( !logger.logPackageBuild( sw.name.downcase ) ) - logger.logToJournal( "Failed to create a package build log." ) - return false - end - logger.logToJournal( "DEBUG: finished #{package} build section." ) - end - - # preinstall section. - puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) - - if ( !sw.preinstall ) - logger.logToJournal( "Failed to process preinstall section in the " + - "package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: 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.logToJournal( "Failed to process install section in the " + - "package description of #{package}." ) - logger.logPackageInstall( sw.name.downcase ) - logger.logToJournal( - "***Starting rollback of #{package} install and removing install log." ) - self.rollBack( "install", details ) - return false - else - logger.logPackageInstall( sw.name.downcase ) - logger.logPackageIntegrity( sw.name.downcase ) - - # cleanup tmp files from installwatch. - File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) - - logger.logToJournal( "DEBUG: finished #{package} install section." ) - end - - # post section. - puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) - - if ( !sw.post ) - logger.logToJournal( "Failed to process post section in the " + - "package description of #{package}." ) - return false - else - logger.logToJournal( "DEBUG: finished #{package} post section." ) - end - - # clean out build sources. - puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) - - if ( !sw.removeBuild ) - logger.logToJournal( "Failed to remove the build sources for " + - "#{package}." ) - #return false # commented out as this is not a reason to fail. - end - - # remove pacakge from install queue. - if ( !queuer.actionPackageQueue( sw.name.downcase, "install", "remove" ) ) - logger.logToJournal( "Failed to remove #{sw.name.donwcase} " + - "from install queue." ) - end - - return true # install completed! - end - - ## - # Reinstalls a given package. - # - # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. - # - # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, - # otherwise false. - ## - def reinstallPackage( package ) - 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 removePackage( package ) - 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 downgradePackage( package, version ) - end - - ## - # Freezes a given package. If successful will add give package to the frozen - # list. - # - # <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 freezePackage( package ) - 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 rootLogin( arguments ) - if ( Process.uid != 0 ) - args = "" - puts "\nEnter root password:" - - for i in 0...ARGV.length - args = args + " " + ARGV[i] - end - - system( 'su -c "./abt ' + args + '" root' ) - exit - end - end -end Deleted: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-07-16 12:17:21 UTC (rev 352) +++ src/trunk/TestAbtPackageManager.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -1,83 +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() - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtPackageManager.testInstallPackage()' - ## - def testInstallPackage - assert( @pkgMgr.installPackage( "ipc", $verbose ), "testInstallPackage()" ) - end - - ## - # Test method for 'AbtPackageManager.testReinstallPackage()' - ## - def testReinstallPackage - assert( @pkgMgr.reinstallPackage( "ipc" ), "testReinstallPackage()" ) - end - - ## - # Test method for 'AbtPackageManager.testRemovePackage()' - ## - def testRemovePackage - assert( @pkgMgr.removePackage( "ipc" ), "testRemovePackage()" ) - end - - ## - # Test method for 'AbtPackageManager.testDowngradePackage()' - ## - def testDowngradePackage - assert( @pkgMgr.downgradePackage( "ipc", "1.2" ), "testDowngradePackage()" ) - end - - ## - # Test method for 'AbtPackageManager.testFreezePackage()' - ## - def testFreezePackage - assert( @pkgMgr.freezePackage( "ipc" ), "testFreezePackage()" ) - end - -end Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 12:17:21 UTC (rev 352) +++ src/trunk/abtconfig.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -28,7 +28,7 @@ # global requires. require 'abtdownloadmanager' require 'abtlogmanager' -require 'AbtPackageManager' +require 'abtpackagemanager' require 'AbtQueueManager' require 'AbtReportManager' require 'AbtSystemManager' Copied: src/trunk/abtpackagemanager.rb (from rev 350, src/trunk/AbtPackageManager.rb) =================================================================== --- src/trunk/abtpackagemanager.rb (rev 0) +++ src/trunk/abtpackagemanager.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -0,0 +1,290 @@ +#!/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 rollBack( type, details ) + logFile = "#{$PACKAGE_INSTALLED}/#{details['Source location']}/" + + case type + when "install" + logFile = logFile + "#{details['Source location']}.install" + + file = File.new( logFile, "r" ) + while ( line = file.gets ) + #puts "DEBUG: about to remove ***#{line.chomp}***" + if ( File.file?( line.chomp ) ) + File.delete( line.chomp ) + else + puts "DEBUG: file not exist? ***#{File.basename( line.chomp )}***" + end + end + file.close + + # cleanup install log as it is incomplete. + File.delete( logFile ) + else + puts "DEBUG: attempt to use APM:rollBack( type ) incorrectly, " + + "unsupported type?" + return false + end + + return true + end + + + public + + ## + # 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 installPackage( package, verbose=true ) + + # first check if installed. + system = AbtSystemManager.new + if ( system.packageInstalled( package ) ) + puts "\n*** Package #{package} is installed, might want to try reinstall? ***" + puts "'abt reinstall #{package}'" + return true + end + + require "#{$PACKAGE_PATH}#{package}" + sw = eval( "#{package.capitalize}.new" ) + queuer = AbtQueueManager.new + logger = AbtLogManager.new + + # get package details. + details = sw.details + + # TODO: check deps + + # add to install queue. + puts "\n*** Adding #{package} to the INSTALL QUEUE. ***" if ( verbose ) + + if ( !queuer.actionPackageQueue( package, "install", "add" ) ) + logger.logToJournal( "Failed to add #{package} to install queue." ) + return false + end + + # pre section. + puts "\n*** Processing the PRE section for #{package}. ***" if (verbose ) + + if ( !sw.pre ) + logger.logToJournal( "Failed to process pre-section in the " + + "package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} pre section." ) + end + + # configure section. + puts "\n*** Processing the CONFIGURE section for #{package}. ***" if ( verbose ) + + if ( !sw.configure( verbose ) ) + logger.logToJournal( "Failed to process configure section in the " + + "package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} configure section." ) + end + + # build section. + puts "\n*** Processing the BUILD section for #{package}. ***" if ( verbose ) + + if ( !sw.build( verbose ) ) + logger.logToJournal( "Failed to process build section in the " + + "package description of #{package}." ) + return false + else + if ( !logger.logPackageBuild( sw.name.downcase ) ) + logger.logToJournal( "Failed to create a package build log." ) + return false + end + logger.logToJournal( "DEBUG: finished #{package} build section." ) + end + + # preinstall section. + puts "\n*** Processing the PREINSTALL section for #{package}. ***" if ( verbose ) + + if ( !sw.preinstall ) + logger.logToJournal( "Failed to process preinstall section in the " + + "package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: 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.logToJournal( "Failed to process install section in the " + + "package description of #{package}." ) + logger.logPackageInstall( sw.name.downcase ) + logger.logToJournal( + "***Starting rollback of #{package} install and removing install log." ) + self.rollBack( "install", details ) + return false + else + logger.logPackageInstall( sw.name.downcase ) + logger.logPackageIntegrity( sw.name.downcase ) + + # cleanup tmp files from installwatch. + File.delete( "#{$ABT_TMP}/#{details['Source location']}.watch" ) + + logger.logToJournal( "DEBUG: finished #{package} install section." ) + end + + # post section. + puts "\n*** Processing the POST section for #{package}. ***" if ( verbose ) + + if ( !sw.post ) + logger.logToJournal( "Failed to process post section in the " + + "package description of #{package}." ) + return false + else + logger.logToJournal( "DEBUG: finished #{package} post section." ) + end + + # clean out build sources. + puts "\n*** Cleaning up the sources for #{package}. ***" if ( verbose ) + + if ( !sw.removeBuild ) + logger.logToJournal( "Failed to remove the build sources for " + + "#{package}." ) + #return false # commented out as this is not a reason to fail. + end + + # remove pacakge from install queue. + if ( !queuer.actionPackageQueue( sw.name.downcase, "install", "remove" ) ) + logger.logToJournal( "Failed to remove #{sw.name.donwcase} " + + "from install queue." ) + end + + return true # install completed! + end + + ## + # Reinstalls a given package. + # + # <b>PARAM</b> <i>String</i> - the name of the package to be reinstalled. + # + # <b>RETURN</b> <i>boolean</i> - True if the package is reinstalled, + # otherwise false. + ## + def reinstallPackage( package ) + 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 removePackage( package ) + 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 downgradePackage( package, version ) + end + + ## + # Freezes a given package. If successful will add give package to the frozen + # list. + # + # <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 freezePackage( package ) + 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 rootLogin( arguments ) + if ( Process.uid != 0 ) + args = "" + puts "\nEnter root password:" + + for i in 0...ARGV.length + args = args + " " + ARGV[i] + end + + system( 'su -c "./abt ' + args + '" root' ) + exit + end + end +end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 12:17:21 UTC (rev 352) +++ src/trunk/testSuiteAbt.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -22,7 +22,7 @@ manager = AbtPackageManager.new manager.installPackage( "ipc" ) -require 'TestAbtPackageManager' +require 'testabtpackagemanager' require 'testabtlogmanager' require 'testabtdownloadmanager' require 'TestAbtPackage' Copied: src/trunk/testabtpackagemanager.rb (from rev 350, src/trunk/TestAbtPackageManager.rb) =================================================================== --- src/trunk/testabtpackagemanager.rb (rev 0) +++ src/trunk/testabtpackagemanager.rb 2007-07-16 12:26:55 UTC (rev 353) @@ -0,0 +1,83 @@ +#!/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() + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtPackageManager.testInstallPackage()' + ## + def testInstallPackage + assert( @pkgMgr.installPackage( "ipc", $verbose ), "testInstallPackage()" ) + end + + ## + # Test method for 'AbtPackageManager.testReinstallPackage()' + ## + def testReinstallPackage + assert( @pkgMgr.reinstallPackage( "ipc" ), "testReinstallPackage()" ) + end + + ## + # Test method for 'AbtPackageManager.testRemovePackage()' + ## + def testRemovePackage + assert( @pkgMgr.removePackage( "ipc" ), "testRemovePackage()" ) + end + + ## + # Test method for 'AbtPackageManager.testDowngradePackage()' + ## + def testDowngradePackage + assert( @pkgMgr.downgradePackage( "ipc", "1.2" ), "testDowngradePackage()" ) + end + + ## + # Test method for 'AbtPackageManager.testFreezePackage()' + ## + def testFreezePackage + assert( @pkgMgr.freezePackage( "ipc" ), "testFreezePackage()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 12:17:22
|
Revision: 352 http://svn.sourceforge.net/abtlinux/?rev=352&view=rev Author: eschabell Date: 2007-07-16 05:17:21 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated log manager test class and references to rubified file name. Modified Paths: -------------- src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/testabtlogmanager.rb Removed Paths: ------------- src/trunk/TestAbtLogManager.rb Deleted: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-07-16 12:15:43 UTC (rev 351) +++ src/trunk/TestAbtLogManager.rb 2007-07-16 12:17:21 UTC (rev 352) @@ -1,82 +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 - @log = AbtLogManager.new() - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtLogManager.testLogPackageIntegrity()' - ## - def testLogPackageIntegrity() - assert( @log.logPackageIntegrity( "ipc" ), "testLogPackageIntegrity()" ) - end - - ## - # Test method for 'AbtLogManager.testLogPackageInstall()' - ## - def testLogPackageInstall() - assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) - end - - ## - # Test method for 'AbtLogManager.testLogPackageBuild()' - ## - def testLogPackageBuild() - assert( @log.logPackageBuild( "ipc" ), "testLogPackageBuild()" ) - end - - ## - # Test method for 'AbtLogManager.testCachePackage()' - ## - def testCachePackage() - assert( @log.cachePackage( "ipc" ), "testCachePackage()" ) - end - - ## - # Test method for 'AbtLogManager.testLogToJournal()' - ## - def testLogToJournal() - assert( @log.logToJournal( "Test message from AbtTestSuite." ), - "testLogToJournal()" ) - end - -end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 12:15:43 UTC (rev 351) +++ src/trunk/testSuiteAbt.rb 2007-07-16 12:17:21 UTC (rev 352) @@ -23,7 +23,7 @@ manager.installPackage( "ipc" ) require 'TestAbtPackageManager' -require 'TestAbtLogManager' +require 'testabtlogmanager' require 'testabtdownloadmanager' require 'TestAbtPackage' require 'TestAbtQueueManager' Copied: src/trunk/testabtlogmanager.rb (from rev 351, src/trunk/TestAbtLogManager.rb) =================================================================== --- src/trunk/testabtlogmanager.rb (rev 0) +++ src/trunk/testabtlogmanager.rb 2007-07-16 12:17:21 UTC (rev 352) @@ -0,0 +1,82 @@ +#!/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 + @log = AbtLogManager.new() + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtLogManager.testLogPackageIntegrity()' + ## + def testLogPackageIntegrity() + assert( @log.logPackageIntegrity( "ipc" ), "testLogPackageIntegrity()" ) + end + + ## + # Test method for 'AbtLogManager.testLogPackageInstall()' + ## + def testLogPackageInstall() + assert( @log.logPackageInstall( "ipc" ), "testLogPackageInstall()" ) + end + + ## + # Test method for 'AbtLogManager.testLogPackageBuild()' + ## + def testLogPackageBuild() + assert( @log.logPackageBuild( "ipc" ), "testLogPackageBuild()" ) + end + + ## + # Test method for 'AbtLogManager.testCachePackage()' + ## + def testCachePackage() + assert( @log.cachePackage( "ipc" ), "testCachePackage()" ) + end + + ## + # Test method for 'AbtLogManager.testLogToJournal()' + ## + def testLogToJournal() + assert( @log.logToJournal( "Test message from AbtTestSuite." ), + "testLogToJournal()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 12:15:41
|
Revision: 351 http://svn.sourceforge.net/abtlinux/?rev=351&view=rev Author: eschabell Date: 2007-07-16 05:15:43 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated log manager and references to rubified file name. Modified Paths: -------------- src/trunk/TestAbtLogManager.rb src/trunk/TestAbtQueueManager.rb src/trunk/abtconfig.rb Added Paths: ----------- src/trunk/abtlogmanager.rb Removed Paths: ------------- src/trunk/AbtLogManager.rb Deleted: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-07-16 12:11:36 UTC (rev 350) +++ src/trunk/AbtLogManager.rb 2007-07-16 12:15:43 UTC (rev 351) @@ -1,305 +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 - - ## - # Returns the path to given packages install log. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>String</i> - Full path to install log. - ## - def getLog( package, type ) - require "#{$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" - - else - log = "" - - end - - return log - end - - - public - - ## - # Constructor for the AbtLogManager. It ensures all needed logs paths are - # initialized. - # - # - # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. - ## - def initialize - [$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 ) - logToJournal << "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 logPackageIntegrity( package ) - #require "#{$PACKAGE_PATH}#{package}" - #sw = eval( "#{package.capitalize}.new" ) - #details = sw.details - - # our log locations. - installLog = getLog( package, 'install' ) - integrityLog = getLog( 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 logPackageInstall( 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 = getLog( package, 'install' ) - tmpInstallLog = getLog( 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 ) - #self.logToJournal( "DEBUG: Found bad logLine!" ) - badLine = true - else - badLine = false - end - - if ( !badLine ) - #self.logToJournal( "DEBUG: adding line to installFile!") - installFile << "#{line.split[2]}\n" - end - end - end - - installFile.close - end - - return true; - end - - ## - # Provides logging of all output produced during the build phase of the - # given package. Should be called as part of the install phase of the build. - # - # <b>PARAM</b> <i>String</i> - Package name. - # - # <b>RETURN</b> <i>boolean</i> - True if build log created successfully, - # otherwise false. - ## - def logPackageBuild( package ) - buildLog = getLog( 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 cachePackage( package ) - system = AbtSystemManager.new - - if ( system.packageInstalled( package ) ) - sw = eval( "#{package.capitalize}.new" ) - cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir - sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) - sourceFile = File.basename( sw.srcUrl ) - installLog = getLog( package, 'install' ) - buildLog = getLog( package, 'install' ) - configureLog = getLog( package, 'install' ) - integrityLog = getLog( package, 'install' ) - packageFile = "#{$PACKAGE_PATH}#{package}.rb" - - - 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 - - ## - # Provides logging of given message to the AbTLinux journal. Message logged - # with date timestamp. - # - # <b>PARAM</b> <i>String</i> - Message to be added to the log. - # - # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. - ## - def logToJournal( message ) - if ( log = File.new( $JOURNAL, "a+" ) ) - log << "#{$TIMESTAMP} : #{message}\n" - log.close - return true - end - - return false - end -end Modified: src/trunk/TestAbtLogManager.rb =================================================================== --- src/trunk/TestAbtLogManager.rb 2007-07-16 12:11:36 UTC (rev 350) +++ src/trunk/TestAbtLogManager.rb 2007-07-16 12:15:43 UTC (rev 351) @@ -3,7 +3,6 @@ require 'test/unit/testcase' require 'test/unit/autorunner' require 'abtconfig' -require 'AbtLogManager' ## # TestAbtLogManager.rb Modified: src/trunk/TestAbtQueueManager.rb =================================================================== --- src/trunk/TestAbtQueueManager.rb 2007-07-16 12:11:36 UTC (rev 350) +++ src/trunk/TestAbtQueueManager.rb 2007-07-16 12:15:43 UTC (rev 351) @@ -3,8 +3,6 @@ require 'test/unit/testcase' require 'test/unit/autorunner' require 'abtconfig' -require 'AbtQueueManager' -require 'AbtLogManager' ## # TestAbtQueueManager.rb Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 12:11:36 UTC (rev 350) +++ src/trunk/abtconfig.rb 2007-07-16 12:15:43 UTC (rev 351) @@ -27,7 +27,7 @@ # global requires. require 'abtdownloadmanager' -require 'AbtLogManager' +require 'abtlogmanager' require 'AbtPackageManager' require 'AbtQueueManager' require 'AbtReportManager' Copied: src/trunk/abtlogmanager.rb (from rev 350, src/trunk/AbtLogManager.rb) =================================================================== --- src/trunk/abtlogmanager.rb (rev 0) +++ src/trunk/abtlogmanager.rb 2007-07-16 12:15:43 UTC (rev 351) @@ -0,0 +1,305 @@ +#!/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 + + ## + # Returns the path to given packages install log. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>String</i> - Full path to install log. + ## + def getLog( package, type ) + require "#{$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" + + else + log = "" + + end + + return log + end + + + public + + ## + # Constructor for the AbtLogManager. It ensures all needed logs paths are + # initialized. + # + # + # <b>RETURN</b> <i>AbtLogManager</i> - an initialized AbtLogManager object. + ## + def initialize + [$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 ) + logToJournal << "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 logPackageIntegrity( package ) + #require "#{$PACKAGE_PATH}#{package}" + #sw = eval( "#{package.capitalize}.new" ) + #details = sw.details + + # our log locations. + installLog = getLog( package, 'install' ) + integrityLog = getLog( 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 logPackageInstall( 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 = getLog( package, 'install' ) + tmpInstallLog = getLog( 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 ) + #self.logToJournal( "DEBUG: Found bad logLine!" ) + badLine = true + else + badLine = false + end + + if ( !badLine ) + #self.logToJournal( "DEBUG: adding line to installFile!") + installFile << "#{line.split[2]}\n" + end + end + end + + installFile.close + end + + return true; + end + + ## + # Provides logging of all output produced during the build phase of the + # given package. Should be called as part of the install phase of the build. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>boolean</i> - True if build log created successfully, + # otherwise false. + ## + def logPackageBuild( package ) + buildLog = getLog( 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 cachePackage( package ) + system = AbtSystemManager.new + + if ( system.packageInstalled( package ) ) + sw = eval( "#{package.capitalize}.new" ) + cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir + sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) + sourceFile = File.basename( sw.srcUrl ) + installLog = getLog( package, 'install' ) + buildLog = getLog( package, 'install' ) + configureLog = getLog( package, 'install' ) + integrityLog = getLog( package, 'install' ) + packageFile = "#{$PACKAGE_PATH}#{package}.rb" + + + 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 + + ## + # Provides logging of given message to the AbTLinux journal. Message logged + # with date timestamp. + # + # <b>PARAM</b> <i>String</i> - Message to be added to the log. + # + # <b>RETURN</b> <i>boolean</i> True if logged, otherwise false. + ## + def logToJournal( message ) + if ( log = File.new( $JOURNAL, "a+" ) ) + log << "#{$TIMESTAMP} : #{message}\n" + log.close + return true + end + + 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-07-16 12:11:34
|
Revision: 350 http://svn.sourceforge.net/abtlinux/?rev=350&view=rev Author: eschabell Date: 2007-07-16 05:11:36 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated test of download manager and references. Modified Paths: -------------- src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/testabtdownloadmanager.rb Removed Paths: ------------- src/trunk/TestAbtDownloadManager.rb Deleted: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-07-16 11:55:55 UTC (rev 349) +++ src/trunk/TestAbtDownloadManager.rb 2007-07-16 12:11:36 UTC (rev 350) @@ -1,84 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' -require 'abtdownloadmanager' -require 'AbtLogManager' - -## -# 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() - end - - ## - # teardown method to cleanup after testing. - ## - def teardown - end - - ## - # Test method for 'AbtDownloadManager.testRetrievePackageSource()' - ## - def testRetrievePackageSource() - assert( @download.retrievePackageSource( "ipc", "#{$SOURCES_REPOSITORY}" ), - "testRetrievePackageSource()" ) - end - - ## - # Test method for 'AbtDownloadManager.testRetrievePackageTree()' - ## - def testRetrievePackageTree() - assert( @download.retrievePackageTree( "dummy" ), - "testRetrievePackageTree()" ) - end - - ## - # Test method for 'AbtDownloadManager.testRetrieveNewsFeed()' - ## - def testRetrieveNewsFeed() - assert( @download.retrieveNewsFeed( $ABTNEWS ), "testRetrieveNewsFeed()" ) - end - - ## - # Test method for 'AbtDownloadManager.testUpdatePackage()' - ## - def testUpdatePackage() - assert( @download.updatePackage(), "testUpdatePackage()" ) - end - - ## - # Test method for 'AbtDownloadManager.testUpdatePackageTree()' - ## - def testUpdatePackageTree() - assert( @download.updatePackageTree(), "testUpdatePackageTree()" ) - end -end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 11:55:55 UTC (rev 349) +++ src/trunk/testSuiteAbt.rb 2007-07-16 12:11:36 UTC (rev 350) @@ -24,7 +24,7 @@ require 'TestAbtPackageManager' require 'TestAbtLogManager' -require 'TestAbtDownloadManager' +require 'testabtdownloadmanager' require 'TestAbtPackage' require 'TestAbtQueueManager' require 'TestAbtReportManager' Copied: src/trunk/testabtdownloadmanager.rb (from rev 349, src/trunk/TestAbtDownloadManager.rb) =================================================================== --- src/trunk/testabtdownloadmanager.rb (rev 0) +++ src/trunk/testabtdownloadmanager.rb 2007-07-16 12:11:36 UTC (rev 350) @@ -0,0 +1,82 @@ +#!/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() + end + + ## + # teardown method to cleanup after testing. + ## + def teardown + end + + ## + # Test method for 'AbtDownloadManager.testRetrievePackageSource()' + ## + def testRetrievePackageSource() + assert( @download.retrievePackageSource( "ipc", "#{$SOURCES_REPOSITORY}" ), + "testRetrievePackageSource()" ) + end + + ## + # Test method for 'AbtDownloadManager.testRetrievePackageTree()' + ## + def testRetrievePackageTree() + assert( @download.retrievePackageTree( "dummy" ), + "testRetrievePackageTree()" ) + end + + ## + # Test method for 'AbtDownloadManager.testRetrieveNewsFeed()' + ## + def testRetrieveNewsFeed() + assert( @download.retrieveNewsFeed( $ABTNEWS ), "testRetrieveNewsFeed()" ) + end + + ## + # Test method for 'AbtDownloadManager.testUpdatePackage()' + ## + def testUpdatePackage() + assert( @download.updatePackage(), "testUpdatePackage()" ) + end + + ## + # Test method for 'AbtDownloadManager.testUpdatePackageTree()' + ## + def testUpdatePackageTree() + assert( @download.updatePackageTree(), "testUpdatePackageTree()" ) + end +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 11:55:54
|
Revision: 349 http://svn.sourceforge.net/abtlinux/?rev=349&view=rev Author: eschabell Date: 2007-07-16 04:55:55 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated abt download manager to rubified file name and updated references. Modified Paths: -------------- src/trunk/TestAbtDownloadManager.rb src/trunk/TestAbtPackage.rb src/trunk/abtconfig.rb Added Paths: ----------- src/trunk/abtdownloadmanager.rb Removed Paths: ------------- src/trunk/AbtDownloadManager.rb Deleted: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-07-16 11:44:54 UTC (rev 348) +++ src/trunk/AbtDownloadManager.rb 2007-07-16 11:55:55 UTC (rev 349) @@ -1,162 +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 retrievePackageSource( packageName, destination ) - require "#{$PACKAGE_PATH}#{packageName}" - logger = AbtLogManager.new - package = eval( packageName.capitalize + '.new' ) - - if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) - logger.logToJournal( "Download not needed, existing source found for #{packageName}" ) - return true - end - - Dir.chdir( destination ) - if ( system( "wget #{package.srcUrl}" ) ) - logger.logToJournal( "Download completed for #{packageName}" ) - return true - end - - return false # download failed. - end - - ## - # 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 retrievePackageTree( packageTreeName ) - end - - ## - # Retrieves the given feed and displays the news items. - # - # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. - # <b>PARAM</b> <i>boolean</i> - default is to emplty the log file, - # passing 'false' will append to news file. - # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been - # retrieved, otherwise false. - ## - def retrieveNewsFeed( uri, cleanLog=true ) - require 'net/http' - require 'uri' - require 'rss/1.0' - require 'rss/2.0' - newsLog = "" - logger = AbtLogManager.new - - # ensure we have our news logfile. - if ( cleanLog ) - 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.logToJournal( "Failed to retrieve news feed #{uri}." ) - return false - end - - # display the feeds. - rss = nil - begin - rss = RSS::Parser.parse(news, false) - rescue RSS::Error - end - - if ( rss.nil? ) - logger.logToJournal( "Failed to display news feed as feed #{uri} " + - "is not RSS 1.0/2.0." ) - return false - else - newsLog << "*** #{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 updatePackage - end - - ## - # Updates the package tree. - # - # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, - # otherwise false. - ## - def updatePackageTree - end - -end Modified: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-07-16 11:44:54 UTC (rev 348) +++ src/trunk/TestAbtDownloadManager.rb 2007-07-16 11:55:55 UTC (rev 349) @@ -3,7 +3,7 @@ require 'test/unit/testcase' require 'test/unit/autorunner' require 'abtconfig' -require 'AbtDownloadManager' +require 'abtdownloadmanager' require 'AbtLogManager' ## Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-07-16 11:44:54 UTC (rev 348) +++ src/trunk/TestAbtPackage.rb 2007-07-16 11:55:55 UTC (rev 349) @@ -4,7 +4,6 @@ require "test/unit/autorunner" require "abtconfig" require "AbtPackage" -require "AbtDownloadManager" require "#{$PACKAGE_PATH}ipc" ## Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-07-16 11:44:54 UTC (rev 348) +++ src/trunk/abtconfig.rb 2007-07-16 11:55:55 UTC (rev 349) @@ -26,7 +26,7 @@ ## # global requires. -require 'AbtDownloadManager' +require 'abtdownloadmanager' require 'AbtLogManager' require 'AbtPackageManager' require 'AbtQueueManager' Copied: src/trunk/abtdownloadmanager.rb (from rev 346, src/trunk/AbtDownloadManager.rb) =================================================================== --- src/trunk/abtdownloadmanager.rb (rev 0) +++ src/trunk/abtdownloadmanager.rb 2007-07-16 11:55:55 UTC (rev 349) @@ -0,0 +1,162 @@ +#!/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 retrievePackageSource( packageName, destination ) + require "#{$PACKAGE_PATH}#{packageName}" + logger = AbtLogManager.new + package = eval( packageName.capitalize + '.new' ) + + if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) + logger.logToJournal( "Download not needed, existing source found for #{packageName}" ) + return true + end + + Dir.chdir( destination ) + if ( system( "wget #{package.srcUrl}" ) ) + logger.logToJournal( "Download completed for #{packageName}" ) + return true + end + + return false # download failed. + end + + ## + # 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 retrievePackageTree( packageTreeName ) + end + + ## + # Retrieves the given feed and displays the news items. + # + # <b>PARAM</b> <i>String</i> - the uri of the rss news feed to be retrieved. + # <b>PARAM</b> <i>boolean</i> - default is to emplty the log file, + # passing 'false' will append to news file. + # <b>RETURN</b> <i>boolean</i> - True if the AbTLinux news feed has been + # retrieved, otherwise false. + ## + def retrieveNewsFeed( uri, cleanLog=true ) + require 'net/http' + require 'uri' + require 'rss/1.0' + require 'rss/2.0' + newsLog = "" + logger = AbtLogManager.new + + # ensure we have our news logfile. + if ( cleanLog ) + 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.logToJournal( "Failed to retrieve news feed #{uri}." ) + return false + end + + # display the feeds. + rss = nil + begin + rss = RSS::Parser.parse(news, false) + rescue RSS::Error + end + + if ( rss.nil? ) + logger.logToJournal( "Failed to display news feed as feed #{uri} " + + "is not RSS 1.0/2.0." ) + return false + else + newsLog << "*** #{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 updatePackage + end + + ## + # Updates the package tree. + # + # <b>RETURN</b> <i>boolean</i> - True if the package tree has been updated, + # otherwise false. + ## + def updatePackageTree + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 11:45:15
|
Revision: 348 http://svn.sourceforge.net/abtlinux/?rev=348&view=rev Author: eschabell Date: 2007-07-16 04:44:54 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Migrated test class file for dep engine to rubyfied name and update references. Modified Paths: -------------- src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/testabtdepengine.rb Removed Paths: ------------- src/trunk/TestAbtDepEngine.rb Deleted: src/trunk/TestAbtDepEngine.rb =================================================================== --- src/trunk/TestAbtDepEngine.rb 2007-07-16 11:42:14 UTC (rev 347) +++ src/trunk/TestAbtDepEngine.rb 2007-07-16 11:44:54 UTC (rev 348) @@ -1,53 +0,0 @@ -#!/usr/bin/ruby -w - -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtdepengine' - -## -# 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.testDepEngine()' - ## - def testDepEngine - assert_equal( false, true, "testDepEngine()" ) - end - -end Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-16 11:42:14 UTC (rev 347) +++ src/trunk/testSuiteAbt.rb 2007-07-16 11:44:54 UTC (rev 348) @@ -29,4 +29,4 @@ require 'TestAbtQueueManager' require 'TestAbtReportManager' require 'TestAbtSystemManager' -require 'TestAbtDepEngine' +require 'testabtdepengine' Copied: src/trunk/testabtdepengine.rb (from rev 346, src/trunk/TestAbtDepEngine.rb) =================================================================== --- src/trunk/testabtdepengine.rb (rev 0) +++ src/trunk/testabtdepengine.rb 2007-07-16 11:44:54 UTC (rev 348) @@ -0,0 +1,53 @@ +#!/usr/bin/ruby -w + +require 'test/unit/testcase' +require 'test/unit/autorunner' +require 'abtdepengine' + +## +# 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.testDepEngine()' + ## + def testDepEngine + assert_equal( false, true, "testDepEngine()" ) + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-16 11:42:16
|
Revision: 347 http://svn.sourceforge.net/abtlinux/?rev=347&view=rev Author: eschabell Date: 2007-07-16 04:42:14 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Removed reference to self, unneeded. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-07-15 20:09:20 UTC (rev 346) +++ src/trunk/AbtLogManager.rb 2007-07-16 11:42:14 UTC (rev 347) @@ -84,7 +84,7 @@ if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) - self << logToJournal << "Created directory: #{dir}." + logToJournal << "Created directory: #{dir}." end } end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-15 20:09:18
|
Revision: 346 http://svn.sourceforge.net/abtlinux/?rev=346&view=rev Author: eschabell Date: 2007-07-15 13:09:20 -0700 (Sun, 15 Jul 2007) Log Message: ----------- Rubifed the depengine file names. Modified Paths: -------------- src/trunk/TestAbtDepEngine.rb src/trunk/testSuiteAbt.rb Added Paths: ----------- src/trunk/abtdepengine.rb Removed Paths: ------------- src/trunk/AbtDepEngine.rb Deleted: src/trunk/AbtDepEngine.rb =================================================================== --- src/trunk/AbtDepEngine.rb 2007-07-05 13:42:56 UTC (rev 345) +++ src/trunk/AbtDepEngine.rb 2007-07-15 20:09:20 UTC (rev 346) @@ -1,44 +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 - end - -end \ No newline at end of file Modified: src/trunk/TestAbtDepEngine.rb =================================================================== --- src/trunk/TestAbtDepEngine.rb 2007-07-05 13:42:56 UTC (rev 345) +++ src/trunk/TestAbtDepEngine.rb 2007-07-15 20:09:20 UTC (rev 346) @@ -2,7 +2,7 @@ require 'test/unit/testcase' require 'test/unit/autorunner' -require 'AbtDepEngine' +require 'abtdepengine' ## # TestAbtDepEngine.rb Copied: src/trunk/abtdepengine.rb (from rev 345, src/trunk/AbtDepEngine.rb) =================================================================== --- src/trunk/abtdepengine.rb (rev 0) +++ src/trunk/abtdepengine.rb 2007-07-15 20:09:20 UTC (rev 346) @@ -0,0 +1,44 @@ +#!/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 + end + +end \ No newline at end of file Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-07-05 13:42:56 UTC (rev 345) +++ src/trunk/testSuiteAbt.rb 2007-07-15 20:09:20 UTC (rev 346) @@ -29,4 +29,4 @@ require 'TestAbtQueueManager' require 'TestAbtReportManager' require 'TestAbtSystemManager' -require 'TestAbtDepEngine' \ No newline at end of file +require 'TestAbtDepEngine' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:42:54
|
Revision: 345 http://svn.sourceforge.net/abtlinux/?rev=345&view=rev Author: eschabell Date: 2007-07-05 06:42:56 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Small auto line break fix. Modified Paths: -------------- src/trunk/AbtPackage.rb Modified: src/trunk/AbtPackage.rb =================================================================== --- src/trunk/AbtPackage.rb 2007-07-05 13:41:05 UTC (rev 344) +++ src/trunk/AbtPackage.rb 2007-07-05 13:42:56 UTC (rev 345) @@ -208,9 +208,7 @@ downloader = AbtDownloadManager.new # download sources. - if ( - !downloader.retrievePackageSource( - @name.downcase, $SOURCES_REPOSITORY ) ) + if ( !downloader.retrievePackageSource( @name.downcase, $SOURCES_REPOSITORY ) ) return false end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:41:08
|
Revision: 344 http://svn.sourceforge.net/abtlinux/?rev=344&view=rev Author: eschabell Date: 2007-07-05 06:41:05 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Refactored download manager to use << where possible. Refactored test class to download sources to global location instead of /tmp (early testing destination for everything). Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/TestAbtDownloadManager.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-07-05 13:39:30 UTC (rev 343) +++ src/trunk/AbtDownloadManager.rb 2007-07-05 13:41:05 UTC (rev 344) @@ -58,16 +58,14 @@ logger = AbtLogManager.new package = eval( packageName.capitalize + '.new' ) - if ( File.exist?( - destination + "/" + File.basename( package.srcUrl ) ) ) - logger.logToJournal( "Download not needed, existing source " + - "found for " + packageName ) + if ( File.exist?( "#{destination}/#{File.basename( package.srcUrl )}" ) ) + logger.logToJournal( "Download not needed, existing source found for #{packageName}" ) return true end Dir.chdir( destination ) if ( system( "wget #{package.srcUrl}" ) ) - logger.logToJournal( "Download completed for " + packageName ) + logger.logToJournal( "Download completed for #{packageName}" ) return true end @@ -127,15 +125,15 @@ "is not RSS 1.0/2.0." ) return false else - newsLog.puts "*** #{rss.channel.title} ***" + newsLog << "*** #{rss.channel.title} ***\n" rss.items.each_with_index do |item, itemCount| itemCount += 1 - newsLog.puts "#{itemCount} #{item.link} #{item.title}" + newsLog << "#{itemCount} #{item.link} #{item.title}\n" end end - newsLog.puts "\n" + newsLog << "\n\n" newsLog.close return true Modified: src/trunk/TestAbtDownloadManager.rb =================================================================== --- src/trunk/TestAbtDownloadManager.rb 2007-07-05 13:39:30 UTC (rev 343) +++ src/trunk/TestAbtDownloadManager.rb 2007-07-05 13:41:05 UTC (rev 344) @@ -49,7 +49,7 @@ # Test method for 'AbtDownloadManager.testRetrievePackageSource()' ## def testRetrievePackageSource() - assert( @download.retrievePackageSource( "ipc", "/tmp" ), + assert( @download.retrievePackageSource( "ipc", "#{$SOURCES_REPOSITORY}" ), "testRetrievePackageSource()" ) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:39:28
|
Revision: 343 http://svn.sourceforge.net/abtlinux/?rev=343&view=rev Author: eschabell Date: 2007-07-05 06:39:30 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Refactored log manager to use <<. Testing of this shows that it is not possible to do this outside the class itself, such as elsewhere in the code to replace logger.logToJournal( "text" ) with logger << logToJournal << "text". Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-07-05 13:06:54 UTC (rev 342) +++ src/trunk/AbtLogManager.rb 2007-07-05 13:39:30 UTC (rev 343) @@ -84,7 +84,7 @@ if ( ! File.directory?( dir ) ) FileUtils.mkdir_p( dir ) - self.logToJournal( "Created directory: #{dir}." ) + self << logToJournal << "Created directory: #{dir}." end } end @@ -118,7 +118,7 @@ IO.foreach( installLog ) do |line| status = File.stat( line.chomp ) octal = sprintf( "%o", status.mode ) - integrityFile.puts "#{line.chomp}:#{octal}" + integrityFile << "#{line.chomp}:#{octal}\n" end installFile.close @@ -167,7 +167,7 @@ if ( !badLine ) #self.logToJournal( "DEBUG: adding line to installFile!") - installFile.puts line.split[2] + installFile << "#{line.split[2]}\n" end end end @@ -295,7 +295,7 @@ ## def logToJournal( message ) if ( log = File.new( $JOURNAL, "a+" ) ) - log.puts "#{$TIMESTAMP} : #{message}" + log << "#{$TIMESTAMP} : #{message}\n" log.close return true end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-07-05 13:06:54
|
Revision: 342 http://svn.sourceforge.net/abtlinux/?rev=342&view=rev Author: eschabell Date: 2007-07-05 06:06:54 -0700 (Thu, 05 Jul 2007) Log Message: ----------- Refactored the code base to make use of global packages location. As we don't have package installation (repository) yet, you will need to symlink from the global location to the pacakges directory in trunk. Modified Paths: -------------- src/trunk/AbtDownloadManager.rb src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/AbtReportManager.rb src/trunk/AbtSystemManager.rb src/trunk/TestAbtPackage.rb src/trunk/abt.rb Modified: src/trunk/AbtDownloadManager.rb =================================================================== --- src/trunk/AbtDownloadManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtDownloadManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -54,7 +54,7 @@ # downloaded, otherwise false. ## def retrievePackageSource( packageName, destination ) - require "packages/#{packageName}" + require "#{$PACKAGE_PATH}#{packageName}" logger = AbtLogManager.new package = eval( packageName.capitalize + '.new' ) Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtLogManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -39,7 +39,7 @@ # <b>RETURN</b> <i>String</i> - Full path to install log. ## def getLog( package, type ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details @@ -100,7 +100,7 @@ # otherwise false. ## def logPackageIntegrity( package ) - #require "packages/#{package}" + #require "#{$PACKAGE_PATH}#{package}" #sw = eval( "#{package.capitalize}.new" ) #details = sw.details Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtPackageManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -103,7 +103,7 @@ return true end - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new logger = AbtLogManager.new Modified: src/trunk/AbtReportManager.rb =================================================================== --- src/trunk/AbtReportManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtReportManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -51,7 +51,7 @@ # otherwise false. ## def showPackageDetails( package ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" if ( package = eval( "#{package.capitalize}.new" ) ) details = package.details Modified: src/trunk/AbtSystemManager.rb =================================================================== --- src/trunk/AbtSystemManager.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/AbtSystemManager.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -176,7 +176,7 @@ # false. ## def packageInstalled( package ) - require "packages/#{package}" + require "#{$PACKAGE_PATH}#{package}" sw = eval( "#{package.capitalize}.new" ) details = sw.details Modified: src/trunk/TestAbtPackage.rb =================================================================== --- src/trunk/TestAbtPackage.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/TestAbtPackage.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -1,11 +1,11 @@ #!/usr/bin/ruby -w -require 'test/unit/testcase' -require 'test/unit/autorunner' -require 'abtconfig' -require 'AbtPackage' -require 'AbtDownloadManager' -require 'packages/ipc' +require "test/unit/testcase" +require "test/unit/autorunner" +require "abtconfig" +require "AbtPackage" +require "AbtDownloadManager" +require "#{$PACKAGE_PATH}ipc" ## # TestAbtPackage.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-15 14:08:23 UTC (rev 341) +++ src/trunk/abt.rb 2007-07-05 13:06:54 UTC (rev 342) @@ -54,7 +54,7 @@ logger.logToJournal( "Starting to install #{options['package']}" ) # return if already installed. - require "packages/#{options['package']}" + require "#{$PACKAGE_PATH}#{options['package']}" sw = eval( "#{options['package'].capitalize}.new" ) if ( manager.installPackage( options['package'] ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 14:08:21
|
Revision: 341 http://svn.sourceforge.net/abtlinux/?rev=341&view=rev Author: eschabell Date: 2007-06-15 07:08:23 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Implemented log managers cache package. Refactored abt install to make use of this automatically after a successful install. Expanded the packages path to now be on the system. (I have just symlinked this location to my svn checkout root location) Changed helper message when a package is called for installation, but is all ready installed. In this case it suggests trying reinstalling it. Another test passing, 26 to go, all unit tests for AbTLogManager are now passing! Modified Paths: -------------- src/trunk/AbtLogManager.rb src/trunk/AbtPackageManager.rb src/trunk/abt.rb src/trunk/abtconfig.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/AbtLogManager.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -211,26 +211,75 @@ system = AbtSystemManager.new if ( system.packageInstalled( package ) ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + sw = eval( "#{package.capitalize}.new" ) + cachedDir = $PACKAGE_CACHED + "/" + sw.srcDir + sourcePath = $SOURCES_REPOSITORY + "/" + File.basename( sw.srcUrl ) + sourceFile = File.basename( sw.srcUrl ) + installLog = getLog( package, 'install' ) + buildLog = getLog( package, 'install' ) + configureLog = getLog( package, 'install' ) + integrityLog = getLog( package, 'install' ) + packageFile = "#{$PACKAGE_PATH}#{package}.rb" - # TODO: collect package source. - FileTest::exists?("#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.install" ) - # TODO: collect package install log. - # TODO: collect package build log. + FileUtils.mkdir_p( cachedDir ) + + # collect package source. + if ( FileTest::exist?( sourcePath ) ) + FileUtils.copy_file( sourcePath, "#{cachedDir}/#{sourceFile}" ) + puts "\nCaching copy of #{package} source." + else + puts "\nUnable to cache copy of #{package} source." + end + + # collect package install log. + if ( FileTest::exist?( installLog ) ) + FileUtils.copy_file( installLog, "#{cachedDir}/#{sw.srcDir}.install" ) + puts "\nCaching copy of #{package} install log." + else + puts "\nUnable to cache copy of #{package} install log." + end - # TODO: collect package configure log. + # collect package build log. + if ( FileTest::exist?( buildLog ) ) + FileUtils.copy_file( buildLog, "#{cachedDir}/#{sw.srcDir}.build" ) + puts "\nCaching copy of #{package} build log." + else + puts "\nUnable to cache copy of #{package} build log." + end - # TODO: collect package integrity log. + # collect package configure log. + if ( FileTest::exist?( configureLog ) ) + FileUtils.copy_file( configureLog, "#{cachedDir}/#{sw.srcDir}.configure" ) + puts "\nCaching copy of #{package} configure log." + else + puts "\nUnable to cache copy of #{package} configure log." + end + + # collect package integrity log. + if ( FileTest::exist?( integrityLog ) ) + FileUtils.copy_file( integrityLog, "#{cachedDir}/#{sw.srcDir}.integrity" ) + puts "\nCaching copy of #{package} integrity log." + else + puts "\nUnable to cache copy of #{package} integrity log." + end - # TODO: collect package description (class file). + # collect package description (class file). + if ( FileTest::exist?( packageFile ) ) + FileUtils.copy_file( packageFile, "#{cachedDir}/#{package}.rb" ) + puts "\nCaching copy of #{package} package description." + else + puts "\nUnable to cache copy of #{package} package description, from location #{packageFile}" + end - # TODO: tar and bzip this directory (package-cache-version.tar.bz2) - - return false # for now, once imlemented, need true + # tar and bzip this directory (package-cache-version.tar.bz2) + Dir.chdir( $PACKAGE_CACHED ) + if ( system( "tar -cf #{sw.srcDir}.tar #{sw.srcDir}" ) && + system( "bzip2 -f #{sw.srcDir}.tar" ) ) + # last but not least, remove our tarball directory + FileUtils.rm_rf( cachedDir ) + return true + end end return false # package not installed, can't cache it. Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/AbtPackageManager.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -98,7 +98,8 @@ # first check if installed. system = AbtSystemManager.new if ( system.packageInstalled( package ) ) - puts "\nPackage #{package} is installed, might want to try reinstall?" + puts "\n*** Package #{package} is installed, might want to try reinstall? ***" + puts "'abt reinstall #{package}'" return true end Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/abt.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -54,28 +54,29 @@ logger.logToJournal( "Starting to install #{options['package']}" ) # return if already installed. - require options['package'] + require "packages/#{options['package']}" sw = eval( "#{options['package'].capitalize}.new" ) - if ( File.directory?( - "#{$PACKAGE_INSTALLED}/#{sw.details['Source location']}" ) ) - puts "\n\n" - puts "*** Package #{options['package']} already installed, " + - "try 'abt reinstall #{options['package']}' ***" - puts "\n\n" - exit - end - if ( manager.installPackage( options['package'] ) ) puts "\n\n" puts "*** Completed install of #{options['package']}. ***" puts "\n\n" logger.logToJournal( "Completed install of #{options['package']}." ) + + if ( logger.cachePackage( options['package'] ) ) + puts "\n\n" + puts "*** Completed caching of package #{options['package']}. ***" + puts "\n\n" + logger.logToJournal( "\nCaching completed for package #{options['package']}." ) + else + logger.logToJournal( "\nCaching of package #{options['package']} failed.") + end else puts "*** #{options['package'].capitalize} install failed, " + "see journal. ***" end + #reporter.showQueue( "install" ); # DEBUG. else show.usage( "packages" ) Modified: src/trunk/abtconfig.rb =================================================================== --- src/trunk/abtconfig.rb 2007-06-15 12:19:55 UTC (rev 340) +++ src/trunk/abtconfig.rb 2007-06-15 14:08:23 UTC (rev 341) @@ -47,7 +47,7 @@ $JOURNAL = "#{$ABT_LOGS}/journal.log" $PACKAGE_INSTALLED = "#{$ABT_STATE}/installed" $PACKAGE_CACHED = "#{$ABT_STATE}/cached" -$PACKAGE_PATH = "./packages/" +$PACKAGE_PATH = "#{$ABT_CACHES}/packages/" $SOURCES_REPOSITORY = "#{$ABT_CACHES}/sources" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 12:19:53
|
Revision: 340 http://svn.sourceforge.net/abtlinux/?rev=340&view=rev Author: eschabell Date: 2007-06-15 05:19:55 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Refactored log manager adding get method for log file locations, this intgrated into all existing methods. Modified Paths: -------------- src/trunk/AbtLogManager.rb Modified: src/trunk/AbtLogManager.rb =================================================================== --- src/trunk/AbtLogManager.rb 2007-06-15 12:05:31 UTC (rev 339) +++ src/trunk/AbtLogManager.rb 2007-06-15 12:19:55 UTC (rev 340) @@ -31,6 +31,44 @@ private + ## + # Returns the path to given packages install log. + # + # <b>PARAM</b> <i>String</i> - Package name. + # + # <b>RETURN</b> <i>String</i> - Full path to install log. + ## + def getLog( package, type ) + require "packages/#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + case type + + when 'install' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" + + when 'integrity' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.integrity" + + when 'tmpinstall' + log = "#{$ABT_TMP}/#{details['Source location']}.watch" + + when 'build' + log = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.build" + + else + log = "" + + end + + return log + end + + public ## @@ -62,15 +100,13 @@ # otherwise false. ## def logPackageIntegrity( package ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + #require "packages/#{package}" + #sw = eval( "#{package.capitalize}.new" ) + #details = sw.details # our log locations. - installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.install" - integrityLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.integrity" + installLog = getLog( package, 'install' ) + integrityLog = getLog( package, 'integrity' ) # get the installed files from the tmp file # into our install log. @@ -106,17 +142,12 @@ def logPackageInstall( package ) # some dirs we will not add to an install log. excluded_pattern = - Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) - - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details + Regexp.new( "^(/dev|/proc|/tmp|/var/tmp|/usr/src|/sys)+" ) badLine = false # used to mark excluded lines from installwatch log. # our log locations. - installLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.install" - tmpInstallLog = "#{$ABT_TMP}/#{details['Source location']}.watch" + installLog = getLog( package, 'install' ) + tmpInstallLog = getLog( package, 'tmpinstall' ) # get the installed files from the tmp file # into our install log. @@ -157,12 +188,7 @@ # otherwise false. ## def logPackageBuild( package ) - require "packages/#{package}" - sw = eval( "#{package.capitalize}.new" ) - details = sw.details - buildLog = "#{$PACKAGE_INSTALLED}/#{details['Source location']}" + - "/#{details['Source location']}.build" - #self.logToJournal( "DEBUG: buildFile is - #{buildFile}" ) + buildLog = getLog( package, 'build' ) # make sure the build file exists. if ( !File.exist?( buildLog ) ) @@ -182,13 +208,32 @@ # otherwise false. ## def cachePackage( package ) - # TODO: collect package source. - # TODO: collect package install log. - # TODO: collect package build log. - # TODO: collect package configure log. - # TODO: collect package integrity log. - # TODO: collect package description (class file). - # TODO: tar and bzip this directory (package-cache-version.tar.bz2) + system = AbtSystemManager.new + + if ( system.packageInstalled( package ) ) + require "packages/#{package}" + sw = eval( "#{package.capitalize}.new" ) + details = sw.details + + # TODO: collect package source. + FileTest::exists?("#{$PACKAGE_INSTALLED}/#{details['Source location']}" + + "/#{details['Source location']}.install" ) + # TODO: collect package install log. + + # TODO: collect package build log. + + # TODO: collect package configure log. + + # TODO: collect package integrity log. + + # TODO: collect package description (class file). + + # TODO: tar and bzip this directory (package-cache-version.tar.bz2) + + return false # for now, once imlemented, need true + end + + return false # package not installed, can't cache it. end ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 12:05:34
|
Revision: 339 http://svn.sourceforge.net/abtlinux/?rev=339&view=rev Author: eschabell Date: 2007-06-15 05:05:31 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Refactored test suite to run an install on our test package ipc, if this is done first it ensures the proper directories, logs, etc are in place for testing. Also removed -I./packages line from shebang, does not work at all. Modified Paths: -------------- src/trunk/abt.rb src/trunk/testSuiteAbt.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-06-15 11:14:36 UTC (rev 338) +++ src/trunk/abt.rb 2007-06-15 12:05:31 UTC (rev 339) @@ -1,4 +1,4 @@ -#!/usr/bin/ruby -wI./packages +#!/usr/bin/ruby -w ## # abt.rb Modified: src/trunk/testSuiteAbt.rb =================================================================== --- src/trunk/testSuiteAbt.rb 2007-06-15 11:14:36 UTC (rev 338) +++ src/trunk/testSuiteAbt.rb 2007-06-15 12:05:31 UTC (rev 339) @@ -1,4 +1,4 @@ -#!/usr/bin/ruby -wI./packages +#!/usr/bin/ruby -w if ( Process.uid != 0 ) puts "Enter root password:" @@ -9,11 +9,24 @@ require 'test/unit' require 'abtconfig' -require 'TestAbtLogManager' # test this first ensures all dirs created. +# 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. +# +logger = AbtLogManager.new +manager = AbtPackageManager.new +manager.installPackage( "ipc" ) + +require 'TestAbtPackageManager' +require 'TestAbtLogManager' require 'TestAbtDownloadManager' require 'TestAbtPackage' -require 'TestAbtPackageManager' require 'TestAbtQueueManager' require 'TestAbtReportManager' require 'TestAbtSystemManager' -require 'TestAbtDepEngine' +require 'TestAbtDepEngine' \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 11:14:34
|
Revision: 338 http://svn.sourceforge.net/abtlinux/?rev=338&view=rev Author: eschabell Date: 2007-06-15 04:14:36 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Refactored install package method to first check for already installed package, suggests reinstall to user if so. Modified Paths: -------------- src/trunk/AbtPackageManager.rb Modified: src/trunk/AbtPackageManager.rb =================================================================== --- src/trunk/AbtPackageManager.rb 2007-06-15 11:13:46 UTC (rev 337) +++ src/trunk/AbtPackageManager.rb 2007-06-15 11:14:36 UTC (rev 338) @@ -94,6 +94,14 @@ # false. ## def installPackage( package, verbose=true ) + + # first check if installed. + system = AbtSystemManager.new + if ( system.packageInstalled( package ) ) + puts "\nPackage #{package} is installed, might want to try reinstall?" + return true + end + require "packages/#{package}" sw = eval( "#{package.capitalize}.new" ) queuer = AbtQueueManager.new This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esc...@us...> - 2007-06-15 11:13:45
|
Revision: 337 http://svn.sourceforge.net/abtlinux/?rev=337&view=rev Author: eschabell Date: 2007-06-15 04:13:46 -0700 (Fri, 15 Jun 2007) Log Message: ----------- Refactored to use abtconfig, which holds all needed requires. Modified Paths: -------------- src/trunk/TestAbtPackageManager.rb Modified: src/trunk/TestAbtPackageManager.rb =================================================================== --- src/trunk/TestAbtPackageManager.rb 2007-06-15 10:32:13 UTC (rev 336) +++ src/trunk/TestAbtPackageManager.rb 2007-06-15 11:13:46 UTC (rev 337) @@ -2,7 +2,7 @@ require 'test/unit/testcase' require 'test/unit/autorunner' -require 'AbtPackageManager' +require 'abtconfig' ## # TestAbtPackageManager.rb This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |