Module babtools_gentoo
[hide private]
[frames] | no frames]

Source Code for Module babtools_gentoo

  1  #!/usr/bin/env python 
  2  # encoding: utf-8 
  3   
  4  #    babtools_gentoo - Simple tools for Gentoo users and ebuild dabblers.  
  5  #  
  6  #    Copyright © 2008 Arne Babenhauserheide 
  7  #  
  8  #    This program is free software: you can redistribute it and/or modify 
  9  #    it under the terms of the GNU General Public License as published by 
 10  #    the Free Software Foundation, either version 3 of the License, or 
 11  #    (at your option) any later version. 
 12  # 
 13  #    This program is distributed in the hope that it will be useful, 
 14  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 15  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 16  #    GNU General Public License for more details. 
 17  # 
 18  #    You should have received a copy of the GNU General Public License 
 19  #    along with this program.  If not, see <http://www.gnu.org/licenses/> 
 20   
 21  """babtools_gentoo: Some tools for working with Gentoo. 
 22    
 23   
 24  Usage:  
 25   - babtools_gentoo.py cmd [OPTIONS] 
 26      
 27     for default usage, or  
 28      
 29   - babtools_gentoo.py --help 
 30      
 31     for getting help 
 32    
 33   
 34  Avaible commands:  
 35   - ebuild_to_local CP 
 36      
 37     CP (cathegory/package) in the simple form dev-lang/python or similar. CPVs (cathegory/package-version) aren't supported, yet.  
 38       
 39   - ebuild_download_to_local CP URL 
 40     
 41     Download an ebuild from bugs.gentoo.org to the local portage tree.     
 42      
 43   - emerge_from_pypi PACKAGE 
 44     
 45     Create an ebuild from a project in PyPI, put it into package.keywords and install it.  
 46     Honors package.keywords directories.  
 47     It only puts the directly named PACKAGE into package.keywords as dev-python/PACKAGE 
 48     but doesn't put the dependencies into package.keywords.  
 49    
 50   
 51  Examples:  
 52   - sudo babtools_gentoo.py ebuild_to_local dev-lang/python 
 53      
 54     copy dev-lang/python into the local overlay 
 55      
 56   - sudo babtools_gentoo.py ebuild_download_to_local games-rpg/vegastrike http://bugs.gentoo.org/attachment.cgi?id=151789 
 57      
 58     Download the ebuild for games-rpg/vegastrike from bugs.gentoo.org and digest it.  
 59     
 60   - sudo babtools_gentoo.py emerge_from_pypi magma 
 61      
 62     Create an ebuild for "magma" from the PyPI and emerge it.  
 63   
 64   
 65  Source URL (Mercurial): U{http://freehg.org/u/ArneBab/babtools_gentoo/} 
 66   
 67  PyPI URL: U{http://pypi.python.org/pypi/babtools_gentoo} 
 68  """ 
 69   
 71      """Display help and a list of commands.""" 
 72      # Just print the second paragraph of the docstring (paragraphs seperated by really empty lines).  
 73      print __doc__.split("\n\n")[1] 
 74      # Print two empty lines.  
 75      print "" 
 76      print "" 
 77      list_commands() 
 78      # Print two empty lines.  
 79      print "" 
 80      print "" 
 81      print_examples() 
 82   
83 -def list_commands():
84 """List avaible commands.""" 85 # Just print the third paragraph of the docstring. 86 print __doc__.split("\n\n")[2]
87 92 93 #### Self-Test #### 94
95 -def _test():
96 from doctest import testmod 97 testmod() 98 99 if __name__ == "__main__": 100 101 from sys import argv 102 # If we get no args, print the help. 103 if len(argv) == 1: 104 print "We need a command as argument, for example 'ebuild_to_local'." 105 print_help() 106 # If we get the help argument, print help, too. 107 elif argv[1] == "help" or argv[1] == "--help" or argv[1] == "-h": 108 print_help() 109 110 # If we get no argument for ebuild_to_local, print an error. 111 elif argv[1] == "ebuild_to_local" and len(argv) == 2: 112 print "'ebuild_to_local' needs a valid package atom as argument (like dev-lang/python)." 113 114 # If we get a valid looking request for ebuild_to_local, 115 # copy the ebuild directory given by the package atom to the 116 # local portage tree. 117 elif argv[1] == "ebuild_to_local" and len(argv) == 3: 118 from portage_functions import copy_ebuild_to_local_overlay 119 copy_ebuild_to_local_overlay(argv[2]) 120 121 # if we get a download request with valid package atom, 122 # download it to the local portage tree. . 123 elif argv[1] == "ebuild_download_to_local": 124 if len(argv) < 4: 125 print_help() 126 else: 127 from portage_functions import download_ebuild_to_local_overlay 128 download_ebuild_to_local_overlay(CP=argv[2], URL=argv[3]) 129 130 # If we get the request to directly install a package from the PyPI, then get it. 131 132 elif argv[1] == "emerge_from_pypi": 133 if len(argv) < 3: 134 print_help() 135 else: 136 from portage_functions import emerge_from_pypi 137 emerge_from_pypi(PACKAGE=argv[2]) 138 else: 139 print "command not recognized:", argv[1] 140 print_help() 141 142 #_test() 143