Esempio n. 1
0
def makeSolarisPkgsCommand(args):
    """Make solaris distribution packages."""
    DIST = getDist()
    WORKSPACE = getWorkspace()
    FLAVOR = getFlavor()
    need_to_build = len(args) > 3
    for arch in ('x86_64', 'i686'):
        try:
            shutil.rmtree('%s/%s/BUILDROOT' % (WORKSPACE, arch))
        except:
            pass
    for d in [
            'x86_64/BUILDROOT', 'i686/BUILDROOT', 'EGGS', 'bin', 'x86_64/PKG',
            'i686/PKG'
    ]:
        try:
            os.mkdir("%s%s%s" % (WORKSPACE, os.sep, d))
        except:
            pass
    for app in ('tar', 'make', 'find'):
        try:
            os.symlink('/usr/bin/g%s' % (app, ),
                       '%s/bin/%s' % (WORKSPACE, app))
        except Exception, e:
            print "Error making app symlink: %s" % (e, )
            pass
Esempio n. 2
0
def makeMsiCommand(args):
    """Make Windows distribution kits."""
    WORKSPACE=getWorkspace()
    FLAVOR=getFlavor()
    print "WORKSPACE is %s" % (WORKSPACE,)
    VERSION=getVersion()
    DISTPATH=args[2]+'/Windows/'
    if FLAVOR=="stable":
        msiflavor=""
        pythonflavor=""
    else:
        msiflavor="-"+FLAVOR
        pythonflavor=FLAVOR+"-"
    release=getRelease("windows")
    need_to_build=False
    need_to_tag=False
    if len(checkRelease("windows")) > 0:
        need_to_build=True
        release=release+1
        need_to_tag=True
    try:
      os.mkdir("%s\\..\\%s" % (WORKSPACE,FLAVOR))
    except Exception,e:
      print "Did not create flavor directory, %s" % (e,)
      pass
Esempio n. 3
0
def makeMacosxPkgCommand(args):
    "Make distribution package for macosx."""
    WORKSPACE=getWorkspace()
    FLAVOR=getFlavor()
    VERSION=getVersion()
    if FLAVOR=="stable":
        pyflavor=""
        pkgflavor=""
    else:
        pyflavor=FLAVOR+"-"
        pkgflavor="-"+FLAVOR
    release=getRelease("macosx")
    need_to_build=False
    need_to_tag=False
    if len(checkRelease("macosx")) > 0:
        need_to_build=True
        release=release+1
        need_to_tag=True
    try:
      os.mkdir("%s/pkg" % WORKSPACE)
    except:
      pass
    pkgfile="%s/pkg/MDSplus%s-%s-%d-osx.pkg" % (WORKSPACE,pkgflavor,VERSION.replace('.','-'),release)
    if not need_to_build:
        print "Checking to see if package file, %s, exists" % (pkgfile,)
        try:
            print os.stat(pkgfile)
        except:
            print '%s is missing. Rebuilding.' % (pkgfile,)
            need_to_build=True
    if need_to_build:
       mdsplusdir="%s/mdsplus" % (WORKSPACE,)
       print "%s, Starting build" % (str(datetime.datetime.now()),)
       shell(mdsplusdir,
	     './configure --enable-mdsip_connections --prefix=%s/build/mdsplus --exec-prefix=%s/build/mdsplus --with-idl=/Applications/itt/idl/idl' % (WORKSPACE,WORKSPACE,),
             "configure failed")
       shell(mdsplusdir,'rm -f lib/*.a; make clean; make','make failed')
       shell(mdsplusdir,'sudo /usr/bin/mdsplus_sudo remove ../build','remove build failed')
       shell(mdsplusdir,'env MDSPLUS_VERSION="%s%s.%d" make install' % (pyflavor,VERSION,release),'make install failed')
       shell(mdsplusdir,'cd ../build/mdsplus/mdsobjects/python; python setup.py bdist_egg version=%s%s.%d' % (pyflavor,VERSION,release),'python bdist_egg failed')
       shell(mdsplusdir,'rsync -a ../build/mdsplus/mdsobjects/python/dist/*.egg %s/%s/EGGS/' % (args[2],FLAVOR),'Failed to copy eggs to destination')
       shell(mdsplusdir,'sudo /usr/bin/mdsplus_sudo chown ../build','chown failed')
       shell(mdsplusdir,'rm -f %s; /Developer/usr/bin/packagemaker --title "MDSplus%s" --version "%s.%d" --scripts %s/build/mdsplus/scripts --install-to "/usr/local" --target "10.5" -r %s/build -v -i "MDSplus%s" -o %s' % (pkgfile,pkgflavor,VERSION,release,WORKSPACE,WORKSPACE,pkgflavor,pkgfile),'Building package failed')
       shell(mdsplusdir,'sudo /usr/bin/mdsplus_sudo remove ../build','remove build failed')
       print "%s, Setup kit build completed" % (str(datetime.datetime.now()))
       if need_to_tag:
            print "Tag all modules for this release. This can take a while!"
            newRelease('macosx',FLAVOR,VERSION,release,'macosx')
       build_url=os.environ['BUILD_URL']
       writePkgInfo(pkgfile[0:-4])
    sys.stdout.flush()
    shell(WORKSPACE,'rsync -a pkg/* %s/%s' % (args[2],FLAVOR),'Failed to copy to destination')
Esempio n. 4
0
def makeDebsCommand(args):
    """Make all debian(Ubuntu) packages."""
    DIST=getLsbReleaseDist()
    WORKSPACE=getWorkspace()
    FLAVOR=getFlavor()
    DISTPATH='/mnt/dist/'+FLAVOR+'/'
    need_to_build=len(args) > 3
    for d in ['debian','DEBS','BUILDROOT','EGGS','REPO']:
        try:
            os.mkdir("%s%s%s" % (WORKSPACE,os.sep,d))
        except:
            pass
    prepareRepo("%s/REPO" % (WORKSPACE,),True)
    VERSION=getVersion()
    HW,BITS=getHardwarePlatform()
    arch={32:'i386',64:'amd64'}[BITS]
    if FLAVOR=="stable":
        debflavor=""
        pythonflavor=""
    else:
        debflavor="-"+FLAVOR
        pythonflavor=FLAVOR+"-"
    updates=dict()
    for pkg in getPackages():
        updates[pkg]=dict()
        updates[pkg]['Update']=False
        updates[pkg]['Tag']=False
        RELEASE_TAG=getReleaseTag(pkg)
        updates[pkg]['Release']=getRelease(pkg)
        if RELEASE_TAG is None:
            print "No releases yet for %s mdsplus-%s. Building." % (FLAVOR,pkg)
            updates[pkg]['Update']=True
            updates[pkg]['Tag']=True
        else:
            c=checkRelease(pkg)
            if len(c) > 0:
                updates[pkg]['Update']=True
		updates[pkg]['Tag']=True
                updates[pkg]['Release']=updates[pkg]['Release']+1
                print "New %s release for mdsplus-%s. Building.\n==========================" % (FLAVOR,pkg)
                for line in c:
                    print line
                print "================================="
            else:
                debfile=getDebfile('/mnt/dist/%s' % (FLAVOR,),arch,debflavor,pkg,VERSION,updates)
                try:
                    os.stat(debfile)
                except Exception,e:
                    print "%s missing. Rebuilding." % (debfile,)
                    updates[pkg]['Update']=True
        if updates[pkg]['Update']:
            need_to_build=True
Esempio n. 5
0
def signrpms(arch):
    try:
        import pexpect
        WORKSPACE=getWorkspace()
        cmd="/bin/sh -c 'rpmsign --addsign --define=\"_signature gpg\" --define=\"_gpg_name MDSplus\" *.rpm'"
    	child = pexpect.spawn(cmd,timeout=60,cwd=WORKSPACE+'/RPMS/'+arch)
#    	child.logfile=sys.stdout
    	child.expect("Enter pass phrase: ")
    	child.sendline("")
        child.expect(pexpect.EOF)
    	child.close()
    	return child.status
    except Exception,e:
        print "Error with signrpms - %s" % (e,)
        return 1
Esempio n. 6
0
def makeRepoRpms():
    WORKSPACE=getWorkspace()
    DIST=getDist()
    FLAVOR=getFlavor()
    if FLAVOR == "stable":
      rpmflavor=""
    else:
      rpmflavor="-"+FLAVOR
    sys.stdout.flush()
    p=subprocess.Popen('rpmbuild -ba' +\
                ' --buildroot=$(mktemp -t -d mdsplus-repo-build.XXXXXXXXXX)'+\
                ' --define="_topdir %s"' % (WORKSPACE,)+\
                ' --define="_builddir %s"' % (WORKSPACE,)+\
                ' --define="flavor %s"' % (FLAVOR,)+\
                ' --define="rpmflavor %s"' % (rpmflavor,)+\
                ' --define="s_dist %s"' % (DIST,)+\
                ' %s/x86_64/mdsplus/rpm/repos.spec >/dev/null' % (WORKSPACE,),shell=True,cwd=getTopDir())
    rpmbuild_status=p.wait()
    if rpmbuild_status != 0:
        print "Error building repository rpm for x86_64 %s %s. rpmbuild returned status=%d." % (DIST,FLAVOR,rpmbuild_status)
        status="error"
    else:
        sys.stdout.flush()
        p=subprocess.Popen('rpmbuild -ba'+\
                    ' --target=i686-linux'+\
                    ' --buildroot=$(mktemp -t -d mdsplus-repo-build.XXXXXXXXXX)'+\
                    ' --define="_topdir %s"' % (WORKSPACE,)+\
                    ' --define="_builddir %s"' % (WORKSPACE,)+\
                    ' --define="flavor %s"' % (FLAVOR,)+\
                    ' --define="rpmflavor %s"' % (rpmflavor,)+\
                    ' --define="s_dist %s"' % (DIST,)+\
                    ' %s/x86_64/mdsplus/rpm/repos.spec >/dev/null' % (WORKSPACE,),shell=True,cwd=getTopDir())
        rpmbuild_status=p.wait()
        if rpmbuild_status != 0:
            print "Error building repository rpm for i686 %s %s. rpmbuild returned status=%d." % (DIST,FLAVOR,rpmbuild_status)
            status="error"
        else:
            status="ok"
    return status
Esempio n. 7
0
def makeSolarisPkgsCommand(args):
    """Make solaris distribution packages."""
    DIST=getDist()
    WORKSPACE=getWorkspace()
    FLAVOR=getFlavor()
    need_to_build=len(args) > 3
    for arch in ('x86_64','i686'):
        try:
            shutil.rmtree('%s/%s/BUILDROOT' % (WORKSPACE,arch))
        except:
            pass
    for d in ['x86_64/BUILDROOT','i686/BUILDROOT','EGGS','bin','x86_64/PKG','i686/PKG']:
        try:
            os.mkdir("%s%s%s" % (WORKSPACE,os.sep,d))
        except:
            pass
    for app in ('tar','make','find'):
        try:
            os.symlink('/usr/bin/g%s' % (app,),'%s/bin/%s' % (WORKSPACE,app))
        except Exception,e:
            print "Error making app symlink: %s" % (e,)
            pass
Esempio n. 8
0
def makeRpmsCommand(args):
    """Make Redhat distributions rpms."""
    DIST=getDist()
    WORKSPACE=getWorkspace()
    FLAVOR=getFlavor()
    DISTPATH=args[2]+"/"+DIST+"/"+FLAVOR+"/"
    for d in ['RPMS','SOURCES','SPECS','SRPMS','EGGS']:
        try:
            os.mkdir("%s/%s" % (WORKSPACE,d))
        except:
            pass
    VERSION=getVersion()
    if FLAVOR=="stable":
        rpmflavor=""
        pythonflavor=""
    else:
        rpmflavor="-"+FLAVOR
        pythonflavor=FLAVOR+"-"
    release=getRelease("kernel")
    if len(checkRelease("kernel")) > 0:
        release=release+1
    specfile="%s/SPECS/mdsplus-%s-%s-%s.spec" % (WORKSPACE,FLAVOR,VERSION,DIST)
    beginRpmSpec(specfile,VERSION,release,rpmflavor,pythonflavor)
    need_to_build=False
    need_changelog=False
    updates=dict()
    for pkg in getPackages():
        updates[pkg]=dict()
        updates[pkg]['Update']=False
        updates[pkg]['Tag']=False
        RELEASE_TAG=getReleaseTag(pkg)
        updates[pkg]['Release']=getRelease(pkg)
        if RELEASE_TAG is None:
            print "No releases yet for %s mdsplus-%s. Building." % (FLAVOR,pkg)
            updates[pkg]['Update']=True
            updates[pkg]['Tag']=True
            need_changelog=True
        else:
            c=checkRelease(pkg)
            if len(c) > 0:
                updates[pkg]['Tag']=True
                updates[pkg]['Update']=True
                updates[pkg]['Release']=updates[pkg]['Release']+1
                print "New %s release for mdsplus-%s. Building.\n==========================" % (FLAVOR,pkg)
                for line in c:
                    print line
                print "================================="
                need_changelog=True
            else:
                for p in ('x86_64','i686'):
                  try:
                    rpm="/mnt/dist/%s/RPMS/%s/mdsplus%s-%s-%s-%s.%s.%s.rpm" % (FLAVOR,p,rpmflavor,pkg,VERSION,updates[pkg]['Release'],DIST,p)
		    os.stat(rpm)
                  except:
                    print "%s missing, rebuilding" % (rpm)
                    updates[pkg]['Update']=True
        if updates[pkg]['Update']:
            need_to_build=True
        addPkgToRpmSpec(specfile,pkg,updates[pkg]['Release'],DIST,rpmflavor)
    status="ok"
    if need_to_build:
        if 'UPDATE_CHANGELOG' in os.environ and need_changelog:
            print "Updating ChangeLog"
            sys.stdout.flush()
            p=subprocess.Popen('$(pwd)/devscripts/UpdateChangeLog %s' % (FLAVOR,),shell=True,cwd=getTopDir())
            p.wait()
        print "%s, Starting to build 32-bit rpms" % (str(datetime.datetime.now()),)
        sys.stdout.flush()
        p=subprocess.Popen('export MDSPLUS_PYTHON_VERSION="%s%s-%s";' % (pythonflavor,VERSION,updates['python']['Release']) +\
                    'scp alchome.psfc.mit.edu:/mnt/scratch/mdsplus/rpm-signing-keys.tgz ~/;tar xfC ~/rpm-signing-keys.tgz ~;' +\
                    'rm -Rf %s/RPMS/*;' % (WORKSPACE,) +\
                    'rpmbuild --target i686-linux' +\
                    ' --buildroot %s/BUILDROOT/i686 -ba' % (WORKSPACE,)+\
                    ' --define="_topdir %s"' % (WORKSPACE,)+\
                    ' --define="_builddir %s/i686/mdsplus"' % (WORKSPACE,)+\
                    ' %s' %(specfile,),shell=True,cwd=getTopDir())
        rpmbuild_status=p.wait()
        print "%s, Done building 32-bit rpms - status=%d" % (str(datetime.datetime.now()),rpmbuild_status)
        if rpmbuild_status != 0:
            print "Error build i686 %s.%s rpms. rpmbuild returned with status=%d" % (FLAVOR,DIST,rpmbuild_status)
            status="error"
        else:
            print "%s, Starting to sign 32-bit rpms" % (str(datetime.datetime.now()),)
            sstatus=signrpms('i686')
            print "%s, Done signing 32-bit rpms - status=%d" % (str(datetime.datetime.now()),sstatus)
            if sstatus != 0:
		print "Error signing package"
                sys.exit(1)
            for pkg in getPackages():
                if updates[pkg]['Update']:
                    writeRpmInfo("%s/RPMS/i686/mdsplus%s-%s-%s-%s.%s.i686" % (WORKSPACE,rpmflavor,pkg,VERSION,updates[pkg]['Release'],DIST))
            print "%s, Starting to build 64-bit rpms" % (str(datetime.datetime.now()),)
            sys.stdout.flush()
            p=subprocess.Popen('rpmbuild --target x86_64-linux'+\
                        ' --buildroot %s/BUILDROOT/x86_64 -ba' % (WORKSPACE,)+\
                        ' --define="_topdir %s"' % (WORKSPACE,)+
                    ' --define="_builddir %s/x86_64/mdsplus"' % (WORKSPACE,)+
                    ' %s' %(specfile,),shell=True,cwd=getTopDir())
            rpmbuild_status=p.wait()
            print "%s, Done building 64-bit rpms - status=%d" % (str(datetime.datetime.now()),rpmbuild_status)
            if rpmbuild_status != 0:
                status="error"
            else:
                print "%s, Starting to sign 64-bit rpms" % (str(datetime.datetime.now()),)
                sstatus=signrpms('x86_64')
                if sstatus != 0:
                  print "Error signing rpm"
                  sys.exit(sstatus)
                print "%s, Done signing 64-bit rpms - status=%d" % (str(datetime.datetime.now()),sstatus)
                for pkg in getPackages():
                    if updates[pkg]['Update']:
                        writeRpmInfo("%s/RPMS/x86_64/mdsplus%s-%s-%s-%s.%s.x86_64" % (WORKSPACE,rpmflavor,pkg,VERSION,updates[pkg]['Release'],DIST))
    else:
        print 'All RPMS are up to date'
        status="skip"
    if status=="ok":
        print "Updating repository rpms"
        status=makeRepoRpms()
    if status=="ok":
        try:
            sys.stdout.flush()
            p=subprocess.Popen('createrepo . >/dev/null',shell=True,cwd=WORKSPACE+"/RPMS")
            stat=p.wait()
	    if stat != 0:
              raise Exception("Repository creation return status=%d" % (stat,))
        except Exception,e:
            print "Error creating repo: %s" (e,)
            sys.exit(p.wait())
        sys.path.insert(0,WORKSPACE+'/x86_64/mdsplus/tests')
        from distribution_tests import test_rpms as test
        test(WORKSPACE,FLAVOR)
        sys.stdout.flush()
        try:
	  os.stat("%s/source" % (WORKSPACE,))
          dotar=True
        except:
          dotar=False
        if dotar:
          p=subprocess.Popen('tar zcf ../SOURCES/mdsplus%s-%s.tar.gz --exclude CVS mdsplus' % (rpmflavor,VERSION),shell=True,cwd="%s/source" % (WORKSPACE,))
          pstat=p.wait()
          if pstat != 0:
            print "Error creating source tarball"
            sys.exit(1)

        p=subprocess.Popen('rsync -av RPMS %s;rsync -av SOURCES %s;rsync -av ./i686/mdsplus/mdsobjects/python/dist/*.egg %s/EGGS/' % (DISTPATH,DISTPATH,DISTPATH),shell=True,cwd=WORKSPACE)
        pstat=p.wait()
        if pstat != 0:
            print "Error copying files to final destination. Does the directory %s exist and is it writable by the account used by this hudson node?" % (DISTPATH,)
            sys.exit(pstat)
        else:
            sys.stdout.flush()
            p=subprocess.Popen('rm -Rf SOURCES EGGS',shell=True,cwd=WORKSPACE)
            pstat=p.wait()
        print "Build completed successfully. Checking for new releaseas and tagging the modules"
        for pkg in getPackages():
            print "Checking %s for new release" % (pkg,)
            if updates[pkg]['Tag']:
                print "      New release. Tag modules with %s %s %s %s" % (FLAVOR,VERSION,updates[pkg]['Release'],DIST)
                newRelease(pkg,FLAVOR,VERSION,updates[pkg]['Release'],DIST)
            else:
                print "      No changes, skipping"
Esempio n. 9
0
def makeMacosxPkgCommand(args):
    "Make distribution package for macosx." ""
    WORKSPACE = getWorkspace()
    FLAVOR = getFlavor()
    VERSION = getVersion()
    if FLAVOR == "stable":
        pyflavor = ""
        pkgflavor = ""
    else:
        pyflavor = FLAVOR + "-"
        pkgflavor = "-" + FLAVOR
    release = getRelease("macosx")
    need_to_build = False
    need_to_tag = False
    if len(checkRelease("macosx")) > 0:
        need_to_build = True
        release = release + 1
        need_to_tag = True
    try:
        os.mkdir("%s/pkg" % WORKSPACE)
    except:
        pass
    pkgfile = "%s/pkg/MDSplus%s-%s-%d-osx.pkg" % (
        WORKSPACE, pkgflavor, VERSION.replace('.', '-'), release)
    if not need_to_build:
        print "Checking to see if package file, %s, exists" % (pkgfile, )
        try:
            print os.stat(pkgfile)
        except:
            print '%s is missing. Rebuilding.' % (pkgfile, )
            need_to_build = True
    if need_to_build:
        mdsplusdir = "%s/mdsplus" % (WORKSPACE, )
        print "%s, Starting build" % (str(datetime.datetime.now()), )
        shell(
            mdsplusdir,
            './configure --enable-mdsip_connections --prefix=%s/build/mdsplus --exec-prefix=%s/build/mdsplus --with-idl=$IDL_DIR --with-jdk=$JDK_DIR --with-labview=$LABVIEW_DIR'
            % (
                WORKSPACE,
                WORKSPACE,
            ), "configure failed")
        shell(mdsplusdir, 'rm -f lib/*.a; make clean; make', 'make failed')
        shell(mdsplusdir, 'sudo rm -Rf ../build', 'remove build failed')
        shell(
            mdsplusdir, 'env MDSPLUS_VERSION="%s%s.%d" make install' %
            (pyflavor, VERSION, release), 'make install failed')
        shell(
            mdsplusdir,
            'cd ../build/mdsplus/mdsobjects/python; python setup.py bdist_egg version=%s%s.%d'
            % (pyflavor, VERSION, release), 'python bdist_egg failed')
        shell(
            mdsplusdir,
            'rsync -a ../build/mdsplus/mdsobjects/python/dist/*.egg %s/%s/EGGS/'
            % (args[2], FLAVOR), 'Failed to copy eggs to destination')
        shell(mdsplusdir, 'sudo chown -R root:admin ../build', 'chown failed')
        shell(
            mdsplusdir,
            'rm -f %s; /Developer/usr/bin/packagemaker --title "MDSplus%s" --version "%s.%d" --scripts %s/build/mdsplus/scripts --install-to "/usr/local" --target "10.5" -r %s/build -v -i "MDSplus%s" -o %s'
            % (pkgfile, pkgflavor, VERSION, release, WORKSPACE, WORKSPACE,
               pkgflavor, pkgfile), 'Building package failed')
        shell(mdsplusdir, 'sudo rm -Rf ../build', 'remove build failed')
        print "%s, Setup kit build completed" % (str(datetime.datetime.now()))
        if need_to_tag:
            print "Tag all modules for this release. This can take a while!"
            newRelease('macosx', FLAVOR, VERSION, release, 'macosx')
        build_url = os.environ['BUILD_URL']
        writePkgInfo(pkgfile[0:-4])
    sys.stdout.flush()
    shell(WORKSPACE, 'rsync -a pkg/* %s/%s' % (args[2], FLAVOR),
          'Failed to copy to destination')