Ejemplo n.º 1
0
def __main__():

    vgls = parse_args()

    collect_metadata(vgls)

    write_manifest(vgls)

    if vgls['do_check']:
        run_check(vgls)
Ejemplo n.º 2
0
 def create_manifest(self):
     ctime = self.destination.CreationDateTime
     msg = manifest.write_manifest(self.destination.FullDestination,
                                   self.destination.ProductName,
                                   ctime.strftime("%Y-%M-%D %H:%M:%S"),
                                   self.product_isos)
     self.builder_log.write(msg)
Ejemplo n.º 3
0
def makeProduct(productName,
                docsources,
                libsources,
                manifestData,
                format='zip',
                builddir='/tmp',
                comments=(),
                productFile=None):
    """
    given the necessary ingredients, builds the product archive
    and returns the path to it.
    """

    buildroot = _getbuildroot(builddir, productName)
    docroot = os.path.join(buildroot, manifestData.get('docroot', 'docroot'))
    libs = os.path.join(buildroot, manifestData.get('libs', 'libs'))
    shutil.copytree(docsources, docroot)
    if libsources:
        shutil.copytree(libsources, libs)
        # to silence the compileall module
        sys.stdout = cStringIO.StringIO()
        compileall.compile_dir(libs, force=1)
        sys.stdout = sys.__stdout__
    manifestpath = os.path.join(buildroot, manifest.MANIFEST_FILE)
    manifest.write_manifest(manifestpath, manifestData, comments=comments)

    if format == 'zip':
        dest = productFile or os.path.join(builddir, '%s.zip' % productName)
        z = zipfile.ZipFile(dest, mode='w', compression=zipfile.ZIP_DEFLATED)

        def zipwalker(zippy, dirname, names, buildroot=buildroot):
            absd = os.path.join(buildroot, dirname)
            brlen = len(buildroot)
            for n in names:
                absn = os.path.join(dirname, n)
                reln = absn[brlen + 1:]
                if os.path.isdir(absn):
                    pass
                else:
                    zippy.write(absn, reln)

        os.path.walk(buildroot, zipwalker, z)
        z.close()

    elif format in ('tar', 'tgz', 'tar.gz'):
        dest = os.path.join(builddir, '%s.tar' % productName)
        status = os.system('cd %s; tar cf %s *' % (buildroot, dest))
        if status:
            raise RuntimeError, "error creating tar file: %s.tar: %s" \
                  % (productName, status)

        if format == 'tar':
            if productFile:
                if dest != productFile:
                    shutil.copyfile(dest, productFile)
                    os.unlink(dest)
                dest = productFile
        else:
            tf = open(dest)
            dest=productFile or os.path.join(builddir, '%s.%s' % \
                                             (productName, format))
            gf = gzip.open(dest, 'w')
            buffsize = 2 << 10
            while 1:
                stuff = tf.read(buffsize)
                if stuff:
                    gf.write(stuff)
                else:
                    break
            gf.close()
    shutil.rmtree(buildroot)
    return dest
Ejemplo n.º 4
0
def makeProduct(productName,
                docsources,
                libsources,
                manifestData,
                format='zip',
                builddir='/tmp',
                comments=(),
                productFile=None):
    """
    given the necessary ingredients, builds the product archive
    and returns the path to it.
    """

    buildroot=_getbuildroot(builddir, productName)
    docroot=os.path.join(buildroot, manifestData.get('docroot', 'docroot'))
    libs=os.path.join(buildroot, manifestData.get('libs', 'libs'))
    shutil.copytree(docsources, docroot)
    if libsources:
        shutil.copytree(libsources, libs)
        # to silence the compileall module
        sys.stdout=cStringIO.StringIO()
        compileall.compile_dir(libs, force=1)
        sys.stdout=sys.__stdout__
    manifestpath=os.path.join(buildroot, manifest.MANIFEST_FILE)
    manifest.write_manifest(manifestpath, manifestData, comments=comments)
    
    if format=='zip':
        dest=productFile or os.path.join(builddir, '%s.zip' % productName)
        z=zipfile.ZipFile(dest,
                          mode='w',
                          compression=zipfile.ZIP_DEFLATED)
        def zipwalker(zippy, dirname, names, buildroot=buildroot):
            absd=os.path.join(buildroot, dirname)
            brlen=len(buildroot)
            for n in names:
                absn=os.path.join(dirname, n)
                reln=absn[brlen+1:]
                if os.path.isdir(absn):
                    pass
                else:
                    zippy.write(absn, reln)
        os.path.walk(buildroot, zipwalker, z)
        z.close()
        
    elif format in ('tar', 'tgz', 'tar.gz'):
        dest=os.path.join(builddir, '%s.tar' % productName)
        status=os.system('cd %s; tar cf %s *' % (buildroot, dest))
        if status:
            raise RuntimeError, "error creating tar file: %s.tar: %s" \
                  % (productName, status)
        
        if format=='tar':
            if productFile:
                if dest != productFile:
                    shutil.copyfile(dest, productFile)
                    os.unlink(dest)
                dest=productFile
        else:
            tf=open(dest)
            dest=productFile or os.path.join(builddir, '%s.%s' % \
                                             (productName, format))
            gf=gzip.open(dest, 'w')
            buffsize=2<<10
            while 1:
                stuff=tf.read(buffsize)
                if stuff:
                    gf.write(stuff)
                else:
                    break
            gf.close()
    shutil.rmtree(buildroot)
    return dest