Ejemplo n.º 1
0
 def fetch_comarfiles(self):
     spec = self.spec
     for package in spec.packages:
         for pcomar in package.providesComar:
             comaruri = join(self.specdiruri,
                             ctx.const.comar_dir, pcomar.script)
             self.download(comaruri, join(self.destdir, ctx.const.comar_dir))
Ejemplo n.º 2
0
 def fetch_patches(self):
     spec = self.spec
     for patch in spec.source.patches:
         file_name = basename(patch.filename)
         dir_name = dirname(patch.filename)
         patchuri = join(self.specdiruri, ctx.const.files_dir, dir_name, file_name)
         self.download(patchuri, join(self.destdir, ctx.const.files_dir, dir_name))
Ejemplo n.º 3
0
 def fetch_comarfiles(self):
     spec = self.spec
     for package in spec.packages:
         for pcomar in package.providesComar:
             comaruri = join(self.specdiruri, ctx.const.comar_dir,
                             pcomar.script)
             self.download(comaruri, join(self.destdir,
                                          ctx.const.comar_dir))
Ejemplo n.º 4
0
 def fetch_additionalFiles(self):
     spec = self.spec
     for pkg in spec.packages:
         for afile in pkg.additionalFiles:
             file_name = basename(afile.filename)
             dir_name = dirname(afile.filename)
             afileuri = join(self.specdiruri, ctx.const.files_dir, dir_name, file_name)
             self.download(afileuri, join(self.destdir, ctx.const.files_dir, dir_name))
Ejemplo n.º 5
0
 def fetch_patches(self):
     spec = self.spec
     for patch in spec.source.patches:
         file_name = basename(patch.filename)
         dir_name = dirname(patch.filename)
         patchuri = join(self.specdiruri, ctx.const.files_dir, dir_name,
                         file_name)
         self.download(patchuri,
                       join(self.destdir, ctx.const.files_dir, dir_name))
Ejemplo n.º 6
0
 def fetch_additionalFiles(self):
     spec = self.spec
     for pkg in spec.packages:
         for afile in pkg.additionalFiles:
             file_name = basename(afile.filename)
             dir_name = dirname(afile.filename)
             afileuri = join(self.specdiruri, ctx.const.files_dir, dir_name,
                             file_name)
             self.download(
                 afileuri, join(self.destdir, ctx.const.files_dir,
                                dir_name))
Ejemplo n.º 7
0
    def download(uri,
                 transfer_dir="/tmp",
                 sha1sum=False,
                 compress=None,
                 sign=None,
                 copylocal=False):

        assert isinstance(uri, URI)

        if sha1sum:
            sha1filename = File.download(URI(uri.get_uri() + '.sha1sum'),
                                         transfer_dir)
            sha1f = file(sha1filename)
            newsha1 = sha1f.readlines()[0]

        if uri.is_remote_file() or copylocal:
            localfile = join(transfer_dir, uri.filename())

            # TODO: code to use old .sha1sum file, is this a necessary optimization?
            #oldsha1fn = localfile + '.sha1sum'
            #if os.exists(oldsha1fn):
            #oldsha1 = file(oldsha1fn).readlines()[0]
            if sha1sum and os.path.exists(localfile):
                oldsha1 = pisi.util.sha1_file(localfile)
                if (newsha1 == oldsha1):
                    # early terminate, we already got it ;)
                    raise AlreadyHaveException(uri, localfile)

            if uri.is_remote_file():
                ctx.ui.info(_("Fetching %s") % uri.get_uri(), verbose=True)
                fetch_url(uri, transfer_dir, ctx.ui.Progress)
            else:
                # copy to transfer dir,
                localfile = join(transfer_dir, uri.filename())
                ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri(),
                            verbose=True)
                shutil.copy(uri.get_uri(), transfer_dir)
        else:
            localfile = uri.get_uri()  #TODO: use a special function here?
            if not os.path.exists(localfile):
                raise IOError(_("File '%s' not found.") % localfile)
            if not os.access(localfile, os.W_OK):
                oldfn = localfile
                localfile = join(transfer_dir, os.path.basename(localfile))
                shutil.copy(oldfn, localfile)

        if sha1sum:
            if (pisi.util.sha1_file(localfile) != newsha1):
                raise Error(_("File integrity of %s compromised.") % uri)

        localfile = File.decompress(localfile, compress)

        return localfile
Ejemplo n.º 8
0
 def pkg_dir(self):
     "package build directory"
     packageDir = self.spec.source.name + '-' + \
                  self.spec.source.version + '-' + self.spec.source.release
     from pisi.util import join_path as join
     return join( ctx.config.dest_dir(), ctx.config.values.dirs.tmp_dir,
                  packageDir )
Ejemplo n.º 9
0
    def download(uri, transfer_dir = "/tmp", sha1sum = False, 
                 compress = None, sign = None, copylocal = False):

        assert isinstance(uri, URI)

        if sha1sum:
            sha1filename = File.download(URI(uri.get_uri() + '.sha1sum'), transfer_dir)
            sha1f = file(sha1filename)
            newsha1 = sha1f.readlines()[0]

        if uri.is_remote_file() or copylocal:
            localfile = join(transfer_dir, uri.filename())

            # TODO: code to use old .sha1sum file, is this a necessary optimization?
            #oldsha1fn = localfile + '.sha1sum'
            #if os.exists(oldsha1fn):
                #oldsha1 = file(oldsha1fn).readlines()[0]
            if sha1sum and os.path.exists(localfile):
                oldsha1 = pisi.util.sha1_file(localfile)
                if (newsha1 == oldsha1):
                    # early terminate, we already got it ;)
                    raise AlreadyHaveException(uri, localfile)

            if uri.is_remote_file():
                ctx.ui.info(_("Fetching %s") % uri.get_uri())
                fetch_url(uri, transfer_dir)
            else:
                # copy to transfer dir,
                localfile = join(transfer_dir, uri.filename())
                ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri())
                shutil.copy(uri.get_uri(), transfer_dir)
        else:
            localfile = uri.get_uri() #TODO: use a special function here?
            if not os.path.exists(localfile):
                raise IOError(_("File '%s' not found.") % localfile)
            if not os.access(localfile, os.W_OK):
                oldfn = localfile
                localfile = join(transfer_dir, os.path.basename(localfile))
                shutil.copy(oldfn, localfile)

        if sha1sum:        
            if (pisi.util.sha1_file(localfile) != newsha1):
                raise Error(_("File integrity of %s compromised.") % uri)

        localfile = File.decompress(localfile, compress)

        return localfile
Ejemplo n.º 10
0
 def download(uri, transfer_dir = "/tmp"):
     assert type(uri == URI)
     if uri.is_remote_file():
         ctx.ui.info(_("Fetching %s") % uri.get_uri())
         localfile = join(transfer_dir, uri.filename())
         fetch_url(uri, transfer_dir) # FIXME: localfile would look better for fetch iface?
     else:
         localfile = uri.get_uri() #TODO: use a special function here?
     return localfile
Ejemplo n.º 11
0
    def fetch_files(self):
        self.specdiruri = dirname(self.specuri.get_uri())
        pkgname = basename(self.specdiruri)
        self.destdir = join(ctx.config.tmp_dir(), pkgname)
        #self.location = dirname(self.url.uri)

        self.fetch_actionsfile()
        self.fetch_patches()
        self.fetch_comarfiles()
        self.fetch_additionalFiles()

        return self.destdir
Ejemplo n.º 12
0
    def fetch_files(self):
        self.specdiruri = dirname(self.specuri.get_uri())
        pkgname = basename(self.specdiruri)
        self.destdir = join(ctx.config.tmp_dir(), pkgname)
        #self.location = dirname(self.url.uri)

        self.fetch_actionsfile()
        self.fetch_patches()
        self.fetch_comarfiles()
        self.fetch_additionalFiles()

        return self.destdir
Ejemplo n.º 13
0
def get_file_type(path, pinfo_list, install_dir):
    """Return the file type of a path according to the given PathInfo
    list"""
    
    Match = lambda x: [match for match in glob.glob(install_dir + x) if join(install_dir, path).find(match) > -1]

    def Sort(x):
        x.sort(reverse=True)
        return x
    
    best_matched_path = Sort([pinfo.path for pinfo in pinfo_list if Match(pinfo.path)])[0]
    info = [pinfo for pinfo in pinfo_list if best_matched_path == pinfo.path][0]
    return info.fileType, info.permanent
Ejemplo n.º 14
0
    def __init__(self, options = Options()):
        self.options = options
        self.values = ConfigurationFile("/etc/pisi/pisi.conf")

        destdir = self.get_option('destdir')
        if destdir:
            if destdir.strip().startswith('/'):
                self.destdir = destdir
            else:
                self.destdir = join(os.getcwd(), destdir)
        else:
            self.destdir = self.values.general.destinationdirectory

        if not os.path.exists(self.destdir):
            ctx.ui.warning( _('Destination directory %s does not exist. Creating it.') % self.destdir)
            os.makedirs(self.destdir)
Ejemplo n.º 15
0
    def __init__(self, options = Options()):
        self.options = options
        self.values = ConfigurationFile("/etc/pisi/pisi.conf")

        destdir = self.get_option('destdir')
        if destdir:
            if destdir.strip().startswith('/'):
                self.destdir = destdir
            else:
                self.destdir = join(os.getcwd(), destdir)
        else:
            self.destdir = self.values.general.destinationdirectory

        if not os.path.exists(self.destdir):
            ctx.ui.warning( _('Destination directory %s does not exist. Creating it.') % self.destdir)
            os.makedirs(self.destdir)

        # get the initial environment variables. this is needed for
        # build process.
        self.environ = deepcopy(os.environ)
Ejemplo n.º 16
0
    def __init__(self, options = Options()):
        self.options = options
        self.values = ConfigurationFile("/etc/pisi/pisi.conf")

        destdir = self.get_option('destdir')
        if destdir:
            if destdir.strip().startswith('/'):
                self.destdir = destdir
            else:
                self.destdir = join(os.getcwd(), destdir)
        else:
            self.destdir = self.values.general.destinationdirectory

        if not os.path.exists(self.destdir):
            ctx.ui.warning( _('Destination directory %s does not exist. Creating it.') % self.destdir)
            os.makedirs(self.destdir)

        # get the initial environment variables. this is needed for
        # build process.
        self.environ = deepcopy(os.environ)
Ejemplo n.º 17
0
def get_file_type(path, pinfo_list, install_dir):
    """Return the file type of a path according to the given PathInfo
    list"""
    #print 'get_file_type',path,str(pinfo_list),install_dir
    Match = lambda x: [
        match for match in glob.glob(install_dir + x)
        if join(install_dir, path).find(match) > -1
    ]

    def Sort(x):
        x.sort(reverse=True)
        return x

    matches = [pinfo.path for pinfo in pinfo_list if Match(pinfo.path)]
    if len(matches) > 0:
        best_matched_path = Sort(matches)[0]
    else:
        raise Error, _("No file matches %s in Spec file." % path)
    info = [pinfo for pinfo in pinfo_list
            if best_matched_path == pinfo.path][0]
    return info.fileType, info.permanent
Ejemplo n.º 18
0
    def __init__(self, uri, mode, transfer_dir = "/tmp"):
        "it is pointless to open a file without a URI and a mode"
        uri = File.make_uri(uri)
        if mode==File.read or mode==File.write:
            self.mode = mode
        else:
            raise Error(_("File mode must be either File.read or File.write"))
        if uri.is_remote_file():
            if self.mode == File.read:
                ctx.ui.info(_("Fetching %s") % uri.get_uri())
                localfile = join(transfer_dir, uri.filename())
                fetch_url(uri, transfer_dir) # FIXME: localfile would look better for fetch iface?
            else:
                raise Error(_("Remote write not implemented"))
        else:
            localfile = uri.get_uri() #TODO: use a special function here?

        if self.mode == File.read:
            access = 'r'
        else:
            access = 'w'
        self.__file__ = file(localfile, access)
Ejemplo n.º 19
0
 def archives_dir(self):
     return join(self.dest_dir(), self.values.dirs.archives_dir)
Ejemplo n.º 20
0
def install():
    shelltools.system("./tools/build/jam_src/bin.linuxx86/bjam --prefix=%s install" % 
                      join(get.installDIR(), "usr"))
    pisitools.dodoc("ChangeLog", "AUTHORS", "INSTALL*", "NEWS", "README*")
Ejemplo n.º 21
0
                    if str(old_pkg.metadata.package.name) != package_name:
                        ctx.ui.warning(
                            _('Skipping %s with wrong pkg name ') %
                            old_package_fn)
                        return
                    old_build = old_pkg.metadata.package.build
                    found.append((old_package_fn, old_build))
                except Exception, e:
                    print e
                    ctx.ui.warning(
                        'Package file %s may be corrupt. Skipping.' %
                        old_package_fn)

        for root, dirs, files in os.walk(ctx.config.packages_dir()):
            for file in files:
                locate_old_package(join(root, file))

        outdir = ctx.get_option('output_dir')
        if not outdir:
            outdir = '.'
        for file in [join(outdir, entry) for entry in os.listdir(outdir)]:
            if os.path.isfile(file):
                locate_old_package(file)

        if not found:
            return (1, None)
            ctx.ui.warning(
                _('(no previous build found, setting build no to 1.)'))
        else:
            a = filter(lambda (x, y): y != None, found)
            ctx.ui.debug(str(a))
Ejemplo n.º 22
0
 def pkg_dir(self, pkg, version, release):
     return join(ctx.config.lib_dir(), 'package', 
                 pkg + '-' + version + '-' + release)
Ejemplo n.º 23
0
 def files_name(self, pkg, version, release):
     pkg_dir = self.pkg_dir(pkg, version, release)
     return join(pkg_dir, ctx.const.files_xml)
Ejemplo n.º 24
0
 def __init__(self):
     self.d = shelve.LockedDBShelf('install')
     self.dp = shelve.LockedDBShelf('configpending')
     self.files_dir = join(ctx.config.db_dir(), 'files')
Ejemplo n.º 25
0
 def __init__(self):
     self.d = shelve.LockedDBShelf('install')
     self.dp = shelve.LockedDBShelf('configpending')
     self.files_dir = join(ctx.config.db_dir(), 'files')
Ejemplo n.º 26
0
    def calc_build_no(self, package_name):
        """Calculate build number"""

        def metadata_changed(old_metadata, new_metadata):
            for key in old_metadata.package.__dict__.keys():
                if old_metadata.package.__dict__[key] != new_metadata.package.__dict__[key]:
                    if key != "build":
                        return True

            return False
            
        # find previous build in packages dir
        found = []        
        def locate_old_package(old_package_fn):
            if util.is_package_name(os.path.basename(old_package_fn), package_name):
                try:
                    old_pkg = Package(old_package_fn, 'r')
                    old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
                    ctx.ui.info(_('(found old version %s)') % old_package_fn)
                    if str(old_pkg.metadata.package.name) != package_name:
                        ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
                                                old_package_fn)
                        return
                    old_build = old_pkg.metadata.package.build
                    found.append( (old_package_fn, old_build) )
                except Error:
                    ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)

        for root, dirs, files in os.walk(ctx.config.packages_dir()):
            for file in files:
                locate_old_package(join(root,file))

        outdir=ctx.get_option('output_dir')
        if not outdir:
            outdir = '.'
        for file in [join(outdir,entry) for entry in os.listdir(outdir)]:
            if os.path.isfile(file):
                locate_old_package(file)

        if not found:
            return (1, None)
            ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
        else:
            a = filter(lambda (x,y): y != None, found)
            ctx.ui.debug(str(a))
            if a:
                # sort in order of increasing build number
                a.sort(lambda x,y : cmp(x[1],y[1]))
                old_package_fn = a[-1][0]   # get the last one
                old_build = a[-1][1]

                # compare old files.xml with the new one..
                old_pkg = Package(old_package_fn, 'r')
                old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
    
                changed = False
                fnew = self.files.list
                fold = old_pkg.files.list
                fold.sort(lambda x,y : cmp(x.path,y.path))
                fnew.sort(lambda x,y : cmp(x.path,y.path))
                    
                if len(fnew) != len(fold):
                    changed = True
                else:
                    for i in range(len(fold)):
                        fo = fold.pop(0)
                        fn = fnew.pop(0)
                        if fo.path != fn.path:
                            changed = True
                            break
                        else:
                            if fo.hash != fn.hash:
                                changed = True
                                break
                
                if metadata_changed(old_pkg.metadata, self.metadata):
                    changed = True

                self.old_packages.append(os.path.basename(old_package_fn))
            else: # no old build had a build number
                old_build = None

            ctx.ui.debug('old build number: %s' % old_build)
                            
            # set build number
            if old_build is None:
                ctx.ui.warning(_('(old package lacks a build no, setting build no to 1.)'))
                return (1, None)
            elif changed:
                ctx.ui.info(_('There are changes, incrementing build no to %d') % (old_build + 1))
                return (old_build + 1, old_build)
            else:
                ctx.ui.info(_('There is no change from previous build %d') % old_build)
                return (old_build, old_build)
Ejemplo n.º 27
0
 def pkg_dir(self, pkg, version, release):
     return join(ctx.config.lib_dir(), "package", pkg + "-" + version + "-" + release)
Ejemplo n.º 28
0
 def __init__(self):
     self.d = shelve.LockedDBShelf("install")
     self.dp = shelve.LockedDBShelf("configpending")
     self.files_dir = join(ctx.config.db_dir(), "files")
Ejemplo n.º 29
0
 def fetch_actionsfile(self):
     actionsuri = join(self.specdiruri, ctx.const.actions_file)
     self.download(actionsuri, self.destdir)
Ejemplo n.º 30
0
 def packages_dir(self):
     return join(self.dest_dir(), self.values.dirs.packages_dir)
Ejemplo n.º 31
0
 def db_dir(self):
     return join(self.dest_dir(), self.values.dirs.db_dir)
Ejemplo n.º 32
0
    def build_packages(self):
        """Build each package defined in PSPEC file. After this process there
        will be .pisi files hanging around, AS INTENDED ;)"""

        self.fetch_component()  # bug 856

        # Strip install directory before building .pisi packages.
        self.strip_install_dir()

        if ctx.get_option('create_static'):
            obj = self.generate_static_package_object()
            if obj:
                self.spec.packages.append(obj)

        if ctx.config.values.build.generatedebug:
            obj = self.generate_debug_package_object()
            if obj:
                self.spec.packages.append(obj)

        new_packages = []
        old_package_names = []

        for package in self.spec.packages:
            old_package_name = None
            # store additional files
            c = os.getcwd()
            os.chdir(self.specdir)
            install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
            for afile in package.additionalFiles:
                src = os.path.join(ctx.const.files_dir, afile.filename)
                dest = os.path.join(
                    install_dir + os.path.dirname(afile.target),
                    os.path.basename(afile.target))
                util.copy_file(src, dest)
                if afile.permission:
                    # mode is octal!
                    os.chmod(dest, int(afile.permission, 8))
            os.chdir(c)

            ctx.ui.action(_("** Building package %s") % package.name)

            ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
            self.gen_files_xml(package)

            # build number
            if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno:
                build_no = old_build_no = None
                ctx.ui.warning(
                    _('Build number is not available. For repo builds you must enable buildno in pisi.conf.'
                      ))
            else:
                build_no, old_build_no = self.calc_build_no(package.name)

            ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
            self.gen_metadata_xml(package, build_no)

            # Calculate new and oldpackage names for buildfarm
            name = util.package_name(package.name, self.spec.source.version,
                                     self.spec.source.release,
                                     self.metadata.package.build)

            if old_build_no:
                old_package_name = util.package_name(package.name,
                                                     self.spec.source.version,
                                                     self.spec.source.release,
                                                     old_build_no)
            old_package_names.append(old_package_name)

            outdir = ctx.get_option('output_dir')
            if outdir:
                name = pisi.util.join_path(outdir, name)
            new_packages.append(name)

            ctx.ui.info(_("Creating PISI package %s.") % name)

            pkg = Package(name, 'w')

            # add comar files to package
            os.chdir(self.specdir)
            for pcomar in package.providesComar:
                fname = util.join_path(ctx.const.comar_dir, pcomar.script)
                pkg.add_to_package(fname)

            # add xmls and files
            os.chdir(self.pkg_dir())

            pkg.add_to_package(ctx.const.metadata_xml)
            pkg.add_to_package(ctx.const.files_xml)

            # Now it is time to add files to the packages using newly
            # created files.xml
            files = Files()
            files.read(ctx.const.files_xml)

            if ctx.get_option('package_format') == "1.0":
                for finfo in files.list:
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    pkg.add_to_package(orgname, arcname)
                pkg.close()
            else:  # default package format is 1.1, so make it fallback.
                ctx.build_leftover = join(self.pkg_dir(),
                                          ctx.const.install_tar_lzma)
                tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma")
                for finfo in files.list:
                    #print finfo.path
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    tar.add_to_archive(orgname, arcname.lstrip("install"))
                tar.close()
                pkg.add_to_package(ctx.const.install_tar_lzma)
                pkg.close()
                os.unlink(ctx.const.install_tar_lzma)
                ctx.build_leftover = None

            os.chdir(c)
            self.set_state("buildpackages")
            ctx.ui.info(_("Done."))

        #show the files those are not collected from the install dir
        if ctx.get_option('show_abandoned_files') or ctx.get_option('debug'):
            abandoned_files = self.get_abandoned_files()
            if abandoned_files:
                ctx.ui.warning(
                    _('Abandoned files under the install dir (%s):') %
                    (install_dir))
                for f in abandoned_files:
                    ctx.ui.info('    - %s' % (f))
            else:
                ctx.ui.warning(
                    _('All of the files under the install dir (%s) has been collected by package(s)'
                      ) % (install_dir))

        if ctx.config.values.general.autoclean is True:
            ctx.ui.info(_("Cleaning Build Directory..."))
            util.clean_dir(self.pkg_dir())
        else:
            ctx.ui.info(_("Keeping Build Directory"))

        # reset environment variables after build.  this one is for
        # buildfarm actually. buildfarm re-inits pisi for each build
        # and left environment variables go directly into initial dict
        # making actionsapi.variables.exportFlags() useless...
        os.environ = {}
        os.environ = deepcopy(ctx.config.environ)

        return new_packages, old_package_names
Ejemplo n.º 33
0
def install():
    shelltools.system(
        "./tools/build/jam_src/bin.linuxx86/bjam --prefix=%s install" %
        join(get.installDIR(), "usr"))
    pisitools.dodoc("ChangeLog", "AUTHORS", "INSTALL*", "NEWS", "README*")
Ejemplo n.º 34
0
    def build_packages(self):
        """Build each package defined in PSPEC file. After this process there
        will be .pisi files hanging around, AS INTENDED ;)"""

        self.fetch_component() # bug 856

        # Strip install directory before building .pisi packages.
        self.strip_install_dir()

        package_names = []

        for package in self.spec.packages:
            # store additional files
            c = os.getcwd()
            os.chdir(self.specdir)
            install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
            for afile in package.additionalFiles:
                src = os.path.join(ctx.const.files_dir, afile.filename)
                dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
                util.copy_file(src, dest)
                if afile.permission:
                    # mode is octal!
                    os.chmod(dest, int(afile.permission, 8))

            os.chdir(c)
           
            ctx.ui.action(_("** Building package %s") % package.name);

            ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
            self.gen_files_xml(package)

            ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
            self.gen_metadata_xml(package)

            ctx.ui.info(_("Creating PISI package %s.") % package.name)

            name = util.package_name(package.name,
                                     self.spec.source.version,
                                     self.spec.source.release,
                                     self.metadata.package.build)
            pkg = Package(name, 'w')
            package_names.append(name)

            # add comar files to package
            os.chdir(self.specdir)
            for pcomar in package.providesComar:
                fname = util.join_path(ctx.const.comar_dir,
                                     pcomar.script)
                pkg.add_to_package(fname)

            # add xmls and files
            os.chdir(self.pkg_dir())
        
            pkg.add_to_package(ctx.const.metadata_xml)
            pkg.add_to_package(ctx.const.files_xml)

            # Now it is time to add files to the packages using newly
            # created files.xml
            files = Files()
            files.read(ctx.const.files_xml)
            for finfo in files.list:
                pkg.add_to_package(join("install", finfo.path))

            pkg.close()
            os.chdir(c)
            self.set_state("buildpackages")
            ctx.ui.info(_("Done."))
           
        if ctx.config.values.general.autoclean is True:
            ctx.ui.info(_("Cleaning Build Directory..."))
            util.clean_dir(self.pkg_dir())
        else:
            ctx.ui.info(_("Keeping Build Directory"))

        return package_names
Ejemplo n.º 35
0
 def files_name(self, pkg, version, release):
     pkg_dir = self.pkg_dir(pkg, version, release)
     return join(pkg_dir, ctx.const.files_xml)
Ejemplo n.º 36
0
 def tmp_dir(self):
     return join(self.dest_dir(), self.values.dirs.tmp_dir)
Ejemplo n.º 37
0
 def pkg_dir(self, pkg, version, release):
     return join(ctx.config.lib_dir(), 'package',
                 pkg + '-' + version + '-' + release)
Ejemplo n.º 38
0
 def subdir(self, path):
     dir = join(self.dest_dir(), path)
     pisi.util.check_dir(dir)
     return dir
Ejemplo n.º 39
0
 def fetch_actionsfile(self):
     actionsuri = join(self.specdiruri, ctx.const.actions_file)
     self.download(actionsuri, self.destdir)
Ejemplo n.º 40
0
    def build_packages(self):
        """Build each package defined in PSPEC file. After this process there
        will be .pisi files hanging around, AS INTENDED ;)"""

        self.fetch_component() # bug 856

        # Strip install directory before building .pisi packages.
        self.strip_install_dir()

        if ctx.get_option('create_static'):
            obj = self.generate_static_package_object()
            if obj:
                self.spec.packages.append(obj)

        if not ctx.get_option('no_debug'):
            obj = self.generate_debug_package_object()
            if obj:
                self.spec.packages.append(obj)

        package_names = []
        old_package_names = []

        for package in self.spec.packages:
            old_package_name = None
            # store additional files
            c = os.getcwd()
            os.chdir(self.specdir)
            install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
            for afile in package.additionalFiles:
                src = os.path.join(ctx.const.files_dir, afile.filename)
                dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
                util.copy_file(src, dest)
                if afile.permission:
                    # mode is octal!
                    os.chmod(dest, int(afile.permission, 8))

            os.chdir(c)
           
            ctx.ui.action(_("** Building package %s") % package.name);

            ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
            self.gen_files_xml(package)

            ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
            build_number, old_build_number = self.gen_metadata_xml(package)

            name =  util.package_name(package.name,
                                     self.spec.source.version,
                                     self.spec.source.release,
                                     self.metadata.package.build)

            outdir = ctx.get_option('output_dir')
            if outdir:
                name = pisi.util.join_path(outdir, name)

            ctx.ui.info(_("Creating PISI package %s.") % name)

            # somebody explain to me why this is done here -- exa
            if old_build_number:
                old_package_name = util.package_name(package.name,
                                     self.spec.source.version,
                                     self.spec.source.release,
                                     old_build_number)
            pkg = Package(name, 'w')
            package_names.append(name)
            old_package_names.append(old_package_name)

            # add comar files to package
            os.chdir(self.specdir)
            for pcomar in package.providesComar:
                fname = util.join_path(ctx.const.comar_dir,
                                     pcomar.script)
                pkg.add_to_package(fname)

            # add xmls and files
            os.chdir(self.pkg_dir())
        
            pkg.add_to_package(ctx.const.metadata_xml)
            pkg.add_to_package(ctx.const.files_xml)

            # Now it is time to add files to the packages using newly
            # created files.xml
            files = Files()
            files.read(ctx.const.files_xml)

            if ctx.get_option('package_format') == "1.1":
                tar = archive.ArchiveTar("install.tar.lzma", "tarlzma")
                for finfo in files.list:
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    tar.add_to_archive(orgname, arcname.lstrip("install"))
                tar.close()
                pkg.add_to_package("install.tar.lzma")
                pkg.close()
                os.unlink("install.tar")
                os.unlink("install.tar.lzma")
            else:
                for finfo in files.list:
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    pkg.add_to_package(orgname, arcname)
                pkg.close()

            os.chdir(c)
            self.set_state("buildpackages")
            ctx.ui.info(_("Done."))

        #show the files those are not collected from the install dir
        if ctx.get_option('show_abandoned_files') or ctx.get_option('debug'):
            abandoned_files = self.get_abandoned_files()
            if abandoned_files:
                ctx.ui.warning(_('Abandoned files under the install dir (%s):') % (install_dir))
                for f in abandoned_files:
                    ctx.ui.info('    - %s' % (f))
            else:
                ctx.ui.warning(_('All of the files under the install dir (%s) has been collected by package(s)') 
                                                                % (install_dir))
            
        if ctx.config.values.general.autoclean is True:
            ctx.ui.info(_("Cleaning Build Directory..."))
            util.clean_dir(self.pkg_dir())
        else:
            ctx.ui.info(_("Keeping Build Directory"))

        return package_names, old_package_names
Ejemplo n.º 41
0
 def index_dir(self):
     return join(self.dest_dir(), self.values.dirs.index_dir)
Ejemplo n.º 42
0
 def subdir(self, path):
     dir = join(self.dest_dir(), path)
     pisi.util.check_dir(dir)
     return dir
Ejemplo n.º 43
0
    def build_packages(self):
        """Build each package defined in PSPEC file. After this process there
        will be .pisi files hanging around, AS INTENDED ;)"""

        self.fetch_component() # bug 856

        # Strip install directory before building .pisi packages.
        self.strip_install_dir()

        if ctx.get_option('create_static'):
            obj = self.generate_static_package_object()
            if obj:
                self.spec.packages.append(obj)

        if ctx.config.values.build.generatedebug:
            obj = self.generate_debug_package_object()
            if obj:
                self.spec.packages.append(obj)

        self.new_packages = []
        self.old_packages = []

        for package in self.spec.packages:
            old_package_name = None
            # store additional files
            c = os.getcwd()
            os.chdir(self.specdir)
            install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
            for afile in package.additionalFiles:
                src = os.path.join(ctx.const.files_dir, afile.filename)
                dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
                util.copy_file(src, dest)
                if afile.permission:
                    # mode is octal!
                    os.chmod(dest, int(afile.permission, 8))
            os.chdir(c)
           
            ctx.ui.action(_("** Building package %s") % package.name);

            ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
            self.gen_files_xml(package)

            ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
            self.gen_metadata_xml(package)

            # build number
            if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno:
                build_no = old_build_no = None
                ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.'))
            else:
                build_no, old_build_no = self.calc_build_no(package.name)
            
            self.metadata.package.build = build_no
            self.metadata.write(util.join_path(self.pkg_dir(), ctx.const.metadata_xml))

            # Calculate new and oldpackage names for buildfarm
            name =  util.package_name(package.name,
                                     self.spec.source.version,
                                     self.spec.source.release,
                                     self.metadata.package.build)

            outdir = ctx.get_option('output_dir')
            if outdir:
                name = pisi.util.join_path(outdir, name)
            self.new_packages.append(name)

            ctx.ui.info(_("Creating PISI package %s.") % name)

            pkg = Package(name, 'w')

            # add comar files to package
            os.chdir(self.specdir)
            for pcomar in package.providesComar:
                fname = util.join_path(ctx.const.comar_dir,
                                     pcomar.script)
                pkg.add_to_package(fname)

            # add xmls and files
            os.chdir(self.pkg_dir())
        
            pkg.add_to_package(ctx.const.metadata_xml)
            pkg.add_to_package(ctx.const.files_xml)

            # Now it is time to add files to the packages using newly
            # created files.xml
            files = Files()
            files.read(ctx.const.files_xml)

            if ctx.get_option('package_format') == "1.0":
                for finfo in files.list:
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    pkg.add_to_package(orgname, arcname)
                pkg.close()
            else: # default package format is 1.1, so make it fallback.
                ctx.build_leftover = join(self.pkg_dir(), ctx.const.install_tar_lzma)
                tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma")
                for finfo in files.list:
                    orgname = arcname = join("install", finfo.path)
                    if package.debug_package:
                        orgname = join("debug", finfo.path)
                    tar.add_to_archive(orgname, arcname.lstrip("install"))
                tar.close()
                pkg.add_to_package(ctx.const.install_tar_lzma)
                pkg.close()
                os.unlink(ctx.const.install_tar_lzma)
                ctx.build_leftover = None

            os.chdir(c)
            self.set_state("buildpackages")
            ctx.ui.info(_("Done."))

        #show the files those are not collected from the install dir
        if ctx.get_option('show_abandoned_files') or ctx.get_option('debug'):
            abandoned_files = self.get_abandoned_files()
            if abandoned_files:
                ctx.ui.warning(_('Abandoned files under the install dir (%s):') % (install_dir))
                for f in abandoned_files:
                    ctx.ui.info('    - %s' % (f))
            else:
                ctx.ui.warning(_('All of the files under the install dir (%s) has been collected by package(s)') 
                                                                % (install_dir))
            
        if ctx.config.values.general.autoclean is True:
            ctx.ui.info(_("Cleaning Build Directory..."))
            util.clean_dir(self.pkg_dir())
        else:
            ctx.ui.info(_("Keeping Build Directory"))


        # reset environment variables after build.  this one is for
        # buildfarm actually. buildfarm re-inits pisi for each build
        # and left environment variables go directly into initial dict
        # making actionsapi.variables.exportFlags() useless...
        os.environ = {}
        os.environ = deepcopy(ctx.config.environ)

        return self.new_packages, self.old_packages
Ejemplo n.º 44
0
 def files_name(self, pkg, version, release):
     from pisi.util import join_path as join
     pkg_dir = join(ctx.config.lib_dir(), pkg + '-' + version + '-' + release)
     return join(pkg_dir, ctx.const.files_xml)