def doExport(projectName, rootPath, prompt, theBranchManager=theBranchManager, sh=sh): """ Export the repo from SVN into a clean directory. @type projectName: C{str} @param projectName: The Combinator name of the project to export. @type rootPath: L{FilePath} @param rootPath: The working copy of the SVN path to export. @type prompt: C{bool} @param prompt: If true, ask the user before executing any shell commands. @rtype: C{tuple} of L{FilePath} and C{str} @return: The path to which the export was done and the URI which was exported. """ branchRelativePath = theBranchManager.currentBranchFor(projectName) branchURI = theBranchManager.projectBranchURI( projectName, branchRelativePath) exportPath = FilePath('.release').temporarySibling() cmd = 'svn export -rHEAD %(rootPath)s %(exportPath)s' sh(cmd % {'rootPath': rootPath.path, 'exportPath': exportPath.path}, null=False, prompt=prompt) return exportPath, branchURI
def doExport(projectName, rootPath, prompt, theBranchManager=theBranchManager, sh=sh): """ Export the repo from SVN into a clean directory. @type projectName: C{str} @param projectName: The Combinator name of the project to export. @type rootPath: L{FilePath} @param rootPath: The working copy of the SVN path to export. @type prompt: C{bool} @param prompt: If true, ask the user before executing any shell commands. @rtype: C{tuple} of L{FilePath} and C{str} @return: The path to which the export was done and the URI which was exported. """ branchRelativePath = theBranchManager.currentBranchFor(projectName) branchURI = theBranchManager.projectBranchURI(projectName, branchRelativePath) exportPath = FilePath('.release').temporarySibling() cmd = 'svn export -rHEAD %(rootPath)s %(exportPath)s' sh(cmd % { 'rootPath': rootPath.path, 'exportPath': exportPath.path }, null=False, prompt=prompt) return exportPath, branchURI
def testSourceInstall(): cmd = 'PYTHONPATH=%(installPath)s:$PYTHONPATH trial %(projectName)s' sh(cmd % { 'installPath': siteInstallPath.path, 'projectName': proj.initPath.parent().basename() }, null=False, prompt=prompt)
def unpackSourceRelease(): projectExport = exportPath.child(proj.name) chdir(projectExport.child('dist').path) cmd = 'tar xzf %(projectName)s-%(projectVersion)s.tar.gz' sh(cmd % {'projectName': proj.name, 'projectVersion': proj.version.short()}, null=False, prompt=prompt)
def installSourceRelease(): projectExport = exportPath.child(proj.name) projectDir = '%s-%s' % (proj.name, proj.version.short()) unpackPath = projectExport.child('dist').child(projectDir) chdir(unpackPath.path) cmd = '%(python)s setup.py install --prefix %(installPath)s' sh(cmd % {'python': sys.executable, 'installPath': installPath.path}, null=False, prompt=prompt)
def unpackSourceRelease(): projectExport = exportPath.child(proj.name) chdir(projectExport.child('dist').path) cmd = 'tar xzf %(projectName)s-%(projectVersion)s.tar.gz' sh(cmd % { 'projectName': proj.name, 'projectVersion': proj.version.short() }, null=False, prompt=prompt)
def tagRelease(): source = '%(branchURI)s/%(projectName)s' dest = '%(tagRootURI)s/%(projectName)s-%(projectVersion)s' cmd = 'svn cp %s %s -m "Tagging release"' % (source, dest) sh(cmd % {'branchURI': branchURI, 'projectName': proj.name, 'tagRootURI': tagRootURI, 'projectVersion': proj.version.short()}, null=False, prompt=prompt)
def tagRelease(): source = '%(branchURI)s/%(projectName)s' dest = '%(tagRootURI)s/%(projectName)s-%(projectVersion)s' cmd = 'svn cp %s %s -m "Tagging release"' % (source, dest) sh(cmd % { 'branchURI': branchURI, 'projectName': proj.name, 'tagRootURI': tagRootURI, 'projectVersion': proj.version.short() }, null=False, prompt=prompt)
def installSourceRelease(): projectExport = exportPath.child(proj.name) projectDir = '%s-%s' % (proj.name, proj.version.short()) unpackPath = projectExport.child('dist').child(projectDir) chdir(unpackPath.path) cmd = '%(python)s setup.py install --prefix %(installPath)s' sh(cmd % { 'python': sys.executable, 'installPath': installPath.path }, null=False, prompt=prompt)
def doCommit(rootPath, prompt, msg, sh=sh): """ Commit version files and probably NEWS.txt files to version control. @type rootPath: L{FilePath} @param rootPath: The root path to commit to version control. @type prompt: C{bool} @param prompt: If true, ask the user before executing any shell commands. @type msg: C{str} @param msg: Version control commit message. """ cmd = 'svn commit %(rootPath)s -m "%(msg)s"' sh(cmd % {'rootPath': rootPath.path, 'msg': msg}, null=False, prompt=prompt)
def produce_devel_doc(basepath, guidepath): TPL_PATH = os.path.join(basepath, 'doc', 'devel', 'template.tpl') DOC_DIR = os.path.join(basepath, 'doc', 'devel') IMAGES_DIR = os.path.join(basepath, 'doc', 'user', 'images') sh("lore --config template=%(tpl_path)s " "--config baseurl=api/%%s.html " "%(doc_dir)s/*.xhtml" % dict(doc_dir=DOC_DIR, tpl_path=TPL_PATH)) sh("mkdir -p %s" % guidepath) sh("cp %s/*.html doc/devel/*.css %s" % (DOC_DIR, guidepath)) sh("cp -R %s %s/images" % (IMAGES_DIR, guidepath))
def produce_devel_doc(basepath, guidepath): TPL_PATH = os.path.join(basepath, 'doc', 'devel', 'template.tpl') DOC_DIR = os.path.join(basepath, 'doc', 'devel') IMAGES_DIR = os.path.join(basepath, 'doc', 'user', 'images') sh("lore --config template=%(tpl_path)s " "--config baseurl=api/%%s.html " "%(doc_dir)s/*.xhtml" % dict(doc_dir=DOC_DIR, tpl_path=TPL_PATH) ) sh("mkdir -p %s" % guidepath) sh("cp %s/*.html doc/devel/*.css %s" % (DOC_DIR, guidepath)) sh("cp -R %s %s/images" % (IMAGES_DIR, guidepath))
def doCommit(rootPath, prompt, msg, sh=sh): """ Commit version files and probably NEWS.txt files to version control. @type rootPath: L{FilePath} @param rootPath: The root path to commit to version control. @type prompt: C{bool} @param prompt: If true, ask the user before executing any shell commands. @type msg: C{str} @param msg: Version control commit message. """ cmd = 'svn commit %(rootPath)s -m "%(msg)s"' sh(cmd % { 'rootPath': rootPath.path, 'msg': msg }, null=False, prompt=prompt)
def produce_tree(): name = get_vmc_name() version = get_vmc_version() target = os.getenv("TARGET") if target == None: target = "generic" release = os.getenv("RELEASE") if release == None: release = "1" tmp = "./tmp" nvr_triplet = "%s-%s-%s" % (name, version, release) root = "%s/%s-%s" % (tmp, name, version) import re def list_core_files(path, pattern): result = [] def walk_callback(arg, directory, files): if '.svn' in files: files.remove('.svn') for file in files: if os.path.isdir(os.path.join(directory, file)): continue m = re.search(pattern, file) if m: result.append(os.path.join(directory, file)) os.path.walk(path, walk_callback, None) return result def list_data_files(path): result = [] def walk_callback(arg, directory, files): if '.svn' in files: files.remove('.svn') result.extend( os.path.join(directory, file) for file in files if not os.path.isdir(os.path.join(directory, file))) os.path.walk(path, walk_callback, None) return result core_files = [ (get_vmc_data_dir(), list_core_files('vmc', '.+\.py\Z')), ] data_files = [ # Plugins (os.path.join(get_vmc_data_dir(), 'plugins', 'os'), list_data_files('plugins/os')), (os.path.join(get_vmc_data_dir(), 'plugins', 'devices'), list_data_files('plugins/devices')), (os.path.join(get_vmc_data_dir(), 'plugins', 'notifications'), list_data_files('plugins/notifications')), # Resources (os.path.join(get_vmc_resources_dir(), 'extra'), list_data_files('resources/extra')), (os.path.join(get_vmc_resources_dir(), 'glade'), list_data_files('resources/glade')), (os.path.join(get_vmc_resources_dir(), 'templates'), list_data_files('resources/templates')), # Data (get_vmc_data_dir(), ['gtk-tap.py']), # Icon ('/usr/share/applications', ['resources/desktop/vmc.desktop']), ('/usr/share/pixmaps', ['resources/desktop/vodafone.png']), # Doc (get_vmc_doc_dir(), ['debian/copyright', 'README', 'README-fr'] + glob('LICENSE*')), # Bin (get_vmc_bin_dir(), glob('bin/*')), ] # echo "%_unpackaged_files_terminate_build 0" >> /etc/rpm/macros # Install core and data files for dst, src in core_files: sh("mkdir -p %s%s" % (root, dst)) for file in src: (directory, a, b) = file.rpartition('/') dstdir = "%s%s/%s" % (root, dst, directory) if not os.path.exists(dstdir): sh("mkdir -p %s" % dstdir) sh("cp -p %s %s/." % (file, dstdir)) for dst, src in data_files: sh("mkdir -p %s%s" % (root, dst)) for file in src: dstdir = "%s%s" % (root, dst) sh("cp -p %s %s/." % (file, dstdir)) # Splashscreen - apply version img_to_patch_path = "%s%s" % ( root, os.path.join(get_vmc_resources_dir(), 'glade', 'splash.png')) paint_file(img_to_patch_path, '%s' % version) # Remove developer overrides sh('rm -f %s/vmc/common/consts-dev.py' % root) # Generate user doc # Mandriva Free 2010 rpm package building fails to generate documentation so this two lines need to be commented. sh('tar -cf - doc/user | (cd %s && tar -xf -)' % tmp) sh('(cd %s/doc/user && make -f Makefile.pkg ROOT=../../%s-%s/%s/guide)' % (tmp, name, version, get_vmc_doc_dir())) # Apply platform specific overrides sh('(cd resources/platform/%s && tar -cf - . --exclude=./debian) | (cd %s && tar -xf -)' % (target, root)) # I18N sh('(cd resources && tar -cf - po glade) | (cd %s && tar -xf -)' % tmp) sh('(cd %s/po && make install ROOT=../%s-%s/ VERSION=%s)' % (tmp, name, version, version)) # Remove any svn info in copy sh('find %s -name ".svn" | xargs rm -rf' % root) # if we have an RPM spec file we must be building a bundle for an RPM based distro try: specfile = '%s/vmc.spec' % root os.stat(specfile) sh("sed -i %s -e 's,Name:.*$,Name: %s,'" % (specfile, name)) sh("sed -i %s -e 's,Version:.*$,Version: %s,'" % (specfile, version)) sh("sed -i %s -e 's,Release:.*$,Release: %s,'" % (specfile, release)) sh("sed -i %s -e 's,Source0:.*$,Source0: %s.tar.bz2,'" % (specfile, nvr_triplet)) # remove any precompiled objects - rpm's smart enough to build them sh('find %s -name "*.pyc" | xargs rm -rf' % root) sh('find %s -name "*.pyo" | xargs rm -rf' % root) sh('(cd %s && tar -jcvf %s.tar.bz2 %s-%s)' % (tmp, nvr_triplet, name, version)) except: pass # if we have a platform/debian directory we must be building for a DEB based distro if os.path.exists('resources/platform/%s/debian' % target): # copy it sh('(cd resources/platform/%s && tar -cf - debian) | (cd %s && tar -xf -)' % (target, tmp)) changelog = '%s/debian/changelog' % tmp sh("sed -i %s -e 's,name,%s,' -e 's,version,%s,' -e 's,release,%s,'" % (changelog, name, version, release)) control = '%s/debian/control' % tmp sh("sed -i %s -e 's,Source.*$,Source: %s,' -e 's,Package.*$,Package: %s,'" % (control, name, name)) # compile all of the python objects import compileall compileall.compile_dir('%s/' % root, ddir='/', force=True) # so make can find out the root directory f = open('%s/builddir' % tmp, 'w') f.write('%s-%s' % (name, version)) f.close()
def makeSourceRelease(): chdir(exportPath.child(proj.name).path) cmd = '%(python)s setup.py sdist' sh(cmd % {'python': sys.executable}, null=False, prompt=prompt)
def produce_source(arch): tmp_dir = get_temp_dir() version = get_vmc_version() pkg_name = "vodafone-mobile-connect-card-driver-for-linux-%s" % version final_path = os.path.join(tmp_dir, pkg_name) sh("cp -RL %s %s" % (os.getcwd(), final_path)) sh("cp -R %s/po %s/resources/" % (os.getcwd(), final_path)) sh("cp -R %s/desktop %s/resources/" % (os.getcwd(), final_path)) sh("cp %s/consts_prefix.py %s/vmc/common/" % (os.getcwd(), final_path)) sh('find %s -name ".svn" | xargs rm -rf' % final_path) sh('find %s -name ".pyc" | xargs rm -rf' % final_path) sh('find %s -name "~" | xargs rm -rf' % final_path) img_to_patch_path = os.path.join(final_path, 'resources', 'glade', 'splash.png') paint_file(img_to_patch_path, '%s' % version) sh('rm -rf %s/po %s/desktop %s/consts_prefix.py' % (final_path, final_path, final_path)) sh('rm -rf %s/resources/extra/*ttf' % final_path) sh('rm -rf %s/resources/extra/*xcf' % final_path) sh('rm -rf %s/rpm' % final_path) sh('rm -rf %s/vmc/common/consts-dev.py' % final_path) guide_path = os.path.join(final_path, 'doc', 'guide', 'devel') # generate devel doc produce_devel_doc(final_path, guide_path) produce_api_doc(guide_path) # generate user doc sh('make -C %s/doc/install html' % final_path) sh('make -C %s/doc/user html' % final_path) # targz it final_name = os.path.basename(final_path) sh('cd %s; tar czvf %s.tar.gz %s; cd -' % (tmp_dir, final_name, final_name)) sh('cd %s; dpkg-buildpackage -rfakeroot -a%s; cd -' % (final_path, arch)) print "The generated files are in %s" % tmp_dir return tmp_dir
if __name__ == '__main__': try: distro = sys.argv[1] except IndexError: distro = 'ubuntu' try: arch = sys.argv[2] except IndexError: arch = 'i386' distros = ['ubuntu', 'fedora', 'opensuse'] archs = ['i386', 'amd64'] if distro in distros and arch in archs: sh('ln -fs postinst.%s debian/postinst' % distro) sh('ln -fs prerm.%s debian/prerm' % distro) tmp_dir = produce_source(arch) vmc_version = get_vmc_version() ########### # PREPARE # ########### sh('rm -rf ../build/*') sh('cp admin/install-%s.sh ../build/' % distro) if distro != 'ubuntu': sh('cd ../build/; sudo alien %s/vodafone-mobile-connect-card-driver-for-linux_%s_%s.deb --to-rpm --scripts; cd -' % (tmp_dir, vmc_version, arch)) if distro == 'opensuse': sh('cp ../opensuse-deps/* ../build/') else: sh('cp %s/vodafone-mobile-connect-card-driver-for-linux_%s_%s.deb ../build/' % (tmp_dir, vmc_version, arch)) #########
def produce_tree(): name = get_vmc_name() version = get_vmc_version() target=os.getenv("TARGET") if target == None: target = "generic" release=os.getenv("RELEASE") if release == None: release = "1" tmp = "./tmp" nvr_triplet="%s-%s-%s" % (name,version,release) root = "%s/%s-%s" % (tmp, name, version) import re def list_core_files(path, pattern): result = [] def walk_callback(arg, directory, files): if '.svn' in files: files.remove('.svn') for file in files: if os.path.isdir(os.path.join(directory, file)): continue m = re.search(pattern, file) if m: result.append(os.path.join(directory, file)) os.path.walk(path, walk_callback, None) return result def list_data_files(path): result = [] def walk_callback(arg, directory, files): if '.svn' in files: files.remove('.svn') result.extend(os.path.join(directory, file) for file in files if not os.path.isdir(os.path.join(directory, file))) os.path.walk(path, walk_callback, None) return result core_files = [ (get_vmc_data_dir(), list_core_files('vmc','.+\.py\Z')), ] data_files = [ # Plugins (os.path.join(get_vmc_data_dir(), 'plugins', 'os'), list_data_files('plugins/os')), (os.path.join(get_vmc_data_dir(), 'plugins', 'devices'), list_data_files('plugins/devices')), (os.path.join(get_vmc_data_dir(), 'plugins', 'notifications'), list_data_files('plugins/notifications')), # Resources (os.path.join(get_vmc_resources_dir(), 'extra'), list_data_files('resources/extra')), (os.path.join(get_vmc_resources_dir(), 'glade'), list_data_files('resources/glade')), (os.path.join(get_vmc_resources_dir(), 'templates'), list_data_files('resources/templates')), # Data (get_vmc_data_dir(), ['gtk-tap.py']), # Icon ('/usr/share/applications', ['resources/desktop/vmc.desktop']), ('/usr/share/pixmaps', ['resources/desktop/vodafone.png']), # Doc (get_vmc_doc_dir(), ['debian/copyright', 'README', 'README-fr'] + glob('LICENSE*')), # Bin (get_vmc_bin_dir(), glob('bin/*')), ] # echo "%_unpackaged_files_terminate_build 0" >> /etc/rpm/macros # Install core and data files for dst, src in core_files: sh("mkdir -p %s%s" % (root, dst)) for file in src: (directory,a,b) = file.rpartition('/') dstdir="%s%s/%s" % (root, dst, directory) if not os.path.exists(dstdir): sh("mkdir -p %s" % dstdir) sh("cp -p %s %s/." % (file, dstdir)) for dst, src in data_files: sh("mkdir -p %s%s" % (root, dst)) for file in src: dstdir="%s%s" % ( root, dst ) sh("cp -p %s %s/." % ( file, dstdir )) # Splashscreen - apply version img_to_patch_path = "%s%s" % (root, os.path.join(get_vmc_resources_dir(), 'glade', 'splash.png')) paint_file(img_to_patch_path, '%s' % version) # Remove developer overrides sh('rm -f %s/vmc/common/consts-dev.py' % root) # Generate user doc # Mandriva Free 2010 rpm package building fails to generate documentation so this two lines need to be commented. sh('tar -cf - doc/user | (cd %s && tar -xf -)' % tmp) sh('(cd %s/doc/user && make -f Makefile.pkg ROOT=../../%s-%s/%s/guide)' % (tmp, name, version,get_vmc_doc_dir())) # Apply platform specific overrides sh('(cd resources/platform/%s && tar -cf - . --exclude=./debian) | (cd %s && tar -xf -)' % (target, root)) # I18N sh('(cd resources && tar -cf - po glade) | (cd %s && tar -xf -)' % tmp) sh('(cd %s/po && make install ROOT=../%s-%s/ VERSION=%s)' % (tmp, name, version, version)) # Remove any svn info in copy sh('find %s -name ".svn" | xargs rm -rf' % root) # if we have an RPM spec file we must be building a bundle for an RPM based distro try: specfile='%s/vmc.spec' % root os.stat(specfile) sh("sed -i %s -e 's,Name:.*$,Name: %s,'" % (specfile,name)) sh("sed -i %s -e 's,Version:.*$,Version: %s,'" % (specfile,version)) sh("sed -i %s -e 's,Release:.*$,Release: %s,'" % (specfile,release)) sh("sed -i %s -e 's,Source0:.*$,Source0: %s.tar.bz2,'" % (specfile,nvr_triplet)) # remove any precompiled objects - rpm's smart enough to build them sh('find %s -name "*.pyc" | xargs rm -rf' % root) sh('find %s -name "*.pyo" | xargs rm -rf' % root) sh('(cd %s && tar -jcvf %s.tar.bz2 %s-%s)' % (tmp,nvr_triplet,name,version)) except: pass # if we have a platform/debian directory we must be building for a DEB based distro if os.path.exists('resources/platform/%s/debian' % target): # copy it sh('(cd resources/platform/%s && tar -cf - debian) | (cd %s && tar -xf -)' % (target, tmp)) changelog='%s/debian/changelog' % tmp sh("sed -i %s -e 's,name,%s,' -e 's,version,%s,' -e 's,release,%s,'" % (changelog,name,version,release)) control='%s/debian/control' % tmp sh("sed -i %s -e 's,Source.*$,Source: %s,' -e 's,Package.*$,Package: %s,'" % (control,name,name)) # compile all of the python objects import compileall compileall.compile_dir('%s/' % root, ddir='/', force=True) # so make can find out the root directory f = open('%s/builddir' % tmp,'w') f.write('%s-%s' % (name,version)) f.close()
def testSourceInstall(): cmd = 'PYTHONPATH=%(installPath)s:$PYTHONPATH trial %(projectName)s' sh(cmd % {'installPath': siteInstallPath.path, 'projectName': proj.initPath.parent().basename()}, null=False, prompt=prompt)