Ejemplo n.º 1
0
Version Popt::getVersion(const Package &p, VersionFlag vf, bool versionMustExist) {
	if(_args.empty()) {
		switch(vf) {
			case NO_DEFAULT:
				// No default, skip to the popArg call below which
				// will trigger the appropriate error.
				break;
			case INSTALLED:
				if(p.isInstalled()) {
					return p.getInstalledVersion(); // exists per definition
				}
				break; // Fall through to popArg
			case INSTALLED_OR_CURRENT:
				if(p.isInstalled()) {
					return p.getInstalledVersion(); // exists per definition
				}
				// fall through to next case
			case CURRENT:
				if(p.hasVersions()) {
					return p.getRecentVersion(); // Exists per definition
				}
				break; // Fall through to popArg
			case NONE_NEEDED:
				// Ignores versionMustExist, caller has to handle this,
				// but at least we do not return an invalid version just an empty
				// one, the caller can easily distinct them.
				return Version::EMPTY_VERSION;
		}
	}
	const Version v(popArg("missing version"));
	if(v.isEmptyVersion() || versionMustExist) {
		p.checkVersionExists(v);
	}
	return v;
}
Ejemplo n.º 2
0
void Server :: buildLocalPackages( Server *local )
{
    Package *curr;
    QListIterator<Package> it( packageList );

    QList<Package> *locallist = &local->getPackageList();

    for ( ; it.current(); ++it )
    {
        curr = it.current();
        QString name = curr->getPackageName();

        // If the package name is an ipk name, then convert the filename to a package name
        if ( name.find( ".ipk" ) != -1 )
            name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );

        if ( local )
        {
            Package *p = local->getPackage( name );
            curr->setLocalPackage( p );
            if ( p )
            {
                // Replace local version
                if ( curr->getVersion() > p->getVersion() )
                {
                    int pos = locallist->at();
                    locallist->remove( p );
                    locallist->insert( pos, curr );
                }

                // Set some default stuff like size and things
                if ( p->getInstalledVersion() == curr->getVersion() )
                {
                    p->setPackageSize( curr->getPackageSize() );
                    p->setSection( curr->getSection() );
                    p->setDescription( curr->getDescription() );
                }
            }

        }
        else
            curr->setLocalPackage( 0 );
    }

}