Yum as4 autoinstall

#!/usr/bin/env python
import os,urllib,shutil

os.system( 'rpm -qa|grep -i "yum"|xargs rpm -e --nodeps')
os.system( 'rpm -qa|grep -i "centos"|xargs rpm -e --nodeps')
i = 'yum_forAS4.tar.gz'

if not os.path.isfile(i):
                web = 'http://www.haoxm.net/tools/' + i
                print '"%s" Downloading........'%i
                urlfile = urllib.urlopen(web)
                local = open(i, 'wb').write(urlfile.read())
                urlfile.close
                os.system( 'tar -zxf %s' %i)


os.system( 'cd yum_forAS4 && rpm -ivh *.rpm')
key = 'rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4'
base = '/etc/yum.repos.d/'

if not os.path.isdir(base):
        os.mkdir(base)
yum = base + 'CentOS-Base.repo'
if not os.path.isfile(base):
     shutil.copyfile( 'yum_forAS4/CentOS-Base.repo',yum)
     os.system(key)
     os.system( 'yum update')

你可能感兴趣的:(职场,yum,休闲,as4)