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')
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"
p=subprocess.Popen('mv dist/* %s/EGGS/;rm -Rf dist'%(WORKSPACE,),shell=True,cwd="%s/x86_64/mdsplus/mdsobjects/python"%(WORKSPACE)) p.wait() else: print 'All packages are up to date' status="skip" if status=="ok": sys.path.insert(0,WORKSPACE+'/x86_64/mdsplus/tests') from distribution_tests import test_solaris as test test(WORKSPACE,FLAVOR) print "Build and testing completed successfully. Updating packages in public repositories." sys.stdout.flush() for pkg in getPackages(): for arch in ('x86_64','i686'): build_status=createPkg(WORKSPACE,FLAVOR,pkg,VERSION,updates[pkg]['Release'],arch,DIST,'~/mdsplus-repo-%s' % (arch)) if build_status != 0: print "Error building %s package for %s" % (arch,pkg) sys.exit(1) else: os.close(os.open('%s/%s/PKG/%s' % (WORKSPACE,arch,getPkgFile(arch,DIST,pkgflavor,pkg,VERSION,updates)),os.O_CREAT)) p=subprocess.Popen('devscripts/solarisServeRestart',shell=True,cwd="%s/x86_64/mdsplus"%(WORKSPACE)) p.wait() print "Tagging modules with new releases." sys.stdout.flush() for pkg in getPackages(): if updates[pkg]['Tag']: print "New release. Tag %s modules with %s %s %s %s" % (pkg,FLAVOR,VERSION,updates[pkg]['Release'],DIST) sys.stdout.flush() newRelease(pkg,FLAVOR,VERSION,updates[pkg]['Release'],DIST) if status=="error": sys.exit(1)
sys.stdout.flush() for pkg in getPackages(): for arch in ('x86_64', 'i686'): build_status = createPkg(WORKSPACE, FLAVOR, pkg, VERSION, updates[pkg]['Release'], arch, DIST, '~/mdsplus-repo-%s' % (arch)) if build_status != 0: print "Error building %s package for %s" % (arch, pkg) sys.exit(1) else: os.close( os.open( '%s/%s/PKG/%s' % (WORKSPACE, arch, getPkgFile(arch, DIST, pkgflavor, pkg, VERSION, updates)), os.O_CREAT)) p = subprocess.Popen('devscripts/solarisServeRestart', shell=True, cwd="%s/x86_64/mdsplus" % (WORKSPACE)) p.wait() print "Tagging modules with new releases." sys.stdout.flush() for pkg in getPackages(): if updates[pkg]['Tag']: print "New release. Tag %s modules with %s %s %s %s" % ( pkg, FLAVOR, VERSION, updates[pkg]['Release'], DIST) sys.stdout.flush() newRelease(pkg, FLAVOR, VERSION, updates[pkg]['Release'], DIST) if status == "error": sys.exit(1)
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')
sys.exit(stat) msiUpdateSetup(FLAVOR,WORKSPACE,VERSION,release,32,msi32,msiflavor) print "%s, Starting to build 32-bit setup kit" % (str(datetime.datetime.now()),) sys.stdout.flush() p=subprocess.Popen('pushd %s & devenv /build "Release|Setup32" mdsplus.sln' % (WORKSPACE,),shell=True) stat=p.wait() print "%s, 32-bit setup kit build completed with status=%d" % (str(datetime.datetime.now()),stat) if (stat != 0): print "Build failed!" sys.exit(stat) msiUpdateSetup(FLAVOR,WORKSPACE,VERSION,release,64,msi64,msiflavor) print "%s, Starting to build 64-bit setup kit" % (str(datetime.datetime.now()),) sys.stdout.flush() p=subprocess.Popen('pushd %s & devenv /build "Release|Setup64" mdsplus.sln' % (WORKSPACE,),shell=True) stat=p.wait() print "%s, 64-bit setup kit build completed with status=%d" % (str(datetime.datetime.now()),stat) if (stat != 0): print "Build failed!" sys.exit(stat) if need_to_tag: print "Tag all modules for this release. This can take a while!" newRelease('windows',FLAVOR,VERSION,release,'win') build_url=os.environ['BUILD_URL'] writeMsiInfo(msi32) writeMsiInfo(msi64) sys.stdout.flush() print "Done tagging modules. Now copying files to distribution location" sys.stdout.flush() p=subprocess.Popen('pscp -r -i c:\\Users\\twf\\id_dsa_nop.ppk %s/../%s %s' % (WORKSPACE,FLAVOR,DISTPATH),shell=True) sys.exit(p.wait())
print 'All DEBS are up to date' status="skip" if status=="ok": sys.path.insert(0,WORKSPACE+'/tests') from distribution_tests import test_debian as test test(WORKSPACE,FLAVOR) print "Build completed successfully. Checking for new releaseas and tagging the modules" sys.stdout.flush() prepareRepo("/mnt/dist/repo",False) p=subprocess.Popen( 'find DEBS -name "*.deb" -exec reprepro -V --waitforlock 20 -b /mnt/dist/repo -C %s includedeb MDSplus {} \;' % (FLAVOR,), shell=True,cwd=WORKSPACE) pstat=p.wait() p=subprocess.Popen('rsync -av DEBS EGGS /mnt/dist/%s/' % (FLAVOR,),shell=True,cwd=WORKSPACE) pstat=p.wait() if pstat != 0: print "Error copying files to destination" sys.exit(1) for d in ('EGGS','REPO','DEBS'): try: shutil.rmtree(WORKSPACE+'/'+d) except: pass for pkg in getPackages(): if updates[pkg]['Tag']: print "New release. Tag %s modules with %s %s %s %s" % (pkg,FLAVOR,VERSION,updates[pkg]['Release'],DIST) sys.stdout.flush() newRelease(pkg,FLAVOR,VERSION,updates[pkg]['Release'],getDist()) if status=="error": sys.exit(1)