forked from ungleich-public/cdist
		
	no longer need check-apt-repository
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								2bab4ed93b
							
						
					
				
			
			
				commit
				
					
						f46b2a9a5a
					
				
			
		
					 2 changed files with 1 additions and 47 deletions
				
			
		| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
#!/usr/bin/env python
 | 
			
		||||
#
 | 
			
		||||
# Check if the given apt repository is installed or not.
 | 
			
		||||
# Exit with:
 | 
			
		||||
#   0: if it is installed
 | 
			
		||||
#   1: if not
 | 
			
		||||
#   2: on error
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
import sys
 | 
			
		||||
from aptsources import distro, sourceslist
 | 
			
		||||
from softwareproperties import ppa
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def is_repository_installed(repository):
 | 
			
		||||
    #print 'repository:', repository
 | 
			
		||||
    codename = distro.get_distro().codename
 | 
			
		||||
    #print 'codename:', codename
 | 
			
		||||
    (line, file) = ppa.expand_ppa_line(repository.strip(), codename)
 | 
			
		||||
    #print 'line:', line
 | 
			
		||||
    #print 'file:', file
 | 
			
		||||
    sources_list = sourceslist.SourcesList()
 | 
			
		||||
    source_entry = sourceslist.SourceEntry(line, file)
 | 
			
		||||
 | 
			
		||||
    if source_entry in sources_list:
 | 
			
		||||
        #print 'yes'
 | 
			
		||||
        return True
 | 
			
		||||
    else:
 | 
			
		||||
        #print 'no'
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    if (len(sys.argv) != 2):
 | 
			
		||||
        print 'Error: need a repository as argument'
 | 
			
		||||
        sys.exit(2)
 | 
			
		||||
    #repository = 'ppa:freenx-team'
 | 
			
		||||
    repository = sys.argv[1]
 | 
			
		||||
    if is_repository_installed(repository):
 | 
			
		||||
        sys.exit(0)
 | 
			
		||||
    else:
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,14 +18,10 @@
 | 
			
		|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
name="$__object_id"
 | 
			
		||||
 | 
			
		||||
__package python-software-properties --state installed
 | 
			
		||||
 | 
			
		||||
require="__package/python-software-properties" \
 | 
			
		||||
   __file /usr/local/bin/check-apt-repository \
 | 
			
		||||
   --source "$__type/files/check-apt-repository" \
 | 
			
		||||
   --mode 0755
 | 
			
		||||
 | 
			
		||||
require="__package/python-software-properties" \
 | 
			
		||||
   __file /usr/local/bin/remove-apt-repository \
 | 
			
		||||
   --source "$__type/files/remove-apt-repository" \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue