def pkginit(): debver = versions.getverfromchangelog() upstreamver = versions.getupstreamver(debver) package = versions.getpackagefromchangelog() wcdir = os.path.abspath(getwcdir()) shouldbe = os.path.realpath(wcdir) + '/+packages/%s/%s-%s' % \ (package, package, upstreamver) if not os.path.realpath(os.getcwd()) == shouldbe: print "Current working directory %s" % os.getcwd() print "is not part of working copy build area %s" % shouldbe print "Exiting." sys.exit(50) if not os.path.basename(os.getcwd()) == '%s-%s' % (package, upstreamver): # I guess this test is redundant now.... print "Current working directory should be named" print "%s-%s but it is %s" % (package, upstreamver, os.path.basename(os.getcwd())) sys.exit(51) return (debver, upstreamver, package, wcdir)
def importdsc(dscname): """Imports the original source into both upstream and Debian locations. Side effect: chdir to wc""" dscname = os.path.abspath(dscname) wc = os.path.abspath(tbpconfig.getwcdir()) dscinfo = parsedsc(dscname) origtar = None for item in dscinfo['Files']: md5sum, size, filename = item.split(' ') if filename.endswith('tar.gz'): origtar = filename if origtar == None: print "Could not find orig.tar.gz in dsc file; aborting." sys.exit(20) origtar = os.path.join(os.path.dirname(dscname), origtar) importorigtargz(origtar, dscinfo['Source'][0], versions.getupstreamver(dscinfo['Version'][0])) # OK, upstream is in there. Now handle the Debian side of things. os.chdir(wc) archive = tla.getarchive() tlaupstreamrev = extcmd.run('tla cfgcat upstream/%s/%s' % \ (dscinfo['Source'][0], versions.getupstreamver(dscinfo['Version'][0]))) tlaupstreamrev = tlaupstreamrev[0].split("\t")[1].strip() tlaupstreamver = re.search('^(.+)--.+$', tlaupstreamrev).group(1) tladebianver = "%s/%s--debian--1.0" % (archive, dscinfo['Source'][0]) isnew = tla.condsetup(tladebianver) configs.makepkgconfigifneeded('debian', dscinfo['Source'][0]) if not configs.checkversion('debian', dscinfo['Source'][0], dscinfo['Version'][0]): print "Debian import: version %s is not newer than all versions in archive" % dscinfo['Version'][0] print "Will not import Debian because of this." return if isnew: extcmd.qrun('tla tag "%s" "%s"' % (tlaupstreamrev, tladebianver)) tmpdir = os.path.join(wc, ",,tbp-importdeb") os.mkdir(tmpdir) try: os.chdir(tmpdir) extcmd.qrun('dpkg-source -x "%s"' % dscname) for item in os.listdir(tmpdir): if not item.endswith('tar.gz'): debsrcdir = os.path.abspath(item) tmpwcdir = os.path.join(tmpdir, ",,tbp-importdeb-wc") extcmd.qrun('tla get "%s" "%s"' % (tladebianver, tmpwcdir)) os.chdir(tmpwcdir) if os.path.isfile('debian/changelog'): oldver = versions.getverfromchangelog() else: # First import -- just tagged, no Debian version. oldver = 'TPBIMPORTFAKE' if versions.getupstreamver(oldver) != \ versions.getupstreamver(dscinfo['Version'][0]): # OK, our current tree doesn't use the same upstream # version as the new one. So we need to fix. #extcmd.qrun('tla star-merge "%s"' % tlaupstreamrev) # FIXME: when we get tla 1.1, use tlaupstreamrev to be more # precise. try: extcmd.qrun('tla %s "%s"' % \ (cmd().replay, tlaupstreamver)) except RuntimeError: pass #extcmd.qrun('tla update --in-place . "%s"' % tlaupstreamrev) for file in extcmd.run('tla inventory -b'): # Delete orig, rej files file = file.rstrip() os.unlink(file) os.chdir(tmpdir) extcmd.qrun('tla_load_dirs --wc="%s" --summary="Import Debian %s version %s" "%s"' % \ (tmpwcdir, dscinfo['Source'][0], dscinfo['Version'][0], debsrcdir)) os.chdir(tmpwcdir) newrev_base = extcmd.run('tla revisions')[-1] newrev = "%s--%s" % (tladebianver, newrev_base) print "Committed %s" % newrev finally: os.chdir(wc) rmrf(tmpdir) os.chdir(wc) configs.writeconfig('debian', dscinfo['Source'][0], dscinfo['Version'][0], newrev) configs.writelatest('debian', dscinfo['Source'][0], dscinfo['Version'][0], tladebianver) extcmd.qrun('tla commit -L "Added configs for Debian %s %s"' % \ (dscinfo['Source'][0], dscinfo['Version'][0]))