iphitus Posted November 16, 2004 Report Share Posted November 16, 2004 #! /usr/bin/env python ## Yum Repository selection frontend ## by iphitus -- iphitus@gmail.com from sys import argv,exit from os import listdir,getuid,execvp,system,wait from optparse import OptionParser ## Change this if this file is not named program_name program_name = "yumrepo" def main(): arguments = argv[1:] ## Load list of repositories repolist = listdir("/etc/yum.repos.d") for f in repolist: if f[-5:] != ".repo": repolist.remove(f) ## Load and parse command line options parser = OptionParser() parser.add_option("-l", "--list-repos", action="store_true", dest="listrepos", help="List available repositories.") (options,args) = parser.parse_args() ## Check to see if root, if not, su then execute command again if getuid() != 0: getroot = raw_input("This program requires root access, run as root? (Y/n)") if getroot == "n" or getroot == "N": exit() else: astring = " " for a in arguments: astring = astring+" "+a suargs = ["root","--command="+program_name+astring] execvp("su",suargs) ## Check command line options if options.listrepos: print "Available repositories are:" for r in repolist: print " ",r[:-5] exit() ## Start offering repos yum="yum " for f in repolist: response = raw_input("Use repository: " + f[:-5] + "? (Y/n)") if response == "y" or response == "Y": yum = yum + "--enablerepo=" + f[:-5] + " " elif response == "n" or response == "N": yum = yum + "--disablerepo=" + f[:-5] + " " else: yum = yum + "--enablerepo=" + f[:-5] + " " ## Add other yum arguments for a in arguments: if a[0] != "-" and a != "": yum=yum+" " + a ## Run Yum system(yum) if __name__ == "__main__": main() here we go... arguments werent passed in the last one because i rewrote it to use execvp :P here's the fixed one using system again Quote Link to comment Share on other sites More sharing options...
jlc Posted November 16, 2004 Author Report Share Posted November 16, 2004 $ yumrepo install ifplugd This program requires root access, run as root? (Y/n) Password: Use repository: freshrpms? (Y/n)n Use repository: fedora-devel? (Y/n)n Use repository: livna-testing? (Y/n)n Use repository: atrpms-bleeding? (Y/n)n Use repository: newsrpms? (Y/n)n Use repository: fedora-us? (Y/n)n Use repository: fedora? (Y/n) Use repository: atrpms-testing? (Y/n)n Use repository: atrpms-stable? (Y/n)n Use repository: fedora-updates-testing? (Y/n)n Use repository: livna-stable? (Y/n)n Use repository: fedora-updates? (Y/n)n Use repository: dries? (Y/n)n Use repository: atrpms-good? (Y/n)n Use repository: dag? (Y/n)y Use repository: livna-unstable? (Y/n)n Error getting repository data for fedora-devel, repository not found Can't find a repo that I said no to :unsure: Here is another question for you, is it possible to have them all default to "N" except "fedora" and "fedora-updates" ? Quote Link to comment Share on other sites More sharing options...
iphitus Posted November 17, 2004 Report Share Posted November 17, 2004 I quite frankly am puzzled I made myself a script which spits out all the options passed to it to replace yum itself........ This is what it says.... ~ | yumrepo This program requires root access, run as root? (Y/n)y Password: Use repository: dag? (Y/n)n Use repository: dries? (Y/n)n Use repository: fedora-us? (Y/n)n Use repository: freshrpms? (Y/n)n Use repository: livna-stable? (Y/n)n Use repository: livna-testing? (Y/n)n Use repository: livna-unstable? (Y/n)n Use repository: newsrpms? (Y/n)n im yum, i do stuff ['/usr/bin/yum', '--disablerepo=dag', '--disablerepo=dries', '--disablerepo=fedora-us', '--disablerepo=freshrpms', '--disablerepo=livna-stable', '--disablerepo=livna-testing', '--disablerepo=livna-unstable', '--disablerepo=newsrpms'] done This is the script I am using for yumrepo #! /usr/bin/env python ## Yum Repository selection frontend ## by iphitus -- iphitus@gmail.com from sys import argv,exit from os import listdir,getuid,execvp,system,wait from optparse import OptionParser ## Change this if this file is not named program_name program_name = "yumrepo" def main(): arguments = argv[1:] ## Load list of repositories repolist = listdir("/etc/yum.repos.d") for f in repolist: if f[-5:] != ".repo": repolist.remove(f) ## Load and parse command line options parser = OptionParser() parser.add_option("-l", "--list-repos", action="store_true", dest="listrepos", help="List available repositories.") (options,args) = parser.parse_args() ## Check to see if root, if not, su then execute command again if getuid() != 0: getroot = raw_input("This program requires root access, run as root? (Y/n)") if getroot == "n" or getroot == "N": exit() else: astring = " " for a in arguments: astring = astring+" "+a suargs = ["root","--command="+program_name+astring] execvp("su",suargs) ## Check command line options if options.listrepos: print "Available repositories are:" for r in repolist: print " ",r[:-5] exit() ## Start offering repos yum="yum " for f in repolist: response = raw_input("Use repository: " + f[:-5] + "? (Y/n)") if response == "y" or response == "Y": yum = yum + "--enablerepo=" + f[:-5] + " " elif response == "n" or response == "N": yum = yum + "--disablerepo=" + f[:-5] + " " else: yum = yum + "--disablerepo=" + f[:-5] + " " ## Add other yum arguments for a in arguments: if a[0] != "-" and a != "": yum=yum+" " + a ## Run Yum system(yum) if __name__ == "__main__": main() Quote Link to comment Share on other sites More sharing options...
jlc Posted November 18, 2004 Author Report Share Posted November 18, 2004 If I get a chance, I'll see if i can figure it out :unsure: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.