extras-buildsys/utils extras-push, NONE, 1.1 extras-repobuild.py, NONE, 1.1 extras-sign-move.py, NONE, 1.1 extras-push.py, 1.1, NONE
Seth Vidal (skvidal)
fedora-extras-commits at redhat.com
Wed Aug 17 05:17:47 UTC 2005
Author: skvidal
Update of /cvs/fedora/extras-buildsys/utils
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv16549
Added Files:
extras-push extras-repobuild.py extras-sign-move.py
Removed Files:
extras-push.py
Log Message:
- remove old extras-push.py
- check in extras-push scripts - these are the current ones. They do not
interact with the db or plague-server directly at all.
--- NEW FILE extras-push ---
#!/bin/bash
if [ -z $1 ]; then
echo "Need a dist"
exit 1
fi
~/bin/extras-sign-move.py $1 && ~/bin/extras-repobuild.py $1
--- NEW FILE extras-repobuild.py ---
#!/usr/bin/python -t
# This program 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.
#
# This program 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
import sys
import rpmUtils
import shutil
import string
# get the path to where to look for the packages to be signed
# make repo
# make repoview
# email to fedora-extras-list with the built packages list
# sing, dance, romance
treedir = '/rpmbuild/extras/tree/extras'
cachedir = '/tmp/repomd-cache'
compsname = 'comps.xml'
archdict = {'3':['x86_64', 'i386'],
'development':['ppc','x86_64','i386'],
'4':['ppc','x86_64', 'i386']}
ts = rpmUtils.transaction.initReadOnlyTransaction()
DEBUG = False
def debugprint(msg):
if DEBUG:
print msg
def main(dist):
if not archdict.has_key(dist):
print "No Distribution named %s found" % dist
sys.exit(1)
destdir = os.path.join(treedir, dist)
print "Making Repository Metadata"
# SRPM repo creation
repodir = os.path.join(destdir, 'SRPMS')
rpdata = os.path.join(repodir, 'repodata')
debugprint('removing tree %s' % rpdata)
if not DEBUG:
if os.path.exists(rpdata): shutil.rmtree(rpdata)
cmd = '/usr/bin/createrepo -c %s -q %s' % (cachedir, repodir)
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
cmd = '/usr/bin/repoview %s' % repodir
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
# arch repo creation
for arch in archdict[dist]:
repodir = os.path.join(destdir, arch)
compspath = os.path.join(repodir, compsname)
rpdata = os.path.join(repodir, 'repodata')
debugprint('removing tree %s' % rpdata)
if not DEBUG:
if os.path.exists(rpdata): shutil.rmtree(rpdata)
if os.path.exists(compspath):
cmd = '/usr/bin/createrepo -c %s -q -g %s -x *debuginfo* %s' % (cachedir, compsname, repodir)
else:
cmd = '/usr/bin/createrepo -c %s -q -x *debuginfo* %s' % (cachedir, repodir)
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
cmd = '/usr/bin/repoview %s' % repodir
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
dbg_repodir = os.path.join(destdir, arch, 'debug')
dbg_rpdata = os.path.join(dbg_repodir, 'repodata')
debugprint('removing tree %s' % dbg_rpdata)
if not DEBUG:
if os.path.exists(dbg_rpdata): shutil.rmtree(dbg_rpdata)
cmd = '/usr/bin/createrepo -c %s -q %s' % (cachedir, dbg_repodir)
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
cmd = '/usr/bin/repoview %s' % dbg_repodir
debugprint(cmd)
if not DEBUG:
result = os.system(cmd)
if __name__ == '__main__':
me = os.getcwd()
if len(sys.argv) < 2:
print "Usage:\nextras-repobuild.py release\n\n"
sys.exit(1)
main(sys.argv[1])
os.chdir(me)
--- NEW FILE extras-sign-move.py ---
#!/usr/bin/python -t
# This program 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.
#
# This program 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
import sys
import rpmUtils
import smtplib
import shutil
import string
from email.MIMEText import MIMEText
# get the path to where to look for the packages to be signed
# get the list of stuff there (logs, md5sums, specs, rpms)
# list the rpms and pause
# sign the rpms
# collect list of srpms and get package n-v-r from them
# move pkgs into repo
# email to fedora-extras-list with the built packages list
stagesdir = '/rpmbuild/repodir'
treedir = '/rpmbuild/extras/tree/extras'
cachedir = '/tmp/repomd-cache'
compsname = 'comps.xml'
archdict = {'3':['x86_64', 'i386'],
'development':['ppc','x86_64','i386'],
'4':['ppc','x86_64', 'i386'],
'5':['ppc','x86_64', 'i386']}
ts = rpmUtils.transaction.initReadOnlyTransaction()
DEBUG = False
def debugprint(msg):
if DEBUG:
print msg
def find_files(path):
"""returns a dict of filetypes and paths to those files"""
filedict = {}
filedict['srpm'] = []
filedict['log'] = []
filedict['rpm'] = []
filedict['spec'] = []
filedict['md5sum'] = []
filedict['debuginfo'] = []
filedict['other'] = []
for root, dirs, files in os.walk(path):
for file in files:
# match the files to what list they should be in
if file.endswith('.log'):
which = 'log'
elif file.endswith('.rpm'):
if file.find('debuginfo') != -1:
which = 'debuginfo'
elif file.endswith('.src.rpm'):
which = 'srpm'
else:
which = 'rpm'
elif file.endswith('.spec'):
which = 'spec'
elif file.endswith('.md5sum'):
which = 'md5sum'
else:
which = 'other'
fullfile = os.path.join(root, file)
filedict[which].append(fullfile)
return filedict
def naevr(pkg):
"""return nevra from the package srpm"""
hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg)
name = hdr['name']
ver = hdr['version']
rel = hdr['release']
arch = hdr['arch']
epoch = hdr['epoch']
if epoch is None:
epoch = 0
return (name, arch, epoch, ver, rel)
def email_list(pkglist, dist):
"""email extras list with the new package listing"""
mail_from = 'buildsys at fedoraproject.org'
mail_to = 'fedora-extras-list at redhat.com'
uniqued = rpmUtils.miscutils.unique(pkglist)
uniqued.sort()
output = "\nPackages built and released for Fedora Extras %s: %s \n\n" % (dist, len(uniqued))
for pkg in uniqued:
add = '%s\n' % (pkg)
output = output + add
end = """
For more information about the built packages please see the repository
or the fedora Info Feed: http://fedoraproject.org/infofeed/
"""
output = output + end
msg = MIMEText(output)
subject = 'Fedora Extras %s Package Build Report' % dist
msg['Subject'] = subject
msg['From'] = mail_from
msg['To'] = mail_to
s = smtplib.SMTP()
s.connect()
s.sendmail(mail_from, [mail_to], msg.as_string())
s.close()
def sign_pkgs(filelist):
"""gpg sign all the rpms"""
numfiles = len(filelist)
if numfiles < 1:
print "No packages to sign"
return False
while numfiles > 0:
if numfiles > 256:
files = filelist[:256]
del filelist[:256]
else:
files = filelist
filelist = []
foo = string.join(files)
result = os.system('echo %s | xargs rpm --resign' % foo)
if result != 0:
return False
numfiles = len(filelist)
return True
def main(dist):
if not archdict.has_key(dist):
print "No Distribution named %s found" % dist
sys.exit(1)
needsign = os.path.join(stagesdir, dist)
files = find_files(needsign)
rpms = files['rpm'] + files['srpm'] + files['debuginfo']
rpms.sort()
for item in rpms:
print ' %s' % os.path.basename(item)
destdir = os.path.join(treedir, dist)
if not os.path.exists(destdir):
for arch in archdict[dist]:
if not DEBUG:
os.makedirs(destdir + '/' + arch + '/debug')
if not DEBUG:
os.makedirs(destdir + '/' + 'SRPMS')
rpms = files['rpm'] + files['srpm'] + files['debuginfo']
if len(rpms) == 0:
print 'nothing to sign'
sys.exit(1)
print "Signing Packages:"
if not DEBUG:
result = sign_pkgs(rpms)
if not result:
print "Error signing packages"
sys.exit(2)
infolist = []
for package in files['srpm']:
(n,a,e,v,r) = naevr(package)
infolist.append('%s-%s-%s' % (n,v,r))
pkg_fn = os.path.basename(package)
srpmloc = os.path.join(destdir, 'SRPMS', pkg_fn)
if os.path.exists(srpmloc):
debugprint('Deleting %s' % srpmloc)
if not DEBUG:
os.unlink(srpmloc)
debugprint('Moving %s to %s' % (package, srpmloc))
if not DEBUG:
shutil.move(package, srpmloc)
# go through each package and move it to the right arch location.
# if it is a noarch package, copy2 it to all arch locations and unlink it
# if it is a debuginfo package move it into the 'debug' dir for that arch
print "Moving Packages into Place"
for package in files['rpm'] + files['debuginfo']:
pkg_fn = os.path.basename(package)
(n,a,e,v,r) = naevr(package)
if a == 'noarch':
for arch in archdict[dist]:
if package in files['debuginfo']:
arch = '%s/debug' % arch
rpmloc = os.path.join(destdir, arch, pkg_fn)
debugprint("Copying %s to %s" % (package, rpmloc))
if not DEBUG:
shutil.copy(package, rpmloc)
if not DEBUG:
os.unlink(package)
continue
elif a in ['i386', 'i486', 'i586', 'i686', 'athlon']:
if package in files['debuginfo']:
arch = 'i386/debug'
else:
arch = 'i386'
elif a in ['x86_64', 'ia32e', 'amd64']:
if package in files['debuginfo']:
arch = 'x86_64/debug'
else:
arch = 'x86_64'
elif a in ['ppc', 'ppc64', 'ppc32']:
if package in files['debuginfo']:
arch = 'ppc/debug'
else:
arch = 'ppc'
else:
print 'Unknown arch %s' % a
continue
rpmloc = os.path.join(destdir, arch, pkg_fn)
debugprint('Moving %s to %s' % (package, rpmloc))
if not DEBUG:
shutil.move(package, rpmloc)
# email the list
if not DEBUG:
print "Emailing info"
email_list(infolist, dist)
# clean up the crap
print "Cleaning Up"
for file in files['log'] + files['md5sum'] + files['spec']:
debugprint('removing %s' % file)
if not DEBUG:
os.unlink(file)
# FIXME clean up empty dirs, too.
if __name__ == '__main__':
me = os.getcwd()
if len(sys.argv) < 2:
print "Usage:\nextras-sign-move.py release\n\n"
sys.exit(1)
main(sys.argv[1])
os.chdir(me)
--- extras-push.py DELETED ---
More information about the fedora-extras-commits
mailing list